diff --git a/example/zig-formatter/src/main.zig b/example/zig-formatter/src/main.zig index 87a8e4915..085b6d116 100644 --- a/example/zig-formatter/src/main.zig +++ b/example/zig-formatter/src/main.zig @@ -31,7 +31,7 @@ pub fn main() !void { // Use TerminalFormatter to emit HTML const formatter: ghostty_vt.formatter.TerminalFormatter = .init(&t, .{ .emit = .html, - .palette = &t.color_palette.colors, + .palette = &t.colors.palette.current, }); // Write to stdout diff --git a/src/config/Config.zig b/src/config/Config.zig index a9aaf8f86..78ea19aef 100644 --- a/src/config/Config.zig +++ b/src/config/Config.zig @@ -4960,6 +4960,13 @@ pub const TerminalColor = union(enum) { return .{ .color = try Color.parseCLI(input) }; } + pub fn toTerminalRGB(self: TerminalColor) ?terminal.color.RGB { + return switch (self) { + .color => |v| v.toTerminalRGB(), + .@"cell-foreground", .@"cell-background" => null, + }; + } + /// Used by Formatter pub fn formatEntry(self: TerminalColor, formatter: formatterpkg.EntryFormatter) !void { switch (self) { diff --git a/src/inspector/cell.zig b/src/inspector/cell.zig index 9a3112bdd..b2dc59fef 100644 --- a/src/inspector/cell.zig +++ b/src/inspector/cell.zig @@ -130,7 +130,7 @@ pub const Cell = struct { switch (self.style.fg_color) { .none => cimgui.c.igText("default"), .palette => |idx| { - const rgb = t.color_palette.colors[idx]; + const rgb = t.colors.palette.current[idx]; cimgui.c.igValue_Int("Palette", idx); var color: [3]f32 = .{ @as(f32, @floatFromInt(rgb.r)) / 255, @@ -169,7 +169,7 @@ pub const Cell = struct { switch (self.style.bg_color) { .none => cimgui.c.igText("default"), .palette => |idx| { - const rgb = t.color_palette.colors[idx]; + const rgb = t.colors.palette.current[idx]; cimgui.c.igValue_Int("Palette", idx); var color: [3]f32 = .{ @as(f32, @floatFromInt(rgb.r)) / 255, diff --git a/src/inspector/cursor.zig b/src/inspector/cursor.zig index be1cd63fe..37ec412e9 100644 --- a/src/inspector/cursor.zig +++ b/src/inspector/cursor.zig @@ -51,7 +51,7 @@ pub fn renderInTable( switch (cursor.style.fg_color) { .none => cimgui.c.igText("default"), .palette => |idx| { - const rgb = t.color_palette.colors[idx]; + const rgb = t.colors.palette.current[idx]; cimgui.c.igValue_Int("Palette", idx); var color: [3]f32 = .{ @as(f32, @floatFromInt(rgb.r)) / 255, @@ -90,7 +90,7 @@ pub fn renderInTable( switch (cursor.style.bg_color) { .none => cimgui.c.igText("default"), .palette => |idx| { - const rgb = t.color_palette.colors[idx]; + const rgb = t.colors.palette.current[idx]; cimgui.c.igValue_Int("Palette", idx); var color: [3]f32 = .{ @as(f32, @floatFromInt(rgb.r)) / 255, diff --git a/src/renderer/Thread.zig b/src/renderer/Thread.zig index 210c2e337..fd9d0f51a 100644 --- a/src/renderer/Thread.zig +++ b/src/renderer/Thread.zig @@ -437,21 +437,6 @@ fn drainMailbox(self: *Thread) !void { grid.set.deref(grid.old_key); }, - .foreground_color => |color| { - self.renderer.foreground_color = color; - self.renderer.markDirty(); - }, - - .background_color => |color| { - self.renderer.background_color = color; - self.renderer.markDirty(); - }, - - .cursor_color => |color| { - self.renderer.cursor_color = color; - self.renderer.markDirty(); - }, - .resize => |v| self.renderer.setScreenSize(v), .change_config => |config| { diff --git a/src/renderer/generic.zig b/src/renderer/generic.zig index 9e13d0b41..0b4c55896 100644 --- a/src/renderer/generic.zig +++ b/src/renderer/generic.zig @@ -120,30 +120,6 @@ pub fn Renderer(comptime GraphicsAPI: type) type { scrollbar: terminal.Scrollbar, scrollbar_dirty: bool, - /// The foreground color set by an OSC 10 sequence. If unset then - /// default_foreground_color is used. - foreground_color: ?terminal.color.RGB, - - /// Foreground color set in the user's config file. - default_foreground_color: terminal.color.RGB, - - /// The background color set by an OSC 11 sequence. If unset then - /// default_background_color is used. - background_color: ?terminal.color.RGB, - - /// Background color set in the user's config file. - default_background_color: terminal.color.RGB, - - /// The cursor color set by an OSC 12 sequence. If unset then - /// default_cursor_color is used. - cursor_color: ?terminal.color.RGB, - - /// Default cursor color when no color is set explicitly by an OSC 12 command. - /// This is cursor color as set in the user's config, if any. If no cursor color - /// is set in the user's config, then the cursor color is determined by the - /// current foreground color. - default_cursor_color: ?configpkg.Config.TerminalColor, - /// The current set of cells to render. This is rebuilt on every frame /// but we keep this around so that we don't reallocate. Each set of /// cells goes into a separate shader. @@ -691,12 +667,6 @@ pub fn Renderer(comptime GraphicsAPI: type) type { .focused = true, .scrollbar = .zero, .scrollbar_dirty = false, - .foreground_color = null, - .default_foreground_color = options.config.foreground, - .background_color = null, - .default_background_color = options.config.background, - .cursor_color = null, - .default_cursor_color = options.config.cursor_color, // Render state .cells = .{}, @@ -1094,10 +1064,12 @@ pub fn Renderer(comptime GraphicsAPI: type) type { // Data we extract out of the critical area. const Critical = struct { bg: terminal.color.RGB, + fg: terminal.color.RGB, screen: terminal.Screen, screen_type: terminal.ScreenType, mouse: renderer.State.Mouse, preedit: ?renderer.State.Preedit, + cursor_color: ?terminal.color.RGB, cursor_style: ?renderer.CursorStyle, color_palette: terminal.color.Palette, scrollbar: terminal.Scrollbar, @@ -1132,36 +1104,16 @@ pub fn Renderer(comptime GraphicsAPI: type) type { // cross-thread mailbox message within the IO path. const scrollbar = state.terminal.screen.pages.scrollbar(); - // Swap bg/fg if the terminal is reversed - const bg = self.background_color orelse self.default_background_color; - const fg = self.foreground_color orelse self.default_foreground_color; - defer { - if (self.background_color) |*c| { - c.* = bg; - } else { - self.default_background_color = bg; - } - - if (self.foreground_color) |*c| { - c.* = fg; - } else { - self.default_foreground_color = fg; - } - } - - if (state.terminal.modes.get(.reverse_colors)) { - if (self.background_color) |*c| { - c.* = fg; - } else { - self.default_background_color = fg; - } - - if (self.foreground_color) |*c| { - c.* = bg; - } else { - self.default_foreground_color = bg; - } - } + // Get our bg/fg, swap them if reversed. + const RGB = terminal.color.RGB; + const bg: RGB, const fg: RGB = colors: { + const bg = state.terminal.colors.background.get().?; + const fg = state.terminal.colors.foreground.get().?; + break :colors if (state.terminal.modes.get(.reverse_colors)) + .{ fg, bg } + else + .{ bg, fg }; + }; // Get the viewport pin so that we can compare it to the current. const viewport_pin = state.terminal.screen.pages.pin(.{ .viewport = .{} }).?; @@ -1252,13 +1204,15 @@ pub fn Renderer(comptime GraphicsAPI: type) type { self.cells_viewport = viewport_pin; break :critical .{ - .bg = self.background_color orelse self.default_background_color, + .bg = bg, + .fg = fg, .screen = screen_copy, .screen_type = state.terminal.active_screen, .mouse = state.mouse, .preedit = preedit, + .cursor_color = state.terminal.colors.cursor.get(), .cursor_style = cursor_style, - .color_palette = state.terminal.color_palette.colors, + .color_palette = state.terminal.colors.palette.current, .scrollbar = scrollbar, .full_rebuild = full_rebuild, }; @@ -1277,6 +1231,9 @@ pub fn Renderer(comptime GraphicsAPI: type) type { critical.preedit, critical.cursor_style, &critical.color_palette, + critical.bg, + critical.fg, + critical.cursor_color, ); // Notify our shaper we're done for the frame. For some shapers, @@ -2104,11 +2061,6 @@ pub fn Renderer(comptime GraphicsAPI: type) type { self.uniforms.bools.use_linear_blending = config.blending.isLinear(); self.uniforms.bools.use_linear_correction = config.blending == .@"linear-corrected"; - // Set our new colors - self.default_background_color = config.background; - self.default_foreground_color = config.foreground; - self.default_cursor_color = config.cursor_color; - const bg_image_config_changed = self.config.bg_image_fit != config.bg_image_fit or self.config.bg_image_position != config.bg_image_position or @@ -2370,6 +2322,9 @@ pub fn Renderer(comptime GraphicsAPI: type) type { preedit: ?renderer.State.Preedit, cursor_style_: ?renderer.CursorStyle, color_palette: *const terminal.color.Palette, + background: terminal.color.RGB, + foreground: terminal.color.RGB, + terminal_cursor_color: ?terminal.color.RGB, ) !void { self.draw_mutex.lock(); defer self.draw_mutex.unlock(); @@ -2503,12 +2458,12 @@ pub fn Renderer(comptime GraphicsAPI: type) type { .extend => if (y == 0) { self.uniforms.padding_extend.up = !row.neverExtendBg( color_palette, - self.background_color orelse self.default_background_color, + background, ); } else if (y == self.cells.size.rows - 1) { self.uniforms.padding_extend.down = !row.neverExtendBg( color_palette, - self.background_color orelse self.default_background_color, + background, ); }, } @@ -2629,7 +2584,7 @@ pub fn Renderer(comptime GraphicsAPI: type) type { // configuration, inversions, selections, etc. const bg_style = style.bg(cell, color_palette); const fg_style = style.fg(.{ - .default = self.foreground_color orelse self.default_foreground_color, + .default = foreground, .palette = color_palette, .bold = self.config.bold_color, }); @@ -2649,7 +2604,7 @@ pub fn Renderer(comptime GraphicsAPI: type) type { // If no configuration, then our selection background // is our foreground color. - break :bg self.foreground_color orelse self.default_foreground_color; + break :bg foreground; } // Not selected @@ -2671,9 +2626,7 @@ pub fn Renderer(comptime GraphicsAPI: type) type { const fg = fg: { // Our happy-path non-selection background color // is our style or our configured defaults. - const final_bg = bg_style orelse - self.background_color orelse - self.default_background_color; + const final_bg = bg_style orelse background; // Whether we need to use the bg color as our fg color: // - Cell is selected, inverted, and set to cell-foreground @@ -2689,7 +2642,7 @@ pub fn Renderer(comptime GraphicsAPI: type) type { }; } - break :fg self.background_color orelse self.default_background_color; + break :fg background; } break :fg if (style.flags.inverse) @@ -2703,7 +2656,7 @@ pub fn Renderer(comptime GraphicsAPI: type) type { // Set the cell's background color. { - const rgb = bg orelse self.background_color orelse self.default_background_color; + const rgb = bg orelse background; // Determine our background alpha. If we have transparency configured // then this is dynamic depending on some situations. This is all @@ -2888,24 +2841,24 @@ pub fn Renderer(comptime GraphicsAPI: type) type { const style = cursor_style_ orelse break :cursor; const cursor_color = cursor_color: { // If an explicit cursor color was set by OSC 12, use that. - if (self.cursor_color) |v| break :cursor_color v; + if (terminal_cursor_color) |v| break :cursor_color v; // Use our configured color if specified - if (self.default_cursor_color) |v| switch (v) { + if (self.config.cursor_color) |v| switch (v) { .color => |color| break :cursor_color color.toTerminalRGB(), inline .@"cell-foreground", .@"cell-background", => |_, tag| { const sty = screen.cursor.page_pin.style(screen.cursor.page_cell); const fg_style = sty.fg(.{ - .default = self.foreground_color orelse self.default_foreground_color, + .default = foreground, .palette = color_palette, .bold = self.config.bold_color, }); const bg_style = sty.bg( screen.cursor.page_cell, color_palette, - ) orelse self.background_color orelse self.default_background_color; + ) orelse background; break :cursor_color switch (tag) { .color => unreachable, @@ -2915,7 +2868,7 @@ pub fn Renderer(comptime GraphicsAPI: type) type { }, }; - break :cursor_color self.foreground_color orelse self.default_foreground_color; + break :cursor_color foreground; }; self.addCursor(screen, style, cursor_color); @@ -2950,11 +2903,14 @@ pub fn Renderer(comptime GraphicsAPI: type) type { const sty = screen.cursor.page_pin.style(screen.cursor.page_cell); const fg_style = sty.fg(.{ - .default = self.foreground_color orelse self.default_foreground_color, + .default = foreground, .palette = color_palette, .bold = self.config.bold_color, }); - const bg_style = sty.bg(screen.cursor.page_cell, color_palette) orelse self.background_color orelse self.default_background_color; + const bg_style = sty.bg( + screen.cursor.page_cell, + color_palette, + ) orelse background; break :blk switch (txt) { // If the cell is reversed, use the opposite cell color instead. @@ -2962,7 +2918,7 @@ pub fn Renderer(comptime GraphicsAPI: type) type { .@"cell-background" => if (sty.flags.inverse) fg_style else bg_style, else => unreachable, }; - } else self.background_color orelse self.default_background_color; + } else background; self.uniforms.cursor_color = .{ uniform_color.r, @@ -2978,7 +2934,12 @@ pub fn Renderer(comptime GraphicsAPI: type) type { const range = preedit_range.?; var x = range.x[0]; for (preedit_v.codepoints[range.cp_offset..]) |cp| { - self.addPreeditCell(cp, .{ .x = x, .y = range.y }) catch |err| { + self.addPreeditCell( + cp, + .{ .x = x, .y = range.y }, + background, + foreground, + ) catch |err| { log.warn("error building preedit cell, will be invalid x={} y={}, err={}", .{ x, range.y, @@ -3253,10 +3214,12 @@ pub fn Renderer(comptime GraphicsAPI: type) type { self: *Self, cp: renderer.State.Preedit.Codepoint, coord: terminal.Coordinate, + screen_bg: terminal.color.RGB, + screen_fg: terminal.color.RGB, ) !void { // Preedit is rendered inverted - const bg = self.foreground_color orelse self.default_foreground_color; - const fg = self.background_color orelse self.default_background_color; + const bg = screen_fg; + const fg = screen_bg; // Render the glyph for our preedit text const render_ = self.font_grid.renderCodepoint( diff --git a/src/renderer/message.zig b/src/renderer/message.zig index d6255661f..e33922ae2 100644 --- a/src/renderer/message.zig +++ b/src/renderer/message.zig @@ -42,16 +42,6 @@ pub const Message = union(enum) { old_key: font.SharedGridSet.Key, }, - /// Change the foreground color as set by an OSC 10 command, if any. - foreground_color: ?terminal.color.RGB, - - /// Change the background color as set by an OSC 11 command, if any. - background_color: ?terminal.color.RGB, - - /// Change the cursor color. This can be done separately from changing the - /// config file in response to an OSC 12 command. - cursor_color: ?terminal.color.RGB, - /// Changes the size. The screen size might change, padding, grid, etc. resize: renderer.Size, diff --git a/src/terminal/Terminal.zig b/src/terminal/Terminal.zig index 2201a324c..64cda5ee3 100644 --- a/src/terminal/Terminal.zig +++ b/src/terminal/Terminal.zig @@ -73,17 +73,8 @@ scrolling_region: ScrollingRegion, /// The last reported pwd, if any. pwd: std.ArrayList(u8), -/// The default color palette. This is only modified by changing the config file -/// and is used to reset the palette when receiving an OSC 104 command. -default_palette: color.Palette = color.default, - -/// The color palette to use. The mask indicates which palette indices have been -/// modified with OSC 4 -color_palette: struct { - const Mask = std.StaticBitSet(@typeInfo(color.Palette).array.len); - colors: color.Palette = color.default, - mask: Mask = .initEmpty(), -} = .{}, +/// The color state for this terminal. +colors: Colors, /// The previous printed character. This is used for the repeat previous /// char CSI (ESC [ b). @@ -134,6 +125,23 @@ flags: packed struct { dirty: Dirty = .{}, } = .{}, +/// The various color configurations a terminal maintains and that can +/// be set dynamically via OSC, with defaults usually coming from a +/// configuration. +pub const Colors = struct { + background: color.DynamicRGB, + foreground: color.DynamicRGB, + cursor: color.DynamicRGB, + palette: color.DynamicPalette, + + pub const default: Colors = .{ + .background = .unset, + .foreground = .unset, + .cursor = .unset, + .palette = .default, + }; +}; + /// This is a set of dirty flags the renderer can use to determine /// what parts of the screen need to be redrawn. It is up to the renderer /// to clear these flags. @@ -199,6 +207,7 @@ pub const Options = struct { cols: size.CellCountInt, rows: size.CellCountInt, max_scrollback: usize = 10_000, + colors: Colors = .default, /// The default mode state. When the terminal gets a reset, it /// will revert back to this state. @@ -212,7 +221,7 @@ pub fn init( ) !Terminal { const cols = opts.cols; const rows = opts.rows; - return Terminal{ + return .{ .cols = cols, .rows = rows, .active_screen = .primary, @@ -226,6 +235,7 @@ pub fn init( .right = cols - 1, }, .pwd = .empty, + .colors = opts.colors, .modes = .{ .values = opts.default_modes, .default = opts.default_modes, diff --git a/src/terminal/color.zig b/src/terminal/color.zig index b71279dbb..4492d65ae 100644 --- a/src/terminal/color.zig +++ b/src/terminal/color.zig @@ -1,3 +1,5 @@ +const colorpkg = @This(); + const std = @import("std"); const assert = std.debug.assert; const x11_color = @import("x11_color.zig"); @@ -45,6 +47,97 @@ pub const default: Palette = default: { /// Palette is the 256 color palette. pub const Palette = [256]RGB; +/// A palette that can have its colors changed and reset. Purposely built +/// for terminal color operations. +pub const DynamicPalette = struct { + /// The current palette including any user modifications. + current: Palette, + + /// The original/default palette values. + original: Palette, + + /// A bitset where each bit represents whether the corresponding + /// palette index has been modified from its default value. + mask: Mask, + + const Mask = std.StaticBitSet(@typeInfo(Palette).array.len); + + pub const default: DynamicPalette = .init(colorpkg.default); + + /// Initialize a dynamic palette with a default palette. + pub fn init(def: Palette) DynamicPalette { + return .{ + .current = def, + .original = def, + .mask = .initEmpty(), + }; + } + + /// Set a custom color at the given palette index. + pub fn set(self: *DynamicPalette, idx: u8, color: RGB) void { + self.current[idx] = color; + self.mask.set(idx); + } + + /// Reset the color at the given palette index to its original value. + pub fn reset(self: *DynamicPalette, idx: u8) void { + self.current[idx] = self.original[idx]; + self.mask.unset(idx); + } + + /// Reset all colors to their original values. + pub fn resetAll(self: *DynamicPalette) void { + self.* = .init(self.original); + } + + /// Change the default palette, but preserve the changed values. + pub fn changeDefault(self: *DynamicPalette, def: Palette) void { + self.original = def; + + // Fast path, the palette is usually not changed. + if (self.mask.count() == 0) { + self.current = self.original; + return; + } + + // There are usually less set than unset, so iterate over the changed + // values and override them. + var current = def; + var it = self.mask.iterator(.{}); + while (it.next()) |idx| current[idx] = self.current[idx]; + self.current = current; + } +}; + +/// RGB value that can be changed and reset. This can also be totally unset +/// in every way, in which case the caller can determine their own ultimate +/// default. +pub const DynamicRGB = struct { + override: ?RGB, + default: ?RGB, + + pub const unset: DynamicRGB = .{ .override = null, .default = null }; + + pub fn init(def: RGB) DynamicRGB { + return .{ + .override = null, + .default = def, + }; + } + + pub fn get(self: *const DynamicRGB) ?RGB { + return self.override orelse self.default; + } + + pub fn set(self: *DynamicRGB, color: RGB) void { + self.override = color; + } + + pub fn reset(self: *DynamicRGB) void { + self.override = self.default; + } +}; + /// Color names in the standard 8 or 16 color palette. pub const Name = enum(u8) { black = 0, @@ -456,3 +549,118 @@ test "RGB.parse" { try testing.expectError(error.InvalidFormat, RGB.parse("#fffff")); try testing.expectError(error.InvalidFormat, RGB.parse("#gggggg")); } + +test "DynamicPalette: init" { + const testing = std.testing; + + var p: DynamicPalette = .init(default); + try testing.expectEqual(default, p.current); + try testing.expectEqual(default, p.original); + try testing.expectEqual(@as(usize, 0), p.mask.count()); +} + +test "DynamicPalette: set" { + const testing = std.testing; + + var p: DynamicPalette = .init(default); + const new_color = RGB{ .r = 255, .g = 0, .b = 0 }; + + p.set(0, new_color); + try testing.expectEqual(new_color, p.current[0]); + try testing.expect(p.mask.isSet(0)); + try testing.expectEqual(@as(usize, 1), p.mask.count()); + + try testing.expectEqual(default[0], p.original[0]); +} + +test "DynamicPalette: reset" { + const testing = std.testing; + + var p: DynamicPalette = .init(default); + const new_color = RGB{ .r = 255, .g = 0, .b = 0 }; + + p.set(0, new_color); + try testing.expect(p.mask.isSet(0)); + + p.reset(0); + try testing.expectEqual(default[0], p.current[0]); + try testing.expect(!p.mask.isSet(0)); + try testing.expectEqual(@as(usize, 0), p.mask.count()); +} + +test "DynamicPalette: resetAll" { + const testing = std.testing; + + var p: DynamicPalette = .init(default); + const new_color = RGB{ .r = 255, .g = 0, .b = 0 }; + + p.set(0, new_color); + p.set(5, new_color); + p.set(10, new_color); + try testing.expectEqual(@as(usize, 3), p.mask.count()); + + p.resetAll(); + try testing.expectEqual(default, p.current); + try testing.expectEqual(default, p.original); + try testing.expectEqual(@as(usize, 0), p.mask.count()); +} + +test "DynamicPalette: changeDefault with no changes" { + const testing = std.testing; + + var p: DynamicPalette = .init(default); + var new_palette = default; + new_palette[0] = RGB{ .r = 100, .g = 100, .b = 100 }; + + p.changeDefault(new_palette); + try testing.expectEqual(new_palette, p.original); + try testing.expectEqual(new_palette, p.current); + try testing.expectEqual(@as(usize, 0), p.mask.count()); +} + +test "DynamicPalette: changeDefault preserves changes" { + const testing = std.testing; + + var p: DynamicPalette = .init(default); + const custom_color = RGB{ .r = 255, .g = 0, .b = 0 }; + + p.set(5, custom_color); + try testing.expect(p.mask.isSet(5)); + + var new_palette = default; + new_palette[0] = RGB{ .r = 100, .g = 100, .b = 100 }; + new_palette[5] = RGB{ .r = 50, .g = 50, .b = 50 }; + + p.changeDefault(new_palette); + + try testing.expectEqual(new_palette, p.original); + try testing.expectEqual(new_palette[0], p.current[0]); + try testing.expectEqual(custom_color, p.current[5]); + try testing.expect(p.mask.isSet(5)); + try testing.expectEqual(@as(usize, 1), p.mask.count()); +} + +test "DynamicPalette: changeDefault with multiple changes" { + const testing = std.testing; + + var p: DynamicPalette = .init(default); + const red = RGB{ .r = 255, .g = 0, .b = 0 }; + const green = RGB{ .r = 0, .g = 255, .b = 0 }; + const blue = RGB{ .r = 0, .g = 0, .b = 255 }; + + p.set(1, red); + p.set(2, green); + p.set(3, blue); + + var new_palette = default; + new_palette[0] = RGB{ .r = 50, .g = 50, .b = 50 }; + new_palette[1] = RGB{ .r = 60, .g = 60, .b = 60 }; + + p.changeDefault(new_palette); + + try testing.expectEqual(new_palette[0], p.current[0]); + try testing.expectEqual(red, p.current[1]); + try testing.expectEqual(green, p.current[2]); + try testing.expectEqual(blue, p.current[3]); + try testing.expectEqual(@as(usize, 3), p.mask.count()); +} diff --git a/src/terminal/formatter.zig b/src/terminal/formatter.zig index 246624d5b..70cdd347b 100644 --- a/src/terminal/formatter.zig +++ b/src/terminal/formatter.zig @@ -225,7 +225,7 @@ pub const TerminalFormatter = struct { .plain => break :palette, .vt => { - for (self.terminal.color_palette.colors, 0..) |rgb, i| { + for (self.terminal.colors.palette.current, 0..) |rgb, i| { try writer.print( "\x1b]4;{d};rgb:{x:0>2}/{x:0>2}/{x:0>2}\x1b\\", .{ i, rgb.r, rgb.g, rgb.b }, @@ -236,7 +236,7 @@ pub const TerminalFormatter = struct { // For HTML, we emit CSS to setup our palette variables. .html => { try writer.writeAll("