1
0
Fork 0
mirror of https://github.com/alacritty/alacritty.git synced 2024-11-18 13:55:23 -05:00

Fix cell opacity when color matches terminal bg

Commit e964af8 introduced a regression, where if cell's bg color was
equal to NamedColor::Background rgb color it was rendered with transparent
background. However the correct behavior is to render bg transparent
only when bg color is actually a NamedColor::Background.

Fixes #2814.
This commit is contained in:
Kirill Chibisov 2019-09-26 17:10:54 +03:00 committed by Christian Duerr
parent ad24485cdb
commit 9a0555bbba
2 changed files with 6 additions and 3 deletions

View file

@ -49,6 +49,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Block URL highlight while a selection is active
- Bindings for Alt + F1-F12
- Discard scrolling region escape with bottom above top
- Opacity always applying to cells with their background color matching the teriminal background
### Removed

View file

@ -273,11 +273,13 @@ impl RenderableCell {
// Lookup RGB values
let mut fg_rgb = Self::compute_fg_rgb(config, colors, cell.fg, cell.flags);
let mut bg_rgb = Self::compute_bg_rgb(colors, cell.bg);
let mut bg_alpha = Self::compute_bg_alpha(cell.bg);
let selection_background = config.colors.selection.background;
if let (true, Some(col)) = (selected, selection_background) {
// Override selection background with config colors
bg_rgb = col;
bg_alpha = 1.0;
} else if selected ^ cell.inverse() {
if fg_rgb == bg_rgb && !cell.flags.contains(Flags::HIDDEN) {
// Reveal inversed text when fg/bg is the same
@ -300,7 +302,7 @@ impl RenderableCell {
inner: RenderableCellContent::Chars(cell.chars()),
fg: fg_rgb,
bg: bg_rgb,
bg_alpha: Self::compute_bg_alpha(colors, bg_rgb),
bg_alpha,
flags: cell.flags,
}
}
@ -343,8 +345,8 @@ impl RenderableCell {
}
#[inline]
fn compute_bg_alpha(colors: &color::List, bg: Rgb) -> f32 {
if colors[NamedColor::Background] == bg {
fn compute_bg_alpha(bg: Color) -> f32 {
if bg == Color::Named(NamedColor::Background) {
0.
} else {
1.