From 70918570a980908d127146790d63abed48fe262f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bla=C5=BE=20Hrastnik?= Date: Wed, 7 Aug 2024 04:30:38 +0900 Subject: [PATCH] tui: Port improvement from ratatui on crossterm 0.28 (https://github.com/ratatui-org/ratatui/pull/1072) --- helix-tui/src/backend/crossterm.rs | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/helix-tui/src/backend/crossterm.rs b/helix-tui/src/backend/crossterm.rs index 0e60e386..e8947ee0 100644 --- a/helix-tui/src/backend/crossterm.rs +++ b/helix-tui/src/backend/crossterm.rs @@ -8,8 +8,8 @@ use crossterm::{ }, execute, queue, style::{ - Attribute as CAttribute, Color as CColor, Print, SetAttribute, SetBackgroundColor, - SetForegroundColor, + Attribute as CAttribute, Color as CColor, Colors, Print, SetAttribute, SetBackgroundColor, + SetColors, SetForegroundColor, }, terminal::{self, Clear, ClearType}, Command, @@ -260,14 +260,12 @@ where diff.queue(&mut self.buffer)?; modifier = cell.modifier; } - if cell.fg != fg { - let color = CColor::from(cell.fg); - queue!(self.buffer, SetForegroundColor(color))?; + if cell.fg != fg || cell.bg != bg { + queue!( + self.buffer, + SetColors(Colors::new(cell.fg.into(), cell.bg.into())) + )?; fg = cell.fg; - } - if cell.bg != bg { - let color = CColor::from(cell.bg); - queue!(self.buffer, SetBackgroundColor(color))?; bg = cell.bg; }