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.

Constructors

Accessors

Methods

  • 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.

    Parameters

    Returns void

  • Forget every step. The chart is left as it is. In place: a press whose command restores the chart still files its step.

    Returns void

  • 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.

    Parameters

    • Optionallabel: string

    Returns () => void

  • Run 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.

    Type Parameters

    • T

    Parameters

    • fn: () => T

    Returns T

  • Apply again the step an undo took back. False when there was none, or it could not be applied.

    Returns boolean

  • Called after every change to what canUndo, canRedo or the peeks report.

    Parameters

    • listener: () => void

    Returns () => void

  • 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.

    Type Parameters

    • T

    Parameters

    • fn: () => T
    • Optionallabel: string

    Returns T

  • Take back the latest step. False when there was none, or it could not be applied.

    Returns boolean