Skip to main content

ListCursor

Struct ListCursor 

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

A focus over len rows and the window of rows shown around it.

The window’s place lives in the cursor, so it doesn’t jump from frame to frame: ask for it with window (rows of one height) or window_by_heights each time the list is shown.

Implementations§

Source§

impl ListCursor

Source

pub fn new(len: usize) -> Self

A cursor on the first of len rows, keeping the focus in view.

Source

pub fn scrolling(self, scroll: Scroll) -> Self

The same cursor, its window following the focus by scroll.

Source

pub fn at(self, index: usize) -> Self

The same cursor on row index (the last row, if there is no such row).

Source

pub fn focus(&self) -> usize

The focused row. With no rows it is 0, which isn’t a row.

Source

pub fn len(&self) -> usize

How many rows there are.

Source

pub fn is_empty(&self) -> bool

Whether there are no rows.

Source

pub fn scroll(&self) -> Scroll

How the window follows the focus.

Source

pub fn first_shown(&self) -> usize

The first row of the window, as the last window or window_by_heights left it.

Source

pub fn step( &mut self, forward: bool, wrap: bool, enabled: impl Fn(usize) -> bool, ) -> bool

Moves the focus to the next (forward) or previous row that enabled accepts, going round the ends if wrap, else stopping at them. Returns whether the focus moved, so the caller knows to play its move sound. With no such row it stays put.

Source

pub fn settle(&mut self, enabled: impl Fn(usize) -> bool) -> bool

Moves the focus off a row enabled rejects: to the next row it accepts, else the nearest one before. Returns whether it moved. For after the rows changed (a row was used up, or removed).

Source

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

Sets the number of rows, after some were added or removed. A focus past the new end moves to the last row; the window is clamped the next time it is asked for.

Source

pub fn window(&mut self, rows_shown: usize) -> Range<usize> ⓘ

The rows a box of rows_shown rows shows: always the focus, placed by the cursor’s Scroll rule, and never past the end of the list while there are rows before it to show instead. A box of no rows still shows the focused one. With no rows it is empty.

Source

pub fn window_by_heights( &mut self, heights: &[usize], room: usize, ) -> Range<usize> ⓘ

The rows a box room tall shows when the rows have different heights (heights[i] is row i’s, in the box’s units: a backlog of wrapped lines). As window: always the focus, even a focused row taller than the box, placed by the Scroll rule, and as many rows as fit. heights has one entry per row.

Trait Implementations§

Source§

impl Clone for ListCursor

Source§

fn clone(&self) -> ListCursor

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 ListCursor

Source§

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

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

impl Default for ListCursor

Source§

fn default() -> ListCursor

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

impl Eq for ListCursor

Source§

impl PartialEq for ListCursor

Source§

fn eq(&self, other: &ListCursor) -> 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 ListCursor

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<T> DynClone for T
where T: Clone,

Source§

fn __clone_box(&self, _: Private) -> *mut ()

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 = 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.