Skip to main content

ListState

Struct ListState 

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

A cursor over a list of rows, the first row shown, and a selection.

Rows are positions in what is listed (after filtering, say); the selection is kept by index, whatever the caller’s indices are (an item’s index before filtering), so marks survive a change of filter. Movement takes the page, the rows on screen, since that can change with every render.

Implementations§

Source§

impl ListState

Source

pub fn new() -> ListState

Source

pub fn len(&self) -> usize

How many rows there are.

Source

pub fn is_empty(&self) -> bool

Source

pub fn set_len(&mut self, len: usize)

Set the number of rows. The cursor is left where it is: call reset or set_cursor to put it on a row that exists.

Source

pub fn cursor(&self) -> usize

The row the cursor is on.

Source

pub fn set_cursor(&mut self, row: usize)

Put the cursor on row, without scrolling (see follow).

Source

pub fn offset(&self) -> usize

The first row shown.

Source

pub fn set_offset(&mut self, offset: usize)

Source

pub fn reset(&mut self, row: usize, page: usize)

Put the cursor on row and the first row shown back at the top, then scroll just enough to show the cursor: after the rows changed.

Source

pub fn follow(&mut self, page: usize)

Scroll just enough that the cursor’s row is among the page shown.

Source

pub fn step(&mut self, delta: isize, page: usize)

Move the cursor by delta rows (negative: up), stopping at the ends, and scroll to follow it. Nothing happens with no rows.

Source

pub fn select_row(&mut self, row: usize, page: usize)

Move to row (clamped to the last) and scroll to show it.

Source

pub fn visible(&self, page: usize) -> Range<usize> ⓘ

The rows shown on a page of page rows.

Source

pub fn clear_selection(&mut self, count: usize)

Make room to select count indices, all unselected.

Source

pub fn is_selected(&self, index: usize) -> bool

Source

pub fn set_selected(&mut self, index: usize, on: bool)

Select or unselect index; indices past the room made are grown to.

Source

pub fn toggle(&mut self, index: usize)

Flip whether index is selected.

Source

pub fn selected(&self) -> Vec<usize>

The selected indices, in order.

Source

pub fn selected_count(&self) -> usize

How many indices are selected.

Trait Implementations§

Source§

impl Clone for ListState

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Debug for ListState

Source§

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

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

impl Default for ListState

Source§

fn default() -> Self

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

impl Eq for ListState

Source§

impl PartialEq for ListState

Source§

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

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

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

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for ListState

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<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
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 = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

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.