feat(bin): Quit on 'q' across all commands

This commit is contained in:
Erik Kundt
2025-01-29 13:33:10 +01:00
parent 0e7579b783
commit 2d4a06d9fa
4 changed files with 15 additions and 11 deletions
+4 -3
View File
@@ -340,7 +340,7 @@ fn browser_page(_state: &State, channel: &Channel<Message>) -> Widget<State, Mes
if props.handle_keys {
match key {
Key::Esc | Key::Ctrl('c') => Some(Message::Exit { selection: None }),
Key::Char('q') | Key::Ctrl('c') => Some(Message::Exit { selection: None }),
Key::Char('?') => Some(Message::OpenHelp),
_ => None,
}
@@ -413,7 +413,7 @@ fn help_page(_state: &State, channel: &Channel<Message>) -> Widget<State, Messag
.shortcuts(shortcuts)
.to_widget(tx.clone())
.on_event(|key, _, _| match key {
Key::Esc | Key::Ctrl('c') => Some(Message::Exit { selection: None }),
Key::Char('q') | Key::Ctrl('c') => Some(Message::Exit { selection: None }),
Key::Char('?') => Some(Message::LeavePage),
_ => None,
})
@@ -429,7 +429,8 @@ fn help_text() -> String {
`PageDown`: move cursor one page down
`Home`: move cursor to the first line
`End`: move cursor to the last line
`Esc`: Quit / cancel
`Esc`: Cancel
`q`: Quit
# Specific keybindings
+4 -3
View File
@@ -438,7 +438,7 @@ fn browser_page(channel: &Channel<Message>) -> Widget<State, Message> {
if props.handle_keys {
match key {
Key::Esc | Key::Ctrl('c') => Some(Message::Quit),
Key::Char('q') | Key::Ctrl('c') => Some(Message::Quit),
Key::Char('p') => Some(Message::TogglePreview),
Key::Char('?') => Some(Message::OpenHelp),
Key::Char('\n') => Some(Message::ExitFromMode),
@@ -644,7 +644,7 @@ fn help_page(channel: &Channel<Message>) -> Widget<State, Message> {
.shortcuts(shortcuts)
.to_widget(tx.clone())
.on_event(|key, _, _| match key {
Key::Esc | Key::Ctrl('c') => Some(Message::Quit),
Key::Char('q') | Key::Ctrl('c') => Some(Message::Quit),
Key::Char('?') => Some(Message::LeavePage),
_ => None,
})
@@ -662,7 +662,8 @@ fn help_text() -> String {
`End`: move cursor to the last line
`Tab`: focus next section
`BackTab`: focus previous section
`Esc`: Quit / cancel
`Esc`: Cancel
`q`: Quit
# Specific keybindings
+3 -2
View File
@@ -257,7 +257,7 @@ fn browser_page(_state: &State, channel: &Channel<Message>) -> Widget<State, Mes
if props.handle_keys {
match key {
Key::Esc | Key::Ctrl('c') => Some(Message::Quit),
Key::Char('q') | Key::Ctrl('c') => Some(Message::Quit),
Key::Char('?') => Some(Message::OpenHelp),
Key::Char('\n') => Some(Message::ExitFromMode),
Key::Char('c') => Some(Message::Exit {
@@ -354,7 +354,8 @@ fn help_text() -> String {
`PageDown`: move cursor one page down
`Home`: move cursor to the first line
`End`: move cursor to the last line
`Esc`: Quit / cancel
`Esc`: Cancel
`q`: Quit
# Specific keybindings
+4 -3
View File
@@ -32,7 +32,8 @@ const HELP: &str = r#"# Generic keybindings
`PageDown`: move cursor one page down
`Home`: move cursor to the first line
`End`: move cursor to the last line
`Esc`: Quit / cancel
`Esc`: Cancel
`q`: Quit
# Specific keybindings
@@ -285,7 +286,7 @@ impl Show<Message> for App {
);
});
if ui.input_global(|key| key == Key::Esc) {
if ui.input_global(|key| key == Key::Char('q')) {
ui.send_message(Message::Quit);
}
if ui.input_global(|key| key == Key::Char('?')) {
@@ -366,7 +367,7 @@ impl Show<Message> for App {
if ui.input_global(|key| key == Key::Char('?')) {
ui.send_message(Message::PageChanged { page: Page::Main });
}
if ui.input_global(|key| key == Key::Esc) {
if ui.input_global(|key| key == Key::Char('q')) {
ui.send_message(Message::Quit);
}
}