This commit is contained in:
Timon 2020-03-24 22:00:23 +01:00 committed by GitHub
parent 67a6667929
commit 9c9543d454
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 27 additions and 22 deletions

View File

@ -1,9 +1,12 @@
# Version 0.16.1
# Version 0.17
- Impl Display for MoveToColumn, MoveToNextLine, MoveToPreviousLine
- Make unix event reader always use `/dev/tty`.
- Direct write command ansi_codes into formatter instead of double allocation.
- Add NONE flag to KeyModifiers
- Add support for converting chars to StylizedContent
- Make terminal size function fallback to `STDOUT_FILENO` if `/dev/tty` is missing.
# Version 0.16.0
- Make terminal size function work on `/dev/tty` instead of `STDOUT_FILENO`.
- Change attribute vector in `ContentStyle` to bitmask.
- Add `SetAttributes` command.
- Add `Attributes` type, which is a bitfield of enabled attributes.

View File

@ -1,6 +1,6 @@
[package]
name = "crossterm"
version = "0.16.0"
version = "0.17.0"
authors = ["T. Post"]
description = "An crossplatform terminal library for manipulating terminals."
repository = "https://github.com/crossterm-rs/crossterm"
@ -37,7 +37,7 @@ bitflags = "1.2"
lazy_static = "1.4"
parking_lot = "0.10"
futures = { version = "0.3", optional = true }
serde = { version = "1.0.0", features = ["derive"], optional = true }
serde = { version = "1.0", features = ["derive"], optional = true }
#
# Windows dependencies
@ -54,7 +54,7 @@ crossterm_winapi = "0.6.1"
#
[target.'cfg(unix)'.dependencies]
libc = "0.2"
mio = "0.6.21"
mio = "0.6"
signal-hook = { version = "0.1.13", features = ["mio-support"] }
#

View File

@ -85,6 +85,7 @@ terminals have been tested. If you have used this library for a terminal other t
issues, then feel free to add it to the above list - I really would appreciate it!
## Getting Started
_see the /examples and documentation for more advanced examples._
<details>
<summary>
@ -93,7 +94,7 @@ Click to show Cargo.toml.
```toml
[dependencies]
crossterm = "0.14"
crossterm = "0.17"
```
</details>
@ -106,6 +107,7 @@ use crossterm::{
execute,
style::{Color, Print, ResetColor, SetBackgroundColor, SetForegroundColor},
ExecutableCommand, Result,
event,
};
fn main() -> Result<()> {
@ -176,7 +178,7 @@ License - see the [LICENSE](https://github.com/crossterm-rs/crossterm/blob/maste
[l1]: https://crates.io/crates/crossterm
[s2]: https://img.shields.io/badge/license-MIT-blue.svg
[l2]: crossterm/LICENSE
[l2]: ./LICENSE
[s3]: https://docs.rs/crossterm/badge.svg
[l3]: https://docs.rs/crossterm/

View File

@ -65,18 +65,14 @@ impl Drop for FileDesc {
/// Creates a file descriptor pointing to the standard input or `/dev/tty`.
pub fn tty_fd() -> Result<FileDesc> {
let (fd, close_on_drop) = if unsafe { libc::isatty(libc::STDIN_FILENO) == 1 } {
(libc::STDIN_FILENO, false)
} else {
(
fs::OpenOptions::new()
.read(true)
.write(true)
.open("/dev/tty")?
.into_raw_fd(),
true,
)
};
let (fd, close_on_drop) = (
fs::OpenOptions::new()
.read(true)
.write(true)
.open("/dev/tty")?
.into_raw_fd(),
true,
);
Ok(FileDesc::new(fd, close_on_drop))
}

View File

@ -88,7 +88,10 @@ pub(crate) fn parse_event(buffer: &[u8], input_available: bool) -> Result<Option
KeyCode::Char((c as u8 - 0x1C + b'4') as char),
KeyModifiers::CONTROL,
))))),
b'\0' => Ok(Some(InternalEvent::Event(Event::Key(KeyCode::Null.into())))),
b'\0' => Ok(Some(InternalEvent::Event(Event::Key(KeyEvent::new(
KeyCode::Char(' '),
KeyModifiers::CONTROL,
))))),
_ => parse_utf8_char(buffer).map(|maybe_char| {
maybe_char
.map(KeyCode::Char)
@ -193,6 +196,7 @@ pub(crate) fn parse_csi_modifier_key_code(buffer: &[u8]) -> Result<Option<Intern
(53, 66) => Event::Key(KeyEvent::new(KeyCode::Down, KeyModifiers::CONTROL)),
(53, 67) => Event::Key(KeyEvent::new(KeyCode::Right, KeyModifiers::CONTROL)),
(53, 68) => Event::Key(KeyEvent::new(KeyCode::Left, KeyModifiers::CONTROL)),
(50, 65) => Event::Key(KeyEvent::new(KeyCode::Up, KeyModifiers::SHIFT)),
(50, 66) => Event::Key(KeyEvent::new(KeyCode::Down, KeyModifiers::SHIFT)),
(50, 67) => Event::Key(KeyEvent::new(KeyCode::Right, KeyModifiers::SHIFT)),

View File

@ -10,7 +10,7 @@
//! have to worry about the platform you are working with.
//!
//! This crate supports all UNIX and Windows terminals down to Windows 7 (not all terminals are tested
//! see [Tested Terminals](https://github.com/crossterm-rs/crossterm/tree/zrzka/docs-update#tested-terminals)
//! see [Tested Terminals](https://github.com/crossterm-rs/crossterm#tested-terminals)
//! for more info).
//!
//! ## Command API