Colorizer is slow
Colorizer uses std::regex, but it is too slow for that amount of work. Not to mention it is not optimized to scan multiple expressions at once. It is necessary to replace it with a proper lexical scanner (like RE/Flex).
Have you considered making the colorization rely on an interface (kind of like how ImGui combo boxes use a getter function to get the items)? I have a context-sensitive language with a parser already wired up, so I can answer queries like "What's the next text span and what color should it be" relatively fast.
Aside from helping me, this might also be a cleaner way to separate these two parts. I'd love to integrate this into my project!
BTW, this would also enable highlighting based on criteria other than keywords, which I want to use for a live script profiler.
Yes, I have. It would make it much more flexible to use any kind of colorizer. I only need a bit bigger chunk of time to do that....
@sherief This pull request does pretty much what you suggested, https://github.com/BalazsJako/ImGuiColorTextEdit/pull/44. It adds a callback function which return true/false and when true the begin and end location of the identified text + the color ('palette index') for the given text.
The above PR has now been integrated. It only speeds up C++ syntax coloring for now, although other languages would be relatively easy to support. If you want to contribute for one of the other language definitions, please do! I will soon start working on accelerating HLSL.