| 334 | )EOKEYWORDS"}; |
| 335 | |
| 336 | void ConfigureSyntax(ScintillaEdit *scintilla, int language) |
| 337 | { |
| 338 | scintilla->setCodePage(SC_CP_UTF8); |
| 339 | |
| 340 | bool hlsl = false; |
| 341 | bool glsl = false; |
| 342 | int lexLang = language; |
| 343 | |
| 344 | if(lexLang == SCLEX_HLSL || lexLang == SCLEX_GLSL || lexLang == SCLEX_BUFFER) |
| 345 | lexLang = SCLEX_CPP; |
| 346 | |
| 347 | scintilla->setLexer(lexLang); |
| 348 | |
| 349 | #define SC_COL(qcol) SCINTILLA_COLOUR(qcol.red(), qcol.green(), qcol.blue()) |
| 350 | |
| 351 | // set the default style to base/text |
| 352 | QColor base = scintilla->palette().color(QPalette::Base); |
| 353 | QColor text = scintilla->palette().color(QPalette::Text); |
| 354 | scintilla->styleSetBack(STYLE_DEFAULT, SC_COL(base)); |
| 355 | scintilla->styleSetFore(STYLE_DEFAULT, SC_COL(text)); |
| 356 | |
| 357 | scintilla->setCaretFore(SC_COL(text)); |
| 358 | |
| 359 | // default all lexer styles up to STYLE_DEFAULT as the same, then override per-colour below |
| 360 | for(sptr_t i = 0; i < STYLE_DEFAULT; i++) |
| 361 | { |
| 362 | scintilla->styleSetBack(i, SC_COL(base)); |
| 363 | scintilla->styleSetFore(i, SC_COL(text)); |
| 364 | } |
| 365 | |
| 366 | // set highlight text colour |
| 367 | QColor highlight = scintilla->palette().color(QPalette::Highlight); |
| 368 | QColor highlightedText = scintilla->palette().color(QPalette::HighlightedText); |
| 369 | scintilla->setSelBack(true, SC_COL(highlight)); |
| 370 | scintilla->setSelFore(true, SC_COL(highlightedText)); |
| 371 | |
| 372 | // set margin colours |
| 373 | QColor window = scintilla->palette().color(QPalette::Window); |
| 374 | QColor windowText = scintilla->palette().color(QPalette::WindowText); |
| 375 | for(sptr_t i = 0; i < 5; i++) |
| 376 | scintilla->setMarginBackN(i, SC_COL(window)); |
| 377 | scintilla->styleSetBack(STYLE_LINENUMBER, SC_COL(window)); |
| 378 | scintilla->styleSetFore(STYLE_LINENUMBER, SC_COL(windowText)); |
| 379 | |
| 380 | sptr_t blue = IsDarkTheme() ? SCINTILLA_COLOUR(105, 105, 255) : SCINTILLA_COLOUR(0, 0, 150); |
| 381 | sptr_t magenta = IsDarkTheme() ? SCINTILLA_COLOUR(255, 105, 255) : SCINTILLA_COLOUR(150, 0, 150); |
| 382 | sptr_t rouge = IsDarkTheme() ? SCINTILLA_COLOUR(255, 150, 150) : SCINTILLA_COLOUR(175, 70, 70); |
| 383 | |
| 384 | // works for either dark or light |
| 385 | sptr_t green = SCINTILLA_COLOUR(0, 150, 0); |
| 386 | sptr_t teal = SCINTILLA_COLOUR(0, 150, 150); |
| 387 | sptr_t olive = SCINTILLA_COLOUR(150, 150, 0); |
| 388 | |
| 389 | if(lexLang == SCLEX_CPP) |
| 390 | { |
| 391 | scintilla->setProperty("lexer.cpp.track.preprocessor", "0"); |
| 392 | scintilla->setProperty("styling.within.preprocessor", "1"); |
| 393 | |