//! Front-end events consumed by `update()`.

use crossterm::event::KeyEvent;

/// Events originating from the user or clock.
///
/// Note: there is no `Mouse(...)` variant on purpose. capo does not enable
/// `EnableMouseCapture`, so the terminal keeps ownership of the mouse for
/// native selection / Cmd+C / context menus. Wheel scrolling reaches the
/// transcript as Up/Down key events thanks to DECSET 1007 (alt-scroll),
/// which the alt-screen-aware terminals translate automatically.
#[derive(Debug, Clone)]
pub enum InputEvent {
    Key(KeyEvent),
    Paste(String),
    Resize(u16, u16),
    Tick,
}

/// The union type that `update()` consumes: either user input or an agent-side
/// `UiEvent`.
#[derive(Debug)]
pub enum Event {
    Input(InputEvent),
    Ui(capo_agent::UiEvent),
}

impl From<InputEvent> for Event {
    fn from(e: InputEvent) -> Self {
        Self::Input(e)
    }
}

impl From<capo_agent::UiEvent> for Event {
    fn from(e: capo_agent::UiEvent) -> Self {
        Self::Ui(e)
    }
}
