Struct termimad::ListView[][src]

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

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

Implementations

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 write_on<W>(&self, w: &mut W) -> Result<()> where
    W: Write
[src]

write the list view on the given writer

pub fn write(&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> !RefUnwindSafe for ListView<'t, T>

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

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

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

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

Blanket Implementations

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

pub fn type_id(&self) -> TypeId[src]

Gets the TypeId of self. Read more

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

pub fn borrow(&self) -> &T[src]

Immutably borrows from an owned value. Read more

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

pub fn borrow_mut(&mut self) -> &mut T[src]

Mutably borrows from an owned value. Read more

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

pub fn from(t: T) -> T[src]

Performs the conversion.

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

pub fn into(self) -> U[src]

Performs the conversion.

impl<T> Pointable for T

pub const ALIGN: usize

The alignment of pointer.

type Init = T

The type for initializers.

pub unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more

pub unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more

pub unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more

pub unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more

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.

pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>[src]

Performs the conversion.

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.

pub fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>[src]

Performs the conversion.