feat: use solid alpha dimmed background color for highlight column

This commit is contained in:
CJ van den Berg 2025-04-18 20:51:04 +02:00
parent a9b902ab6c
commit 376ca8c9fc
Signed by: neurocyte
GPG key ID: 8EB1E1BB660E3FB9
4 changed files with 42 additions and 38 deletions

View file

@ -76,10 +76,18 @@ pub fn columns(self: *const Cell) usize {
}
pub fn dim(self: *Cell, alpha: u8) void {
self.cell.style.fg = apply_alpha_value(self.cell.style.fg, alpha);
self.dim_fg(alpha);
self.dim_bg(alpha);
}
pub fn dim_bg(self: *Cell, alpha: u8) void {
self.cell.style.bg = apply_alpha_value(self.cell.style.bg, alpha);
}
pub fn dim_fg(self: *Cell, alpha: u8) void {
self.cell.style.fg = apply_alpha_value(self.cell.style.fg, alpha);
}
fn apply_alpha_value(c: vaxis.Cell.Color, a: u8) vaxis.Cell.Color {
var rgb = if (c == .rgb) c.rgb else return c;
rgb[0] = @intCast((@as(u32, @intCast(rgb[0])) * a) / 256);