| James Wilkins 2005-10-13, 3:56 am |
| I don't know if this will interest anyone here, but I got some very
basic syntax highlighting for Dylan working in gtksourceview. This
package does syntax highlighting for various programs; I'm using Gnome's
gedit at the moment.
Hopefully no one has done this already. The only information I could
find on syntax highlighting was for emacs, vi, or xcode.
Between my minimal knowledge of Dylan and lack of skill at writing
regular expressions, I'm pretty sure that the highlighting is incomplete
and outright wrong in many cases. If anyone else wants to correct or
extend the XML definition file I'd much appreciate it. That said, even
what I have so far looks a lot better to me than mono-colored text.
Here's a screen shot: http://notzero.net/misc/dylan-highlight.png .
These instructions apply to making this work on Linux, using a recent
version of Gnome.
The file: http://notzero.net/misc/dylan.lang
Copy this file to either ~/.gnome2/gtksourceview-1.0/language-spec/ ,
or to /usr/share/gtksourceview-1.0/language-spec/ .
This is an XML file which gtksourceview uses to determine how to do
syntax highlighting. It's pretty simple, but I couldn't find any
documentation on the format. I instead looked at the files for other
languages and took a guess at how things should work. There are lots of
examples in /usr/share/gtksourceview-1.0/language-spec/.
To make everything work automatically, it is also necessary to define a
MIME type for Dylan source files. How to do this was also not as well
documented as it could have been. It seems that Gnome recently switched
from using their own method of handling MIME types, over to
freedesktop.org's method. I didn't discover this until after a lot of
time spent modifying the old configuration files and wondering why it
was having no effect.
The file: http://notzero.net/misc/dylan.xml
Copy this file into /usr/share/mime/packages/, run update-mime-types,
and there now exists a "text/x-dylan" type which will associate with all
*.dylan files.
At this point, any editor using gtksourceview which opens a dylan file
should display highlighted source.
I hope that someone finds this to be of use. Even better would be if
someone likes it enough to fix my messed up dylan.lang file. :)
- Jim Wilkins
|