diff options
| author | nyamatongwe <devnull@localhost> | 2007-04-23 01:19:47 +0000 | 
|---|---|---|
| committer | nyamatongwe <devnull@localhost> | 2007-04-23 01:19:47 +0000 | 
| commit | 3c64900f796301a5c3f7aa7119a685b7691bacee (patch) | |
| tree | 80801a6bed9b5ce0ca7c435a4e29639e100911c3 /src/LexPython.cxx | |
| parent | 57c8f19a89279b5d2ab079fbab931a1d787c6381 (diff) | |
| download | scintilla-mirror-3c64900f796301a5c3f7aa7119a685b7691bacee.tar.gz | |
Changed to use new indicator API.
Diffstat (limited to 'src/LexPython.cxx')
| -rw-r--r-- | src/LexPython.cxx | 34 | 
1 files changed, 22 insertions, 12 deletions
| diff --git a/src/LexPython.cxx b/src/LexPython.cxx index 1bdebf6de..8c924a0e8 100644 --- a/src/LexPython.cxx +++ b/src/LexPython.cxx @@ -21,6 +21,7 @@  #include "SciLexer.h"  enum kwType { kwOther, kwClass, kwDef, kwImport }; +static const int indicatorWhitespace = 1;  static bool IsPyComment(Accessor &styler, int pos, int len) {  	return len > 0 && styler[pos] == '#'; @@ -123,26 +124,29 @@ static void ColourisePyDoc(unsigned int startPos, int length, int initStyle,  	styler.IndentAmount(lineCurrent, &spaceFlags, IsPyComment);  	bool hexadecimal = false; -	// Python uses a different mask because bad indentation is marked by oring with 32 -	StyleContext sc(startPos, endPos - startPos, initStyle, styler, 0x7f); +	StyleContext sc(startPos, endPos - startPos, initStyle, styler); + +	bool indentGood = true; +	int startIndicator = sc.currentPos;  	for (; sc.More(); sc.Forward()) {  		if (sc.atLineStart) { -			const char chBad = static_cast<char>(64); -			const char chGood = static_cast<char>(0); -			char chFlags = chGood; +			styler.IndentAmount(lineCurrent, &spaceFlags, IsPyComment); +			indentGood = true;  			if (whingeLevel == 1) { -				chFlags = (spaceFlags & wsInconsistent) ? chBad : chGood; +				indentGood = (spaceFlags & wsInconsistent) == 0;  			} else if (whingeLevel == 2) { -				chFlags = (spaceFlags & wsSpaceTab) ? chBad : chGood; +				indentGood = (spaceFlags & wsSpaceTab) == 0;  			} else if (whingeLevel == 3) { -				chFlags = (spaceFlags & wsSpace) ? chBad : chGood; +				indentGood = (spaceFlags & wsSpace) == 0;  			} else if (whingeLevel == 4) { -				chFlags = (spaceFlags & wsTab) ? chBad : chGood; +				indentGood = (spaceFlags & wsTab) == 0; +			} +			if (!indentGood) { +				styler.IndicatorFill(startIndicator, sc.currentPos, indicatorWhitespace, 0); +				startIndicator = sc.currentPos;  			} -			sc.SetState(sc.state); -			styler.SetFlags(chFlags, static_cast<char>(sc.state));  		}  		if (sc.atLineEnd) { @@ -154,7 +158,6 @@ static void ColourisePyDoc(unsigned int startPos, int length, int initStyle,  				sc.SetState(sc.state);  			}  			lineCurrent++; -			styler.IndentAmount(lineCurrent, &spaceFlags, IsPyComment);  			if ((sc.state == SCE_P_STRING) || (sc.state == SCE_P_CHARACTER)) {  				sc.ChangeState(SCE_P_STRINGEOL);  				sc.ForwardSetState(SCE_P_DEFAULT); @@ -248,6 +251,12 @@ static void ColourisePyDoc(unsigned int startPos, int length, int initStyle,  			}  		} +		if (!indentGood && !IsASpaceOrTab(sc.ch)) { +			styler.IndicatorFill(startIndicator, sc.currentPos, indicatorWhitespace, 1); +			startIndicator = sc.currentPos; +			indentGood = true; +		} +  		// State exit code may have moved on to end of line  		if (needEOLCheck && sc.atLineEnd) {  			lineCurrent++; @@ -282,6 +291,7 @@ static void ColourisePyDoc(unsigned int startPos, int length, int initStyle,  			}  		}  	} +	styler.IndicatorFill(startIndicator, sc.currentPos, indicatorWhitespace, 0);  	sc.Complete();  } | 
