aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--doc/ScintillaDoc.html10
-rw-r--r--doc/ScintillaHistory.html3
-rw-r--r--include/Scintilla.h1
-rw-r--r--include/Scintilla.iface3
-rw-r--r--src/ScintillaBase.cxx43
-rw-r--r--src/ScintillaBase.h5
-rw-r--r--win32/DepGen.py3
-rw-r--r--win32/deps.mak9
-rw-r--r--win32/makefile18
-rw-r--r--win32/nmdeps.mak9
-rw-r--r--win32/scintilla.mak16
11 files changed, 93 insertions, 27 deletions
diff --git a/doc/ScintillaDoc.html b/doc/ScintillaDoc.html
index 53bfec16a..b4eae90ea 100644
--- a/doc/ScintillaDoc.html
+++ b/doc/ScintillaDoc.html
@@ -269,7 +269,7 @@
<h2 class="provisional">Lexilla</h2>
<p>For Scintilla 5.0, lexers will be split off into a separate Lexilla library.
- Scintilla will be responsible for the GUI and calling lexers and Lexilla will provide the lexers.
+ Scintilla will be responsible for the GUI and calling lexers with Lexilla providing the lexers.
To allow work towards this with Scintilla 4.x, the first stage is to allow building Lexilla but
also include the lexers in Scintilla.</p>
@@ -288,6 +288,9 @@
is exposed which will create a lexer object (ILexer5 *) for any object lexer or function lexer.
</p>
+ <p>A lexer created by Lexilla may be used in Scintilla by calling
+ <a class="seealso" href="#SCI_SETILEXER">SCI_SETILEXER</a>.</p>
+
<h2 id="MessageCategories">Contents</h2>
<table class="categories" summary="Message categories">
@@ -6891,6 +6894,7 @@ sptr_t CallScintilla(unsigned int iMessage, uptr_t wParam, sptr_t lParam){
<a class="message" href="#SCI_SETLEXERLANGUAGE">SCI_SETLEXERLANGUAGE(&lt;unused&gt;, const char
*language)</a><br />
<a class="message" href="#SCI_GETLEXERLANGUAGE">SCI_GETLEXERLANGUAGE(&lt;unused&gt;, char *language) &rarr; int</a><br />
+ <a class="message" href="#SCI_SETILEXER">SCI_SETILEXER(&lt;unused&gt;, pointer lexer)</a><br />
<a class="message" href="#SCI_LOADLEXERLIBRARY">SCI_LOADLEXERLIBRARY(&lt;unused&gt;, const char
*path)</a><br />
<a class="message" href="#SCI_COLOURISE">SCI_COLOURISE(position start, position end)</a><br />
@@ -6941,6 +6945,10 @@ sptr_t CallScintilla(unsigned int iMessage, uptr_t wParam, sptr_t lParam){
<code>Lex*.cxx</code> file and search for <code>LexerModule</code>. The third argument in the
<code>LexerModule</code> constructor is the name to use.</p>
+ <p class="provisional"><b id="SCI_SETILEXER">SCI_SETILEXER(&lt;unused&gt;, pointer lexer)</b><br />
+ <code>SCI_SETILEXER</code> allows setting a lexer as an <code>ILexer5*</code>.
+ The lexer may be implemented by an application or a shared library such as Lexilla.</p>
+
<p>To test if your lexer assignment worked, use <a class="message"
href="#SCI_GETLEXER"><code>SCI_GETLEXER</code></a> before and after setting the new lexer to
see if the lexer number changed.</p>
diff --git a/doc/ScintillaHistory.html b/doc/ScintillaHistory.html
index 282118ded..af9c8a49c 100644
--- a/doc/ScintillaHistory.html
+++ b/doc/ScintillaHistory.html
@@ -570,6 +570,9 @@
Lexers made available as Lexilla library.
</li>
<li>
+ SCI_SETILEXER implemented to use lexers from Lexilla or other sources.
+ </li>
+ <li>
ILexer5 interface defined provisionally to support use of Lexilla.
The details of this interface may change before being stabilised in Scintilla 5.0.
</li>
diff --git a/include/Scintilla.h b/include/Scintilla.h
index b5fc17eb6..b9a013655 100644
--- a/include/Scintilla.h
+++ b/include/Scintilla.h
@@ -1037,6 +1037,7 @@ typedef sptr_t (*SciFnDirect)(sptr_t ptr, unsigned int iMessage, uptr_t wParam,
#define SCI_NAMEOFSTYLE 4030
#define SCI_TAGSOFSTYLE 4031
#define SCI_DESCRIPTIONOFSTYLE 4032
+#define SCI_SETILEXER 4033
#define SC_MOD_NONE 0x0
#define SC_MOD_INSERTTEXT 0x1
#define SC_MOD_DELETETEXT 0x2
diff --git a/include/Scintilla.iface b/include/Scintilla.iface
index dde113847..fecd1b45f 100644
--- a/include/Scintilla.iface
+++ b/include/Scintilla.iface
@@ -2931,6 +2931,9 @@ fun int TagsOfStyle=4031(int style, stringresult tags)
# Result is NUL-terminated.
fun int DescriptionOfStyle=4032(int style, stringresult description)
+# Set the lexer from an ILexer*.
+set void SetILexer=4033(, pointer ilexer)
+
# Notifications
# Type of modification and the action which caused the modification.
# These are defined as a bit mask to make it easy to specify which notifications are wanted.
diff --git a/src/ScintillaBase.cxx b/src/ScintillaBase.cxx
index c1f3b995a..055d61f91 100644
--- a/src/ScintillaBase.cxx
+++ b/src/ScintillaBase.cxx
@@ -24,9 +24,7 @@
#include "ILexer.h"
#include "Scintilla.h"
-#ifdef SCI_LEXER
#include "SciLexer.h"
-#endif
#include "PropSetSimple.h"
#include "CharacterCategory.h"
@@ -60,9 +58,7 @@
#include "AutoComplete.h"
#include "ScintillaBase.h"
-#ifdef SCI_LEXER
#include "ExternalLexer.h"
-#endif
using namespace Scintilla;
@@ -547,8 +543,6 @@ void ScintillaBase::RightButtonDownWithModifiers(Point pt, unsigned int curTime,
Editor::RightButtonDownWithModifiers(pt, curTime, modifiers);
}
-#ifdef SCI_LEXER
-
namespace Scintilla {
class LexState : public LexInterface {
@@ -560,6 +554,7 @@ public:
int lexLanguage;
explicit LexState(Document *pdoc_);
+ void SetInstance(ILexer5 *instance_);
// Deleted so LexState objects can not be copied.
LexState(const LexState &) = delete;
LexState(LexState &&) = delete;
@@ -568,8 +563,10 @@ public:
~LexState() override;
void SetLexer(uptr_t wParam);
void SetLexerLanguage(const char *languageName);
+
const char *DescribeWordListSets();
void SetWordList(int n, const char *wl);
+ int GetIdentifier() const;
const char *GetName() const;
void *PrivateCall(int operation, void *pointer);
const char *PropertyNames();
@@ -612,6 +609,15 @@ LexState::~LexState() {
}
}
+void LexState::SetInstance(ILexer5 *instance_) {
+ if (instance) {
+ instance->Release();
+ instance = nullptr;
+ }
+ instance = instance_;
+ pdoc->LexerChanged();
+}
+
LexState *ScintillaBase::DocumentLexState() {
if (!pdoc->GetLexInterface()) {
pdoc->SetLexInterface(new LexState(pdoc));
@@ -674,7 +680,15 @@ void LexState::SetWordList(int n, const char *wl) {
}
const char *LexState::GetName() const {
- return lexCurrent ? lexCurrent->languageName : "";
+ if (lexCurrent) {
+ return lexCurrent->languageName;
+ }
+ if (instance) {
+ if (instance->Version() >= lvRelease5) {
+ return instance->GetName();
+ }
+ }
+ return "";
}
void *LexState::PrivateCall(int operation, void *pointer) {
@@ -832,10 +846,7 @@ const char *LexState::DescriptionOfStyle(int style) {
}
}
-#endif
-
void ScintillaBase::NotifyStyleToNeeded(Sci::Position endStyleNeeded) {
-#ifdef SCI_LEXER
if (DocumentLexState()->lexLanguage != SCLEX_CONTAINER) {
const Sci::Line lineEndStyled =
pdoc->SciLineFromPosition(pdoc->GetEndStyled());
@@ -844,14 +855,11 @@ void ScintillaBase::NotifyStyleToNeeded(Sci::Position endStyleNeeded) {
DocumentLexState()->Colourise(endStyled, endStyleNeeded);
return;
}
-#endif
Editor::NotifyStyleToNeeded(endStyleNeeded);
}
void ScintillaBase::NotifyLexerChanged(Document *, void *) {
-#ifdef SCI_LEXER
vs.EnsureStyle(0xff);
-#endif
}
sptr_t ScintillaBase::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) {
@@ -1049,7 +1057,6 @@ sptr_t ScintillaBase::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lPara
displayPopupMenu = static_cast<int>(wParam);
break;
-#ifdef SCI_LEXER
case SCI_SETLEXER:
DocumentLexState()->SetLexer(static_cast<int>(wParam));
break;
@@ -1057,6 +1064,10 @@ sptr_t ScintillaBase::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lPara
case SCI_GETLEXER:
return DocumentLexState()->lexLanguage;
+ case SCI_SETILEXER:
+ DocumentLexState()->SetInstance(reinterpret_cast<ILexer5 *>(lParam));
+ return 0;
+
case SCI_COLOURISE:
if (DocumentLexState()->lexLanguage == SCLEX_CONTAINER) {
pdoc->ModifiedAt(static_cast<Sci::Position>(wParam));
@@ -1093,9 +1104,11 @@ sptr_t ScintillaBase::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lPara
case SCI_GETLEXERLANGUAGE:
return StringResult(lParam, DocumentLexState()->GetName());
+#ifdef SCI_LEXER
case SCI_LOADLEXERLIBRARY:
ExternalLexerLoad(ConstCharPtrFromSPtr(lParam));
break;
+#endif
case SCI_PRIVATELEXERCALL:
return reinterpret_cast<sptr_t>(
@@ -1167,8 +1180,6 @@ sptr_t ScintillaBase::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lPara
return StringResult(lParam, DocumentLexState()->
DescriptionOfStyle(static_cast<int>(wParam)));
-#endif
-
default:
return Editor::WndProc(iMessage, wParam, lParam);
}
diff --git a/src/ScintillaBase.h b/src/ScintillaBase.h
index fc4315e6d..b7a4acf1f 100644
--- a/src/ScintillaBase.h
+++ b/src/ScintillaBase.h
@@ -10,10 +10,7 @@
namespace Scintilla {
-#ifdef SCI_LEXER
class LexState;
-#endif
-
/**
*/
class ScintillaBase : public Editor, IListBoxDelegate {
@@ -42,12 +39,10 @@ protected:
int maxListWidth; /// Maximum width of list, in average character widths
int multiAutoCMode; /// Mode for autocompleting when multiple selections are present
-#ifdef SCI_LEXER
LexState *DocumentLexState();
void SetLexer(uptr_t wParam);
void SetLexerLanguage(const char *languageName);
void Colourise(int start, int end);
-#endif
ScintillaBase();
// Deleted so ScintillaBase objects can not be copied.
diff --git a/win32/DepGen.py b/win32/DepGen.py
index c255574b0..6196720e2 100644
--- a/win32/DepGen.py
+++ b/win32/DepGen.py
@@ -22,6 +22,9 @@ def Generate():
# Add ScintillaBaseL as the same as ScintillaBase
deps = Dependencies.InsertSynonym(deps, "ScintillaBase.o", "ScintillaBaseL.o")
+ # Add CatalogueL as the same as Catalogue
+ deps = Dependencies.InsertSynonym(deps, "Catalogue.o", "CatalogueL.o")
+
Dependencies.UpdateDependencies("../win32/deps.mak", deps, topComment)
# Create the dependencies file for MSVC
diff --git a/win32/deps.mak b/win32/deps.mak
index 4eed6cc45..ef38f88e2 100644
--- a/win32/deps.mak
+++ b/win32/deps.mak
@@ -88,6 +88,15 @@ Catalogue.o: \
../lexlib/LexerModule.h \
../lexlib/CatalogueModules.h \
../src/Catalogue.h
+CatalogueL.o: \
+ ../src/Catalogue.cxx \
+ ../include/ILexer.h \
+ ../include/Sci_Position.h \
+ ../include/Scintilla.h \
+ ../include/SciLexer.h \
+ ../lexlib/LexerModule.h \
+ ../lexlib/CatalogueModules.h \
+ ../src/Catalogue.h
CellBuffer.o: \
../src/CellBuffer.cxx \
../include/Platform.h \
diff --git a/win32/makefile b/win32/makefile
index 30ae527fb..45c9c525b 100644
--- a/win32/makefile
+++ b/win32/makefile
@@ -100,6 +100,7 @@ SRC_OBJS = \
MarginView.o \
PerLine.o \
PositionCache.o \
+ PropSetSimple.o \
RESearch.o \
RunStyles.o \
Selection.o \
@@ -112,13 +113,12 @@ SRC_OBJS = \
# Required by lexers
LEXLIB_OBJS = \
Accessor.o \
- Catalogue.o \
+ CatalogueL.o \
DefaultLexer.o \
ExternalLexer.o \
LexerBase.o \
LexerModule.o \
LexerSimple.o \
- PropSetSimple.o \
StyleContext.o \
WordList.o
@@ -134,12 +134,18 @@ SCILEX_OBJS=\
COMPONENT_OBJS = \
$(SRC_OBJS) \
+ Accessor.o \
+ Catalogue.o \
HanjaDic.o \
+ LexerBase.o \
+ LexerModule.o \
+ LexerSimple.o \
PlatWin.o \
ScintillaBase.o \
ScintillaDLL.o \
ScintillaWin.o \
- ScintRes.o
+ ScintRes.o \
+ WordList.o
LEXCOMPONENT_OBJS = \
$(SCILEX_OBJS) \
@@ -162,6 +168,12 @@ include deps.mak
ScintillaBaseL.o:
$(CXX) $(CXX_ALL_FLAGS) $(CXXFLAGS) -D SCI_LEXER -c $< -o $@
+Catalogue.o: Catalogue.cxx
+ $(CXX) $(CXX_ALL_FLAGS) $(CXXFLAGS) -D SCI_LEXER -D SCI_EMPTYCATALOGUE -c $< -o $@
+
+CatalogueL.o: Catalogue.cxx
+ $(CXX) $(CXX_ALL_FLAGS) $(CXXFLAGS) -D SCI_LEXER -c $< -o $@
+
ScintRes.o: ScintRes.rc
$(WINDRES) ScintRes.rc $@
diff --git a/win32/nmdeps.mak b/win32/nmdeps.mak
index c4fab693f..753bc6463 100644
--- a/win32/nmdeps.mak
+++ b/win32/nmdeps.mak
@@ -88,6 +88,15 @@ $(DIR_O)/Catalogue.obj: \
../lexlib/LexerModule.h \
../lexlib/CatalogueModules.h \
../src/Catalogue.h
+$(DIR_O)/CatalogueL.obj: \
+ ../src/Catalogue.cxx \
+ ../include/ILexer.h \
+ ../include/Sci_Position.h \
+ ../include/Scintilla.h \
+ ../include/SciLexer.h \
+ ../lexlib/LexerModule.h \
+ ../lexlib/CatalogueModules.h \
+ ../src/Catalogue.h
$(DIR_O)/CellBuffer.obj: \
../src/CellBuffer.cxx \
../include/Platform.h \
diff --git a/win32/scintilla.mak b/win32/scintilla.mak
index 0e0f7558c..e005e298b 100644
--- a/win32/scintilla.mak
+++ b/win32/scintilla.mak
@@ -221,14 +221,14 @@ LEX_OBJS=\
# Required by lexers
LEXLIB_OBJS = \
$(DIR_O)\Accessor.obj \
- $(DIR_O)\Catalogue.obj \
+ $(DIR_O)\CatalogueL.obj \
$(DIR_O)\ExternalLexer.obj \
$(DIR_O)\DefaultLexer.obj \
$(DIR_O)\LexerBase.obj \
$(DIR_O)\LexerModule.obj \
$(DIR_O)\LexerSimple.obj \
$(DIR_O)\StyleContext.obj \
- $(DIR_O)\WordList.obj \
+ $(DIR_O)\WordList.obj
# Required by libraries and DLLs that include lexing
SCILEX_OBJS = \
@@ -241,11 +241,17 @@ SCILEX_OBJS = \
$(DIR_O)\ScintillaWin.obj
COMPONENT_OBJS = \
+ $(DIR_O)\Accessor.obj \
+ $(DIR_O)\Catalogue.obj \
$(DIR_O)\HanjaDic.obj \
+ $(DIR_O)\LexerBase.obj \
+ $(DIR_O)\LexerModule.obj \
+ $(DIR_O)\LexerSimple.obj \
$(DIR_O)\PlatWin.obj \
$(DIR_O)\ScintillaBase.obj \
$(DIR_O)\ScintillaDLL.obj \
$(DIR_O)\ScintillaWin.obj \
+ $(DIR_O)\WordList.obj \
$(SRC_OBJS)
LEXCOMPONENT_OBJS = \
@@ -279,6 +285,12 @@ $(LIBSCI): $(SCILEX_OBJS)
$(DIR_O)\ScintillaBaseL.obj: ..\src\ScintillaBase.cxx
$(CXX) $(CXXFLAGS) -DSCI_LEXER -c $(NAME)$@ ..\src\ScintillaBase.cxx
+$(DIR_O)\CatalogueL.obj: ..\src\Catalogue.cxx
+ $(CXX) $(CXXFLAGS) -DSCI_LEXER -c $(NAME)$@ ..\src\Catalogue.cxx
+
+$(DIR_O)\Catalogue.obj: ..\src\Catalogue.cxx
+ $(CXX) $(CXXFLAGS) -DSCI_LEXER -DSCI_EMPTYCATALOGUE -c $(NAME)$@ ..\src\Catalogue.cxx
+
# Dependencies
!IF EXISTS(nmdeps.mak)