mirror of
https://github.com/ratatui-org/ratatui
synced 2025-02-18 06:58:51 +00:00
build(deps): upgrade crossterm to 0.27 (#380)
This commit is contained in:
parent
8b28672131
commit
37fa6abe9d
3 changed files with 34 additions and 38 deletions
|
@ -38,7 +38,7 @@ rustdoc-args = ["--cfg", "docsrs"]
|
||||||
[dependencies]
|
[dependencies]
|
||||||
bitflags = "2.3"
|
bitflags = "2.3"
|
||||||
cassowary = "0.3"
|
cassowary = "0.3"
|
||||||
crossterm = { version = "0.26", optional = true }
|
crossterm = { version = "0.27", optional = true }
|
||||||
indoc = "2.0"
|
indoc = "2.0"
|
||||||
paste = "1.0.2"
|
paste = "1.0.2"
|
||||||
serde = { version = "1", optional = true, features = ["derive"] }
|
serde = { version = "1", optional = true, features = ["derive"] }
|
||||||
|
|
|
@ -88,7 +88,7 @@ where
|
||||||
for (x, y, cell) in content {
|
for (x, y, cell) in content {
|
||||||
// Move the cursor if the previous location was not (x - 1, y)
|
// Move the cursor if the previous location was not (x - 1, y)
|
||||||
if !matches!(last_pos, Some(p) if x == p.0 + 1 && y == p.1) {
|
if !matches!(last_pos, Some(p) if x == p.0 + 1 && y == p.1) {
|
||||||
map_error(queue!(self.buffer, MoveTo(x, y)))?;
|
queue!(self.buffer, MoveTo(x, y))?;
|
||||||
}
|
}
|
||||||
last_pos = Some((x, y));
|
last_pos = Some((x, y));
|
||||||
if cell.modifier != modifier {
|
if cell.modifier != modifier {
|
||||||
|
@ -101,38 +101,38 @@ where
|
||||||
}
|
}
|
||||||
if cell.fg != fg {
|
if cell.fg != fg {
|
||||||
let color = CColor::from(cell.fg);
|
let color = CColor::from(cell.fg);
|
||||||
map_error(queue!(self.buffer, SetForegroundColor(color)))?;
|
queue!(self.buffer, SetForegroundColor(color))?;
|
||||||
fg = cell.fg;
|
fg = cell.fg;
|
||||||
}
|
}
|
||||||
if cell.bg != bg {
|
if cell.bg != bg {
|
||||||
let color = CColor::from(cell.bg);
|
let color = CColor::from(cell.bg);
|
||||||
map_error(queue!(self.buffer, SetBackgroundColor(color)))?;
|
queue!(self.buffer, SetBackgroundColor(color))?;
|
||||||
bg = cell.bg;
|
bg = cell.bg;
|
||||||
}
|
}
|
||||||
if cell.underline_color != underline_color {
|
if cell.underline_color != underline_color {
|
||||||
let color = CColor::from(cell.underline_color);
|
let color = CColor::from(cell.underline_color);
|
||||||
map_error(queue!(self.buffer, SetUnderlineColor(color)))?;
|
queue!(self.buffer, SetUnderlineColor(color))?;
|
||||||
underline_color = cell.underline_color;
|
underline_color = cell.underline_color;
|
||||||
}
|
}
|
||||||
|
|
||||||
map_error(queue!(self.buffer, Print(&cell.symbol)))?;
|
queue!(self.buffer, Print(&cell.symbol))?;
|
||||||
}
|
}
|
||||||
|
|
||||||
map_error(queue!(
|
queue!(
|
||||||
self.buffer,
|
self.buffer,
|
||||||
SetForegroundColor(CColor::Reset),
|
SetForegroundColor(CColor::Reset),
|
||||||
SetBackgroundColor(CColor::Reset),
|
SetBackgroundColor(CColor::Reset),
|
||||||
SetUnderlineColor(CColor::Reset),
|
SetUnderlineColor(CColor::Reset),
|
||||||
SetAttribute(CAttribute::Reset)
|
SetAttribute(CAttribute::Reset)
|
||||||
))
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn hide_cursor(&mut self) -> io::Result<()> {
|
fn hide_cursor(&mut self) -> io::Result<()> {
|
||||||
map_error(execute!(self.buffer, Hide))
|
execute!(self.buffer, Hide)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn show_cursor(&mut self) -> io::Result<()> {
|
fn show_cursor(&mut self) -> io::Result<()> {
|
||||||
map_error(execute!(self.buffer, Show))
|
execute!(self.buffer, Show)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn get_cursor(&mut self) -> io::Result<(u16, u16)> {
|
fn get_cursor(&mut self) -> io::Result<(u16, u16)> {
|
||||||
|
@ -141,7 +141,7 @@ where
|
||||||
}
|
}
|
||||||
|
|
||||||
fn set_cursor(&mut self, x: u16, y: u16) -> io::Result<()> {
|
fn set_cursor(&mut self, x: u16, y: u16) -> io::Result<()> {
|
||||||
map_error(execute!(self.buffer, MoveTo(x, y)))
|
execute!(self.buffer, MoveTo(x, y))
|
||||||
}
|
}
|
||||||
|
|
||||||
fn clear(&mut self) -> io::Result<()> {
|
fn clear(&mut self) -> io::Result<()> {
|
||||||
|
@ -149,7 +149,7 @@ where
|
||||||
}
|
}
|
||||||
|
|
||||||
fn clear_region(&mut self, clear_type: ClearType) -> io::Result<()> {
|
fn clear_region(&mut self, clear_type: ClearType) -> io::Result<()> {
|
||||||
map_error(execute!(
|
execute!(
|
||||||
self.buffer,
|
self.buffer,
|
||||||
Clear(match clear_type {
|
Clear(match clear_type {
|
||||||
ClearType::All => crossterm::terminal::ClearType::All,
|
ClearType::All => crossterm::terminal::ClearType::All,
|
||||||
|
@ -158,12 +158,12 @@ where
|
||||||
ClearType::CurrentLine => crossterm::terminal::ClearType::CurrentLine,
|
ClearType::CurrentLine => crossterm::terminal::ClearType::CurrentLine,
|
||||||
ClearType::UntilNewLine => crossterm::terminal::ClearType::UntilNewLine,
|
ClearType::UntilNewLine => crossterm::terminal::ClearType::UntilNewLine,
|
||||||
})
|
})
|
||||||
))
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn append_lines(&mut self, n: u16) -> io::Result<()> {
|
fn append_lines(&mut self, n: u16) -> io::Result<()> {
|
||||||
for _ in 0..n {
|
for _ in 0..n {
|
||||||
map_error(queue!(self.buffer, Print("\n")))?;
|
queue!(self.buffer, Print("\n"))?;
|
||||||
}
|
}
|
||||||
self.buffer.flush()
|
self.buffer.flush()
|
||||||
}
|
}
|
||||||
|
@ -180,10 +180,6 @@ where
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn map_error(error: crossterm::Result<()>) -> io::Result<()> {
|
|
||||||
error.map_err(|e| io::Error::new(io::ErrorKind::Other, e.to_string()))
|
|
||||||
}
|
|
||||||
|
|
||||||
impl From<Color> for CColor {
|
impl From<Color> for CColor {
|
||||||
fn from(color: Color) -> Self {
|
fn from(color: Color) -> Self {
|
||||||
match color {
|
match color {
|
||||||
|
@ -227,54 +223,54 @@ impl ModifierDiff {
|
||||||
//use crossterm::Attribute;
|
//use crossterm::Attribute;
|
||||||
let removed = self.from - self.to;
|
let removed = self.from - self.to;
|
||||||
if removed.contains(Modifier::REVERSED) {
|
if removed.contains(Modifier::REVERSED) {
|
||||||
map_error(queue!(w, SetAttribute(CAttribute::NoReverse)))?;
|
queue!(w, SetAttribute(CAttribute::NoReverse))?;
|
||||||
}
|
}
|
||||||
if removed.contains(Modifier::BOLD) {
|
if removed.contains(Modifier::BOLD) {
|
||||||
map_error(queue!(w, SetAttribute(CAttribute::NormalIntensity)))?;
|
queue!(w, SetAttribute(CAttribute::NormalIntensity))?;
|
||||||
if self.to.contains(Modifier::DIM) {
|
if self.to.contains(Modifier::DIM) {
|
||||||
map_error(queue!(w, SetAttribute(CAttribute::Dim)))?;
|
queue!(w, SetAttribute(CAttribute::Dim))?;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if removed.contains(Modifier::ITALIC) {
|
if removed.contains(Modifier::ITALIC) {
|
||||||
map_error(queue!(w, SetAttribute(CAttribute::NoItalic)))?;
|
queue!(w, SetAttribute(CAttribute::NoItalic))?;
|
||||||
}
|
}
|
||||||
if removed.contains(Modifier::UNDERLINED) {
|
if removed.contains(Modifier::UNDERLINED) {
|
||||||
map_error(queue!(w, SetAttribute(CAttribute::NoUnderline)))?;
|
queue!(w, SetAttribute(CAttribute::NoUnderline))?;
|
||||||
}
|
}
|
||||||
if removed.contains(Modifier::DIM) {
|
if removed.contains(Modifier::DIM) {
|
||||||
map_error(queue!(w, SetAttribute(CAttribute::NormalIntensity)))?;
|
queue!(w, SetAttribute(CAttribute::NormalIntensity))?;
|
||||||
}
|
}
|
||||||
if removed.contains(Modifier::CROSSED_OUT) {
|
if removed.contains(Modifier::CROSSED_OUT) {
|
||||||
map_error(queue!(w, SetAttribute(CAttribute::NotCrossedOut)))?;
|
queue!(w, SetAttribute(CAttribute::NotCrossedOut))?;
|
||||||
}
|
}
|
||||||
if removed.contains(Modifier::SLOW_BLINK) || removed.contains(Modifier::RAPID_BLINK) {
|
if removed.contains(Modifier::SLOW_BLINK) || removed.contains(Modifier::RAPID_BLINK) {
|
||||||
map_error(queue!(w, SetAttribute(CAttribute::NoBlink)))?;
|
queue!(w, SetAttribute(CAttribute::NoBlink))?;
|
||||||
}
|
}
|
||||||
|
|
||||||
let added = self.to - self.from;
|
let added = self.to - self.from;
|
||||||
if added.contains(Modifier::REVERSED) {
|
if added.contains(Modifier::REVERSED) {
|
||||||
map_error(queue!(w, SetAttribute(CAttribute::Reverse)))?;
|
queue!(w, SetAttribute(CAttribute::Reverse))?;
|
||||||
}
|
}
|
||||||
if added.contains(Modifier::BOLD) {
|
if added.contains(Modifier::BOLD) {
|
||||||
map_error(queue!(w, SetAttribute(CAttribute::Bold)))?;
|
queue!(w, SetAttribute(CAttribute::Bold))?;
|
||||||
}
|
}
|
||||||
if added.contains(Modifier::ITALIC) {
|
if added.contains(Modifier::ITALIC) {
|
||||||
map_error(queue!(w, SetAttribute(CAttribute::Italic)))?;
|
queue!(w, SetAttribute(CAttribute::Italic))?;
|
||||||
}
|
}
|
||||||
if added.contains(Modifier::UNDERLINED) {
|
if added.contains(Modifier::UNDERLINED) {
|
||||||
map_error(queue!(w, SetAttribute(CAttribute::Underlined)))?;
|
queue!(w, SetAttribute(CAttribute::Underlined))?;
|
||||||
}
|
}
|
||||||
if added.contains(Modifier::DIM) {
|
if added.contains(Modifier::DIM) {
|
||||||
map_error(queue!(w, SetAttribute(CAttribute::Dim)))?;
|
queue!(w, SetAttribute(CAttribute::Dim))?;
|
||||||
}
|
}
|
||||||
if added.contains(Modifier::CROSSED_OUT) {
|
if added.contains(Modifier::CROSSED_OUT) {
|
||||||
map_error(queue!(w, SetAttribute(CAttribute::CrossedOut)))?;
|
queue!(w, SetAttribute(CAttribute::CrossedOut))?;
|
||||||
}
|
}
|
||||||
if added.contains(Modifier::SLOW_BLINK) {
|
if added.contains(Modifier::SLOW_BLINK) {
|
||||||
map_error(queue!(w, SetAttribute(CAttribute::SlowBlink)))?;
|
queue!(w, SetAttribute(CAttribute::SlowBlink))?;
|
||||||
}
|
}
|
||||||
if added.contains(Modifier::RAPID_BLINK) {
|
if added.contains(Modifier::RAPID_BLINK) {
|
||||||
map_error(queue!(w, SetAttribute(CAttribute::RapidBlink)))?;
|
queue!(w, SetAttribute(CAttribute::RapidBlink))?;
|
||||||
}
|
}
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
|
|
|
@ -12,8 +12,8 @@
|
||||||
//! Add the following to your `Cargo.toml`:
|
//! Add the following to your `Cargo.toml`:
|
||||||
//! ```toml
|
//! ```toml
|
||||||
//! [dependencies]
|
//! [dependencies]
|
||||||
//! crossterm = "0.26"
|
//! crossterm = "0.27"
|
||||||
//! ratatui = "0.20"
|
//! ratatui = "0.22"
|
||||||
//! ```
|
//! ```
|
||||||
//!
|
//!
|
||||||
//! The crate is using the `crossterm` backend by default that works on most platforms. But if for
|
//! The crate is using the `crossterm` backend by default that works on most platforms. But if for
|
||||||
|
@ -22,8 +22,8 @@
|
||||||
//!
|
//!
|
||||||
//! ```toml
|
//! ```toml
|
||||||
//! [dependencies]
|
//! [dependencies]
|
||||||
//! termion = "1.5"
|
//! termion = "2.0.1"
|
||||||
//! ratatui = { version = "0.20", default-features = false, features = ['termion'] }
|
//! ratatui = { version = "0.22", default-features = false, features = ['termion'] }
|
||||||
//! ```
|
//! ```
|
||||||
//!
|
//!
|
||||||
//! The same logic applies for all other available backends.
|
//! The same logic applies for all other available backends.
|
||||||
|
|
Loading…
Add table
Reference in a new issue