diff options
| author | nyamatongwe <unknown> | 2007-07-31 04:07:02 +0000 | 
|---|---|---|
| committer | nyamatongwe <unknown> | 2007-07-31 04:07:02 +0000 | 
| commit | ad78f49baf803944285c6acacf19a72846c44c04 (patch) | |
| tree | c64a96b6a7e40aba7010b3e402efc5f93d96daa1 | |
| parent | 6cb0be3014ecbab91f2bfa92ca7ae4058e70192b (diff) | |
| download | scintilla-mirror-ad78f49baf803944285c6acacf19a72846c44c04.tar.gz | |
Eric Promislow added an operator state for YAML and recognise comments
after code.
| -rw-r--r-- | include/SciLexer.h | 1 | ||||
| -rw-r--r-- | include/Scintilla.iface | 1 | ||||
| -rw-r--r-- | src/LexYAML.cxx | 21 | 
3 files changed, 15 insertions, 8 deletions
| diff --git a/include/SciLexer.h b/include/SciLexer.h index 692cc2198..fcffb6d3a 100644 --- a/include/SciLexer.h +++ b/include/SciLexer.h @@ -738,6 +738,7 @@  #define SCE_YAML_DOCUMENT 6  #define SCE_YAML_TEXT 7  #define SCE_YAML_ERROR 8 +#define SCE_YAML_OPERATOR 9  #define SCE_TEX_DEFAULT 0  #define SCE_TEX_SPECIAL 1  #define SCE_TEX_GROUP 2 diff --git a/include/Scintilla.iface b/include/Scintilla.iface index fde3335fe..c2e5e7cc0 100644 --- a/include/Scintilla.iface +++ b/include/Scintilla.iface @@ -2726,6 +2726,7 @@ val SCE_YAML_REFERENCE=5  val SCE_YAML_DOCUMENT=6  val SCE_YAML_TEXT=7  val SCE_YAML_ERROR=8 +val SCE_YAML_OPERATOR=9  # Lexical states for SCLEX_TEX  lex TeX=SCLEX_TEX SCE_TEX_  val SCE_TEX_DEFAULT=0 diff --git a/src/LexYAML.cxx b/src/LexYAML.cxx index 0edd78691..ef5315f24 100644 --- a/src/LexYAML.cxx +++ b/src/LexYAML.cxx @@ -37,12 +37,12 @@ static inline bool AtEOL(Accessor &styler, unsigned int i) {  static unsigned int SpaceCount(char* lineBuffer) {  	if (lineBuffer == NULL)  		return 0; -	 +  	char* headBuffer = lineBuffer; -	 +  	while (*headBuffer == ' ')  		headBuffer++; -	 +  	return headBuffer - lineBuffer;  } @@ -62,14 +62,14 @@ static void ColouriseYAMLLine(  	unsigned int endPos,  	WordList &keywords,  	Accessor &styler) { -	     +  	unsigned int i = 0;  	bool bInQuotes = false;  	unsigned int indentAmount = SpaceCount(lineBuffer); -		 +  	if (currentLine > 0) {  		int parentLineState = styler.GetLineState(currentLine - 1); -	 +  		if ((parentLineState&YAML_STATE_MASK) == YAML_STATE_TEXT || (parentLineState&YAML_STATE_MASK) == YAML_STATE_TEXT_PARENT) {  			unsigned int parentIndentAmount = parentLineState&(~YAML_STATE_MASK);  			if (indentAmount > parentIndentAmount) { @@ -102,7 +102,8 @@ static void ColouriseYAMLLine(  		if (lineBuffer[i] == '\'' || lineBuffer[i] == '\"') {  			bInQuotes = !bInQuotes;  		} else if (lineBuffer[i] == ':' && !bInQuotes) { -			styler.ColourTo(startLine + i, SCE_YAML_IDENTIFIER); +			styler.ColourTo(startLine + i - 1, SCE_YAML_IDENTIFIER); +			styler.ColourTo(startLine + i, SCE_YAML_OPERATOR);  			// Non-folding scalar  			i++;  			while ((i < lengthLine) && isspacechar(lineBuffer[i])) @@ -130,6 +131,10 @@ static void ColouriseYAMLLine(  					styler.ColourTo(endPos, SCE_YAML_ERROR);  					return;  				} +			} else if (lineBuffer[i] == '#') { +				styler.ColourTo(startLine + i - 1, SCE_YAML_DEFAULT); +				styler.ColourTo(endPos, SCE_YAML_COMMENT); +				return;  			}  			styler.SetLineState(currentLine, YAML_STATE_VALUE);  			if (lineBuffer[i] == '&' || lineBuffer[i] == '*') { @@ -169,7 +174,7 @@ static void ColouriseYAMLDoc(unsigned int startPos, int length, int, WordList *k  	unsigned int endPos = startPos + length;  	unsigned int maxPos = styler.Length();  	unsigned int lineCurrent = styler.GetLine(startPos); -	 +  	for (unsigned int i = startPos; i < maxPos && i < endPos; i++) {  		lineBuffer[linePos++] = styler[i];  		if (AtEOL(styler, i) || (linePos >= sizeof(lineBuffer) - 1)) { | 
