pub struct ListState {
pub selected: Option<usize>,
/* private fields */
}Fields§
§selected: Option<usize>The selected item. If None, no item is currently selected.
Implementations§
Source§impl ListState
impl ListState
Sourcepub fn selected(&self) -> Option<usize>
👎Deprecated since 0.9.0: Use ListState’s selected field instead.
pub fn selected(&self) -> Option<usize>
Returns the index of the currently selected item, if any.
Sourcepub fn next(&mut self)
pub fn next(&mut self)
Selects the next element of the list. If circular is true, calling next on the last element selects the first.
§Example
use tui_widget_list::ListState;
let mut list_state = ListState::default();
list_state.next();Sourcepub fn previous(&mut self)
pub fn previous(&mut self)
Selects the previous element of the list. If circular is true, calling previous on the first element selects the last.
§Example
use tui_widget_list::ListState;
let mut list_state = ListState::default();
list_state.previous();Sourcepub fn scroll_offset_index(&self) -> usize
pub fn scroll_offset_index(&self) -> usize
Returns the index of the first item currently displayed on the screen.
Sourcepub fn scroll_truncation(&self) -> u16
pub fn scroll_truncation(&self) -> u16
Returns the number of rows/columns of the first visible item that are scrolled off the top/left.
When the first visible item is partially scrolled out of view, this returns how many rows (for vertical lists) or columns (for horizontal lists) are hidden above/left of the viewport. Returns 0 if the first visible item is fully visible.
§Example
If message #5 is the first visible item but its first 2 rows are scrolled off the top,
this returns 2. Combined with scroll_offset_index(), you can calculate the exact
scroll position in pixels/rows.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for ListState
impl RefUnwindSafe for ListState
impl Send for ListState
impl Sync for ListState
impl Unpin for ListState
impl UnwindSafe for ListState
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> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more