Hi,
I've got some files in an older defunct scripting language that I'd like to edit, but I want to at least have some basic syntax highlighting for it.
I just had a look at the "Filetype definition files" section of the manual (http://geany.uvena.de/manual/ch03s09.html).
Also, I also see that there only *seems* to be only 16 scintilla filetypes available:
.../src/geany/scintilla$ ls -1 Lex*.cxx LexAsm.cxx LexBash.cxx LexCaml.cxx LexConf.cxx LexCPP.cxx LexCrontab.cxx LexCSS.cxx LexHTML.cxx LexOMS.cxx LexOthers.cxx LexPascal.cxx LexPerl.cxx LexPython.cxx LexRuby.cxx LexSQL.cxx LexTCL.cxx
(well, maybe a couple more since LexOthers.cxx contains a few), however in geany: "Document --> Set filetype" I see a number of languages listed there that don't seem to be represented by Lex*.cxx files, such as "D" (and maybe "O-Matrix" (?)). Furthermore, I don't see Crontab listed in the menu items, even though there's a LexCrontab.cxx file for it. (Hm . . . incidentally, LexOMS.cxx & LexBash.cxx look almost identical.)
What is the correspondence between those Lex*.cxx files and the geany menu items in "Document --> Set filetype"?
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 . . . .
Thanks, ---John
On Fri, 28 Jul 2006 14:34:14 -0400, "John Gabriele" jmg3000@gmail.com wrote:
Hi,
I've got some files in an older defunct scripting language that I'd like to edit, but I want to at least have some basic syntax highlighting for it.
Also, I also see that there only *seems* to be only 16 scintilla filetypes available:
Yes and no. Geany doesn't use all available lexers provided by Scintilla. It uses only these which are needed for the filetypes supported by Geany.
(well, maybe a couple more since LexOthers.cxx contains a few), however in geany: "Document --> Set filetype" I see a number of languages listed there that don't seem to be represented by Lex*.cxx files, such as "D" (and maybe "O-Matrix" (?)). Furthermore, I don't
D, Java, C++ and C are highlighted by the C++ lexer LexCpp. O-Matrix has its own lexer, LexOMS. LexOMS is not provided by Scintilla, I derived it from LexBash, therefore the similarities ;-).
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.
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.
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. 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.
Have a nice weekend, I'm on the way getting out ;-).
Regards, Enrico
P.S.: one note on OMS: Some time ago, someone from http://www.omatrix.com/ asked me to create a filetype for their language. So I did and it is the OMS filetype. But he didn't answered my last mails since months, so I'm thinking about to remove this filetype because I think nobody use it.
-- Get my GPG key from http://www.uvena.de/pub.key
On 7/28/06, Enrico Tröger enrico.troeger@uvena.de wrote:
On Fri, 28 Jul 2006 14:34:14 -0400, "John Gabriele" jmg3000@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
2006/7/28, John Gabriele jmg3000@gmail.com:
On 7/28/06, Enrico Tröger enrico.troeger@uvena.de wrote:
On Fri, 28 Jul 2006 14:34:14 -0400, "John Gabriele" jmg3000@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@uvena.de http://uvena.de/cgi-bin/mailman/listinfo/geany