From 8d6a75babe4fc97f116a1b1813e7f3d096b4bae3 Mon Sep 17 00:00:00 2001 From: Stephan Dilly Date: Sat, 26 Jun 2021 13:15:41 +0200 Subject: [PATCH] quit key binding (closes #771) --- CHANGELOG.md | 1 + src/app.rs | 11 ++++------- src/keys.rs | 4 ++-- 3 files changed, 7 insertions(+), 9 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index fd27af96..57cf4d72 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## Added - new `undo-last-commit` command [[@remique](https://github.com/remique)] ([#758](https://github.com/extrawurst/gitui/issues/758)) - taglist: show arrow-symbol on tags not present on origin [[@cruessler](https://github.com/cruessler)] ([#776](https://github.com/extrawurst/gitui/issues/776)) +- new quit key `[q]` ([#771](https://github.com/extrawurst/gitui/issues/771)) ## Fixed - openssl vendoring broken on macos ([#772](https://github.com/extrawurst/gitui/issues/772)) diff --git a/src/app.rs b/src/app.rs index 659de896..562fccfd 100644 --- a/src/app.rs +++ b/src/app.rs @@ -261,8 +261,7 @@ impl App { log::trace!("event: {:?}", ev); if let InputEvent::Input(ev) = ev { - if self.check_quit_key(ev) || self.check_weak_quit_key(ev) - { + if self.check_hard_exit(ev) || self.check_quit(ev) { return Ok(()); } @@ -453,14 +452,12 @@ impl App { ] ); - fn check_weak_quit_key(&mut self, ev: Event) -> bool { + fn check_quit(&mut self, ev: Event) -> bool { if self.any_popup_visible() { return false; } if let Event::Key(e) = ev { - if e == self.key_config.exit_if_no_popup - || e == self.key_config.exit_popup - { + if e == self.key_config.quit { self.do_quit = true; return true; } @@ -468,7 +465,7 @@ impl App { false } - fn check_quit_key(&mut self, ev: Event) -> bool { + fn check_hard_exit(&mut self, ev: Event) -> bool { if let Event::Key(e) = ev { if e == self.key_config.exit { self.do_quit = true; diff --git a/src/keys.rs b/src/keys.rs index 0a6c6b05..94d28d27 100644 --- a/src/keys.rs +++ b/src/keys.rs @@ -34,7 +34,7 @@ pub struct KeyConfig { pub focus_above: KeyEvent, pub focus_below: KeyEvent, pub exit: KeyEvent, - pub exit_if_no_popup: KeyEvent, + pub quit: KeyEvent, pub exit_popup: KeyEvent, pub open_commit: KeyEvent, pub open_commit_editor: KeyEvent, @@ -102,7 +102,7 @@ impl Default for KeyConfig { focus_above: KeyEvent { code: KeyCode::Up, modifiers: KeyModifiers::empty()}, focus_below: KeyEvent { code: KeyCode::Down, modifiers: KeyModifiers::empty()}, exit: KeyEvent { code: KeyCode::Char('c'), modifiers: KeyModifiers::CONTROL}, - exit_if_no_popup: KeyEvent { code: KeyCode::Char('q'), modifiers: KeyModifiers::empty()}, + quit: KeyEvent { code: KeyCode::Char('q'), modifiers: KeyModifiers::empty()}, exit_popup: KeyEvent { code: KeyCode::Esc, modifiers: KeyModifiers::empty()}, open_commit: KeyEvent { code: KeyCode::Char('c'), modifiers: KeyModifiers::empty()}, open_commit_editor: KeyEvent { code: KeyCode::Char('e'), modifiers:KeyModifiers::CONTROL},