CommandManager

interface CommandManager

The project's history: thread-affine and asynchronous. Its methods are called on the model thread; completions may arrive on any thread.

Inheritors

AndroidCommandManager
JsCommandManager
JvmCommandManager
NativeCommandManager
WasmJsCommandManager

Properties

Link copied to clipboard
abstract val state: UndoState

Functions

Link copied to clipboard
abstract fun beginGesture(description: String, origin: MutationOrigin = MutationOrigin.User, batching: StepEventBatching = StepEventBatching.PerCommand): UndoResult

A gesture is a step that coalesces adjacent commands sharing a command id: intermediate values are applied, but history keeps only the first and the last.

Link copied to clipboard
abstract fun beginStep(description: String, origin: MutationOrigin = MutationOrigin.User, batching: StepEventBatching = StepEventBatching.PerCommand): UndoResult

Opens one named history step spanning several commands. Commands performed while it is open are applied immediately but enter history as one entry only when endStep succeeds. Nested steps are deliberately rejected.

Link copied to clipboard
abstract fun cancelGesture(completion: (UndoResult) -> Unit? = null)
Link copied to clipboard
abstract fun cancelStep(completion: (UndoResult) -> Unit? = null)

Reverts every child that already ran, in reverse order.

Link copied to clipboard
abstract fun clear(markCurrentStateSaved: Boolean = true): Boolean

Releases every retained revert and makes the current document a new history root. Fails while a command is pending or a step is open.

Link copied to clipboard
abstract fun endGesture(completion: (UndoResult) -> Unit? = null)
Link copied to clipboard
abstract fun endStep(completion: (UndoResult) -> Unit? = null)
Link copied to clipboard
abstract fun markSaved(): Boolean

Save points and retention. What "dirty" means belongs to the history, not to whoever writes the file: a numeric cursor cannot tell an undo followed by a fresh edit from the state that was saved.

Link copied to clipboard
abstract fun markStateSaved(stateId: Long): Boolean
Link copied to clipboard
abstract fun redo(completion: (UndoResult) -> Unit? = null)
Link copied to clipboard
Link copied to clipboard
abstract fun shutdown()

Refuses new work and completes pending notification as Cancelled.

Link copied to clipboard
abstract fun undo(completion: (UndoResult) -> Unit? = null)