termit-ui 0.0.1

Terminal UI with GUI-like layouts
Documentation
use crate::geometry::*;

#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub enum GrinInput {
    Resize(Point),
    Key(KeyEvent),
    Mouse(MouseEvent),
    Raw(Vec<u8>),
}

/// A mouse related event.
#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
pub struct MouseEvent {
    pub position: Point,
    pub action: MouseAction,
}

/// A mouse button.
#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
pub enum MouseAction {
    /// A mouse left button was pressed.
    PressLeft,
    /// A mouse right button was pressed.
    PressRight,
    /// A mouse right button was pressed.
    PressMiddle,
    /// A mouse button was released.
    Release,
    /// A mouse button is held over the given coordinates.
    Drag,
    /// Mouse wheel is going up.
    WheelUp,
    /// Mouse wheel is going down.
    WheelDown,
}

#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
pub struct KeyEvent {
    pub key: Key,
    pub ctrl: bool,
    pub alt: bool,
}

/// A key.
#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
pub enum Key {
    /// Backspace.
    Backspace,
    /// Left arrow.
    Left,
    /// Right arrow.
    Right,
    /// Up arrow.
    Up,
    /// Down arrow.
    Down,
    /// Home key.
    Home,
    /// End key.
    End,
    /// Page Up key.
    PageUp,
    /// Page Down key.
    PageDown,
    /// Delete key.
    Delete,
    /// Insert key.
    Insert,
    /// Function keys.
    ///
    /// Only function keys 1 through 12 are supported.
    F(u8),
    /// Normal character.
    Char(char),
    /// Null byte.
    Null,
    /// Esc key.
    Esc,
    /// Unknown key
    Other(u8),
}