pub struct Events { /* private fields */ }Expand description
Helper struct to read from crossterm’s input events
Implementations§
Source§impl Events
impl Events
Sourcepub fn from_config(config: Config) -> Events
pub fn from_config(config: Config) -> Events
Creates an Events instance from Config and starts a thread to listen on crossterm input events
Sourcepub fn next(&self) -> Result<Option<Event>, RecvError>
pub fn next(&self) -> Result<Option<Event>, RecvError>
Checks if there was a new event to read from.
Returns Some(Event) if there was some, None if not and Result::Err if the connection was disconnected.
Examples found in repository?
examples/command/main.rs (line 32)
31fn handle_input(tui: &mut TuiClap, events: &Events) {
32 if let Ok(Some(Event::Key(key_event))) = events.next() {
33 match key_event.code {
34 KeyCode::Backspace => {
35 tui.state().del_char()
36 }
37 KeyCode::Enter => {
38 if let Ok(matches) = tui.parse() {
39 match handle_matches(matches) {
40 Ok(output) => {
41 for message in output {
42 tui.write_to_output(message)
43 }
44 }
45 Err(err) => tui.write_to_output(err)
46 }
47 }
48 }
49 KeyCode::Char(char) => {
50 tui.state().add_char(char)
51 },
52 _ => {}
53 }
54 }
55}pub fn disable_exit_key(&mut self)
pub fn enable_exit_key(&mut self)
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Events
impl RefUnwindSafe for Events
impl Send for Events
impl !Sync for Events
impl Unpin for Events
impl UnwindSafe for Events
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