aboutsummaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authornyamatongwe <unknown>2002-02-11 02:15:56 +0000
committernyamatongwe <unknown>2002-02-11 02:15:56 +0000
commit059b5ea7391a9879a96921b256a185165e8ab2db (patch)
tree8fccbc9b0127de0aa755ebbef0a78b4ca1609bad /src
parent537e81b993a0118c5c51018f5697ae4f5c1cc3bc (diff)
downloadscintilla-mirror-059b5ea7391a9879a96921b256a185165e8ab2db.tar.gz
Changes to tighten up styling beyond the bounds of the document.
May not be permanent.
Diffstat (limited to 'src')
-rw-r--r--src/Document.cxx1
-rw-r--r--src/DocumentAccessor.cxx3
-rw-r--r--src/DocumentAccessor.h4
-rw-r--r--src/LexOthers.cxx4
-rw-r--r--src/LexPython.cxx6
-rw-r--r--src/StyleContext.h38
6 files changed, 36 insertions, 20 deletions
diff --git a/src/Document.cxx b/src/Document.cxx
index 4bc7c05a2..8b40806f3 100644
--- a/src/Document.cxx
+++ b/src/Document.cxx
@@ -1100,6 +1100,7 @@ void Document::SetStyles(int length, char *styles) {
int prevEndStyled = endStyled;
bool didChange = false;
for (int iPos = 0; iPos < length; iPos++, endStyled++) {
+ PLATFORM_ASSERT(endStyled < Length());
if (cb.SetStyleAt(endStyled, styles[iPos], stylingMask)) {
didChange = true;
}
diff --git a/src/DocumentAccessor.cxx b/src/DocumentAccessor.cxx
index 76530e1de..f115f1930 100644
--- a/src/DocumentAccessor.cxx
+++ b/src/DocumentAccessor.cxx
@@ -80,6 +80,7 @@ int DocumentAccessor::SetLineState(int line, int state) {
void DocumentAccessor::StartAt(unsigned int start, char chMask) {
pdoc->StartStyling(start, chMask);
+ startPosStyling = start;
}
void DocumentAccessor::StartSegment(unsigned int pos) {
@@ -103,6 +104,7 @@ void DocumentAccessor::ColourTo(unsigned int pos, int chAttr) {
chFlags = 0;
chAttr |= chFlags;
for (unsigned int i = startSeg; i <= pos; i++) {
+ PLATFORM_ASSERT((startPosStyling + validLen) < Length());
styleBuf[validLen++] = static_cast<char>(chAttr);
}
}
@@ -120,6 +122,7 @@ void DocumentAccessor::Flush() {
if (validLen > 0) {
pdoc->SetStyles(validLen, styleBuf);
validLen = 0;
+ startPosStyling += validLen;
}
}
diff --git a/src/DocumentAccessor.h b/src/DocumentAccessor.h
index 48742a9b4..5b68dd15c 100644
--- a/src/DocumentAccessor.h
+++ b/src/DocumentAccessor.h
@@ -26,6 +26,7 @@ protected:
char chFlags;
char chWhile;
unsigned int startSeg;
+ int startPosStyling;
bool InternalIsLeadByte(char ch);
void Fill(int position);
@@ -33,7 +34,8 @@ protected:
public:
DocumentAccessor(Document *pdoc_, PropSet &props_, WindowID id_=0) :
Accessor(), pdoc(pdoc_), props(props_), id(id_),
- lenDoc(-1), validLen(0), chFlags(0), chWhile(0) {
+ lenDoc(-1), validLen(0), chFlags(0), chWhile(0),
+ startSeg(0), startPosStyling(0) {
}
~DocumentAccessor();
char StyleAt(int position);
diff --git a/src/LexOthers.cxx b/src/LexOthers.cxx
index 0814d518c..2c9c3e444 100644
--- a/src/LexOthers.cxx
+++ b/src/LexOthers.cxx
@@ -217,9 +217,9 @@ static void ColourisePropsLine(
if (lineBuffer[i] == '=') {
styler.ColourTo(startLine + i - 1, 0);
styler.ColourTo(startLine + i, 3);
- styler.ColourTo(endPos, 0);
+ styler.ColourTo(endPos-1, 0);
} else {
- styler.ColourTo(endPos, 0);
+ styler.ColourTo(endPos-1, 0);
}
}
}
diff --git a/src/LexPython.cxx b/src/LexPython.cxx
index 35a5a92be..4af4ca225 100644
--- a/src/LexPython.cxx
+++ b/src/LexPython.cxx
@@ -156,6 +156,8 @@ static void ColourisePyDoc(unsigned int startPos, int length, int initStyle,
sc.ChangeState(SCE_P_STRINGEOL);
sc.ForwardSetState(SCE_P_DEFAULT);
}
+ if (!sc.More())
+ break;
}
// Check for a state end
@@ -166,7 +168,7 @@ static void ColourisePyDoc(unsigned int startPos, int length, int initStyle,
if (!IsAWordChar(sc.ch)) {
sc.SetState(SCE_P_DEFAULT);
}
- } else if (sc.state == SCE_P_WORD) {
+ } else if (sc.state == SCE_P_IDENTIFIER) {
if ((sc.ch == '.') || (!IsAWordChar(sc.ch))) {
char s[100];
sc.GetCurrent(s, sizeof(s));
@@ -245,7 +247,7 @@ static void ColourisePyDoc(unsigned int startPos, int length, int initStyle,
sc.Forward();
}
} else if (IsAWordStart(sc.ch)) {
- sc.SetState(SCE_P_WORD);
+ sc.SetState(SCE_P_IDENTIFIER);
}
}
}
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_;