Skip to content

Commit 0c20590

Browse files
authored
0.24 (#686)
1 parent fe37c89 commit 0c20590

File tree

11 files changed

+55
-15
lines changed

11 files changed

+55
-15
lines changed

CHANGELOG.md

+11
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,14 @@
1+
# Version 0.24.0
2+
- Add DoubleUnderlined, Undercurled, Underdots the text, Underdotted, Underdashes, Underdashed attributes and allow coloring their foreground / background color.
3+
- Fix windows unicode character parsing, this fixed various key combinations and support typing unicode characters.
4+
- Consistency and better documentation on mouse cursor operations (BREAKING CHANGE).
5+
- MoveTo, MoveToColumn, MoveToRow are 0-based. (left top most cell is 0,0). Moving like this is absolute
6+
- MoveToNextLine, MoveToPreviousLine, MoveUp, MoveDown, MoveRight, MoveLeft are 1-based,. Moving like this is relative. Moving 1 left means moving 1 left. Moving 0 to the left is not possible, wikipedia states that most terminals will just default to 1.
7+
- terminal::size returns error when previously it returned (0,0).
8+
- Remove println from serialisation code.
9+
- Fix mouse up for middle and right buttons.
10+
- Fix escape codes on Git-Bash + Windows Terminal / Alacritty / WezTerm.
11+
- Add support for cursor keys in application mode.
112
# Version 0.23.2
213
- Update signal-hook and mio to version 0.8.
314

Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "crossterm"
3-
version = "0.23.2"
3+
version = "0.24.0"
44
authors = ["T. Post"]
55
description = "A crossplatform terminal library for manipulating terminals."
66
repository = "https://github.com/crossterm-rs/crossterm"

examples/interactive-demo/src/test/attribute.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,11 @@ use crate::Result;
44
use crossterm::{cursor, queue, style};
55
use std::io::Write;
66

7-
const ATTRIBUTES: [(style::Attribute, style::Attribute); 6] = [
7+
const ATTRIBUTES: [(style::Attribute, style::Attribute); 10] = [
88
(style::Attribute::Bold, style::Attribute::NormalIntensity),
99
(style::Attribute::Italic, style::Attribute::NoItalic),
1010
(style::Attribute::Underlined, style::Attribute::NoUnderline),
11+
1112
(style::Attribute::DoubleUnderlined, style::Attribute::NoUnderline),
1213
(style::Attribute::Undercurled, style::Attribute::NoUnderline),
1314
(style::Attribute::Underdotted, style::Attribute::NoUnderline),

examples/is_tty.rs

+5-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
1-
use crossterm::{tty::IsTty, terminal::{size, SetSize}, execute};
1+
use crossterm::{
2+
execute,
3+
terminal::{size, SetSize},
4+
tty::IsTty,
5+
};
26
use std::io::{stdin, stdout};
37

48
pub fn main() {

src/event/sys/unix/parse.rs

+18-6
Original file line numberDiff line numberDiff line change
@@ -44,12 +44,24 @@ pub(crate) fn parse_event(buffer: &[u8], input_available: bool) -> Result<Option
4444
Ok(None)
4545
} else {
4646
match buffer[2] {
47-
b'D' => Ok(Some(InternalEvent::Event(Event::Key(KeyCode::Left.into())))),
48-
b'C' => Ok(Some(InternalEvent::Event(Event::Key(KeyCode::Right.into())))),
49-
b'A' => Ok(Some(InternalEvent::Event(Event::Key(KeyCode::Up.into())))),
50-
b'B' => Ok(Some(InternalEvent::Event(Event::Key(KeyCode::Down.into())))),
51-
b'H' => Ok(Some(InternalEvent::Event(Event::Key(KeyCode::Home.into())))),
52-
b'F' => Ok(Some(InternalEvent::Event(Event::Key(KeyCode::End.into())))),
47+
b'D' => {
48+
Ok(Some(InternalEvent::Event(Event::Key(KeyCode::Left.into()))))
49+
}
50+
b'C' => Ok(Some(InternalEvent::Event(Event::Key(
51+
KeyCode::Right.into(),
52+
)))),
53+
b'A' => {
54+
Ok(Some(InternalEvent::Event(Event::Key(KeyCode::Up.into()))))
55+
}
56+
b'B' => {
57+
Ok(Some(InternalEvent::Event(Event::Key(KeyCode::Down.into()))))
58+
}
59+
b'H' => {
60+
Ok(Some(InternalEvent::Event(Event::Key(KeyCode::Home.into()))))
61+
}
62+
b'F' => {
63+
Ok(Some(InternalEvent::Event(Event::Key(KeyCode::End.into()))))
64+
}
5365
// F1-F4
5466
val @ b'P'..=b'S' => Ok(Some(InternalEvent::Event(Event::Key(
5567
KeyCode::F(1 + val - b'P').into(),

src/style.rs

+8
Original file line numberDiff line numberDiff line change
@@ -234,6 +234,14 @@ impl Command for SetUnderlineColor {
234234
fn write_ansi(&self, f: &mut impl fmt::Write) -> fmt::Result {
235235
write!(f, csi!("{}m"), Colored::UnderlineColor(self.0))
236236
}
237+
238+
#[cfg(windows)]
239+
fn execute_winapi(&self) -> Result<()> {
240+
Err(std::io::Error::new(
241+
std::io::ErrorKind::Other,
242+
"SetUnderlineColor not supported by winapi.",
243+
))
244+
}
237245
}
238246

239247
/// A command that optionally sets the foreground and/or background color.

src/style/sys/windows.rs

+1
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,7 @@ impl From<Colored> for u16 {
167167
Color::AnsiValue(_val) => 0,
168168
}
169169
}
170+
Colored::UnderlineColor(_) => 0,
170171
}
171172
}
172173
}

src/style/types/attribute.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ impl Attribute {
176176
/// See <https://en.wikipedia.org/wiki/ANSI_escape_code#SGR_parameters>
177177
pub fn sgr(self) -> String {
178178
if (self as usize) > 4 && (self as usize) < 9 {
179-
return "4:".to_string() + SGR[self as usize].to_string().as_str()
179+
return "4:".to_string() + SGR[self as usize].to_string().as_str();
180180
}
181181
SGR[self as usize].to_string()
182182
}

src/style/types/colored.rs

+1
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ pub enum Colored {
1717
/// A background color.
1818
BackgroundColor(Color),
1919
/// An underline color.
20+
/// Imporant: doesnt work on windows 10 or lower.
2021
UnderlineColor(Color),
2122
}
2223

src/style/types/colors.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ impl From<Colored> for Colors {
6666
Colored::UnderlineColor(color) => Colors {
6767
foreground: None,
6868
background: Some(color),
69-
}
69+
},
7070
}
7171
}
7272
}

src/terminal/sys/unix.rs

+6-4
Original file line numberDiff line numberDiff line change
@@ -39,11 +39,13 @@ pub(crate) fn size() -> Result<(u16, u16)> {
3939
STDOUT_FILENO
4040
};
4141

42-
if wrap_with_result(unsafe { ioctl(fd, TIOCGWINSZ.into(), &mut size) }).is_ok() {
43-
if size.ws_col != 0 && size.ws_row != 0 {
44-
return Ok((size.ws_col, size.ws_row));
45-
}
42+
if wrap_with_result(unsafe { ioctl(fd, TIOCGWINSZ.into(), &mut size) }).is_ok()
43+
&& size.ws_col != 0
44+
&& size.ws_row != 0
45+
{
46+
return Ok((size.ws_col, size.ws_row));
4647
}
48+
4749
tput_size().ok_or_else(|| std::io::Error::last_os_error().into())
4850
}
4951

0 commit comments

Comments
 (0)