diff --git a/src/tui/terminal_view.zig b/src/tui/terminal_view.zig index a6fc412..d62daf5 100644 --- a/src/tui/terminal_view.zig +++ b/src/tui/terminal_view.zig @@ -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});