[Geany] more info on syntax highlighting

Alexandre Moreira alexandream at xxxxx
Mon Jul 31 15:51:01 UTC 2006


2006/7/28, John Gabriele <jmg3000 at gmail.com>:
> 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.

I'd like to add a few thoughts here for I think this is an area where Geany will
receive a few complaints when it gets to be more widely used (which we all
hope will be soon enough, I guess).

Geany has as of now one of the hardest ways of adding syntax highlighting
schemes: it relies on the guy who compiles the source to add it at compile time
(please correct me if I am wrong) which makes end-user customization quite
hard.

I know our target audience is made of developpers but, being a
developer myself I
know there are some among us that are not gentooers nor slackers and just prefer
sticking with the software in their distro's repositories when it is available.

That being so, I still see the advantage of having our existing
system. It really gives us very powerful and fast highlighting
schemes. Wouldn't it be possible to have an alternative way ? Having
compiled support for some languages, and one "language-agnostic" lexer
that just read a highlighting scheme for the language in question (if
it exists) and does the job of a less-powerful-and-not-so-fast lexer
for that language, just to add the ability for the users to create
lexers without having to write a full lexer ?

I take it for the number of syntax highlighting schemes we have on Vim
and, while I'm not saying that is just because of it, it has an easier
method to write syntax schemes without the need to learn C or C++.

What do you say ? is that possible ? is it easy to integrate with
existing code ? I can think of a system that integrates this, but I
don't know how the existing code does it... nor I have the skills to
deal with those language parsing techniques without having to re-learn
a lot of it... (all I know is what I needed to make a compiler in
college, a couple years ago, and I used flex + bison, which made my
job a lot easier)

Not saying that we "need" this... just checking the possibility.

Regards,
Alexandre Moreira.

PS: I would like to add that, while I think it is a good feature to
have, it is *obviously* (at least in my opinion) going to wait until a
point after 1.0, for it would probably break much of the existing code
to have it.

>
> 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
> _______________________________________________
> Geany mailing list
> Geany at uvena.de
> http://uvena.de/cgi-bin/mailman/listinfo/geany
>



More information about the Users mailing list