[Lazarus] Regex and Syntax Highlighting

João Marcelo Vaz jmsvaz at gmail.com
Tue May 25 15:18:50 CEST 2010


Hi Graeme,

Have you seen Colorer-take5 on the following URL
http://colorer.sourceforge.net/ ?

It's cited in the tutorial you pointed at
http://www.catch22.net/tuts/neatpad/18 .

João Marcelo
2010/5/25 Graeme Geldenhuys <graemeg.lists at gmail.com>

> Hi,
>
> Does anybody know of a website or article I can read about how to
> integrate regular expressions with an editor to end up with a editor
> that can handle syntax highlighting. It doesn't need to be specific to
> Object Pascal (that would be too easy and ideal). ;-)
>
> For example, mcedit (from Midnight Commander), gEdit (Gnome's default
> editor) etc all use regex to handle there syntax highlighting. What I
> would like to find out is how to use regex with an editor component.
> Both are new to me, so yes, I'm down on both counts, but I am very
> eager to learn. :-)
>
> As far as I can see, I need to find out about the following requirements:
>
>  * What events must the editor component make available (eg: OnLineDraw)
>  * how to use regular expressions with such events
>  * what if syntax highlighting spans multiple lines (eg: a multi-line
> comment in Object Pascal)
>  * syntax definition file layout. I guess I can look at gEdit's spec.
> They use XML files to define
>    each syntax highlighter. If I can piggy-back on there definition
> file, I'll instantly have a whole
>    bunch of syntax highlighters available.
>
>
> And yes I was told before that using regex for syntax highlighting is
> slow, but I think that's a matter of implementation. The editors I
> have seen and used are more that fast enough even on large files. The
> huge benefit of external (runtime) syntax highlighting via something
> like regex is that it is very simple to extend by anybody that knows
> regex. This means, no need for custom components to do syntax
> highlighting like SynEdit, no recompiling of components or
> applications etc.
>
> Anyway, this editor component will form part of a larger project I am
> working on. I already have the basics of a editor component and need
> to find out what else I need to implement for syntax highlighting to
> be possible in that editor component.
>
> Any thoughts, suggestions, pointers - any information or links to
> information would be very helpful.
>
> I found a very nice article that explains the design of an editor that
> must support Unicode and Syntax Highlighting. So far the author has
> implemented the basic editor, Unicode support, but hasn't reaching the
> part I am interested in - syntax highlighting. :-(  None the less,
> this is an interesting tutorial to read. You can find it at the
> following URL.
>
>  http://www.catch22.net/tuts/neatpad/1
>
>
> --
> Regards,
>  - Graeme -
>
>
> _______________________________________________
> fpGUI - a cross-platform Free Pascal GUI toolkit
> http://opensoft.homeip.net/fpgui/
>
> --
> _______________________________________________
> Lazarus mailing list
> Lazarus at lists.lazarus.freepascal.org
> http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lazarus-ide.org/pipermail/lazarus/attachments/20100525/7694848f/attachment-0004.html>


More information about the Lazarus mailing list