Class ExpressionHistory

java.lang.Object
org.cyclops.integrateddynamics.core.logicprogrammer.ExpressionHistory

public class ExpressionHistory extends Object
The changes to an expression in the logic programmer, to go back and forth through them. Changes are recorded by observing the expression, so they can come from slots, parameters or text alike. Typing the same expression in another way is a change as well, as the text is shown as typed.
  • Field Details

  • Constructor Details

    • ExpressionHistory

      public ExpressionHistory()
  • Method Details

    • observe

      public void observe(Expression expression, @Nullable String text)
      Observe the current expression, which records a change if it or its text differs from the one observed before.
      Parameters:
      expression - The current expression.
      text - The text it was typed as, or null if it is printed.
    • canUndo

      public boolean canUndo()
    • canRedo

      public boolean canRedo()
    • undo

      @Nullable public ExpressionHistory.Entry undo()
      Go back one change. Call moved(Entry) once the returned expression is set.
      Returns:
      The expression to go back to, or null if there is none.
    • redo

      @Nullable public ExpressionHistory.Entry redo()
      Go forward one undone change. Call moved(Entry) once the returned expression is set.
      Returns:
      The expression to go forward to, or null if there is none.
    • moved

      public void moved(ExpressionHistory.Entry entry)
      Make the given expression the current one without recording a change, after an undo or redo set it.
      Parameters:
      entry - The current expression and its text.
    • clear

      public void clear()
      Forget all changes, such as when another expression is opened.