Compare commits

...

4 Commits

Author SHA1 Message Date
nyx
20548704c5
Merge aa9850766b into 79eb752552 2024-10-08 23:40:02 +01:00
nyx
aa9850766b
add `ctrl + c` exiting
Co-authored-by: Adam Perkowski <adas1per@protonmail.com>
2024-10-07 19:08:37 -04:00
nyx
596467f155
remove cap support 2024-10-05 03:25:41 -04:00
nyx
c6850fb463
do not exit linutil in confirmation prompt when q is pressed 2024-10-04 10:30:41 -04:00
2 changed files with 14 additions and 10 deletions

View File

@ -88,7 +88,7 @@ impl FloatContent for ConfirmPrompt {
use KeyCode::*; use KeyCode::*;
self.status = match key.code { self.status = match key.code {
Char('y') | Char('Y') => ConfirmStatus::Confirm, Char('y') | Char('Y') => ConfirmStatus::Confirm,
Char('n') | Char('N') | Esc => ConfirmStatus::Abort, Char('n') | Char('N') | Esc | Char('q') => ConfirmStatus::Abort,
Char('j') => { Char('j') => {
self.scroll_down(); self.scroll_down();
ConfirmStatus::None ConfirmStatus::None
@ -116,10 +116,10 @@ impl FloatContent for ConfirmPrompt {
"Confirmation prompt", "Confirmation prompt",
Box::new([ Box::new([
Shortcut::new("Continue", ["Y", "y"]), Shortcut::new("Continue", ["Y", "y"]),
Shortcut::new("Abort", ["N", "n"]), Shortcut::new("Abort", ["N", "n", "q", "Esc"]),
Shortcut::new("Scroll up", ["j"]), Shortcut::new("Scroll up", ["k"]),
Shortcut::new("Scroll down", ["k"]), Shortcut::new("Scroll down", ["j"]),
Shortcut::new("Close linutil", ["CTRL-c", "q"]), Shortcut::new("Close linutil", ["CTRL-c"]),
]), ]),
) )
} }

View File

@ -410,11 +410,15 @@ impl AppState {
// This should be defined first to allow closing // This should be defined first to allow closing
// the application even when not drawable ( If terminal is small ) // the application even when not drawable ( If terminal is small )
// Exit on 'q' or 'Ctrl-c' input // Exit on 'q' or 'Ctrl-c' input
if matches!( if matches!(self.focus, Focus::TabList | Focus::List)
self.focus, && (key.code == KeyCode::Char('q')
Focus::TabList | Focus::List | Focus::ConfirmationPrompt(_) || key.modifiers.contains(KeyModifiers::CONTROL) && key.code == KeyCode::Char('c'))
) && (key.code == KeyCode::Char('q') {
|| key.modifiers.contains(KeyModifiers::CONTROL) && key.code == KeyCode::Char('c')) return false;
}
if matches!(self.focus, Focus::ConfirmationPrompt(_))
&& (key.modifiers.contains(KeyModifiers::CONTROL) && key.code == KeyCode::Char('c'))
{ {
return false; return false;
} }