Skip to main content

Module edit

Module edit 

Source
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§

TextEditPlugin
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 to range.start, and record an undo entry. See insert_text for the visibility rationale.
insert_text
Insert text at at_byte (must be a char boundary; producers clamp via TextPos::from_byte), moving caret + anchor past the insertion and recording an undo entry. Public so lumen-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::Insert from a string. Inserts at the cursor head by resolving inside the mutator.
move_cursor
Resolve a CursorMotion from from against 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 (Qt verticalMovementX, 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 range with text, landing the caret after the replacement and recording a single undo entry. See insert_text for the visibility rationale.
text_apply_edits
The single text mutator (W3.2). Drains lumen_core::text_events::TextEditRequest and mutates TextBuffer / TextCursor / UndoStack / ImePreedit in place. Emits TextEditApplied after each accepted edit and TextEditRejected for validator / single-line newline / undo-empty rejections.
text_attach_buffer
Bootstrap. For every TextInput entity without a TextBuffer, attach TextBuffer (seeded from TextContent), TextCursor (seeded from TextInput.cursor), an empty UndoStack, and the TextEditable marker. 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 TextContent so the existing renderer / apply_text_bindings push 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_focused path mutates TextContent directly (the bd23f51 surgical fix), reflect those changes back into TextBuffer so the W3 model stays in sync. Runs AFTER the legacy keystroke path and BEFORE shaping/render.