Module text_edit
Expand description
EditCore — the shared headless text-editing model.
Caret + selection state (byte offsets), the in-progress IME composition,
an optional per-character admission filter, and the motion / edit
vocabulary every editable surface needs, built on the shared
text_selection boundary walkers. Edits come back
as byte-space Edit splices the host applies to its mirror
(Edit::apply) and its Automerge Text (Edit::splice_automerge,
char-addressed). It is deliberately UI-free: no rendering, no CRDT handle.
Every text field uses it: TextInput (and through it every form field,
RichTextLine and BlockEditor), the transient query fields of palettes
and menus (QueryComposition), NameField, and the app-specific
editors. Laid-out geometry — visual/bidi arrow motion, wrapped
Up/Down, Home/End of a soft-wrapped row — stays in the widget, which feeds
the resolved position back through EditCore::motion_to or
EditCore::place_position; the core owns everything logical, which is
exactly what unit tests can pin without a GPU.
TypingRun notes when the user last typed, so a word being typed is
not checked before it settles.
Structs§
- Caret
Word - Debounces the word under the caret: it is settled once the same word
(same text at the same place) has been under a collapsed caret for
SUGGESTION_SETTLE. Typing into the word or moving to another one restarts the wait; moving the caret within the word does not. - Char
Splice - An
Editin Automerge’s char offsets: deleteremovedchars at charat, then insertinsertedchars there. - Edit
- A splice to apply to the buffer, in byte offsets over the pre-edit text:
at..at+removedis replaced byinserted.Edit::applyapplies it to aStringmirror;Edit::splice_automergeto a char-addressed AutomergeText. - Edit
Core - The caret + selection model, the IME composition in progress, and the
field’s admission filter. Selection offsets are bytes into the bound
text (matching
text_selectionand cosmic-text’s byte-indexed layout). - Typing
Run - A burst of typing: every edit
touches the run, and a programmatic replacement of the textcloses it.
Enums§
- Motion
- A caret motion. Vertical motion across wrapped lines is the host’s job
because it needs laid-out line geometry;
Motion::LineUpandMotion::LineDownmove across\n-delimited lines only.
Constants§
- SUGGESTION_
SETTLE - How long the word under the caret must stay the same before a field offers a spelling suggestion for it: a short pause at the end of a word, or the caret coming to rest in a word typed earlier.
Functions§
- delete_
last_ grapheme - Backspace for text typed only at its end (a type-ahead query, a digit entry): remove the last character as a person sees it, never half of a combining sequence or an emoji. Returns whether anything was removed.
- word_
at_ caret - The word the caret is in or just after, as a byte range: letters plus
in-word apostrophes, so
don'tis one word.Nonebetween words.
Type Aliases§
- Char
Filter - A per-character admission rule (for example a spreadsheet cell-reference
box that only takes
[A-Za-z0-9$:]). Applied to every insertion path: typing, paste, IME preedit and commit, programmatic insertion.