1 | // Copyright (C) 2016 The Qt Company Ltd. |
2 | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 |
3 | |
4 | #ifndef MESSAGEHIGHLIGHTER_H |
5 | #define MESSAGEHIGHLIGHTER_H |
6 | |
7 | #include <QtGui/QSyntaxHighlighter> |
8 | |
9 | QT_BEGIN_NAMESPACE |
10 | |
11 | class QTextEdit; |
12 | |
13 | /* Message highlighter based on HtmlSyntaxHighlighter from designer */ |
14 | class MessageHighlighter : public QSyntaxHighlighter |
15 | { |
16 | Q_OBJECT |
17 | |
18 | public: |
19 | MessageHighlighter(QTextEdit *textEdit); |
20 | |
21 | protected: |
22 | void highlightBlock(const QString &text) override; |
23 | |
24 | private: |
25 | enum Construct { |
26 | Entity, |
27 | Tag, |
28 | , |
29 | Attribute, |
30 | Value, |
31 | Accelerator, // "Open &File" |
32 | Variable, // "Opening %1" |
33 | LastConstruct = Variable |
34 | }; |
35 | |
36 | enum State { |
37 | NormalState = -1, |
38 | , |
39 | InTag |
40 | }; |
41 | |
42 | QTextCharFormat m_formats[LastConstruct + 1]; |
43 | }; |
44 | |
45 | QT_END_NAMESPACE |
46 | |
47 | #endif // MESSAGEHIGHLIGHTER_H |
48 | |