CoreTrace Qt IDE 1.0
The CoreTrace Text editor
 
Loading...
Searching...
No Matches
syntax_highlighter.hpp
Go to the documentation of this file.
1#ifndef SYNTAX_HIGHLIGHTER_HPP
2#define SYNTAX_HIGHLIGHTER_HPP
3
4#include <QSyntaxHighlighter>
5#include <QTextCharFormat>
6#include <QRegularExpression>
7
8class SyntaxHighlighter : public QSyntaxHighlighter {
9 Q_OBJECT
10
11public:
12 explicit SyntaxHighlighter(QTextDocument* parent = nullptr);
13 virtual ~SyntaxHighlighter() = default;
14
15protected:
16 void highlightBlock(const QString& text) override = 0;
17};
18
20 Q_OBJECT
21
22public:
23 explicit CppHighlighter(QTextDocument* parent = nullptr);
24
25protected:
26 void highlightBlock(const QString& text) override;
27
28private:
30 QRegularExpression pattern;
31 QTextCharFormat format;
32 };
33
34 QVector<HighlightingRule> highlightingRules;
35
36 QTextCharFormat keywordFormat;
37 QTextCharFormat functionFormat;
38 QTextCharFormat typeFormat;
39 QTextCharFormat commentFormat;
40 QTextCharFormat stringFormat;
41 QTextCharFormat numberFormat;
42};
43
44#endif // SYNTAX_HIGHLIGHTER_HPP
Definition syntax_highlighter.hpp:19
QTextCharFormat numberFormat
Definition syntax_highlighter.hpp:41
QTextCharFormat functionFormat
Definition syntax_highlighter.hpp:37
QTextCharFormat typeFormat
Definition syntax_highlighter.hpp:38
QTextCharFormat stringFormat
Definition syntax_highlighter.hpp:40
QTextCharFormat keywordFormat
Definition syntax_highlighter.hpp:36
QVector< HighlightingRule > highlightingRules
Definition syntax_highlighter.hpp:34
QTextCharFormat commentFormat
Definition syntax_highlighter.hpp:39
void highlightBlock(const QString &text) override
Definition syntax_highlighter.cpp:99
Definition syntax_highlighter.hpp:8
virtual ~SyntaxHighlighter()=default
void highlightBlock(const QString &text) override=0
Definition syntax_highlighter.hpp:29
QRegularExpression pattern
Definition syntax_highlighter.hpp:30
QTextCharFormat format
Definition syntax_highlighter.hpp:31