Skip to main content

DefaultDelegate

Struct DefaultDelegate 

Source
pub struct DefaultDelegate {
    pub show_description: bool,
    pub styles: DefaultItemStyles,
    pub update_func: Option<Box<dyn Fn(&dyn Msg, &Model) -> Cmd + Send + Sync>>,
    pub short_help_func: Option<Box<dyn Fn() -> Vec<Binding> + Send + Sync>>,
    pub full_help_func: Option<Box<dyn Fn() -> Vec<Vec<Binding>> + Send + Sync>>,
    /* private fields */
}
Expand description

DefaultDelegate is a standard delegate designed to work in lists. It’s styled by DefaultItemStyles, which can be customized as you like.

The description line can be hidden by setting show_description to false, which renders the list as single-line-items. The spacing between items can be set with the set_spacing method.

Fields§

§show_description: bool

Whether to show the description line.

§styles: DefaultItemStyles

The styles for the delegate.

§update_func: Option<Box<dyn Fn(&dyn Msg, &Model) -> Cmd + Send + Sync>>

An optional update function called on item updates.

§short_help_func: Option<Box<dyn Fn() -> Vec<Binding> + Send + Sync>>

An optional short help function.

§full_help_func: Option<Box<dyn Fn() -> Vec<Vec<Binding>> + Send + Sync>>

An optional full help function.

Implementations§

Source§

impl DefaultDelegate

Source

pub fn set_height(&mut self, i: usize)

SetHeight sets delegate’s preferred height.

Source

pub fn height(&self) -> usize

Height returns the delegate’s preferred height. This has effect only if ShowDescription is true, otherwise height is always 1.

Source

pub fn set_spacing(&mut self, i: usize)

SetSpacing sets the delegate’s spacing.

Source

pub fn spacing(&self) -> usize

Spacing returns the delegate’s spacing.

Source

pub fn render(&self, m: &Model, index: usize, item: &dyn Item) -> String

Render prints an item.

Trait Implementations§

Source§

impl ItemDelegate for DefaultDelegate

Source§

fn render(&self, m: &Model, index: usize, item: &dyn Item) -> String

Render renders the item’s view.
Source§

fn height(&self) -> usize

Height is the height of the list item.
Source§

fn spacing(&self) -> usize

Spacing is the size of the horizontal gap between list items in cells.
Source§

fn update(&self, msg: &dyn Msg, m: &Model) -> Cmd

Update is the update loop for items. All messages in the list’s update loop will pass through here except when the user is setting a filter. Use this method to perform item-level updates appropriate to this delegate. Read more
Source§

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

ShortHelp returns bindings for the short help view, if the delegate implements the help keymap interface.
Source§

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

FullHelp returns bindings for the full help view, if the delegate implements the help keymap interface.

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

Source§

type Output = T

Should always be Self
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.