From 4b0b9265ee8e64a9ea82263560758e146eda4aca Mon Sep 17 00:00:00 2001 From: Alexandre Bury Date: Mon, 10 Feb 2020 09:53:14 -0800 Subject: [PATCH] Crossterm: use button from upstream rather than last_button --- src/backend/crossterm.rs | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/src/backend/crossterm.rs b/src/backend/crossterm.rs index 86ef78c..d976130 100644 --- a/src/backend/crossterm.rs +++ b/src/backend/crossterm.rs @@ -44,7 +44,6 @@ type Stdout = File; /// Backend using crossterm pub struct Backend { current_style: Cell, - last_button: Option, stdout: RefCell>, } @@ -218,7 +217,6 @@ impl Backend { Ok(Box::new(Backend { current_style: Cell::new(theme::ColorPair::from_256colors(0, 0)), - last_button: None, stdout, })) } @@ -250,16 +248,17 @@ impl Backend { match mouse_event { CMouseEvent::Down(button, x, y, _) => { let button = MouseButton::from(button); - self.last_button = Some(button); event = MouseEvent::Press(button); position = (x, y).into(); } - CMouseEvent::Up(_, x, y, _) => { - event = MouseEvent::Release(self.last_button.unwrap()); + CMouseEvent::Up(button, x, y, _) => { + let button = MouseButton::from(button); + event = MouseEvent::Release(button); position = (x, y).into(); } - CMouseEvent::Drag(_, x, y, _) => { - event = MouseEvent::Hold(self.last_button.unwrap()); + CMouseEvent::Drag(button, x, y, _) => { + let button = MouseButton::from(button); + event = MouseEvent::Hold(button); position = (x, y).into(); } CMouseEvent::ScrollDown(x, y, _) => {