feat(terminal): support OSC 10/11 query terminal fg/bg color

This commit is contained in:
CJ van den Berg 2026-02-26 20:52:06 +01:00
parent f68102e448
commit 519d8dd886
Signed by: neurocyte
GPG key ID: 8EB1E1BB660E3FB9

View file

@ -189,7 +189,7 @@ pub fn shutdown(allocator: Allocator) void {
}
}
pub fn render(self: *Self, _: *const Widget.Theme) bool {
pub fn render(self: *Self, theme: *const Widget.Theme) bool {
// Drain the vt event queue.
while (self.vt.vt.tryEvent()) |event| {
switch (event) {
@ -209,6 +209,17 @@ pub fn render(self: *Self, _: *const Widget.Theme) bool {
}
}
// Update the terminal's fg/bg color cache from the current theme so that
// OSC 10/11 colour queries return accurate values.
if (theme.editor.fg) |fg| {
const c = fg.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.
self.vt.vt.draw(self.allocator, self.plane.window, self.focused) catch |e| {
std.log.err("terminal_view: draw failed: {}", .{e});