Skip to content

Commit

Permalink
feat: ctrl-c to quit the app
Browse files Browse the repository at this point in the history
Now ctrl-c will exit the app, bypassing any bindings.
  • Loading branch information
bloznelis committed Dec 26, 2024
1 parent 0f02879 commit 3bfa556
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ use arboard::Clipboard;
use crossterm::event;
use crossterm::event::Event;
use crossterm::event::KeyCode;
use crossterm::event::KeyEvent;
use crossterm::event::KeyEventKind;
use crossterm::event::KeyModifiers;
use git2::Repository;
Expand Down Expand Up @@ -105,6 +106,7 @@ impl State {
screen.size = Size::new(w, h);
}
}
Event::Key(key) if self.is_system_quit(&key) => self.quit = true,
Event::Key(key) => {
if self.prompt.state.is_focused() {
self.prompt.state.handle_key_event(key)
Expand Down Expand Up @@ -136,6 +138,13 @@ impl State {
Ok(())
}

fn is_system_quit(&mut self, key: &KeyEvent) -> bool {
matches!(
(key.code, key.modifiers),
(KeyCode::Char('c'), KeyModifiers::CONTROL)
)
}

fn update_prompt(&mut self, term: &mut Term) -> Res<()> {
if self.prompt.state.status() == Status::Aborted {
self.unhide_menu();
Expand Down

0 comments on commit 3bfa556

Please sign in to comment.