~ubuntu-branches/ubuntu/karmic/qscintilla2/karmic

« back to all changes in this revision

Viewing changes to Qt4/Qsci/qscilexer.h

  • Committer: Bazaar Package Importer
  • Author(s): Torsten Marek
  • Date: 2009-06-20 12:11:11 UTC
  • mfrom: (1.1.3 upstream) (5.1.1 experimental)
  • Revision ID: james.westby@ubuntu.com-20090620121111-6xsr2u1usw62eprl
Tags: 2.4-3
* Upload rebuilt packages
* Fixes segfault on import

Show diffs side-by-side

added added

removed removed

Lines of Context:
52
52
class QSettings;
53
53
 
54
54
class QsciAbstractAPIs;
55
 
 
56
 
 
57
 
//! \brief The QsciLexer class is an abstract class used as a base for specific
58
 
//! existing Scintilla language lexers.
59
 
//!
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
66
 
//! language lexer.
67
 
//!
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.
 
55
class QsciScintilla;
 
56
 
 
57
 
 
58
//! \brief The QsciLexer class is an abstract class used as a base for language
 
59
//! lexers.
 
60
//!
 
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.
 
67
//!
 
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.
71
71
//!
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.
 
74
//!
 
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
77
80
{
78
81
    Q_OBJECT
89
92
    //! sub-class.
90
93
    virtual const char *language() const = 0;
91
94
 
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.
 
97
    //!
 
98
    //! \sa lexerId()
 
99
    virtual const char *lexer() const;
 
100
 
 
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.
 
104
    //!
 
105
    //! \sa lexer()
 
106
    virtual int lexerId() const;
95
107
 
96
108
    //! Returns the current API set or 0 if there isn't one.
97
109
    //!
207
219
    //! Returns the default paper colour for style number \a style.
208
220
    virtual QColor defaultPaper(int style) const;
209
221
 
 
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;}
 
225
 
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.
212
228
    //!
228
244
    //! \sa defaultPaper(), paper()
229
245
    void setDefaultPaper(const QColor &c);
230
246
 
 
247
    //! \internal Set the QsciScintilla instance that the lexer is attached to.
 
248
    virtual void setEditor(QsciScintilla *editor);
 
249
 
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();
242
261
 
 
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;
 
265
 
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.
331
354
    QColor defColor;
332
355
    QColor defPaper;
333
356
    QsciAbstractAPIs *apiSet;
 
357
    QsciScintilla *attached_editor;
334
358
 
335
359
    void setStyleDefaults() const;
336
360
    StyleData &styleData(int style) const;