ailloli_ui_runtime/input/text_edit.rs
1//! Compatibility text-selection and editing command values.
2
3/// Runtime alias for a UTF-8 byte anchor/caret selection.
4///
5/// # Examples
6///
7/// ```
8/// use ailloli_ui_runtime::input::Selection;
9/// let selection = Selection::collapsed(3);
10/// assert_eq!(selection.normalized(), (3, 3));
11/// ```
12pub type Selection = ailloli_ui_text::TextSelection;
13
14/// Legacy backend-neutral editing command.
15///
16/// The enum carries intent only and performs no mutation by itself. New editing
17/// integrations can use `ailloli_ui_text::TextEditAction` for grapheme-, IME-,
18/// undo-, and clipboard-aware behavior.
19///
20/// # Examples
21///
22/// ```
23/// use ailloli_ui_runtime::input::EditCmd;
24/// assert_eq!(EditCmd::InsertText { text: "x".into() }, EditCmd::InsertText { text: "x".into() });
25/// ```
26#[derive(Debug, Clone, PartialEq)]
27pub enum EditCmd {
28 /// Insert the exact owned UTF-8 payload.
29 ///
30 /// Interpretation of newlines and empty strings belongs to the consumer.
31 InsertText {
32 /// Exact UTF-8 text to insert; an empty string is retained as supplied.
33 text: String,
34 },
35 /// Delete before the caret using the consumer's boundary policy.
36 DeleteBackward,
37 /// Delete after the caret using the consumer's boundary policy.
38 DeleteForward,
39 /// Move left using the consumer's character/grapheme policy.
40 MoveCaretLeft,
41 /// Move right using the consumer's character/grapheme policy.
42 MoveCaretRight,
43 /// Select the consumer's complete editable range.
44 SelectAll,
45 /// Install an explicit, otherwise unvalidated byte selection.
46 SetSelection {
47 /// Anchor and focus byte offsets interpreted by the consumer.
48 selection: Selection,
49 },
50}