alma 0.1.0

A Bevy-native modal text editor with Vim-style navigation.
Documentation
//! Raw editor input messages.

use crate::vim::KeyToken;
use bevy::prelude::Message;

/// Input normalized away from Bevy platform details.
#[derive(Clone, Debug, Eq, Message, PartialEq)]
pub enum EditorInputEvent {
    /// A key token intended for modal editor interpretation.
    Key(KeyInputEvent),
    /// Printable text intended for prompt or insertion contexts.
    Text(TextInputEvent),
}

impl EditorInputEvent {
    /// Returns whether this event is a synthetic held-key repeat.
    #[must_use]
    pub const fn is_repeated_key(&self) -> bool {
        matches!(self, Self::Key(key) if key.repeated)
    }
}

/// Normalized keyboard input.
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
pub struct KeyInputEvent {
    /// Layout-independent Vim-facing key token.
    pub token: KeyToken,
    /// Whether this key was synthesized by held-key repeat handling.
    pub repeated: bool,
}

/// Printable text input.
#[derive(Clone, Debug, Eq, PartialEq)]
pub struct TextInputEvent {
    /// Text produced by the active input method.
    pub text: String,
}