Expand description
W3.2-W3.4: Lumen text-editing systems.
Single-mutator architecture. Every text mutation (keyboard, IME,
script, paste, undo, pointer drag) flows through
lumen_core::text_events::TextEditRequest; the single
text_apply_edits system in this crate is the only place that
mutates lumen_core::text_model::TextBuffer.
Coexistence strategy. The existing TextContent + TextInput model
(bd23f51 surgical fix) keeps working unchanged through the W3
rollout: text_attach_buffer adds a TextBuffer / TextCursor
/ UndoStack alongside every TextInput, and
text_mirror_buffer_to_content writes the rope back into
TextContent after each edit so the existing renderer / binding
systems keep reading the same shape.
See docs/audits/text-editing.md:172-275 for the rewrite spec.
Structs§
- Text
Edit Plugin - Plugin that wires the text-edit systems.
Functions§
- caret_
blink - Caret blink driver (W2 Qt-polish: text-editing core).
- delete_
range - Delete the byte
range(char-boundary clamped by callers), collapse the caret torange.start, and record an undo entry. Seeinsert_textfor the visibility rationale. - insert_
text - Insert
textatat_byte(must be a char boundary; producers clamp viaTextPos::from_byte), moving caret + anchor past the insertion and recording an undo entry. Public solumen-input’s keystroke router can mutate the buffer through the same single implementation the request mutator uses. - make_
insert - Helper used by producers: build a
TextEditRequest::Insertfrom a string. Inserts at the cursor head by resolving inside the mutator. - move_
cursor - Resolve a
CursorMotionfromfromagainst the buffer contents. Line motions step logical (\n-delimited) lines with byte-column preservation. Public so the keystroke router shares one motion implementation with the request mutator. - move_
cursor_ visual - D6: resolve a soft-wrap-aware vertical / line-bound motion against shaped
TextGeometry. Returns(new head, new goal_x): the goal x to store back on the cursor (QtverticalMovementX, D5). - next_
grapheme_ boundary - Next extended grapheme cluster boundary after
from. - prev_
code_ point_ boundary - Previous code point boundary before
from. - prev_
grapheme_ boundary - Previous extended grapheme cluster boundary before
from. - replace_
range - Replace the byte
rangewithtext, landing the caret after the replacement and recording a single undo entry. Seeinsert_textfor the visibility rationale. - text_
apply_ edits - The single text mutator (W3.2). Drains
lumen_core::text_events::TextEditRequestand mutatesTextBuffer/TextCursor/UndoStack/ImePreeditin place. EmitsTextEditAppliedafter each accepted edit andTextEditRejectedfor validator / single-line newline / undo-empty rejections. - text_
attach_ buffer - Bootstrap. For every
TextInputentity without aTextBuffer, attachTextBuffer(seeded fromTextContent),TextCursor(seeded fromTextInput.cursor), an emptyUndoStack, and theTextEditablemarker. Idempotent - runs every tick at near-zero cost when nothing new is spawned. - text_
mirror_ buffer_ to_ content - Mirror system. After every successful edit, write the rope back into
TextContentso the existing renderer /apply_text_bindingspush path keeps reading the same shape. Also writes the byte cursor back into [TextInput.cursor] for legacy keystroke routes. - text_
reflect_ content_ to_ buffer - Pre-keystroke gate. When the existing
route_ime_events/type_into_focusedpath mutatesTextContentdirectly (the bd23f51 surgical fix), reflect those changes back intoTextBufferso the W3 model stays in sync. Runs AFTER the legacy keystroke path and BEFORE shaping/render.