Contents
Scintillua
Overview
The Scintillua Scintilla lexer has its own API to avoid any modifications to
Scintilla itself. It is invoked using SCI_PRIVATELEXERCALL
. Please note
that some of the names of the API calls do not make perfect sense. This is a
tradeoff in order to keep Scintilla unmodified.
The following notation is used:
SCI_PRIVATELEXERCALL (int operation, void *pointer)
This means you would call Scintilla like this:
SendScintilla(sci, SCI_PRIVATELEXERCALL, operation, pointer);
Scintillua Usage Example
Here is a pseudo-code example:
init_app() {
sci = scintilla_new()
lib = "/home/mitchell/app/lexers/liblexlpeg.so"
SendScintilla(sci, SCI_LOADLEXERLIBRARY, 0, lib)
}
create_doc() {
doc = SendScintilla(sci, SCI_CREATEDOCUMENT)
SendScintilla(sci, SCI_SETDOCPOINTER, 0, doc)
SendScintilla(sci, SCI_SETLEXERLANGUAGE, 0, "lpeg")
home = "/home/mitchell/app/lexers"
SendScintilla(sci, SCI_SETPROPERTY, "lexer.lpeg.home", home)
SendScintilla(sci, SCI_SETPROPERTY, "lexer.lpeg.color.theme", "light")
fn = SendScintilla(sci, SCI_GETDIRECTFUNCTION)
SendScintilla(sci, SCI_PRIVATELEXERCALL, SCI_GETDIRECTFUNCTION, fn)
psci = SendScintilla(sci, SCI_GETDIRECTPOINTER)
SendScintilla(sci, SCI_PRIVATELEXERCALL, SCI_SETDOCPOINTER, psci)
SendScintilla(sci, SCI_PRIVATELEXERCALL, SCI_SETLEXERLANGUAGE, "lua")
}
set_lexer(lang) {
psci = SendScintilla(sci, SCI_GETDIRECTPOINTER)
SendScintilla(sci, SCI_PRIVATELEXERCALL, SCI_SETDOCPOINTER, psci)
SendScintilla(sci, SCI_PRIVATELEXERCALL, SCI_SETLEXERLANGUAGE, lang)
}
Functions
SCI_PRIVATELEXERCALL
(SCI_GETDIRECTFUNCTION, SciFnDirect)
Tells Scintillua the address of the function that handles Scintilla messages.
Despite the name SCI_GETDIRECTFUNCTION
, it only notifies Scintillua what
the value of SciFnDirect
obtained from SCI_GETDIRECTFUNCTION
is. It
does not return anything.
Use this if you would like to have the Scintillua lexer set all Lua LPeg
lexer styles automatically. This is useful for maintaining a consistent color
theme. Do not use this if your application maintains its own color theme.
If you use this call, it must be made once for each Scintilla buffer that
was created using SCI_CREATEDOCUMENT
. You must also use the
SCI_SETDOCPOINTER()
Scintillua API call.
Parameters:
SCI_GETDIRECTFUNCTION
:SciFnDirect
: The pointer returned bySCI_GETDIRECTFUNCTION
.
Usage:
fn = SendScintilla(sci, SCI_GETDIRECTFUNCTION)
SendScintilla(sci, SCI_PRIVATELEXERCALL, SCI_GETDIRECTFUNCTION, fn)
See also:
SCI_PRIVATELEXERCALL
(SCI_GETLEXERLANGUAGE, languageName)
Returns the length of the string name of the current Lua LPeg lexer or stores
the name into the given buffer. If the buffer is long enough, the name is
terminated by a 0
character.
Parameters:
SCI_GETLEXERLANGUAGE
:languageName
: (char *
) If0
, returns the length that should be allocated to store the string Lua LPeg lexer name. Otherwise fills the buffer with the name.
SCI_PRIVATELEXERCALL
(styleNum, style)
Depending on the sign of styleNum
, returns the length of the associated
string for the given style number or stores the string into the given buffer.
If the buffer is long enough, the string is terminated by a 0
character.
For negative styleNum
, the associated string is a SciTE-formatted style
definition. Otherwise, the associated string is the name of the token for the
given style number.
Please see the SciTE documentation for the style definition format
specified by style.*.stylenumber
. You can parse these definitions to set
Lua LPeg lexer styles manually if you chose not to have them set
automatically using the SCI_GETDIRECTFUNCTION()
and SCI_SETDOCPOINTER()
Scintillua API calls.
Parameters:
styleNum
: (int
) For the range-STYLE_MAX <= styleNum < 0
, uses the Scintilla style number-styleNum - 1
for returning SciTE-formatted style definitions. (Style0
would be-1
, style1
would be-2
, and so on.) For the range0 <= styleNum < STYLE_MAX
, uses the normal Scintilla style number for returning token names.style
: (char *
) If0
, returns the length that should be allocated to store the associated string. Otherwise fills the buffer with the string.
Usage:
style = SendScintilla(sci, SCI_GETSTYLEAT, pos)
SendScintilla(sci, SCI_PRIVATELEXERCALL, style, token)
// token now contains the name of the style at pos
SCI_PRIVATELEXERCALL
(SCI_SETDOCPOINTER, sci)
Tells Scintillua the address of the Scintilla window currently in use.
Despite the name SCI_SETDOCPOINTER
, it has no relationship to Scintilla
documents.
Use this call only if you are using the
SCI_GETDIRECTFUNCTION()
Scintillua API call. It
must be made before each call to the
SCI_SETLEXERLANGUAGE()
Scintillua API call.
Parameters:
SCI_SETDOCPOINTER
:sci
: The pointer returned bySCI_GETDIRECTPOINTER
.
Usage:
SendScintilla(sci, SCI_PRIVATELEXERCALL, SCI_SETDOCPOINTER, sci)
See also:
SCI_PRIVATELEXERCALL
(SCI_SETLEXERLANGUAGE, languageName)
Sets the current Lua LPeg lexer to languageName
.
If you are having the Scintillua lexer set the Lua LPeg lexer styles
automatically, make sure you call the
SCI_SETDOCPOINTER()
Scintillua API first.
Parameters:
SCI_SETLEXERLANGUAGE
:languageName
: (const char*
) The name of the Lua LPeg lexer to use.
Usage:
SendScintilla(sci, SCI_PRIVATELEXERCALL, SCI_SETLEXERLANGUAGE, "lua")
See also: