-
Notifications
You must be signed in to change notification settings - Fork 1
/
highlighter.h
45 lines (35 loc) · 981 Bytes
/
highlighter.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#ifndef HIGHLIGHTER_H
#define HIGHLIGHTER_H
#include <QSyntaxHighlighter>
class Highlighter : public QSyntaxHighlighter {
Q_OBJECT
public:
Highlighter(QTextDocument *parent = 0);
protected:
void highlightBlock(const QString &text) Q_DECL_OVERRIDE;
private:
struct HighlightingRule
{
QRegExp pattern;
QTextCharFormat format;
};
QVector<HighlightingRule> highlightingRules;
QTextCharFormat classFormat;
QTextCharFormat keywordFormat;
QTextCharFormat singleLineCommentFormat;
QTextCharFormat multiLineCommentFormat;
QTextCharFormat typeFormat;
QTextCharFormat symbolFormat;
QTextCharFormat numberFormat;
QTextCharFormat stringFormat;
QRegExp commentStartExpression;
QRegExp commentEndExpression;
void classRules();
void keywordRules();
void commentRules();
void typeRules();
void symbolRules();
void numberRules();
void stringRules();
};
#endif // HIGHLIGHTER_H