From 5233df7325659d2772ce02c73adbae9e7d14b234 Mon Sep 17 00:00:00 2001 From: 依云 Date: Fri, 3 Apr 2026 07:52:45 +0800 Subject: feat: option to disable mouse support (#3372) ## Checks - [x] I am happy for maintainers to push small adjustments to this PR, to speed up the review cycle - [x] I have checked that there are no existing pull requests for the same thing This adds an option to disable mouse support, so that the terminal handles mouse events, making it easy to select text. I've found myself needing to copy from history frequently recently and holding Shift is not convenient. However, this makes mouse scrolling not work as expected, e.g. in my case it scrolls six lines at a time. Also see #1209. --- crates/atuin-client/src/settings.rs | 2 ++ .../atuin/src/command/client/search/interactive.rs | 26 +++++++++++----------- 2 files changed, 15 insertions(+), 13 deletions(-) (limited to 'crates') diff --git a/crates/atuin-client/src/settings.rs b/crates/atuin-client/src/settings.rs index 78953320..22b892d1 100644 --- a/crates/atuin-client/src/settings.rs +++ b/crates/atuin-client/src/settings.rs @@ -1094,6 +1094,7 @@ pub struct Settings { pub history_format: String, pub prefers_reduced_motion: bool, pub store_failed: bool, + pub no_mouse: bool, #[serde(with = "serde_regex", default = "RegexSet::empty", skip_serializing)] pub history_filter: RegexSet, @@ -1563,6 +1564,7 @@ impl Settings { .map(|_| config::Value::new(None, config::ValueKind::Boolean(true))) .unwrap_or_else(|| config::Value::new(None, config::ValueKind::Boolean(false))), )? + .set_default("no_mouse", false)? .add_source( Environment::with_prefix("atuin") .prefix_separator("_") diff --git a/crates/atuin/src/command/client/search/interactive.rs b/crates/atuin/src/command/client/search/interactive.rs index a0b1fe31..8e5f8551 100644 --- a/crates/atuin/src/command/client/search/interactive.rs +++ b/crates/atuin/src/command/client/search/interactive.rs @@ -1490,10 +1490,11 @@ fn restore_popup_area(saved: &SavedScreen, popup_rect: Rect, scroll_offset: u16) struct Stdout { writer: TerminalWriter, inline_mode: bool, + no_mouse: bool, } impl Stdout { - pub fn new(inline_mode: bool) -> std::io::Result { + pub fn new(inline_mode: bool, no_mouse: bool) -> std::io::Result { terminal::enable_raw_mode()?; let mut writer = TerminalWriter::new()?; @@ -1502,11 +1503,11 @@ impl Stdout { execute!(writer, terminal::EnterAlternateScreen)?; } - execute!( - writer, - event::EnableMouseCapture, - event::EnableBracketedPaste, - )?; + if !no_mouse { + execute!(writer, event::EnableMouseCapture)?; + } + + execute!(writer, event::EnableBracketedPaste)?; #[cfg(not(target_os = "windows"))] execute!( @@ -1521,6 +1522,7 @@ impl Stdout { Ok(Self { writer, inline_mode, + no_mouse, }) } } @@ -1533,12 +1535,10 @@ impl Drop for Stdout { if !self.inline_mode { execute!(self.writer, terminal::LeaveAlternateScreen).unwrap(); } - execute!( - self.writer, - event::DisableMouseCapture, - event::DisableBracketedPaste, - ) - .unwrap(); + if !self.no_mouse { + execute!(self.writer, event::DisableMouseCapture).unwrap(); + } + execute!(self.writer, event::DisableBracketedPaste).unwrap(); terminal::disable_raw_mode().unwrap(); } @@ -1667,7 +1667,7 @@ pub async fn history( let popup_mode = saved_screen.is_some(); - let stdout = Stdout::new(inline_height > 0)?; + let stdout = Stdout::new(inline_height > 0, settings.no_mouse)?; // In popup mode, clear the popup region on the physical terminal before // ratatui takes over. Ratatui's diff-based rendering compares against an -- cgit v1.3.1