aboutsummaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authornyamatongwe <devnull@localhost>2008-01-30 09:20:11 +0000
committernyamatongwe <devnull@localhost>2008-01-30 09:20:11 +0000
commit20ae21ae5f632d65f1a61a88870db8ae913ceb29 (patch)
treec80a441bc5f771d624c9ee9b4cc93a0dee965ae6 /src
parentecf6099ed2c77da3d7abaa06b4cdba98559ee244 (diff)
downloadscintilla-mirror-20ae21ae5f632d65f1a61a88870db8ae913ceb29.tar.gz
Path from Boris optimizes redraw when extending selection.
Diffstat (limited to 'src')
-rw-r--r--src/Editor.cxx35
-rw-r--r--src/Editor.h2
2 files changed, 22 insertions, 15 deletions
diff --git a/src/Editor.cxx b/src/Editor.cxx
index 1eaf8f92e..89ff5b2ad 100644
--- a/src/Editor.cxx
+++ b/src/Editor.cxx
@@ -719,19 +719,26 @@ void Editor::SetRectangularRange() {
}
}
-void Editor::InvalidateSelection(int currentPos_, int anchor_) {
- int firstAffected = anchor;
- if (firstAffected > currentPos)
- firstAffected = currentPos;
- if (firstAffected > anchor_)
- firstAffected = anchor_;
+void Editor::InvalidateSelection(int currentPos_, int anchor_, bool invalidateWholeSelection) {
+ if (anchor != anchor_ || selType == selRectangle) {
+ invalidateWholeSelection = true;
+ }
+ int firstAffected = currentPos;
+ if (invalidateWholeSelection) {
+ if (firstAffected > anchor)
+ firstAffected = anchor;
+ if (firstAffected > anchor_)
+ firstAffected = anchor_;
+ }
if (firstAffected > currentPos_)
firstAffected = currentPos_;
- int lastAffected = anchor;
- if (lastAffected < currentPos)
- lastAffected = currentPos;
- if (lastAffected < anchor_)
- lastAffected = anchor_;
+ int lastAffected = currentPos;
+ if (invalidateWholeSelection) {
+ if (lastAffected < anchor)
+ lastAffected = anchor;
+ if (lastAffected < anchor_)
+ lastAffected = anchor_;
+ }
if (lastAffected < (currentPos_ + 1)) // +1 ensures caret repainted
lastAffected = (currentPos_ + 1);
needUpdateUI = true;
@@ -742,7 +749,7 @@ void Editor::SetSelection(int currentPos_, int anchor_) {
currentPos_ = pdoc->ClampPositionIntoDocument(currentPos_);
anchor_ = pdoc->ClampPositionIntoDocument(anchor_);
if ((currentPos != currentPos_) || (anchor != anchor_)) {
- InvalidateSelection(currentPos_, anchor_);
+ InvalidateSelection(currentPos_, anchor_, true);
currentPos = currentPos_;
anchor = anchor_;
}
@@ -753,7 +760,7 @@ void Editor::SetSelection(int currentPos_, int anchor_) {
void Editor::SetSelection(int currentPos_) {
currentPos_ = pdoc->ClampPositionIntoDocument(currentPos_);
if (currentPos != currentPos_) {
- InvalidateSelection(currentPos_, currentPos_);
+ InvalidateSelection(currentPos_, anchor, false);
currentPos = currentPos_;
}
SetRectangularRange();
@@ -7442,7 +7449,7 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) {
moveExtendsSelection = !moveExtendsSelection || (selType != selStream);
selType = selStream;
}
- InvalidateSelection(currentPos, anchor);
+ InvalidateSelection(currentPos, anchor, true);
}
case SCI_GETSELECTIONMODE:
switch (selType) {
diff --git a/src/Editor.h b/src/Editor.h
index ee3db99b3..0d0b8ac9c 100644
--- a/src/Editor.h
+++ b/src/Editor.h
@@ -279,7 +279,7 @@ protected: // ScintillaBase subclass needs access to much of Editor
int SelectionStart();
int SelectionEnd();
void SetRectangularRange();
- void InvalidateSelection(int currentPos_, int anchor_);
+ void InvalidateSelection(int currentPos_, int anchor_, bool invalidateWholeSelection);
void SetSelection(int currentPos_, int anchor_);
void SetSelection(int currentPos_);
void SetEmptySelection(int currentPos_);