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.cpp64
1 files changed, 0 insertions, 64 deletions
diff --git a/utils/wpseditor/gui/src/qsyntaxer.cpp b/utils/wpseditor/gui/src/qsyntaxer.cpp
deleted file mode 100644
index 5a0b6cd97c..0000000000
--- a/utils/wpseditor/gui/src/qsyntaxer.cpp
+++ /dev/null
@@ -1,64 +0,0 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 *
9 * Copyright (C) 2007 by Rostilav Checkan
10 * $Id$
11 *
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation; either version 2
15 * of the License, or (at your option) any later version.
16 *
17 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
18 * KIND, either express or implied.
19 *
20 ****************************************************************************/
21
22#include <QTextCharFormat>
23
24#include "qsyntaxer.h"
25
26QSyntaxer::QSyntaxer(QTextDocument *parent)
27 : QSyntaxHighlighter(parent) {
28 HighlightingRule rule;
29
30 hrules[0].pattern = QRegExp("%[^\\| \n<\\?%]{1,2}");
31 hrules[0].format.setFontWeight(QFont::Bold);
32 hrules[0].format.setForeground(Qt::darkBlue);
33
34
35 hrules[1].pattern = QRegExp("%[\\?]{1}[^<]{1,2}");
36 hrules[1].format.setForeground(Qt::darkMagenta);
37
38 hrules[2].pattern = QRegExp("(<|>)");
39 hrules[2].format.setForeground(Qt::red);
40
41 hrules[3].pattern = QRegExp("\\|");
42 hrules[3].format.setForeground(Qt::darkRed);
43
44 hrules[4].pattern = QRegExp("#[^\n]*");
45 hrules[4].format.setForeground(Qt::darkGreen);
46 hrules[4].format.setFontItalic(true);
47}
48//
49void QSyntaxer::highlightBlock(const QString &text) {
50 QTextCharFormat wholeText;
51 wholeText.setFont(QFont("arial",11,QFont::Normal));
52 setFormat(0,text.length(),wholeText);
53
54 foreach (HighlightingRule rule, hrules) {
55 QRegExp expression(rule.pattern);
56 int index = text.indexOf(expression);
57 while (index >= 0) {
58 int length = expression.matchedLength();
59 setFormat(index, length, rule.format);
60 index = text.indexOf(expression, index + length);
61 }
62 }
63
64}