mirror of
https://github.com/ClementTsang/bottom.git
synced 2025-07-22 21:24:49 +02:00
feature: support delete key to kill processes (#1717)
* feature: support delete key to kill processes * clippy * Changelog * fn + delete
This commit is contained in:
parent
508f05b640
commit
86b7ef331e
@ -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.
|
||||
- [#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.
|
||||
- [#1717](https://github.com/ClementTsang/bottom/pull/1717): Support delete key (fn + delete on macOS) to kill processes.
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
|
@ -211,26 +211,26 @@ Note that key bindings are generally case-sensitive.
|
||||
|
||||
### Process table
|
||||
|
||||
| Binding | Action |
|
||||
| ---------------------- | ---------------------------------------------------------------- |
|
||||
| ++up++ , ++k++ | Move up within a widget |
|
||||
| ++down++ , ++j++ | Move down within a widget |
|
||||
| ++g+g++ , ++home++ | Jump to the first entry in the table |
|
||||
| ++G++ , ++end++ | Jump to the last entry in the table |
|
||||
| ++d+d++ , ++f9++ | Send a kill signal to the selected process |
|
||||
| ++c++ | Sort by CPU usage, press again to reverse sorting order |
|
||||
| ++m++ | Sort by memory usage, press again to reverse sorting order |
|
||||
| ++p++ | Sort by PID name, press again to reverse sorting order |
|
||||
| ++n++ | Sort by process name, press again to reverse sorting order |
|
||||
| ++tab++ | Toggle grouping processes with the same name |
|
||||
| ++P++ | Toggle between showing the full command or just the process name |
|
||||
| ++ctrl+f++ , ++slash++ | Toggle showing the search sub-widget |
|
||||
| ++s++ , ++f6++ | Toggle showing the sort sub-widget |
|
||||
| ++I++ | Invert the current sort |
|
||||
| ++"%"++ | Toggle between values and percentages for memory usage |
|
||||
| ++t++ , ++f5++ | Toggle tree mode |
|
||||
| ++M++ | Sort by gpu memory usage, press again to reverse sorting order |
|
||||
| ++C++ | Sort by gpu usage, press again to reverse sorting order |
|
||||
| Binding | Action |
|
||||
| --------------------------------------------------- | ---------------------------------------------------------------- |
|
||||
| ++up++ , ++k++ | Move up within a widget |
|
||||
| ++down++ , ++j++ | Move down within a widget |
|
||||
| ++g+g++ , ++home++ | Jump to the first entry in the table |
|
||||
| ++G++ , ++end++ | Jump to the last entry in the table |
|
||||
| ++d+d++ , ++f9++ | Send a kill signal to the selected process |
|
||||
| ++c++ | Sort by CPU usage, press again to reverse sorting order |
|
||||
| ++m++ | Sort by memory usage, press again to reverse sorting order |
|
||||
| ++p++ | Sort by PID name, press again to reverse sorting order |
|
||||
| ++n++ | Sort by process name, press again to reverse sorting order |
|
||||
| ++tab++ | Toggle grouping processes with the same name |
|
||||
| ++P++ | Toggle between showing the full command or just the process name |
|
||||
| ++ctrl+f++ , ++slash++ | Toggle showing the search sub-widget |
|
||||
| ++s++ , ++f6++, ++delete++ (++fn+delete++ on macOS) | Toggle showing the sort sub-widget |
|
||||
| ++I++ | Invert the current sort |
|
||||
| ++"%"++ | Toggle between values and percentages for memory usage |
|
||||
| ++t++ , ++f5++ | Toggle tree mode |
|
||||
| ++M++ | Sort by gpu memory usage, press again to reverse sorting order |
|
||||
| ++C++ | Sort by gpu usage, press again to reverse sorting order |
|
||||
|
||||
### Sort sub-widget
|
||||
|
||||
@ -256,7 +256,7 @@ Note that key bindings are generally case-sensitive.
|
||||
| ++ctrl+w++ | Delete a word behind the cursor |
|
||||
| ++ctrl+h++ | 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+w++ , ++f2++ | Toggle matching the entire word |
|
||||
| ++alt+r++ , ++f3++ | Toggle using regex |
|
||||
|
27
src/app.rs
27
src/app.rs
@ -516,16 +516,17 @@ impl App {
|
||||
}
|
||||
|
||||
pub fn on_delete(&mut self) {
|
||||
if let BottomWidgetType::ProcSearch = self.current_widget.widget_type {
|
||||
let is_in_search_widget = self.is_in_search_widget();
|
||||
if let Some(proc_widget_state) = self
|
||||
.states
|
||||
.proc_state
|
||||
.widget_states
|
||||
.get_mut(&(self.current_widget.widget_id - 1))
|
||||
{
|
||||
if is_in_search_widget {
|
||||
if proc_widget_state.proc_search.search_state.is_enabled
|
||||
match self.current_widget.widget_type {
|
||||
BottomWidgetType::ProcSearch => {
|
||||
let is_in_search_widget = self.is_in_search_widget();
|
||||
if let Some(proc_widget_state) = self
|
||||
.states
|
||||
.proc_state
|
||||
.widget_states
|
||||
.get_mut(&(self.current_widget.widget_id - 1))
|
||||
{
|
||||
if is_in_search_widget
|
||||
&& proc_widget_state.proc_search.search_state.is_enabled
|
||||
&& proc_widget_state.cursor_char_index()
|
||||
< proc_widget_state
|
||||
.proc_search
|
||||
@ -555,10 +556,12 @@ impl App {
|
||||
|
||||
proc_widget_state.update_query();
|
||||
}
|
||||
} else {
|
||||
self.start_killing_process()
|
||||
}
|
||||
}
|
||||
BottomWidgetType::Proc => {
|
||||
self.start_killing_process();
|
||||
}
|
||||
_ => {}
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user