Skip to content

Commit

Permalink
0.22.1 (#614)
Browse files Browse the repository at this point in the history
# 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
  • Loading branch information
TimonPost authored Oct 19, 2021
1 parent 4e72bd1 commit db95626
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 9 deletions.
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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.
Expand Down
6 changes: 3 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -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"
Expand Down Expand Up @@ -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
Expand All @@ -48,7 +48,7 @@ version = "0.3.9"
features = ["winuser"]

[target.'cfg(windows)'.dependencies]
crossterm_winapi = "0.8"
crossterm_winapi = "0.9"

#
# UNIX dependencies
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ Click to show Cargo.toml.

```toml
[dependencies]
crossterm = "0.20"
crossterm = "0.22"
```

</details>
Expand Down Expand Up @@ -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


Expand Down
8 changes: 4 additions & 4 deletions src/event/sys/windows.rs
Original file line number Diff line number Diff line change
@@ -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};
Expand Down Expand Up @@ -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> {
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<()> {
Expand All @@ -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(())
}
1 change: 1 addition & 0 deletions src/event/sys/windows/parse.rs
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,7 @@ fn parse_mouse_event_record(event: &MouseEvent) -> Result<Option<crate::event::M
}
EventFlags::DoubleClick => 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 {
Expand Down

0 comments on commit db95626

Please sign in to comment.