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
9QT_BEGIN_NAMESPACE
10
11class QTextEdit;
12
13/* Message highlighter based on HtmlSyntaxHighlighter from designer */
14class MessageHighlighter : public QSyntaxHighlighter
15{
16 Q_OBJECT
17
18public:
19 MessageHighlighter(QTextEdit *textEdit);
20
21protected:
22 void highlightBlock(const QString &text) override;
23
24private:
25 enum Construct {
26 Entity,
27 Tag,
28 Comment,
29 Attribute,
30 Value,
31 Accelerator, // "Open &File"
32 Variable, // "Opening %1"
33 LastConstruct = Variable
34 };
35
36 enum State {
37 NormalState = -1,
38 InComment,
39 InTag
40 };
41
42 QTextCharFormat m_formats[LastConstruct + 1];
43};
44
45QT_END_NAMESPACE
46
47#endif // MESSAGEHIGHLIGHTER_H
48

source code of qttools/src/linguist/linguist/messagehighlighter.h