CommandInputState

Struct CommandInputState 

Source
pub struct CommandInputState { /* private fields */ }

Implementations§

Source§

impl CommandInputState

Source

pub fn add_char(&mut self, c: char)

Examples found in repository?
examples/command/main.rs (line 50)
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}
Source

pub fn del_char(&mut self)

Examples found in repository?
examples/command/main.rs (line 35)
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}
Source

pub fn reset(&mut self)

Source

pub fn enter(&mut self) -> String

Source

pub fn back_in_history(&mut self)

Source

pub fn forward_in_history(&mut self)

Trait Implementations§

Source§

impl Default for CommandInputState

Source§

fn default() -> CommandInputState

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.