mirror of
https://github.com/pythops/bluetui.git
synced 2026-05-06 13:31:35 +08:00
Binds <Esc> to quit in contexts where q or ctrl+c is accepted as quit (#98)
This commit is contained in:
@@ -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"
|
||||
|
||||
@@ -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'
|
||||
}
|
||||
|
||||
@@ -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 => {
|
||||
|
||||
Reference in New Issue
Block a user