diff options
-rw-r--r-- | src/ScintillaBase.cxx | 108 |
1 files changed, 26 insertions, 82 deletions
diff --git a/src/ScintillaBase.cxx b/src/ScintillaBase.cxx index 9180b3796..8cf5b5a2c 100644 --- a/src/ScintillaBase.cxx +++ b/src/ScintillaBase.cxx @@ -24,14 +24,8 @@ #include "ILexer.h" #include "Scintilla.h" -#include "SciLexer.h" - -#include "PropSetSimple.h" #include "CharacterCategory.h" -#include "LexerModule.h" -#include "Catalogue.h" - #include "Position.h" #include "UniqueString.h" #include "SplitVector.h" @@ -58,8 +52,6 @@ #include "AutoComplete.h" #include "ScintillaBase.h" -#include "ExternalLexer.h" - using namespace Scintilla; ScintillaBase::ScintillaBase() { @@ -67,9 +59,6 @@ ScintillaBase::ScintillaBase() { listType = 0; maxListWidth = 0; multiAutoCMode = SC_MULTIAUTOC_ONCE; -#ifdef SCI_LEXER - Scintilla_LinkLexers(); -#endif } ScintillaBase::~ScintillaBase() { @@ -546,9 +535,6 @@ void ScintillaBase::RightButtonDownWithModifiers(Point pt, unsigned int curTime, namespace Scintilla { class LexState : public LexInterface { - const LexerModule *lexCurrent; - void SetLexerModule(const LexerModule *lex); - PropSetSimple props; int interfaceVersion; public: int lexLanguage; @@ -561,8 +547,6 @@ public: LexState &operator=(const LexState &) = delete; LexState &operator=(LexState &&) = delete; ~LexState() override; - void SetLexer(uptr_t wParam); - void SetLexerLanguage(const char *languageName); const char *DescribeWordListSets(); void SetWordList(int n, const char *wl); @@ -596,10 +580,9 @@ public: } LexState::LexState(Document *pdoc_) : LexInterface(pdoc_) { - lexCurrent = nullptr; performingStyle = false; interfaceVersion = lvRelease4; - lexLanguage = SCLEX_CONTAINER; + lexLanguage = 0; } LexState::~LexState() { @@ -625,43 +608,6 @@ LexState *ScintillaBase::DocumentLexState() { return dynamic_cast<LexState *>(pdoc->GetLexInterface()); } -void LexState::SetLexerModule(const LexerModule *lex) { - if (lex != lexCurrent) { - if (instance) { - instance->Release(); - instance = nullptr; - } - interfaceVersion = lvRelease4; - lexCurrent = lex; - if (lexCurrent) { - instance = lexCurrent->Create(); - interfaceVersion = instance->Version(); - } - pdoc->LexerChanged(); - } -} - -void LexState::SetLexer(uptr_t wParam) { - lexLanguage = static_cast<int>(wParam); - if (lexLanguage == SCLEX_CONTAINER) { - SetLexerModule(nullptr); - } else { - const LexerModule *lex = Catalogue::Find(lexLanguage); - if (!lex) - lex = Catalogue::Find(SCLEX_NULL); - SetLexerModule(lex); - } -} - -void LexState::SetLexerLanguage(const char *languageName) { - const LexerModule *lex = Catalogue::Find(languageName); - if (!lex) - lex = Catalogue::Find(SCLEX_NULL); - if (lex) - lexLanguage = lex->GetLanguage(); - SetLexerModule(lex); -} - const char *LexState::DescribeWordListSets() { if (instance) { return instance->DescribeWordListSets(); @@ -680,21 +626,15 @@ void LexState::SetWordList(int n, const char *wl) { } int LexState::GetIdentifier() const { - if (lexCurrent) { - return lexCurrent->GetLanguage(); - } if (instance) { if (instance->Version() >= lvRelease5) { return instance->GetIdentifier(); } } - return SCLEX_CONTAINER; + return 0; } const char *LexState::GetName() const { - if (lexCurrent) { - return lexCurrent->languageName; - } if (instance) { if (instance->Version() >= lvRelease5) { return instance->GetName(); @@ -736,7 +676,6 @@ const char *LexState::DescribeProperty(const char *name) { } void LexState::PropSet(const char *key, const char *val) { - props.Set(key, val, strlen(key), strlen(val)); if (instance) { const Sci_Position firstModification = instance->PropertySet(key, val); if (firstModification >= 0) { @@ -746,15 +685,34 @@ void LexState::PropSet(const char *key, const char *val) { } const char *LexState::PropGet(const char *key) const { - return props.Get(key); + if (instance) { + return instance->PropertyGet(key); + } else { + return nullptr; + } } int LexState::PropGetInt(const char *key, int defaultValue) const { - return props.GetInt(key, defaultValue); + if (instance) { + const char *value = instance->PropertyGet(key); + if (value && *value) { + return atoi(value); + } + } + return defaultValue; } size_t LexState::PropGetExpanded(const char *key, char *result) const { - return props.GetExpanded(key, result); + if (instance) { + const char *value = instance->PropertyGet(key); + if (value) { + if (result) { + strcpy(result, value); + } + return strlen(value); + } + } + return 0; } int LexState::LineEndTypesSupported() { @@ -859,7 +817,7 @@ const char *LexState::DescriptionOfStyle(int style) { } void ScintillaBase::NotifyStyleToNeeded(Sci::Position endStyleNeeded) { - if (DocumentLexState()->GetIdentifier() != SCLEX_CONTAINER) { + if (DocumentLexState()->GetIdentifier() != 0) { const Sci::Line lineEndStyled = pdoc->SciLineFromPosition(pdoc->GetEndStyled()); const Sci::Position endStyled = @@ -1069,10 +1027,6 @@ sptr_t ScintillaBase::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lPara displayPopupMenu = static_cast<int>(wParam); break; - case SCI_SETLEXER: - DocumentLexState()->SetLexer(static_cast<int>(wParam)); - break; - case SCI_GETLEXER: return DocumentLexState()->GetIdentifier(); @@ -1081,7 +1035,7 @@ sptr_t ScintillaBase::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lPara return 0; case SCI_COLOURISE: - if (DocumentLexState()->lexLanguage == SCLEX_CONTAINER) { + if (DocumentLexState()->lexLanguage == 0) { pdoc->ModifiedAt(static_cast<Sci::Position>(wParam)); NotifyStyleToNeeded((lParam == -1) ? pdoc->Length() : lParam); } else { @@ -1109,19 +1063,9 @@ sptr_t ScintillaBase::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lPara DocumentLexState()->SetWordList(static_cast<int>(wParam), ConstCharPtrFromSPtr(lParam)); break; - case SCI_SETLEXERLANGUAGE: - DocumentLexState()->SetLexerLanguage(ConstCharPtrFromSPtr(lParam)); - break; - 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>( DocumentLexState()->PrivateCall(static_cast<int>(wParam), reinterpret_cast<void *>(lParam))); |