Re: Syntax Highlighting Text Widgets





On Wed, 01 Mar 2000 05:34:07 Matthew wrote:
> 
> I'm an author in a project that could make use of one of the syntax
> highlighting text widgets.  So I ask you, my peers, which one is
> the best?  My needs are pretty basic:

The best?  Oh, I won't touch that one...
 
>   I want to compile it in, so no library.
>   Neat and Simple are better than fast.
>   No deps other than Gtk/glib/glibc2.
 
> If you've tinkered with the various offerings, I'd appreciate a candid 
answer. 
> Feel free to e-mail me if you do not want to offend one of the authors.

I'm biased here, since I'm the author of gtkeditor, nevertheless I'll
use this opportunity to do my sales pitch...we've redesigned and
reimplemented our editor widget durring the last month or so, so I
don't think there's that many other around who's got any experience
with the new design.  The tools using gtkeditor right now, use a
version that is close to a year old by now.  Anyway...

GtkEditor is a very flexible editor.  Highlighting is configured using
regular expressions (in earlier version gnu-regex, now we use flex).
You can specify either 'patterns' or 'blocks'.  The 'patterns' are
simple regexs such as "[a-zA-Z][a-zA-Z0-9]*[ \t]*(" for a C function.
The 'blocks' are, well, blocks of syntax, anything with a 'start' and
'end' pattern such as C-comments ("/\*","\*/") or strings ("\"","\"").
Blocks allows you to change the highlighting rules, e.g., in comments
you don't want to highlight 'return' as a keyword, but you might want
to highlight anything between a '@' and ';' when you're writing
javadoc-like comments.  You don't want to highlight such keywords
outside the comments.  Blocks can be nested, based on precedence
levels.

Highlighting is done using a dynamically loaded scanner, so you can
create a bunch of those and (re-)use them in different widgets.  The
editor code provides functions for creating these scanners, but you
can also code them by hand if you want to do something particularly
clever.

We are currently adding a plugin mechanism that will allow almost any
kind of configuration, making the gtkeditor even more configurable.

The only requirements for GtkEditor is a vanilla installation of GTK+.
This differs from earlier versions of GtkEditor. We use gtktext as a
basis widget[1], but will adopt the new text widget as soon as we get
an official replacement.

The distribution _does_ create a library, but it is very small, and
there should be no problem linking it in statically.

The major disadvantage with GtkEditor, as I see it, is that we're in
the middle of a redesign, which puts the API in a bit of flux.  It
won't be stable until a 0.2.0 release.  On the other hand, this is the
opportunity to tailor the editor to your needs :) I don't think the
highlighting API will change much though.  We're pretty satisfied with
it as it is.

You can read more about it at <URL:http://gtkeditor.sourceforge.net>.

    /mailund


[1] We use gtktext as basis widget, but we might add options for
    useing other text widgets.  We require very little of the text
    widget we use.  We need 'insert' and 'delete' signals (present in
    any derivative of gtkeditable) and functions to insert text with
    properties such as font and/or colour[2] and delete text again.

[2] Not necessarily both diffent fonts _and_ colours.  We just need
    _something_ for "highlighting" to make sense ;)





[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]