Skip to content

Commit afb86a0

Browse files
committed
Make Esc-to-quit configurable via esc_quit setting. Set to false by default.
1 parent 31bae3d commit afb86a0

File tree

3 files changed

+14
-2
lines changed

3 files changed

+14
-2
lines changed

Readme.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ This will produce an executable file at `target/release/bluetui` that you can co
7777

7878
`s`: Start/Stop scanning.
7979

80-
`ctrl+c` or `q` or `<Esc>`: Quit the app.
80+
`ctrl+c` or `q`: Quit the app. (Note: `<Esc>` can also quit if `esc_quit = true` is set in config)
8181

8282
### Adapters
8383

@@ -114,6 +114,7 @@ layout = "SpaceAround"
114114
width = "auto"
115115

116116
toggle_scanning = "s"
117+
esc_quit = false # Set to true to enable Esc key to quit the app
117118

118119
[adapter]
119120
toggle_pairing = "p"

src/config.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,9 @@ pub struct Config {
2121
#[serde(default = "default_toggle_scanning")]
2222
pub toggle_scanning: char,
2323

24+
#[serde(default = "default_esc_quit")]
25+
pub esc_quit: bool,
26+
2427
#[serde(default)]
2528
pub adapter: Adapter,
2629

@@ -166,6 +169,10 @@ fn default_toggle_scanning() -> char {
166169
's'
167170
}
168171

172+
fn default_esc_quit() -> bool {
173+
false
174+
}
175+
169176
fn default_toggle_adapter_pairing() -> char {
170177
'p'
171178
}

src/handler.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -264,7 +264,11 @@ pub async fn handle_key_events(
264264
app.quit();
265265
}
266266

267-
KeyCode::Char('q') | KeyCode::Esc => {
267+
KeyCode::Char('q') => {
268+
app.quit();
269+
}
270+
271+
KeyCode::Esc if app.config.esc_quit => {
268272
app.quit();
269273
}
270274

0 commit comments

Comments
 (0)