diff options
| author | nyamatongwe <unknown> | 2008-01-30 09:20:11 +0000 | 
|---|---|---|
| committer | nyamatongwe <unknown> | 2008-01-30 09:20:11 +0000 | 
| commit | 0a8a19bcede5aa35350d1ad0f2a3d7a8e8326dd3 (patch) | |
| tree | c80a441bc5f771d624c9ee9b4cc93a0dee965ae6 | |
| parent | 8a5cc90202b95f63cb131ceea0db72571e3f7cde (diff) | |
| download | scintilla-mirror-0a8a19bcede5aa35350d1ad0f2a3d7a8e8326dd3.tar.gz | |
Path from Boris optimizes redraw when extending selection.
| -rw-r--r-- | src/Editor.cxx | 35 | ||||
| -rw-r--r-- | src/Editor.h | 2 | 
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_); | 
