Vixen
dd8b0a81
csharp
public sealed class UndoManager

The ordinary in-memory undo stack.

Read the guide page for this →

Remarks

What a document with no command stack of its own wants, and what UiApplication installs so that a dialog's text box has ⌘Z without an application deciding to.

⚠ Bounded, and the bound is a decision. An edit is two closures over the strings either side of it, so an unbounded stack in a long-lived application is a copy of every version of every field it ever showed. Limit drops the oldest, which is what every editor does and is why "undo all the way to the beginning" is not a promise anything makes.

Fields and properties (6)

  • public int Limit

    How many edits it keeps.

  • public bool CanUndo

    Whether there is anything to take back.

  • public bool CanRedo

    Whether there is anything to put back.

  • public bool IsPerforming

    Whether an undo or a redo is running right now.

  • public string? UndoName

    What the next undo would take back, for a menu item's label.

  • public string? RedoName

    What the next redo would put back.

Methods (4)

  • public void Register(string name, Action undo, Action redo)

    Records something that has already happened.

  • public bool Undo()

    Takes back the most recent edit.

  • public bool Redo()

    Puts back the most recently undone edit.

  • public void Clear()

    Forgets everything.

Used by (4)

  • ResponderChainTestsVixen.Ui.Tests
  • UiApplicationVixen.Ui.Desktop
  • UndoCommandsTestsVixen.Ui.Tests
  • UndoTestsVixen.Ui.Controls.Tests