#include <qscilexer.h>
Inherits QObject.
Inherited by QsciLexerAsm, QsciLexerAVS, QsciLexerBash, QsciLexerBatch, QsciLexerCMake, QsciLexerCoffeeScript, QsciLexerCPP, QsciLexerCSS, QsciLexerCustom, QsciLexerD, QsciLexerDiff, QsciLexerEDIFACT, QsciLexerFortran77, QsciLexerHex, QsciLexerHTML, QsciLexerJSON, QsciLexerLua, QsciLexerMakefile, QsciLexerMarkdown, QsciLexerMatlab, QsciLexerPascal, QsciLexerPerl, QsciLexerPO, QsciLexerPostScript, QsciLexerPOV, QsciLexerProperties, QsciLexerPython, QsciLexerRuby, QsciLexerSpice, QsciLexerSQL, QsciLexerTCL, QsciLexerTeX, QsciLexerVerilog, QsciLexerVHDL, and QsciLexerYAML.
|
virtual void | setAutoIndentStyle (int autoindentstyle) |
|
virtual void | setColor (const QColor &c, int style=-1) |
|
virtual void | setEolFill (bool eoffill, int style=-1) |
|
virtual void | setFont (const QFont &f, int style=-1) |
|
virtual void | setPaper (const QColor &c, int style=-1) |
|
|
virtual bool | readProperties (QSettings &qs, const QString &prefix) |
|
virtual bool | writeProperties (QSettings &qs, const QString &prefix) const |
|
QByteArray | textAsBytes (const QString &text) const |
|
QString | bytesAsText (const char *bytes, int size) const |
|
The QsciLexer class is an abstract class used as a base for language lexers.
A lexer scans the text breaking it up into separate language objects, e.g. keywords, strings, operators. The lexer then uses a different style to draw each object. A style is identified by a style number and has a number of attributes, including colour and font. A specific language lexer will implement appropriate default styles which can be overriden by an application by further sub-classing the specific language lexer.
A lexer may provide one or more sets of words to be recognised as keywords. Most lexers only provide one set, but some may support languages embedded in other languages and provide several sets.
QsciLexer provides convenience methods for saving and restoring user preferences for fonts and colours.
If you want to write a lexer for a new language then you can add it to the underlying Scintilla code and implement a corresponding QsciLexer sub-class to manage the different styles used. Alternatively you can implement a sub-class of QsciLexerCustom.
◆ QsciLexer()
QsciLexer::QsciLexer |
( |
QObject * |
parent = 0 | ) |
|
◆ language()
virtual const char* QsciLexer::language |
( |
| ) |
const |
|
pure virtual |
Returns the name of the language. It must be re-implemented by a sub-class.
Implemented in QsciLexerYAML, QsciLexerXML, QsciLexerVHDL, QsciLexerVerilog, QsciLexerTeX, QsciLexerTekHex, QsciLexerTCL, QsciLexerSRec, QsciLexerSQL, QsciLexerSpice, QsciLexerRuby, QsciLexerPython, QsciLexerProperties, QsciLexerPOV, QsciLexerPostScript, QsciLexerPO, QsciLexerPerl, QsciLexerPascal, QsciLexerOctave, QsciLexerNASM, QsciLexerMatlab, QsciLexerMASM, QsciLexerMarkdown, QsciLexerMakefile, QsciLexerLua, QsciLexerJSON, QsciLexerJavaScript, QsciLexerJava, QsciLexerIntelHex, QsciLexerIDL, QsciLexerHTML, QsciLexerFortran77, QsciLexerFortran, QsciLexerEDIFACT, QsciLexerDiff, QsciLexerD, QsciLexerCSS, QsciLexerCSharp, QsciLexerCPP, QsciLexerCoffeeScript, QsciLexerCMake, QsciLexerBatch, QsciLexerBash, and QsciLexerAVS.
◆ lexer()
virtual const char* QsciLexer::lexer |
( |
| ) |
const |
|
virtual |
Returns the name of the lexer. If 0 is returned then the lexer's numeric identifier is used. The default implementation returns 0.
- See also
- lexerId()
Reimplemented in QsciLexerYAML, QsciLexerXML, QsciLexerVHDL, QsciLexerVerilog, QsciLexerTeX, QsciLexerTekHex, QsciLexerTCL, QsciLexerSRec, QsciLexerSQL, QsciLexerSpice, QsciLexerRuby, QsciLexerPython, QsciLexerProperties, QsciLexerPOV, QsciLexerPostScript, QsciLexerPO, QsciLexerPerl, QsciLexerPascal, QsciLexerOctave, QsciLexerNASM, QsciLexerMatlab, QsciLexerMASM, QsciLexerMarkdown, QsciLexerMakefile, QsciLexerLua, QsciLexerJSON, QsciLexerIntelHex, QsciLexerHTML, QsciLexerFortran77, QsciLexerFortran, QsciLexerEDIFACT, QsciLexerDiff, QsciLexerD, QsciLexerCSS, QsciLexerCPP, QsciLexerCoffeeScript, QsciLexerCMake, QsciLexerBatch, QsciLexerBash, and QsciLexerAVS.
◆ lexerId()
virtual int QsciLexer::lexerId |
( |
| ) |
const |
|
virtual |
◆ apis()
Returns the current API set or 0 if there isn't one.
- See also
- setAPIs()
◆ autoCompletionWordSeparators()
virtual QStringList QsciLexer::autoCompletionWordSeparators |
( |
| ) |
const |
|
virtual |
◆ autoIndentStyle()
int QsciLexer::autoIndentStyle |
( |
| ) |
|
◆ blockEnd()
virtual const char* QsciLexer::blockEnd |
( |
int * |
style = 0 | ) |
const |
|
virtual |
◆ blockLookback()
virtual int QsciLexer::blockLookback |
( |
| ) |
const |
|
virtual |
Returns the number of lines prior to the current one when determining the scope of a block when auto-indenting.
Reimplemented in QsciLexerPython.
◆ blockStart()
virtual const char* QsciLexer::blockStart |
( |
int * |
style = 0 | ) |
const |
|
virtual |
◆ blockStartKeyword()
virtual const char* QsciLexer::blockStartKeyword |
( |
int * |
style = 0 | ) |
const |
|
virtual |
◆ color()
virtual QColor QsciLexer::color |
( |
int |
style | ) |
const |
|
virtual |
◆ eolFill()
virtual bool QsciLexer::eolFill |
( |
int |
style | ) |
const |
|
virtual |
Returns the end-of-line for style number style. The default is false.
◆ font()
virtual QFont QsciLexer::font |
( |
int |
style | ) |
const |
|
virtual |
◆ keywords()
virtual const char* QsciLexer::keywords |
( |
int |
set | ) |
const |
|
virtual |
Returns the set of keywords for the keyword set set recognised by the lexer as a space separated string. Keyword sets are numbered from 1. 0 is returned if there is no such set.
Reimplemented in QsciLexerYAML, QsciLexerXML, QsciLexerVHDL, QsciLexerVerilog, QsciLexerTeX, QsciLexerTCL, QsciLexerSQL, QsciLexerSpice, QsciLexerRuby, QsciLexerPython, QsciLexerPOV, QsciLexerPostScript, QsciLexerPerl, QsciLexerPascal, QsciLexerOctave, QsciLexerMatlab, QsciLexerLua, QsciLexerJSON, QsciLexerJavaScript, QsciLexerJava, QsciLexerIDL, QsciLexerHTML, QsciLexerFortran77, QsciLexerFortran, QsciLexerD, QsciLexerCSS, QsciLexerCSharp, QsciLexerCPP, QsciLexerCoffeeScript, QsciLexerCMake, QsciLexerBatch, QsciLexerBash, QsciLexerAVS, and QsciLexerAsm.
◆ defaultStyle()
virtual int QsciLexer::defaultStyle |
( |
| ) |
const |
|
virtual |
Returns the number of the style used for whitespace. The default implementation returns 0 which is the convention adopted by most lexers.
◆ description()
virtual QString QsciLexer::description |
( |
int |
style | ) |
const |
|
pure virtual |
Returns the descriptive name for style number style. For a valid style number for this language a non-empty QString must be returned. If the style number is invalid then an empty QString must be returned. This is intended to be used in user preference dialogs.
Implemented in QsciLexerYAML, QsciLexerVHDL, QsciLexerVerilog, QsciLexerTeX, QsciLexerTekHex, QsciLexerTCL, QsciLexerSRec, QsciLexerSQL, QsciLexerSpice, QsciLexerRuby, QsciLexerPython, QsciLexerProperties, QsciLexerPOV, QsciLexerPostScript, QsciLexerPO, QsciLexerPerl, QsciLexerPascal, QsciLexerMatlab, QsciLexerMarkdown, QsciLexerMakefile, QsciLexerLua, QsciLexerJSON, QsciLexerJavaScript, QsciLexerIntelHex, QsciLexerIDL, QsciLexerHTML, QsciLexerHex, QsciLexerFortran77, QsciLexerEDIFACT, QsciLexerDiff, QsciLexerD, QsciLexerCSS, QsciLexerCSharp, QsciLexerCPP, QsciLexerCoffeeScript, QsciLexerCMake, QsciLexerBatch, QsciLexerBash, QsciLexerAVS, and QsciLexerAsm.
◆ paper()
virtual QColor QsciLexer::paper |
( |
int |
style | ) |
const |
|
virtual |
◆ defaultColor()
QColor QsciLexer::defaultColor |
( |
| ) |
const |
◆ defaultEolFill()
virtual bool QsciLexer::defaultEolFill |
( |
int |
style | ) |
const |
|
virtual |
Returns the default end-of-line for style number style. The default is false.
Reimplemented in QsciLexerYAML, QsciLexerXML, QsciLexerVHDL, QsciLexerVerilog, QsciLexerTCL, QsciLexerSQL, QsciLexerRuby, QsciLexerPython, QsciLexerProperties, QsciLexerPOV, QsciLexerPerl, QsciLexerPascal, QsciLexerMakefile, QsciLexerLua, QsciLexerJSON, QsciLexerJavaScript, QsciLexerHTML, QsciLexerFortran77, QsciLexerD, QsciLexerCSharp, QsciLexerCPP, QsciLexerCoffeeScript, QsciLexerBatch, QsciLexerBash, and QsciLexerAsm.
◆ defaultFont()
QFont QsciLexer::defaultFont |
( |
| ) |
const |
◆ defaultPaper()
QColor QsciLexer::defaultPaper |
( |
| ) |
const |
◆ editor()
Returns the QsciScintilla instance that the lexer is currently attached to or 0 if it is unattached.
◆ setAPIs()
The current set of APIs is set to apis. If apis is 0 then any existing APIs for this lexer are removed.
- See also
- apis()
◆ setDefaultColor()
void QsciLexer::setDefaultColor |
( |
const QColor & |
c | ) |
|
◆ setDefaultFont()
void QsciLexer::setDefaultFont |
( |
const QFont & |
f | ) |
|
◆ setDefaultPaper()
void QsciLexer::setDefaultPaper |
( |
const QColor & |
c | ) |
|
◆ readSettings()
bool QsciLexer::readSettings |
( |
QSettings & |
qs, |
|
|
const char * |
prefix = "/Scintilla" |
|
) |
| |
The colour, paper, font and end-of-line for each style number, and all lexer specific properties are read from the settings qs. prefix is prepended to the key of each entry. true is returned if there was no error.
- See also
- writeSettings(), QsciScintilla::setLexer()
◆ refreshProperties()
virtual void QsciLexer::refreshProperties |
( |
| ) |
|
|
virtual |
Causes all properties to be refreshed by emitting the propertyChanged() signal as required.
Reimplemented in QsciLexerYAML, QsciLexerXML, QsciLexerVHDL, QsciLexerVerilog, QsciLexerTeX, QsciLexerTCL, QsciLexerSQL, QsciLexerRuby, QsciLexerPython, QsciLexerProperties, QsciLexerPOV, QsciLexerPostScript, QsciLexerPO, QsciLexerPerl, QsciLexerPascal, QsciLexerLua, QsciLexerJSON, QsciLexerHTML, QsciLexerFortran77, QsciLexerD, QsciLexerCSS, QsciLexerCPP, QsciLexerCoffeeScript, QsciLexerCMake, QsciLexerBash, QsciLexerAVS, and QsciLexerAsm.
◆ styleBitsNeeded()
virtual int QsciLexer::styleBitsNeeded |
( |
| ) |
const |
|
virtual |
Returns the number of style bits needed by the lexer. Normally this should only be re-implemented by custom lexers. This is deprecated and no longer has any effect.
Reimplemented in QsciLexerCustom.
◆ wordCharacters()
virtual const char* QsciLexer::wordCharacters |
( |
| ) |
const |
|
virtual |
Returns the string of characters that comprise a word. The default is 0 which implies the upper and lower case alphabetic characters and underscore.
Reimplemented in QsciLexerVerilog, QsciLexerTeX, QsciLexerProperties, QsciLexerPOV, QsciLexerPerl, QsciLexerMakefile, QsciLexerHTML, QsciLexerDiff, QsciLexerD, QsciLexerCSS, QsciLexerCPP, QsciLexerCoffeeScript, QsciLexerBatch, QsciLexerBash, and QsciLexerAVS.
◆ writeSettings()
bool QsciLexer::writeSettings |
( |
QSettings & |
qs, |
|
|
const char * |
prefix = "/Scintilla" |
|
) |
| const |
The colour, paper, font and end-of-line for each style number, and all lexer specific properties are written to the settings qs. prefix is prepended to the key of each entry. true is returned if there was no error.
- See also
- readSettings()
◆ setAutoIndentStyle
virtual void QsciLexer::setAutoIndentStyle |
( |
int |
autoindentstyle | ) |
|
|
virtualslot |
◆ setColor
virtual void QsciLexer::setColor |
( |
const QColor & |
c, |
|
|
int |
style = -1 |
|
) |
| |
|
virtualslot |
The foreground colour for style number style is set to c. If style is -1 then the colour is set for all styles.
◆ setEolFill
virtual void QsciLexer::setEolFill |
( |
bool |
eoffill, |
|
|
int |
style = -1 |
|
) |
| |
|
virtualslot |
The end-of-line fill for style number style is set to eoffill. If style is -1 then the fill is set for all styles.
◆ setFont
virtual void QsciLexer::setFont |
( |
const QFont & |
f, |
|
|
int |
style = -1 |
|
) |
| |
|
virtualslot |
The font for style number style is set to f. If style is -1 then the font is set for all styles.
◆ setPaper
virtual void QsciLexer::setPaper |
( |
const QColor & |
c, |
|
|
int |
style = -1 |
|
) |
| |
|
virtualslot |
The background colour for style number style is set to c. If style is -1 then the colour is set for all styles.
◆ colorChanged
void QsciLexer::colorChanged |
( |
const QColor & |
c, |
|
|
int |
style |
|
) |
| |
|
signal |
This signal is emitted when the foreground colour of style number style has changed. The new colour is c.
◆ eolFillChanged
void QsciLexer::eolFillChanged |
( |
bool |
eolfilled, |
|
|
int |
style |
|
) |
| |
|
signal |
This signal is emitted when the end-of-file fill of style number style has changed. The new fill is eolfilled.
◆ fontChanged
void QsciLexer::fontChanged |
( |
const QFont & |
f, |
|
|
int |
style |
|
) |
| |
|
signal |
This signal is emitted when the font of style number style has changed. The new font is f.
◆ paperChanged
void QsciLexer::paperChanged |
( |
const QColor & |
c, |
|
|
int |
style |
|
) |
| |
|
signal |
This signal is emitted when the background colour of style number style has changed. The new colour is c.
◆ propertyChanged
void QsciLexer::propertyChanged |
( |
const char * |
prop, |
|
|
const char * |
val |
|
) |
| |
|
signal |
This signal is emitted when the value of the lexer property prop needs to be changed. The new value is val.
◆ readProperties()
virtual bool QsciLexer::readProperties |
( |
QSettings & |
qs, |
|
|
const QString & |
prefix |
|
) |
| |
|
protectedvirtual |
The lexer's properties are read from the settings qs. 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.
Reimplemented in QsciLexerYAML, QsciLexerXML, QsciLexerVHDL, QsciLexerVerilog, QsciLexerTeX, QsciLexerTCL, QsciLexerSQL, QsciLexerRuby, QsciLexerPython, QsciLexerProperties, QsciLexerPOV, QsciLexerPostScript, QsciLexerPO, QsciLexerPerl, QsciLexerPascal, QsciLexerLua, QsciLexerJSON, QsciLexerHTML, QsciLexerFortran77, QsciLexerD, QsciLexerCSS, QsciLexerCPP, QsciLexerCoffeeScript, QsciLexerCMake, QsciLexerBash, QsciLexerAVS, and QsciLexerAsm.
◆ writeProperties()
virtual bool QsciLexer::writeProperties |
( |
QSettings & |
qs, |
|
|
const QString & |
prefix |
|
) |
| const |
|
protectedvirtual |
The lexer's properties are written to the settings qs. 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.
Reimplemented in QsciLexerYAML, QsciLexerXML, QsciLexerVHDL, QsciLexerVerilog, QsciLexerTeX, QsciLexerTCL, QsciLexerSQL, QsciLexerRuby, QsciLexerPython, QsciLexerProperties, QsciLexerPOV, QsciLexerPostScript, QsciLexerPO, QsciLexerPerl, QsciLexerPascal, QsciLexerLua, QsciLexerJSON, QsciLexerHTML, QsciLexerFortran77, QsciLexerD, QsciLexerCSS, QsciLexerCPP, QsciLexerCoffeeScript, QsciLexerCMake, QsciLexerBash, QsciLexerAVS, and QsciLexerAsm.