diff options
| author | nyamatongwe <devnull@localhost> | 2001-04-13 04:55:04 +0000 | 
|---|---|---|
| committer | nyamatongwe <devnull@localhost> | 2001-04-13 04:55:04 +0000 | 
| commit | a1008c54ed13feeb5d1a0dc3ebf3f8c908d541ba (patch) | |
| tree | 72f9058f86ae76bf8d6131a4e80d87549b4770ad /src/KeyWords.cxx | |
| parent | 917e46a21acff859faffb292b28f9c063caf2b92 (diff) | |
| download | scintilla-mirror-a1008c54ed13feeb5d1a0dc3ebf3f8c908d541ba.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 | 
