ailloli_ui_editor/input/
edit_action.rs

1//! Adapter-neutral aggregation of lower-level text edit outcomes.
2
3use ailloli_ui_text::TextEditOutcome;
4
5/// Aggregate result returned by editor input helpers.
6///
7/// `clipboard_write = Some("")` requests writing an empty clipboard string and
8/// differs from `None`. `clipboard_read` requests a later host read.
9///
10/// # Examples
11///
12/// ```
13/// use ailloli_ui_editor::EditorInputOutcome;
14/// let outcome = EditorInputOutcome::default();
15/// assert!(!outcome.text_changed && !outcome.state_changed);
16/// assert_eq!(outcome.clipboard_write, None);
17/// assert!(!outcome.clipboard_read);
18/// ```
19#[derive(Debug, Clone, Default, PartialEq, Eq)]
20pub struct EditorInputOutcome {
21    /// Whether buffer bytes changed.
22    pub text_changed: bool,
23    /// Whether selection, caret, composition, or another edit state changed.
24    pub state_changed: bool,
25    /// Exact text to write, or `None` for no clipboard write request.
26    pub clipboard_write: Option<String>,
27    /// Whether the host should read clipboard text for a pending paste.
28    pub clipboard_read: bool,
29}
30
31/// Preserves every field from the lower-level text-edit outcome.
32impl From<TextEditOutcome> for EditorInputOutcome {
33    /// Converts without merging or clearing clipboard requests.
34    fn from(value: TextEditOutcome) -> Self {
35        Self {
36            text_changed: value.text_changed,
37            state_changed: value.state_changed,
38            clipboard_write: value.clipboard_write,
39            clipboard_read: value.clipboard_read,
40        }
41    }
42}