From db956267f80744b1d8ab08dcd7d92ee21b7a60f2 Mon Sep 17 00:00:00 2001 From: Timon Date: Tue, 19 Oct 2021 10:19:16 +0200 Subject: [PATCH] 0.22.1 (#614) # Version 0.22.1 - Update yanked version crossterm-winapi and move to crossterm-winapi 0.9.0. - Changed panic to error when calling disable-mouse capture without setting it first. - Update bitflags dependency. # Version 0.22 - Fix serde Color serialisation/deserialization inconsistency. - Update crossterm-winapi 0.8.1 to fix panic for certain mouse events --- CHANGELOG.md | 9 +++++++++ Cargo.toml | 6 +++--- README.md | 4 ++-- src/event/sys/windows.rs | 8 ++++---- src/event/sys/windows/parse.rs | 1 + 5 files changed, 19 insertions(+), 9 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0b6f443..5081818 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,12 @@ +# Version 0.22.1 +- Update yanked version crossterm-winapi and move to crossterm-winapi 0.9.0. +- Changed panic to error when calling disable-mouse capture without setting it first. +- Update bitflags dependency. + +# Version 0.22 +- Fix serde Color serialisation/deserialization inconsistency. +- Update crossterm-winapi 0.8.1 to fix panic for certain mouse events + # Version 0.21 - Expose `is_raw` function. - Add 'purge' option on unix system, this clears the entire screen buffer. diff --git a/Cargo.toml b/Cargo.toml index 7326546..2b8bce4 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "crossterm" -version = "0.21.0" +version = "0.22.1" authors = ["T. Post"] description = "A crossplatform terminal library for manipulating terminals." repository = "https://github.com/crossterm-rs/crossterm" @@ -33,7 +33,7 @@ event-stream = ["futures-core"] # Shared dependencies # [dependencies] -bitflags = "1.2" +bitflags = "1.3" parking_lot = "0.11" # optional deps only added when requested @@ -48,7 +48,7 @@ version = "0.3.9" features = ["winuser"] [target.'cfg(windows)'.dependencies] -crossterm_winapi = "0.8" +crossterm_winapi = "0.9" # # UNIX dependencies diff --git a/README.md b/README.md index 374f383..d293996 100644 --- a/README.md +++ b/README.md @@ -87,7 +87,7 @@ Click to show Cargo.toml. ```toml [dependencies] -crossterm = "0.20" +crossterm = "0.22" ``` @@ -150,7 +150,7 @@ features = ["event-stream"] | `Mio` | event readiness polling, waking up poller | UNIX only | `signal-hook`| signalhook is used to handle terminal resize SIGNAL with Mio. | UNIX only | `winapi`| Used for low-level windows system calls which ANSI codes can't replace| windows only -| `futures`| Can be used to for async stream of events | only with a feature flag +| `futures-core`| Can be used to for async stream of events | only with a feature flag | `serde`| Se/dese/realizing of events | only with a feature flag diff --git a/src/event/sys/windows.rs b/src/event/sys/windows.rs index 7485d55..af20497 100644 --- a/src/event/sys/windows.rs +++ b/src/event/sys/windows.rs @@ -1,6 +1,7 @@ //! This is a WINDOWS specific implementation for input related action. use std::convert::TryFrom; +use std::io; use std::sync::atomic::{AtomicU64, Ordering}; use crossterm_winapi::{ConsoleMode, Handle}; @@ -30,10 +31,9 @@ fn init_original_console_mode(original_mode: u32) { } /// Returns the original console color, make sure to call `init_console_color` before calling this function. Otherwise this function will panic. -fn original_console_mode() -> u32 { +fn original_console_mode() -> Result { u32::try_from(ORIGINAL_CONSOLE_MODE.load(Ordering::Relaxed)) - // safe unwrap, initial console color was set with `init_console_color` in `WinApiColor::new()` - .expect("Original console mode not set") + .map_err(|_| io::Error::new(io::ErrorKind::Other, "Initial console modes not set")) } pub(crate) fn enable_mouse_capture() -> Result<()> { @@ -46,6 +46,6 @@ pub(crate) fn enable_mouse_capture() -> Result<()> { pub(crate) fn disable_mouse_capture() -> Result<()> { let mode = ConsoleMode::from(Handle::current_in_handle()?); - mode.set_mode(original_console_mode())?; + mode.set_mode(original_console_mode()?)?; Ok(()) } diff --git a/src/event/sys/windows/parse.rs b/src/event/sys/windows/parse.rs index e728073..defca05 100644 --- a/src/event/sys/windows/parse.rs +++ b/src/event/sys/windows/parse.rs @@ -170,6 +170,7 @@ fn parse_mouse_event_record(event: &MouseEvent) -> Result None, // double click not supported by unix terminals EventFlags::MouseHwheeled => None, // horizontal scroll not supported by unix terminals + _ => None, }; Ok(kind.map(|kind| crate::event::MouseEvent {