Expand description
Shared undo / redo infrastructure.
Mirrors the C# agg-sharp IUndoRedoCommand / UndoBuffer pattern so that
any subsystem — text editing, layout, graph editing — can participate in a
common, extensible undo stack.
Two complementary models live here:
UndoBuffer— a command-history stack (do/undo/redo per named command), the general-purpose mechanism used by most subsystems.undoer::Undoer— a time-coalescing state snapshot undoer (a faithful port of egui’sUndoer<State>). It suits editors that would rather diff whole-state snapshots than author explicit commands — the RichTextEdit widget snapshots{RichDoc, caret}through it, and the dialogs demo snapshots its{toggle, text}.
§Usage
ⓘ
use agg_gui::undo::{DoUndoActions, UndoBuffer};
let mut buf = UndoBuffer::new();
// Execute an action and make it undoable:
let v = std::rc::Rc::new(std::cell::Cell::new(0i32));
let v2 = v.clone();
buf.add_and_do(Box::new(DoUndoActions::new(
"set value",
move || v.set(42),
move || v2.set(0),
)));Re-exports§
Modules§
- undoer
- Time-coalescing undo/redo history — a faithful port of egui’s
egui::util::undoer::Undoer<State>(seeegui-reference/crates/egui/src/util/undoer.rs).
Structs§
- DoUndo
Actions - A command backed by two closures: one for
do_itand one forundo_it. - Undo
Buffer - Two-stack undo/redo history buffer.
Traits§
- Undo
Redo Command - A named, reversible operation.