[Geany] Syntax highlight revisited [was Recognising PHP code (and perhaps others)]

Timothy Boronczyk tboronczyk at xxxxx
Thu Dec 16 05:44:04 UTC 2010


There's been several problems and attempts to fix PHP syntax highlighting in
Geany. Perhaps it would be beneficial to write a small parser instead of
relying on regex pattern matching. I don't think such a parser would have to
be 100% complete... just sufficient enough to *properly* identify keywords,
function/class constructs, and maybe a few other tidbits like namespaces. I
know the desire is to keep the core code small, but a hand-written parser
should be fast and rather lightweight.

Taking it a step further would be start thinking in terms of extensions. I
don't know if it would be possible to override the internals of highlighting
and populating the function list currently, but if the code were refactored
to provide an API we could have a screen in the configuration options to
specify colors of various tokens (keywords, variables, etc). Then geany
would call out to the extension and return back a list of positions,
lengths, and token types. It can then go through and set characters
appearing at position x for length l with the color indicated by token type
t. The work would be done in the external module and geany would be able to
apply the coloring relatively easily in one pass. Then it calls out to get a
list of classes and functions and such which the extension identified while
it was parsing to populate the side list.

I'm just brainstorming here and not sure how it would work with
multi-language documents like html/javascript/php. But might be worth
discussing since this does seem to be a problem that comes up every now and
then. Thoughts?

-Tim

Timothy Boronczyk, ZCE
tboronczyk at gmail.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.geany.org/pipermail/users/attachments/20101216/10677124/attachment.html>


More information about the Users mailing list