diff options
| author | Neil <nyamatongwe@gmail.com> | 2014-07-18 23:37:23 +1000 | 
|---|---|---|
| committer | Neil <nyamatongwe@gmail.com> | 2014-07-18 23:37:23 +1000 | 
| commit | 1472b33e83897ba443974f838fb92fe720118d42 (patch) | |
| tree | 9c756a4b25bb8b32082cee01f5d6b1c39e7930bb /src/CellBuffer.cxx | |
| parent | 5e13b48636a6442af501bdbf1fe4afd7d008e489 (diff) | |
| download | scintilla-mirror-1472b33e83897ba443974f838fb92fe720118d42.tar.gz | |
Added the tentative undo feature. This is useful for IMEs that want to display
and manipulate a character being composed, but may then commit or remove it
leaving no history in undo of the intermediate forms.
Diffstat (limited to 'src/CellBuffer.cxx')
| -rw-r--r-- | src/CellBuffer.cxx | 40 | 
1 files changed, 39 insertions, 1 deletions
diff --git a/src/CellBuffer.cxx b/src/CellBuffer.cxx index 0c56c9e92..710e32403 100644 --- a/src/CellBuffer.cxx +++ b/src/CellBuffer.cxx @@ -144,6 +144,7 @@ UndoHistory::UndoHistory() {  	currentAction = 0;  	undoSequenceDepth = 0;  	savePoint = 0; +	tentativePoint = -1;  	actions[currentAction].Create(startAction);  } @@ -194,7 +195,7 @@ const char *UndoHistory::AppendAction(actionType at, int position, const char *d  			// Visual Studio 2013 Code Analysis wrongly believes actions can be NULL at its next reference  			__analysis_assume(actions);  #endif -			if (currentAction == savePoint) { +			if ((currentAction == savePoint) || (currentAction == tentativePoint)) {  				currentAction++;  			} else if (!actions[currentAction].mayCoalesce) {  				// Not allowed to coalesce if this set @@ -282,6 +283,7 @@ void UndoHistory::DeleteUndoHistory() {  	currentAction = 0;  	actions[currentAction].Create(startAction);  	savePoint = 0; +	tentativePoint = -1;  }  void UndoHistory::SetSavePoint() { @@ -292,6 +294,26 @@ bool UndoHistory::IsSavePoint() const {  	return savePoint == currentAction;  } +void UndoHistory::TentativeStart() { +	tentativePoint = currentAction; +} + +void UndoHistory::TentativeCommit() { +	tentativePoint = -1; +	// Truncate undo history +	maxAction = currentAction; +} + +int UndoHistory::TentativeSteps() { +	// Drop any trailing startAction +	if (actions[currentAction].at == startAction && currentAction > 0) +		currentAction--; +	if (tentativePoint >= 0) +		return currentAction - tentativePoint; +	else +		return -1; +} +  bool UndoHistory::CanUndo() const {  	return (currentAction > 0) && (maxAction > 0);  } @@ -505,6 +527,22 @@ bool CellBuffer::IsSavePoint() const {  	return uh.IsSavePoint();  } +void CellBuffer::TentativeStart() { +	uh.TentativeStart(); +} + +void CellBuffer::TentativeCommit() { +	uh.TentativeCommit(); +} + +int CellBuffer::TentativeSteps() { +	return uh.TentativeSteps(); +} + +bool CellBuffer::TentativeActive() const { +	return uh.TentativeActive(); +} +  // Without undo  void CellBuffer::InsertLine(int line, int position, bool lineStart) {  | 
