From faa03fd3766367e4a84a15b768c2665ced4b0848 Mon Sep 17 00:00:00 2001 From: Mohammad AlSaleh Date: Sun, 31 Dec 2023 13:12:50 +0300 Subject: [PATCH] Support color inversion `htop` with *Monochromatic* colors is rendered correctly now. Signed-off-by: Mohammad AlSaleh --- src/terminal.rs | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/terminal.rs b/src/terminal.rs index ae3a562..4569fca 100644 --- a/src/terminal.rs +++ b/src/terminal.rs @@ -421,8 +421,18 @@ impl Terminal { let end = text.len(); let mut attrs = self.default_attrs; - let mut fg = convert_color(&self.colors, indexed.cell.fg); - let mut bg = convert_color(&self.colors, indexed.cell.bg); + + let (mut fg, mut bg) = if indexed.cell.flags.contains(Flags::INVERSE) { + ( + convert_color(&self.colors, indexed.cell.bg), + convert_color(&self.colors, indexed.cell.fg), + ) + } else { + ( + convert_color(&self.colors, indexed.cell.fg), + convert_color(&self.colors, indexed.cell.bg), + ) + }; // Change color if cursor if indexed.point == grid.cursor.point {