Skip to main content

Select

Struct Select 

Source
pub struct Select<T: Clone + PartialEq + Send + Sync + 'static> { /* private fields */ }
Expand description

A select field for choosing one option from a list.

Implementations§

Source§

impl<T: Clone + PartialEq + Send + Sync + Default + 'static> Select<T>

Source

pub fn new() -> Self

Creates a new select field.

Source

pub fn key(self, key: impl Into<String>) -> Self

Sets the field key.

Source

pub fn options(self, options: Vec<SelectOption<T>>) -> Self

Sets the options.

Source

pub fn title(self, title: impl Into<String>) -> Self

Sets the title.

Source

pub fn description(self, description: impl Into<String>) -> Self

Sets the description.

Source

pub fn inline(self, inline: bool) -> Self

Sets whether options display inline.

Source

pub fn validate(self, validate: fn(&T) -> Option<String>) -> Self

Sets the validation function.

Source

pub fn height_options(self, height: usize) -> Self

Sets the visible height (number of options shown).

Source

pub fn filterable(self, enabled: bool) -> Self

Enables or disables type-to-filter support.

When filtering is enabled, typing characters will filter the visible options. Navigation keys (j/k/g/G) still work for movement. Press Escape to clear the filter, Backspace to delete the last character.

Source

pub fn get_selected_value(&self) -> Option<&T>

Gets the currently selected value.

Source

pub fn id(&self) -> usize

Returns the field ID.

Trait Implementations§

Source§

impl<T: Clone + PartialEq + Send + Sync + Default + 'static> Default for Select<T>

Source§

fn default() -> Self

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

impl<T: Clone + PartialEq + Send + Sync + Default + 'static> Field for Select<T>

Source§

fn get_key(&self) -> &str

Returns the field’s key.
Source§

fn get_value(&self) -> Box<dyn Any>

Returns the field’s value.
Source§

fn error(&self) -> Option<&str>

Returns the current validation error, if any.
Source§

fn init(&mut self) -> Option<Cmd>

Initializes the field.
Source§

fn update(&mut self, msg: &Message) -> Option<Cmd>

Updates the field with a message.
Source§

fn view(&self) -> String

Renders the field.
Source§

fn focus(&mut self) -> Option<Cmd>

Focuses the field.
Source§

fn blur(&mut self) -> Option<Cmd>

Blurs the field.
Source§

fn key_binds(&self) -> Vec<Binding>

Returns the help keybindings.
Source§

fn with_theme(&mut self, theme: &Theme)

Sets the theme.
Source§

fn with_keymap(&mut self, keymap: &KeyMap)

Sets the keymap.
Source§

fn with_width(&mut self, width: usize)

Sets the width.
Source§

fn with_height(&mut self, height: usize)

Sets the height.
Source§

fn with_position(&mut self, position: FieldPosition)

Sets the field position.
Source§

fn skip(&self) -> bool

Returns whether this field should be skipped.
Source§

fn zoom(&self) -> bool

Returns whether this field should zoom (take full height).

Auto Trait Implementations§

§

impl<T> Freeze for Select<T>

§

impl<T> !RefUnwindSafe for Select<T>

§

impl<T> Send for Select<T>

§

impl<T> Sync for Select<T>

§

impl<T> Unpin for Select<T>
where T: Unpin,

§

impl<T> !UnwindSafe for Select<T>

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> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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, 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.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more