Struct tui_textarea::Input
source · pub struct Input {
pub key: Key,
pub ctrl: bool,
pub alt: bool,
}Expand description
Backend-agnostic key input type.
When crossterm and/or termion features are enabled, converting their key input types into this Input type is defined.
use tui_textarea::{TextArea, Input, Key};
use crossterm::event::{Event, read};
let event = read().unwrap();
// `Input::from` can convert backend-native event into `Input`
let input = Input::from(event.clone());
// or `Into::into`
let input: Input = event.clone().into();
// Conversion from `KeyEvent` value is also available
if let Event::Key(key) = event {
let input = Input::from(key);
}Creating Input instance directly can cause backend-agnostic input as follows.
use tui_textarea::{TextArea, Input, Key};
let mut textarea = TextArea::default();
// Input Ctrl+A
textarea.input(Input {
key: Key::Char('a'),
ctrl: true,
alt: false,
});Fields§
§key: KeyTyped key.
ctrl: boolCtrl modifier key. true means Ctrl key was pressed.
alt: boolAlt modifier key. true means Alt key was pressed.
Trait Implementations§
source§impl From<Event> for Input
impl From<Event> for Input
source§fn from(event: CrosstermEvent) -> Self
fn from(event: CrosstermEvent) -> Self
Convert crossterm::event::Event to Input.
source§impl From<MouseEvent> for Input
impl From<MouseEvent> for Input
source§fn from(mouse: CrosstermMouseEvent) -> Self
fn from(mouse: CrosstermMouseEvent) -> Self
Convert crossterm::event::MouseEvent to Input.
Auto Trait Implementations§
impl RefUnwindSafe for Input
impl Send for Input
impl Sync for Input
impl Unpin for Input
impl UnwindSafe for Input
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more