summaryrefslogtreecommitdiffstats
path: root/qt/qextscintillalexerhtml.h
blob: 1a71fe982cf540f429a39cf9d80cc938566779f4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
// This defines the interface to the QextScintillaLexerHTML class.
//
// Copyright (c) 2006
// 	Riverbank Computing Limited <info@riverbankcomputing.co.uk>
// 
// This file is part of QScintilla.
// 
// This copy of QScintilla is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2, or (at your option) any
// later version.
// 
// QScintilla is supplied in the hope that it will be useful, but WITHOUT ANY
// WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
// FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
// details.
// 
// You should have received a copy of the GNU General Public License along with
// QScintilla; see the file LICENSE.  If not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.


#ifndef QEXTSCINTILLALEXERHTML_H
#define QEXTSCINTILLALEXERHTML_H


#include <qobject.h>

#include <qextscintillaglobal.h>
#include <qextscintillalexer.h>


//! \brief The QextScintillaLexerHTML class encapsulates the Scintilla HTML
//! lexer.
class QEXTSCINTILLA_EXPORT QextScintillaLexerHTML : public QextScintillaLexer
{
	Q_OBJECT

public:
	//! This enum defines the meanings of the different styles used by the
	//! HTML lexer.
	enum {
		//! The default.
		Default = 0,

		//! A tag.
		Tag = 1,

		//! An unknown tag.
		UnknownTag = 2,

		//! An attribute.
		Attribute = 3,

		//! An unknown attribute.
		UnknownAttribute = 4,

		//! An HTML number.
		HTMLNumber = 5,

		//! An HTML double-quoted string.
		HTMLDoubleQuotedString = 6,

		//! An HTML single-quoted string.
		HTMLSingleQuotedString = 7,

		//! Other text within a tag.
		OtherInTag = 8,

		//! An HTML comment.
		HTMLComment = 9,

		//! An entity.
		Entity = 10,

		//! The end of an XML style tag.
		XMLTagEnd = 11,

		//! The start of an XML fragment.
		XMLStart = 12,

		//! The end of an XML fragment.
		XMLEnd = 13,

		//! A script tag.
		Script = 14,

		//! The start of an ASP fragment with @.
		ASPAtStart = 15,

		//! The start of an ASP fragment.
		ASPStart = 16,

		//! CDATA.
		CDATA = 17,

		//! The start of a PHP fragment.
		PHPStart = 18,

		//! An unquoted HTML value.
		HTMLValue = 19,

		//! An ASP X-Code comment.
		ASPXCComment = 20,

		//! The default for SGML.
		SGMLDefault = 21,

		//! An SGML command.
		SGMLCommand = 22,

		//! The first parameter of an SGML command.
		SGMLParameter = 23,

		//! An SGML double-quoted string.
		SGMLDoubleQuotedString = 24,

		//! An SGML single-quoted string.
		SGMLSingleQuotedString = 25,

		//! An SGML error.
		SGMLError = 26,

		//! An SGML special entity.
		SGMLSpecial = 27,

		//! An SGML entity.
		SGMLEntity = 28,

		//! An SGML comment.
		SGMLComment = 29,

		//! A comment with the first parameter of an SGML command.
		SGMLParameterComment = 30,

		//! The default for an SGML block.
		SGMLBlockDefault = 31,

		//! The start of a JavaScript fragment.
		JavaScriptStart = 40,

		//! The default for JavaScript.
		JavaScriptDefault = 41,

		//! A JavaScript comment.
		JavaScriptComment = 42,

		//! A JavaScript line comment.
		JavaScriptCommentLine = 43,

		//! A JavaDoc style JavaScript comment.
		JavaScriptCommentDoc = 44,

		//! A JavaScript number.
		JavaScriptNumber = 45,

		//! A JavaScript word.
		JavaScriptWord = 46,

		//! A JavaScript keyword.
		JavaScriptKeyword = 47,

		//! A JavaScript double-quoted string.
		JavaScriptDoubleQuotedString = 48,

		//! A JavaScript single-quoted string.
		JavaScriptSingleQuotedString = 49,

		//! A JavaScript symbol.
		JavaScriptSymbol = 50,

		//! The end of a JavaScript line where a string is not closed.
		JavaScriptUnclosedString = 51,

		//! A JavaScript regular expression.
		JavaScriptRegex = 52,

