-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathhighlighter.h
More file actions
62 lines (49 loc) · 1.44 KB
/
highlighter.h
File metadata and controls
62 lines (49 loc) · 1.44 KB
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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
#ifndef HIGHLIGHTER_H
#define HIGHLIGHTER_H
#include <QObject>
#include <QSyntaxHighlighter>
#include <QTextCharFormat>
#include <QRegularExpression>
#include <QTextEdit>
#include <QTextDocument>
#include <theme.h>
class Highlighter : public QSyntaxHighlighter
{
Q_OBJECT
public:
explicit Highlighter(QObject *parent = nullptr);
public slots:
void syntaxColorUpdateHandler(HighlightColor& colors);
void updateSearchText(const QString &text);
protected:
void highlightBlock(const QString &text) override;
private:
struct HighlightingRule
{
QRegularExpression pattern;
QTextCharFormat format;
};
QRegularExpression m_regex;
QTextCharFormat m_format;
QList<HighlightingRule> highlightingRules;
QRegularExpression commentStartExpression;
QRegularExpression commentEndExpression;
QRegularExpression regexCodeBlock;
QRegularExpression searchMatchExpression;
QTextCharFormat tickMarkFormat;
QTextCharFormat unTickMarkFormat;
QTextCharFormat keywordFormat;
QTextCharFormat classFormat;
QTextCharFormat singleLineCommentFormat;
QTextCharFormat multiLineCommentFormat;
QTextCharFormat quotationFormat;
QTextCharFormat functionFormat;
QTextCharFormat searchMatchFormat;
QTextCharFormat formatBlock;
QTextCharFormat formatNormal;
QTextDocument *doc;
HighlightColor syntaxColor;
bool initialised;
void initColors();
};
#endif // HIGHLIGHTER_H