aboutsummaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authormitchell <unknown>2020-01-03 19:46:53 -0500
committermitchell <unknown>2020-01-03 19:46:53 -0500
commitb6d260731bddb23d63f4a0990305b1d9501f7cf8 (patch)
tree2ec6039f887cb14498e469973b68aaca7a2c939e /src
parent8eb134dbbd44002f3acd90d91550875f161136fa (diff)
downloadscintilla-mirror-b6d260731bddb23d63f4a0990305b1d9501f7cf8.tar.gz
Backport: Move collection of modules from Catalogue.cxx to CatalogueModules.h so it can be reused.
Backport of changeset 7866:fff1071ea1db.
Diffstat (limited to 'src')
-rw-r--r--src/Catalogue.cxx29
-rw-r--r--src/ScintillaBase.cxx3
2 files changed, 13 insertions, 19 deletions
diff --git a/src/Catalogue.cxx b/src/Catalogue.cxx
index b5a4dde4c..919ecf668 100644
--- a/src/Catalogue.cxx
+++ b/src/Catalogue.cxx
@@ -19,36 +19,27 @@
#include "SciLexer.h"
#include "LexerModule.h"
+#include "CatalogueModules.h"
#include "Catalogue.h"
using namespace Scintilla;
-static std::vector<LexerModule *> lexerCatalogue;
+namespace {
+
+CatalogueModules catalogueDefault;
+
+}
const LexerModule *Catalogue::Find(int language) {
- Scintilla_LinkLexers();
- for (const LexerModule *lm : lexerCatalogue) {
- if (lm->GetLanguage() == language) {
- return lm;
- }
- }
- return nullptr;
+ return catalogueDefault.Find(language);
}
const LexerModule *Catalogue::Find(const char *languageName) {
- Scintilla_LinkLexers();
- if (languageName) {
- for (const LexerModule *lm : lexerCatalogue) {
- if (lm->languageName && (0 == strcmp(lm->languageName, languageName))) {
- return lm;
- }
- }
- }
- return nullptr;
+ return catalogueDefault.Find(languageName);
}
void Catalogue::AddLexerModule(LexerModule *plm) {
- lexerCatalogue.push_back(plm);
+ catalogueDefault.AddLexerModule(plm);
}
// To add or remove a lexer, add or remove its file and run LexGen.py.
@@ -63,7 +54,7 @@ int Scintilla_LinkLexers() {
initialised = 1;
// Shorten the code that declares a lexer and ensures it is linked in by calling a method.
-#define LINK_LEXER(lexer) extern LexerModule lexer; Catalogue::AddLexerModule(&lexer);
+#define LINK_LEXER(lexer) extern LexerModule lexer; catalogueDefault.AddLexerModule(&lexer);
//++Autogenerated -- run scripts/LexGen.py to regenerate
//**\(\tLINK_LEXER(\*);\n\)
diff --git a/src/ScintillaBase.cxx b/src/ScintillaBase.cxx
index 76308ce2a..0b7adbd67 100644
--- a/src/ScintillaBase.cxx
+++ b/src/ScintillaBase.cxx
@@ -72,6 +72,9 @@ ScintillaBase::ScintillaBase() {
listType = 0;
maxListWidth = 0;
multiAutoCMode = SC_MULTIAUTOC_ONCE;
+#ifdef SCI_LEXER
+ Scintilla_LinkLexers();
+#endif
}
ScintillaBase::~ScintillaBase() {