Update GIF, add DELETE key to search options.

This commit is contained in:
ClementTsang 2020-02-16 21:54:18 -05:00
parent f7ab907b74
commit 9fcbff99a3
5 changed files with 43 additions and 7 deletions

View File

@ -4,7 +4,7 @@
A graphical top clone, written in Rust. Inspired by both [gtop](https://github.com/aksakalli/gtop) and [gotop](https://github.com/cjbassi/gotop). Supports Linux, macOS, and Windows. A graphical top clone, written in Rust. Inspired by both [gtop](https://github.com/aksakalli/gtop) and [gotop](https://github.com/cjbassi/gotop). Supports Linux, macOS, and Windows.
![Quick demo recording](assets/recording_1.gif) _Terminal: Kitty Terminal, Font: IBM Plex Mono, OS: Arch Linux_ ![Quick demo recording](assets/recording_1.gif) _Terminal: Kitty Terminal, Font: IBM Plex Mono, OS: Arch Linux. Theme based on [gruvbox](https://github.com/morhetz/gruvbox) (see sample config)_
## Features ## Features

BIN
assets/cpu_filter.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 101 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 670 KiB

After

Width:  |  Height:  |  Size: 1.1 MiB

View File

@ -410,6 +410,40 @@ impl App {
} }
} }
pub fn on_delete(&mut self) {
match self.current_widget_selected {
WidgetPosition::Process => self.start_dd(),
WidgetPosition::ProcessSearch => {
if self.process_search_state.search_state.is_enabled
&& self
.process_search_state
.search_state
.current_cursor_position < self
.process_search_state
.search_state
.current_search_query
.len()
{
self.process_search_state
.search_state
.current_search_query
.remove(
self.process_search_state
.search_state
.current_cursor_position,
);
self.update_regex();
self.update_process_gui = true;
}
}
_ => {}
}
}
/// Deletes an entire word till the next space or end
pub fn on_skip_backspace(&mut self) {}
pub fn is_searching(&self) -> bool { pub fn is_searching(&self) -> bool {
self.process_search_state.search_state.is_enabled self.process_search_state.search_state.is_enabled
} }
@ -535,11 +569,12 @@ impl App {
pub fn on_backspace(&mut self) { pub fn on_backspace(&mut self) {
if let WidgetPosition::ProcessSearch = self.current_widget_selected { if let WidgetPosition::ProcessSearch = self.current_widget_selected {
if self if self.process_search_state.search_state.is_enabled
.process_search_state && self
.search_state .process_search_state
.current_cursor_position .search_state
> 0 .current_cursor_position
> 0
{ {
self.process_search_state self.process_search_state
.search_state .search_state

View File

@ -319,7 +319,7 @@ fn handle_key_event_or_break(
KeyCode::Enter => app.on_enter(), KeyCode::Enter => app.on_enter(),
KeyCode::Tab => app.on_tab(), KeyCode::Tab => app.on_tab(),
KeyCode::Backspace => app.on_backspace(), KeyCode::Backspace => app.on_backspace(),
KeyCode::Delete => app.start_dd(), KeyCode::Delete => app.on_delete(),
_ => {} _ => {}
} }
} else { } else {
@ -342,6 +342,7 @@ fn handle_key_event_or_break(
} }
KeyCode::Char('a') => app.skip_cursor_beginning(), KeyCode::Char('a') => app.skip_cursor_beginning(),
KeyCode::Char('e') => app.skip_cursor_end(), KeyCode::Char('e') => app.skip_cursor_end(),
KeyCode::Backspace => app.on_skip_backspace(),
_ => {} _ => {}
} }
} else if let KeyModifiers::SHIFT = event.modifiers { } else if let KeyModifiers::SHIFT = event.modifiers {