diff --git a/src/app.rs b/src/app.rs index 91c1800..a70a386 100644 --- a/src/app.rs +++ b/src/app.rs @@ -9,6 +9,13 @@ use { termimad::crossterm::event::Event, termimad::EventSource, }; +#[cfg(windows)] +use termimad::crossterm::event::{ + MouseEventKind, + KeyCode, + KeyEvent, + KeyModifiers, +}; /// Run the mission and return the reference to the next /// job to run, if any @@ -77,6 +84,17 @@ pub fn run( debug!("key pressed: {}", CroKey::from(key_event)); action = keybindings.get(key_event); } + #[cfg(windows)] + Event::Mouse(mouse_event) => { + let key_code = + match mouse_event.kind { + MouseEventKind::ScrollDown => {KeyCode::Down} + MouseEventKind::ScrollUp => {KeyCode::Up} + _ => {KeyCode::Null} + }; + action = keybindings.get(KeyEvent::new(key_code,KeyModifiers::NONE)); + } + #[cfg(not(windows))] _ => {} } event_source.unblock(false); diff --git a/src/cli.rs b/src/cli.rs index 3cde46c..e472dc1 100644 --- a/src/cli.rs +++ b/src/cli.rs @@ -17,6 +17,11 @@ use { termimad::EventSource, }; +#[cfg(windows)] +use termimad::crossterm::event::{ + EnableMouseCapture, + DisableMouseCapture, +}; /// The Write type used by all GUI writing functions pub type W = std::io::BufWriter; @@ -106,6 +111,8 @@ pub fn run() -> anyhow::Result<()> { let mut w = writer(); w.queue(EnterAlternateScreen)?; w.queue(cursor::Hide)?; + #[cfg(windows)] + w.queue(EnableMouseCapture)?; let event_source = EventSource::new()?; let mut job_stack = JobStack::new(&settings); @@ -141,6 +148,8 @@ pub fn run() -> anyhow::Result<()> { w.queue(cursor::Show)?; w.queue(LeaveAlternateScreen)?; + #[cfg(windows)] + w.queue(DisableMouseCapture)?; w.flush()?; result }