Expand description
Undo histories, as the interface sees them (ADR 0014): the pure parts
of the History contract.
Experimental: may change in any release
(docs/stability.md).
- A scope (
ScopeId, described byScopeInfo) is one history: a document’s edit, a collection’s marks, the application’s values, the settings window. Steps never cross scopes. - A step says what it is, not how to undo it (
StepInfo): its id, scope,Label, origin, group, the place of the context stack it was made in, its time and whether it is still in progress. The inverse stays with the owner. - A scope’s steps are a
Line: what an undo walks back (oldest first) and what a redo makes again (the next one last), with the scope’s revision. Redo is linear: a new step drops the redo list. - Merging (
merges): repeats on one target (held arrows, wheel notches, a colour picker’s frames) carry the same merge key and are one step while they come less thanMERGE_WINDOWapart, from the same origin, the focus unchanged. - Routing (
newest): Ctrl+Z, outside a text field and a focused local scope, undoes the newest step among the scopes active in the window, unless the application routes by focus (the API crate’shistory::Routing). - A jump (
plan_jump) is a run of undos or redos to a step. - Beyond them, as an owner supports them (
Features): aSnapshot(a named state pinned in a scope), aPreviewof a point (At) the pointer is on, the steps a new step dropped from the redo list (Replaced), and one step undone out of order, unless a later step shares a target (may_undo_out_of_order).
use egui_pop_model::commands::Origin;
use egui_pop_model::history::{Label, Line, MergeMark, ScopeId, StepInfo, merges, plan_jump};
let a = MergeMark::new("view/zoom", Origin::User, 10.0);
assert!(merges(&a, &MergeMark::new("view/zoom", Origin::User, 10.4)));
assert!(!merges(&a, &MergeMark::new("view/zoom", Origin::User, 11.5)));
let step = |id| StepInfo::new(id, ScopeId::from_static("app"), Label::text("Zoom"), Origin::User);
let line = Line { undo: vec![step(1), step(2)], redo: vec![step(3)], rev: 4 };
let jump = plan_jump(&line, 3).unwrap();
assert_eq!((jump.redo, jump.count), (true, 1));Re-exports§
pub use crate::ids::ScopeId;
Structs§
- Features
- What an owner supports beyond undo, redo and jump, per scope; the history panel offers only these.
- Jump
- A jump, as undos or redos.
- Label
- What a step is called: a message id and its arguments, rendered in the interface’s language when shown, with its English text for an interface that does not know the message (“Exposure +0.30 EV”).
- Line
- A scope’s steps.
- Merge
Mark - What a step carries to be merged with the next: its merge key (the target path, or the component’s own key), origin and time.
- Preview
- What the owner answers a hover on the history panel: it may show the
state there itself (
shown: in its own views, the image as it was), and say what differs from now, which the panel shows beside the row. Nothing is committed: the hover ending cancels it. - Preview
Change - One thing a preview says differs.
- Refusal
- A refusal, with its reason as the interface shows it.
- Replaced
- A step a new step dropped from the redo list, kept by an owner whose history keeps every state (ADR 0014): the history panel shows it as a “replaced” row behind a toggle, and a jump reaches it.
- Request
- An undo, a redo or a jump asked of a scope.
- Scope
Info - A history, described.
- Snapshot
- A named state pinned in a scope (ADR 0014): taken by the user or an agent, never dropped by the cap, restored as a new step.
- Step
Info - One step of a history, as the interface sees it.
Enums§
- At
- A point of a history the panel previews: a step (0: the start, a replaced step included) or a snapshot.
- Refusal
Kind - Why an undo, a redo or a jump was refused.
Constants§
- APP
- The application’s own history: the value store’s steps.
- CAP
- How many steps a scope keeps by default, the oldest dropped first.
- MERGE_
WINDOW - How far apart, in seconds, two repeats on one target may come and still be one step.
- SETTINGS
- The settings window’s history: the values written from its form.
Functions§
- may_
undo_ out_ of_ order - Whether undoing
stepout of order is allowed (VS Code’s rule): no later step ofundo(oldest first) changed one of the sametargets.targets_ofnames what a step changes.Err: the later step in the way, and the target it shares. - merges
- Whether
nextjoins the step that ended withprev: the same key and origin, less thanMERGE_WINDOWlater. The owner also stops merging when the focus leaves, after an undo or a redo, and across groups. - newest
- The scope Ctrl+Z undoes among
lines(the active scopes): the one whose head is newest, by time then by id; a later scope wins a tie.None: nothing to undo in any of them. - plan_
jump - How to bring a scope to step
to: after it,tois the head (0: the start, everything undone).