mirror of
https://github.com/ClementTsang/bottom.git
synced 2026-05-17 20:31:28 +00:00
feature: add spacebar shortcut to toggle process tree nodes (#1830)
* feature: added spacebar as a toggle for proc tree mode * bug: added check if the app is currently in search widget state * refactor: moved the if statements inside the match case * docs: added documentation for Spaec as tree toggle * revert: changes * feat: added space key to toggle tree * refactor: clippy errors * docs: updated documentation for space as toggle * feat: experimental change to Minus, collapse entire tree * fix: clippy errors * feat: finished - and + as full tree collapse/expand * refactor: clippy errors * Made the all collapse function more concise * Changed i32 calls to Pid * updated help text * Fixed array * reverted total collapse and expand of trees * array fix
This commit is contained in:
@@ -101,7 +101,7 @@ Pressing ++t++ or ++f5++ in the table toggles tree mode in the process widget, d
|
||||
|
||||
A process in tree mode can also be "collapsed", hiding its children and any descendants, using the either the ++minus++,
|
||||
++plus++, or ++left++ keys, or clicking on an entry. It can be expanded by using the ++minus++, ++plus++, or ++right++
|
||||
keys, or by clicking on the entry again.
|
||||
keys, or by clicking on the entry again. The ++space++ key can also be used to toggle between the collapsed and expanded states.
|
||||
|
||||
!!! info
|
||||
|
||||
|
||||
+17
@@ -684,6 +684,23 @@ impl App {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn on_space_key(&mut self) {
|
||||
if !self.is_in_dialog() {
|
||||
if self.current_widget.widget_type == BottomWidgetType::Proc {
|
||||
if let Some(proc_widget_state) = self
|
||||
.states
|
||||
.proc_state
|
||||
.get_mut_widget_state(self.current_widget.widget_id)
|
||||
{
|
||||
proc_widget_state.toggle_current_tree_branch_entry();
|
||||
}
|
||||
}
|
||||
} else if self.process_kill_dialog.is_open() {
|
||||
// Either select the current option,
|
||||
// or scroll to the next one
|
||||
}
|
||||
}
|
||||
|
||||
pub fn on_page_up(&mut self) {
|
||||
if self.process_kill_dialog.is_open() {
|
||||
self.process_kill_dialog.on_page_up();
|
||||
|
||||
+19
-19
@@ -63,25 +63,25 @@ const CPU_HELP_TEXT: [&str; 2] = [
|
||||
|
||||
const PROCESS_HELP_TEXT: [&str; 20] = [
|
||||
"3 - Process widget",
|
||||
"dd, F9, Delete Kill the selected process",
|
||||
"c Sort by CPU usage, press again to reverse",
|
||||
"m Sort by memory usage, press again to reverse",
|
||||
"p Sort by PID name, press again to reverse",
|
||||
"n Sort by process name, press again to reverse",
|
||||
"Tab Group/un-group processes with the same name",
|
||||
"Ctrl-f, / Open process search widget",
|
||||
"P Toggle between showing the full command or just the process name",
|
||||
"s, F6 Open process sort widget",
|
||||
"I Invert current sort",
|
||||
"% Toggle between values and percentages for memory usage",
|
||||
"t, F5 Toggle tree mode",
|
||||
"Right Collapse a branch while in tree mode",
|
||||
"Left Expand a branch while in tree mode",
|
||||
"+, -, click Toggle whether a branch is expanded or collapsed in tree mode",
|
||||
"click on header Sorts the entries by that column, click again to invert the sort",
|
||||
"C Sort by GPU usage, press again to reverse",
|
||||
"M Sort by GPU memory usage, press again to reverse",
|
||||
"z Toggle the display of kernel threads",
|
||||
"dd, F9, Delete Kill the selected process",
|
||||
"c Sort by CPU usage, press again to reverse",
|
||||
"m Sort by memory usage, press again to reverse",
|
||||
"p Sort by PID name, press again to reverse",
|
||||
"n Sort by process name, press again to reverse",
|
||||
"Tab Group/un-group processes with the same name",
|
||||
"Ctrl-f, / Open process search widget",
|
||||
"P Toggle between showing the full command or just the process name",
|
||||
"s, F6 Open process sort widget",
|
||||
"I Invert current sort",
|
||||
"% Toggle between values and percentages for memory usage",
|
||||
"t, F5 Toggle tree mode",
|
||||
"Right Collapse a branch while in tree mode",
|
||||
"Left Expand a branch while in tree mode",
|
||||
"+, -, click, Space Toggle whether a branch is expanded or collapsed in tree mode",
|
||||
"click on header Sorts the entries by that column, click again to invert the sort",
|
||||
"C Sort by GPU usage, press again to reverse",
|
||||
"M Sort by GPU memory usage, press again to reverse",
|
||||
"z Toggle the display of kernel threads",
|
||||
];
|
||||
|
||||
const SEARCH_HELP_TEXT: [&str; 51] = [
|
||||
|
||||
+2
-4
@@ -56,17 +56,15 @@ pub fn handle_key_event_or_break(
|
||||
// c_debug!("KeyEvent: {event:?}");
|
||||
|
||||
if event.modifiers.is_empty() {
|
||||
// Required catch for searching - otherwise you couldn't search with q.
|
||||
if event.code == KeyCode::Char('q') && !app.is_in_search_widget() {
|
||||
return true;
|
||||
}
|
||||
match event.code {
|
||||
KeyCode::Char('q') if !app.is_in_search_widget() => return true,
|
||||
KeyCode::End => app.skip_to_last(),
|
||||
KeyCode::Home => app.skip_to_first(),
|
||||
KeyCode::Up => app.on_up_key(),
|
||||
KeyCode::Down => app.on_down_key(),
|
||||
KeyCode::Left => app.on_left_key(),
|
||||
KeyCode::Right => app.on_right_key(),
|
||||
KeyCode::Char(' ') if !app.is_in_search_widget() => app.on_space_key(),
|
||||
KeyCode::Char(caught_char) => app.on_char_key(caught_char),
|
||||
KeyCode::Esc => app.on_esc(),
|
||||
KeyCode::Enter => app.on_enter(),
|
||||
|
||||
Reference in New Issue
Block a user