Struct tty_form::SelectInput
source · [−]pub struct SelectInput { /* private fields */ }Expand description
An option selection field.
Examples
use tty_form::{CompoundStep, Control, SelectInput};
use tty_interface::Style;
let mut step = CompoundStep::new();
SelectInput::new("Select favorite food:", vec![
("Pizza", "A supreme pizza."),
("Burgers", "A hamburger with cheese."),
("Fries", "Simple potato french-fries."),
]).add_to_step(&mut step);Implementations
sourceimpl SelectInput
impl SelectInput
sourcepub fn new(prompt: &str, options: Vec<(&str, &str)>) -> Self
pub fn new(prompt: &str, options: Vec<(&str, &str)>) -> Self
Create a new option-selection input with the specified prompt and options.
sourcepub fn set_prompt(&mut self, prompt: &str)
pub fn set_prompt(&mut self, prompt: &str)
Update this input’s prompt text.
sourcepub fn add_option(&mut self, option: SelectInputOption)
pub fn add_option(&mut self, option: SelectInputOption)
Add an option to this input’s list.
sourcepub fn set_options(&mut self, options: Vec<SelectInputOption>)
pub fn set_options(&mut self, options: Vec<SelectInputOption>)
Set this input’s options.
Trait Implementations
sourceimpl Control for SelectInput
impl Control for SelectInput
sourcefn is_focusable(&self) -> bool
fn is_focusable(&self) -> bool
Whether this control is a focusable input.
sourcefn handle_input(&mut self, key_event: KeyEvent)
fn handle_input(&mut self, key_event: KeyEvent)
Updates the control’s state from the given input event.
sourcefn get_drawer(&self) -> Option<Vec<String>>
fn get_drawer(&self) -> Option<Vec<String>>
Get this control’s drawer contents, if available.
sourcefn add_to_step(self, step: &mut CompoundStep)
fn add_to_step(self, step: &mut CompoundStep)
Finish configuration and add this control to the specified form step.
sourceimpl Default for SelectInput
impl Default for SelectInput
Auto Trait Implementations
impl RefUnwindSafe for SelectInput
impl Send for SelectInput
impl Sync for SelectInput
impl Unpin for SelectInput
impl UnwindSafe for SelectInput
Blanket Implementations
sourceimpl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more