Struct ratatui_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 ratatui_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 ratatui_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: Key
Typed key.
ctrl: bool
Ctrl modifier key. true
means Ctrl key was pressed.
alt: bool
Alt modifier key. true
means Alt key was pressed.
Trait Implementations§
source§impl<'arbitrary> Arbitrary<'arbitrary> for Input
impl<'arbitrary> Arbitrary<'arbitrary> for Input
source§fn arbitrary(u: &mut Unstructured<'arbitrary>) -> Result<Self>
fn arbitrary(u: &mut Unstructured<'arbitrary>) -> Result<Self>
Generate an arbitrary value of
Self
from the given unstructured data. Read moresource§fn arbitrary_take_rest(u: Unstructured<'arbitrary>) -> Result<Self>
fn arbitrary_take_rest(u: Unstructured<'arbitrary>) -> Result<Self>
Generate an arbitrary value of
Self
from the entirety of the given
unstructured data. Read moresource§impl From<Event> for Input
impl From<Event> for Input
source§fn from(event: TermionEvent) -> Self
fn from(event: TermionEvent) -> Self
Convert termion::event::Event
to Input
.
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<Key> for Input
impl From<Key> for Input
source§fn from(key: TermionKey) -> Self
fn from(key: TermionKey) -> Self
Convert termion::event::Key
to Input
.
source§impl From<MouseEvent> for Input
impl From<MouseEvent> for Input
source§fn from(mouse: TermionMouseEvent) -> Self
fn from(mouse: TermionMouseEvent) -> Self
Convert termion::event::MouseEvent
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