Skip to content

Commit 8d6a75b

Browse files
author
Stephan Dilly
committed
quit key binding (closes #771)
1 parent aee8721 commit 8d6a75b

File tree

3 files changed

+7
-9
lines changed

3 files changed

+7
-9
lines changed

CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1010
## Added
1111
- new `undo-last-commit` command [[@remique](https://github.com/remique)] ([#758](https://github.com/extrawurst/gitui/issues/758))
1212
- taglist: show arrow-symbol on tags not present on origin [[@cruessler](https://github.com/cruessler)] ([#776](https://github.com/extrawurst/gitui/issues/776))
13+
- new quit key `[q]` ([#771](https://github.com/extrawurst/gitui/issues/771))
1314

1415
## Fixed
1516
- openssl vendoring broken on macos ([#772](https://github.com/extrawurst/gitui/issues/772))

src/app.rs

+4-7
Original file line numberDiff line numberDiff line change
@@ -261,8 +261,7 @@ impl App {
261261
log::trace!("event: {:?}", ev);
262262

263263
if let InputEvent::Input(ev) = ev {
264-
if self.check_quit_key(ev) || self.check_weak_quit_key(ev)
265-
{
264+
if self.check_hard_exit(ev) || self.check_quit(ev) {
266265
return Ok(());
267266
}
268267

@@ -453,22 +452,20 @@ impl App {
453452
]
454453
);
455454

456-
fn check_weak_quit_key(&mut self, ev: Event) -> bool {
455+
fn check_quit(&mut self, ev: Event) -> bool {
457456
if self.any_popup_visible() {
458457
return false;
459458
}
460459
if let Event::Key(e) = ev {
461-
if e == self.key_config.exit_if_no_popup
462-
|| e == self.key_config.exit_popup
463-
{
460+
if e == self.key_config.quit {
464461
self.do_quit = true;
465462
return true;
466463
}
467464
}
468465
false
469466
}
470467

471-
fn check_quit_key(&mut self, ev: Event) -> bool {
468+
fn check_hard_exit(&mut self, ev: Event) -> bool {
472469
if let Event::Key(e) = ev {
473470
if e == self.key_config.exit {
474471
self.do_quit = true;

src/keys.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ pub struct KeyConfig {
3434
pub focus_above: KeyEvent,
3535
pub focus_below: KeyEvent,
3636
pub exit: KeyEvent,
37-
pub exit_if_no_popup: KeyEvent,
37+
pub quit: KeyEvent,
3838
pub exit_popup: KeyEvent,
3939
pub open_commit: KeyEvent,
4040
pub open_commit_editor: KeyEvent,
@@ -102,7 +102,7 @@ impl Default for KeyConfig {
102102
focus_above: KeyEvent { code: KeyCode::Up, modifiers: KeyModifiers::empty()},
103103
focus_below: KeyEvent { code: KeyCode::Down, modifiers: KeyModifiers::empty()},
104104
exit: KeyEvent { code: KeyCode::Char('c'), modifiers: KeyModifiers::CONTROL},
105-
exit_if_no_popup: KeyEvent { code: KeyCode::Char('q'), modifiers: KeyModifiers::empty()},
105+
quit: KeyEvent { code: KeyCode::Char('q'), modifiers: KeyModifiers::empty()},
106106
exit_popup: KeyEvent { code: KeyCode::Esc, modifiers: KeyModifiers::empty()},
107107
open_commit: KeyEvent { code: KeyCode::Char('c'), modifiers: KeyModifiers::empty()},
108108
open_commit_editor: KeyEvent { code: KeyCode::Char('e'), modifiers:KeyModifiers::CONTROL},

0 commit comments

Comments
 (0)