Add Ctrl-A and Ctrl-E for searching to skip around to start and end respectively.

This commit is contained in:
ClementTsang 2020-01-17 19:53:42 -05:00
parent 7e442330ba
commit 4c7b3ee239
2 changed files with 18 additions and 0 deletions

View File

@ -319,6 +319,22 @@ impl App {
}
}
pub fn skip_cursor_beginning(&mut self) {
if !self.is_in_dialog() {
if let ApplicationPosition::ProcessSearch = self.current_application_position {
self.current_cursor_position = 0;
}
}
}
pub fn skip_cursor_end(&mut self) {
if !self.is_in_dialog() {
if let ApplicationPosition::ProcessSearch = self.current_application_position {
self.current_cursor_position = self.current_search_query.len();
}
}
}
pub fn on_char_key(&mut self, caught_char: char) {
// Forbid any char key presses when showing a dialog box...
if !self.is_in_dialog() {

View File

@ -256,6 +256,8 @@ fn main() -> error::Result<()> {
}
}
KeyCode::Char('s') => app.toggle_simple_search(),
KeyCode::Char('a') => app.skip_cursor_beginning(),
KeyCode::Char('e') => app.skip_cursor_end(),
_ => {}
}
}