Class UndoTree<T>

  • Type Parameters:
    T - the type of state object being tracked

    public class UndoTree<T>
    extends java.lang.Object
    Provides undo/redo functionality for the LineReader.

    This class implements a simple undo tree that allows tracking and restoring previous states of an object (typically the line buffer). It maintains a linear history of states that can be navigated with undo and redo operations.

    Key features:

    • Tracks a sequence of states that can be undone and redone
    • Uses a consumer to apply state changes when undoing or redoing
    • Maintains the current position in the undo history

    Note that the first added state (the initial state) cannot be undone.

    • Constructor Summary

      Constructors 
      Constructor Description
      UndoTree​(java.util.function.Consumer<T> s)  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      boolean canRedo()  
      boolean canUndo()  
      void clear()  
      void newState​(T state)  
      void redo()  
      void undo()  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • UndoTree

        public UndoTree​(java.util.function.Consumer<T> s)
    • Method Detail

      • clear

        public void clear()
      • newState

        public void newState​(T state)
      • canUndo

        public boolean canUndo()
      • canRedo

        public boolean canRedo()
      • undo

        public void undo()
      • redo

        public void redo()