diff options
author | nyamatongwe <unknown> | 2001-07-03 01:44:17 +0000 |
---|---|---|
committer | nyamatongwe <unknown> | 2001-07-03 01:44:17 +0000 |
commit | 349bddf693a5b6101fb96ad2bbd000824dcde51d (patch) | |
tree | 183b1ac54fea335605ef3c7ace3b8717cbd854d2 /src | |
parent | 3426fa7b7599bb634844e6d4f0d08a1b4a35b3cc (diff) | |
download | scintilla-mirror-349bddf693a5b6101fb96ad2bbd000824dcde51d.tar.gz |
Simplified by removal of stylingPos variable as it mostly shadowed
endStyled and there were bugs when they got out of synch.
Avoid setting endStyled to -1 as this led to bugs in clients.
Diffstat (limited to 'src')
-rw-r--r-- | src/Document.cxx | 15 | ||||
-rw-r--r-- | src/Document.h | 1 |
2 files changed, 6 insertions, 10 deletions
diff --git a/src/Document.cxx b/src/Document.cxx index 20f8286d4..f7465e886 100644 --- a/src/Document.cxx +++ b/src/Document.cxx @@ -33,7 +33,6 @@ Document::Document() { dbcsCodePage = 0; stylingBits = 5; stylingBitsMask = 0x1F; - stylingPos = 0; stylingMask = 0; for (int ch = 0; ch < 256; ch++) { wordchars[ch] = isalnum(ch) || ch == '_'; @@ -378,7 +377,7 @@ void Document::DeleteChars(int pos, int len) { const char *text = cb.DeleteChars(pos * 2, len * 2); if (startSavePoint && cb.IsCollectingUndo()) NotifySavePoint(!startSavePoint); - if (pos < Length()) + if ((pos < Length()) || (pos == 0)) ModifiedAt(pos); else ModifiedAt(pos-1); @@ -1041,21 +1040,20 @@ void Document::SetStylingBits(int bits) { } void Document::StartStyling(int position, char mask) { - stylingPos = position; stylingMask = mask; + endStyled = position; } void Document::SetStyleFor(int length, char style) { if (enteredCount == 0) { enteredCount++; int prevEndStyled = endStyled; - if (cb.SetStyleFor(stylingPos, length, style, stylingMask)) { + if (cb.SetStyleFor(endStyled, length, style, stylingMask)) { DocModification mh(SC_MOD_CHANGESTYLE | SC_PERFORMED_USER, prevEndStyled, length); NotifyModified(mh); } - stylingPos += length; - endStyled = stylingPos; + endStyled += length; enteredCount--; } } @@ -1065,12 +1063,11 @@ void Document::SetStyles(int length, char *styles) { enteredCount++; int prevEndStyled = endStyled; bool didChange = false; - for (int iPos = 0; iPos < length; iPos++, stylingPos++) { - if (cb.SetStyleAt(stylingPos, styles[iPos], stylingMask)) { + for (int iPos = 0; iPos < length; iPos++, endStyled++) { + if (cb.SetStyleAt(endStyled, styles[iPos], stylingMask)) { didChange = true; } } - endStyled = stylingPos; if (didChange) { DocModification mh(SC_MOD_CHANGESTYLE | SC_PERFORMED_USER, prevEndStyled, endStyled - prevEndStyled); diff --git a/src/Document.h b/src/Document.h index 581957257..394c8f94b 100644 --- a/src/Document.h +++ b/src/Document.h @@ -82,7 +82,6 @@ private: int refCount; CellBuffer cb; bool wordchars[256]; - int stylingPos; char stylingMask; int endStyled; int enteredCount; |