Skip to content

Commit 9c9543d

Browse files
authored
0.17 (#403)
1 parent 67a6667 commit 9c9543d

File tree

6 files changed

+27
-22
lines changed

6 files changed

+27
-22
lines changed

CHANGELOG.md

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,12 @@
1-
# Version 0.16.1
1+
# Version 0.17
2+
- Impl Display for MoveToColumn, MoveToNextLine, MoveToPreviousLine
3+
- Make unix event reader always use `/dev/tty`.
4+
- Direct write command ansi_codes into formatter instead of double allocation.
5+
- Add NONE flag to KeyModifiers
26
- Add support for converting chars to StylizedContent
37
- Make terminal size function fallback to `STDOUT_FILENO` if `/dev/tty` is missing.
48

59
# Version 0.16.0
6-
- Make terminal size function work on `/dev/tty` instead of `STDOUT_FILENO`.
710
- Change attribute vector in `ContentStyle` to bitmask.
811
- Add `SetAttributes` command.
912
- Add `Attributes` type, which is a bitfield of enabled attributes.

Cargo.toml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "crossterm"
3-
version = "0.16.0"
3+
version = "0.17.0"
44
authors = ["T. Post"]
55
description = "An crossplatform terminal library for manipulating terminals."
66
repository = "https://github.com/crossterm-rs/crossterm"
@@ -37,7 +37,7 @@ bitflags = "1.2"
3737
lazy_static = "1.4"
3838
parking_lot = "0.10"
3939
futures = { version = "0.3", optional = true }
40-
serde = { version = "1.0.0", features = ["derive"], optional = true }
40+
serde = { version = "1.0", features = ["derive"], optional = true }
4141

4242
#
4343
# Windows dependencies
@@ -54,7 +54,7 @@ crossterm_winapi = "0.6.1"
5454
#
5555
[target.'cfg(unix)'.dependencies]
5656
libc = "0.2"
57-
mio = "0.6.21"
57+
mio = "0.6"
5858
signal-hook = { version = "0.1.13", features = ["mio-support"] }
5959

6060
#

README.md

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@ terminals have been tested. If you have used this library for a terminal other t
8585
issues, then feel free to add it to the above list - I really would appreciate it!
8686

8787
## Getting Started
88+
_see the /examples and documentation for more advanced examples._
8889

8990
<details>
9091
<summary>
@@ -93,7 +94,7 @@ Click to show Cargo.toml.
9394

9495
```toml
9596
[dependencies]
96-
crossterm = "0.14"
97+
crossterm = "0.17"
9798
```
9899

99100
</details>
@@ -106,6 +107,7 @@ use crossterm::{
106107
execute,
107108
style::{Color, Print, ResetColor, SetBackgroundColor, SetForegroundColor},
108109
ExecutableCommand, Result,
110+
event,
109111
};
110112

111113
fn main() -> Result<()> {
@@ -124,7 +126,7 @@ fn main() -> Result<()> {
124126
.execute(SetBackgroundColor(Color::Red))?
125127
.execute(Print("Styled text here."))?
126128
.execute(ResetColor)?;
127-
129+
128130
Ok(())
129131
}
130132
```
@@ -176,7 +178,7 @@ License - see the [LICENSE](https://github.com/crossterm-rs/crossterm/blob/maste
176178
[l1]: https://crates.io/crates/crossterm
177179

178180
[s2]: https://img.shields.io/badge/license-MIT-blue.svg
179-
[l2]: crossterm/LICENSE
181+
[l2]: ./LICENSE
180182

181183
[s3]: https://docs.rs/crossterm/badge.svg
182184
[l3]: https://docs.rs/crossterm/

src/event/sys/unix/file_descriptor.rs

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -65,18 +65,14 @@ impl Drop for FileDesc {
6565

6666
/// Creates a file descriptor pointing to the standard input or `/dev/tty`.
6767
pub fn tty_fd() -> Result<FileDesc> {
68-
let (fd, close_on_drop) = if unsafe { libc::isatty(libc::STDIN_FILENO) == 1 } {
69-
(libc::STDIN_FILENO, false)
70-
} else {
71-
(
72-
fs::OpenOptions::new()
73-
.read(true)
74-
.write(true)
75-
.open("/dev/tty")?
76-
.into_raw_fd(),
77-
true,
78-
)
79-
};
68+
let (fd, close_on_drop) = (
69+
fs::OpenOptions::new()
70+
.read(true)
71+
.write(true)
72+
.open("/dev/tty")?
73+
.into_raw_fd(),
74+
true,
75+
);
8076

8177
Ok(FileDesc::new(fd, close_on_drop))
8278
}

src/event/sys/unix/parse.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,10 @@ pub(crate) fn parse_event(buffer: &[u8], input_available: bool) -> Result<Option
8888
KeyCode::Char((c as u8 - 0x1C + b'4') as char),
8989
KeyModifiers::CONTROL,
9090
))))),
91-
b'\0' => Ok(Some(InternalEvent::Event(Event::Key(KeyCode::Null.into())))),
91+
b'\0' => Ok(Some(InternalEvent::Event(Event::Key(KeyEvent::new(
92+
KeyCode::Char(' '),
93+
KeyModifiers::CONTROL,
94+
))))),
9295
_ => parse_utf8_char(buffer).map(|maybe_char| {
9396
maybe_char
9497
.map(KeyCode::Char)
@@ -193,6 +196,7 @@ pub(crate) fn parse_csi_modifier_key_code(buffer: &[u8]) -> Result<Option<Intern
193196
(53, 66) => Event::Key(KeyEvent::new(KeyCode::Down, KeyModifiers::CONTROL)),
194197
(53, 67) => Event::Key(KeyEvent::new(KeyCode::Right, KeyModifiers::CONTROL)),
195198
(53, 68) => Event::Key(KeyEvent::new(KeyCode::Left, KeyModifiers::CONTROL)),
199+
196200
(50, 65) => Event::Key(KeyEvent::new(KeyCode::Up, KeyModifiers::SHIFT)),
197201
(50, 66) => Event::Key(KeyEvent::new(KeyCode::Down, KeyModifiers::SHIFT)),
198202
(50, 67) => Event::Key(KeyEvent::new(KeyCode::Right, KeyModifiers::SHIFT)),

src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
//! have to worry about the platform you are working with.
1111
//!
1212
//! This crate supports all UNIX and Windows terminals down to Windows 7 (not all terminals are tested
13-
//! see [Tested Terminals](https://github.com/crossterm-rs/crossterm/tree/zrzka/docs-update#tested-terminals)
13+
//! see [Tested Terminals](https://github.com/crossterm-rs/crossterm#tested-terminals)
1414
//! for more info).
1515
//!
1616
//! ## Command API

0 commit comments

Comments
 (0)