From c8cb85e9b5bd7370d63ba4c6d9923a3cba02f449 Mon Sep 17 00:00:00 2001 From: Timon Post Date: Wed, 5 May 2021 16:18:14 +0200 Subject: [PATCH 1/7] 0.20 --- Cargo.toml | 6 +++--- src/style/styled_content.rs | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 6333a5df3..e63134021 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "crossterm" -version = "0.19.0" +version = "0.20.0" authors = ["T. Post"] description = "A crossplatform terminal library for manipulating terminals." repository = "https://github.com/crossterm-rs/crossterm" @@ -63,10 +63,10 @@ signal-hook-mio = { version = "0.2.1", features = ["support-v0_7"] } # Dev dependencies (examples, ...) # [dev-dependencies] -tokio = { version = "1.0", features = ["full"] } +tokio = { version = "1.5", features = ["full"] } futures = "0.3" futures-timer = "3.0" -async-std = "1.4" +async-std = "1.9" # # Examples diff --git a/src/style/styled_content.rs b/src/style/styled_content.rs index bb9598959..c607dad99 100644 --- a/src/style/styled_content.rs +++ b/src/style/styled_content.rs @@ -27,7 +27,7 @@ use crate::{ /// /// println!("{}", styled); /// ``` -#[derive(Copy, Clone, Debug)] +#[derive(Copy, Clone, Debug, Eq, PartialEq)] pub struct StyledContent { /// The style (colors, content attributes). style: ContentStyle, From 82e570e46df58b74cdc70f0b99ead4582278acb2 Mon Sep 17 00:00:00 2001 From: Timon Post Date: Thu, 6 May 2021 11:25:23 +0200 Subject: [PATCH 2/7] 0.20 --- Cargo.toml | 2 +- src/cursor/sys/windows.rs | 6 +++--- src/terminal.rs | 2 +- src/terminal/sys/windows.rs | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index e63134021..e0435cf6d 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -48,7 +48,7 @@ version = "0.3.9" features = ["winuser"] [target.'cfg(windows)'.dependencies] -crossterm_winapi = "0.7.0" +crossterm_winapi = {path="../crossterm-winapi"} # # UNIX dependencies diff --git a/src/cursor/sys/windows.rs b/src/cursor/sys/windows.rs index 1151e2224..d5a6eb3c1 100644 --- a/src/cursor/sys/windows.rs +++ b/src/cursor/sys/windows.rs @@ -4,7 +4,7 @@ use std::convert::TryFrom; use std::io; use std::sync::atomic::{AtomicU64, Ordering}; -use crossterm_winapi::{is_true, Coord, Handle, HandleType, ScreenBuffer}; +use crossterm_winapi::{Coord, Handle, HandleType, ScreenBuffer, result}; use winapi::{ shared::minwindef::{FALSE, TRUE}, um::wincon::{SetConsoleCursorInfo, SetConsoleCursorPosition, CONSOLE_CURSOR_INFO, COORD}, @@ -154,7 +154,7 @@ impl ScreenBufferCursor { let position = COORD { X: x, Y: y }; unsafe { - if !is_true(SetConsoleCursorPosition( + if let Err(_) = result(SetConsoleCursorPosition( **self.screen_buffer.handle(), position, )) { @@ -171,7 +171,7 @@ impl ScreenBufferCursor { }; unsafe { - if !is_true(SetConsoleCursorInfo( + if let Err(_) = result(SetConsoleCursorInfo( **self.screen_buffer.handle(), &cursor_info, )) { diff --git a/src/terminal.rs b/src/terminal.rs index ea92302aa..e003f5844 100644 --- a/src/terminal.rs +++ b/src/terminal.rs @@ -187,7 +187,7 @@ impl Command for EnterAlternateScreen { #[cfg(windows)] fn execute_winapi(&self, _writer: impl FnMut() -> Result<()>) -> Result<()> { - let alternate_screen = ScreenBuffer::create(); + let alternate_screen = ScreenBuffer::create()?; alternate_screen.show()?; Ok(()) } diff --git a/src/terminal/sys/windows.rs b/src/terminal/sys/windows.rs index b76d64aa8..ceb87eedb 100644 --- a/src/terminal/sys/windows.rs +++ b/src/terminal/sys/windows.rs @@ -168,7 +168,7 @@ pub(crate) fn set_size(width: u16, height: u16) -> Result<()> { screen_buffer.set_size(current_size.width - 1, current_size.height - 1)?; } - let bounds = console.largest_window_size(); + let bounds = console.largest_window_size()?; if width > bounds.x { return Err(ErrorKind::new( From f495bbd87b05b641527491c9b81d0f3a88b4959e Mon Sep 17 00:00:00 2001 From: Timon Post Date: Thu, 6 May 2021 11:36:37 +0200 Subject: [PATCH 3/7] changelog --- CHANGELOG.md | 11 +++++++++++ src/lib.rs | 2 ++ 2 files changed, 13 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index a9cbb8055..f46b9327d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,14 @@ +# Version 0.20 +- Update from signal-hook with 'mio-feature flag' to signal-hook-mio 0.2.1. +- Manually implements Eq, PartialEq and Hash for KeyEvent improving equality checks and hash calculation. +- `crossterm::ErrorKind` to `io::Error`. +- Added Cursor Shape Support. +- Add support for function keys F13...F20. +- Support taking any Display in `SetTitle` command. +- Remove lazy_static dependency. +- Remove extra Clone bounds in the style module. + - Add `MoveToRow` command. + # Version 0.19 - Use single thread for async event reader. - Patch timeout handling for event polling this was not working correctly. diff --git a/src/lib.rs b/src/lib.rs index 41e882801..c152f2c75 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -48,6 +48,8 @@ //! [`MoveLeft`](cursor/struct.MoveLeft.html), [`MoveRight`](cursor/struct.MoveRight.html), //! [`MoveTo`](cursor/struct.MoveTo.html), [`MoveToColumn`](cursor/struct.MoveToColumn.html),[`MoveToRow`](cursor/struct.MoveToRow.html), //! [`MoveToNextLine`](cursor/struct.MoveToNextLine.html), [`MoveToPreviousLine`](cursor/struct.MoveToPreviousLine.html), +//! - Shape - +//! [`SetCursorShape`](cursor/struct.SetCursorShape .html) //! - Module [`event`](event/index.html) //! - Mouse events - [`EnableMouseCapture`](event/struct.EnableMouseCapture.html), //! [`DisableMouseCapture`](event/struct.DisableMouseCapture.html) From 6d690aa138551765d60f6b256db4b39596a97f6b Mon Sep 17 00:00:00 2001 From: Timon Post Date: Thu, 6 May 2021 11:43:11 +0200 Subject: [PATCH 4/7] switch to release winapi --- Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Cargo.toml b/Cargo.toml index e0435cf6d..fae48ff6b 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -48,7 +48,7 @@ version = "0.3.9" features = ["winuser"] [target.'cfg(windows)'.dependencies] -crossterm_winapi = {path="../crossterm-winapi"} +crossterm_winapi = "0.8" # # UNIX dependencies From 00371b16c6d071cd0894f6002b730973ce044946 Mon Sep 17 00:00:00 2001 From: Timon Post Date: Thu, 6 May 2021 11:51:18 +0200 Subject: [PATCH 5/7] fmt --- src/cursor/sys/windows.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cursor/sys/windows.rs b/src/cursor/sys/windows.rs index d5a6eb3c1..1bc43a814 100644 --- a/src/cursor/sys/windows.rs +++ b/src/cursor/sys/windows.rs @@ -4,7 +4,7 @@ use std::convert::TryFrom; use std::io; use std::sync::atomic::{AtomicU64, Ordering}; -use crossterm_winapi::{Coord, Handle, HandleType, ScreenBuffer, result}; +use crossterm_winapi::{result, Coord, Handle, HandleType, ScreenBuffer}; use winapi::{ shared::minwindef::{FALSE, TRUE}, um::wincon::{SetConsoleCursorInfo, SetConsoleCursorPosition, CONSOLE_CURSOR_INFO, COORD}, From 374cae21dbe64c1c148a457774efffa03d428d8e Mon Sep 17 00:00:00 2001 From: Timon Post Date: Thu, 6 May 2021 11:59:32 +0200 Subject: [PATCH 6/7] clippy --- src/cursor/sys/windows.rs | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/cursor/sys/windows.rs b/src/cursor/sys/windows.rs index 1bc43a814..06da423aa 100644 --- a/src/cursor/sys/windows.rs +++ b/src/cursor/sys/windows.rs @@ -154,10 +154,12 @@ impl ScreenBufferCursor { let position = COORD { X: x, Y: y }; unsafe { - if let Err(_) = result(SetConsoleCursorPosition( + if result(SetConsoleCursorPosition( **self.screen_buffer.handle(), position, - )) { + )) + .is_err() + { return Err(io::Error::last_os_error()); } } @@ -171,10 +173,12 @@ impl ScreenBufferCursor { }; unsafe { - if let Err(_) = result(SetConsoleCursorInfo( + if result(SetConsoleCursorInfo( **self.screen_buffer.handle(), &cursor_info, - )) { + )) + .is_err() + { return Err(io::Error::last_os_error()); } } From d69f73ff2e3fe687b88e0a10b679ebe462ff29bf Mon Sep 17 00:00:00 2001 From: Timon Date: Thu, 10 Jun 2021 15:51:56 +0200 Subject: [PATCH 7/7] update docs --- CHANGELOG.md | 3 ++- README.md | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f46b9327d..625b1c96b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,7 +8,8 @@ - Remove lazy_static dependency. - Remove extra Clone bounds in the style module. - Add `MoveToRow` command. - + - Remove writer parameter from execute_winapi + # Version 0.19 - Use single thread for async event reader. - Patch timeout handling for event polling this was not working correctly. diff --git a/README.md b/README.md index a798f4728..374f38345 100644 --- a/README.md +++ b/README.md @@ -87,7 +87,7 @@ Click to show Cargo.toml. ```toml [dependencies] -crossterm = "0.18" +crossterm = "0.20" ```