Skip to main content

Module changeset

Module changeset 

Source
Expand description

Text editing changeset system

STATUS: The core types (TextChangeset, TextOperation, TextOp* structs) are actively used by window.rs, undo_redo.rs, event.rs, and platform code.

The live copy/cut/select-all/delete paths run through common/event.rs (SystemChange::CopyToClipboard/CutToClipboard, CallbackChange::SetSelectAllRange, LayoutWindow::delete_selection), not through changeset constructors. The earlier create_*_changeset helpers were a never-wired parallel implementation (with placeholder deleted_text, CursorPosition::Uninitialized cursors, and byte±1 UTF-8 deletion) and have been removed.

§Architecture

This module implements a two-phase changeset system for all text editing operations:

  1. Create changesets (pre-callback): Analyze what would change, don’t mutate yet
  2. Apply changesets (post-callback): Actually mutate state if !preventDefault

This pattern enables:

  • preventDefault support for ALL operations (not just text input)
  • Undo/redo stack (record changesets before applying)
  • Validation (check bounds, permissions before mutation)
  • Inspection (user callbacks can see planned changes)

Structs§

TextChangeset
A text editing changeset that can be inspected before application
TextOpClearSelection
Clear all selections
TextOpCopy
Copy selection to clipboard (no text change)
TextOpCut
Cut selection to clipboard (deletes text)
TextOpDeleteText
Delete text in range
TextOpExtendSelection
Extend selection in a direction
TextOpInsertText
Insert text at cursor position
TextOpMoveCursor
Move cursor to new position
TextOpPaste
Paste from clipboard (inserts text)
TextOpReplaceText
Replace text in range with new text
TextOpSelectAll
Select all text in node
TextOpSetSelection
Set selection to new range

Enums§

CursorMovement
Type of cursor movement
SelectionDirection
Re-export from events module Direction of cursor movement or selection expansion.
TextOperation
Text editing operation (what will change)

Type Aliases§

ChangesetId
Unique identifier for a changeset (for undo/redo)