		//! The start of an ASP JavaScript fragment.
		ASPJavaScriptStart = 55,

		//! The default for ASP JavaScript.
		ASPJavaScriptDefault = 56,

		//! An ASP JavaScript comment.
		ASPJavaScriptComment = 57,

		//! An ASP JavaScript line comment.
		ASPJavaScriptCommentLine = 58,

		//! An ASP JavaDoc style JavaScript comment.
		ASPJavaScriptCommentDoc = 59,

		//! An ASP JavaScript number.
		ASPJavaScriptNumber = 60,

		//! An ASP JavaScript word.
		ASPJavaScriptWord = 61,

		//! An ASP JavaScript keyword.
		ASPJavaScriptKeyword = 62,

		//! An ASP JavaScript double-quoted string.
		ASPJavaScriptDoubleQuotedString = 63,

		//! An ASP JavaScript single-quoted string.
		ASPJavaScriptSingleQuotedString = 64,

		//! An ASP JavaScript symbol.
		ASPJavaScriptSymbol = 65,

		//! The end of an ASP JavaScript line where a string is not
		//! closed.
		ASPJavaScriptUnclosedString = 66,

		//! An ASP JavaScript regular expression.
		ASPJavaScriptRegex = 67,

		//! The start of a VBScript fragment.
		VBScriptStart = 70,

		//! The default for VBScript.
		VBScriptDefault = 71,

		//! A VBScript comment.
		VBScriptComment = 72,

		//! A VBScript number.
		VBScriptNumber = 73,

		//! A VBScript keyword.
		VBScriptKeyword = 74,

		//! A VBScript string.
		VBScriptString = 75,

		//! A VBScript identifier.
		VBScriptIdentifier = 76,

		//! The end of a VBScript line where a string is not closed.
		VBScriptUnclosedString = 77,

		//! The start of an ASP VBScript fragment.
		ASPVBScriptStart = 80,

		//! The default for ASP VBScript.
		ASPVBScriptDefault = 81,

		//! An ASP VBScript comment.
		ASPVBScriptComment = 82,

		//! An ASP VBScript number.
		ASPVBScriptNumber = 83,

		//! An ASP VBScript keyword.
		ASPVBScriptKeyword = 84,

		//! An ASP VBScript string.
		ASPVBScriptString = 85,

		//! An ASP VBScript identifier.
		ASPVBScriptIdentifier = 86,

		//! The end of an ASP VBScript line where a string is not
		//! closed.
		ASPVBScriptUnclosedString = 87,

		//! The start of a Python fragment.
		PythonStart = 90,

		//! The default for Python.
		PythonDefault = 91,

		//! A Python comment.
		PythonComment = 92,

		//! A Python number.
		PythonNumber = 93,

		//! A Python double-quoted string.
		PythonDoubleQuotedString = 94,

		//! A Python single-quoted string.
		PythonSingleQuotedString = 95,

		//! A Python keyword.
		PythonKeyword = 96,

		//! A Python triple single-quoted string.
		PythonTripleSingleQuotedString = 97,

		//! A Python triple double-quoted string.
		PythonTripleDoubleQuotedString = 98,

		//! The name of a Python class.
		PythonClassName = 99,

		//! The name of a Python function or method.
		PythonFunctionMethodName = 100,

		//! A Python operator.
		PythonOperator = 101,

		//! A Python identifier.
		PythonIdentifier = 102,

		//! The start of an ASP Python fragment.
		ASPPythonStart = 105,

		//! The default for ASP Python.
		ASPPythonDefault = 106,

		//! An ASP Python comment.
		ASPPythonComment = 107,

		//! An ASP Python number.
		ASPPythonNumber = 108,

		//! An ASP Python double-quoted string.
		ASPPythonDoubleQuotedString = 109,

		//! An ASP Python single-quoted string.
		ASPPythonSingleQuotedString = 110,

		//! An ASP Python keyword.
		ASPPythonKeyword = 111,

		//! An ASP Python triple single-quoted string.
		ASPPythonTripleSingleQuotedString = 112,

		//! An ASP Python triple double-quoted string.
		ASPPythonTripleDoubleQuotedString = 113,

		//! The name of an ASP Python class.
		ASPPythonClassName = 114,

		//! The name of an ASP Python function or method.
		ASPPythonFunctionMethodName = 115,

