Mercurial > octave
comparison libgui/languages/build_ts/octave-qsci/Qsci/qscilexercpp.h @ 31537:5ceb4bfcdb0f stable
add tools and files for updating the gui's language files for translation
* libgui/languages/build_ts/README.md: readme for updating language files
* libgui/languages/build_ts/octave-qsci: QScintilla source files for
languages without translation provided by QScintilla
* libgui/languages/build_ts/octave-qt: Qt source files for languages
without translation provided by Qt
author | Torsten Lilge <ttl-octave@mailbox.org> |
---|---|
date | Thu, 24 Nov 2022 06:48:25 +0100 |
parents | |
children | dd5ece3664ed |
comparison
equal
deleted
inserted
replaced
31535:4b80982e0af8 | 31537:5ceb4bfcdb0f |
---|---|
1 // This defines the interface to the QsciLexerCPP class. | |
2 // | |
3 // Copyright (c) 2019 Riverbank Computing Limited <info@riverbankcomputing.com> | |
4 // | |
5 // This file is part of QScintilla. | |
6 // | |
7 // This file may be used under the terms of the GNU General Public License | |
8 // version 3.0 as published by the Free Software Foundation and appearing in | |
9 // the file LICENSE included in the packaging of this file. Please review the | |
10 // following information to ensure the GNU General Public License version 3.0 | |
11 // requirements will be met: http://www.gnu.org/copyleft/gpl.html. | |
12 // | |
13 // If you do not wish to use this file under the terms of the GPL version 3.0 | |
14 // then you may purchase a commercial license. For more information contact | |
15 // info@riverbankcomputing.com. | |
16 // | |
17 // This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | |
18 // WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | |
19 | |
20 | |
21 #ifndef QSCILEXERCPP_H | |
22 #define QSCILEXERCPP_H | |
23 | |
24 #include <QObject> | |
25 | |
26 #include <Qsci/qsciglobal.h> | |
27 #include <Qsci/qscilexer.h> | |
28 | |
29 | |
30 //! \brief The QsciLexerCPP class encapsulates the Scintilla C++ | |
31 //! lexer. | |
32 class QSCINTILLA_EXPORT QsciLexerCPP : public QsciLexer | |
33 { | |
34 Q_OBJECT | |
35 | |
36 public: | |
37 //! This enum defines the meanings of the different styles used by the | |
38 //! C++ lexer. | |
39 enum { | |
40 //! The default. | |
41 Default = 0, | |
42 InactiveDefault = Default + 64, | |
43 | |
44 //! A C comment. | |
45 Comment = 1, | |
46 InactiveComment = Comment + 64, | |
47 | |
48 //! A C++ comment line. | |
49 CommentLine = 2, | |
50 InactiveCommentLine = CommentLine + 64, | |
51 | |
52 //! A JavaDoc/Doxygen style C comment. | |
53 CommentDoc = 3, | |
54 InactiveCommentDoc = CommentDoc + 64, | |
55 | |
56 //! A number. | |
57 Number = 4, | |
58 InactiveNumber = Number + 64, | |
59 | |
60 //! A keyword. | |
61 Keyword = 5, | |
62 InactiveKeyword = Keyword + 64, | |
63 | |
64 //! A double-quoted string. | |
65 DoubleQuotedString = 6, | |
66 InactiveDoubleQuotedString = DoubleQuotedString + 64, | |
67 | |
68 //! A single-quoted string. | |
69 SingleQuotedString = 7, | |
70 InactiveSingleQuotedString = SingleQuotedString + 64, | |
71 | |
72 //! An IDL UUID. | |
73 UUID = 8, | |
74 InactiveUUID = UUID + 64, | |
75 | |
76 //! A pre-processor block. | |
77 PreProcessor = 9, | |
78 InactivePreProcessor = PreProcessor + 64, | |
79 | |
80 //! An operator. | |
81 Operator = 10, | |
82 InactiveOperator = Operator + 64, | |
83 | |
84 //! An identifier | |
85 Identifier = 11, | |
86 InactiveIdentifier = Identifier + 64, | |
87 | |
88 //! The end of a line where a string is not closed. | |
89 UnclosedString = 12, | |
90 InactiveUnclosedString = UnclosedString + 64, | |
91 | |
92 //! A C# verbatim string. | |
93 VerbatimString = 13, | |
94 InactiveVerbatimString = VerbatimString + 64, | |
95 | |
96 //! A JavaScript regular expression. | |
97 Regex = 14, | |
98 InactiveRegex = Regex + 64, | |
99 | |
100 //! A JavaDoc/Doxygen style C++ comment line. | |
101 CommentLineDoc = 15, | |
102 InactiveCommentLineDoc = CommentLineDoc + 64, | |
103 | |
104 //! A keyword defined in keyword set number 2. The class must be | |
105 //! sub-classed and re-implement keywords() to make use of this style. | |
106 KeywordSet2 = 16, | |
107 InactiveKeywordSet2 = KeywordSet2 + 64, | |
108 | |
109 //! A JavaDoc/Doxygen keyword. | |
110 CommentDocKeyword = 17, | |
111 InactiveCommentDocKeyword = CommentDocKeyword + 64, | |
112 | |
113 //! A JavaDoc/Doxygen keyword error. | |
114 CommentDocKeywordError = 18, | |
115 InactiveCommentDocKeywordError = CommentDocKeywordError + 64, | |
116 | |
117 //! A global class or typedef defined in keyword set number 5. The | |
118 //! class must be sub-classed and re-implement keywords() to make use | |
119 //! of this style. | |
120 GlobalClass = 19, | |
121 InactiveGlobalClass = GlobalClass + 64, | |
122 | |
123 //! A C++ raw string. | |
124 RawString = 20, | |
125 InactiveRawString = RawString + 64, | |
126 | |
127 //! A Vala triple-quoted verbatim string. | |
128 TripleQuotedVerbatimString = 21, | |
129 InactiveTripleQuotedVerbatimString = TripleQuotedVerbatimString + 64, | |
130 | |
131 //! A Pike hash-quoted string. | |
132 HashQuotedString = 22, | |
133 InactiveHashQuotedString = HashQuotedString + 64, | |
134 | |
135 //! A pre-processor stream comment. | |
136 PreProcessorComment = 23, | |
137 InactivePreProcessorComment = PreProcessorComment + 64, | |
138 | |
139 //! A JavaDoc/Doxygen style pre-processor comment. | |
140 PreProcessorCommentLineDoc = 24, | |
141 InactivePreProcessorCommentLineDoc = PreProcessorCommentLineDoc + 64, | |
142 | |
143 //! A user-defined literal. | |
144 UserLiteral = 25, | |
145 InactiveUserLiteral = UserLiteral + 64, | |
146 | |
147 //! A task marker. | |
148 TaskMarker = 26, | |
149 InactiveTaskMarker = TaskMarker + 64, | |
150 | |
151 //! An escape sequence. | |
152 EscapeSequence = 27, | |
153 InactiveEscapeSequence = EscapeSequence + 64, | |
154 }; | |
155 | |
156 //! Construct a QsciLexerCPP with parent \a parent. \a parent is typically | |
157 //! the QsciScintilla instance. \a caseInsensitiveKeywords is true if the | |
158 //! lexer ignores the case of keywords. | |
159 QsciLexerCPP(QObject *parent = 0, bool caseInsensitiveKeywords = false); | |
160 | |
161 //! Destroys the QsciLexerCPP instance. | |
162 virtual ~QsciLexerCPP(); | |
163 | |
164 //! Returns the name of the language. | |
165 const char *language() const; | |
166 | |
167 //! Returns the name of the lexer. Some lexers support a number of | |
168 //! languages. | |
169 const char *lexer() const; | |
170 | |
171 //! \internal Returns the character sequences that can separate | |
172 //! auto-completion words. | |
173 QStringList autoCompletionWordSeparators() const; | |
174 | |
175 //! \internal Returns a space separated list of words or characters in | |
176 //! a particular style that define the end of a block for | |
177 //! auto-indentation. The styles is returned via \a style. | |
178 const char *blockEnd(int *style = 0) const; | |
179 | |
180 //! \internal Returns a space separated list of words or characters in | |
181 //! a particular style that define the start of a block for | |
182 //! auto-indentation. The styles is returned via \a style. | |
183 const char *blockStart(int *style = 0) const; | |
184 | |
185 //! \internal Returns a space separated list of keywords in a | |
186 //! particular style that define the start of a block for | |
187 //! auto-indentation. The styles is returned via \a style. | |
188 const char *blockStartKeyword(int *style = 0) const; | |
189 | |
190 //! \internal Returns the style used for braces for brace matching. | |
191 int braceStyle() const; | |
192 | |
193 //! Returns the string of characters that comprise a word. | |
194 const char *wordCharacters() const; | |
195 | |
196 //! Returns the foreground colour of the text for style number \a style. | |
197 //! | |
198 //! \sa defaultPaper() | |
199 QColor defaultColor(int style) const; | |
200 | |
201 //! Returns the end-of-line fill for style number \a style. | |
202 bool defaultEolFill(int style) const; | |
203 | |
204 //! Returns the font for style number \a style. | |
205 QFont defaultFont(int style) const; | |
206 | |
207 //! Returns the background colour of the text for style number \a style. | |
208 //! | |
209 //! \sa defaultColor() | |
210 QColor defaultPaper(int style) const; | |
211 | |
212 //! Returns the set of keywords for the keyword set \a set recognised | |
213 //! by the lexer as a space separated string. Set 1 is normally used for | |
214 //! primary keywords and identifiers. Set 2 is normally used for secondary | |
215 //! keywords and identifiers. Set 3 is normally used for documentation | |
216 //! comment keywords. Set 4 is normally used for global classes and | |
217 //! typedefs. | |
218 const char *keywords(int set) const; | |
219 | |
220 //! Returns the descriptive name for style number \a style. If the | |
221 //! style is invalid for this language then an empty QString is returned. | |
222 //! This is intended to be used in user preference dialogs. | |
223 QString description(int style) const; | |
224 | |
225 //! Causes all properties to be refreshed by emitting the | |
226 //! propertyChanged() signal as required. | |
227 void refreshProperties(); | |
228 | |
229 //! Returns true if "} else {" lines can be folded. | |
230 //! | |
231 //! \sa setFoldAtElse() | |
232 bool foldAtElse() const {return fold_atelse;} | |
233 | |
234 //! Returns true if multi-line comment blocks can be folded. | |
235 //! | |
236 //! \sa setFoldComments() | |
237 bool foldComments() const {return fold_comments;} | |
238 | |
239 //! Returns true if trailing blank lines are included in a fold block. | |
240 //! | |
241 //! \sa setFoldCompact() | |
242 bool foldCompact() const {return fold_compact;} | |
243 | |
244 //! Returns true if preprocessor blocks can be folded. | |
245 //! | |
246 //! \sa setFoldPreprocessor() | |
247 bool foldPreprocessor() const {return fold_preproc;} | |
248 | |
249 //! Returns true if preprocessor lines (after the preprocessor | |
250 //! directive) are styled. | |
251 //! | |
252 //! \sa setStylePreprocessor() | |
253 bool stylePreprocessor() const {return style_preproc;} | |
254 | |
255 //! If \a allowed is true then '$' characters are allowed in identifier | |
256 //! names. The default is true. | |
257 //! | |
258 //! \sa dollarsAllowed() | |
259 void setDollarsAllowed(bool allowed); | |
260 | |
261 //! Returns true if '$' characters are allowed in identifier names. | |
262 //! | |
263 //! \sa setDollarsAllowed() | |
264 bool dollarsAllowed() const {return dollars;} | |
265 | |
266 //! If \a enabled is true then triple quoted strings are highlighted. The | |
267 //! default is false. | |
268 //! | |
269 //! \sa highlightTripleQuotedStrings() | |
270 void setHighlightTripleQuotedStrings(bool enabled); | |
271 | |
272 //! Returns true if triple quoted strings should be highlighted. | |
273 //! | |
274 //! \sa setHighlightTripleQuotedStrings() | |
275 bool highlightTripleQuotedStrings() const {return highlight_triple;} | |
276 | |
277 //! If \a enabled is true then hash quoted strings are highlighted. The | |
278 //! default is false. | |
279 //! | |
280 //! \sa highlightHashQuotedStrings() | |
281 void setHighlightHashQuotedStrings(bool enabled); | |
282 | |
283 //! Returns true if hash quoted strings should be highlighted. | |
284 //! | |
285 //! \sa setHighlightHashQuotedStrings() | |
286 bool highlightHashQuotedStrings() const {return highlight_hash;} | |
287 | |
288 //! If \a enabled is true then back-quoted raw strings are highlighted. | |
289 //! The default is false. | |
290 //! | |
291 //! \sa highlightBackQuotedStrings() | |
292 void setHighlightBackQuotedStrings(bool enabled); | |
293 | |
294 //! Returns true if back-quoted raw strings should be highlighted. | |
295 //! | |
296 //! \sa setHighlightBackQuotedStrings() | |
297 bool highlightBackQuotedStrings() const {return highlight_back;} | |
298 | |
299 //! If \a enabled is true then escape sequences in strings are highlighted. | |
300 //! The default is false. | |
301 //! | |
302 //! \sa highlightEscapeSequences() | |
303 void setHighlightEscapeSequences(bool enabled); | |
304 | |
305 //! Returns true if escape sequences in strings should be highlighted. | |
306 //! | |
307 //! \sa setHighlightEscapeSequences() | |
308 bool highlightEscapeSequences() const {return highlight_escape;} | |
309 | |
310 //! If \a allowed is true then escape sequences are allowed in verbatim | |
311 //! strings. The default is false. | |
312 //! | |
313 //! \sa verbatimStringEscapeSequencesAllowed() | |
314 void setVerbatimStringEscapeSequencesAllowed(bool allowed); | |
315 | |
316 //! Returns true if hash quoted strings should be highlighted. | |
317 //! | |
318 //! \sa setVerbatimStringEscapeSequencesAllowed() | |
319 bool verbatimStringEscapeSequencesAllowed() const {return vs_escape;} | |
320 | |
321 public slots: | |
322 //! If \a fold is true then "} else {" lines can be folded. The | |
323 //! default is false. | |
324 //! | |
325 //! \sa foldAtElse() | |
326 virtual void setFoldAtElse(bool fold); | |
327 | |
328 //! If \a fold is true then multi-line comment blocks can be folded. | |
329 //! The default is false. | |
330 //! | |
331 //! \sa foldComments() | |
332 virtual void setFoldComments(bool fold); | |
333 | |
334 //! If \a fold is true then trailing blank lines are included in a fold | |
335 //! block. The default is true. | |
336 //! | |
337 //! \sa foldCompact() | |
338 virtual void setFoldCompact(bool fold); | |
339 | |
340 //! If \a fold is true then preprocessor blocks can be folded. The | |
341 //! default is true. | |
342 //! | |
343 //! \sa foldPreprocessor() | |
344 virtual void setFoldPreprocessor(bool fold); | |
345 | |
346 //! If \a style is true then preprocessor lines (after the preprocessor | |
347 //! directive) are styled. The default is false. | |
348 //! | |
349 //! \sa stylePreprocessor() | |
350 virtual void setStylePreprocessor(bool style); | |
351 | |
352 protected: | |
353 //! The lexer's properties are read from the settings \a qs. \a prefix | |
354 //! (which has a trailing '/') should be used as a prefix to the key of | |
355 //! each setting. true is returned if there is no error. | |
356 //! | |
357 //! \sa writeProperties() | |
358 bool readProperties(QSettings &qs,const QString &prefix); | |
359 | |
360 //! The lexer's properties are written to the settings \a qs. | |
361 //! \a prefix (which has a trailing '/') should be used as a prefix to | |
362 //! the key of each setting. true is returned if there is no error. | |
363 //! | |
364 //! \sa readProperties() | |
365 bool writeProperties(QSettings &qs,const QString &prefix) const; | |
366 | |
367 private: | |
368 void setAtElseProp(); | |
369 void setCommentProp(); | |
370 void setCompactProp(); | |
371 void setPreprocProp(); | |
372 void setStylePreprocProp(); | |
373 void setDollarsProp(); | |
374 void setHighlightTripleProp(); | |
375 void setHighlightHashProp(); | |
376 void setHighlightBackProp(); | |
377 void setHighlightEscapeProp(); | |
378 void setVerbatimStringEscapeProp(); | |
379 | |
380 bool fold_atelse; | |
381 bool fold_comments; | |
382 bool fold_compact; | |
383 bool fold_preproc; | |
384 bool style_preproc; | |
385 bool dollars; | |
386 bool highlight_triple; | |
387 bool highlight_hash; | |
388 bool highlight_back; | |
389 bool highlight_escape; | |
390 bool vs_escape; | |
391 | |
392 bool nocase; | |
393 | |
394 QsciLexerCPP(const QsciLexerCPP &); | |
395 QsciLexerCPP &operator=(const QsciLexerCPP &); | |
396 }; | |
397 | |
398 #endif |