Binds <Esc> to quit in contexts where q or ctrl+c is accepted as quit (#98)

This commit is contained in:
Jeff Nunn
2025-11-22 16:05:45 -06:00
committed by GitHub
parent b6427dfd77
commit 6cd286fd66
3 changed files with 13 additions and 1 deletions

View File

@@ -77,7 +77,7 @@ This will produce an executable file at `target/release/bluetui` that you can co
`s`: Start/Stop scanning.
`ctrl+c` or `q`: Quit the app.
`ctrl+c` or `q`: Quit the app. (Note: `<Esc>` can also quit if `esc_quit = true` is set in config)
### Adapters
@@ -114,6 +114,7 @@ layout = "SpaceAround"
width = "auto"
toggle_scanning = "s"
esc_quit = false # Set to true to enable Esc key to quit the app
[adapter]
toggle_pairing = "p"

View File

@@ -21,6 +21,9 @@ pub struct Config {
#[serde(default = "default_toggle_scanning")]
pub toggle_scanning: char,
#[serde(default = "default_esc_quit")]
pub esc_quit: bool,
#[serde(default)]
pub adapter: Adapter,
@@ -166,6 +169,10 @@ fn default_toggle_scanning() -> char {
's'
}
fn default_esc_quit() -> bool {
false
}
fn default_toggle_adapter_pairing() -> char {
'p'
}

View File

@@ -268,6 +268,10 @@ pub async fn handle_key_events(
app.quit();
}
KeyCode::Esc if app.config.esc_quit => {
app.quit();
}
// Switch focus
KeyCode::Tab | KeyCode::Char('l') => match app.focused_block {
FocusedBlock::Adapter => {