Package: groovy.console.ui.text

## [Java] Class TextUndoManager

- groovy.console.ui.text.TextUndoManager

-     public class TextUndoManager
      extends UndoManager

  To use this, simply drop this as an UndoableEditListener into your document, and then create actions to call undo/redo as needed (checking can undo/redo first, of course).

- - ### Constructor Summary

    Constructors
    Constructor and description
    `TextUndoManager()` Creates a new instance of TextUndoManager.

  - ### Methods Summary

    Methods
    Type Params | Return Type | Name and description
    --- | --- | ---
    `` | `public void` | `addPropertyChangeListener(PropertyChangeListener pcl)` Registers a listener for undo/redo state changes.
    `` | `public void` | `die()` Sends `die` to each subedit, in the reverse of the order that they were added.
    `` | `public void` | `discardAllEdits()` Empties the undo manager sending each edit a `die` message in the process. See Also: AbstractUndoableEdit#die#die
    `` | `protected void` | `firePropertyChangeEvent(String name, boolean oldValue, boolean newValue)` Fires an undo-state property change event.
    `` | `public boolean` | `hasChanged()` Indicates whether the document differs from the last reset point.
    `` | `public void` | `redo()` Redoes the appropriate edits. If `end` has been invoked this calls through to the superclass. Otherwise this invokes `redo` on all edits between the index of the next edit and the next significant edit, updating the index of the next edit appropriately. throws: CannotRedoException if one of the edits throws `CannotRedoException` or there are no edits to be redone See Also: CompoundEdit.end canRedo editToBeRedone
    `` | `protected void` | `redoTo(UndoableEdit edit)` Redoes all changes from the index of the next edit to `edit`, updating the index of the next edit appropriately. throws: CannotRedoException if one of the edits throws `CannotRedoException` Parameters: `edit` - the edit to be redo to
    `` | `public void` | `removePropertyChangeListener(PropertyChangeListener pcl)` Removes a listener for undo/redo state changes.
    `` | `public void` | `reset()` Marks the current undo position as the unmodified state.
    `` | `public void` | `setRecording(boolean recording)` Toggle recording of undoable edits.
    `` | `protected void` | `trimEdits(int from, int to)` Removes edits in the specified range. All edits in the given range (inclusive, and in reverse order) will have `die` invoked on them and are removed from the list of edits. This has no effect if `from` > `to`. Parameters: `from` - the minimum index to remove `to` - the maximum index to remove
    `` | `public void` | `undo()` Undoes the appropriate edits. If `end` has been invoked this calls through to the superclass, otherwise this invokes `undo` on all edits between the index of the next edit and the last significant edit, updating the index of the next edit appropriately. throws: CannotUndoException if one of the edits throws `CannotUndoException` or there are no edits to be undone See Also: CompoundEdit.end canUndo editToBeUndone
    `` | `public void` | `undoableEditHappened(UndoableEditEvent uee)` An `UndoableEditListener` method. This invokes `addEdit` with `e.getEdit()`. Parameters: `e` - the `UndoableEditEvent` the `UndoableEditEvent` will be added from See Also: addEdit

  - ### Inherited Methods Summary

    Inherited Methods
    Methods inherited from class | Name
    --- | ---
    `class UndoManager` | `addEdit, canRedo, canUndo, canUndoOrRedo, die, discardAllEdits, end, equals, getClass, getLimit, getPresentationName, getRedoPresentationName, getUndoOrRedoPresentationName, getUndoPresentationName, hashCode, isInProgress, isSignificant, notify, notifyAll, redo, replaceEdit, setLimit, toString, undo, undoOrRedo, undoableEditHappened, wait, wait, wait`

- - ### Constructor Detail

    - #### public TextUndoManager()

      Creates a new instance of TextUndoManager.

  - ### Method Detail

    - #### public void addPropertyChangeListener(PropertyChangeListener pcl)

      Registers a listener for undo/redo state changes.

      Parameters:
        `pcl` - the listener to add

    - #### public void die()

      Sends `die` to each subedit, in the reverse of the order that they were added.

    - #### public void discardAllEdits()

      Empties the undo manager sending each edit a `die` message in the process.

      See Also:
        AbstractUndoableEdit#die#die

    - #### protected void firePropertyChangeEvent(String name, boolean oldValue, boolean newValue)

      Fires an undo-state property change event.

      Parameters:
        `name` - the property name
        `oldValue` - the previous value
        `newValue` - the new value

    - #### public boolean hasChanged()

      Indicates whether the document differs from the last reset point.

      Returns:
        `true` if undo history contains unreset edits

    - #### public void redo()

      Redoes the appropriate edits. If `end` has been invoked this calls through to the superclass. Otherwise this invokes `redo` on all edits between the index of the next edit and the next significant edit, updating the index of the next edit appropriately.

      throws:
        CannotRedoException if one of the edits throws `CannotRedoException` or there are no edits to be redone
      See Also:
        CompoundEdit.end
        canRedo
        editToBeRedone

    - #### protected void redoTo(UndoableEdit edit)

      Redoes all changes from the index of the next edit to `edit`, updating the index of the next edit appropriately.

      throws:
        CannotRedoException if one of the edits throws `CannotRedoException`
      Parameters:
        `edit` - the edit to be redo to

    - #### public void removePropertyChangeListener(PropertyChangeListener pcl)

      Removes a listener for undo/redo state changes.

      Parameters:
        `pcl` - the listener to remove

    - #### public void reset()

      Marks the current undo position as the unmodified state.

    - #### public void setRecording(boolean recording)

      Toggle recording of undoable edits. Used to suppress capture of programmatic style changes (e.g. a theme switch re-parsing the document) that shouldn't be reachable via user-initiated Undo.

      Since:
        6.0.0

    - #### protected void trimEdits(int from, int to)

      Removes edits in the specified range. All edits in the given range (inclusive, and in reverse order) will have `die` invoked on them and are removed from the list of edits. This has no effect if `from` > `to`.

      Parameters:
        `from` - the minimum index to remove
        `to` - the maximum index to remove

    - #### public void undo()

      Undoes the appropriate edits. If `end` has been invoked this calls through to the superclass, otherwise this invokes `undo` on all edits between the index of the next edit and the last significant edit, updating the index of the next edit appropriately.

      throws:
        CannotUndoException if one of the edits throws `CannotUndoException` or there are no edits to be undone
      See Also:
        CompoundEdit.end
        canUndo
        editToBeUndone

    - #### public void undoableEditHappened(UndoableEditEvent uee)

      An `UndoableEditListener` method. This invokes `addEdit` with `e.getEdit()`.

      Parameters:
        `e` - the `UndoableEditEvent` the `UndoableEditEvent` will be added from
      See Also:
        addEdit