diff options
author | nyamatongwe <unknown> | 2007-04-23 01:19:47 +0000 |
---|---|---|
committer | nyamatongwe <unknown> | 2007-04-23 01:19:47 +0000 |
commit | 45672e45d1c4710c53a0659b8febe463fe87f136 (patch) | |
tree | 80801a6bed9b5ce0ca7c435a4e29639e100911c3 /src | |
parent | b4dc83397dfe36d538dfc3dd476b0ebe0c4c44ea (diff) | |
download | scintilla-mirror-45672e45d1c4710c53a0659b8febe463fe87f136.tar.gz |
Changed to use new indicator API.
Diffstat (limited to 'src')
-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(); } |