diff options
author | Clement Tsang <34804052+ClementTsang@users.noreply.github.com> | 2020-08-29 19:23:20 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-08-29 19:23:20 -0400 |
commit | 6632714f26a8004decba81ed6f38959741b510f0 (patch) | |
tree | 0e14808369587540548cc5c6a8d93785d8f0e73b | |
parent | 3d2fc76aa24047deb167768940c5969d2bb2a595 (diff) |
feature: Allow Ctrl-F and / to work in sort (#212)
Fixes a bug, and also allows `Ctrl-F` and `/` to work in the sort widget.
-rw-r--r-- | src/app.rs | 37 | ||||
-rw-r--r-- | src/canvas/widgets/battery_display.rs | 1 |
2 files changed, 23 insertions, 15 deletions
@@ -287,20 +287,25 @@ impl App { pub fn on_slash(&mut self) { if !self.is_in_dialog() { - // FIXME: Add ProcSort too, it's annoying - if let BottomWidgetType::Proc = self.current_widget.widget_type { - // Toggle on - if let Some(proc_widget_state) = self - .proc_state - .get_mut_widget_state(self.current_widget.widget_id) - { - proc_widget_state - .process_search_state - .search_state - .is_enabled = true; - self.move_widget_selection(&WidgetDirection::Down); - self.is_force_redraw = true; + match &self.current_widget.widget_type { + BottomWidgetType::Proc | BottomWidgetType::ProcSort => { + // Toggle on + if let Some(proc_widget_state) = self.proc_state.get_mut_widget_state( + self.current_widget.widget_id + - match &self.current_widget.widget_type { + BottomWidgetType::ProcSort => 2, + _ => 0, + }, + ) { + proc_widget_state + .process_search_state + .search_state + .is_enabled = true; + self.move_widget_selection(&WidgetDirection::Down); + self.is_force_redraw = true; + } } + _ => {} } } } @@ -328,8 +333,10 @@ impl App { .set_to_sorted_index(&proc_widget_state.process_sorting_type); self.move_widget_selection(&WidgetDirection::Left); } else { - // Otherwise, move right - self.move_widget_selection(&WidgetDirection::Right); + // Otherwise, move right if currently on the sort widget + if let BottomWidgetType::ProcSort = self.current_widget.widget_type { + self.move_widget_selection(&WidgetDirection::Right); + } } } diff --git a/src/canvas/widgets/battery_display.rs b/src/canvas/widgets/battery_display.rs index 9166d50c..1bca2519 100644 --- a/src/canvas/widgets/battery_display.rs +++ b/src/canvas/widgets/battery_display.rs @@ -198,6 +198,7 @@ impl BatteryDisplayWidget for Painter { // .map(|battery| Spans::from(battery.battery_name.clone()))) // .collect::<Vec<_>>(), // ) + // FIXME: [MOUSE] Support mouse for the tabs? Tabs::default() .titles( app_state |