change: Allow e to also close expanded widgets

Allow `e` to toggle expansion, rather than only allowing it to open.
This commit is contained in:
Clement Tsang 2020-08-22 14:31:19 -07:00 committed by GitHub
parent 1a25fbb987
commit 3252796f17
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 14 additions and 3 deletions

View File

@ -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, backwards compatibility's sake, for macOS, this will still check `.config` if it exists first,
but otherwise, it will default to the new location. but otherwise, it will default to the new location.
- Allow `e` to also escape expanded mode.
### Bug Fixes ### Bug Fixes
- [#183](https://github.com/ClementTsang/bottom/pull/183): Fixed bug in basic mode where the battery widget was placed incorrectly. - [#183](https://github.com/ClementTsang/bottom/pull/183): Fixed bug in basic mode where the battery widget was placed incorrectly.

View File

@ -199,7 +199,7 @@ Run using `btm`.
| `?` | Open help menu | | `?` | Open help menu |
| `gg`, `Home` | Jump to the first entry | | `gg`, `Home` | Jump to the first entry |
| `Shift-g`, `End` | Jump to the last 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 in on chart (decrease time range) |
| `-` | Zoom out on chart (increase time range) | | `-` | Zoom out on chart (increase time range) |
| `=` | Reset zoom | | `=` | Reset zoom |

View File

@ -1151,7 +1151,7 @@ impl App {
'+' => self.zoom_in(), '+' => self.zoom_in(),
'-' => self.zoom_out(), '-' => self.zoom_out(),
'=' => self.reset_zoom(), '=' => self.reset_zoom(),
'e' => self.expand_widget(), 'e' => self.toggle_expand_widget(),
's' => self.toggle_sort(), 's' => self.toggle_sort(),
'I' => self.invert_sort(), 'I' => self.invert_sort(),
'%' => self.toggle_percentages(), '%' => self.toggle_percentages(),
@ -1186,6 +1186,15 @@ impl App {
self.to_delete_process_list.clone() 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) { fn expand_widget(&mut self) {
if !self.is_in_dialog() && !self.app_config_fields.use_basic_mode { if !self.is_in_dialog() && !self.app_config_fields.use_basic_mode {
// Pop-out mode. We ignore if in process search. // Pop-out mode. We ignore if in process search.

View File

@ -78,7 +78,7 @@ pub const GENERAL_HELP_TEXT: [&str; 29] = [
"? Open help menu\n", "? Open help menu\n",
"gg Jump to the first entry\n", "gg Jump to the first entry\n",
"G Jump to the last 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 in on chart (decrease time range)\n",
"- Zoom out on chart (increase time range)\n", "- Zoom out on chart (increase time range)\n",
"= Reset zoom\n", "= Reset zoom\n",