summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorCanop <cano.petrole@gmail.com>2022-03-27 08:23:44 +0200
committerCanop <cano.petrole@gmail.com>2022-03-27 08:23:44 +0200
commit68ca143c0d8f5a8b871cafc7e283423a113f6959 (patch)
tree40a3284e25f63d3bc2801cbd4ca9d1b5eb53cbf8 /src
parentf9fe6efebf3ce4e32d93705db8decc2019f7112f (diff)
add the (already documented) capture_mouse conf item
See https://github.com/Canop/broot/issues/238
Diffstat (limited to 'src')
-rw-r--r--src/app/app_context.rs10
-rw-r--r--src/cli/mod.rs5
-rw-r--r--src/conf/conf.rs5
-rw-r--r--src/launchable.rs10
4 files changed, 20 insertions, 10 deletions
diff --git a/src/app/app_context.rs b/src/app/app_context.rs
index adb27ad..542b422 100644
--- a/src/app/app_context.rs
+++ b/src/app/app_context.rs
@@ -61,7 +61,8 @@ pub struct AppContext {
/// modal (aka "vim) mode enabled
pub modal: bool,
- pub mouse_capture_disabled: bool,
+ /// Whether to support mouse interactions
+ pub capture_mouse: bool,
/// max number of panels (including preview) that can be
/// open. Guaranteed to be at least 2.
@@ -110,6 +111,11 @@ impl AppContext {
let max_panels_count = config.max_panels_count
.unwrap_or(2)
.clamp(2, 100);
+ let capture_mouse = match (config.capture_mouse, config.disable_mouse_capture) {
+ (Some(b), _) => b, // the new "capture_mouse" argument takes precedence
+ (_, Some(b)) => !b,
+ _ => true,
+ };
Ok(Self {
config_paths,
launch_args,
@@ -123,7 +129,7 @@ impl AppContext {
true_colors,
icons,
modal: config.modal.unwrap_or(false),
- mouse_capture_disabled: config.disable_mouse_capture.unwrap_or(false),
+ capture_mouse,
max_panels_count,
quit_on_last_cancel: config.quit_on_last_cancel.unwrap_or(false),
file_sum_threads_count,
diff --git a/src/cli/mod.rs b/src/cli/mod.rs
index 6c72b1b..3bc64c5 100644
--- a/src/cli/mod.rs
+++ b/src/cli/mod.rs
@@ -190,12 +190,11 @@ pub fn run() -> Result<Option<Launchable>, ProgramError> {
let app = App::new(&context)?;
w.queue(EnterAlternateScreen)?;
w.queue(cursor::Hide)?;
- let capture_mouse = config.disable_mouse_capture != Some(true);
- if capture_mouse {
+ if context.capture_mouse {
w.queue(EnableMouseCapture)?;
}
let r = app.run(&mut w, &context, &config);
- if capture_mouse {
+ if context.capture_mouse {
w.queue(DisableMouseCapture)?;
}
w.queue(cursor::Show)?;
diff --git a/src/conf/conf.rs b/src/conf/conf.rs
index dde306c..f94db83 100644
--- a/src/conf/conf.rs
+++ b/src/conf/conf.rs
@@ -59,9 +59,13 @@ pub struct Conf {
#[serde(alias="search-modes")]
pub search_modes: Option<FnvHashMap<String, String>>,
+ /// Obsolete, kept for compatibility: you should now use capture_mouse
#[serde(alias="disable-mouse-capture")]
pub disable_mouse_capture: Option<bool>,
+ #[serde(alias="capture-mouse")]
+ pub capture_mouse: Option<bool>,
+
#[serde(alias="cols-order")]
pub cols_order: Option<ColsConf>,
@@ -147,6 +151,7 @@ impl Conf {
overwrite!(self, icon_theme, conf);
overwrite!(self, syntax_theme, conf);
overwrite!(self, disable_mouse_capture, conf);
+ overwrite!(self, capture_mouse, conf);
overwrite!(self, true_colors, conf);
overwrite!(self, show_selection_mark, conf);
overwrite!(self, cols_order, conf);
diff --git a/src/launchable.rs b/src/launchable.rs
index 7c602d0..9378cb2 100644
--- a/src/launchable.rs
+++ b/src/launchable.rs
@@ -52,7 +52,7 @@ pub enum Launchable {
exe: String,
args: Vec<String>,
working_dir: Option<PathBuf>,
- mouse_capture_disabled: bool,
+ capture_mouse: bool,
},
/// open a path
@@ -110,7 +110,7 @@ impl Launchable {
exe,
args: parts.collect(),
working_dir,
- mouse_capture_disabled: con.mouse_capture_disabled,
+ capture_mouse: con.capture_mouse,
}),
None => Err(io::Error::new(io::ErrorKind::Other, "Empty launch string")),
}
@@ -133,7 +133,7 @@ impl Launchable {
working_dir,
exe,
args,
- mouse_capture_disabled,
+ capture_mouse,
} => {
debug!("working_dir: {:?}", &working_dir);
// we restore the normal terminal in case the executable
@@ -143,7 +143,7 @@ impl Launchable {
if let Some(ref mut w) = &mut w {
w.queue(cursor::Show).unwrap();
w.queue(LeaveAlternateScreen).unwrap();
- if !mouse_capture_disabled {
+ if *capture_mouse {
w.queue(DisableMouseCapture).unwrap();
}
terminal::disable_raw_mode().unwrap();
@@ -164,7 +164,7 @@ impl Launchable {
});
if let Some(ref mut w) = &mut w {
terminal::enable_raw_mode().unwrap();
- if !mouse_capture_disabled {
+ if *capture_mouse {
w.queue(EnableMouseCapture).unwrap();
}
w.queue(EnterAlternateScreen).unwrap();