From c6850fb4633c3b732851f6c35b0eb78f5ee5a3e1 Mon Sep 17 00:00:00 2001 From: nyx Date: Fri, 4 Oct 2024 10:30:41 -0400 Subject: [PATCH 1/3] do not exit linutil in confirmation prompt when q is pressed --- tui/src/confirmation.rs | 10 +++++----- tui/src/state.rs | 8 +++----- 2 files changed, 8 insertions(+), 10 deletions(-) diff --git a/tui/src/confirmation.rs b/tui/src/confirmation.rs index 28732e35..726476e0 100644 --- a/tui/src/confirmation.rs +++ b/tui/src/confirmation.rs @@ -88,7 +88,7 @@ impl FloatContent for ConfirmPrompt { use KeyCode::*; self.status = match key.code { Char('y') | Char('Y') => ConfirmStatus::Confirm, - Char('n') | Char('N') | Esc => ConfirmStatus::Abort, + Char('n') | Char('N') | Esc | Char('q') | Char('Q') => ConfirmStatus::Abort, Char('j') => { self.scroll_down(); ConfirmStatus::None @@ -116,10 +116,10 @@ impl FloatContent for ConfirmPrompt { "Confirmation prompt", Box::new([ Shortcut::new("Continue", ["Y", "y"]), - Shortcut::new("Abort", ["N", "n"]), - Shortcut::new("Scroll up", ["j"]), - Shortcut::new("Scroll down", ["k"]), - Shortcut::new("Close linutil", ["CTRL-c", "q"]), + Shortcut::new("Abort", ["N", "n", "q", "Q", "Esc"]), + Shortcut::new("Scroll up", ["k"]), + Shortcut::new("Scroll down", ["j"]), + Shortcut::new("Close linutil", ["CTRL-c"]), ]), ) } diff --git a/tui/src/state.rs b/tui/src/state.rs index 36865557..6f8bef83 100644 --- a/tui/src/state.rs +++ b/tui/src/state.rs @@ -411,11 +411,9 @@ impl AppState { // This should be defined first to allow closing // the application even when not drawable ( If terminal is small ) // Exit on 'q' or 'Ctrl-c' input - if matches!( - self.focus, - Focus::TabList | Focus::List | Focus::ConfirmationPrompt(_) - ) && (key.code == KeyCode::Char('q') - || key.modifiers.contains(KeyModifiers::CONTROL) && key.code == KeyCode::Char('c')) + if matches!(self.focus, Focus::TabList | Focus::List) + && (key.code == KeyCode::Char('q') + || key.modifiers.contains(KeyModifiers::CONTROL) && key.code == KeyCode::Char('c')) { return false; } From 596467f155cf1b080a886cc17ee09721f8231e6a Mon Sep 17 00:00:00 2001 From: nyx Date: Fri, 4 Oct 2024 22:21:16 -0400 Subject: [PATCH 2/3] remove cap support --- tui/src/confirmation.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tui/src/confirmation.rs b/tui/src/confirmation.rs index 726476e0..d883fd2f 100644 --- a/tui/src/confirmation.rs +++ b/tui/src/confirmation.rs @@ -88,7 +88,7 @@ impl FloatContent for ConfirmPrompt { use KeyCode::*; self.status = match key.code { Char('y') | Char('Y') => ConfirmStatus::Confirm, - Char('n') | Char('N') | Esc | Char('q') | Char('Q') => ConfirmStatus::Abort, + Char('n') | Char('N') | Esc | Char('q') => ConfirmStatus::Abort, Char('j') => { self.scroll_down(); ConfirmStatus::None @@ -116,7 +116,7 @@ impl FloatContent for ConfirmPrompt { "Confirmation prompt", Box::new([ Shortcut::new("Continue", ["Y", "y"]), - Shortcut::new("Abort", ["N", "n", "q", "Q", "Esc"]), + Shortcut::new("Abort", ["N", "n", "q", "Esc"]), Shortcut::new("Scroll up", ["k"]), Shortcut::new("Scroll down", ["j"]), Shortcut::new("Close linutil", ["CTRL-c"]), From aa9850766bc208fbdab556b935e100ed90b680be Mon Sep 17 00:00:00 2001 From: nyx Date: Mon, 7 Oct 2024 18:52:23 -0400 Subject: [PATCH 3/3] add ``ctrl + c`` exiting Co-authored-by: Adam Perkowski --- tui/src/state.rs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/tui/src/state.rs b/tui/src/state.rs index 6f8bef83..b4b7ddb6 100644 --- a/tui/src/state.rs +++ b/tui/src/state.rs @@ -418,6 +418,12 @@ impl AppState { return false; } + if matches!(self.focus, Focus::ConfirmationPrompt(_)) + && (key.modifiers.contains(KeyModifiers::CONTROL) && key.code == KeyCode::Char('c')) + { + return false; + } + // If UI is not drawable returning true will mark as the key handled if !self.drawable { return true;