diff --git a/term/src/input.rs b/term/src/input.rs new file mode 100644 index 000000000..864e2bb12 --- /dev/null +++ b/term/src/input.rs @@ -0,0 +1,59 @@ +use super::VisibleRowIndex; + +bitflags! { + #[derive(Default)] + pub struct KeyModifiers :u8{ + const CTRL = 1; + const ALT = 2; + const META = 4; + const SUPER = 8; + const SHIFT = 16; + } +} + +#[derive(Debug, Copy, Clone, PartialEq, Eq)] +pub enum KeyCode { + Char(char), + Unknown, + Control, + Alt, + Meta, + Super, + Hyper, + Shift, + Left, + Up, + Right, + Down, + PageUp, + PageDown, + Home, + End, + Insert, +} + +#[derive(Debug, Copy, Clone, PartialEq, Eq)] +pub enum MouseButton { + Left, + Middle, + Right, + WheelUp, + WheelDown, + None, +} + +#[derive(Debug, Copy, Clone, PartialEq, Eq)] +pub enum MouseEventKind { + Press, + Release, + Move, +} + +#[derive(Debug, Copy, Clone, PartialEq, Eq)] +pub struct MouseEvent { + pub kind: MouseEventKind, + pub x: usize, + pub y: VisibleRowIndex, + pub button: MouseButton, + pub modifiers: KeyModifiers, +} diff --git a/term/src/lib.rs b/term/src/lib.rs index fa3f05c90..155e8bacd 100644 --- a/term/src/lib.rs +++ b/term/src/lib.rs @@ -26,6 +26,9 @@ use std::time::{Duration, Instant}; #[macro_use] mod debug; +pub mod input; +pub use input::*; + pub mod selection; use selection::{SelectionCoordinate, SelectionRange}; @@ -103,64 +106,6 @@ pub const ST: &[u8] = b"\x1b\\"; #[allow(dead_code)] pub const DCS: &[u8] = b"\x1bP"; -bitflags! { - #[derive(Default)] - pub struct KeyModifiers :u8{ - const CTRL = 1; - const ALT = 2; - const META = 4; - const SUPER = 8; - const SHIFT = 16; - } -} - -#[derive(Debug, Copy, Clone, PartialEq, Eq)] -pub enum KeyCode { - Char(char), - Unknown, - Control, - Alt, - Meta, - Super, - Hyper, - Shift, - Left, - Up, - Right, - Down, - PageUp, - PageDown, - Home, - End, - Insert, -} - -#[derive(Debug, Copy, Clone, PartialEq, Eq)] -pub enum MouseButton { - Left, - Middle, - Right, - WheelUp, - WheelDown, - None, -} - -#[derive(Debug, Copy, Clone, PartialEq, Eq)] -pub enum MouseEventKind { - Press, - Release, - Move, -} - -#[derive(Debug, Copy, Clone, PartialEq, Eq)] -pub struct MouseEvent { - pub kind: MouseEventKind, - pub x: usize, - pub y: VisibleRowIndex, - pub button: MouseButton, - pub modifiers: KeyModifiers, -} - #[derive(Debug, Clone, Eq, PartialEq)] pub struct CellAttributes { attributes: u16,