public interface IUndoManagerSomewhere for a control to put an edit so that it can be taken back.
Remarks
A control finds a manager rather than owning one. CodeBuffer argues the point and is right: undo belongs to the application, because it has to interleave with everything else — a rename that touched three files, a refactor, a move — and a stack inside a text control can only ever undo typing. What the argument does not settle is where the control looks, and until this existed the answer was nowhere, so a dialog's text box had no ⌘Z in any Vixen application including the editor.
⚠ Nearest wins, and nothing is a real answer. The lookup walks the element's ancestors and then the document, which is AppKit's NSResponder.undoManager with the ceremony removed. A field in a dialog with no document behind it finds nothing, registers nothing, and leaves ⌘Z to whatever else was listening — which is the right behaviour and is what keeps a text field from shadowing an application's own Undo.
⚠ Closures, not commands. An edit is two delegates. There is no interface for a caller to implement, no reflection and nothing to register (ADR-002); an implementation that already has a command stack — the editor's — adapts by wrapping its own command in the pair.
Fields and properties (3)
bool CanUndoWhether there is anything to take back.
bool CanRedoWhether there is anything to put back.
bool IsPerformingWhether an undo or a redo is running right now.
Methods (3)
void Register(string name, Action undo, Action redo)Records something that has already happened.
bool Undo()Takes back the most recent edit.
bool Redo()Puts back the most recently undone edit.
Used by (12)
- ControllerVixen.Ui.Tests
- IResponderVixen.Ui
- TextFieldVixen.Ui.Controls
- UiDocumentVixen.Ui
- UiElementVixen.Ui
- UndoCommandsVixen.Ui
- UndoManagerVixen.Ui
- ActiveDocumentUndoVixen.Editor.App
- CommandStackVixen.Editor.Core
- CommandStackUndoManagerTestsVixen.Editor.Core.Tests
- EditorApplicationVixen.Editor.App
- EditorUndoManagerTestsVixen.Editor.App.Tests