mirror of
https://github.com/ghostty-org/ghostty.git
synced 2025-07-18 17:56:09 +03:00
renderer: Allow the renderer to draw transparent cells
Co-authored-by: Kat <65649991+00-kat@users.noreply.github.com>
This commit is contained in:

committed by
Mitchell Hashimoto

parent
4aa28988a6
commit
991426e84e
@ -814,6 +814,22 @@ palette: Palette = .{},
|
|||||||
/// On macOS, changing this configuration requires restarting Ghostty completely.
|
/// On macOS, changing this configuration requires restarting Ghostty completely.
|
||||||
@"background-opacity": f64 = 1.0,
|
@"background-opacity": f64 = 1.0,
|
||||||
|
|
||||||
|
/// Applies background opacity to cells with an explicit background color
|
||||||
|
/// set.
|
||||||
|
///
|
||||||
|
/// Normally, `background-opacity` is only applied to the window background.
|
||||||
|
/// If a cell has an explicit background color set, such as red, then that
|
||||||
|
/// background color will be fully opaque. An effect of this is that some
|
||||||
|
/// terminal applications that repaint the background color of the terminal
|
||||||
|
/// such as a Neovim and Tmux may not respect the `background-opacity`
|
||||||
|
/// (by design).
|
||||||
|
///
|
||||||
|
/// Setting this to `true` will apply the `background-opacity` to all cells
|
||||||
|
/// regardless of whether they have an explicit background color set or not.
|
||||||
|
///
|
||||||
|
/// Available since: 1.2.0
|
||||||
|
@"background-opacity-cells": bool = false,
|
||||||
|
|
||||||
/// Whether to blur the background when `background-opacity` is less than 1.
|
/// Whether to blur the background when `background-opacity` is less than 1.
|
||||||
///
|
///
|
||||||
/// Valid values are:
|
/// Valid values are:
|
||||||
|
@ -516,6 +516,7 @@ pub fn Renderer(comptime GraphicsAPI: type) type {
|
|||||||
cursor_text: ?configpkg.Config.TerminalColor,
|
cursor_text: ?configpkg.Config.TerminalColor,
|
||||||
background: terminal.color.RGB,
|
background: terminal.color.RGB,
|
||||||
background_opacity: f64,
|
background_opacity: f64,
|
||||||
|
background_opacity_cells: bool,
|
||||||
foreground: terminal.color.RGB,
|
foreground: terminal.color.RGB,
|
||||||
selection_background: ?configpkg.Config.TerminalColor,
|
selection_background: ?configpkg.Config.TerminalColor,
|
||||||
selection_foreground: ?configpkg.Config.TerminalColor,
|
selection_foreground: ?configpkg.Config.TerminalColor,
|
||||||
@ -568,6 +569,7 @@ pub fn Renderer(comptime GraphicsAPI: type) type {
|
|||||||
|
|
||||||
return .{
|
return .{
|
||||||
.background_opacity = @max(0, @min(1, config.@"background-opacity")),
|
.background_opacity = @max(0, @min(1, config.@"background-opacity")),
|
||||||
|
.background_opacity_cells = config.@"background-opacity-cells",
|
||||||
.font_thicken = config.@"font-thicken",
|
.font_thicken = config.@"font-thicken",
|
||||||
.font_thicken_strength = config.@"font-thicken-strength",
|
.font_thicken_strength = config.@"font-thicken-strength",
|
||||||
.font_features = font_features.list,
|
.font_features = font_features.list,
|
||||||
@ -2628,6 +2630,13 @@ pub fn Renderer(comptime GraphicsAPI: type) type {
|
|||||||
// Cells that are reversed should be fully opaque.
|
// Cells that are reversed should be fully opaque.
|
||||||
if (style.flags.inverse) break :bg_alpha default;
|
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.
|
// Cells that have an explicit bg color should be fully opaque.
|
||||||
if (bg_style != null) break :bg_alpha default;
|
if (bg_style != null) break :bg_alpha default;
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user