refactor(terminal): use color module helper u24_to_u8s
This commit is contained in:
parent
2bc8e0ac18
commit
d05741ba24
2 changed files with 8 additions and 9 deletions
|
|
@ -106,6 +106,10 @@ pub const RGBf = struct {
|
||||||
const GAMMA = 2.4;
|
const GAMMA = 2.4;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
pub fn u24_to_u8s(v: u24) [3]u8 {
|
||||||
|
return .{ @truncate(v >> 16), @truncate(v >> 8), @truncate(v) };
|
||||||
|
}
|
||||||
|
|
||||||
pub fn max_contrast(v: u24, a: u24, b: u24) u24 {
|
pub fn max_contrast(v: u24, a: u24, b: u24) u24 {
|
||||||
return RGB.max_contrast(RGB.from_u24(v), RGB.from_u24(a), RGB.from_u24(b)).to_u24();
|
return RGB.max_contrast(RGB.from_u24(v), RGB.from_u24(a), RGB.from_u24(b)).to_u24();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -18,7 +18,8 @@ const tui = @import("tui.zig");
|
||||||
const input = @import("input");
|
const input = @import("input");
|
||||||
const keybind = @import("keybind");
|
const keybind = @import("keybind");
|
||||||
pub const Mode = keybind.Mode;
|
pub const Mode = keybind.Mode;
|
||||||
const RGB = @import("color").RGB;
|
const color = @import("color");
|
||||||
|
const RGB = color.RGB;
|
||||||
|
|
||||||
pub const name = @typeName(Self);
|
pub const name = @typeName(Self);
|
||||||
|
|
||||||
|
|
@ -371,14 +372,8 @@ pub fn render(self: *Self, theme: *const Widget.Theme) bool {
|
||||||
|
|
||||||
// Update the terminal's fg/bg color cache from the current theme so that
|
// Update the terminal's fg/bg color cache from the current theme so that
|
||||||
// OSC 10/11 colour queries return accurate values.
|
// OSC 10/11 colour queries return accurate values.
|
||||||
if (theme.editor.fg) |fg| {
|
if (theme.editor.fg) |fg| self.vt.vt.fg_color = color.u24_to_u8s(fg.color);
|
||||||
const c = fg.color;
|
if (theme.editor.bg) |bg| self.vt.vt.bg_color = color.u24_to_u8s(bg.color);
|
||||||
self.vt.vt.fg_color = .{ @truncate(c >> 16), @truncate(c >> 8), @truncate(c) };
|
|
||||||
}
|
|
||||||
if (theme.editor.bg) |bg| {
|
|
||||||
const c = bg.color;
|
|
||||||
self.vt.vt.bg_color = .{ @truncate(c >> 16), @truncate(c >> 8), @truncate(c) };
|
|
||||||
}
|
|
||||||
|
|
||||||
// Blit the terminal's front screen into our vaxis.Window.
|
// Blit the terminal's front screen into our vaxis.Window.
|
||||||
const software_cursor = !tui.has_native_cursor();
|
const software_cursor = !tui.has_native_cursor();
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue