diff options
Diffstat (limited to 'desktop-utilities/lumina-textedit/syntaxSupport.cpp')
-rw-r--r-- | desktop-utilities/lumina-textedit/syntaxSupport.cpp | 41 |
1 files changed, 40 insertions, 1 deletions
diff --git a/desktop-utilities/lumina-textedit/syntaxSupport.cpp b/desktop-utilities/lumina-textedit/syntaxSupport.cpp index 38ca4d3f..093ca52a 100644 --- a/desktop-utilities/lumina-textedit/syntaxSupport.cpp +++ b/desktop-utilities/lumina-textedit/syntaxSupport.cpp @@ -9,7 +9,7 @@ QStringList Custom_Syntax::availableRules(){ QStringList avail; avail << "C++"; - + avail << "Python"; return avail; } @@ -61,5 +61,44 @@ void Custom_Syntax::loadRules(QString type){ srule.startPattern = QRegExp("/\\*"); srule.endPattern = QRegExp("\\*/"); splitrules << srule; + + }else if(type=="Python"){ + //Keywords + QStringList keywords; + keywords << "and" << "as" << "assert" << "break" << "class" << "continue" << "def" << "del" \ + << "elif" << "else" << "except" << "exec" << "finally" << "for" << "from" \ + << "global" << "if" << "import" << "in" << "is" << "lambda" << "not" \ + << "or" << "pass" << "print" << "raise" << "return" << "try" << "while" << "with" << "yield"; + + SyntaxRule rule; + rule.format.setForeground(Qt::darkBlue); + rule.format.setFontWeight(QFont::Bold); + for(int i=0; i<keywords.length(); i++){ + rule.pattern = QRegExp("\\b"+keywords[i]+"\\b"); //turn each keyword into a QRegExp and insert the rule + rules << rule; + } + //Class Names + //rule.format.setForeground(Qt::darkMagenta); + //rule.pattern = QRegExp("\\bQ[A-Za-z]+\\b"); + //rules << rule; + //Quotes + rule.format.setForeground(Qt::red); + rule.format.setFontWeight(QFont::Normal); + rule.pattern = QRegExp("\".*\""); + rules << rule; + //Functions + rule.format.setForeground(Qt::blue); + rule.pattern = QRegExp("\\b[A-Za-z0-9_]+(?=\\()"); + rules << rule; + //Comment (single line) + rule.format.setForeground(Qt::green); + rule.pattern = QRegExp("#[^\n]*"); + rules << rule; + //Comment (multi-line) + //SyntaxRuleSplit srule; + //srule.format = rule.format; //re-use the single-line comment format + //srule.startPattern = QRegExp("/\\*"); + //srule.endPattern = QRegExp("\\*/"); + //splitrules << srule; } }
\ No newline at end of file |