0.24 (#686)
This commit is contained in:
parent
fe37c8947b
commit
0c20590774
11
CHANGELOG.md
11
CHANGELOG.md
@ -1,3 +1,14 @@
|
|||||||
|
# Version 0.24.0
|
||||||
|
- Add DoubleUnderlined, Undercurled, Underdots the text, Underdotted, Underdashes, Underdashed attributes and allow coloring their foreground / background color.
|
||||||
|
- Fix windows unicode character parsing, this fixed various key combinations and support typing unicode characters.
|
||||||
|
- Consistency and better documentation on mouse cursor operations (BREAKING CHANGE).
|
||||||
|
- MoveTo, MoveToColumn, MoveToRow are 0-based. (left top most cell is 0,0). Moving like this is absolute
|
||||||
|
- 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.
|
||||||
|
- terminal::size returns error when previously it returned (0,0).
|
||||||
|
- Remove println from serialisation code.
|
||||||
|
- Fix mouse up for middle and right buttons.
|
||||||
|
- Fix escape codes on Git-Bash + Windows Terminal / Alacritty / WezTerm.
|
||||||
|
- Add support for cursor keys in application mode.
|
||||||
# Version 0.23.2
|
# Version 0.23.2
|
||||||
- Update signal-hook and mio to version 0.8.
|
- Update signal-hook and mio to version 0.8.
|
||||||
|
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "crossterm"
|
name = "crossterm"
|
||||||
version = "0.23.2"
|
version = "0.24.0"
|
||||||
authors = ["T. Post"]
|
authors = ["T. Post"]
|
||||||
description = "A crossplatform terminal library for manipulating terminals."
|
description = "A crossplatform terminal library for manipulating terminals."
|
||||||
repository = "https://github.com/crossterm-rs/crossterm"
|
repository = "https://github.com/crossterm-rs/crossterm"
|
||||||
|
@ -4,10 +4,11 @@ use crate::Result;
|
|||||||
use crossterm::{cursor, queue, style};
|
use crossterm::{cursor, queue, style};
|
||||||
use std::io::Write;
|
use std::io::Write;
|
||||||
|
|
||||||
const ATTRIBUTES: [(style::Attribute, style::Attribute); 6] = [
|
const ATTRIBUTES: [(style::Attribute, style::Attribute); 10] = [
|
||||||
(style::Attribute::Bold, style::Attribute::NormalIntensity),
|
(style::Attribute::Bold, style::Attribute::NormalIntensity),
|
||||||
(style::Attribute::Italic, style::Attribute::NoItalic),
|
(style::Attribute::Italic, style::Attribute::NoItalic),
|
||||||
(style::Attribute::Underlined, style::Attribute::NoUnderline),
|
(style::Attribute::Underlined, style::Attribute::NoUnderline),
|
||||||
|
|
||||||
(style::Attribute::DoubleUnderlined, style::Attribute::NoUnderline),
|
(style::Attribute::DoubleUnderlined, style::Attribute::NoUnderline),
|
||||||
(style::Attribute::Undercurled, style::Attribute::NoUnderline),
|
(style::Attribute::Undercurled, style::Attribute::NoUnderline),
|
||||||
(style::Attribute::Underdotted, style::Attribute::NoUnderline),
|
(style::Attribute::Underdotted, style::Attribute::NoUnderline),
|
||||||
|
@ -1,4 +1,8 @@
|
|||||||
use crossterm::{tty::IsTty, terminal::{size, SetSize}, execute};
|
use crossterm::{
|
||||||
|
execute,
|
||||||
|
terminal::{size, SetSize},
|
||||||
|
tty::IsTty,
|
||||||
|
};
|
||||||
use std::io::{stdin, stdout};
|
use std::io::{stdin, stdout};
|
||||||
|
|
||||||
pub fn main() {
|
pub fn main() {
|
||||||
|
@ -44,12 +44,24 @@ pub(crate) fn parse_event(buffer: &[u8], input_available: bool) -> Result<Option
|
|||||||
Ok(None)
|
Ok(None)
|
||||||
} else {
|
} else {
|
||||||
match buffer[2] {
|
match buffer[2] {
|
||||||
b'D' => Ok(Some(InternalEvent::Event(Event::Key(KeyCode::Left.into())))),
|
b'D' => {
|
||||||
b'C' => Ok(Some(InternalEvent::Event(Event::Key(KeyCode::Right.into())))),
|
Ok(Some(InternalEvent::Event(Event::Key(KeyCode::Left.into()))))
|
||||||
b'A' => Ok(Some(InternalEvent::Event(Event::Key(KeyCode::Up.into())))),
|
}
|
||||||
b'B' => Ok(Some(InternalEvent::Event(Event::Key(KeyCode::Down.into())))),
|
b'C' => Ok(Some(InternalEvent::Event(Event::Key(
|
||||||
b'H' => Ok(Some(InternalEvent::Event(Event::Key(KeyCode::Home.into())))),
|
KeyCode::Right.into(),
|
||||||
b'F' => Ok(Some(InternalEvent::Event(Event::Key(KeyCode::End.into())))),
|
)))),
|
||||||
|
b'A' => {
|
||||||
|
Ok(Some(InternalEvent::Event(Event::Key(KeyCode::Up.into()))))
|
||||||
|
}
|
||||||
|
b'B' => {
|
||||||
|
Ok(Some(InternalEvent::Event(Event::Key(KeyCode::Down.into()))))
|
||||||
|
}
|
||||||
|
b'H' => {
|
||||||
|
Ok(Some(InternalEvent::Event(Event::Key(KeyCode::Home.into()))))
|
||||||
|
}
|
||||||
|
b'F' => {
|
||||||
|
Ok(Some(InternalEvent::Event(Event::Key(KeyCode::End.into()))))
|
||||||
|
}
|
||||||
// F1-F4
|
// F1-F4
|
||||||
val @ b'P'..=b'S' => Ok(Some(InternalEvent::Event(Event::Key(
|
val @ b'P'..=b'S' => Ok(Some(InternalEvent::Event(Event::Key(
|
||||||
KeyCode::F(1 + val - b'P').into(),
|
KeyCode::F(1 + val - b'P').into(),
|
||||||
|
@ -234,6 +234,14 @@ impl Command for SetUnderlineColor {
|
|||||||
fn write_ansi(&self, f: &mut impl fmt::Write) -> fmt::Result {
|
fn write_ansi(&self, f: &mut impl fmt::Write) -> fmt::Result {
|
||||||
write!(f, csi!("{}m"), Colored::UnderlineColor(self.0))
|
write!(f, csi!("{}m"), Colored::UnderlineColor(self.0))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(windows)]
|
||||||
|
fn execute_winapi(&self) -> Result<()> {
|
||||||
|
Err(std::io::Error::new(
|
||||||
|
std::io::ErrorKind::Other,
|
||||||
|
"SetUnderlineColor not supported by winapi.",
|
||||||
|
))
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// A command that optionally sets the foreground and/or background color.
|
/// A command that optionally sets the foreground and/or background color.
|
||||||
|
@ -167,6 +167,7 @@ impl From<Colored> for u16 {
|
|||||||
Color::AnsiValue(_val) => 0,
|
Color::AnsiValue(_val) => 0,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Colored::UnderlineColor(_) => 0,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -176,7 +176,7 @@ impl Attribute {
|
|||||||
/// See <https://en.wikipedia.org/wiki/ANSI_escape_code#SGR_parameters>
|
/// See <https://en.wikipedia.org/wiki/ANSI_escape_code#SGR_parameters>
|
||||||
pub fn sgr(self) -> String {
|
pub fn sgr(self) -> String {
|
||||||
if (self as usize) > 4 && (self as usize) < 9 {
|
if (self as usize) > 4 && (self as usize) < 9 {
|
||||||
return "4:".to_string() + SGR[self as usize].to_string().as_str()
|
return "4:".to_string() + SGR[self as usize].to_string().as_str();
|
||||||
}
|
}
|
||||||
SGR[self as usize].to_string()
|
SGR[self as usize].to_string()
|
||||||
}
|
}
|
||||||
|
@ -17,6 +17,7 @@ pub enum Colored {
|
|||||||
/// A background color.
|
/// A background color.
|
||||||
BackgroundColor(Color),
|
BackgroundColor(Color),
|
||||||
/// An underline color.
|
/// An underline color.
|
||||||
|
/// Imporant: doesnt work on windows 10 or lower.
|
||||||
UnderlineColor(Color),
|
UnderlineColor(Color),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -66,7 +66,7 @@ impl From<Colored> for Colors {
|
|||||||
Colored::UnderlineColor(color) => Colors {
|
Colored::UnderlineColor(color) => Colors {
|
||||||
foreground: None,
|
foreground: None,
|
||||||
background: Some(color),
|
background: Some(color),
|
||||||
}
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -39,11 +39,13 @@ pub(crate) fn size() -> Result<(u16, u16)> {
|
|||||||
STDOUT_FILENO
|
STDOUT_FILENO
|
||||||
};
|
};
|
||||||
|
|
||||||
if wrap_with_result(unsafe { ioctl(fd, TIOCGWINSZ.into(), &mut size) }).is_ok() {
|
if wrap_with_result(unsafe { ioctl(fd, TIOCGWINSZ.into(), &mut size) }).is_ok()
|
||||||
if size.ws_col != 0 && size.ws_row != 0 {
|
&& size.ws_col != 0
|
||||||
|
&& size.ws_row != 0
|
||||||
|
{
|
||||||
return Ok((size.ws_col, size.ws_row));
|
return Ok((size.ws_col, size.ws_row));
|
||||||
}
|
}
|
||||||
}
|
|
||||||
tput_size().ok_or_else(|| std::io::Error::last_os_error().into())
|
tput_size().ok_or_else(|| std::io::Error::last_os_error().into())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user