From b31763db98e37eaef6ae0231f31796a6cfb788b5 Mon Sep 17 00:00:00 2001 From: Canop Date: Wed, 15 Jan 2025 21:16:47 +0100 Subject: [PATCH 1/2] update changelog --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 93060e0..6d653cd 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,7 @@ ### next - with `--headless`, bacon runs without TUI - Fix #293 - `--config-toml` argument - Fix #284 +- fix workspace level Cargo.toml file not watched ### v3.7.0 - 2024/12/27 From 2eec8c26c72a0cd964eae5b6aba588862fb3eaae Mon Sep 17 00:00:00 2001 From: Canop Date: Wed, 15 Jan 2025 21:17:49 +0100 Subject: [PATCH 2/2] fix middle click sending bacon to outer heaven This makes bacon handle mouse events. Downsides: - potential regression for users pasting with middle click - major regression for users selecting and copying with the mouse - not using the scroll multiplier defined OS wide Fix #298 --- src/app.rs | 25 +++++++++++-------------- src/cli.rs | 12 ++++-------- 2 files changed, 15 insertions(+), 22 deletions(-) diff --git a/src/app.rs b/src/app.rs index 6b16cf1..9818965 100644 --- a/src/app.rs +++ b/src/app.rs @@ -11,16 +11,11 @@ use { EventSourceOptions, Ticker, crossbeam::channel::select, - crossterm::event::Event, - }, -}; - -#[cfg(windows)] -use { - crokey::key, - termimad::crossterm::event::{ - MouseEvent, - MouseEventKind, + crossterm::event::{ + Event, + MouseEvent, + MouseEventKind, + }, }, }; @@ -102,6 +97,9 @@ fn run_mission( headless: bool, ) -> Result { let keybindings = mission.settings.keybindings.clone(); + let scroll_multiplier = 3; // TODO can we read the OS setting? + let wheel_down = Internal::Scroll(ScrollCommand::Lines(scroll_multiplier)).into(); + let wheel_up = Internal::Scroll(ScrollCommand::Lines(-scroll_multiplier)).into(); // build the watcher detecting and transmitting mission file changes let ignorer = time!(Info, mission.ignorer()); @@ -204,6 +202,7 @@ fn run_mission( } } recv(user_events) -> user_event => { + info!("user event received: {:#?}", user_event); match user_event?.event { Event::Resize(mut width, mut height) => { state.resize(width, height); @@ -215,13 +214,11 @@ fn run_mission( action = keybindings.get(key_combination); } } - #[cfg(windows)] Event::Mouse(MouseEvent { kind: MouseEventKind::ScrollDown, .. }) => { - action = keybindings.get(key!(down)); + action = Some(&wheel_down); } - #[cfg(windows)] Event::Mouse(MouseEvent { kind: MouseEventKind::ScrollUp, .. }) => { - action = keybindings.get(key!(up)); + action = Some(&wheel_up); } _ => {} } diff --git a/src/cli.rs b/src/cli.rs index 9977367..d7f5335 100644 --- a/src/cli.rs +++ b/src/cli.rs @@ -9,18 +9,16 @@ use { termimad::crossterm::{ QueueableCommand, cursor, + event::{ + DisableMouseCapture, + EnableMouseCapture, + }, terminal::{ EnterAlternateScreen, LeaveAlternateScreen, }, }, }; - -#[cfg(windows)] -use termimad::crossterm::event::{ - DisableMouseCapture, - EnableMouseCapture, -}; /// The Write type used by all GUI writing functions pub type W = std::io::BufWriter; @@ -85,13 +83,11 @@ pub fn run() -> anyhow::Result<()> { if !headless { w.queue(EnterAlternateScreen)?; w.queue(cursor::Hide)?; - #[cfg(windows)] w.queue(EnableMouseCapture)?; w.flush()?; } let result = app::run(&mut w, settings, &args, context, headless); if !headless { - #[cfg(windows)] w.queue(DisableMouseCapture)?; w.queue(cursor::Show)?; w.queue(LeaveAlternateScreen)?;