I have a stack oriented programming language that I need to write a very simple editor for, with code highlighting. It would be preferable to do such with a RichTextBox
I have seen many code highlighting samples and demos, and nearly all of them require the entire RichTextBox to be refreshed OnTextChanged. This works for smaller code files, and even with slightly larger ones, if the scrollbar is correctly re-positioned, but the bigger the file gets, the greater the lag when trying to edit.
There's got to be a better way. Obviously, Visual Studio does it flawlessly...
So, what method should I use?
(Pseudocode or even just a general concept layout is fine for an answer)
I strongly recommend you to use the open-source ICSharpCode.TextEditor. This is a very rich text editor with support for customizable syntax highlighting and even intellisense. Among other features like line-numbers, error-highlighting, error-hinting, code-block-collapse and etc.
Examples of applications that use it are:
Scintilla is used in a lot of different editors. Notepad++ is one of them.
Here is a .Net wrapper: http://scintillanet.codeplex.com/

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With