54
54
class QsciAbstractAPIs;
57
//! \brief The QsciLexer class is an abstract class used as a base for specific
58
//! existing Scintilla language lexers.
60
//! A Scintilla lexer scans the text breaking it up into separate language
61
//! objects, e.g. keywords, strings, operators. The lexer then uses a
62
//! different style to draw each object. A style is identified by a style
63
//! number and has a number of attributes, including colour and font. A
64
//! specific language lexer will implement appropriate default styles which can
65
//! be overriden by an application by further sub-classing the specific
68
//! A specific language lexer may provide one or more sets of words to be
69
//! recognised as keywords. Most lexers only provide one set, but some may
70
//! support languages embedded in other languages and provide several sets.
58
//! \brief The QsciLexer class is an abstract class used as a base for language
61
//! A lexer scans the text breaking it up into separate language objects, e.g.
62
//! keywords, strings, operators. The lexer then uses a different style to
63
//! draw each object. A style is identified by a style number and has a number
64
//! of attributes, including colour and font. A specific language lexer will
65
//! implement appropriate default styles which can be overriden by an
66
//! application by further sub-classing the specific language lexer.
68
//! A lexer may provide one or more sets of words to be recognised as keywords.
69
//! Most lexers only provide one set, but some may support languages embedded
70
//! in other languages and provide several sets.
72
72
//! QsciLexer provides convenience methods for saving and restoring user
73
//! preferences for fonts and colours. Note that QSciLexer is not a means to
74
//! writing new lexers - you must do that by adding a new lexer to the
75
//! underlying Scintilla code.
73
//! preferences for fonts and colours.
75
//! If you want to write a lexer for a new language then you can add it to the
76
//! underlying Scintilla code and implement a corresponding QsciLexer sub-class
77
//! to manage the different styles used. Alternatively you can implement a
78
//! sub-class of QsciLexerCustom.
76
79
class QSCINTILLA_EXPORT QsciLexer : public QObject
90
93
virtual const char *language() const = 0;
92
//! Returns the name of the lexer. Some lexers support a number of
93
//! languages. It must be re-implemented by a sub-class.
94
virtual const char *lexer() const = 0;
95
//! Returns the name of the lexer. If 0 is returned then the lexer's
96
//! numeric identifier is used. The default implementation returns 0.
99
virtual const char *lexer() const;
101
//! Returns the identifier (i.e. a QsciScintillaBase::SCLEX_* value) of the
102
//! lexer. This is only used if lexer() returns 0. The default
103
//! implementation returns QsciScintillaBase::SCLEX_CONTAINER.
106
virtual int lexerId() const;
96
108
//! Returns the current API set or 0 if there isn't one.
207
219
//! Returns the default paper colour for style number \a style.
208
220
virtual QColor defaultPaper(int style) const;
222
//! Returns the QsciScintilla instance that the lexer is currently attached
223
//! to or 0 if it is unattached.
224
QsciScintilla *editor() const {return attached_editor;}
210
226
//! The current set of APIs is set to \a apis. If \a apis is 0 then any
211
227
//! existing APIs for this lexer are removed.
228
244
//! \sa defaultPaper(), paper()
229
245
void setDefaultPaper(const QColor &c);
247
//! \internal Set the QsciScintilla instance that the lexer is attached to.
248
virtual void setEditor(QsciScintilla *editor);
231
250
//! The colour, paper, font and end-of-line for each style number, and
232
251
//! all lexer specific properties are read from the settings \a qs.
233
252
//! \a prefix is prepended to the key of each entry. true is returned
240
259
//! propertyChanged() signal as required.
241
260
virtual void refreshProperties();
262
//! Returns the number of style bits needed by the lexer. Normally this
263
//! should only be re-implemented by custom lexers.
264
virtual int styleBitsNeeded() const;
243
266
//! \internal Returns the string of characters that comprise a word.
244
267
//! The default is 0 which implies the upper and lower case alphabetic
245
268
//! characters and underscore.