MenuOptions

Struct MenuOptions 

Source
pub struct MenuOptions { /* private fields */ }
Expand description

Controls and characters that can be configured to change the way the menu acts and displays

§Example

let options = MenuOptions::new()
    .cursor("→")
    .select_key(console::Key::Tab)
    .max_lines_visible(6);

menu!("Only 6 lines are visible!",
    menu_items_list,
    options
    )

Implementations§

Source§

impl MenuOptions

Source

pub fn new() -> Self

Create a new MenuOptions with all the defaults

Source

pub fn cursor(self, cursor: &str) -> Self

Set the user’s row-indicator/cursor to a custom character. The default is: ‘>’

Source

pub fn cursor_width(self, cursor_width: usize) -> Self

Override the space given for the cursor navigation column

Source

pub fn selected_indicator(self, indicator: &str) -> Self

Set the “Item Selected” indicator to a custom character. Defaults is: ‘X’

Source

pub fn selected_indicator_width(self, indicator_width: usize) -> Self

Override the space given for the cursor navigation column

Source

pub fn select_key(self, key: Key) -> Self

Set the key that is used to select an item. The default is: [console::Key::Char(' ')]

Source

pub fn max_lines_visible(self, max_lines: usize) -> Self

Set the maximum number of items that will be displayed at any one time. The default is: 10

Source

pub fn minimum_search_threshold(self, threshold: f32) -> Self

Set the degree of “fuzziness” that it will match too. Higher numbers will return more results, but less accurate ones. Has to be 1.0 >= x >= 0 or will panic The default is: 0.005

Set if ‘selected’ rows are still shown during searches they aren’t results for The default is: true

Source

pub fn only_one_selection(self, only_one: bool) -> Self

Set if the menu should exit and return only the first user selection. The default is: false

Source

pub fn clear_on_close(self, do_clear: bool) -> Self

Set if the menu should delete any left-over lines from the terminal. The default is: true

Trait Implementations§

Source§

impl Clone for MenuOptions

Source§

fn clone(&self) -> MenuOptions

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for MenuOptions

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for MenuOptions

Source§

fn default() -> Self

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

impl PartialEq for MenuOptions

Source§

fn eq(&self, other: &MenuOptions) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl StructuralPartialEq for MenuOptions

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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.