GNOME Bugzilla – Bug 136812
Add a Matlab syntax highlightning to the GtkSourceView
Last modified: 2005-12-31 15:26:45 UTC
The GEdit doesn't colour Matlab files.
Moving the product to gtksourceview. (To get the syntax highlighting you would have to create a matlab.lang file)
I'm currently working on a lang file for MatLab M-files. I've just began so expect a some time before a full (i'll try my best) inclusion of all matlab syntax.
Created attachment 26796 [details] [review] Beginnings of MATLAB M-file language spec. Comments?
The comment "for now" is there only so that highlighting works on the m-file i'm using as a test base. I'll move those functions to their own categories, like the others, in the future.
That is just great. I have some ideas about, but I'm happy that matlab syntax is reality :) I couldn't do that from scratch, because I didn't know how. Now I can modify the specs myself. I think that copying color scheme from original matlab's editor would be helpfull. Comments should be default green (dark) or maybe ligth gray (like coments). Keywords like for, if, end should be blue (0000FF) and so on. I'm very thankfull for this work. By the way, I have one question? Is that posibility to use gedit or another editor using gtksourceview as matlab IDE? It is to add scripts or somethink else for matlab programs debugging. Matlab's command window itself has that possibility: Debugging commands. dbstop - Set breakpoint. dbclear - Remove breakpoint. dbcont - Resume execution. dbdown - Change local workspace context. dbmex - Enable MEX-file debugging. dbstack - List who called whom. dbstatus - List all breakpoints. dbstep - Execute one or more lines. dbtype - List M-file with line numbers. dbup - Change local workspace context. dbquit - Quit debug mode. but Matlab's GUI (using Java VM) is horrible. The mouse scroll doesn't work, GUI crasher quite often, etc. I think of using external editor (Anjuta ???) as matlab's gui, but don't know how to debug programs.
>I'm happy that matlab syntax is reality :) Glad you like it :) >I think that copying color scheme from original matlab's editor would be helpfull. I'd love to do this as default but I'm unsure how to accomplish this from the spec file. I started by using another spec file as a template so I'll have to look into it. >Is that posibility to use gedit or another editor using gtksourceview as matlab IDE? I'm not sure about all programs that use gtksourceview but gedit has a plugin system which could allow you to make calls to the matlab binary and use gedit's shell output plugin (not sure if plugin interoperability is possible) to display what matlab has returned. MonoDevelop, a C# IDE, uses gtksourceview and has a plugin system, as well. I'm not familiar with either source-wise nor am I a well enough rounded programmer to tackle modifying the sources to do what your looking for.
I'll try it (Mono Develop or gedit plugins) in spare time (what is spare time? :). Thanks for all, tell me if I could help in somethink. I'm not a programmer, but I know C and Matlab and use them to do some numerical research and algorithm developing.
Created attachment 27661 [details] [review] M-file language spec with all functions
I realized that categorizing the functions is quite cumbersome so I just created a flat list of all functions and made them the "Keyword" style. Later i'll filter out the constants (e.g., i, j, and pi) and add the following elements: Arithmetic Operators + - * / \ ^ ' Relational Operators < > <= >= == ~= Logical Operators, Element-wise & | ~ Logical Operators, Short-circuit && || Special Characters [ ] ( ) {} = ' . ... , ; % ! btw, spare time == leisure
I have a questions about your m.lang file: - Why do you want to highlight all the Matlab functions? I think it is enough to highlight the keywords of the language (like if, else, etc) and eventually operators and numbers. - Why have you split the list of functions in several keyword lists? IIRC, gtksourceview automatically makes this operation for you (to avoid a regex bug).
- Hmm. I never thought of just highlighting keywords. To be honest, I really like the colors ;-) - GtkSourceView-WARNING **: Only the first 250 elements will be highlighted. See bug #110991 for further details.
*** Bug 305925 has been marked as a duplicate of this bug. ***
A related GNU Octave lang file [http://bugzilla.gnome.org/show_bug.cgi?id=307452]. GNU Octave is a matlab clone, and implements MATLAB language. I think they might share a MIME type if we ask gnome-vfs folks to add it to their default gnome.mime. octave.lang implements basics. I think my octave.lang is more complete, [derived from other .lang files ofcourse, not my own work all of it], and works well. I hope we add octave.lang over m.lang as octave.lang has: %, # as comment lines [default in Octave] 'string' & "string" delimiters for STrings. A lesser and 'builtin' function + keyword lists. Not the whole thing, as I mean. Thanks Muthu
It seems the best .lang file we have is the søren's one attached to bug #307452 (that is a duplicate of bug #170604). Marking this one as a duplicate of bug #170604. *** This bug has been marked as a duplicate of 170604 ***