From f123b66dccf1f1c0f7ba23d473448d1c6989196e Mon Sep 17 00:00:00 2001 From: Ken Moore Date: Thu, 21 Apr 2016 08:43:41 -0400 Subject: Another minor change to lumina-textedit: Add a "preprocessor" syntax color, and add preprocessor line highlighting to C+++ syntax rules. Also ensure that the defined colors are always up to date, even if a new color is added at some later version. --- .../lumina-textedit/syntaxSupport.cpp | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) (limited to 'desktop-utilities/lumina-textedit/syntaxSupport.cpp') diff --git a/desktop-utilities/lumina-textedit/syntaxSupport.cpp b/desktop-utilities/lumina-textedit/syntaxSupport.cpp index a5b07f5d..617cebae 100644 --- a/desktop-utilities/lumina-textedit/syntaxSupport.cpp +++ b/desktop-utilities/lumina-textedit/syntaxSupport.cpp @@ -25,15 +25,15 @@ QStringList Custom_Syntax::knownColors(){ } void Custom_Syntax::SetupDefaultColors(QSettings *settings){ - if(settings->contains("colors/keyword")){ return; } //already has color info - settings->setValue("colors/keyword", QColor(Qt::blue).name() ); - settings->setValue("colors/altkeyword", QColor(Qt::darkBlue).name() ); - settings->setValue("colors/class", QColor(Qt::darkRed).name() ); - settings->setValue("colors/text", QColor(Qt::darkMagenta).name() ); - settings->setValue("colors/function", QColor(Qt::darkCyan).name() ); - settings->setValue("colors/comment", QColor(Qt::darkGreen).name() ); - settings->setValue("colors/bracket-found", QColor(Qt::green).name() ); - settings->setValue("colors/bracket-missing", QColor(Qt::red).name() ); + if(!settings->contains("colors/keyword")){settings->setValue("colors/keyword", QColor(Qt::blue).name() ); } + if(!settings->contains("colors/altkeyword")){settings->setValue("colors/altkeyword", QColor(Qt::darkBlue).name() ); } + if(!settings->contains("colors/class")){settings->setValue("colors/class", QColor(Qt::darkRed).name() ); } + if(!settings->contains("colors/text")){settings->setValue("colors/text", QColor(Qt::darkMagenta).name() ); } + if(!settings->contains("colors/function")){settings->setValue("colors/function", QColor(Qt::darkCyan).name() ); } + if(!settings->contains("colors/comment")){settings->setValue("colors/comment", QColor(Qt::darkGreen).name() ); } + if(!settings->contains("colors/bracket-found")){settings->setValue("colors/bracket-found", QColor(Qt::green).name() ); } + if(!settings->contains("colors/bracket-missing")){settings->setValue("colors/bracket-missing", QColor(Qt::red).name() ); } + if(!settings->contains("colors/preprocessor")){settings->setValue("colors/preprocessor", QColor(Qt::darkYellow).name() ); } } QString Custom_Syntax::ruleForFile(QString filename){ @@ -77,6 +77,10 @@ void Custom_Syntax::loadRules(QString type){ rule.format.setForeground( QColor(settings->value("colors/function").toString()) ); rule.pattern = QRegExp("\\b[A-Za-z0-9_]+(?=\\()"); rules << rule; + //Proprocessor commands + rule.format.setForeground( QColor(settings->value("colors/preprocessor").toString()) ); + rule.pattern = QRegExp("^#[^\n]*"); + rules << rule; //Comment (single line) rule.format.setForeground( QColor(settings->value("colors/comment").toString()) ); rule.pattern = QRegExp("//[^\n]*"); -- cgit