Struct tty_form::control::SelectInput
source · pub struct SelectInput { /* private fields */ }Expand description
An option selection field.
Examples
use tty_interface::Style;
use tty_form::{
step::CompoundStep,
control::{Control, SelectInput},
};
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(&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 text(&self) -> (Segment, Option<u16>)
fn text(&self) -> (Segment, Option<u16>)
This control’s rendered contents and an optional offset for the cursor.
sourcefn drawer(&self) -> Option<DrawerContents>
fn drawer(&self) -> Option<DrawerContents>
This control’s drawer contents, if available.
sourcefn evaluation(&self) -> Option<(DependencyId, Evaluation)>
fn evaluation(&self) -> Option<(DependencyId, Evaluation)>
This control’s dependency evaluation which other controls may react to.
sourcefn dependency(&self) -> Option<(DependencyId, Action)>
fn dependency(&self) -> Option<(DependencyId, Action)>
This control’s dependency which it may react to.
sourcefn evaluate(&self, evaluation: &Evaluation) -> bool
fn evaluate(&self, evaluation: &Evaluation) -> bool
Perform an evaluation against this control’s current state.
sourcefn add_to(self, step: &mut CompoundStep)
fn add_to(self, step: &mut CompoundStep)
Finish configuration and add this control to the specified form step.
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