summaryrefslogtreecommitdiffstats
path: root/alacritty_terminal
diff options
context:
space:
mode:
authorKirill Chibisov <contact@kchibisov.com>2020-07-27 23:49:25 +0300
committerGitHub <noreply@github.com>2020-07-27 20:49:25 +0000
commitb7faa9f4378cf922c44f53a8003731fb0de13670 (patch)
tree5a7d7186e007f8f5f6ae913caba8bd8fa6c1cfc9 /alacritty_terminal
parenta7d5a965c54aab85ea7671b4622edd13262f60d7 (diff)
Fix CellForeground and CellBackground cursor colors
This commit fixes regression introduced in bedf5f3004e8f33011925ca471be02ead96f4581, when setting certain CellForeground/CellBackground combinations stoppped working.
Diffstat (limited to 'alacritty_terminal')
-rw-r--r--alacritty_terminal/src/term/mod.rs23
1 files changed, 12 insertions, 11 deletions
diff --git a/alacritty_terminal/src/term/mod.rs b/alacritty_terminal/src/term/mod.rs
index 7d00961e..ef61ebdf 100644
--- a/alacritty_terminal/src/term/mod.rs
+++ b/alacritty_terminal/src/term/mod.rs
@@ -398,13 +398,14 @@ impl<'a, C> Iterator for RenderableCellsIter<'a, C> {
let mut cell = RenderableCell::new(self, cell);
if self.cursor.key.style == CursorStyle::Block {
- // Invert cursor if static background is close to the cell's background.
- match self.cursor.cursor_color {
- CellRgb::Rgb(col) if col.contrast(cell.bg) >= MIN_CURSOR_CONTRAST => {
- cell.fg = self.cursor.text_color.color(cell.fg, cell.bg);
+ cell.fg = match self.cursor.cursor_color {
+ // Apply cursor color, or invert the cursor if it has a fixed background
+ // close to the cell's background.
+ CellRgb::Rgb(col) if col.contrast(cell.bg) < MIN_CURSOR_CONTRAST => {
+ cell.bg
},
- _ => cell.fg = cell.bg,
- }
+ _ => self.cursor.text_color.color(cell.fg, cell.bg),
+ };
}
return Some(cell);
@@ -422,11 +423,11 @@ impl<'a, C> Iterator for RenderableCellsIter<'a, C> {
let mut cell = RenderableCell::new(self, cell);
cell.inner = RenderableCellContent::Cursor(self.cursor.key);
- // Only apply static color if it isn't close to the cell's current background.
- if let CellRgb::Rgb(color) = self.cursor.cursor_color {
- if color.contrast(cell.bg) >= MIN_CURSOR_CONTRAST {
- cell.fg = self.cursor.cursor_color.color(cell.fg, cell.bg);
- }
+ // Apply cursor color, or invert the cursor if it has a fixed background close
+ // to the cell's background.
+ match self.cursor.cursor_color {
+ CellRgb::Rgb(color) if color.contrast(cell.bg) < MIN_CURSOR_CONTRAST => (),
+ _ => cell.fg = self.cursor.cursor_color.color(cell.fg, cell.bg),
}
return Some(cell);