umbrello 2.39.0
Umbrello UML Modeller is a Unified Modelling Language (UML) diagram program based on KDE Technology
codetexthighlighter.h
Go to the documentation of this file.
1/*
2 CodeTextHighlighter: Syntax highlighter for the CodeTextEdit widget.
3 SPDX-FileCopyrightText: 2010 Nokia Corporation and /or its subsidiary(-ies) <qt-info@nokia.com>
4 Code based on examples of the Qt Toolkit under BSD license,
5 <http://doc.qt.nokia.com/4.6/richtext-syntaxhighlighter.html>.
6 SPDX-FileCopyrightText: 2010 Umbrello UML Modeller Authors <umbrello-devel@kde.org>
7
8 SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL
9*/
10
11#ifndef CODETEXTHIGHLIGHTER_H
12#define CODETEXTHIGHLIGHTER_H
13
14#include <QHash>
15#include <QRegularExpression>
16#include <QSyntaxHighlighter>
17#include <QTextCharFormat>
18
19class QTextDocument;
20
21class CodeTextHighlighter : public QSyntaxHighlighter
22{
23 Q_OBJECT
24
25public:
26 explicit CodeTextHighlighter(QTextDocument *parent = nullptr);
27
28protected:
29 void highlightBlock(const QString &text);
30
31private:
32 QStringList keywords();
33
35 {
36 QRegularExpression pattern;
37 QTextCharFormat format;
38 };
39 QVector<HighlightingRule> m_highlightingRules;
40
41 QRegularExpression m_commentStartExpression;
42 QRegularExpression m_commentEndExpression;
43
44 QTextCharFormat m_keywordFormat;
45 QTextCharFormat m_classFormat;
47 QTextCharFormat m_multiLineCommentFormat;
48 QTextCharFormat m_quotationFormat;
49 QTextCharFormat m_functionFormat;
50};
51
52#endif // CODETEXTHIGHLIGHTER_H
Definition codetexthighlighter.h:22
QTextCharFormat m_functionFormat
Definition codetexthighlighter.h:49
CodeTextHighlighter(QTextDocument *parent=nullptr)
Definition codetexthighlighter.cpp:24
QTextCharFormat m_singleLineCommentFormat
Definition codetexthighlighter.h:46
QVector< HighlightingRule > m_highlightingRules
Definition codetexthighlighter.h:39
QTextCharFormat m_classFormat
Definition codetexthighlighter.h:45
QTextCharFormat m_quotationFormat
Definition codetexthighlighter.h:48
QTextCharFormat m_multiLineCommentFormat
Definition codetexthighlighter.h:47
QRegularExpression m_commentStartExpression
Definition codetexthighlighter.h:41
QStringList keywords()
Definition codetexthighlighter.cpp:112
void highlightBlock(const QString &text)
Definition codetexthighlighter.cpp:71
QRegularExpression m_commentEndExpression
Definition codetexthighlighter.h:42
QTextCharFormat m_keywordFormat
Definition codetexthighlighter.h:44
Definition codetexthighlighter.h:35
QRegularExpression pattern
Definition codetexthighlighter.h:36
QTextCharFormat format
Definition codetexthighlighter.h:37