pub struct Menu<O>where
O: MenuOption,{
pub title: TermString,
pub options: Vec<O>,
pub cancel_label: TermString,
pub title_colors: Color2,
pub arrow_colors: Color2,
pub selected_colors: Color2,
pub unselected_colors: Color2,
pub bg: Color,
pub title_y: Coord,
pub pad_after_title: Coord,
pub pad_after_option: Coord,
}
Expand description
A menu, with a list of options and potentially a cancel option.
Fields§
§title: TermString
The title shown above the menu.
options: Vec<O>
A list of options.
cancel_label: TermString
Label showed by the “CANCEL” button (default “CANCEL”).
title_colors: Color2
Colors for the title.
arrow_colors: Color2
Colors for the arrows.
selected_colors: Color2
Colors for selected options.
unselected_colors: Color2
Colors for unselected options.
bg: Color
Color of the background of no text.
title_y: Coord
Number of lines padded before the title.
pad_after_title: Coord
Number of lines padded after the title.
pad_after_option: Coord
Number of lines padded after an option.
Implementations§
source§impl<O> Menu<O>where
O: MenuOption,
impl<O> Menu<O>where O: MenuOption,
sourcepub fn new(title: TermString, options: Vec<O>) -> Self
pub fn new(title: TermString, options: Vec<O>) -> Self
Creates a new menu with default styles.
sourcepub async fn select(&self, term: &mut Terminal) -> Result<usize, Error>
pub async fn select(&self, term: &mut Terminal) -> Result<usize, Error>
Asks for the user to select an item of the menu without cancel option.
sourcepub async fn select_with_initial(
&self,
term: &mut Terminal,
initial: usize
) -> Result<usize, Error>
pub async fn select_with_initial( &self, term: &mut Terminal, initial: usize ) -> Result<usize, Error>
Asks for the user to select an item of the menu without cancel option, but with a given initial chosen option.
sourcepub async fn select_with_cancel(
&self,
term: &mut Terminal
) -> Result<Option<usize>, Error>
pub async fn select_with_cancel( &self, term: &mut Terminal ) -> Result<Option<usize>, Error>
Asks for the user to select an item of the menu with a cancel option.
sourcepub async fn select_cancel_initial(
&self,
term: &mut Terminal,
initial: usize,
cancel: bool
) -> Result<Option<usize>, Error>
pub async fn select_cancel_initial( &self, term: &mut Terminal, initial: usize, cancel: bool ) -> Result<Option<usize>, Error>
Asks for the user to select an item of the menu with a cancel option, and sets the initial chosen option to the given one, together with a paramter stating whether cancel option is currently chosen.
Trait Implementations§
source§impl<O> PartialEq<Menu<O>> for Menu<O>where
O: MenuOption + PartialEq,
impl<O> PartialEq<Menu<O>> for Menu<O>where O: MenuOption + PartialEq,
impl<O> Eq for Menu<O>where O: MenuOption + Eq,
impl<O> StructuralEq for Menu<O>where O: MenuOption,
impl<O> StructuralPartialEq for Menu<O>where O: MenuOption,
Auto Trait Implementations§
impl<O> RefUnwindSafe for Menu<O>where O: RefUnwindSafe,
impl<O> Send for Menu<O>where O: Send,
impl<O> Sync for Menu<O>where O: Sync,
impl<O> Unpin for Menu<O>where O: Unpin,
impl<O> UnwindSafe for Menu<O>where O: UnwindSafe,
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
source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere T: Any,
source§fn into_any(self: Box<T, Global>) -> Box<dyn Any, Global>
fn into_any(self: Box<T, Global>) -> Box<dyn Any, Global>
Box<dyn Trait>
(where Trait: Downcast
) to Box<dyn Any>
. Box<dyn Any>
can
then be further downcast
into Box<ConcreteType>
where ConcreteType
implements Trait
.source§fn into_any_rc(self: Rc<T, Global>) -> Rc<dyn Any, Global>
fn into_any_rc(self: Rc<T, Global>) -> Rc<dyn Any, Global>
Rc<Trait>
(where Trait: Downcast
) to Rc<Any>
. Rc<Any>
can then be
further downcast
into Rc<ConcreteType>
where ConcreteType
implements Trait
.source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &Any
’s vtable from &Trait
’s.source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &mut Any
’s vtable from &mut Trait
’s.source§impl<Q, K> Equivalent<K> for Qwhere
Q: Eq + ?Sized,
K: Borrow<Q> + ?Sized,
impl<Q, K> Equivalent<K> for Qwhere Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,
source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key
and return true
if they are equal.