From 530a3eb4303745c40aaaf7c3a36e39173688f9af Mon Sep 17 00:00:00 2001 From: mitchell <70453897+orbitalquark@users.noreply.github.com> Date: Mon, 12 Apr 2021 20:19:07 -0400 Subject: [PATCH] Updated to Scintilla 5.0.1, resulting in SCI_PRIVATELEXERCALL API changes. Scintilla 5.0.1 removes SCI_SETLEXERLANGUAGE and SCI_LOADLEXERLIBRARY, so the following API changes were made: * SCI_SETLEXERLANGUAGE -> SCI_SETILEXER (set lexer name) * SCI_LOADLEXERLIBRARY -> SCI_CREATELOADER (add path to Lua lexers) * SCI_GETLEXERLANGUAGE -> SCI_GETLEXER (get current lexer name) * SCI_PROPERTYNAMES -> SCI_GETLEXERLANGUAGE (get list of known lexers) --- LexLPeg.cxx | 14 +++--- Makefile | 4 +- README.md | 2 +- docs/api.md | 108 +++++++++++++++++++++++----------------------- docs/manual.md | 10 ++--- scintillua.luadoc | 38 ++++++++-------- 6 files changed, 88 insertions(+), 88 deletions(-) diff --git a/LexLPeg.cxx b/LexLPeg.cxx index f71b25e..c22a92b 100644 --- a/LexLPeg.cxx +++ b/LexLPeg.cxx @@ -789,7 +789,7 @@ void SCI_METHOD LexerLPeg::Fold( Sci_Position SCI_METHOD LexerLPeg::PropertySet(const char *key, const char *value) { props.Set(key, value, strlen(key), strlen(value)); if (strcmp(key, LexerHomeKey) == 0 && lexerNames.empty()) - ReadLexerNames(value); // not using SCI_LOADLEXERLIBRARY private call + ReadLexerNames(value); // not using SCI_CREATELOADER private call if (reinit && (strcmp(key, LexerHomeKey) == 0 || strcmp(key, LexerNameKey) == 0)) Init(); #if NO_SCITE else if (L && SS && sci && strncmp(key, "style.", 6) == 0) { @@ -828,7 +828,7 @@ void *SCI_METHOD LexerLPeg::PrivateCall(int code, void *arg) { if (ownLua) lua_close(L); L = reinterpret_cast(arg), ownLua = false; return nullptr; - case SCI_LOADLEXERLIBRARY: { + case SCI_CREATELOADER: { const char *path = reinterpret_cast(arg); ReadLexerNames(path); std::string home(props.Get(LexerHomeKey)); @@ -837,12 +837,12 @@ void *SCI_METHOD LexerLPeg::PrivateCall(int code, void *arg) { PropertySet(LexerHomeKey, home.c_str()); return nullptr; } - case SCI_PROPERTYNAMES: { + case SCI_GETLEXERLANGUAGE: { std::stringstream names; for (const std::string &name : lexerNames) names << name << '\n'; return StringResult(lParam, names.str().c_str()); } - case SCI_SETLEXERLANGUAGE: + case SCI_SETILEXER: if (strcmp(props.Get(LexerNameKey), reinterpret_cast(arg)) != 0) { reinit = true; PropertySet(LexerErrorKey, ""); @@ -852,7 +852,7 @@ void *SCI_METHOD LexerLPeg::PrivateCall(int code, void *arg) { else Init(); return nullptr; - case SCI_GETLEXERLANGUAGE: { + case SCI_GETLEXER: { std::string val("null"); if (!L) return StringResult(lParam, val.c_str()); RECORD_STACK_TOP(L); @@ -990,12 +990,12 @@ EXPORT_FUNCTION void CALLING_CONVENTION SetLibraryProperty(const char *key, cons EXPORT_FUNCTION ILexer5 *CALLING_CONVENTION CreateLexer(const char *name) { ILexer5 *lpegLexer = LexerLPeg::LexerFactoryLPeg(); if (!lpegHome.empty()) - lpegLexer->PrivateCall(SCI_LOADLEXERLIBRARY, const_cast(lpegHome.c_str())); + lpegLexer->PrivateCall(SCI_CREATELOADER, const_cast(lpegHome.c_str())); if (!lpegColorTheme.empty()) lpegLexer->PropertySet(LexerLPeg::LexerThemeKey, lpegColorTheme.c_str()); if (name) { if (strncmp(name, "lpeg_", 5) == 0) name += 5; // prefix used for SciTE - lpegLexer->PrivateCall(SCI_SETLEXERLANGUAGE, const_cast(name)); + lpegLexer->PrivateCall(SCI_SETILEXER, const_cast(name)); } if (strlen(lpegLexer->PropertyGet(LexerLPeg::LexerErrorKey)) > 0) { lpegLexer->Release(); diff --git a/Makefile b/Makefile index a627cfe..04712c5 100644 --- a/Makefile +++ b/Makefile @@ -93,7 +93,7 @@ test-scite: scintilla make -C scite/gtk -j4 scite/bin/SciTE # Tests, via Wine, SciTE Win64 using SciTEGlobal.properties. -wscite_zip = wscite500.zip +wscite_zip = wscite501.zip /tmp/$(wscite_zip): ; wget -O $@ https://www.scintilla.org/$(wscite_zip) /tmp/wscite: /tmp/$(wscite_zip) unzip -d /tmp $< @@ -106,7 +106,7 @@ test-wscite: /tmp/wscite # External dependencies. -scintilla_tgz = scintilla500.tgz +scintilla_tgz = scintilla501.tgz lexilla_tgz = lexilla500.tgz lua_tgz = lua-5.3.5.tar.gz lpeg_tgz = lpeg-1.0.2.tar.gz diff --git a/README.md b/README.md index 0b5f384..6dc74af 100644 --- a/README.md +++ b/README.md @@ -27,7 +27,7 @@ information of source code snippets. Scintilla is not required in that case. ## Requirements Scintillua requires Scintilla 4.4.5 or greater for a drop-in installation. When compiling -Scintillua, Scintilla 5.0.0 or greater and [Lexilla][] 5.0.0 are required. The drop-in external +Scintillua, Scintilla 5.0.1 or greater and [Lexilla][] 5.0.0 are required. The drop-in external lexer already has Lua and LPeg are pre-compiled into it. When used a standalone Lua library, Scintillua requires Lua 5.1 or greater and [LPeg][] 1.0.0 diff --git a/docs/api.md b/docs/api.md index 69c2b74..e131b60 100644 --- a/docs/api.md +++ b/docs/api.md @@ -35,13 +35,13 @@ Here is a pseudo-code example: 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") + SendScintilla(sci, SCI_PRIVATELEXERCALL, SCI_SETILEXER, "lua") } set_lexer(lang) { psci = SendScintilla(sci, SCI_GETDIRECTPOINTER) SendScintilla(sci, SCI_PRIVATELEXERCALL, SCI_SETDOCPOINTER, psci) - SendScintilla(sci, SCI_PRIVATELEXERCALL, SCI_SETLEXERLANGUAGE, lang) + SendScintilla(sci, SCI_PRIVATELEXERCALL, SCI_SETILEXER, lang) } ### Functions defined by `Scintillua` @@ -70,6 +70,24 @@ Usage: * `lua = luaL_newstate()` * `SendScintilla(sci, SCI_PRIVATELEXERCALL, SCI_CHANGELEXERSTATE, lua)` + +#### `SCI_PRIVATELEXERCALL`(SCI\_CREATELOADER, path) + +Tells Scintillua that the given path is where Scintillua's lexers are 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. + +Fields: + +* `SCI_CREATELOADER`: +* `path`: (`const char *`) A path containing Scintillua lexers and/or themes. + +Usage: + +* `SendScintilla(sci, SCI_PRIVATELEXERCALL, SCI_CREATELOADER, "path/to/lexers")` + #### `SCI_PRIVATELEXERCALL`(SCI\_GETDIRECTFUNCTION, SciFnDirect) @@ -102,8 +120,8 @@ See also: * [`SCI_SETDOCPOINTER`](#SCI_SETDOCPOINTER) - -#### `SCI_PRIVATELEXERCALL`(SCI\_GETLEXERLANGUAGE, languageName) + +#### `SCI_PRIVATELEXERCALL`(SCI\_GETLEXER, 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. @@ -115,10 +133,34 @@ or child lexer at the current caret position. In order for this to work, you mus Fields: -* `SCI_GETLEXERLANGUAGE`: +* `SCI_GETLEXER`: * `languageName`: (`char *`) If `NULL`, returns the length that should be allocated to store the string Lua LPeg lexer name. Otherwise fills the buffer with the name. + +#### `SCI_PRIVATELEXERCALL`(SCI\_GETLEXERLANGUAGE, names) + +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_SETILEXER`](#SCI_SETILEXER) Scintillua +API call. + +Fields: + +* `SCI_GETLEXERLANGUAGE`: +* `names`: (`char *`) If `NULL`, returns the length that should be allocated to store the + list of lexer names. Otherwise fills the buffer with the names. + +Usage: + +* `SendScintilla(sci, SCI_PRIVATELEXERCALL, SCI_GETLEXERLANGUAGE, lexers)` +* `// lexers now contains a '\n'-separated list of known lexer names` + +See also: + +* [`SCI_SETILEXER`](#SCI_SETILEXER) + #### `SCI_PRIVATELEXERCALL`(SCI\_GETNAMEDSTYLES, styleName) @@ -154,48 +196,6 @@ Usage: * `SendScintilla(sci, SCI_PRIVATELEXERCALL, SCI_GETSTATUS, errmsg)` * `if (strlen(errmsg) > 0) { /* handle error */ }` - -#### `SCI_PRIVATELEXERCALL`(SCI\_LOADLEXERLIBRARY, path) - -Tells Scintillua that the given path is where Scintillua's lexers are 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. - -Fields: - -* `SCI_LOADLEXERLIBRARY`: -* `path`: (`const char *`) A path containing Scintillua lexers and/or themes. - -Usage: - -* `SendScintilla(sci, SCI_PRIVATELEXERCALL, SCI_LOADLEXERLIBRARY, "path/to/lexers")` - - -#### `SCI_PRIVATELEXERCALL`(SCI\_PROPERTYNAMES, names) - -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`](#SCI_SETLEXERLANGUAGE) -Scintillua API call. - -Fields: - -* `SCI_PROPERTYNAMES`: -* `names`: (`char *`) If `NULL`, returns the length that should be allocated to store the - list of lexer names. Otherwise fills the buffer with the names. - -Usage: - -* `SendScintilla(sci, SCI_PRIVATELEXERCALL, SCI_PROPERTYNAMES, lexers)` -* `// lexers now contains a '\n'-separated list of known lexer names` - -See also: - -* [`SCI_SETLEXERLANGUAGE`](#SCI_SETLEXERLANGUAGE) - #### `SCI_PRIVATELEXERCALL`(SCI\_SETDOCPOINTER, sci) @@ -205,7 +205,7 @@ Despite the name `SCI_SETDOCPOINTER`, it has no relationship to Scintilla docume Use this call only if you are using the [`SCI_GETDIRECTFUNCTION()`](#SCI_GETDIRECTFUNCTION) Scintillua API call. It *must* be made *before* each call to the -[`SCI_SETLEXERLANGUAGE()`](#SCI_SETLEXERLANGUAGE) Scintillua API call. +[`SCI_SETILEXER()`](#SCI_SETILEXER) Scintillua API call. Fields: @@ -221,10 +221,10 @@ Usage: See also: * [`SCI_GETDIRECTFUNCTION`](#SCI_GETDIRECTFUNCTION) -* [`SCI_SETLEXERLANGUAGE`](#SCI_SETLEXERLANGUAGE) +* [`SCI_SETILEXER`](#SCI_SETILEXER) - -#### `SCI_PRIVATELEXERCALL`(SCI\_SETLEXERLANGUAGE, languageName) + +#### `SCI_PRIVATELEXERCALL`(SCI\_SETILEXER, languageName) Sets the current Lua LPeg lexer to `languageName`. @@ -233,17 +233,17 @@ sure you call the [`SCI_SETDOCPOINTER()`](#SCI_SETDOCPOINTER) Scintillua API *fi Fields: -* `SCI_SETLEXERLANGUAGE`: +* `SCI_SETILEXER`: * `languageName`: (`const char*`) The name of the Lua LPeg lexer to use. Usage: -* `SendScintilla(sci, SCI_PRIVATELEXERCALL, SCI_SETLEXERLANGUAGE, "lua")` +* `SendScintilla(sci, SCI_PRIVATELEXERCALL, SCI_SETILEXER, "lua")` See also: * [`SCI_SETDOCPOINTER`](#SCI_SETDOCPOINTER) -* [`SCI_PROPERTYNAMES`](#SCI_PROPERTYNAMES) +* [`SCI_GETLEXERLANGUAGE`](#SCI_GETLEXERLANGUAGE) #### `SCI_PRIVATELEXERCALL`(styleNum, style) diff --git a/docs/manual.md b/docs/manual.md index d8221b8..09cfa6c 100644 --- a/docs/manual.md +++ b/docs/manual.md @@ -169,9 +169,9 @@ In order to use Scintillua's lexers in your application: if you want to manage Scintilla styles yourself. 3. Call Scintillua's `CreateLexer()` with either `NULL` or the name of a Lua lexer to use in your application. -4. Call Scintilla's [SCI_SETILEXER][], passing the lexer returned in step 3. 5. If you called - `CreateLexer()` with `NULL`, then call Scintillua's [SCI_SETLEXERLANGUAGE][] [API][] to use - the given Lua lexer in your application. +4. Call [Scintilla's SCI_SETILEXER][], passing the lexer returned in step 3. +5. If you called `CreateLexer()` with `NULL`, then call Scintillua's [SCI_SETILEXER][] [API][] + to use the given Lua lexer in your application. For example, using the GTK platform: @@ -186,8 +186,8 @@ please see the [API][] Documentation. [Lua]: https://lua.org [LPeg]: http://www.inf.puc-rio.br/~roberto/lpeg/lpeg.html -[SCI_SETILEXER]: https://scintilla.org/ScintillaDoc.html#SCI_SETILEXER -[SCI_SETLEXERLANGUAGE]: api.html#SCI_SETLEXERLANGUAGE +[Scintilla's SCI_SETILEXER]: https://scintilla.org/ScintillaDoc.html#SCI_SETILEXER +[SCI_SETILEXER]: api.html#SCI_SETILEXER [API Documentation]: api.html ### Using Scintillua as a Lua Library diff --git a/scintillua.luadoc b/scintillua.luadoc index cd68a33..81a4905 100644 --- a/scintillua.luadoc +++ b/scintillua.luadoc @@ -37,13 +37,13 @@ -- 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") +-- SendScintilla(sci, SCI_PRIVATELEXERCALL, SCI_SETILEXER, "lua") -- } -- -- set_lexer(lang) { -- psci = SendScintilla(sci, SCI_GETDIRECTPOINTER) -- SendScintilla(sci, SCI_PRIVATELEXERCALL, SCI_SETDOCPOINTER, psci) --- SendScintilla(sci, SCI_PRIVATELEXERCALL, SCI_SETLEXERLANGUAGE, lang) +-- SendScintilla(sci, SCI_PRIVATELEXERCALL, SCI_SETILEXER, lang) -- } module('Scintillua') @@ -76,13 +76,13 @@ function SCI_PRIVATELEXERCALL(SCI_GETDIRECTFUNCTION, SciFnDirect) end -- -- Use this call only if you are using the [`SCI_GETDIRECTFUNCTION()`](#SCI_GETDIRECTFUNCTION) -- Scintillua API call. It *must* be made *before* each call to the --- [`SCI_SETLEXERLANGUAGE()`](#SCI_SETLEXERLANGUAGE) Scintillua API call. +-- [`SCI_SETILEXER()`](#SCI_SETILEXER) Scintillua API call. -- @param sci The pointer returned by [`SCI_GETDIRECTPOINTER`][]. -- -- [`SCI_GETDIRECTPOINTER`]: https://scintilla.org/ScintillaDoc.html#SCI_GETDIRECTPOINTER -- @usage SendScintilla(sci, SCI_PRIVATELEXERCALL, SCI_SETDOCPOINTER, sci) -- @see SCI_GETDIRECTFUNCTION --- @see SCI_SETLEXERLANGUAGE +-- @see SCI_SETILEXER -- @name SCI_SETDOCPOINTER function SCI_PRIVATELEXERCALL(SCI_SETDOCPOINTER, sci) end @@ -109,11 +109,11 @@ function SCI_PRIVATELEXERCALL(SCI_CHANGELEXERSTATE, lua) end -- If you are having the Scintillua lexer set the Lua LPeg lexer styles automatically, make -- sure you call the [`SCI_SETDOCPOINTER()`](#SCI_SETDOCPOINTER) Scintillua API *first*. -- @param languageName (`const char*`) The name of the Lua LPeg lexer to use. --- @usage SendScintilla(sci, SCI_PRIVATELEXERCALL, SCI_SETLEXERLANGUAGE, "lua") +-- @usage SendScintilla(sci, SCI_PRIVATELEXERCALL, SCI_SETILEXER, "lua") -- @see SCI_SETDOCPOINTER --- @see SCI_PROPERTYNAMES --- @name SCI_SETLEXERLANGUAGE -function SCI_PRIVATELEXERCALL(SCI_SETLEXERLANGUAGE, languageName) end +-- @see SCI_GETLEXERLANGUAGE +-- @name SCI_SETILEXER +function SCI_PRIVATELEXERCALL(SCI_SETILEXER, languageName) end --- -- Returns the length of the string name of the current Lua LPeg lexer or stores the name into @@ -125,8 +125,8 @@ function SCI_PRIVATELEXERCALL(SCI_SETLEXERLANGUAGE, languageName) end -- [`SCI_GETDIRECTFUNCTION`](#SCI_GETDIRECTFUNCTION) and [`SCI_SETDOCPOINTER`](#SCI_SETDOCPOINTER). -- @param languageName (`char *`) If `NULL`, returns the length that should be allocated to -- store the string Lua LPeg lexer name. Otherwise fills the buffer with the name. --- @name SCI_GETLEXERLANGUAGE -function SCI_PRIVATELEXERCALL(SCI_GETLEXERLANGUAGE, languageName) end +-- @name SCI_GETLEXER +function SCI_PRIVATELEXERCALL(SCI_GETLEXER, languageName) end --- -- Returns the length of the associated SciTE-formatted style definition for the given style @@ -167,23 +167,23 @@ function SCI_PRIVATELEXERCALL(SCI_GETSTATUS) end -- This call may be made multiple times in order to support lexers and themes across multiple -- directories. -- @param path (`const char *`) A path containing Scintillua lexers and/or themes. --- @usage SendScintilla(sci, SCI_PRIVATELEXERCALL, SCI_LOADLEXERLIBRARY, "path/to/lexers") --- @name SCI_LOADLEXERLIBRARY -function SCI_PRIVATELEXERCALL(SCI_LOADLEXERLIBRARY, path) end +-- @usage SendScintilla(sci, SCI_PRIVATELEXERCALL, SCI_CREATELOADER, "path/to/lexers") +-- @name SCI_CREATELOADER +function SCI_PRIVATELEXERCALL(SCI_CREATELOADER, path) end --- -- 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`](#SCI_SETLEXERLANGUAGE) --- Scintillua API call. +-- The lexers in this list can be passed to the [`SCI_SETILEXER`](#SCI_SETILEXER) Scintillua +-- API call. -- @param names (`char *`) If `NULL`, returns the length that should be allocated to store the -- list of lexer names. Otherwise fills the buffer with the names. --- @usage SendScintilla(sci, SCI_PRIVATELEXERCALL, SCI_PROPERTYNAMES, lexers) +-- @usage SendScintilla(sci, SCI_PRIVATELEXERCALL, SCI_GETLEXERLANGUAGE, lexers) -- @usage // lexers now contains a '\n'-separated list of known lexer names --- @see SCI_SETLEXERLANGUAGE --- @name SCI_PROPERTYNAMES -function SCI_PRIVATELEXERCALL(SCI_PROPERTYNAMES, names) end +-- @see SCI_SETILEXER +-- @name SCI_GETLEXERLANGUAGE +function SCI_PRIVATELEXERCALL(SCI_GETLEXERLANGUAGE, names) end --- -- Returns the style number associated with *styleName*, or `STYLE_DEFAULT` if *styleName*