		//! An ASP Python operator.
		ASPPythonOperator = 116,

		//! An ASP Python identifier
		ASPPythonIdentifier = 117,

		//! The default for PHP.
		PHPDefault = 118,

		//! A PHP double-quoted string.
		PHPDoubleQuotedString = 119,

		//! A PHP single-quoted string.
		PHPSingleQuotedString = 120,

		//! A PHP keyword.
		PHPKeyword = 121,

		//! A PHP number.
		PHPNumber = 122,

		//! A PHP variable.
		PHPVariable = 123,

		//! A PHP comment.
		PHPComment = 124,

		//! A PHP line comment.
		PHPCommentLine = 125,

		//! A PHP double-quoted variable.
		PHPDoubleQuotedVariable = 126,

		//! A PHP operator.
		PHPOperator = 127
	};

	//! Construct a QextScintillaLexerHTML with parent \a parent and name
	//! \a name.  \a parent is typically the QextScintilla instance.
	QextScintillaLexerHTML(QObject *parent = 0,const char *name = 0);

	//! Destroys the QextScintillaLexerHTML instance.
	virtual ~QextScintillaLexerHTML();

	//! Returns the name of the language.
	const char *language() const;

	//! Returns the name of the lexer.  Some lexers support a number of
	//! languages.
	const char *lexer() const;

	//! \internal Returns the string of characters that comprise a word.
	const char *wordCharacters() const;

	//! Returns the foreground colour of the text for style number
	//! \a style.
	//!
	//! \sa paper()
	QColor color(int style) const;

	//! Returns the end-of-line fill for style number \a style.
	bool eolFill(int style) const;

	//! Returns the font for style number \a style.
	QFont font(int style) const;

	//! Returns the set of keywords for the keyword set \a set recognised
	//! by the lexer as a space separated string.
	const char *keywords(int set) const;

	//! Returns the descriptive name for style number \a style.  If the
	//! style is invalid for this language then QString::null is returned.
	//! This is intended to be used in user preference dialogs.
	QString description(int style) const;

	//! Returns the background colour of the text for style number
	//! \a style.
	//!
	//! \sa color()
	QColor paper(int style) const;

	//! Causes all properties to be refreshed by emitting the
	//! propertyChanged() signal as required.
	void refreshProperties();

	//! Returns TRUE if trailing blank lines are included in a fold block.
	//!
	//! \sa setFoldCompact()
	bool foldCompact() const;

	//! Returns TRUE if preprocessor blocks can be folded.
	//!
	//! \sa setFoldPreprocessor()
	bool foldPreprocessor() const;

	//! Returns TRUE if tags are case sensitive.
	//!
	//! \sa setCaseSensitiveTags()
	bool caseSensitiveTags() const;

public slots:
	//! If \a fold is TRUE then trailing blank lines are included in a fold
	//! block. The default is TRUE.
	//!
	//! \sa foldCompact()
	virtual void setFoldCompact(bool fold);

	//! If \a fold is TRUE then preprocessor blocks can be folded.  The
	//! default is FALSE.
	//!
	//! \sa foldPreprocessor()
	virtual void setFoldPreprocessor(bool fold);

	//! If \a sens is TRUE then tags are case sensitive.  The default is
	//! FALSE.
	//!
	//! \sa caseSensitiveTags()
	virtual void setCaseSensitiveTags(bool sens);

protected:
	//! The lexer's properties are read from the settings \a qs.  \a prefix
	//! (which has a trailing '/') should be used as a prefix to the key of
	//! each setting.  TRUE is returned if there is no error.
	//!
	bool readProperties(QSettings &qs,const QString &prefix);

	//! The lexer's properties are written to the settings \a qs.
	//! \a prefix (which has a trailing '/') should be used as a prefix to
	//! the key of each setting.  TRUE is returned if there is no error.
	//!
	bool writeProperties(QSettings &qs,const QString &prefix) const;

private:
	void setCompactProp();
	void setPreprocProp();
	void setCaseSensTagsProp();

	bool fold_compact;
	bool fold_preproc;
	bool case_sens_tags;

#if defined(Q_DISABLE_COPY)
	QextScintillaLexerHTML(const QextScintillaLexerHTML &);
	QextScintillaLexerHTML &operator=(const QextScintillaLexerHTML &);
#endif
};

#endif