ratatui_eventInput/
lib.rs#[cfg(feature = "crossterm")]
mod crossterm;
#[cfg(feature = "termion")]
mod termion;
#[cfg(feature = "termwiz")]
mod termwiz;
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
pub struct Input {
pub key: Key,
pub modifier: Modifier,
}
impl Input {
pub fn new(key: Key, modifier: Modifier) -> Input {
Input { key, modifier }
}
pub fn new_key(key: Key) -> Input {
Input {
key,
modifier: Modifier::None,
}
}
pub fn keys(keys: &[Key]) -> Vec<Input> {
keys.iter().map(|key| Self::new_key(*key)).collect()
}
pub fn with_key(&mut self, key: Key) -> &mut Self {
self.key = key;
self
}
pub fn with_modifier(&mut self, modifier: Modifier) -> &mut Self {
self.modifier = modifier;
self
}
}
impl Default for Input {
fn default() -> Self {
Self {
key: Key::None,
modifier: Modifier::None,
}
}
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
pub enum Key {
Up,
Down,
Left,
Right,
Char(char),
Esc,
Backspace,
Enter,
Tab,
CapsLock,
Home,
End,
PageUp,
PageDown,
Delete,
Insert,
Func(u8),
ScrollLock,
NumLock,
PrintScreen,
Pause,
Menu,
BackTab,
MediaPlay,
MediaPause,
MediaPlayPause,
MediaStop,
MediaNext,
MediaPrevious,
RaisVolume,
LowerVolume,
MuteVolume,
Modifier(Modifier),
None,
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
pub enum Modifier {
Shift(Side),
Control(Side),
Alt(Side),
Super(Side),
Meta(Side),
Hyper(Side),
None,
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
pub enum Side {
Left,
Right,
}