From e02a7b49e160cbc00d763a979d99deb3b48a8488 Mon Sep 17 00:00:00 2001 From: mitchell Date: Sat, 7 Mar 2020 20:30:24 -0500 Subject: LexLPeg can now report a list of known lexers via SCI_PRIVATELEXERCALL. --- doc/LPegLexer.html | 77 +++++++++++++++++++++++++++++++++++++++++++++--------- 1 file changed, 64 insertions(+), 13 deletions(-) (limited to 'doc') diff --git a/doc/LPegLexer.html b/doc/LPegLexer.html index 52e0202d4..02b1dbdd2 100644 --- a/doc/LPegLexer.html +++ b/doc/LPegLexer.html @@ -147,7 +147,19 @@ selecting it as the lexer to use via SCI_SETLEXER or SCI_SETLEXERLANGUAGE, - the following property must be set via + you must call + SCI_PRIVATELEXERCALL + with + SCI_LOADLEXERLIBRARY + and the path to where you included Scintilla's lexlua/ + directory in your application's installation location. If you prefer not to + use SCI_PRIVATELEXERCALL, you may instead set via + SCI_SETPROPERTY + the lexer.lpeg.home lexer property to the location of + lexlua/. + +

The following properties are recognized by the LPeg lexer and can be set + via SCI_SETPROPERTY:

@@ -157,21 +169,23 @@ + your application's installation location. It is automatically set when + calling + SCI_PRIVATELEXERCALL + with + SCI_LOADLEXERLIBRARY. + Lexers across multiple directories can be used by separating + directories with a ; character. - -
The directory containing the Lua lexers. This is the path where you included Scintilla's lexlua/ directory in - your application's installation location.
- -

The following properties are optional and may or may not be set:

- - @@ -243,13 +257,13 @@ doc = SendScintilla(sci, SCI_CREATEDOCUMENT, 0, 0) SendScintilla(sci, SCI_SETDOCPOINTER, 0, doc) SendScintilla(sci, SCI_SETLEXERLANGUAGE, 0, "lpeg") - home = "/home/mitchell/app/lua_lexers" - SendScintilla(sci, SCI_SETPROPERTY, "lexer.lpeg.home", home) SendScintilla(sci, SCI_SETPROPERTY, "lexer.lpeg.color.theme", "light") fn = SendScintilla(sci, SCI_GETDIRECTFUNCTION, 0, 0) SendScintilla(sci, SCI_PRIVATELEXERCALL, SCI_GETDIRECTFUNCTION, fn) psci = SendScintilla(sci, SCI_GETDIRECTPOINTER, 0, 0) SendScintilla(sci, SCI_PRIVATELEXERCALL, SCI_SETDOCPOINTER, psci) + home = "/home/mitchell/app/lua_lexers" + SendScintilla(sci, SCI_PRIVATELEXERCALL, SCI_LOADLEXERLIBRARY, home); SendScintilla(sci, SCI_PRIVATELEXERCALL, SCI_SETLEXERLANGUAGE, "lua") } @@ -264,6 +278,8 @@ SCI_PRIVATELEXERCALL(SCI_GETDIRECTFUNCTION, int SciFnDirect)
SCI_PRIVATELEXERCALL(SCI_GETLEXERLANGUAGE, char *languageName) → int
SCI_PRIVATELEXERCALL(SCI_GETSTATUS, char *errorMessage) → int
+ SCI_PRIVATELEXERCALL(SCI_LOADLEXERLIBRARY, const char *path)
+ SCI_PRIVATELEXERCALL(SCI_PROPERTYNAMES, char *names) → int
SCI_PRIVATELEXERCALL(int styleNum, char *styleName) → int
SCI_PRIVATELEXERCALL(SCI_SETDOCPOINTER, int sci)
SCI_PRIVATELEXERCALL(SCI_SETLEXERLANGUAGE, languageName)
@@ -352,6 +368,39 @@ if (strlen(errmsg) > 0) { /* handle error */ } +

SCI_PRIVATELEXERCALL(SCI_LOADLEXERLIBRARY, const char *path)
+ Tells the LPeg lexer that the given path is where a copy of Scintilla's + lexlua/ is located, or is a path that contains additional + lexers and/or themes to load (e.g. user-defined lexers/themes).

+ +

This call may be made multiple times in order to support lexers and + themes across multiple directories.

+ +

Usage:

+ +

+    SendScintilla(sci, SCI_PRIVATELEXERCALL, SCI_LOADLEXERLIBRARY, "path/to/lexlua")
+    
+ +

SCI_PRIVATELEXERCALL(SCI_PRIVATELEXERCALL, char *names) → int
+ Returns the length of a '\n'-separated list of known lexer names, or stores + the lexer list into the given buffer. If the buffer is long enough, the + string is terminated by a 0 character.

+ +

The lexers in this list can be passed to the + SCI_SETLEXERLANGUAGE + LPeg Lexer API call.

+ +

Usage:

+ +

+    SendScintilla(sci, SCI_PRIVATELEXERCALL, SCI_PROPERTYNAMES, lexers)
+    // lexers now contains a '\n'-separated list of known lexer names
+    
+ +

See also: + SCI_SETLEXERLANGUAGE

+

SCI_PRIVATELEXERCALL(int styleNum, char *styleName) → int
Returns the length of the token name associated with the given style number or stores the style name into the given buffer. If the buffer is long @@ -403,7 +452,9 @@ SendScintilla(sci, SCI_PRIVATELEXERCALL, SCI_SETLEXERLANGUAGE, "lua") -

See also: SCI_SETDOCPOINTER

+

See also: + SCI_SETDOCPOINTER, + SCI_PROPERTYNAMES

Using Scintilla as a Lua Library

-- cgit v1.2.3
lexer.lpeg.color.theme The color theme to use. Color themes are located in the - lexlua/themes/ directory. Currently supported themes - are light, dark, scite, and + lexlua/themes/ directory. (They can also be located in + any themes subdirectories of additional paths specified + in lexer.lpeg.home.) Currently supported themes are + light, dark, scite, and curses. Your application can define colors and styles manually through Scintilla properties. The theme files have examples.