pub struct TableState {
pub selected: Option<usize>,
pub hovered: Option<usize>,
pub offset: usize,
/* private fields */
}Expand description
Mutable state for a Table widget.
Fields§
§selected: Option<usize>Index of the currently selected row, if any.
hovered: Option<usize>Index of the currently hovered row, if any.
offset: usizeScroll offset (first visible row index).
Implementations§
Source§impl TableState
impl TableState
Sourcepub fn select(&mut self, index: Option<usize>)
pub fn select(&mut self, index: Option<usize>)
Set the selected row index, resetting offset on deselect.
Sourcepub fn with_persistence_id(self, id: impl Into<String>) -> Self
pub fn with_persistence_id(self, id: impl Into<String>) -> Self
Create a new TableState with a persistence ID for state saving.
Sourcepub fn persistence_id(&self) -> Option<&str>
pub fn persistence_id(&self) -> Option<&str>
Get the persistence ID, if set.
Source§impl TableState
impl TableState
Sourcepub fn undo_id(&self) -> UndoWidgetId
pub fn undo_id(&self) -> UndoWidgetId
Get the undo widget ID.
This can be used to associate undo commands with this state instance.
Sourcepub fn sort_column(&self) -> Option<usize>
pub fn sort_column(&self) -> Option<usize>
Get the current sort column.
Sourcepub fn sort_ascending(&self) -> bool
pub fn sort_ascending(&self) -> bool
Get whether the sort is ascending.
Sourcepub fn set_filter(&mut self, filter: impl Into<String>)
pub fn set_filter(&mut self, filter: impl Into<String>)
Set the filter text.
Sourcepub fn handle_mouse(
&mut self,
event: &MouseEvent,
hit: Option<(HitId, HitRegion, u64)>,
expected_id: HitId,
row_count: usize,
) -> MouseResult
pub fn handle_mouse( &mut self, event: &MouseEvent, hit: Option<(HitId, HitRegion, u64)>, expected_id: HitId, row_count: usize, ) -> MouseResult
Handle a mouse event for this table.
§Hit data convention
The hit data (u64) encodes the row index. When the table renders with
a hit_id, each visible row registers HitRegion::Content with
data = row_index as u64.
§Arguments
event— the mouse event from the terminalhit— result offrame.hit_test(event.x, event.y), if availableexpected_id— theHitIdthis table was rendered withrow_count— total number of rows in the table
Sourcepub fn scroll_down(&mut self, lines: usize, row_count: usize)
pub fn scroll_down(&mut self, lines: usize, row_count: usize)
Scroll the table down by the given number of lines.
Clamps so that the last row can still appear at the top of the viewport.
Trait Implementations§
Source§impl Clone for TableState
impl Clone for TableState
Source§fn clone(&self) -> TableState
fn clone(&self) -> TableState
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more