Crate undo

source ·
Expand description

An undo-redo library.

An implementation of the command pattern, where all edits are done by creating objects that applies the modifications. All objects knows how to undo the changes it applies, and by using the provided data structures it is easy to undo and redo edits made to a target.

See the examples for more information.

Features

  • Edit provides the base functionality for all edit commands. Multiple edit commands can be merged into a single edit by implementing the merge method on the edit. This allows smaller edits to be used to build more complex operations, or smaller incremental changes to be merged into larger changes that can be undone and redone in a single step.
  • Record provides basic stack based undo-redo functionality.
  • History provides full tree based undo-redo functionality.
  • Queue and checkpoint functionality is supported for both Record and History.
  • The target can be marked as saved to disk and the user will be notified when it changes.
  • The amount of changes being tracked can be configured by the user so only the N most recent changes are stored.
  • Configurable display formatting using the display structures.

Examples

All examples in the documentation uses the Add command found here.

Cargo Feature Flags

NameDefaultEnablesDescription
stdallocEnables the standard library.
allocEnables the alloc crate.
coloredEnables colored output when visualizing the display structures.
serdeEnables serialization and deserialization.

Re-exports

Modules

  • A history tree of edit commands.
  • A linear record of edit commands.

Structs

  • A position in a history tree.
  • Wrapper around an Edit command that contains additional metadata.

Enums

  • Describes an event on the structures.
  • Says if the Edit command have been merged with another command.

Traits

  • Base functionality for all edit commands.
  • Handles events.