renderer: faint should not be applied to bg alpha

Fixes #889
This commit is contained in:
Mitchell Hashimoto
2023-11-15 11:38:16 -08:00
parent 1deafe34fb
commit ed3e3764d9
2 changed files with 14 additions and 10 deletions

View File

@ -1322,22 +1322,24 @@ pub fn updateCell(
// in an attempt to make transparency look the best for various
// situations. See inline comments.
const bg_alpha: u8 = bg_alpha: {
if (self.config.background_opacity >= 1) break :bg_alpha alpha;
const default: u8 = 255;
if (self.config.background_opacity >= 1) break :bg_alpha default;
// If we're selected, we do not apply background opacity
if (selected) break :bg_alpha alpha;
if (selected) break :bg_alpha default;
// If we're reversed, do not apply background opacity
if (cell.attrs.inverse) break :bg_alpha alpha;
if (cell.attrs.inverse) break :bg_alpha default;
// If we have a background and its not the default background
// then we apply background opacity
if (cell.attrs.has_bg and !std.meta.eql(rgb, self.background_color)) {
break :bg_alpha alpha;
break :bg_alpha default;
}
// We apply background opacity.
var bg_alpha: f64 = @floatFromInt(alpha);
var bg_alpha: f64 = @floatFromInt(default);
bg_alpha *= self.config.background_opacity;
bg_alpha = @ceil(bg_alpha);
break :bg_alpha @intFromFloat(bg_alpha);

View File

@ -1084,22 +1084,24 @@ pub fn updateCell(
// in an attempt to make transparency look the best for various
// situations. See inline comments.
const bg_alpha: u8 = bg_alpha: {
if (self.config.background_opacity >= 1) break :bg_alpha alpha;
const default: u8 = 255;
if (self.config.background_opacity >= 1) break :bg_alpha default;
// If we're selected, we do not apply background opacity
if (selected) break :bg_alpha alpha;
if (selected) break :bg_alpha default;
// If we're reversed, do not apply background opacity
if (cell.attrs.inverse) break :bg_alpha alpha;
if (cell.attrs.inverse) break :bg_alpha default;
// If we have a background and its not the default background
// then we apply background opacity
if (cell.attrs.has_bg and !std.meta.eql(rgb, self.background_color)) {
break :bg_alpha alpha;
break :bg_alpha default;
}
// We apply background opacity.
var bg_alpha: f64 = @floatFromInt(alpha);
var bg_alpha: f64 = @floatFromInt(default);
bg_alpha *= self.config.background_opacity;
bg_alpha = @ceil(bg_alpha);
break :bg_alpha @intFromFloat(bg_alpha);