Skip to main content

Module text

Module text 

Source
Available on crate feature ui only.
Expand description

Interactive text editing state.

text


TextInput models one-line UTF-8 editing over caller-chosen storage. It keeps the initialized length, cursor position, and TextInputConfig, while its storage type determines ownership and capacity.

EventKey ── TextInputKeymap ──> TextInputAction
                                     │
                                     ▼ apply
TextInput<B> ─────────────────> TextInputOutcome
     │                               └── Rejected(TextInputReject)
     └── borrow ──────────────> TextInputView

TextInputAction expresses storage-independent editing requests. Applying one produces a TextInputOutcome that distinguishes unchanged state, mutation, acceptance, cancellation, and rejection.

TextInputView exposes the initialized text and cursor without exposing its storage representation. The cursor is a byte position on a UTF-8 boundary; character movement and deletion operate on Unicode scalar boundaries.

When event support is enabled, TextInputKeymap translates normalized keyboard events into editing actions. Key mapping remains separate from the editing state itself.

§Boundaries

This module owns editable text state and its explicit transitions.

  • General encoding, segmentation, and text processing belong to text.
  • Normalized keyboard events come from ui::event.
  • Keyboard focus and interaction ownership belong to ui::route.
  • Control composition and presentation belong to ui::widget and ui::view.

It does not define focus acquisition, selection, composition, multiline layout, or rendering.

Structs§

TextInput
𝐓 One-line editable text state over caller-chosen storage.
TextInputConfig
𝐓 Configuration for TextInput.
TextInputKeymapevent
𝐓 🎫 Maps platform-agnostic keyboard events to text input actions.
TextInputView
𝐓 Borrowed view of a text input.

Enums§

TextInputAction
𝐓 🎮 Editing command consumed by TextInput.
TextInputKeymapPresetevent
𝐓 🎫 Preset key mapping for TextInputAction.
TextInputOutcome
𝐓 ⚖️ Result of applying a TextInputAction.
TextInputReject
𝐓 Reason why an action was rejected.