summaryrefslogtreecommitdiff
path: root/utils/wpseditor/gui/src/qsyntaxer.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'utils/wpseditor/gui/src/qsyntaxer.cpp')
-rw-r--r--utils/wpseditor/gui/src/qsyntaxer.cpp88
1 files changed, 44 insertions, 44 deletions
diff --git a/utils/wpseditor/gui/src/qsyntaxer.cpp b/utils/wpseditor/gui/src/qsyntaxer.cpp
index 412ca38148..fa2608be45 100644
--- a/utils/wpseditor/gui/src/qsyntaxer.cpp
+++ b/utils/wpseditor/gui/src/qsyntaxer.cpp
@@ -1,44 +1,44 @@
1#include <QTextCharFormat> 1#include <QTextCharFormat>
2 2
3#include "qsyntaxer.h" 3#include "qsyntaxer.h"
4 4
5QSyntaxer::QSyntaxer(QTextDocument *parent) 5QSyntaxer::QSyntaxer(QTextDocument *parent)
6 : QSyntaxHighlighter(parent) { 6 : QSyntaxHighlighter(parent) {
7 HighlightingRule rule; 7 HighlightingRule rule;
8 8
9 hrules["operator"].pattern = QRegExp("%[^\\| \n<\\?%]{1,2}"); 9 hrules["operator"].pattern = QRegExp("%[^\\| \n<\\?%]{1,2}");
10 hrules["operator"].format.setFontWeight(QFont::Bold); 10 hrules["operator"].format.setFontWeight(QFont::Bold);
11 hrules["operator"].format.setForeground(Qt::darkBlue); 11 hrules["operator"].format.setForeground(Qt::darkBlue);
12 12
13 13
14 hrules["question"].pattern = QRegExp("%[\\?]{1}[^<]{1,2}"); 14 hrules["question"].pattern = QRegExp("%[\\?]{1}[^<]{1,2}");
15 hrules["question"].format.setForeground(Qt::darkMagenta); 15 hrules["question"].format.setForeground(Qt::darkMagenta);
16 16
17 hrules["question2"].pattern = QRegExp("(<|>)"); 17 hrules["question2"].pattern = QRegExp("(<|>)");
18 hrules["question2"].format.setForeground(Qt::red); 18 hrules["question2"].format.setForeground(Qt::red);
19 19
20 20
21 hrules["limiter"].pattern = QRegExp("\\|"); 21 hrules["limiter"].pattern = QRegExp("\\|");
22 hrules["limiter"].format.setForeground(Qt::darkRed); 22 hrules["limiter"].format.setForeground(Qt::darkRed);
23 23
24 hrules["comment"].pattern = QRegExp("#[^\n]*"); 24 hrules["comment"].pattern = QRegExp("#[^\n]*");
25 hrules["comment"].format.setForeground(Qt::darkGreen); 25 hrules["comment"].format.setForeground(Qt::darkGreen);
26 hrules["comment"].format.setFontItalic(true); 26 hrules["comment"].format.setFontItalic(true);
27} 27}
28// 28//
29void QSyntaxer::highlightBlock(const QString &text) { 29void QSyntaxer::highlightBlock(const QString &text) {
30 QTextCharFormat wholeText; 30 QTextCharFormat wholeText;
31 wholeText.setFont(QFont("arial",11,QFont::Normal)); 31 wholeText.setFont(QFont("arial",11,QFont::Normal));
32 setFormat(0,text.length(),wholeText); 32 setFormat(0,text.length(),wholeText);
33 33
34 foreach (HighlightingRule rule, hrules) { 34 foreach (HighlightingRule rule, hrules) {
35 QRegExp expression(rule.pattern); 35 QRegExp expression(rule.pattern);
36 int index = text.indexOf(expression); 36 int index = text.indexOf(expression);
37 while (index >= 0) { 37 while (index >= 0) {
38 int length = expression.matchedLength(); 38 int length = expression.matchedLength();
39 setFormat(index, length, rule.format); 39 setFormat(index, length, rule.format);
40 index = text.indexOf(expression, index + length); 40 index = text.indexOf(expression, index + length);
41 } 41 }
42 } 42 }
43 43
44} 44}