Follow a chart a host rebuilt (and its drawing controller), keeping the
timeline. Panes are matched by slot and studies by id, which is what a
chart restored from the old one's getState keeps. Drawing steps the old
controller held are taken back from the drawings either side of them,
since the new controller holds none of them. A study the old chart held
and the new one does not was left out by the host, and no press brings it back.
Merge everything recorded until the returned function runs into one step: a dialog that previews its edits live, a colour dragged through a picker. A group whose changes cancel out (a dialog's Cancel) leaves no step. Groups nest; the outermost decides.
Optionallabel: stringRun fn as the host's own change rather than a user step: nothing it
does to the chart or its drawings is recorded, and no undo or redo takes
it back, so a study it removes is never brought back by a press, and a
command it pushes is not recorded. The redo branch is kept. Inside a
transaction or a group, the step is recorded on either side of it and
leaves it alone.
The step a redo would take, or null.
The step an undo would take, or null.
Record a host's own reversible step, for a change the history cannot
observe. Inside ignore, or while a press is applied, it records nothing:
the change is the host's own there.
Run fn as one step: every change it makes to the chart and its drawings
is taken back by one undo. A chart setting (the grid, the status line)
and a scale's auto-fit or pinned ratio are read only in a transaction's
full capture, so they are recorded only this way; a pane weight or a
scale option set outside one is a step of its own, which the chart
announces with layout:change. Nested calls join the outermost one. A
throw still records what fn changed before it, then rethrows. An
ignore inside it is left out of the step, which is taken back on
either side of it.
Optionallabel: string
The chart-wide undo and redo coordinator. Build one per chart, give it the drawing controller, and send every undo and redo press through it.