diff options
author | Ken Moore <moorekou@gmail.com> | 2016-04-15 08:55:56 -0400 |
---|---|---|
committer | Ken Moore <moorekou@gmail.com> | 2016-04-15 08:55:56 -0400 |
commit | 34688dd91f44f225e81a36cde1e565ac06290f27 (patch) | |
tree | 9d63e54e2de52cacdb5c024d9b2173b2d96d6bcf /desktop-utilities/lumina-textedit/syntaxSupport.cpp | |
parent | Get some more of the terminal cleaned up. Now "vi" has partial support (still... (diff) | |
download | lumina-34688dd91f44f225e81a36cde1e565ac06290f27.tar.gz lumina-34688dd91f44f225e81a36cde1e565ac06290f27.tar.bz2 lumina-34688dd91f44f225e81a36cde1e565ac06290f27.zip |
Get all the C/C++/Qt syntax highlighting rules all setup. Now the last piece to implement would be bracket/perenthesis matching on cursor action.
Diffstat (limited to 'desktop-utilities/lumina-textedit/syntaxSupport.cpp')
-rw-r--r-- | desktop-utilities/lumina-textedit/syntaxSupport.cpp | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/desktop-utilities/lumina-textedit/syntaxSupport.cpp b/desktop-utilities/lumina-textedit/syntaxSupport.cpp index 27664c52..38ca4d3f 100644 --- a/desktop-utilities/lumina-textedit/syntaxSupport.cpp +++ b/desktop-utilities/lumina-textedit/syntaxSupport.cpp @@ -5,6 +5,7 @@ // See the LICENSE file for full details //=========================================== #include "syntaxSupport.h" + QStringList Custom_Syntax::availableRules(){ QStringList avail; avail << "C++"; @@ -19,8 +20,46 @@ QString Custom_Syntax::ruleForFile(QString filename){ } void Custom_Syntax::loadRules(QString type){ + //NOTE: the "multiLineComment rules.clear(); + splitrules.clear(); if(type=="C++"){ + //Keywords (standard C/C++/Qt definitions) + QStringList keywords; + keywords << "char" << "class" << "const" << "double" << "enum" << "explicit" << "friend" << "inline" \ + << "int" << "long" << "namespace" << "operator" << "private" << "protected" << "public" \ + << "short" << "signals" << "signed" << "slots" << "static" << "struct" << "template" \ + << "typedef" << "typename" << "union" << "unsigned" << "virtual" << "void" << "volatile"; + 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 |