Skip to main content

Module text_model

Module text_model 

Source
Expand description

W3.1: rope-backed text model components.

These components REPLACE the byte-offset TextInput.cursor model for the W3 rewrite, but coexist with the existing TextContent / TextInput pair so the bd23f51 surgical fix keeps working through the rewrite landing.

Component layering:

  • TextContent (existing) - rendered text for non-editable labels.
  • TextBuffer (new) - rope-backed authoritative text for editable entities (<input> / <textarea>). Mirrored into TextContent after each edit so the existing renderer / binding path keeps working unchanged.
  • TextCursor (new) - caret + selection anchor + affinity. Supplants the byte-offset fields on TextInput; the mirror system also writes the byte offset back into TextInput.cursor for legacy code paths (W3 stage; later waves remove the legacy fields).
  • ImePreedit (new) - replaces ImeState; carries the in-progress composition string plus the caret position inside it.

The From/Into impls follow the project-memory rule: convert between types via trait impls, never bespoke convert_x_to_y helpers.

Structs§

ImePreedit
IME preedit (composition) state on a focused editable. Replaces the pre-W3 ImeState for entities with a TextBuffer; the legacy ImeState stays for backwards compatibility with the old TextInput path until the W3 migration completes.
MarkId
Stable identifier for a TextMark. Marks survive edits.
TextBuffer
Rope-backed authoritative text buffer for editable entities (W3.1).
TextCursor
Caret + selection state on an editable entity (W3.1).
TextEditable
Marker: this entity is editable text (W3.1).
TextMark
A point inside a TextBuffer that survives edits (GTK’s GtkTextMark). The text_apply_edits mutator shifts marks during insert/delete according to Self::bias.
TextPos
Position inside a TextBuffer; carries both byte (for slicing) and grapheme (for cursor display) axes.
TextTagRange
A tagged byte range inside a TextBuffer; survives edits via two TextMarks at the endpoints.

Enums§

Affinity
Caret behaviour at line-wrap boundaries (Qt’s Affinity).
Bias
Insertion-at-mark bias (Qt’s QTextCursor::MoveMode::KeepAnchor for marks): when an insertion lands AT a mark’s byte position, should the mark stay before (Backward) or after (Forward) the new text?
TagKind
Tag flavours carried by TextTagRange.
TextBufferKind
Single-line vs multi-line policy for TextBuffer.