[Geany] more info on syntax highlighting

John Gabriele jmg3000 at xxxxx
Fri Jul 28 20:59:48 UTC 2006


On 7/28/06, Enrico Tröger <enrico.troeger at uvena.de> wrote:
> On Fri, 28 Jul 2006 14:34:14 -0400, "John Gabriele" <jmg3000 at gmail.com>
> wrote:
>
> [snip]
>
> > see Crontab listed in the menu items, even though there's a
> > LexCrontab.cxx file for it. (Hm . . . incidentally, LexOMS.cxx &
>
> Why should we support all lexers of Scintilla? Crontab is a filetype I
> didn't include in Geany. If someone is there who really wants it, we
> can include it.

Sorry -- I didn't mean to imply that Geany should support every
possible filetype out there. I was just trying to understand the
relationship between the Scintilla lex files and the languages that
Geany supports, and mentioned LexCrontab.cxx just because it caught my
eye. I don't currently need crontab syntax highlighting.

> > What is the correspondence between those Lex*.cxx files and the geany
> > menu items in "Document --> Set filetype"?
>
> See src/highlighting.c, every defined filetype(with two or three
> exceptions) of Geany has two functions in this file, where the Scintilla
> lexer for this filetype is set.

Check.

> > Can I easily create a new syntax highlighting patterns such that a new
> > menu item will show up in "Document --> set filetype"? I already tried
> > copying (from $prefix/share/geany to ~/.geany/filedefs), renaming, and
> > modifying an existing one, but it doesn't work, and my guess is that I
> > first need a scintilla Lex*.cxx file . . . .
>
> Not really. To create a new filetype, many changes are needed. Maybe
> this will change in the future but it will be a lot of hard work.

Two editors I have some experience using are NEdit and GNU nano.

They both just use regexes to syntax highlight. NEdit's system is
pretty fancy, and does a good job, from what I can tell. nano's system
is very simple. You just write a few regexes with a color value, and
when it sees that pattern in the buffer, it colors it. This system has
the great benefit that anyone can quickly chuck together syntax
highlighting for any oddball file they need to edit. The drawback is,
you quickly find that a bushel of regexes is not the same thing as a
real lexer. :) So, it's not always easy to get the patterns right, and
complex ones are very difficult, but it works pretty well for simple
ones.

So, anyway, I guess the strength of the Scintilla/Geany syntax
highlighting engine is that you get really high-quality and fast
highlighting, but you have to work more for it.

> At the moment, the first step is to edit src/filetypes.c and its header
> file, then editing src/highlighting.c and a few other things. Maybe,
> the easier way is to send me as much information(esp. sample files)
> about the filetype as you can and I will add it because I know where I
> have to add something ;-).
> Of course, if you really want to hack it on yourself, I will help you.

Thanks. For now though, since these files I need to work with are
quite simple, I'll just use nano and write 2 or 3 patterns for them
(basically just enough to highlight the comments at least).

Hm . . . I just noticed that GtkSourceView
http://gtksourceview.sourceforge.net/ uses their own XML ".lang" files
(see http://gtksourceview.sourceforge.net/docs.html) for this. Looks
like they use regexes too. Heh -- regexen plus xml in the same file.
:) Easier than writing a C++ module plus editing src/filetypes.c, etc.
But, again, my hunch is that it's probably not as good nor as fast as
the current scintilla setup (just my guess though).

>
> Have a nice weekend, I'm on the way getting out ;-).

Will do! :)
---John



More information about the Users mailing list