This commit is contained in:
Timon 2021-06-10 15:55:34 +02:00 committed by GitHub
parent 0e8be6a891
commit a618a9f3b3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
9 changed files with 32 additions and 14 deletions

View File

@ -1,3 +1,15 @@
# 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.
- 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.

View File

@ -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"
@ -48,7 +48,7 @@ version = "0.3.9"
features = ["winuser"]
[target.'cfg(windows)'.dependencies]
crossterm_winapi = "0.7.0"
crossterm_winapi = "0.8"
#
# UNIX dependencies
@ -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

View File

@ -87,7 +87,7 @@ Click to show Cargo.toml.
```toml
[dependencies]
crossterm = "0.18"
crossterm = "0.20"
```
</details>

View File

@ -3,7 +3,7 @@
use std::io::Write;
use crate::Result;
use crossterm::{cursor, execute, queue, style, style::Colorize, Command};
use crossterm::{cursor, execute, queue, style, Command, style::Stylize};
use std::thread;
use std::time::Duration;

View File

@ -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::{result, Coord, Handle, HandleType, ScreenBuffer};
use winapi::{
shared::minwindef::{FALSE, TRUE},
um::wincon::{SetConsoleCursorInfo, SetConsoleCursorPosition, CONSOLE_CURSOR_INFO, COORD},
@ -154,10 +154,12 @@ impl ScreenBufferCursor {
let position = COORD { X: x, Y: y };
unsafe {
if !is_true(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 !is_true(SetConsoleCursorInfo(
if result(SetConsoleCursorInfo(
**self.screen_buffer.handle(),
&cursor_info,
)) {
))
.is_err()
{
return Err(io::Error::last_os_error());
}
}

View File

@ -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)

View File

@ -18,7 +18,7 @@ use super::{ContentStyle, PrintStyledContent};
///
/// println!("{}", styled);
/// ```
#[derive(Copy, Clone, Debug)]
#[derive(Copy, Clone, Debug, Eq, PartialEq)]
pub struct StyledContent<D: Display> {
/// The style (colors, content attributes).
style: ContentStyle,

View File

@ -187,7 +187,7 @@ impl Command for EnterAlternateScreen {
#[cfg(windows)]
fn execute_winapi(&self) -> Result<()> {
let alternate_screen = ScreenBuffer::create();
let alternate_screen = ScreenBuffer::create()?;
alternate_screen.show()?;
Ok(())
}

View File

@ -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(