I'm currently developing a very simple app with very basic syntax highlighting in a RichTextBox.
It works almost fine. What I'm doing is:
- Lookup a list of predefined regex if one or more matches.
- Select the match, applying the right style to the selection.
- Then replace the cursor where it initially was.
This method gets triggered on every KeyUp event. And it makes a LOT of flickering.
So my question is: how could I subtly highlight the text that I type without any flickering? This editor will never contain thousands lines of text, maybe about a hundred max so I don't need any very optimized solution yet.
I tried some of the solutions proposed on other posts, but nothing interesting worked. And I don't want to use another component from another library -- I wanted to do it myself for learning purposes.