Re: No colourisation with Qt
"'seasoned_geek' via scintilla-interest" <[email protected]>
| Newsgroups | gmane.comp.lib.scintilla.devel |
|---|---|
| Message-ID | <[email protected]> |
If you haven't found your answer yet, you may wish to look at Example 5 for CsScintilla. https://sourceforge.net/p/csscintilla/csscintilla/ci/default/tree/copperspice_examples/Example5/src/ Yes, it is using CopperSpice and a CopperSpice port of Scintilla, but there aren't a lot of "Hello World!" type examples for Scintilla anymore. The SCiTE text editor was that, but now it is the test bed for everything so a bit difficult to find the tree for the forest. On Thursday, June 6, 2024 at 5:43:19 PM UTC-5 [email protected] wrote: > 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/6f2b9c15-aa85-4a81-a3df-96e0aba027den%40googlegroups.com.