feature: support delete key to kill processes (#1717)

* feature: support delete key to kill processes

* clippy

* Changelog

* fn + delete
This commit is contained in:
Clement Tsang 2025-04-19 02:51:49 -04:00 committed by GitHub
parent 508f05b640
commit 86b7ef331e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 37 additions and 33 deletions

View File

@ -27,6 +27,7 @@ That said, these are more guidelines rather than hardset rules, though the proje
- [#1625](https://github.com/ClementTsang/bottom/pull/1625): Add the ability to configure the disk widget's table columns. - [#1625](https://github.com/ClementTsang/bottom/pull/1625): Add the ability to configure the disk widget's table columns.
- [#1641](https://github.com/ClementTsang/bottom/pull/1641): Support AMD GPU data collection on Linux. - [#1641](https://github.com/ClementTsang/bottom/pull/1641): Support AMD GPU data collection on Linux.
- [#1642](https://github.com/ClementTsang/bottom/pull/1642): Support changing the widget borders. - [#1642](https://github.com/ClementTsang/bottom/pull/1642): Support changing the widget borders.
- [#1717](https://github.com/ClementTsang/bottom/pull/1717): Support delete key (fn + delete on macOS) to kill processes.
### Bug Fixes ### Bug Fixes

View File

@ -212,7 +212,7 @@ Note that key bindings are generally case-sensitive.
### Process table ### Process table
| Binding | Action | | Binding | Action |
| ---------------------- | ---------------------------------------------------------------- | | --------------------------------------------------- | ---------------------------------------------------------------- |
| ++up++ , ++k++ | Move up within a widget | | ++up++ , ++k++ | Move up within a widget |
| ++down++ , ++j++ | Move down within a widget | | ++down++ , ++j++ | Move down within a widget |
| ++g+g++ , ++home++ | Jump to the first entry in the table | | ++g+g++ , ++home++ | Jump to the first entry in the table |
@ -225,7 +225,7 @@ Note that key bindings are generally case-sensitive.
| ++tab++ | Toggle grouping processes with the same name | | ++tab++ | Toggle grouping processes with the same name |
| ++P++ | Toggle between showing the full command or just the process name | | ++P++ | Toggle between showing the full command or just the process name |
| ++ctrl+f++ , ++slash++ | Toggle showing the search sub-widget | | ++ctrl+f++ , ++slash++ | Toggle showing the search sub-widget |
| ++s++ , ++f6++ | Toggle showing the sort sub-widget | | ++s++ , ++f6++, ++delete++ (++fn+delete++ on macOS) | Toggle showing the sort sub-widget |
| ++I++ | Invert the current sort | | ++I++ | Invert the current sort |
| ++"%"++ | Toggle between values and percentages for memory usage | | ++"%"++ | Toggle between values and percentages for memory usage |
| ++t++ , ++f5++ | Toggle tree mode | | ++t++ , ++f5++ | Toggle tree mode |
@ -256,7 +256,7 @@ Note that key bindings are generally case-sensitive.
| ++ctrl+w++ | Delete a word behind the cursor | | ++ctrl+w++ | Delete a word behind the cursor |
| ++ctrl+h++ | Delete the character behind the cursor | | ++ctrl+h++ | Delete the character behind the cursor |
| ++backspace++ | Delete the character behind the cursor | | ++backspace++ | Delete the character behind the cursor |
| ++delete++ | Delete the character at the cursor | | ++delete++ (++fn+delete++ on macOS) | Delete the character at the cursor |
| ++alt+c++ , ++f1++ | Toggle matching case | | ++alt+c++ , ++f1++ | Toggle matching case |
| ++alt+w++ , ++f2++ | Toggle matching the entire word | | ++alt+w++ , ++f2++ | Toggle matching the entire word |
| ++alt+r++ , ++f3++ | Toggle using regex | | ++alt+r++ , ++f3++ | Toggle using regex |

View File

@ -516,7 +516,8 @@ impl App {
} }
pub fn on_delete(&mut self) { pub fn on_delete(&mut self) {
if let BottomWidgetType::ProcSearch = self.current_widget.widget_type { match self.current_widget.widget_type {
BottomWidgetType::ProcSearch => {
let is_in_search_widget = self.is_in_search_widget(); let is_in_search_widget = self.is_in_search_widget();
if let Some(proc_widget_state) = self if let Some(proc_widget_state) = self
.states .states
@ -524,8 +525,8 @@ impl App {
.widget_states .widget_states
.get_mut(&(self.current_widget.widget_id - 1)) .get_mut(&(self.current_widget.widget_id - 1))
{ {
if is_in_search_widget { if is_in_search_widget
if proc_widget_state.proc_search.search_state.is_enabled && proc_widget_state.proc_search.search_state.is_enabled
&& proc_widget_state.cursor_char_index() && proc_widget_state.cursor_char_index()
< proc_widget_state < proc_widget_state
.proc_search .proc_search
@ -555,10 +556,12 @@ impl App {
proc_widget_state.update_query(); proc_widget_state.update_query();
} }
} else {
self.start_killing_process()
} }
} }
BottomWidgetType::Proc => {
self.start_killing_process();
}
_ => {}
} }
} }