pub struct TableEditState<T, E> {
pub mode: Mode,
pub table: TableState,
pub editor: E,
pub data: Vec<T>,
pub mouse: MouseFlags,
pub non_exhaustive: NonExhaustive,
}Expand description
State for TableEdit.
It has a mode-field for insert/edit/view.
Focus
When editing the widget blocks the Focus it is part of. You can’t leave the table as long as it’s editing.
It is intended that the editor-widget sets up a separate Focus for all the widgets and navigates independently of the main application Focus.
Fields§
§mode: ModeEditing mode.
table: TableStateBacking table.
editor: EEditor
data: Vec<T>Data store
mouse: MouseFlags§non_exhaustive: NonExhaustiveImplementations§
Source§impl<T, E> TableEditState<T, E>
impl<T, E> TableEditState<T, E>
pub fn new(editor: E) -> TableEditState<T, E>
pub fn named(name: &str, editor: E) -> TableEditState<T, E>
Sourcepub fn with(self, data: impl IntoIterator<Item = T>) -> TableEditState<T, E>
pub fn with(self, data: impl IntoIterator<Item = T>) -> TableEditState<T, E>
Populate the table-data.
Source§impl<T, E> TableEditState<T, E>
impl<T, E> TableEditState<T, E>
Source§impl<T, E> TableEditState<T, E>
impl<T, E> TableEditState<T, E>
Sourcepub fn row_cells(&self, row: usize) -> Option<(Rect, Vec<Rect>)>
pub fn row_cells(&self, row: usize) -> Option<(Rect, Vec<Rect>)>
Returns the whole row-area and the cell-areas for the given row, if it is visible.
Attention: These areas might be 0-length if the column is scrolled beyond the table-area.
Sourcepub fn cell_at_clicked(&self, pos: (u16, u16)) -> Option<(usize, usize)>
pub fn cell_at_clicked(&self, pos: (u16, u16)) -> Option<(usize, usize)>
Cell at given position.
Sourcepub fn cell_at_drag(&self, pos: (u16, u16)) -> (usize, usize)
pub fn cell_at_drag(&self, pos: (u16, u16)) -> (usize, usize)
Cell when dragging. Position can be outside the table area. See row_at_drag, col_at_drag
Sourcepub fn row_at_drag(&self, pos: (u16, u16)) -> usize
pub fn row_at_drag(&self, pos: (u16, u16)) -> usize
Row when dragging. Position can be outside the table area. If the position is above the table-area this returns offset - #rows. If the position is below the table-area this returns offset + page_len + #rows.
This doesn’t account for the row-height of the actual rows outside the table area, just assumes ‘1’.
Sourcepub fn column_at_drag(&self, pos: (u16, u16)) -> usize
pub fn column_at_drag(&self, pos: (u16, u16)) -> usize
Column when dragging. Position can be outside the table area. If the position is left of the table area this returns offset - 1. If the position is right of the table area this returns offset + page_width + 1.
Source§impl<T, E> TableEditState<T, E>
impl<T, E> TableEditState<T, E>
Sourcepub fn clear_offset(&mut self)
pub fn clear_offset(&mut self)
Sets both offsets to 0.
Sourcepub fn row_max_offset(&self) -> usize
pub fn row_max_offset(&self) -> usize
Maximum offset that is accessible with scrolling.
This is shorter than the length by whatever fills the last page. This is the base for the scrollbar content_length.
Sourcepub fn row_offset(&self) -> usize
pub fn row_offset(&self) -> usize
Current vertical offset.
Sourcepub fn set_row_offset(&mut self, offset: usize) -> bool
pub fn set_row_offset(&mut self, offset: usize) -> bool
Change the vertical offset. The offset may be beyond the number of rows.
The widget returns true if the offset changed at all.
Sourcepub fn row_scroll_by(&self) -> usize
pub fn row_scroll_by(&self) -> usize
Suggested scroll per scroll-event.
Sourcepub fn x_max_offset(&self) -> usize
pub fn x_max_offset(&self) -> usize
Maximum offset that is accessible with scrolling.
This is shorter than the length of the content by whatever fills the last page. This is the base for the scrollbar content_length.
Sourcepub fn set_x_offset(&mut self, offset: usize) -> bool
pub fn set_x_offset(&mut self, offset: usize) -> bool
Change the horizontal offset. The offset may be beyond the table-width.
Returns true if the offset changed at all.
Sourcepub fn page_width(&self) -> usize
pub fn page_width(&self) -> usize
Horizontal page-size at the current offset.
Sourcepub fn x_scroll_by(&self) -> usize
pub fn x_scroll_by(&self) -> usize
Suggested scroll per scroll-event.
Sourcepub fn scroll_to_selected(&mut self) -> bool
pub fn scroll_to_selected(&mut self) -> bool
Ensures that the selected item is visible. Caveat: This doesn’t work nicely if you have varying row-heights. Caveat: Number of rows needs to be correct.
Sourcepub fn scroll_to_row(&mut self, pos: usize) -> bool
pub fn scroll_to_row(&mut self, pos: usize) -> bool
Ensures that the given row is visible. Caveat: This doesn’t work nicely if you have varying row-heights. Caveat: Number of rows needs to be correct.
Sourcepub fn scroll_to_col(&mut self, pos: usize) -> bool
pub fn scroll_to_col(&mut self, pos: usize) -> bool
Ensures that the given column is completely visible.
Sourcepub fn scroll_to_x(&mut self, pos: usize) -> bool
pub fn scroll_to_x(&mut self, pos: usize) -> bool
Ensures that the given position is visible.
Sourcepub fn scroll_down(&mut self, n: usize) -> bool
pub fn scroll_down(&mut self, n: usize) -> bool
Increase the row-offset by n.
Sourcepub fn scroll_left(&mut self, n: usize) -> bool
pub fn scroll_left(&mut self, n: usize) -> bool
Reduce the col-offset by n.
Sourcepub fn scroll_right(&mut self, n: usize) -> bool
pub fn scroll_right(&mut self, n: usize) -> bool
Increase the col-offset by n.
Source§impl<T, E> TableEditState<T, E>
impl<T, E> TableEditState<T, E>
Sourcepub fn clear_selection(&mut self)
pub fn clear_selection(&mut self)
Clear the selection.
Source§impl<T, E> TableEditState<T, E>
impl<T, E> TableEditState<T, E>
Sourcepub fn set_scroll_selection(&mut self, scroll: bool)
pub fn set_scroll_selection(&mut self, scroll: bool)
When scrolling the table, change the selection instead of the offset.
Sourcepub fn has_selection(&mut self) -> bool
pub fn has_selection(&mut self) -> bool
Anything selected?
Sourcepub fn selected(&self) -> Option<usize>
pub fn selected(&self) -> Option<usize>
Selected row. The selected row is not constrained by the row-count.
Sourcepub fn selected_checked(&self) -> Option<usize>
pub fn selected_checked(&self) -> Option<usize>
Return the selected row and ensure it is in the
range 0..rows.
Sourcepub fn select(&mut self, row: Option<usize>) -> bool
pub fn select(&mut self, row: Option<usize>) -> bool
Select the row. The selection is not constrained by the row-count.
Sourcepub fn move_deselect(&mut self) -> bool
pub fn move_deselect(&mut self) -> bool
Set the selection to None and set the offset to 0
Sourcepub fn move_to(&mut self, row: usize) -> bool
pub fn move_to(&mut self, row: usize) -> bool
Move the selection to the given row. Ensures the row is visible afterward.
Source§impl<T, E> TableEditState<T, E>where
E: TableEditorState<T>,
T: Clone,
impl<T, E> TableEditState<T, E>where
E: TableEditorState<T>,
T: Clone,
Sourcepub fn value(&self) -> &Vec<T>
pub fn value(&self) -> &Vec<T>
Get the data.
This will not contain the data of the currently editing row. Instead, it will contain the value before the edit started.
Sourcepub fn is_editing(&self) -> bool
pub fn is_editing(&self) -> bool
Editing is active?
Sourcepub fn edit_new<'a>(
&mut self,
row: usize,
ctx: &'a <E as TableEditorState<T>>::Context<'a>,
) -> Result<(), <E as TableEditorState<T>>::Err>
pub fn edit_new<'a>( &mut self, row: usize, ctx: &'a <E as TableEditorState<T>>::Context<'a>, ) -> Result<(), <E as TableEditorState<T>>::Err>
Edit a new item inserted at the selected row.
Sourcepub fn edit<'a>(
&mut self,
col: Option<usize>,
row: usize,
ctx: &'a <E as TableEditorState<T>>::Context<'a>,
) -> Result<(), <E as TableEditorState<T>>::Err>
pub fn edit<'a>( &mut self, col: Option<usize>, row: usize, ctx: &'a <E as TableEditorState<T>>::Context<'a>, ) -> Result<(), <E as TableEditorState<T>>::Err>
Edit the item at the given row. A starting column can be provided too.
Sourcepub fn cancel<'a>(
&mut self,
ctx: &'a <E as TableEditorState<T>>::Context<'a>,
) -> Result<(), <E as TableEditorState<T>>::Err>
pub fn cancel<'a>( &mut self, ctx: &'a <E as TableEditorState<T>>::Context<'a>, ) -> Result<(), <E as TableEditorState<T>>::Err>
Cancel editing. When inserting a new row, the row will be removed.
Sourcepub fn commit<'a>(
&mut self,
ctx: &'a <E as TableEditorState<T>>::Context<'a>,
) -> Result<(), <E as TableEditorState<T>>::Err>
pub fn commit<'a>( &mut self, ctx: &'a <E as TableEditorState<T>>::Context<'a>, ) -> Result<(), <E as TableEditorState<T>>::Err>
Commit the changes in the editor.
Sourcepub fn commit_and_append<'a>(
&mut self,
ctx: &'a <E as TableEditorState<T>>::Context<'a>,
) -> Result<(), <E as TableEditorState<T>>::Err>
pub fn commit_and_append<'a>( &mut self, ctx: &'a <E as TableEditorState<T>>::Context<'a>, ) -> Result<(), <E as TableEditorState<T>>::Err>
Commit the current changes and start editing the next row. If the end of the table is reached a row will be appended.
Sourcepub fn commit_and_edit<'a>(
&mut self,
ctx: &'a <E as TableEditorState<T>>::Context<'a>,
) -> Result<(), <E as TableEditorState<T>>::Err>
pub fn commit_and_edit<'a>( &mut self, ctx: &'a <E as TableEditorState<T>>::Context<'a>, ) -> Result<(), <E as TableEditorState<T>>::Err>
Commit the current changes and start editing the next row. Does not append at the end of the table.
Trait Implementations§
Source§impl<T, E> Default for TableEditState<T, E>where
E: Default,
impl<T, E> Default for TableEditState<T, E>where
E: Default,
Source§fn default() -> TableEditState<T, E>
fn default() -> TableEditState<T, E>
Source§impl<'a, T, S> HandleEvent<Event, &'a <S as TableEditorState<T>>::Context<'a>, Result<Outcome, <S as TableEditorState<T>>::Err>> for TableEditState<T, S>where
S: HandleEvent<Event, &'a <S as TableEditorState<T>>::Context<'a>, Result<Outcome, <S as TableEditorState<T>>::Err>> + TableEditorState<T>,
T: Clone,
impl<'a, T, S> HandleEvent<Event, &'a <S as TableEditorState<T>>::Context<'a>, Result<Outcome, <S as TableEditorState<T>>::Err>> for TableEditState<T, S>where
S: HandleEvent<Event, &'a <S as TableEditorState<T>>::Context<'a>, Result<Outcome, <S as TableEditorState<T>>::Err>> + TableEditorState<T>,
T: Clone,
Source§impl<T, E> HasFocus for TableEditState<T, E>
impl<T, E> HasFocus for TableEditState<T, E>
Source§fn build(&self, builder: &mut FocusBuilder)
fn build(&self, builder: &mut FocusBuilder)
Source§fn is_focused(&self) -> bool
fn is_focused(&self) -> bool
Source§fn lost_focus(&self) -> bool
fn lost_focus(&self) -> bool
Source§fn gained_focus(&self) -> bool
fn gained_focus(&self) -> bool
Source§fn is_obscured(&self) -> bool
fn is_obscured(&self) -> bool
Source§impl<T, E> HasScreenCursor for TableEditState<T, E>where
E: HasScreenCursor,
impl<T, E> HasScreenCursor for TableEditState<T, E>where
E: HasScreenCursor,
Source§impl<T, E> RelocatableState for TableEditState<T, E>where
E: RelocatableState,
impl<T, E> RelocatableState for TableEditState<T, E>where
E: RelocatableState,
Source§fn relocate(&mut self, shift: (i16, i16), clip: Rect)
fn relocate(&mut self, shift: (i16, i16), clip: Rect)
Source§fn relocate_popup(&mut self, shift: (i16, i16), clip: Rect)
fn relocate_popup(&mut self, shift: (i16, i16), clip: Rect)
Auto Trait Implementations§
impl<T, E> !Freeze for TableEditState<T, E>
impl<T, E> !RefUnwindSafe for TableEditState<T, E>
impl<T, E> !Send for TableEditState<T, E>
impl<T, E> !Sync for TableEditState<T, E>
impl<T, E> !UnwindSafe for TableEditState<T, E>
impl<T, E> Forget for TableEditState<T, E>
impl<T, E> Move for TableEditState<T, E>
impl<T, E> Unpin for TableEditState<T, E>
impl<T, E> UnsafeUnpin for TableEditState<T, E>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
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