diff options
Diffstat (limited to 'src/ScintillaBase.cxx')
| -rw-r--r-- | src/ScintillaBase.cxx | 49 |
1 files changed, 34 insertions, 15 deletions
diff --git a/src/ScintillaBase.cxx b/src/ScintillaBase.cxx index 09736d9f7..af1a6f52e 100644 --- a/src/ScintillaBase.cxx +++ b/src/ScintillaBase.cxx @@ -23,9 +23,7 @@ #include "ILexer.h" #include "Scintilla.h" -#ifdef SCI_LEXER #include "SciLexer.h" -#endif #include "PropSetSimple.h" #include "CharacterCategory.h" @@ -61,9 +59,7 @@ #include "AutoComplete.h" #include "ScintillaBase.h" -#ifdef SCI_LEXER #include "ExternalLexer.h" -#endif using namespace Scintilla; @@ -548,8 +544,6 @@ void ScintillaBase::RightButtonDownWithModifiers(Point pt, unsigned int curTime, Editor::RightButtonDownWithModifiers(pt, curTime, modifiers); } -#ifdef SCI_LEXER - namespace Scintilla { class LexState : public LexInterface { @@ -561,6 +555,7 @@ public: int lexLanguage; explicit LexState(Document *pdoc_); + void SetInstance(ILexer *instance_); // Deleted so LexState objects can not be copied. LexState(const LexState &) = delete; LexState(LexState &&) = delete; @@ -569,8 +564,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(); @@ -609,8 +606,25 @@ LexState::LexState(Document *pdoc_) : LexInterface(pdoc_) { LexState::~LexState() { if (instance) { instance->Release(); + LexillaLexer *iLexer5 = dynamic_cast<LexillaLexer *>(instance); + if (iLexer5) { + delete iLexer5; + } + instance = nullptr; + } +} + +void LexState::SetInstance(ILexer *instance_) { + if (instance) { + instance->Release(); + LexillaLexer *iLexer5 = dynamic_cast<LexillaLexer *>(instance); + if (iLexer5) { + delete iLexer5; + } instance = nullptr; } + instance = instance_; + pdoc->LexerChanged(); } LexState *ScintillaBase::DocumentLexState() { @@ -624,6 +638,10 @@ void LexState::SetLexerModule(const LexerModule *lex) { if (lex != lexCurrent) { if (instance) { instance->Release(); + LexillaLexer *iLexer5 = dynamic_cast<LexillaLexer *>(instance); + if (iLexer5) { + delete iLexer5; + } instance = nullptr; } interfaceVersion = lvOriginal; @@ -841,10 +859,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()); @@ -853,14 +868,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) { @@ -1058,7 +1070,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; @@ -1066,6 +1077,14 @@ sptr_t ScintillaBase::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lPara case SCI_GETLEXER: return DocumentLexState()->lexLanguage; + case SCI_SETILEXER: + if (wParam == 0) { + DocumentLexState()->SetInstance(reinterpret_cast<ILexer *>(lParam)); + } else { + DocumentLexState()->SetInstance(new LexillaLexer(reinterpret_cast<ILexer5 *>(lParam))); + } + return 0; + case SCI_COLOURISE: if (DocumentLexState()->lexLanguage == SCLEX_CONTAINER) { pdoc->ModifiedAt(static_cast<Sci::Position>(wParam)); @@ -1102,9 +1121,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), wParam != 0); break; +#endif case SCI_PRIVATELEXERCALL: return reinterpret_cast<sptr_t>( @@ -1176,8 +1197,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); } |
