No colourisation with Qt

"'Alexander Sorokin' via scintilla-interest" <[email protected]>
Newsgroups gmane.comp.lib.scintilla.devel
Message-ID <[email protected]>
I am setting CPP lexer to Scintilla but there is no colourisation. Tried in 
Windows and Ubuntu. Result is the same. What am I doing wrong?

Code reports that lexer is set. Tried setting text after setting lexer - 
not working too.

MainWindow::MainWindow(QWidget *parent)
    : QMainWindow(parent)
    , ui(new Ui::MainWindow)
{
    ui->setupUi(this);

    scintilla = new ScintillaEdit(this);

    scintilla->setText("#include \"mainwindow.h\"\r\n\
\r\n\
#include <QApplication>\r\n\
\r\n\
int main(int argc, char *argv[])\r\n\
{\r\n\
    QApplication a(argc, argv);\r\n\
    MainWindow w;\r\n\
    w.show();\r\n\
    return a.exec();\r\n\
}\r\n\
\r\n\
");
#if _WIN32
    typedef void *(__stdcall *CreateLexerFn)(const char *name);
    typedef int (__stdcall *GetLexerCountFn)();
    typedef void (__stdcall *GetLexerNameFn)(unsigned int index, char 
*name, int buflength);
#else
    typedef void *(*CreateLexerFn)(const char *name);
    typedef int (*GetLexerCountFn)();
    typedef void (*GetLexerNameFn)(unsigned int index, char *name, int 
buflength);
#endif
    QFunctionPointer fn = QLibrary::resolve("lexilla", "GetLexerCount");
    int lexCount = ((GetLexerCountFn)fn)();
    qDebug() << "Lexer count =" << lexCount;
    if (lexCount > 0) {
        fn = QLibrary::resolve("lexilla", "GetLexerName");
        for (int i = 0; i < lexCount; i++) {
            char name[100] = "";
            ((GetLexerNameFn)fn)(i, name, sizeof(name));
            qDebug() << name;
        }

        fn = QLibrary::resolve("lexilla", "CreateLexer");
        void *lexCpp = ((CreateLexerFn)fn)("cpp");
        if (lexCpp != NULL) {
            qDebug() << "cpp lexer created.";
            sptr_t old_lexer = scintilla->lexer();
            scintilla->setILexer((sptr_t)(void *)lexCpp);

            sptr_t new_lexer = scintilla->lexer();
            if (new_lexer == old_lexer) {
                qDebug() << "Lexer is not set!";
            }
            else {
                qDebug() << scintilla->lexerLanguage() << "lexer set!";
            }
        }
        else {
            qDebug() << "Lexer is NULL!";
        }
    }

    setCentralWidget(scintilla);

    scintilla->colourise(0, -1);
}

-- 
You received this message because you are subscribed to the Google Groups "scintilla-interest" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [email protected].
To view this discussion on the web visit https://groups.google.com/d/msgid/scintilla-interest/8fd90231-cc74-40d5-967d-809970cc951an%40googlegroups.com.
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.