Class orion.textview.UndoStack
The UndoStack is used to record the history of a text model associated to an view. Every change to the model is added to stack, allowing the application to undo and redo these changes.
Defined in: </shared/eclipse/e4/orion/I201301232230/plugins/org.eclipse.orion.client.editor/web/orion/textview/undoStack.js>.
Constructor Attributes | Constructor Name and Description |
---|---|
orion.textview.UndoStack(view, size)
Constructs a new UndoStack on a text view.
|
Method Attributes | Method Name and Description |
---|---|
add(change)
Adds a change to the stack.
|
|
canRedo()
Returns true if there is at least one change to redo.
|
|
canUndo()
Returns true if there is at least one change to undo.
|
|
Finishes a compound change.
|
|
getSize()
Returns the sizes of the stack.
|
|
isClean()
Returns true if current state of stack is the same
as the state when markClean() was called.
|
|
Marks the current state of the stack as clean.
|
|
redo()
Redo the last change in the stack.
|
|
reset()
Reset the stack to its original state.
|
|
Starts a compound change.
|
|
undo()
Undo the last change in the stack.
|
- Parameters:
- {orion.textview.TextView} view
- the text view for the undo stack.
- {Number} size Optional, Default: 100
- the size for the undo stack.
- Parameters:
- change
- the change to add.
- {Number} change.offset
- the offset of the change
- {String} change.text
- the new text of the change
- {String} change.previousText
- the previous text of the change
- Returns:
- {Boolean} returns true if there is at least one change to redo.
- Returns:
- {Boolean} returns true if there is at least one change to undo.
- See:
- #startCompoundChange
- Returns:
- {object} a object where object.undo is the number of changes that can be un-done, and object.redo is the number of changes that can be re-done.
For example, the application calls markClean(), then calls undo() four times and redo() four times. At this point isClean() returns true.
This function is typically called to determine if the content of the view associated with the stack has changed since the last time it was saved.
- Returns:
- {Boolean} returns if the state is the same as the state when markClean() was called.
- See:
- #markClean
This function is typically called when the content of view associated with the stack is saved.
- See:
- #isClean
- Returns:
- {Boolean} returns true if a change was re-done.
All changes added to stack from the time startCompoundChange() is called to the time that endCompoundChange() is called are compound on one change that can be un-done or re-done with one single call to undo() or redo().
- See:
- #endCompoundChange
- Returns:
- {Boolean} returns true if a change was un-done.