Syntax Highlighting Editors and Research

Haven't posted for a while after having a lovely holiday in Majorca, its just such a shame to come home.

I've been looking for a syntax highlighting editor or any examples of how to write one for quite while with no success.

Briefly looked at the SharpDevelop for ideas but I'm keen on writing one myself. So after doing a bit more investigation I found a commercial control which is very similar to the Visual Studio .NET editor with intellisense so if you need an editor control then give this one a look in.

http://www.actiprosoftware.com/Products/DotNet/SyntaxEditor/Default.aspx

If anyone knows some good resources for syntax highlighting or any open source examples then post me a comment. Thanks

2 Comments

  • Hi,



    I am interested in the same thing. Most editors use a very simple model of highlighting, one that just seems to revolve around a huge list of keywords and "blocks" (comments, etc). To get an idea of how most (closed source) editors work it's just a matter of looking at their syntax definition files.



    At the opposite end of the scale you have Visual Assist style of highlighting, which is based on a full c++ parser.



    Lately I've been thinking that a middle ground might be in order. Something like a finite state machine model would provide utmost flexibility, without requiring a full parser for each language you support. Then you would use a simple scripting language (in .NET we have the huge advantage here :) ) to specify the states and the given colours/tokens that are associated with them.



    For example, with a comment state is fairly obvious (inputs with "/*" or "//"), but now you can trigger a move on to another state when a certain token is encountered ("TODO" could signify the need to colour this specially, as could XML comments). Adding full plugin support to your scripting language and you can now add special functionality to the state machine (picking up XML comments and storing in a database for intellisense).



    Hope that helps,

    -- Pete

  • Many editors seem to reparse the current line while you are editing.. this could also benefit from knowing what state you are in :) (see my previous post).

Comments have been disabled for this content.