Goanna UndoManager proposal

In order to implement undo/redo functionality in Goanna, it seems that we can introduce an UndoManager. Each system will have an undo manager. Any mutating action (property set, etc.) will log this action in the undo manager. The log entry will consist of a few things:

  • A name or other identifier
  • A functor which, when invoked, undoes the action
  • A functor which, when invoked, repeats the action

The undo manager must also support groupings. A grouping is an entry which contains other entries, to be presented to the user as one entry. If a group constructor is active, the undo manager will log actions as members of that group rather than as independent actions. Groups should also be nestable, so that grouping operations don't have to be aware of whether or not the actions they invoke create groups.

It should also be possible to create a null group, which will serve to throw away all changes made under it (e.g., splatter would be in a null group).

Undoing starts pushing undone actions onto the redo stack. As soon as a new event is logged, the redo stack is thrown away. Events generated while an undo or redo is in progress are discarded.