Undo
An undo/redo library with dynamic dispatch, state handling and automatic command merging.
About
It uses the Command Pattern where the user implements the UndoCmd
trait for each command.
The UndoStack
has two states, clean and dirty. The stack is clean when no more commands can
be redone, otherwise it is dirty. The stack will notice when it's state changes to either dirty
or clean, and call the user defined methods set in on_clean
and on_dirty
. This is useful if
you want to trigger some event when the state changes, eg. enabling and disabling buttons in an ui.
It also supports automatic merging of commands with the same id.
Redo vs Undo
Redo | Undo | |
---|---|---|
Dispatch | Static | Dynamic |
State Handling | Yes | Yes |
Command Merging | Manual | Auto |
Both supports command merging but undo
will automatically merge commands with the same id,
while in redo
you need to implement the merge method yourself.
Examples
[]
= "0.7.2"
use ;