wezterm: apply transparency tint to all background colors

refs: https://github.com/wez/wezterm/issues/141#issuecomment-711442986
This commit is contained in:
Wez Furlong committed 2020-10-18 21:51:12 -07:00
1 parent 2df66cbdbe
commit aa660d5d06
3 files changed
+21 -19

No files matched your search

+3 -5
View File
@@ -260,11 +260,9 @@ When using a background image or background opacity, the image content can
have relatively low contrast with respect to the text you are trying to
read in your terminal.
The `window_background_tint` setting specifies the alpha channel value
to use for cells that are rendered with the ANSI default background color
attribute. Cells that have reversed or other background colors, or that
are explicitly setting the color attributes to a color that happens to
be the same as the default background are not affected by this setting.
The `window_background_tint` setting specifies the alpha channel value to use
for the background color of cells when either `window_background_image` or
`window_background_opacity` are in use.
The default for this setting is `0.0` such that the background image or
desktop content shows through the window relatively unimpeded.
+12 -14
View File
@@ -2914,7 +2914,6 @@ impl TermWindow {
};
let style = self.fonts.match_style(params.config, attrs);
let bg_is_default = attrs.background == ColorAttribute::Default;
let bg_color = params.palette.resolve_bg(attrs.background);
let fg_color = match attrs.foreground {
wezterm_term::color::ColorAttribute::Default => {
@@ -2942,29 +2941,28 @@ impl TermWindow {
_ => params.palette.resolve_fg(attrs.foreground),
};
let (fg_color, bg_color, bg_is_default) = {
let (fg_color, bg_color) = {
let mut fg = fg_color;
let mut bg = bg_color;
let mut bg_is_default = bg_is_default;
if attrs.reverse() {
std::mem::swap(&mut fg, &mut bg);
// reversed, so don't let it be transparent
bg_is_default = false;
}
(fg, bg, bg_is_default)
(fg, bg)
};
let glyph_color = rgbcolor_to_window_color(fg_color);
let bg_color = if bg_is_default {
rgbcolor_alpha_to_window_color(
bg_color,
(params.config.window_background_tint * 255.0) as u8,
)
} else {
rgbcolor_to_window_color(bg_color)
};
let bg_color = rgbcolor_alpha_to_window_color(
bg_color,
if self.window_background.is_none()
&& params.config.window_background_opacity == 1.0
{
0xff
} else {
(params.config.window_background_tint * 255.0) as u8
},
);
// Shape the printable text from this cluster
let glyph_info = {
+6
View File
@@ -276,6 +276,12 @@ impl Color {
Color::rgba(red, green, blue, 0xff)
}
#[inline]
pub fn with_alpha(self, alpha: u8) -> Self {
let (r, g, b, _) = self.as_rgba();
Self::rgba(r, g, b, alpha)
}
#[inline]
pub fn rgba(red: u8, green: u8, blue: u8, alpha: u8) -> Color {
#[allow(clippy::cast_lossless)]