From 383ef39cd7bdc6f8a9d3fc5fac753570fa630573 Mon Sep 17 00:00:00 2001 From: kjuulh Date: Tue, 7 Jan 2025 22:18:52 +0100 Subject: [PATCH] feat: allow ctrl+c to exit application --- Cargo.lock | 2 +- crates/gitnow/src/interactive.rs | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/Cargo.lock b/Cargo.lock index 12e0a55..164ab5c 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -747,7 +747,7 @@ dependencies = [ [[package]] name = "gitnow" -version = "0.2.3" +version = "0.3.0" dependencies = [ "anyhow", "async-trait", diff --git a/crates/gitnow/src/interactive.rs b/crates/gitnow/src/interactive.rs index 924940b..c47b7db 100644 --- a/crates/gitnow/src/interactive.rs +++ b/crates/gitnow/src/interactive.rs @@ -36,6 +36,7 @@ impl InteractiveApp for &'static crate::app::App { } mod app { + use crossterm::event::KeyModifiers; use ratatui::{ crossterm::event::{self, Event, KeyCode}, layout::{Constraint, Layout}, @@ -92,6 +93,12 @@ mod app { terminal.draw(|frame| self.draw(frame))?; if let Event::Key(key) = event::read()? { + if let KeyCode::Char('c') = key.code { + if key.modifiers.contains(KeyModifiers::CONTROL) { + return Ok(None); + } + } + match key.code { KeyCode::Char(letter) => { self.current_search.push(letter); -- 2.45.2