diff options
| author | nyamatongwe <unknown> | 2007-07-27 01:52:48 +0000 | 
|---|---|---|
| committer | nyamatongwe <unknown> | 2007-07-27 01:52:48 +0000 | 
| commit | f76d4f14632acb5eb5ff671d97654d4032cbef7e (patch) | |
| tree | 6c226067ef20848c5c18189a68be8a75c20cd1c1 /src | |
| parent | 50c550fbaa760461e3262ceaa2e0ab183f94ba21 (diff) | |
| download | scintilla-mirror-f76d4f14632acb5eb5ff671d97654d4032cbef7e.tar.gz | |
Changed lineStates to a SplitVector so that it supports insert and delete
so inserting and deleting lines does not cause a really large number of
changed values under most circumstances leading to fewer notifications.
SVector is no longer used.
Diffstat (limited to 'src')
| -rw-r--r-- | src/CellBuffer.cxx | 31 | ||||
| -rw-r--r-- | src/CellBuffer.h | 4 | ||||
| -rw-r--r-- | src/Document.cxx | 1 | ||||
| -rw-r--r-- | src/DocumentAccessor.cxx | 1 | ||||
| -rw-r--r-- | src/Editor.cxx | 2 | ||||
| -rw-r--r-- | src/PositionCache.cxx | 1 | ||||
| -rw-r--r-- | src/ScintillaBase.cxx | 1 | ||||
| -rw-r--r-- | src/SplitVector.h | 8 | 
8 files changed, 35 insertions, 14 deletions
| diff --git a/src/CellBuffer.cxx b/src/CellBuffer.cxx index 157c91bdc..1beeefc6b 100644 --- a/src/CellBuffer.cxx +++ b/src/CellBuffer.cxx @@ -13,7 +13,6 @@  #include "Platform.h"  #include "Scintilla.h" -#include "SVector.h"  #include "SplitVector.h"  #include "Partitioning.h"  #include "CellBuffer.h" @@ -726,6 +725,20 @@ int CellBuffer::LineFromHandle(int markerHandle) {  // Without undo +void CellBuffer::InsertLine(int line, int position) { +	lv.InsertLine(line, position); +	if (lineStates.Length()) { +		lineStates.Insert(line, 0); +	} +} + +void CellBuffer::RemoveLine(int line) { +	lv.RemoveLine(line); +	if (lineStates.Length()) { +		lineStates.Delete(line); +	} +} +  void CellBuffer::BasicInsertString(int position, const char *s, int insertLength) {  	if (insertLength == 0)  		return; @@ -741,21 +754,21 @@ void CellBuffer::BasicInsertString(int position, const char *s, int insertLength  	char chAfter = substance.ValueAt(position + insertLength);  	if (chPrev == '\r' && chAfter == '\n') {  		// Splitting up a crlf pair at position -		lv.InsertLine(lineInsert, position); +		InsertLine(lineInsert, position);  		lineInsert++;  	}  	char ch = ' ';  	for (int i = 0; i < insertLength; i++) {  		ch = s[i];  		if (ch == '\r') { -			lv.InsertLine(lineInsert, (position + i) + 1); +			InsertLine(lineInsert, (position + i) + 1);  			lineInsert++;  		} else if (ch == '\n') {  			if (chPrev == '\r') {  				// Patch up what was end of line  				lv.SetLineStart(lineInsert - 1, (position + i) + 1);  			} else { -				lv.InsertLine(lineInsert, (position + i) + 1); +				InsertLine(lineInsert, (position + i) + 1);  				lineInsert++;  			}  		} @@ -765,7 +778,7 @@ void CellBuffer::BasicInsertString(int position, const char *s, int insertLength  	if (chAfter == '\n') {  		if (ch == '\r') {  			// End of line already in buffer so drop the newly created one -			lv.RemoveLine(lineInsert - 1); +			RemoveLine(lineInsert - 1);  		}  	}  } @@ -800,13 +813,13 @@ void CellBuffer::BasicDeleteChars(int position, int deleteLength) {  			chNext = substance.ValueAt(position + i + 1);  			if (ch == '\r') {  				if (chNext != '\n') { -					lv.RemoveLine(lineRemove); +					RemoveLine(lineRemove);  				}  			} else if (ch == '\n') {  				if (ignoreNL) {  					ignoreNL = false; 	// Further \n are real deletions  				} else { -					lv.RemoveLine(lineRemove); +					RemoveLine(lineRemove);  				}  			} @@ -817,7 +830,7 @@ void CellBuffer::BasicDeleteChars(int position, int deleteLength) {  		char chAfter = substance.ValueAt(position + deleteLength);  		if (chBefore == '\r' && chAfter == '\n') {  			// Using lineRemove-1 as cr ended line before start of deletion -			lv.RemoveLine(lineRemove - 1); +			RemoveLine(lineRemove - 1);  			lv.SetLineStart(lineRemove - 1, position + 1);  		}  	} @@ -892,12 +905,14 @@ void CellBuffer::PerformRedoStep() {  }  int CellBuffer::SetLineState(int line, int state) { +	lineStates.EnsureLength(line + 1);  	int stateOld = lineStates[line];  	lineStates[line] = state;  	return stateOld;  }  int CellBuffer::GetLineState(int line) { +	lineStates.EnsureLength(line + 1);  	return lineStates[line];  } diff --git a/src/CellBuffer.h b/src/CellBuffer.h index c51eab78d..4f654a8fd 100644 --- a/src/CellBuffer.h +++ b/src/CellBuffer.h @@ -160,7 +160,7 @@ private:  	LineVector lv; -	SVector lineStates; +	SplitVector<int> lineStates;  public: @@ -177,6 +177,8 @@ public:  	int Lines() const;  	int LineStart(int line) const;  	int LineFromPosition(int pos) { return lv.LineFromPosition(pos); } +	void InsertLine(int line, int position); +	void RemoveLine(int line);  	const char *InsertString(int position, const char *s, int insertLength, bool &startSequence);  	/// Setting styles for positions outside the range of the buffer is safe and has no effect. diff --git a/src/Document.cxx b/src/Document.cxx index db9949edc..e2ca7a32a 100644 --- a/src/Document.cxx +++ b/src/Document.cxx @@ -13,7 +13,6 @@  #include "Platform.h"  #include "Scintilla.h" -#include "SVector.h"  #include "SplitVector.h"  #include "Partitioning.h"  #include "RunStyles.h" diff --git a/src/DocumentAccessor.cxx b/src/DocumentAccessor.cxx index b46eeba85..a25979dc2 100644 --- a/src/DocumentAccessor.cxx +++ b/src/DocumentAccessor.cxx @@ -13,7 +13,6 @@  #include "Platform.h"  #include "PropSet.h" -#include "SVector.h"  #include "Accessor.h"  #include "DocumentAccessor.h"  #include "SplitVector.h" diff --git a/src/Editor.cxx b/src/Editor.cxx index 4d10b6272..8f334d534 100644 --- a/src/Editor.cxx +++ b/src/Editor.cxx @@ -21,7 +21,6 @@  #include "Partitioning.h"  #include "RunStyles.h"  #include "ContractionState.h" -#include "SVector.h"  #include "CellBuffer.h"  #include "KeyMap.h"  #include "Indicator.h" @@ -4110,6 +4109,7 @@ void Editor::NewLine() {  		}  	}  	SetLastXChosen(); +	SetScrollBars();  	EnsureCaretVisible();  	// Avoid blinking during rapid typing:  	ShowCaretAtCurrentPosition(); diff --git a/src/PositionCache.cxx b/src/PositionCache.cxx index 8e30f5922..5bdafc27e 100644 --- a/src/PositionCache.cxx +++ b/src/PositionCache.cxx @@ -18,7 +18,6 @@  #include "Partitioning.h"  #include "RunStyles.h"  #include "ContractionState.h" -#include "SVector.h"  #include "CellBuffer.h"  #include "KeyMap.h"  #include "Indicator.h" diff --git a/src/ScintillaBase.cxx b/src/ScintillaBase.cxx index d72f86bc3..60d9c70fc 100644 --- a/src/ScintillaBase.cxx +++ b/src/ScintillaBase.cxx @@ -24,7 +24,6 @@  #include "Partitioning.h"  #include "RunStyles.h"  #include "ContractionState.h" -#include "SVector.h"  #include "CellBuffer.h"  #include "CallTip.h"  #include "KeyMap.h" diff --git a/src/SplitVector.h b/src/SplitVector.h index 342be02ad..9d62aef72 100644 --- a/src/SplitVector.h +++ b/src/SplitVector.h @@ -181,6 +181,14 @@ public:  			gapLength -= insertLength;  		}  	} + +	/// Ensure at least length elements allocated,  +	/// appending zero valued elements if needed. +	void EnsureLength(int wantedLength) { +		if (Length() < wantedLength) { +			InsertValue(Length(), wantedLength - Length(), 0); +		} +	}  	/// Insert text into the buffer from an array.  	void InsertFromArray(int positionToInsert, const T s[], int positionFrom, int insertLength) { | 
