From d5ca0474b5e15091b94c01f878e251f4263b9192 Mon Sep 17 00:00:00 2001
From: mitchell
Date: Tue, 26 May 2020 14:21:43 -0400
Subject: Added SCI_PRIVATELEXERCALL API for retrieving the style number of a
style name.
---
doc/LPegLexer.html | 13 ++++++++++++-
lexers/LexLPeg.cxx | 12 +++++++++---
2 files changed, 21 insertions(+), 4 deletions(-)
diff --git a/doc/LPegLexer.html b/doc/LPegLexer.html
index 3f553e9f9..1cb85599f 100644
--- a/doc/LPegLexer.html
+++ b/doc/LPegLexer.html
@@ -289,7 +289,8 @@
SCI_PRIVATELEXERCALL(SCI_LOADLEXERLIBRARY, const char *path)
SCI_PRIVATELEXERCALL(SCI_PROPERTYNAMES, char *names) → int
SCI_PRIVATELEXERCALL(SCI_SETDOCPOINTER, int sci)
- SCI_PRIVATELEXERCALL(SCI_SETLEXERLANGUAGE, languageName)
+ SCI_PRIVATELEXERCALL(SCI_SETLEXERLANGUAGE, char *languageName)
+ SCI_PRIVATELEXERCALL(SCI_GETNAMEDSTYLES, char *styleName) → int
SCI_NAMEOFSTYLE(int style, char *name) → int
@@ -451,6 +452,16 @@
SCI_SETDOCPOINTER,
SCI_PROPERTYNAMES
+ SCI_PRIVATELEXERCALL(SCI_GETNAMEDSTYLES, const char *styleName)
+ Returns the style number associated with styleName.
+
+ Usage:
+
+
+ style = SendScintilla(sci, SCI_PRIVATELEXERCALL, SCI_GETNAMEDSTYLES, "error")
+ SendScintilla(sci, SCI_ANNOTATIONSETSTYLE, line, style) // match error style
+
+
SCI_NAMEOFSTYLE(int style, char *name) → int
Retrieves the name of a style. Note this is not a
SCI_PRIVATELEXERCALL.
diff --git a/lexers/LexLPeg.cxx b/lexers/LexLPeg.cxx
index a34b10fda..60626fd3b 100644
--- a/lexers/LexLPeg.cxx
+++ b/lexers/LexLPeg.cxx
@@ -806,14 +806,14 @@ public:
auto lParam = reinterpret_cast(arg);
switch(code) {
case SCI_GETDIRECTFUNCTION:
- SS = reinterpret_cast(lParam);
+ SS = reinterpret_cast(arg);
return nullptr;
case SCI_SETDOCPOINTER:
sci = lParam;
return nullptr;
case SCI_CHANGELEXERSTATE:
if (ownLua) lua_close(L);
- L = reinterpret_cast(lParam), ownLua = false;
+ L = reinterpret_cast(arg), ownLua = false;
return nullptr;
case SCI_LOADLEXERLIBRARY: {
const char *path = reinterpret_cast(arg);
@@ -858,7 +858,13 @@ public:
}
val.append(val, 0, val.length() - 1); // "lexer/lexer" fallback
return StringResult(lParam, val.c_str());
- } case SCI_GETSTATUS:
+ } case SCI_GETNAMEDSTYLES:
+ if (!L) return reinterpret_cast(STYLE_DEFAULT);
+ for (int i = 0; i < STYLE_MAX; i++)
+ if (strcmp(NameOfStyle(i), reinterpret_cast(arg)) == 0)
+ return reinterpret_cast(i);
+ return reinterpret_cast(STYLE_DEFAULT);
+ case SCI_GETSTATUS:
return StringResult(lParam, props.Get(LexerErrorKey));
}
return nullptr;
--
cgit v1.2.3