Fix mouse scrolling in windows

This commit is contained in:
Clement Tsang 2020-01-02 22:54:39 -05:00
parent 4ae2882aa6
commit 7b902a9470
4 changed files with 18 additions and 11 deletions

View file

@ -2,6 +2,7 @@
"cSpell.words": [
"AHHHHHH",
"Dataset",
"Ryzen",
"Tebibyte",
"avgcpu",
"backend",

View file

@ -24,7 +24,6 @@ futures-timer = "2.0.2"
futures = "0.3.1"
heim = "0.0.9"
log = "0.4"
rayon = "1.3"
regex = "1.3.1"
sysinfo = "0.9" #0.9 seems to be the last working version for my Ryzen PC...
tokio = "0.2.6"

View file

@ -20,6 +20,8 @@ You can currently install by cloning and building yourself using `cargo build --
macOS support will hopefully come soon<sup>TM</sup>.
## Compatibility
The compatibility of each widget and operating systems are, as of version 0.1.0, as follows:
| OS/Widget | CPU | Memory | Disks | Temperature | Processes | Networks |
@ -110,3 +112,4 @@ The compatibility of each widget and operating systems are, as of version 0.1.0,
- [tokio](https://github.com/tokio-rs/tokio)
- [tui-rs](https://github.com/fdehau/tui-rs)
- [winapi](https://github.com/retep998/winapi-rs)
- [lazy_static](https://github.com/rust-lang-nursery/lazy-static.rs)

View file

@ -8,7 +8,7 @@ extern crate failure;
extern crate lazy_static;
use crossterm::{
event::{self, Event as CEvent, KeyCode, KeyEvent, KeyModifiers, MouseEvent},
event::{self, DisableMouseCapture, EnableMouseCapture, Event as CEvent, KeyCode, KeyEvent, KeyModifiers, MouseEvent},
execute,
terminal::LeaveAlternateScreen,
terminal::{disable_raw_mode, enable_raw_mode, EnterAlternateScreen},
@ -124,10 +124,9 @@ fn main() -> error::Result<()> {
let mut stdout = stdout();
enable_raw_mode()?;
execute!(stdout, EnterAlternateScreen)?;
execute!(stdout, EnableMouseCapture)?;
let backend = CrosstermBackend::new(stdout);
let mut terminal = Terminal::new(backend)?;
let mut terminal = Terminal::new(CrosstermBackend::new(stdout))?;
terminal.hide_cursor()?;
terminal.clear()?;
@ -304,16 +303,21 @@ fn main() -> error::Result<()> {
}
// Draw!
if let Err(err) = canvas::draw_data(&mut terminal, &mut app) {
disable_raw_mode()?;
execute!(terminal.backend_mut(), LeaveAlternateScreen)?;
terminal.show_cursor()?;
cleanup(&mut terminal)?;
error!("{}", err);
return Err(err);
}
}
disable_raw_mode()?;
execute!(terminal.backend_mut(), LeaveAlternateScreen)?;
terminal.show_cursor()?;
cleanup(&mut terminal)?;
Ok(())
}
fn cleanup(terminal: &mut tui::terminal::Terminal<tui::backend::CrosstermBackend<std::io::Stdout>>) -> error::Result<()> {
disable_raw_mode()?;
execute!(terminal.backend_mut(), DisableMouseCapture)?;
execute!(terminal.backend_mut(), LeaveAlternateScreen)?;
terminal.show_cursor()?;
Ok(())
}