Struct youchoose::Menu [−][src]
Expand description
A Menu that lazily displays an iterable and (optionally) its preview.
Implementations
impl<'a, I, D> Menu<'a, I, D> where
D: Display,
I: Iterator<Item = D>,
[src]
impl<'a, I, D> Menu<'a, I, D> where
D: Display,
I: Iterator<Item = D>,
[src]pub fn new(iter: I) -> Menu<'a, I, D>
[src]
pub fn new(iter: I) -> Menu<'a, I, D>
[src]Create a new menu object. The iterable passed in must contain displayable items.
pub fn preview<F>(self, func: F) -> Menu<'a, I, D> where
F: Fn(D) -> String + 'static,
[src]
pub fn preview<F>(self, func: F) -> Menu<'a, I, D> where
F: Fn(D) -> String + 'static,
[src]Add a preview pane that displays the result of applying the function passed in to each item in the iterable. The function must return a String.
pub fn preview_pos(self, side: ScreenSide, width: f64) -> Menu<'a, I, D>
[src]
pub fn preview_pos(self, side: ScreenSide, width: f64) -> Menu<'a, I, D>
[src]Sets the position of the preview pane. The side
parameter determines
the side on which the pane sits. The width
parameter is a float between
0.0
and 1.0
, inclusive. It determines the proportion of the screen that
the preview pane should use.
The menu’s side is automatically switched to opposite the preview pane’s side,
and the menu’s width is set to 1 - width
.
pub fn icon(self, icon: &'a str) -> Menu<'a, I, D>
[src]
pub fn icon(self, icon: &'a str) -> Menu<'a, I, D>
[src]Sets the default icon of the menu. This is displayed before each entry.
pub fn selected_icon(self, icon: &'a str) -> Menu<'a, I, D>
[src]
pub fn selected_icon(self, icon: &'a str) -> Menu<'a, I, D>
[src]Sets the icon displayed when an item is selected in multiselect mode.
pub fn preview_label(self, label: String) -> Menu<'a, I, D>
[src]
pub fn preview_label(self, label: String) -> Menu<'a, I, D>
[src]Sets the text displayed on top of the preview box. It is recommended to surround the label
with spaces for aesthetic reasons. If it is not set, " preview "
will be used.
pub fn add_multiselect_key(self, key: i32) -> Menu<'a, I, D>
[src]
pub fn add_multiselect_key(self, key: i32) -> Menu<'a, I, D>
[src]Adds a keybinding that triggers a multiselection. This inputs an ncurses
keycode.
All ascii keys can be set by passing the character as an i32
. The keycodes for
special keys can be found by importing ncurses
and using the provided constants
or by testing with the getch
function. For example, running the following will display
the keycodes on the screen.
// Make sure to add ncurses as a dependency! use ncurses::*; fn main() { initscr(); loop { let c: i32 = getch(); clear(); if c == 'q' as i32 {break} addstr(&format!("Pressed key with keycode {}!", c.to_string())); } endwin(); }
pub fn add_up_key(self, key: i32) -> Menu<'a, I, D>
[src]
pub fn add_up_key(self, key: i32) -> Menu<'a, I, D>
[src]Adds a keybinding that triggers an up movement. See add_multiselect_key
for more information.
pub fn add_down_key(self, key: i32) -> Menu<'a, I, D>
[src]
pub fn add_down_key(self, key: i32) -> Menu<'a, I, D>
[src]Adds a keybinding that triggers a down movement. See add_multiselect_key
for more information.
pub fn add_select_key(self, key: i32) -> Menu<'a, I, D>
[src]
pub fn add_select_key(self, key: i32) -> Menu<'a, I, D>
[src]Adds a keybinding that triggers a selection. See add_multiselect_key
for more information.
pub fn multiselect(self) -> Menu<'a, I, D>
[src]
pub fn multiselect(self) -> Menu<'a, I, D>
[src]Allow multiple items to be selected from the menu.
Auto Trait Implementations
impl<'a, I, D> !RefUnwindSafe for Menu<'a, I, D>
impl<'a, I, D> !Send for Menu<'a, I, D>
impl<'a, I, D> !Sync for Menu<'a, I, D>
impl<'a, I, D> Unpin for Menu<'a, I, D> where
D: Unpin,
I: Unpin,
D: Unpin,
I: Unpin,