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/KeyWords.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/KeyWords.cxx')
-rw-r--r-- | src/KeyWords.cxx | 64 |
1 files changed, 52 insertions, 12 deletions
diff --git a/src/KeyWords.cxx b/src/KeyWords.cxx index a275c1963..f28fcecfb 100644 --- a/src/KeyWords.cxx +++ b/src/KeyWords.cxx @@ -20,32 +20,70 @@ #include "SciLexer.h" LexerModule *LexerModule::base = 0; +int LexerModule::nextLanguage = SCLEX_AUTOMATIC+1; -LexerModule::LexerModule(int language_, LexerFunction fn_) : - language(language_), fn(fn_) { +LexerModule::LexerModule(int language_, LexerFunction fnLexer_, + const char *languageName_, LexerFunction fnFolder_) : + language(language_), + languageName(languageName_), + fnLexer(fnLexer_), + fnFolder(fnFolder_) { next = base; base = this; + if (language == SCLEX_AUTOMATIC) { + language = nextLanguage; + nextLanguage++; + } } -void LexerModule::Colourise(unsigned int startPos, int lengthDoc, int initStyle, - int language, WordList *keywordlists[], Accessor &styler) { +LexerModule *LexerModule::Find(int language) { LexerModule *lm = base; while (lm) { if (lm->language == language) { - lm->fn(startPos, lengthDoc, initStyle, keywordlists, styler); - return; + return lm; } lm = lm->next; } - // Unknown language + return 0; +} + +LexerModule *LexerModule::Find(const char *languageName) { + if (languageName) { + LexerModule *lm = base; + while (lm) { + if (lm->languageName && 0 == strcmp(lm->languageName, languageName)) { + return lm; + } + lm = lm->next; + } + } + return 0; +} + +void LexerModule::Lex(unsigned int startPos, int lengthDoc, int initStyle, + WordList *keywordlists[], Accessor &styler) { + if (fnLexer) + fnLexer(startPos, lengthDoc, initStyle, keywordlists, styler); +} + +void LexerModule::Fold(unsigned int startPos, int lengthDoc, int initStyle, + WordList *keywordlists[], Accessor &styler) { + if (fnFolder) + fnFolder(startPos, lengthDoc, initStyle, keywordlists, styler); +} + +static void ColouriseNullDoc(unsigned int startPos, int length, int, WordList *[], + Accessor &styler) { // Null language means all style bytes are 0 so just mark the end - no need to fill in. - if (lengthDoc > 0) { - styler.StartAt(startPos + lengthDoc - 1); - styler.StartSegment(startPos + lengthDoc - 1); - styler.ColourTo(startPos + lengthDoc - 1, 0); + if (length > 0) { + styler.StartAt(startPos + length - 1); + styler.StartSegment(startPos + length - 1); + styler.ColourTo(startPos + length - 1, 0); } } +LexerModule lmNull(SCLEX_NULL, ColouriseNullDoc, "null"); + #ifdef __vms // The following code forces a reference to all of the Scintilla lexers. @@ -55,6 +93,7 @@ void LexerModule::Colourise(unsigned int startPos, int lengthDoc, int initStyle, // Taken from wxWindow's stc.cpp. Walter. int wxForceScintillaLexers(void) { + extern LexerModule lmAda; extern LexerModule lmCPP; extern LexerModule lmHTML; extern LexerModule lmXML; @@ -68,7 +107,8 @@ int wxForceScintillaLexers(void) { extern LexerModule lmVB; if ( - &lmCPP + &lmAda + && &lmCPP && &lmHTML && &lmXML && &lmProps |