Detect and colourise comments in the SQL syntax highlighter

This commit is contained in:
Martin Kleusberg
2013-01-01 17:09:13 +01:00
parent 9092e7d41f
commit e33077ef8e
2 changed files with 6 additions and 7 deletions

View File

@@ -61,14 +61,17 @@ SQLiteSyntaxHighlighter::SQLiteSyntaxHighlighter(QTextDocument *parent) :
highlightingRules.append(rule);
}
quotationFormat.setForeground(Qt::darkRed);
singleLineCommentFormat.setForeground(Qt::darkGreen);
rule.pattern = QRegExp("--[^\n]*");
rule.format = singleLineCommentFormat;
highlightingRules.append(rule);
quotationFormat.setForeground(Qt::red);
rule.pattern = QRegExp("\".*\"");
rule.pattern.setMinimal(true);
rule.format = quotationFormat;
highlightingRules.append(rule);
rule.pattern = QRegExp("'.*'");
rule.pattern.setMinimal(true);
rule.format = quotationFormat;
highlightingRules.append(rule);
}

View File

@@ -25,12 +25,8 @@ private:
QVector<HighlightingRule> highlightingRules;
QVector<HighlightingRule> tableNameRules;
QRegExp commentStartExpression;
QRegExp commentEndExpression;
QTextCharFormat keywordFormat;
QTextCharFormat singleLineCommentFormat;
QTextCharFormat multiLineCommentFormat;
QTextCharFormat quotationFormat;
QTextCharFormat tableFormat;
};