renderer: Allow the renderer to draw transparent cells

Co-authored-by: Kat <65649991+00-kat@users.noreply.github.com>
This commit is contained in:
nferhat
2025-07-11 12:47:28 +01:00
committed by Mitchell Hashimoto
parent 4aa28988a6
commit 991426e84e
2 changed files with 25 additions and 0 deletions

View File

@@ -516,6 +516,7 @@ pub fn Renderer(comptime GraphicsAPI: type) type {
cursor_text: ?configpkg.Config.TerminalColor,
background: terminal.color.RGB,
background_opacity: f64,
background_opacity_cells: bool,
foreground: terminal.color.RGB,
selection_background: ?configpkg.Config.TerminalColor,
selection_foreground: ?configpkg.Config.TerminalColor,
@@ -568,6 +569,7 @@ pub fn Renderer(comptime GraphicsAPI: type) type {
return .{
.background_opacity = @max(0, @min(1, config.@"background-opacity")),
.background_opacity_cells = config.@"background-opacity-cells",
.font_thicken = config.@"font-thicken",
.font_thicken_strength = config.@"font-thicken-strength",
.font_features = font_features.list,
@@ -2628,6 +2630,13 @@ pub fn Renderer(comptime GraphicsAPI: type) type {
// Cells that are reversed should be fully opaque.
if (style.flags.inverse) break :bg_alpha default;
// If the user requested to have opacity on all cells, apply it.
if (self.config.background_opacity_cells and bg_style != null) {
var opacity: f64 = @floatFromInt(default);
opacity *= self.config.background_opacity;
break :bg_alpha @intFromFloat(opacity);
}
// Cells that have an explicit bg color should be fully opaque.
if (bg_style != null) break :bg_alpha default;