|
Project Information
Members
Featured
Downloads
Wiki pages
Links
|
OverviewScintillua adds support for Lua LPeg lexers (over 80 of them) in Scintilla and SciTE. The LPeg lexer is an external lexer so no modifications to Scintilla are necessary. As of SciTE 2.22, Scintillua can be 'dropped-in' to a SciTE install. Prior to 2.21, a precompiled SciTE with some required changes was provided. With regards to speed, dynamic lexers parse the same amount of text as Scintilla's lexers; any differences in speed should be negligible. Package ContentsThis package contains the following:
Using with SciTEFirst, unpack the package to a temporary directory. If you have direct access to your SciTE installation: 1. Move the lexers/ folder to SciteDefaultHome. e.g. C:\Program Files\SciTE on Windows.2. Add 'import lexers/lpeg' to your SciTEGlobal.properties (no quotes)./usr/share/scite/ on Linux. If you do not have direct access to your SciTE installation: 1. Move the lexers/ folder to your home directory. e.g. C:\Documents and Settings\mitchell on Windows.2. Add 'import lexers/lpeg' to your SciTEUser.properties (Windows) or .SciTEUser.properties (Linux)./home/mitchell/ on Linux. 3. Modify the 'lexer.lpeg.home' property in lexers/lpeg.properties to reflect where you put the lexers/ folder. e.g lexer.lpeg.home=$(SciteUserHome)\lexerslexer.lpeg.home=$(SciteUserHome)/.lexers Additionally for 64-bit Linux machines, you will have to rename lexers/liblexlpeg.x86_64.so to lexers/liblexlpeg.so. By default, SciTE will use the LPeg lexers wherever possible, falling back to the Scintilla ones if necessary. To disable a particular LPeg lexer, open the lexers/lpeg.properties file and comment out its file.pattern.lexer and lexer.$(file.pattern.lexer) property lines. If you get incorrect or no syntax highlighting, please do the following: 1. Make sure the language has a lexer in the lexers/ directory. 2. Make sure there is a .properties file that has the language's extension. e.g. file.patterns.rhtml=*.rhtml3. Make sure the file pattern's lexer is correct or exists. e.g. lexer.$(file.patterns.rhtml)=*.rhtmllexer.$(file.patterns.java)=java I do not have the time to continuously update *.properties files with extensions and lexers, so please be patient if you have to do it manually. Please also note that SciTE lexer-specific features do not work in LPeg lexers; features like:
Using with ScintillaIf you wish to use the external lexer with an instance of Scintilla, you must set the following properties after calling SCI_SETLEXERLANGUAGE:
Optionally, you may set:
Lexer APIThe Lua LPeg lexer is responsible for managing multiple lexers and the styling information associated with them. Doing this using the Scintilla API without modifying Scintilla itself is impossible. For example, SCI_SETLEXERLANGUAGE causes Scintilla to look within its own lexer catalog for the desired lexer rather than consulting the Lua LPeg lexer. To solve these problems, a lexer API was created and is available via SCI_PRIVATELEXERCALL. Please note the names of API calls may not make perfect sense. The idea behind them was to use existing Scintilla names to maximize portability. The following notation is used: 'code(arg)' expands to 'SendScintilla(sci, SCI_PRIVATELEXERCALL, code, arg)'. SCI_GETDIRECTFUNCTION(SciFnDirect) SCI_SETLEXERLANGUAGE(languageName) SCI_GETLEXERLANGUAGE -STYLE_MAX to -1 0 to STYLE_MAX Using with your AppHere 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)
script = "/home/mitchell/app/lexers/lexer.lua"
SendScintilla(sci, SCI_SETPROPERTY, "lexer.lpeg.script", script)
SendScintilla(sci, SCI_SETPROPERTY, "lexer.lpeg.color.theme", "light")
fn = SendScintilla(sci, SCI_GETDIRECTFUNCTION)
SendScintilla(sci, SCI_PRIVATELEXERCALL, SCI_GETDIRECTFUNCTION, fn)
SendScintilla(sci, SCI_PRIVATELEXERCALL, SCI_SETDOCPOINTER, sci)
SendScintilla(sci, SCI_PRIVATELEXERCALL, SCI_SETLEXERLANGUAGE, "lua")
}
set_lexer(lang) {
SendScintilla(sci, SCI_PRIVATELEXERCALL, SCI_SETDOCPOINTER, sci)
SendScintilla(sci, SCI_PRIVATELEXERCALL, SCI_SETLEXERLANGUAGE, lang)
}Creating LexersPlease see http://caladbolg.net/luadoc/textadept/modules/lexer.html.
|