allow scrolling with mouse

This commit is contained in:
figsoda 2020-11-01 14:10:14 -05:00
parent d5cd92ae3a
commit 1aedeb45c3

View file

@ -8,7 +8,7 @@ mod mpd;
use anyhow::{Context, Error, Result}; use anyhow::{Context, Error, Result};
use crossterm::{ use crossterm::{
event::{self, DisableMouseCapture, EnableMouseCapture, Event, KeyCode, KeyEvent}, event::{self, DisableMouseCapture, EnableMouseCapture, Event, KeyCode, KeyEvent, MouseEvent},
execute, execute,
terminal::{disable_raw_mode, enable_raw_mode, EnterAlternateScreen, LeaveAlternateScreen}, terminal::{disable_raw_mode, enable_raw_mode, EnterAlternateScreen, LeaveAlternateScreen},
}; };
@ -149,7 +149,15 @@ async fn run() -> Result<()> {
} }
_ => (), _ => (),
}, },
Event::Resize(..) => tx.send(Command::UpdateFrame).await.unwrap_or_else(die), Event::Mouse(MouseEvent::ScrollDown(..)) => {
tx.send(Command::Down).await.unwrap_or_else(die);
}
Event::Mouse(MouseEvent::ScrollUp(..)) => {
tx.send(Command::Up).await.unwrap_or_else(die);
}
Event::Resize(..) => {
tx.send(Command::UpdateFrame).await.unwrap_or_else(die);
}
_ => (), _ => (),
} }
} }