-
Notifications
You must be signed in to change notification settings - Fork 40
/
Copy pathmyhighlighter.h
35 lines (29 loc) · 879 Bytes
/
myhighlighter.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
#ifndef MYHIGHLIGHTER_H
#define MYHIGHLIGHTER_H
#include <QSyntaxHighlighter>
#include <QTextCharFormat>
#include <QTextDocument>
class MyHighLighter : public QSyntaxHighlighter {
Q_OBJECT
public:
MyHighLighter(QTextDocument* parent = 0);
protected:
void highlightBlock(const QString& text) Q_DECL_OVERRIDE;
private:
struct HighlightingRule {
QRegExp pattern;
QTextCharFormat format;
};
QVector<HighlightingRule> highlightingRules;
QRegExp commentStartExpression;
QRegExp commentEndExpression;
QTextCharFormat keywordFormat;
QTextCharFormat classFormat;
QTextCharFormat singleLineKey;
QTextCharFormat singleLineValue;
QTextCharFormat singleLineCommentFormat;
QTextCharFormat multiLineCommentFormat;
QTextCharFormat quotationFormat;
QTextCharFormat functionFormat;
};
#endif // MYHIGHLIGHTER_H