Skip to main content

ListState

Struct ListState 

Source
pub struct ListState<T, I>
where T: ListItem<I>, I: ApplicationInfo,
{ /* private fields */ }
Expand description

Persistent state for List.

Implementations§

Source§

impl<T, I> ListState<T, I>
where T: ListItem<I>, I: ApplicationInfo,

Source

pub fn new(id: I::ContentId, items: Vec<T>) -> Self

Create state for a list.

Source

pub fn id(&self) -> I::ContentId

Get the content identifier for this list.

Source

pub fn is_empty(&self) -> bool

Indicates whether or not this list contains any items.

Source

pub fn len(&self) -> usize

Returns the number of items in this list.

Source

pub fn set(&mut self, items: Vec<T>)

Replace the set of items with a new list.

Source

pub fn get(&self) -> Option<&T>

Get a reference to the currently selected value.

Source

pub fn get_mut(&mut self) -> Option<&mut T>

Get a mutable reference to the currently selected value.

Source

pub fn set_term_info(&mut self, area: Rect)

Set the dimensions and placement within the terminal window for this list.

Trait Implementations§

Source§

impl<T, I> CursorMovements<ListCursor> for ListState<T, I>
where T: ListItem<I>, I: ApplicationInfo,

Source§

fn first_word( &self, pos: &ListCursor, _: &CursorMovementsContext<'_, ListCursor>, ) -> ListCursor

Calculate the position of the first word on the line of the provided cursor.
Source§

fn movement( &self, pos: &ListCursor, movement: &MoveType, count: &Count, ctx: &CursorMovementsContext<'_, ListCursor>, ) -> Option<ListCursor>

Calculate the position of the cursor after performing a movement.
Source§

fn range_of_movement( &self, pos: &ListCursor, movement: &MoveType, count: &Count, ctx: &CursorMovementsContext<'_, ListCursor>, ) -> Option<EditRange<ListCursor>>

Calculate a cursor range from the given cursor to the location after performing the given movement.
Source§

fn range( &self, pos: &ListCursor, range: &RangeType, _: bool, count: &Count, ctx: &CursorMovementsContext<'_, ListCursor>, ) -> Option<EditRange<ListCursor>>

Calculate a cursor range based on a given cursor position and a RangeType.
Source§

impl<T, I> CursorSearch<ListCursor> for ListState<T, I>
where T: ListItem<I>, I: ApplicationInfo,

Source§

fn find_char( &self, _: &ListCursor, _: bool, _: MoveDir1D, _: bool, _: char, _: usize, ) -> Option<ListCursor>

Search for a specific character.
Source§

fn find_matches( &self, _: &ListCursor, _: &ListCursor, _: &Regex, ) -> Vec<EditRange<ListCursor>>

Find matches for a regular expression within a range.
Source§

fn find_regex( &self, pos: &ListCursor, dir: MoveDir1D, needle: &Regex, count: usize, ) -> Option<EditRange<ListCursor>>

Search for a regular expression.
Source§

impl<T, I> Editable<EditContext, Store<I>, I> for ListState<T, I>
where T: ListItem<I>, I: ApplicationInfo,

Source§

fn editor_command( &mut self, act: &EditorAction, ctx: &EditContext, store: &mut Store<I>, ) -> EditResult<EditInfo, I>

Execute an editor action.
Source§

impl<T, I> EditorActions<EditContext, Store<I>, I> for ListState<T, I>
where T: ListItem<I>, I: ApplicationInfo,

Source§

fn edit( &mut self, operation: &EditAction, motion: &EditTarget, ctx: &EditContext, store: &mut Store<I>, ) -> EditResult<EditInfo, I>

Perform an editing operation over the targeted text.
Source§

fn mark( &mut self, name: Mark, _: &EditContext, store: &mut Store<I>, ) -> EditResult<EditInfo, I>

Create or update a cursor mark based on the leader’s cursor position.
Source§

fn complete( &mut self, _: &CompletionStyle, _: &CompletionType, _: &CompletionDisplay, _: &EditContext, _: &mut Store<I>, ) -> EditResult<EditInfo, I>

Complete the text before the cursor group leader.
Source§

fn insert_text( &mut self, _: &InsertTextAction, _: &EditContext, _: &mut Store<I>, ) -> EditResult<EditInfo, I>

Insert text relative to the current cursor position.
Source§

fn selection_command( &mut self, _: &SelectionAction, _: &EditContext, _: &mut Store<I>, ) -> EditResult<EditInfo, I>

Modify the current selection.
Source§

fn history_command( &mut self, act: &HistoryAction, _: &EditContext, _: &mut Store<I>, ) -> EditResult<EditInfo, I>

Move to a different point in the buffer’s editing history.
Source§

fn cursor_command( &mut self, act: &CursorAction, ctx: &EditContext, store: &mut Store<I>, ) -> EditResult<EditInfo, I>

Perform an action over a cursor group.
Source§

impl<T, I> Jumpable<EditContext, I> for ListState<T, I>
where T: ListItem<I>, I: ApplicationInfo,

Source§

fn jump( &mut self, list: PositionList, dir: MoveDir1D, count: usize, _: &EditContext, ) -> UIResult<usize, I>

Move through a PositionList in MoveDir1D direction count times. Read more
Source§

impl<C, I, T> Promptable<C, Store<I>, I> for ListState<T, I>
where I: ApplicationInfo, T: ListItem<I> + Promptable<C, Store<I>, I>,

Source§

fn prompt( &mut self, act: &PromptAction, ctx: &C, store: &mut Store<I>, ) -> EditResult<Vec<(Action<I>, C)>, I>

Execute a prompt action.
Source§

impl<I, T> ScrollActions<EditContext, Store<I>, I> for ListState<T, I>
where I: ApplicationInfo, T: ListItem<I>,

Source§

fn dirscroll( &mut self, dir: MoveDir2D, size: ScrollSize, count: &Count, ctx: &EditContext, store: &mut Store<I>, ) -> EditResult<EditInfo, I>

Pan the viewport.
Source§

fn cursorpos( &mut self, pos: MovePosition, axis: Axis, _: &EditContext, store: &mut Store<I>, ) -> EditResult<EditInfo, I>

Scroll so that the cursor is placed along a viewport boundary.
Source§

fn linepos( &mut self, pos: MovePosition, count: &Count, ctx: &EditContext, store: &mut Store<I>, ) -> EditResult<EditInfo, I>

Scroll so that a specific line is placed at a given place in the viewport.
Source§

impl<I, T> Scrollable<EditContext, Store<I>, I> for ListState<T, I>
where I: ApplicationInfo, T: ListItem<I>,

Source§

fn scroll( &mut self, style: &ScrollStyle, ctx: &EditContext, store: &mut Store<I>, ) -> EditResult<EditInfo, I>

Scroll the viewable content in this object.
Source§

impl<I, T> Searchable<EditContext, Store<I>, I> for ListState<T, I>
where I: ApplicationInfo, T: ListItem<I>,

Source§

fn search( &mut self, dir: MoveDirMod, count: Count, ctx: &EditContext, store: &mut Store<I>, ) -> UIResult<EditInfo, I>

Search for the nth result in MoveDirMod direction.
Source§

impl<T, I> TerminalCursor for ListState<T, I>
where T: ListItem<I>, I: ApplicationInfo,

Source§

fn get_term_cursor(&self) -> Option<(u16, u16)>

Returns the current offset of the cursor, relative to the upper left corner of the terminal.
Source§

impl<I, T> WindowOps<I> for ListState<T, I>
where T: ListItem<I>, I: ApplicationInfo,

Source§

fn dup(&self, _: &mut Store<I>) -> Self

Create a copy of this window during a window split.
Source§

fn close(&mut self, _: CloseFlags, _: &mut Store<I>) -> bool

Perform any necessary cleanup for this window and close it. Read more
Source§

fn write( &mut self, _: Option<&str>, _: WriteFlags, _: &mut Store<I>, ) -> UIResult<EditInfo, I>

Write the contents of the window.
Source§

fn draw( &mut self, area: Rect, buf: &mut Buffer, focused: bool, store: &mut Store<I>, )

Draw this window into the buffer for the prescribed area.
Source§

fn get_completions(&self) -> Option<CompletionList>

Get completion candidates to show the user.
Source§

fn get_cursor_word(&self, _: &WordStyle) -> Option<String>

Returns the word following the current cursor position in this window.
Source§

fn get_selected_word(&self) -> Option<String>

Returns the currently selected text in this window.

Auto Trait Implementations§

§

impl<T, I> Freeze for ListState<T, I>

§

impl<T, I> RefUnwindSafe for ListState<T, I>

§

impl<T, I> Send for ListState<T, I>
where T: Send,

§

impl<T, I> Sync for ListState<T, I>
where <I as ApplicationInfo>::ContentId: Sync, T: Sync,

§

impl<T, I> Unpin for ListState<T, I>
where <I as ApplicationInfo>::ContentId: Unpin, T: Unpin,

§

impl<T, I> UnsafeUnpin for ListState<T, I>

§

impl<T, I> UnwindSafe for ListState<T, I>

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

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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
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.
Source§

impl<T> Any for T
where T: Any,