Search code examples
c#.net-4.0codehighlighter

Implementing Code Highlighting


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)


Solution

  • Scintilla is used in a lot of different editors. Notepad++ is one of them.

    Here is a .Net wrapper: http://scintillanet.codeplex.com/

    enter image description here