diff options
author | ClementTsang <cjhtsang@uwaterloo.ca> | 2021-11-20 22:45:49 -0500 |
---|---|---|
committer | ClementTsang <cjhtsang@uwaterloo.ca> | 2021-11-20 22:45:49 -0500 |
commit | cc66f1fcaea6d31581efea7dfc1b0029e4754f49 (patch) | |
tree | 4d9c2f0a6d9ddaefd73e95caddfa9d356e173e89 /src/app/widgets/base | |
parent | 5833cb8ad1f30d42efd9dc7f5f27bed35882bc95 (diff) |
refactor: mostly add back tree mode for process
Mouse control on collapse is not working yet, need to do some work
internally first.
Diffstat (limited to 'src/app/widgets/base')
-rw-r--r-- | src/app/widgets/base/sort_text_table.rs | 7 | ||||
-rw-r--r-- | src/app/widgets/base/text_table.rs | 18 |
2 files changed, 15 insertions, 10 deletions
diff --git a/src/app/widgets/base/sort_text_table.rs b/src/app/widgets/base/sort_text_table.rs index 2c2d9e21..001624a4 100644 --- a/src/app/widgets/base/sort_text_table.rs +++ b/src/app/widgets/base/sort_text_table.rs @@ -288,11 +288,16 @@ where self.table.current_scroll_index() } - /// Returns the current column the table is sorting by. + /// Returns a reference to the current column the table is sorting by. pub fn current_sorting_column(&self) -> &S { &self.table.columns[self.sort_index] } + /// Returns a mutable reference to the current column the table is sorting by. + pub fn current_mut_sorting_column(&mut self) -> &mut S { + &mut self.table.columns[self.sort_index] + } + /// Returns the current column index the table is sorting by. pub fn current_sorting_column_index(&self) -> usize { self.sort_index diff --git a/src/app/widgets/base/text_table.rs b/src/app/widgets/base/text_table.rs index d3c9c601..896eda85 100644 --- a/src/app/widgets/base/text_table.rs +++ b/src/app/widgets/base/text_table.rs @@ -39,8 +39,9 @@ pub trait TableColumn { fn set_x_bounds(&mut self, x_bounds: Option<(u16, u16)>); } -pub type TextTableData = Vec<Vec<(Cow<'static, str>, Option<Cow<'static, str>>, Option<Style>)>>; -pub type TextTableDataRef = [Vec<(Cow<'static, str>, Option<Cow<'static, str>>, Option<Style>)>]; +pub(crate) type TextTableRow = Vec<(Cow<'static, str>, Option<Cow<'static, str>>, Option<Style>)>; +pub(crate) type TextTableData = Vec<TextTableRow>; +pub(crate) type TextTableDataRef = [TextTableRow]; /// A [`SimpleColumn`] represents some column in a [`TextTable`]. #[derive(Debug)] @@ -468,14 +469,13 @@ where .style(painter.colours.table_header_style) .bottom_margin(table_gap); - let table = Table::new(rows) + let mut table = Table::new(rows) .header(header) - .style(painter.colours.text_style) - .highlight_style(if show_selected_entry { - painter.colours.currently_selected_text_style - } else { - painter.colours.text_style - }); + .style(painter.colours.text_style); + + if show_selected_entry { + table = table.highlight_style(painter.colours.currently_selected_text_style); + } if self.selectable { f.render_stateful_widget( |