KSyntaxHighlighting

highlightingdata_p.hpp
1/*
2 SPDX-FileCopyrightText: 2021 Jonathan Poelen <jonathan.poelen@gmail.com>
3
4 SPDX-License-Identifier: MIT
5*/
6
7#ifndef KSYNTAXHIGHLIGHTING_HIGHLIGHTING_DATA_P_H
8#define KSYNTAXHIGHLIGHTING_HIGHLIGHTING_DATA_P_H
9
10#include <QString>
11
12#include <vector>
13
14QT_BEGIN_NAMESPACE
16QT_END_NAMESPACE
17
18namespace KSyntaxHighlighting
19{
20/**
21 * Represents the raw xml data of a context and its rules.
22 * After resolving contexts, members of this class are no longer
23 * use and the instance can be freed to recover used memory.
24 */
26{
27public:
28 void load(const QString &defName, QXmlStreamReader &reader);
29
30 struct Rule {
31 enum class Type : quint8 {
32 Unknown,
33 AnyChar,
34 Detect2Chars,
35 DetectChar,
36 HlCOct,
37 IncludeRules,
38 Int,
39 Keyword,
40 LineContinue,
41 RangeDetect,
42 RegExpr,
43 StringDetect,
44 WordDetect,
45 Float,
46 HlCStringChar,
47 DetectIdentifier,
48 DetectSpaces,
49 HlCChar,
50 HlCHex,
51 };
52
53 struct AnyChar {
54 QString chars;
55 };
56
57 struct Detect2Chars {
58 QChar char1;
59 QChar char2;
60 };
61
62 struct DetectChar {
63 QChar char1;
64 bool dynamic;
65 };
66
67 struct WordDelimiters {
68 QString additionalDeliminator;
69 QString weakDeliminator;
70 };
71
72 struct Float {
73 WordDelimiters wordDelimiters;
74 };
75
76 struct HlCHex {
77 WordDelimiters wordDelimiters;
78 };
79
80 struct HlCOct {
81 WordDelimiters wordDelimiters;
82 };
83
84 struct IncludeRules {
85 QString contextName;
86 bool includeAttribute;
87 };
88
89 struct Int {
90 WordDelimiters wordDelimiters;
91 };
92
93 struct Keyword {
94 QString name;
95 WordDelimiters wordDelimiters;
96 Qt::CaseSensitivity caseSensitivityOverride;
97 bool hasCaseSensitivityOverride;
98 };
99
100 struct LineContinue {
101 QChar char1;
102 };
103
104 struct RangeDetect {
105 QChar begin;
106 QChar end;
107 };
108
109 struct RegExpr {
110 QString pattern;
111 Qt::CaseSensitivity caseSensitivity;
112 bool isMinimal;
113 bool dynamic;
114 };
115
116 struct StringDetect {
117 QString string;
118 Qt::CaseSensitivity caseSensitivity;
119 bool dynamic;
120 };
121
122 struct WordDetect {
123 QString word;
124 WordDelimiters wordDelimiters;
125 Qt::CaseSensitivity caseSensitivity;
126 };
127
128 union Data {
129 AnyChar anyChar;
130 Detect2Chars detect2Chars;
131 DetectChar detectChar;
132 HlCOct hlCOct;
133 IncludeRules includeRules;
134 Int detectInt;
135 Keyword keyword;
136 LineContinue lineContinue;
137 RangeDetect rangeDetect;
138 RegExpr regExpr;
139 StringDetect stringDetect;
140 WordDetect wordDetect;
141 Float detectFloat;
142 HlCHex hlCHex;
143
144 Data() noexcept
145 {
146 }
147
148 ~Data()
149 {
150 }
151 };
152
153 struct Common {
154 QString contextName;
155 QString attributeName;
156 QString beginRegionName;
157 QString endRegionName;
158 int column = -1;
159 bool firstNonSpace = false;
160 bool lookAhead = false;
161 };
162
163 Type type = Type::Unknown;
164 Common common;
165 Data data;
166
167 Rule() noexcept;
168 Rule(Rule &&other) noexcept;
169 Rule(const Rule &other);
170 ~Rule();
171
172 // since nothing is deleted in the rules vector, these functions do not need to be implemented
173 Rule &operator=(Rule &&other) = delete;
174 Rule &operator=(const Rule &other) = delete;
175 };
176
177 QString name;
178
179 /**
180 * attribute name, to lookup our format
181 */
183
184 QString lineEndContext;
185 QString lineEmptyContext;
186 QString fallthroughContext;
187
188 std::vector<Rule> rules;
189
190 bool stopEmptyLineContextSwitchLoop = false;
191 bool noIndentationBasedFolding = false;
192};
193}
194
195#endif
Represents the raw xml data of a context and its rules.
QString attribute
attribute name, to lookup our format
Syntax highlighting engine for Kate syntax definitions.
CaseSensitivity
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Mon Nov 18 2024 12:17:13 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.