summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorClement Tsang <34804052+ClementTsang@users.noreply.github.com>2020-01-02 22:54:39 -0500
committerClement Tsang <34804052+ClementTsang@users.noreply.github.com>2020-01-02 22:54:39 -0500
commit7b902a9470457655852307bc5369a64fcd3e5871 (patch)
tree01561fae11f8ab3e4b0518077e7e2c01e5c4e593
parent4ae2882aa6f288841fdab064d8e89a9310708a47 (diff)
Fix mouse scrolling in windows
-rw-r--r--.vscode/settings.json1
-rw-r--r--Cargo.toml1
-rw-r--r--README.md3
-rw-r--r--src/main.rs18
4 files changed, 15 insertions, 8 deletions
diff --git a/.vscode/settings.json b/.vscode/settings.json
index 356e7745..1efd61f6 100644
--- a/.vscode/settings.json
+++ b/.vscode/settings.json
@@ -2,6 +2,7 @@
"cSpell.words": [
"AHHHHHH",
"Dataset",
+ "Ryzen",
"Tebibyte",
"avgcpu",
"backend",
diff --git a/Cargo.toml b/Cargo.toml
index 51a9c42a..a3670a4d 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -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"
diff --git a/README.md b/README.md
index f4ab4d81..c70cb2c1 100644
--- a/README.md
+++ b/README.md
@@ -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)
diff --git a/src/main.rs b/src/main.rs
index f24eca96..644d1e96 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -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);
}
}
+ 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(())
}