Fix mouse scrolling in windows
This commit is contained in:
parent
4ae2882aa6
commit
7b902a9470
|
@ -2,6 +2,7 @@
|
||||||
"cSpell.words": [
|
"cSpell.words": [
|
||||||
"AHHHHHH",
|
"AHHHHHH",
|
||||||
"Dataset",
|
"Dataset",
|
||||||
|
"Ryzen",
|
||||||
"Tebibyte",
|
"Tebibyte",
|
||||||
"avgcpu",
|
"avgcpu",
|
||||||
"backend",
|
"backend",
|
||||||
|
|
|
@ -24,7 +24,6 @@ futures-timer = "2.0.2"
|
||||||
futures = "0.3.1"
|
futures = "0.3.1"
|
||||||
heim = "0.0.9"
|
heim = "0.0.9"
|
||||||
log = "0.4"
|
log = "0.4"
|
||||||
rayon = "1.3"
|
|
||||||
regex = "1.3.1"
|
regex = "1.3.1"
|
||||||
sysinfo = "0.9" #0.9 seems to be the last working version for my Ryzen PC...
|
sysinfo = "0.9" #0.9 seems to be the last working version for my Ryzen PC...
|
||||||
tokio = "0.2.6"
|
tokio = "0.2.6"
|
||||||
|
|
|
@ -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>.
|
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:
|
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 |
|
| 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)
|
- [tokio](https://github.com/tokio-rs/tokio)
|
||||||
- [tui-rs](https://github.com/fdehau/tui-rs)
|
- [tui-rs](https://github.com/fdehau/tui-rs)
|
||||||
- [winapi](https://github.com/retep998/winapi-rs)
|
- [winapi](https://github.com/retep998/winapi-rs)
|
||||||
|
- [lazy_static](https://github.com/rust-lang-nursery/lazy-static.rs)
|
||||||
|
|
24
src/main.rs
24
src/main.rs
|
@ -8,7 +8,7 @@ extern crate failure;
|
||||||
extern crate lazy_static;
|
extern crate lazy_static;
|
||||||
|
|
||||||
use crossterm::{
|
use crossterm::{
|
||||||
event::{self, Event as CEvent, KeyCode, KeyEvent, KeyModifiers, MouseEvent},
|
event::{self, DisableMouseCapture, EnableMouseCapture, Event as CEvent, KeyCode, KeyEvent, KeyModifiers, MouseEvent},
|
||||||
execute,
|
execute,
|
||||||
terminal::LeaveAlternateScreen,
|
terminal::LeaveAlternateScreen,
|
||||||
terminal::{disable_raw_mode, enable_raw_mode, EnterAlternateScreen},
|
terminal::{disable_raw_mode, enable_raw_mode, EnterAlternateScreen},
|
||||||
|
@ -124,10 +124,9 @@ fn main() -> error::Result<()> {
|
||||||
let mut stdout = stdout();
|
let mut stdout = stdout();
|
||||||
enable_raw_mode()?;
|
enable_raw_mode()?;
|
||||||
execute!(stdout, EnterAlternateScreen)?;
|
execute!(stdout, EnterAlternateScreen)?;
|
||||||
|
execute!(stdout, EnableMouseCapture)?;
|
||||||
|
|
||||||
let backend = CrosstermBackend::new(stdout);
|
let mut terminal = Terminal::new(CrosstermBackend::new(stdout))?;
|
||||||
|
|
||||||
let mut terminal = Terminal::new(backend)?;
|
|
||||||
terminal.hide_cursor()?;
|
terminal.hide_cursor()?;
|
||||||
terminal.clear()?;
|
terminal.clear()?;
|
||||||
|
|
||||||
|
@ -304,16 +303,21 @@ fn main() -> error::Result<()> {
|
||||||
}
|
}
|
||||||
// Draw!
|
// Draw!
|
||||||
if let Err(err) = canvas::draw_data(&mut terminal, &mut app) {
|
if let Err(err) = canvas::draw_data(&mut terminal, &mut app) {
|
||||||
disable_raw_mode()?;
|
cleanup(&mut terminal)?;
|
||||||
execute!(terminal.backend_mut(), LeaveAlternateScreen)?;
|
|
||||||
terminal.show_cursor()?;
|
|
||||||
error!("{}", err);
|
error!("{}", err);
|
||||||
return Err(err);
|
return Err(err);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
disable_raw_mode()?;
|
cleanup(&mut terminal)?;
|
||||||
execute!(terminal.backend_mut(), LeaveAlternateScreen)?;
|
Ok(())
|
||||||
terminal.show_cursor()?;
|
}
|
||||||
|
|
||||||
|
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(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue