Reputation: 8222
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)
Upvotes: 3
Views: 564
Reputation: 101192
Scintilla is used in a lot of different editors. Notepad++ is one of them.
Here is a .Net wrapper: http://scintillanet.codeplex.com/
Upvotes: 2
Reputation: 10536
Not sure if you really want to write your own, I used AvalonEdit, the editor from SharpDevelop for something similar, works pretty nice. It's WPF though, you didn;t say what UI technology you're on. You can even use it in commercial software with the license.
GJ
Upvotes: 1
Reputation: 59456
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:
Upvotes: 3