diff options
author | nyamatongwe <unknown> | 2001-04-13 04:55:04 +0000 |
---|---|---|
committer | nyamatongwe <unknown> | 2001-04-13 04:55:04 +0000 |
commit | 3e36fa6f3ea27bb64ce42bdd1a5b50b52dc6bb04 (patch) | |
tree | 72f9058f86ae76bf8d6131a4e80d87549b4770ad /src/ScintillaBase.cxx | |
parent | c9925ce492d3ea61e692769c2733d69eed133993 (diff) | |
download | scintilla-mirror-3e36fa6f3ea27bb64ce42bdd1a5b50b52dc6bb04.tar.gz |
Start of new lexer infrastructure.
Lexers can have a fold function as well as a lexer function.
They can be identified by string name as well as an integer ID and may
ask to be automatically assigned that ID.
Diffstat (limited to 'src/ScintillaBase.cxx')
-rw-r--r-- | src/ScintillaBase.cxx | 31 |
1 files changed, 29 insertions, 2 deletions
diff --git a/src/ScintillaBase.cxx b/src/ScintillaBase.cxx index fd2bef184..4eb0cf7a0 100644 --- a/src/ScintillaBase.cxx +++ b/src/ScintillaBase.cxx @@ -38,6 +38,7 @@ ScintillaBase::ScintillaBase() { listType = 0; #ifdef SCI_LEXER lexLanguage = SCLEX_CONTAINER; + lexCurrent = 0; for (int wl = 0;wl < numWordLists;wl++) keyWordLists[wl] = new WordList; #endif @@ -338,6 +339,22 @@ void ScintillaBase::ButtonDown(Point pt, unsigned int curTime, bool shift, bool } #ifdef SCI_LEXER +void ScintillaBase::SetLexer(uptr_t wParam) { + lexLanguage = wParam; + lexCurrent = LexerModule::Find(lexLanguage); + if (!lexCurrent) + lexCurrent = LexerModule::Find(SCLEX_NULL); +} + +void ScintillaBase::SetLexerLanguage(const char *languageName) { + lexLanguage = SCLEX_CONTAINER; + lexCurrent = LexerModule::Find(languageName); + if (!lexCurrent) + lexCurrent = LexerModule::Find(SCLEX_NULL); + if (lexCurrent) + lexLanguage = lexCurrent->GetLanguage(); +} + void ScintillaBase::Colourise(int start, int end) { int lengthDoc = pdoc->Length(); if (end == -1) @@ -352,8 +369,12 @@ void ScintillaBase::Colourise(int start, int end) { styleStart = styler.StyleAt(start - 1); styler.SetCodePage(pdoc->dbcsCodePage); - LexerModule::Colourise(start, len, styleStart, lexLanguage, keyWordLists, styler); - styler.Flush(); + if (lexCurrent) { // Should always succeed as null lexer should always be available + lexCurrent->Lex(start, len, styleStart, keyWordLists, styler); + styler.Flush(); + lexCurrent->Fold(start, len, styleStart, keyWordLists, styler); + styler.Flush(); + } } #endif @@ -482,6 +503,7 @@ sptr_t ScintillaBase::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lPara #ifdef SCI_LEXER case SCI_SETLEXER: + SetLexer(wParam); lexLanguage = wParam; break; @@ -504,6 +526,11 @@ sptr_t ScintillaBase::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lPara keyWordLists[wParam]->Set(reinterpret_cast<const char *>(lParam)); } break; + + case SCI_SETLEXERLANGUAGE: + SetLexerLanguage(reinterpret_cast<const char *>(lParam)); + break; + #endif default: |