From 3252796f179e24f4b73b8eb8db52ef932f6e9bc7 Mon Sep 17 00:00:00 2001 From: Clement Tsang <34804052+ClementTsang@users.noreply.github.com> Date: Sat, 22 Aug 2020 14:31:19 -0700 Subject: [PATCH] change: Allow e to also close expanded widgets Allow `e` to toggle expansion, rather than only allowing it to open. --- CHANGELOG.md | 2 ++ README.md | 2 +- src/app.rs | 11 ++++++++++- src/constants.rs | 2 +- 4 files changed, 14 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e99d7424..96432f03 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -29,6 +29,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 backwards compatibility's sake, for macOS, this will still check `.config` if it exists first, but otherwise, it will default to the new location. +- Allow `e` to also escape expanded mode. + ### Bug Fixes - [#183](https://github.com/ClementTsang/bottom/pull/183): Fixed bug in basic mode where the battery widget was placed incorrectly. diff --git a/README.md b/README.md index a8636d68..146079c1 100644 --- a/README.md +++ b/README.md @@ -199,7 +199,7 @@ Run using `btm`. | `?` | Open help menu | | `gg`, `Home` | Jump to the first entry | | `Shift-g`, `End` | Jump to the last entry | -| `e` | Expand the currently selected widget | +| `e` | Toggle expanding the currently selected widget | | `+` | Zoom in on chart (decrease time range) | | `-` | Zoom out on chart (increase time range) | | `=` | Reset zoom | diff --git a/src/app.rs b/src/app.rs index 8402fcc5..5c0c2420 100644 --- a/src/app.rs +++ b/src/app.rs @@ -1151,7 +1151,7 @@ impl App { '+' => self.zoom_in(), '-' => self.zoom_out(), '=' => self.reset_zoom(), - 'e' => self.expand_widget(), + 'e' => self.toggle_expand_widget(), 's' => self.toggle_sort(), 'I' => self.invert_sort(), '%' => self.toggle_percentages(), @@ -1186,6 +1186,15 @@ impl App { self.to_delete_process_list.clone() } + fn toggle_expand_widget(&mut self) { + if self.is_expanded { + self.is_expanded = false; + self.is_force_redraw = true; + } else { + self.expand_widget(); + } + } + fn expand_widget(&mut self) { if !self.is_in_dialog() && !self.app_config_fields.use_basic_mode { // Pop-out mode. We ignore if in process search. diff --git a/src/constants.rs b/src/constants.rs index f8852cc9..c2e03d97 100644 --- a/src/constants.rs +++ b/src/constants.rs @@ -78,7 +78,7 @@ pub const GENERAL_HELP_TEXT: [&str; 29] = [ "? Open help menu\n", "gg Jump to the first entry\n", "G Jump to the last entry\n", - "e Expand the currently selected widget\n", + "e Toggle expanding the currently selected widget\n", "+ Zoom in on chart (decrease time range)\n", "- Zoom out on chart (increase time range)\n", "= Reset zoom\n",