From 3e7dd153008d268cd79bc4e5bd70d9d9874511a6 Mon Sep 17 00:00:00 2001 From: baldurk Date: Tue, 18 Apr 2017 13:48:07 +0100 Subject: [PATCH] Add simple python syntax highlighting --- qrenderdoc/Code/ScintillaSyntax.cpp | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/qrenderdoc/Code/ScintillaSyntax.cpp b/qrenderdoc/Code/ScintillaSyntax.cpp index 3d4ddeedb..81abe23f9 100644 --- a/qrenderdoc/Code/ScintillaSyntax.cpp +++ b/qrenderdoc/Code/ScintillaSyntax.cpp @@ -26,6 +26,10 @@ #include "3rdparty/scintilla/include/SciLexer.h" #include "3rdparty/scintilla/include/qt/ScintillaEdit.h" +static const char *python_keywords = + "False None True and as assert break class continue def del elif else except finally for from " + "global if import in is lambda nonlocal not or pass raise return try while with yield"; + static const char *hlsl_keywords[2] = { // keyword set 0: // Secondary keywords and identifiers @@ -262,4 +266,23 @@ void ConfigureSyntax(ScintillaEdit *scintilla, int language) scintilla->setKeyWords(1, glsl_keywords[1]); } } + else if(language == SCLEX_PYTHON) + { + scintilla->setProperty("tab.timmy.whinge.level", "1"); + scintilla->setProperty("fold", "1"); + + scintilla->setKeyWords(0, python_keywords); + + scintilla->styleSetFore(SCE_P_COMMENTLINE, SCINTILLA_COLOUR(0, 150, 0)); + scintilla->styleSetFore(SCE_P_COMMENTBLOCK, SCINTILLA_COLOUR(0, 150, 0)); + scintilla->styleSetFore(SCE_P_NUMBER, SCINTILLA_COLOUR(0, 150, 150)); + scintilla->styleSetFore(SCE_P_STRING, SCINTILLA_COLOUR(150, 0, 150)); + scintilla->styleSetFore(SCE_P_CHARACTER, SCINTILLA_COLOUR(150, 0, 150)); + scintilla->styleSetFore(SCE_P_DEFNAME, SCINTILLA_COLOUR(150, 150, 0)); + scintilla->styleSetFore(SCE_P_CLASSNAME, SCINTILLA_COLOUR(150, 0, 150)); + scintilla->styleSetFore(SCE_P_WORD, SCINTILLA_COLOUR(0, 0, 150)); + scintilla->styleSetFore(SCE_P_WORD2, SCINTILLA_COLOUR(0, 0, 150)); + scintilla->styleSetBold(SCE_P_WORD, true); + scintilla->styleSetBold(SCE_P_WORD2, true); + } }