Struct cursive_extras::AdvancedSelectView
source · pub struct AdvancedSelectView<T = String>where
T: 'static,{ /* private fields */ }
Expand description
A view that is a lot like a SelectView
but allows mutable access to the selection
and allows multiline items
Implementations§
source§impl AdvancedSelectView
impl AdvancedSelectView
sourcepub fn add_item_str<S: Display>(&mut self, label: S)
pub fn add_item_str<S: Display>(&mut self, label: S)
Add an item with the label as the value
sourcepub fn item_str<S: Display>(self, label: S) -> Self
pub fn item_str<S: Display>(self, label: S) -> Self
Add an item with the label as the value
Chainable version
sourcepub fn insert_item_str<S: Display>(&mut self, index: usize, label: S)
pub fn insert_item_str<S: Display>(&mut self, index: usize, label: S)
Insert an item with the label as the value
sourcepub fn add_all_str<S, I>(&mut self, iter: I)where
S: Display,
I: IntoIterator<Item = S>,
pub fn add_all_str<S, I>(&mut self, iter: I)where S: Display, I: IntoIterator<Item = S>,
Add all the strings from a string iterator
sourcepub fn with_all_str<S, I>(self, iter: I) -> Selfwhere
S: Display,
I: IntoIterator<Item = S>,
pub fn with_all_str<S, I>(self, iter: I) -> Selfwhere S: Display, I: IntoIterator<Item = S>,
Add all the strings from a string iterator
Chainable version
source§impl<T: Ord + 'static> AdvancedSelectView<T>
impl<T: Ord + 'static> AdvancedSelectView<T>
source§impl<T: 'static> AdvancedSelectView<T>
impl<T: 'static> AdvancedSelectView<T>
sourcepub fn set_enabled(&mut self, enabled: bool)
pub fn set_enabled(&mut self, enabled: bool)
Enable or disable this view.
sourcepub fn with_enabled(self, is_enabled: bool) -> Self
pub fn with_enabled(self, is_enabled: bool) -> Self
Enable or disable this view.
Chainable variant.
sourcepub fn is_enabled(&self) -> bool
pub fn is_enabled(&self) -> bool
Returns true
if this view is enabled.
sourcepub fn new() -> AdvancedSelectView<T>
pub fn new() -> AdvancedSelectView<T>
Create a new AdvancedSelectView
sourcepub fn set_autojump(&mut self, autojump: bool)
pub fn set_autojump(&mut self, autojump: bool)
Allow jumping to items starting with the the pressed letter key
sourcepub fn autojump(self) -> Self
pub fn autojump(self) -> Self
Allow jumping to items starting with the the pressed letter key
Chainable version
sourcepub fn set_on_select<F: Fn(&mut Cursive, &T) + 'static>(&mut self, cb: F)
pub fn set_on_select<F: Fn(&mut Cursive, &T) + 'static>(&mut self, cb: F)
Set the select callback
sourcepub fn on_select<F: Fn(&mut Cursive, &T) + 'static>(self, cb: F) -> Self
pub fn on_select<F: Fn(&mut Cursive, &T) + 'static>(self, cb: F) -> Self
Set the select callback
Chainable version
sourcepub fn set_on_submit<F: Fn(&mut Cursive, &T) + 'static>(&mut self, cb: F)
pub fn set_on_submit<F: Fn(&mut Cursive, &T) + 'static>(&mut self, cb: F)
Set the callback when Enter is pressed
sourcepub fn on_submit<F: Fn(&mut Cursive, &T) + 'static>(self, cb: F) -> Self
pub fn on_submit<F: Fn(&mut Cursive, &T) + 'static>(self, cb: F) -> Self
Set the callback when Enter is pressed
Chainable version
sourcepub fn selection_mut(&mut self) -> Option<&mut T>
pub fn selection_mut(&mut self) -> Option<&mut T>
The current selection as a mutable reference
Returns None
if the view is empty
sourcepub fn selected_index(&self) -> usize
pub fn selected_index(&self) -> usize
The index of the current selection
sourcepub fn selected_label(&self) -> Option<&StyledString>
pub fn selected_label(&self) -> Option<&StyledString>
The label of the current selected item
sourcepub fn selected_label_mut(&mut self) -> Option<&mut StyledString>
pub fn selected_label_mut(&mut self) -> Option<&mut StyledString>
The label of the current selected item
sourcepub fn set_selection(&mut self, index: usize)
pub fn set_selection(&mut self, index: usize)
Set the selected item index
sourcepub fn add_item<L: Into<StyledString>>(&mut self, label: L, item: T)
pub fn add_item<L: Into<StyledString>>(&mut self, label: L, item: T)
Add an item to this view
sourcepub fn add_all<L, I>(&mut self, iter: I)where
L: Into<StyledString>,
I: IntoIterator<Item = (L, T)>,
pub fn add_all<L, I>(&mut self, iter: I)where L: Into<StyledString>, I: IntoIterator<Item = (L, T)>,
Add all items from an iterator
sourcepub fn with_all<L, I>(self, iter: I) -> Selfwhere
L: Into<StyledString>,
I: IntoIterator<Item = (L, T)>,
pub fn with_all<L, I>(self, iter: I) -> Selfwhere L: Into<StyledString>, I: IntoIterator<Item = (L, T)>,
Add all items from an iterator
Chainable version
sourcepub fn item<L: Into<StyledString>>(self, label: L, item: T) -> Self
pub fn item<L: Into<StyledString>>(self, label: L, item: T) -> Self
Add an item to this view
Chainable version
sourcepub fn get_item_mut(
&mut self,
index: usize
) -> Option<(&mut StyledString, &mut T)>
pub fn get_item_mut( &mut self, index: usize ) -> Option<(&mut StyledString, &mut T)>
Get an item (mutable reference) at the index
sourcepub fn iter(
&self
) -> impl Iterator<Item = (&StyledString, &T)> + DoubleEndedIterator + ExactSizeIterator
pub fn iter( &self ) -> impl Iterator<Item = (&StyledString, &T)> + DoubleEndedIterator + ExactSizeIterator
Iterate over all the items
sourcepub fn iter_mut(
&mut self
) -> impl Iterator<Item = (&mut StyledString, &mut T)> + DoubleEndedIterator + ExactSizeIteratorwhere
T: Clone,
pub fn iter_mut( &mut self ) -> impl Iterator<Item = (&mut StyledString, &mut T)> + DoubleEndedIterator + ExactSizeIteratorwhere T: Clone,
Iterate over all the items with mutability
sourcepub fn remove_item(&mut self, index: usize)
pub fn remove_item(&mut self, index: usize)
Remove an item at a specific index
sourcepub fn insert_item<L: Into<StyledString>>(
&mut self,
index: usize,
label: L,
item: T
)
pub fn insert_item<L: Into<StyledString>>( &mut self, index: usize, label: L, item: T )
Insert an item at a specific index
sourcepub fn label_sort(&mut self)
pub fn label_sort(&mut self)
Sort the view by label
sourcepub fn sort_by<F>(&mut self, compare: F)where
F: FnMut(&T, &T) -> Ordering,
pub fn sort_by<F>(&mut self, compare: F)where F: FnMut(&T, &T) -> Ordering,
Sort the view with the specified comparator function
sourcepub fn sort_by_key<K, F>(&mut self, key_of: F)where
F: FnMut(&T) -> K,
K: Ord,
pub fn sort_by_key<K, F>(&mut self, key_of: F)where F: FnMut(&T) -> K, K: Ord,
Sort the view with a key extraction function
sourcepub fn move_item_up(&mut self, index: usize)
pub fn move_item_up(&mut self, index: usize)
Move an item up in the view
sourcepub fn move_item_down(&mut self, index: usize)
pub fn move_item_down(&mut self, index: usize)
Move an item down in the view
Trait Implementations§
source§impl<T: 'static> Default for AdvancedSelectView<T>
impl<T: 'static> Default for AdvancedSelectView<T>
source§impl<T: 'static> View for AdvancedSelectView<T>
impl<T: 'static> View for AdvancedSelectView<T>
source§fn draw(&self, printer: &Printer<'_, '_>)
fn draw(&self, printer: &Printer<'_, '_>)
source§fn required_size(&mut self, bound: Vec2) -> Vec2
fn required_size(&mut self, bound: Vec2) -> Vec2
source§fn layout(&mut self, size: Vec2)
fn layout(&mut self, size: Vec2)
source§fn take_focus(&mut self, dir: Direction) -> Result<EventResult, CannotFocus>
fn take_focus(&mut self, dir: Direction) -> Result<EventResult, CannotFocus>
source§fn on_event(&mut self, event: Event) -> EventResult
fn on_event(&mut self, event: Event) -> EventResult
source§fn important_area(&self, size: Vec2) -> Rect
fn important_area(&self, size: Vec2) -> Rect
source§fn needs_relayout(&self) -> bool
fn needs_relayout(&self) -> bool
source§fn call_on_any(
&mut self,
_: &Selector<'_>,
_: &mut dyn FnMut(&mut (dyn View + 'static))
)
fn call_on_any( &mut self, _: &Selector<'_>, _: &mut dyn FnMut(&mut (dyn View + 'static)) )
source§fn focus_view(&mut self, _: &Selector<'_>) -> Result<EventResult, ViewNotFound>
fn focus_view(&mut self, _: &Selector<'_>) -> Result<EventResult, ViewNotFound>
Auto Trait Implementations§
impl<T = String> !RefUnwindSafe for AdvancedSelectView<T>
impl<T = String> !Send for AdvancedSelectView<T>
impl<T = String> !Sync for AdvancedSelectView<T>
impl<T> Unpin for AdvancedSelectView<T>
impl<T = String> !UnwindSafe for AdvancedSelectView<T>
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> Finder for Twhere
T: View,
impl<T> Finder for Twhere T: View,
source§fn call_on_all<V, F>(&mut self, sel: &Selector<'_>, callback: F)where
V: View,
F: FnMut(&mut V),
fn call_on_all<V, F>(&mut self, sel: &Selector<'_>, callback: F)where V: View, F: FnMut(&mut V),
sel
. Read moresource§fn call_on<V, F, R>(&mut self, sel: &Selector<'_>, callback: F) -> Option<R>where
V: View,
F: FnOnce(&mut V) -> R,
fn call_on<V, F, R>(&mut self, sel: &Selector<'_>, callback: F) -> Option<R>where V: View, F: FnOnce(&mut V) -> R,
sel
. Read moresource§impl<T> IntoBoxedView for Twhere
T: View,
impl<T> IntoBoxedView for Twhere T: View,
§impl<T> Pointable for T
impl<T> Pointable for T
source§impl<R, P> ReadPrimitive<R> for Pwhere
R: Read + ReadEndian<P>,
P: Default,
impl<R, P> ReadPrimitive<R> for Pwhere R: Read + ReadEndian<P>, P: Default,
source§fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
ReadEndian::read_from_little_endian()
.source§impl<T> Resizable for Twhere
T: View,
impl<T> Resizable for Twhere T: View,
source§fn resized(
self,
width: SizeConstraint,
height: SizeConstraint
) -> ResizedView<Self>
fn resized( self, width: SizeConstraint, height: SizeConstraint ) -> ResizedView<Self>
self
in a ResizedView
with the given size constraints.source§fn fixed_size<S>(self, size: S) -> ResizedView<Self>where
S: Into<XY<usize>>,
fn fixed_size<S>(self, size: S) -> ResizedView<Self>where S: Into<XY<usize>>,
self
into a fixed-size ResizedView
.source§fn fixed_width(self, width: usize) -> ResizedView<Self>
fn fixed_width(self, width: usize) -> ResizedView<Self>
self
into a fixed-width ResizedView
.source§fn fixed_height(self, height: usize) -> ResizedView<Self>
fn fixed_height(self, height: usize) -> ResizedView<Self>
self
into a fixed-width ResizedView
.source§fn full_screen(self) -> ResizedView<Self>
fn full_screen(self) -> ResizedView<Self>
self
into a full-screen ResizedView
.source§fn full_width(self) -> ResizedView<Self>
fn full_width(self) -> ResizedView<Self>
self
into a full-width ResizedView
.source§fn full_height(self) -> ResizedView<Self>
fn full_height(self) -> ResizedView<Self>
self
into a full-height ResizedView
.source§fn max_size<S>(self, size: S) -> ResizedView<Self>where
S: Into<XY<usize>>,
fn max_size<S>(self, size: S) -> ResizedView<Self>where S: Into<XY<usize>>,
self
into a limited-size ResizedView
.source§fn max_width(self, max_width: usize) -> ResizedView<Self>
fn max_width(self, max_width: usize) -> ResizedView<Self>
self
into a limited-width ResizedView
.source§fn max_height(self, max_height: usize) -> ResizedView<Self>
fn max_height(self, max_height: usize) -> ResizedView<Self>
self
into a limited-height ResizedView
.source§fn min_size<S>(self, size: S) -> ResizedView<Self>where
S: Into<XY<usize>>,
fn min_size<S>(self, size: S) -> ResizedView<Self>where S: Into<XY<usize>>,
self
into a ResizedView
at least sized size
.source§fn min_width(self, min_width: usize) -> ResizedView<Self>
fn min_width(self, min_width: usize) -> ResizedView<Self>
self
in a ResizedView
at least min_width
wide.source§fn min_height(self, min_height: usize) -> ResizedView<Self>
fn min_height(self, min_height: usize) -> ResizedView<Self>
self
in a ResizedView
at least min_height
tall.source§impl<T> Scrollable for Twhere
T: View,
impl<T> Scrollable for Twhere T: View,
source§fn scrollable(self) -> ScrollView<Self>
fn scrollable(self) -> ScrollView<Self>
self
in a ScrollView
.