diff options
Diffstat (limited to 'src/StyleContext.h')
-rw-r--r-- | src/StyleContext.h | 38 |
1 files changed, 23 insertions, 15 deletions
diff --git a/src/StyleContext.h b/src/StyleContext.h index 343c81972..9e803c4a7 100644 --- a/src/StyleContext.h +++ b/src/StyleContext.h @@ -55,25 +55,33 @@ public: styler.ColourTo(currentPos - 1, state); } bool More() { - return currentPos <= endPos; + return currentPos < endPos; } void Forward() { - atLineStart = atLineEnd; - // A lot of this is repeated from the constructor - TODO: merge code - chPrev = ch; - currentPos++; - if (ch >= 0x100) + if (currentPos < endPos) { + atLineStart = atLineEnd; + // A lot of this is repeated from the constructor - TODO: merge code + chPrev = ch; currentPos++; - ch = chNext; - chNext = static_cast<unsigned char>(styler.SafeGetCharAt(currentPos+1)); - if (styler.IsLeadByte(static_cast<char>(chNext))) { - chNext = chNext << 8; - chNext |= static_cast<unsigned char>(styler.SafeGetCharAt(currentPos + 2)); + if (ch >= 0x100) + currentPos++; + ch = chNext; + chNext = static_cast<unsigned char>(styler.SafeGetCharAt(currentPos+1)); + if (styler.IsLeadByte(static_cast<char>(chNext))) { + chNext = chNext << 8; + chNext |= static_cast<unsigned char>(styler.SafeGetCharAt(currentPos + 2)); + } + // Trigger on CR only (Mac style) or either on LF from CR+LF (Dos/Win) or on LF alone (Unix) + // Avoid triggering two times on Dos/Win + // End of line + atLineEnd = (ch == '\r' && chNext != '\n') || (ch == '\n') || (currentPos >= endPos); + } else { + atLineStart = false; + chPrev = ' '; + ch = ' '; + chNext = ' '; + atLineEnd = true; } - // Trigger on CR only (Mac style) or either on LF from CR+LF (Dos/Win) or on LF alone (Unix) - // Avoid triggering two times on Dos/Win - // End of line - atLineEnd = (ch == '\r' && chNext != '\n') || (ch == '\n') || (currentPos >= endPos); } void ChangeState(int state_) { state = state_; |