[QScintilla] Matlab Lexer

John Swensen jpswensen at gmail.com
Wed Apr 13 18:51:26 BST 2011


On Apr 13, 2011, at 1:13 PM, Phil Thompson wrote:

> On Wed, 13 Apr 2011 11:44:11 -0400, John Swensen <jpswensen at gmail.com>
> wrote:
>> I am looking at using the QScintilla package for the editor component of
>> an IDE for GNU Octave.  I see there is a lexer for Matlab, but am
> wondering
>> if something hasn't been completed yet.  For almost every language, I
> see
>> both a Lex<NAMEOFLANGUAGE>.cpp file in the lexer directory and a
>> corresponding qscilexer<NAMEOFLANGUAGE>.cpp file in the Qt4 directory. 
>> However, there is no qscimatlab.cpp file. Do I need to create a
>> qscimatlab.cpp file, following the pattern of some of the other
> languages,
>> to have Matlab syntax support or is there some other way to get the
> Matlab
>> lexer working?  I see that the Matlab lexer is linked in by looking at
>> src/Catalogue.cpp and that when building inside Qt4 there is a
> LexMatlab.o
>> file after the build completes, but I can't figure out how to use the
>> lexer.
> 
> High-level support for lexers is added when requested - nobody has asked
> for Matlab before.
> 
> You can still use the low-level support (the high-level support mainly
> just manages the lexer configuration).
> 
> Phil

Makes sense.  I will try to get the higher level lexer class for Matlab/Octave done and contribute it back to the project.  That issue aside, I am still having problems getting QScintilla to highlight even using the low-level support.  I added the following to the constructor of the MainWindow class for the example-Qt4 project after the textEdit object has been created.

textEdit->SendScintilla (QsciScintillaBase::SCI_SETLEXERLANGUAGE, "octave");
// Also tried this, but it didn't work either
//textEdit->SendScintilla (QsciScintillaBase::SCI_SETLEXER, QsciScintillaBase::SCLEX_MATLAB);
    
textEdit->SendScintilla (QsciScintillaBase::SCI_SETKEYWORDS, "for if end");

It did not syntax highlight an m-file when I opened it.  So, I tried putting it in the loadFile() method of the MainWindow in the example, think that maybe you had to set the lexer after the file was opened.  It still didn't work.  Sorry to be such a noob, but is there something I am missing that will tell the lexer to start lexing?  I took a look at the setLexer method of the QsciScintilla class and couldn't see anything that my simple code was missing, but am clearly wrong somehow.

John


More information about the QScintilla mailing list