mirror of
https://github.com/gitui-org/gitui
synced 2026-05-24 09:28:21 +00:00
add bindings q and ESC for exit if no popup visible
This commit is contained in:
parent
bce652ecca
commit
f29ba723df
2 changed files with 15 additions and 1 deletions
14
src/app.rs
14
src/app.rs
|
|
@ -261,7 +261,7 @@ impl App {
|
|||
log::trace!("event: {:?}", ev);
|
||||
|
||||
if let InputEvent::Input(ev) = ev {
|
||||
if self.check_quit_key(ev) {
|
||||
if self.check_quit_key(ev) || self.check_weak_quit_key(ev) {
|
||||
return Ok(());
|
||||
}
|
||||
|
||||
|
|
@ -451,6 +451,18 @@ impl App {
|
|||
msg
|
||||
]
|
||||
);
|
||||
|
||||
fn check_weak_quit_key(&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 {
|
||||
self.do_quit = true;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
false
|
||||
}
|
||||
|
||||
fn check_quit_key(&mut self, ev: Event) -> bool {
|
||||
if let Event::Key(e) = ev {
|
||||
|
|
|
|||
|
|
@ -34,6 +34,7 @@ pub struct KeyConfig {
|
|||
pub focus_above: KeyEvent,
|
||||
pub focus_below: KeyEvent,
|
||||
pub exit: KeyEvent,
|
||||
pub exit_if_no_popup: KeyEvent,
|
||||
pub exit_popup: KeyEvent,
|
||||
pub open_commit: KeyEvent,
|
||||
pub open_commit_editor: KeyEvent,
|
||||
|
|
@ -101,6 +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()},
|
||||
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},
|
||||
|
|
|
|||
Loading…
Reference in a new issue