umbrello: umbrello/dialogs/codetexthighlighter.h Source File

umbrello 25.08.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
21 class 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
34 struct HighlightingRule
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;
46 QTextCharFormat m_singleLineCommentFormat;
47 QTextCharFormat m_multiLineCommentFormat;
48 QTextCharFormat m_quotationFormat;
49 QTextCharFormat m_functionFormat;
50};
51
52#endif // CODETEXTHIGHLIGHTER_H
CodeTextHighlighter::m_functionFormat
QTextCharFormat m_functionFormat
Definition codetexthighlighter.h:49
CodeTextHighlighter::CodeTextHighlighter
CodeTextHighlighter(QTextDocument *parent=nullptr)
Definition codetexthighlighter.cpp:24
CodeTextHighlighter::m_singleLineCommentFormat
QTextCharFormat m_singleLineCommentFormat
Definition codetexthighlighter.h:46
CodeTextHighlighter::m_highlightingRules
QVector< HighlightingRule > m_highlightingRules
Definition codetexthighlighter.h:39
CodeTextHighlighter::m_classFormat
QTextCharFormat m_classFormat
Definition codetexthighlighter.h:45
CodeTextHighlighter::m_quotationFormat
QTextCharFormat m_quotationFormat
Definition codetexthighlighter.h:48
CodeTextHighlighter::m_multiLineCommentFormat
QTextCharFormat m_multiLineCommentFormat
Definition codetexthighlighter.h:47
CodeTextHighlighter::m_commentStartExpression
QRegularExpression m_commentStartExpression
Definition codetexthighlighter.h:41
CodeTextHighlighter::keywords
QStringList keywords()
Definition codetexthighlighter.cpp:112
CodeTextHighlighter::highlightBlock
void highlightBlock(const QString &text)
Definition codetexthighlighter.cpp:71
CodeTextHighlighter::m_commentEndExpression
QRegularExpression m_commentEndExpression
Definition codetexthighlighter.h:42
CodeTextHighlighter::m_keywordFormat
QTextCharFormat m_keywordFormat
Definition codetexthighlighter.h:44
CodeTextHighlighter::HighlightingRule
Definition codetexthighlighter.h:35
CodeTextHighlighter::HighlightingRule::pattern
QRegularExpression pattern
Definition codetexthighlighter.h:36
CodeTextHighlighter::HighlightingRule::format
QTextCharFormat format
Definition codetexthighlighter.h:37