[.net] Syntax highlighting controls?

Started by
7 comments, last by doynax 18 years, 4 months ago
I'm developing a little Z80 IDE, and one of the requirements I've had is syntax highlighting. Unfortunately, this has proved a major speed issue, so I'm wondering if anyone has found a decent free control that is fast and non-buggy. Most of the ones I've found do some magic with the RichTextBox but are full of bugs or painfully slow. The commercial ones are way out of my budget for my little free tool.

[Website] [+++ Divide By Cucumber Error. Please Reinstall Universe And Reboot +++]

Advertisement
have you looked at Scintilla? There is a .NET wrapper of it that is used by the Scide Project but I have never used so have no idea what it is like. It's released under the MIT license which is pretty lax...

It might be a bit overkill for what you want though...
RTF is a lot like HTML, maybe you could use the RTF control and edit the RTF manually instead of using the "select text->set color->unselect text" process that most of those free controls use.

I know, I've tried setting it up myself before, and it is a pain in the ass. I've thought about just scrapping the text controls all together and writing one from scratch off of the generic System.Windows.Forms.Control class and handling all the events and painting myself. Not fun.

[Formerly "capn_midnight". See some of my projects. Find me on twitter tumblr G+ Github.]

Although there isn't explicitly a syntax highlighting control, another site you should check out is Lutz Roeder's .NET controls. He has a very nice command bar control as well as a WYSIWYG HTML editor control. Could become useful, someday. But definately use that CommandBar control....
Rob Loach [Website] [Projects] [Contact]
Alright, I gave up and wrote my own from scratch. I was already doing a text-to-RTF conversion as capn_midnight suggested, but now track the cursor position and extract and change the SelectedText and SelectedRTF properties (locking the window handle of course to eliminate flickering).

[Website] [+++ Divide By Cucumber Error. Please Reinstall Universe And Reboot +++]

Is there any chance of you will be releasing this control? I know there are a lot of people in need of such user control.
You should never let your fears become the boundaries of your dreams.
Quote:Original post by _DarkWIng_
Is there any chance of you will be releasing this control? I know there are a lot of people in need of such user control.
It has a few bugs of its own (files > 3000 lines jump the scroll bar to the wrong position - Win32 limitation, I assume) and is still not incredibly fast (5 seconds to load a 2000 line file now) and it's not very well designed in terms of being used as an external control (not adding any seperator characters causes it to delete any source you put in it). Probably not in other words, unless you wanted to tweak it yourself.

EDIT: as a "try before you buy", download this and unzip it, then unzip this on top of it (the second file is an update). If you open one of the sample projects (in the Projects folder), hit Ctrl+Space to see the awesome slowness, or open ti83plus.inc for another demo. [sad]

[Website] [+++ Divide By Cucumber Error. Please Reinstall Universe And Reboot +++]

I've been using the rich text control myself...

to give you an idea of what I've managed:

older pic (more complex shader) and a newer pic.

There has definitly been a number of things I've learnt... but a few big ones:

make sure you are only reparsing as little as possilbe :P this is hard but hopfully obvious.
Colour only areas that have changed if typing. if you insert text yourself, you will need to recolour everything.
The big one however, is to overload the 'Text' property of the RTF class with your own variation that does some caching. the Text reconstructs the text in the RTF every single time you call it, it's *really* slow.

The source isn't avaliable just yet, and it ain't pretty eiether..


of course the *vast* majority of the work there was the parser... Oooo boyo that code can get interesting. (yeah I kinda decided to write my own shader fragment format... o well)
Quote:Original post by RipTorn
of course the *vast* majority of the work there was the parser... Oooo boyo that code can get interesting. (yeah I kinda decided to write my own shader fragment format... o well)
True, but parsing itsn't a problem in this case since there are no dependencies between the lines. At least not unless he's using some weird assembler..

This topic is closed to new replies.

Advertisement