diff options
author | ClementTsang <clementjhtsang@gmail.com> | 2020-01-15 22:57:00 -0500 |
---|---|---|
committer | ClementTsang <clementjhtsang@gmail.com> | 2020-01-15 22:57:00 -0500 |
commit | a4badebd73eb20774399476d991742187cf74e18 (patch) | |
tree | f3d7338904be7c9561f0bac250b0c8419235e669 /src | |
parent | 5d0c8a9f32bb9ead677e6dbd0210e67b14e48152 (diff) |
Added in-program hotkey (Ctrl-S) to switch search levels, need to add some GUI indication. Also made it so that you don't need ENTER anymore to search... will monitor and test how this affects performance.
Diffstat (limited to 'src')
-rw-r--r-- | src/app.rs | 26 | ||||
-rw-r--r-- | src/main.rs | 1 |
2 files changed, 15 insertions, 12 deletions
@@ -227,6 +227,14 @@ impl App { &self.current_search_query } + pub fn toggle_simple_search(&mut self) { + if !self.is_in_dialog() && self.is_searching() { + if let ApplicationPosition::ProcessSearch = self.current_application_position { + self.use_simple = !self.use_simple; + } + } + } + /// One of two functions allowed to run while in a dialog... pub fn on_enter(&mut self) { if self.show_dd { @@ -241,18 +249,6 @@ impl App { self.show_dd = false; } } - } else if let ApplicationPosition::ProcessSearch = self.current_application_position { - // Generate regex. - - // TODO: [OPT] if we can get this to work WITHOUT pressing enter that would be good. - // However, this will be a bit hard without a thorough look at optimization to avoid - // wasteful regex generation. - - self.current_regex = if self.current_search_query.is_empty() { - BASE_REGEX.clone() - } else { - regex::Regex::new(&(self.current_search_query)) - }; } } @@ -280,6 +276,12 @@ impl App { if let ApplicationPosition::ProcessSearch = self.current_application_position { self.current_search_query.push(caught_char); + + self.current_regex = if self.current_search_query.is_empty() { + BASE_REGEX.clone() + } else { + regex::Regex::new(&(self.current_search_query)) + }; } else { match caught_char { '/' => { diff --git a/src/main.rs b/src/main.rs index 3b2afade..96a08bdc 100644 --- a/src/main.rs +++ b/src/main.rs @@ -253,6 +253,7 @@ fn main() -> error::Result<()> { app.reset(); } } + KeyCode::Char('s') => app.toggle_simple_search(), _ => {} } } |