EditHistory
Namespace: Hex1b.Documents
Assembly: Hex1b.dll
Manages undo/redo history for an editor. Supports explicit grouping, automatic typing coalescing, and cursor state restoration.
public sealed class EditHistoryInheritance
Object → EditHistory
Properties
CanRedo
Whether there are operations to redo.
Returns: Boolean
public bool CanRedo { get; }CanUndo
Whether there are operations to undo.
Returns: Boolean
public bool CanUndo { get; }CoalesceTimeoutMs
Maximum time in milliseconds between keystrokes for typing coalescing.
Returns: Int64
public long CoalesceTimeoutMs { get; set; }RedoCount
Number of redo groups on the stack.
Returns: Int32
public int RedoCount { get; }UndoCount
Number of undo groups on the stack.
Returns: Int32
public int UndoCount { get; }Methods
BeginGroup(CursorSet, long, string?)
Begin a new explicit edit group. Nested calls increment a counter; only the outermost Commit actually pushes the group.
Parameters:
public void BeginGroup(CursorSet cursors, long documentVersion, string? source = null)CancelGroup()
Cancel the current edit group. Drops all collected operations. The caller is responsible for reverting the document state.
public void CancelGroup()Clear()
Clear all history.
public void Clear()CommitGroup(CursorSet, long)
Commit the current edit group. Only the outermost commit pushes to undo stack.
Parameters:
public void CommitGroup(CursorSet cursors, long documentVersion)RecordEdit(EditOperation, EditOperation, CursorSet, long, long, bool)
Record an edit for potential coalescing with adjacent typing edits. If the edit can be coalesced with the previous group, it is appended. Otherwise, a new group is created.
Parameters:
operation(EditOperation):inverse(EditOperation):cursors(CursorSet):versionBefore(Int64):versionAfter(Int64):coalescable(Boolean):
public void RecordEdit(EditOperation operation, EditOperation inverse, CursorSet cursors, long versionBefore, long versionAfter, bool coalescable = false)Redo()
Redo the last undone edit group. Returns the group for the caller to re-apply operations and restore cursors.
Returns: EditGroup
public EditGroup? Redo()Undo()
Undo the last edit group. Returns the group for the caller to apply inverse operations and restore cursors.
Returns: EditGroup
public EditGroup? Undo()