diff options
author | Canop <cano.petrole@gmail.com> | 2021-05-06 21:52:07 +0200 |
---|---|---|
committer | Canop <cano.petrole@gmail.com> | 2021-05-06 21:54:18 +0200 |
commit | 6c4b5ced881851ab38e65061c46ea0760ed9c384 (patch) | |
tree | 5d09a79bc56dbc956aeb3bfe899dfe6d5d578dbf /src/app | |
parent | f339c301135fd45db8827515a1929fab81ba13af (diff) |
config / quit_on_last_cancel
configure whether to quit when the user hits the escape
key and there's nothing to cancel
Fix #380
Diffstat (limited to 'src/app')
-rw-r--r-- | src/app/app.rs | 6 | ||||
-rw-r--r-- | src/app/app_context.rs | 5 |
2 files changed, 7 insertions, 4 deletions
diff --git a/src/app/app.rs b/src/app/app.rs index 63a2274..9dbab9c 100644 --- a/src/app/app.rs +++ b/src/app/app.rs @@ -26,8 +26,6 @@ use { termimad::{Event, EventSource}, }; -const ESCAPE_TO_QUIT: bool = false; - #[cfg(feature = "client-server")] use std::sync::{Arc, Mutex}; @@ -419,7 +417,7 @@ impl App { if self.remove_state() { self.mut_state().refresh(app_cmd_context.screen, con); self.mut_panel().refresh_input_status(app_state, &app_cmd_context); - } else if ESCAPE_TO_QUIT { + } else if con.quit_on_last_cancel { self.quitting = true; } } @@ -437,7 +435,7 @@ impl App { con, }; self.mut_panel().apply_command(w, &cmd, app_state, &app_cmd_context)?; - } else if ESCAPE_TO_QUIT { + } else if con.quit_on_last_cancel { self.quitting = true; } } diff --git a/src/app/app_context.rs b/src/app/app_context.rs index 55bf296..7af3502 100644 --- a/src/app/app_context.rs +++ b/src/app/app_context.rs @@ -65,6 +65,10 @@ pub struct AppContext { /// max number of panels (including preview) that can be /// open. Guaranteed to be at least 2. pub max_panels_count: usize, + + /// whether to quit broot when the user hits "escape" + /// and there's nothing to cancel + pub quit_on_last_cancel: bool, } impl AppContext { @@ -111,6 +115,7 @@ impl AppContext { modal: config.modal.unwrap_or(false), mouse_capture_disabled: config.disable_mouse_capture.unwrap_or(false), max_panels_count, + quit_on_last_cancel: config.quit_on_last_cancel.unwrap_or(false), }) } } |