Re: [gtk-list] Re: Gtk_Text customization?



>>>>> "P" == Preben Randhol <randhol@dusken4.samfundet.ntnu.no> writes:

 P> What languages are supported. Do you make it so general that one
 P> could make highlight patterns for all kinds of programming
 P> languages? That would be great.

You specify regular expressions for start and end of comment, start
and end of string, and keywords (for now anyway). It then highlights
according to that.

E.g:

static GtkEditorHilitePatterns default_patterns =
{ "/\\*",			/* comment_start */
  "\\*/",			/* comment_end */
  "\"\\|'",			/* string_start */
  "\"\\|'",			/* string_end */
  "\\b\\(if\\|else\\|for\\|while\\)\\b" /* keywords */
};

The above are the default patterns now (I only use them for testing,
they could be changed...I don't know...). The patterns can be changed
on run time, so different language can be supported simply by
installing new regexps.

Then you specify the text attributes for each category. Rigth now I
only specify the foreground color

struct _GtkEditorHiliteColors {
  GdkColormap *cmap;
  GdkColor plain;
  GdkColor comment;
  GdkColor string;
  GdkColor keywords;
};

but there is no reason why font and background color couldn't be
specified likewise.

Perhaps it should also be possible to add new highlight categories
dynamically, but I havn't looked into that yet.

I plan to add parenthesis matching in a similar fashion, by specifying
a start and an end paranthesis string, where start and end
para. should match pairwise

e.g.

struct _Para foo = {
  "([{", /* start */
  ")]}"  /* end */
}

so that when a '(' == start[0] is inserted, the editor searches
backwards for char end[0] == ')', and highlights the two. That would
also make the para.match language independent. I haven't implemented
this yet, so this is just my thoughts.

I see no way to make indention language independend though. So I think
it would be necessary to use a callback function to calculate the
indention level or something. It will be a day or two before I start
working on this.

/mailund

-- 
| Thomas Mailund                  |            Office B2.18 at DAIMI |
| Ny Munkegade 62 3. tv.          |      Email: mailund@daimi.aau.dk |
| 8000 Aarhus, Denmark            | http://www.daimi.aau.dk/~mailund |
| Phone (+45) 21 45 13 95         |         Phone: (+45) 89 42 32 80 |



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