diff options
| author | nyamatongwe <devnull@localhost> | 2005-12-11 23:43:04 +0000 | 
|---|---|---|
| committer | nyamatongwe <devnull@localhost> | 2005-12-11 23:43:04 +0000 | 
| commit | 8baea8206456c00cf13b6160e51e22be87ab42bd (patch) | |
| tree | 9b6fe767b3ac0c8fa0f6fbba1f1ccada6263f3b1 /src/CellBuffer.cxx | |
| parent | 341cb23a35eb6372191044140a1d2437faaafe02 (diff) | |
| download | scintilla-mirror-8baea8206456c00cf13b6160e51e22be87ab42bd.tar.gz | |
Patch from Armel Asselin in RFE 1377661 to store positions in undo stack
in terms of document (cell) position rather than byte position.
Will help allow expansion to more than 2 bytes per cell.
Diffstat (limited to 'src/CellBuffer.cxx')
| -rw-r--r-- | src/CellBuffer.cxx | 23 | 
1 files changed, 8 insertions, 15 deletions
| diff --git a/src/CellBuffer.cxx b/src/CellBuffer.cxx index 2e8349481..1109a17fb 100644 --- a/src/CellBuffer.cxx +++ b/src/CellBuffer.cxx @@ -465,7 +465,7 @@ void UndoHistory::AppendAction(actionType at, int position, char *data, int leng  			} else if (currentAction == savePoint) {  				currentAction++;  			} else if ((at == insertAction) && -			           (position != (actPrevious.position + actPrevious.lenData*2))) { +			           (position != (actPrevious.position + actPrevious.lenData))) {  				// Insertions must be immediately after to coalesce  				currentAction++;  			} else if (!actions[currentAction].mayCoalesce) { @@ -473,7 +473,7 @@ void UndoHistory::AppendAction(actionType at, int position, char *data, int leng  				currentAction++;  			} else if (at == removeAction) {  				if ((lengthData == 1) || (lengthData == 2)){ -					if ((position + lengthData * 2) == actPrevious.position) { +					if ((position + lengthData) == actPrevious.position) {  						; // Backspace -> OK  					} else if (position == actPrevious.position) {  						; // Delete -> OK @@ -725,7 +725,7 @@ const char *CellBuffer::InsertString(int position, char *s, int insertLength) {  			for (int i = 0; i < insertLength / 2; i++) {  				data[i] = s[i * 2];  			} -			uh.AppendAction(insertAction, position, data, insertLength / 2); +			uh.AppendAction(insertAction, position / 2, data, insertLength / 2);  		}  		BasicInsertString(position, s, insertLength); @@ -733,13 +733,6 @@ const char *CellBuffer::InsertString(int position, char *s, int insertLength) {  	return data;  } -void CellBuffer::InsertCharStyle(int position, char ch, char style) { -	char s[2]; -	s[0] = ch; -	s[1] = style; -	InsertString(position*2, s, 2); -} -  bool CellBuffer::SetStyleAt(int position, char style, char mask) {  	style &= mask;  	char curVal = ByteAt(position * 2 + 1); @@ -778,7 +771,7 @@ const char *CellBuffer::DeleteChars(int position, int deleteLength) {  			for (int i = 0; i < deleteLength / 2; i++) {  				data[i] = ByteAt(position + i * 2);  			} -			uh.AppendAction(removeAction, position, data, deleteLength / 2); +			uh.AppendAction(removeAction, position / 2, data, deleteLength / 2);  		}  		BasicDeleteChars(position, deleteLength); @@ -1045,14 +1038,14 @@ const Action &CellBuffer::GetUndoStep() const {  void CellBuffer::PerformUndoStep() {  	const Action &actionStep = uh.GetUndoStep();  	if (actionStep.at == insertAction) { -		BasicDeleteChars(actionStep.position, actionStep.lenData*2); +		BasicDeleteChars(actionStep.position*2, actionStep.lenData*2);  	} else if (actionStep.at == removeAction) {  		char *styledData = new char[actionStep.lenData * 2];  		for (int i = 0; i < actionStep.lenData; i++) {  			styledData[i*2] = actionStep.data[i];  			styledData[i*2 + 1] = 0;  		} -		BasicInsertString(actionStep.position, styledData, actionStep.lenData*2); +		BasicInsertString(actionStep.position*2, styledData, actionStep.lenData*2);  		delete []styledData;  	}  	uh.CompletedUndoStep(); @@ -1078,10 +1071,10 @@ void CellBuffer::PerformRedoStep() {  			styledData[i*2] = actionStep.data[i];  			styledData[i*2 + 1] = 0;  		} -		BasicInsertString(actionStep.position, styledData, actionStep.lenData*2); +		BasicInsertString(actionStep.position*2, styledData, actionStep.lenData*2);  		delete []styledData;  	} else if (actionStep.at == removeAction) { -		BasicDeleteChars(actionStep.position, actionStep.lenData*2); +		BasicDeleteChars(actionStep.position*2, actionStep.lenData*2);  	}  	uh.CompletedRedoStep();  } | 
