[][src]Struct termimad::ListView

pub struct ListView<'t, T> {
    pub area: Area,
    pub skin: &'t MadSkin,
    // some fields omitted
}

A filterable list whose columns can be automatically resized.

Notes:

  • another version will allow more than one style per cell (i.e. make the cells composites rather than compounds). Shout out if you need that now.
  • this version doesn't allow cell wrapping

Fields

area: Areaskin: &'t MadSkin

Methods

impl<'t, T> ListView<'t, T>[src]

pub fn new(
    area: Area,
    columns: Vec<ListViewColumn<'t, T>>,
    skin: &'t MadSkin
) -> Self
[src]

Create a new list view with the passed columns.

The columns can't be changed afterwards but the area can be modified. When two columns have the same title, those titles are merged (but the columns below stay separated).

pub fn sort(&mut self, sort: Box<dyn Fn(&T, &T) -> Ordering>)[src]

set a comparator for row sorting

pub fn tbody_height(&self) -> i32[src]

return the height which is available for rows

pub fn scrollbar(&self) -> Option<(u16, u16)>[src]

return an option which when filled contains a tupple with the top and bottom of the vertical scrollbar. Return none when the content fits the available space.

pub fn add_row(&mut self, data: T)[src]

pub fn clear_rows(&mut self)[src]

remove all rows (and selection).

Keep the columns and the sort function, if any.

pub fn row_counts(&self) -> (usize, usize)[src]

return both the number of displayed rows and the total number

pub fn update_dimensions(&mut self)[src]

recompute the widths of all columns. This should be called when the area size is modified

pub fn set_filter(&mut self, filter: Box<dyn Fn(&T) -> bool>)[src]

pub fn remove_filter(&mut self)[src]

pub fn display(&self) -> Result<()>[src]

display the whole list in its area

pub fn do_scroll_show_bottom(&self) -> bool[src]

return true if the last line of the list is visible

pub fn scroll_to_bottom(&mut self)[src]

ensure the last line is visible

pub fn try_scroll_lines(&mut self, lines_count: i32)[src]

set the scroll amount. lines_count can be negative

pub fn try_scroll_pages(&mut self, pages_count: i32)[src]

set the scroll amount. pages_count can be negative

pub fn try_select_next(&mut self, up: bool)[src]

try to select the next visible line

pub fn select_first_line(&mut self)[src]

select the first visible line (unless there's nothing).

pub fn select_last_line(&mut self)[src]

select the last visible line (unless there's nothing).

pub fn make_selection_visible(&mut self)[src]

scroll to ensure the selected line (if any) is visible.

This is automatically called by try_scroll and try select functions

pub fn get_selection(&self) -> Option<&T>[src]

pub fn has_selection(&self) -> bool[src]

pub fn unselect(&mut self)[src]

Auto Trait Implementations

impl<'t, T> !Send for ListView<'t, T>

impl<'t, T> Unpin for ListView<'t, T> where
    T: Unpin

impl<'t, T> !Sync for ListView<'t, T>

impl<'t, T> !UnwindSafe for ListView<'t, T>

impl<'t, T> !RefUnwindSafe for ListView<'t, T>

Blanket Implementations

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> From<T> for T[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> Any for T where
    T: 'static + ?Sized
[src]