Skip to content

Commit

Permalink
Updated to Scintilla 5.0.1, resulting in SCI_PRIVATELEXERCALL API cha…
Browse files Browse the repository at this point in the history
…nges.

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)
  • Loading branch information
orbitalquark committed Apr 13, 2021
1 parent 87a3687 commit 530a3eb
Show file tree
Hide file tree
Showing 6 changed files with 88 additions and 88 deletions.
14 changes: 7 additions & 7 deletions LexLPeg.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -828,7 +828,7 @@ void *SCI_METHOD LexerLPeg::PrivateCall(int code, void *arg) {
if (ownLua) lua_close(L);
L = reinterpret_cast<lua_State *>(arg), ownLua = false;
return nullptr;
case SCI_LOADLEXERLIBRARY: {
case SCI_CREATELOADER: {
const char *path = reinterpret_cast<const char *>(arg);
ReadLexerNames(path);
std::string home(props.Get(LexerHomeKey));
Expand All @@ -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<const char *>(arg)) != 0) {
reinit = true;
PropertySet(LexerErrorKey, "");
Expand All @@ -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);
Expand Down Expand Up @@ -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<char *>(lpegHome.c_str()));
lpegLexer->PrivateCall(SCI_CREATELOADER, const_cast<char *>(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<char *>(name));
lpegLexer->PrivateCall(SCI_SETILEXER, const_cast<char *>(name));
}
if (strlen(lpegLexer->PropertyGet(LexerLPeg::LexerErrorKey)) > 0) {
lpegLexer->Release();
Expand Down
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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 $<
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
108 changes: 54 additions & 54 deletions docs/api.md
Original file line number Diff line number Diff line change
Expand Up @@ -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`
Expand Down Expand Up @@ -70,6 +70,24 @@ Usage:
* `lua = luaL_newstate()`
* `SendScintilla(sci, SCI_PRIVATELEXERCALL, SCI_CHANGELEXERSTATE, lua)`

<a id="SCI_CREATELOADER"></a>
#### `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")`

<a id="SCI_GETDIRECTFUNCTION"></a>
#### `SCI_PRIVATELEXERCALL`(SCI\_GETDIRECTFUNCTION, SciFnDirect)

Expand Down Expand Up @@ -102,8 +120,8 @@ See also:

* [`SCI_SETDOCPOINTER`](#SCI_SETDOCPOINTER)

<a id="SCI_GETLEXERLANGUAGE"></a>
#### `SCI_PRIVATELEXERCALL`(SCI\_GETLEXERLANGUAGE, languageName)
<a id="SCI_GETLEXER"></a>
#### `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.
Expand All @@ -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.

<a id="SCI_GETLEXERLANGUAGE"></a>
#### `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)

<a id="SCI_GETNAMEDSTYLES"></a>
#### `SCI_PRIVATELEXERCALL`(SCI\_GETNAMEDSTYLES, styleName)

Expand Down Expand Up @@ -154,48 +196,6 @@ Usage:
* `SendScintilla(sci, SCI_PRIVATELEXERCALL, SCI_GETSTATUS, errmsg)`
* `if (strlen(errmsg) > 0) { /* handle error */ }`

<a id="SCI_LOADLEXERLIBRARY"></a>
#### `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")`

<a id="SCI_PROPERTYNAMES"></a>
#### `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)

<a id="SCI_SETDOCPOINTER"></a>
#### `SCI_PRIVATELEXERCALL`(SCI\_SETDOCPOINTER, sci)

Expand All @@ -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:

Expand All @@ -221,10 +221,10 @@ Usage:
See also:

* [`SCI_GETDIRECTFUNCTION`](#SCI_GETDIRECTFUNCTION)
* [`SCI_SETLEXERLANGUAGE`](#SCI_SETLEXERLANGUAGE)
* [`SCI_SETILEXER`](#SCI_SETILEXER)

<a id="SCI_SETLEXERLANGUAGE"></a>
#### `SCI_PRIVATELEXERCALL`(SCI\_SETLEXERLANGUAGE, languageName)
<a id="SCI_SETILEXER"></a>
#### `SCI_PRIVATELEXERCALL`(SCI\_SETILEXER, languageName)

Sets the current Lua LPeg lexer to `languageName`.

Expand All @@ -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)

<a id="styleNum"></a>
#### `SCI_PRIVATELEXERCALL`(styleNum, style)
Expand Down
10 changes: 5 additions & 5 deletions docs/manual.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:

Expand All @@ -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
Expand Down
38 changes: 19 additions & 19 deletions scintillua.luadoc
Original file line number Diff line number Diff line change
Expand Up @@ -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')

Expand Down Expand Up @@ -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

Expand All @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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*
Expand Down

0 comments on commit 530a3eb

Please sign in to comment.