From 9fcbff99a32d0d12b9f017564bc1149cfee24432 Mon Sep 17 00:00:00 2001 From: ClementTsang Date: Sun, 16 Feb 2020 21:54:18 -0500 Subject: Update GIF, add DELETE key to search options. --- README.md | 2 +- assets/cpu_filter.png | Bin 0 -> 103215 bytes assets/recording_1.gif | Bin 686412 -> 1144888 bytes src/app.rs | 45 ++++++++++++++++++++++++++++++++++++++++----- src/main.rs | 3 ++- 5 files changed, 43 insertions(+), 7 deletions(-) create mode 100644 assets/cpu_filter.png diff --git a/README.md b/README.md index bfbca25b..52334cd0 100644 --- a/README.md +++ b/README.md @@ -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. -![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 diff --git a/assets/cpu_filter.png b/assets/cpu_filter.png new file mode 100644 index 00000000..cbfa62b1 Binary files /dev/null and b/assets/cpu_filter.png differ diff --git a/assets/recording_1.gif b/assets/recording_1.gif index 24d24c39..4f15a7a8 100644 Binary files a/assets/recording_1.gif and b/assets/recording_1.gif differ diff --git a/src/app.rs b/src/app.rs index c9b8bac3..fd010bca 100644 --- a/src/app.rs +++ b/src/app.rs @@ -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 { self.process_search_state.search_state.is_enabled } @@ -535,11 +569,12 @@ impl App { pub fn on_backspace(&mut self) { if let WidgetPosition::ProcessSearch = self.current_widget_selected { - if self - .process_search_state - .search_state - .current_cursor_position - > 0 + if self.process_search_state.search_state.is_enabled + && self + .process_search_state + .search_state + .current_cursor_position + > 0 { self.process_search_state .search_state diff --git a/src/main.rs b/src/main.rs index 5c6fd2d4..426ab268 100644 --- a/src/main.rs +++ b/src/main.rs @@ -319,7 +319,7 @@ fn handle_key_event_or_break( KeyCode::Enter => app.on_enter(), KeyCode::Tab => app.on_tab(), KeyCode::Backspace => app.on_backspace(), - KeyCode::Delete => app.start_dd(), + KeyCode::Delete => app.on_delete(), _ => {} } } else { @@ -342,6 +342,7 @@ fn handle_key_event_or_break( } KeyCode::Char('a') => app.skip_cursor_beginning(), KeyCode::Char('e') => app.skip_cursor_end(), + KeyCode::Backspace => app.on_skip_backspace(), _ => {} } } else if let KeyModifiers::SHIFT = event.modifiers { -- cgit v1.2.3