diff options
Diffstat (limited to 'src/tuine/component/text_table.rs')
-rw-r--r-- | src/tuine/component/text_table.rs | 34 |
1 files changed, 13 insertions, 21 deletions
diff --git a/src/tuine/component/text_table.rs b/src/tuine/component/text_table.rs index 2ab8fe8f..bdfb104b 100644 --- a/src/tuine/component/text_table.rs +++ b/src/tuine/component/text_table.rs @@ -20,7 +20,7 @@ use crate::{ pub use self::table_column::{TextColumn, TextColumnConstraint}; use self::table_scroll_state::ScrollState as TextTableState; -use super::Component; +use super::{Component, ShouldRender}; #[derive(Clone, Debug, Default)] pub struct StyleSheet { @@ -29,7 +29,7 @@ pub struct StyleSheet { table_header: Style, } -struct TextTableMsg {} +pub enum TextTableMsg {} /// A sortable, scrollable table for text data. pub struct TextTable<'a> { @@ -59,8 +59,6 @@ impl<'a> TextTable<'a> { style_sheet: StyleSheet::default(), sortable: false, table_gap: 0, - on_select: None, - on_select_click: None, } } @@ -89,22 +87,6 @@ impl<'a> TextTable<'a> { self } - /// What [`Message`] to send when a row is selected. - /// - /// Defaults to `None` (doing nothing). - pub fn on_select(mut self, on_select: Option<Message>) -> Self { - self.on_select = on_select; - self - } - - /// What [`Message`] to send if a selected row is clicked on. - /// - /// Defaults to `None` (doing nothing). - pub fn on_select_click(mut self, on_select_click: Option<Message>) -> Self { - self.on_select_click = on_select_click; - self - } - fn update_column_widths(&mut self, bounds: Rect) { let total_width = bounds.width; let mut width_remaining = bounds.width; @@ -157,7 +139,11 @@ impl<'a> TextTable<'a> { impl<'a> Component for TextTable<'a> { type Message = TextTableMsg; - fn on_event(&mut self, bounds: Rect, event: Event, messages: &mut Vec<Message>) -> Status { + type Properties = (); + + fn on_event( + &mut self, bounds: Rect, event: Event, messages: &mut Vec<Self::Message>, + ) -> Status { use crate::tuine::MouseBoundIntersect; use crossterm::event::{MouseButton, MouseEventKind}; @@ -190,6 +176,12 @@ impl<'a> Component for TextTable<'a> { } } + fn update(&mut self, message: Self::Message) -> ShouldRender { + match message {} + + true + } + fn draw<B: Backend>(&mut self, bounds: Rect, frame: &mut Frame<'_, B>) { self.table_gap = if !self.show_gap || (self.data.len() + 2 > bounds.height.into() |