summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGabriel Schneider <[email protected]>2026-11-26 10:19:20 -0300
committerGabriel Schneider <[email protected]>2026-11-26 11:28:39 -0300
commitadd0837dc1927389096cbaaf65b7e1a42028eafc (patch)
treecdf3252f64669691dd4d5338fc2019390d6d8131
parent7d0aaa0c1e68127c023358698498eaeffe57401b (diff)
downloadpardes-add0837dc1927389096cbaaf65b7e1a42028eafc.tar.gz
pardes-add0837dc1927389096cbaaf65b7e1a42028eafc.zip
colors, Core, Kind, lib: the old views deleted, now that no surface reads them (DESIGN.md B6, B8): `ChromeTheme` (its old fields, `view` and `resolved`) and the old names' view of every theme (`viewOf`, theme_schema's `toLegacy` and `Derived`), `readingOf` (the reading tint, gone with G1'), `separatorOf`, `focusTint`/`focusTintFloor` and their floors, `lerp`, the sRGB `mix`, and `Grounds` (the library's diff grounds: `Chrome`'s `add` and `del` say them; lib_syntax exports `Chrome` in its place); `Pardes.theme()` is the theme worn in the new names (`*const Theme`: a picker's preview, a theme file's, or the session's), read for its name; `chromeTheme()` is gone and `chrome()` is the one accessor (the session's chrome or a preview's, each a `Chrome` worked out at a theme change); a theme file is kept as the `Theme` it loads to (`custom_theme`), its old names read by the load-time loader, which STAYS (`LegacyTheme` and `Theme.fromLegacy`: the user's own one_dark_zed_mod.zon and an older DumpThemes' output load as before); Kind's page, ink, selection and link for a picture's or a PDF's raster from the chrome (R1: the page, never the tag, as a theme's page where it has none: dark's `null_page`; the link the page's key ink), the macOS shell's rules and page from the chrome and the theme's `page`; the source test (body_layer.zig's: no `theme()` read but its name, no `chromeTheme()`, `.roles`, `Grounds` or `LegacyTheme`) covers draw.zig, tagline.zig, Band.zig, Messages.zig and Kind.zig too, so a surface deriving its own colour cannot be written there (B6's bar); THE TESTS: the tests of the old derivations go with them, each held by the ring test on the chrome (every native's separators and focus tint, every faithful port's own chrome, a legacy document's derived roles, the old active name-tint precedence), and the rest read the new names and the chrome (a theme's own rule kept, the natives' text and UI roles on their own surfaces, their dark palettes, the quiet line numbers through a theme file, the column grips, the ThemeFile load and its old-names loader, Core's, Command's, panes', terminal's, output's and file_watch's theme reads, the library consumer's diff grounds through `Chrome`); RUN: the build is the test of a deletion (no reader left), the suites below; GOLDENS: none moved; GATES on this change, the stack's top (tui): core-test 1158/1332 (174 skipped: the 4 tests of the old derivations gone; the importer's 7 counted again after a cache wipe), shell-test 1373/1376 (3 skipped), pane-test 184/185 (1 skipped), behaviour-test 287/287 and --replay 20 seeds of 70 steps, 0 failures, process-test 0 of 149 failed (3 skipped; 0 of 103 moved with --update), term-test 17/17, kitty-test 45/45; gui unit-test 1984/1988 (4 skipped; its one failure the known BaselineHarnessMismatch; test/consumer's diff grounds through `Chrome` pass); the ring 245 of 245; the dump fuzz at 40,000 join seeds twice and 1,779 image seeds 11/11 (custom_theme, a digested field, is a Theme now); the soak (replicas, 5 clients, rtt 30,80,207): diverged 0, unequal 0, quiet checks 365/0 451/0 622/0, unlisted stops 0, the corpus 22 of 22 scenes the same, no leak; load 1.3 to 15.6 (other agents' builds); OUTSIDE the L2a files: core/colors.zig, core/Core.zig, core/root.zig, core/theme_schema.zig, core/lib_syntax.zig, core/syntax.zig (a doc line), core/Kind.zig (two hunks), core/File.zig (a test line), core/body_layer.zig (the source test's list), runtime/macos.zig (three lines), dev/file_watch.zig, test/consumer/lib.zig, test/panes.zig, test/terminal.zig, test/output.zig, core/Command.zig (tests)
Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_016Y9MNBFhdevVu48bvL9kCE
-rw-r--r--core/Command.zig8
-rw-r--r--core/Core.zig37
-rw-r--r--core/File.zig2
-rw-r--r--core/Kind.zig16
-rw-r--r--core/body_layer.zig5
-rw-r--r--core/colors.zig488
-rw-r--r--core/lib_syntax.zig7
-rw-r--r--core/root.zig2
-rw-r--r--core/syntax.zig2
-rw-r--r--core/theme_schema.zig46
-rw-r--r--dev/file_watch.zig6
-rw-r--r--runtime/macos.zig8
-rw-r--r--test/consumer/lib.zig10
-rw-r--r--test/output.zig6
-rw-r--r--test/panes.zig23
-rw-r--r--test/terminal.zig26
16 files changed, 151 insertions, 541 deletions
diff --git a/core/Command.zig b/core/Command.zig
index f41d0639..132ad9e4 100644
--- a/core/Command.zig
+++ b/core/Command.zig
@@ -842,14 +842,14 @@ test ":theme lists the themes and the whole window wears the current one, none d
p.view().active = id;
const s = &p.view().tag_state;
const own = p.theme();
- const own_chrome = p.chromeTheme().*;
+ const own_chrome = p.chrome().*;
typeKeys(p, ":theme ");
try std.testing.expectEqual(Rows.themes, s.prompt.command.rows);
try std.testing.expectEqual(@as(u16, @intCast(colors.themes.len)), s.nhits);
try std.testing.expect(has(try tagOf(p), try std.fmt.allocPrint(a, " {d} themes · the window wears the current one ", .{colors.themes.len})));
// The window wears the first: its colours, its chrome; no pane dimmed.
try std.testing.expectEqualStrings(colors.themes[s.hits[0]].name, p.theme().name);
- try std.testing.expectEqual(colors.ChromeTheme.fromTheme(p.theme()), p.chromeTheme().*);
+ try std.testing.expectEqual(colors.Chrome.of(p.theme()), p.chrome().*);
try std.testing.expect(s.previewing.isSet(other));
const surface = try p.render(a);
const r = p.view().rects[other];
@@ -864,13 +864,13 @@ test ":theme lists the themes and the whole window wears the current one, none d
const next = colors.themes[s.hits[1]].name;
try std.testing.expectEqualStrings(try std.fmt.allocPrint(a, "theme {s}", .{next}), s.field.text());
try std.testing.expectEqualStrings(next, p.theme().name);
- try std.testing.expectEqual(colors.ChromeTheme.fromTheme(p.theme()), p.chromeTheme().*);
+ try std.testing.expectEqual(colors.Chrome.of(p.theme()), p.chrome().*);
// A load meanwhile (dump.afterLoad) works out the session's own chrome,
// never the one worn. Esc: the window's own again, nothing set.
colors.finishThemeInitialization(p);
p.update(.{ .key = .{ .cp = Key.escape } });
try std.testing.expectEqualStrings(own.name, p.theme().name);
- try std.testing.expectEqual(own_chrome, p.chromeTheme().*);
+ try std.testing.expectEqual(own_chrome, p.chrome().*);
try std.testing.expect(p.theme_preview == null and !s.previewing.isSet(other));
// Enter keeps the one the window wears.
typeKeys(p, ":theme o");
diff --git a/core/Core.zig b/core/Core.zig
index e727d27d..947fee4c 100644
--- a/core/Core.zig
+++ b/core/Core.zig
@@ -12,7 +12,6 @@ const BOX_H = pardes.BOX_H;
const Builtin = pardes.Builtin;
const COLBAR_H = pardes.COLBAR_H;
const CellPixels = pardes.CellPixels;
-const ChromeTheme = pardes.ChromeTheme;
const Color = pardes.Color;
const Effect = pardes.Effect;
const Event = pardes.Event;
@@ -47,7 +46,6 @@ const TAG_TEXT_INSET = pardes.TAG_TEXT_INSET;
const TOPBAR_H = pardes.TOPBAR_H;
const TagHit = pardes.TagHit;
const Text = pardes.panes.Text;
-const LegacyTheme = pardes.LegacyTheme;
const builtins = pardes.builtins;
const colors = pardes.colors;
const column_weight_unit = layout.column_weight_unit;
@@ -345,19 +343,19 @@ locations_config: locations.Config = .{},
locations_cache: locations.Cache = .{},
tty_filter_palette: pardes.Term.FilterPalette = .{},
font_request_taken: bool = false,
-custom_theme: ?LegacyTheme = null,
+custom_theme: ?colors.Theme = null,
/// The theme the window wears while a picker of them (or `:theme `)
/// previews one, by index, and its chrome (colors.previewTheme); the
/// session's own theme untouched under it.
theme_preview: ?u16 = null,
-preview_chrome: ChromeTheme = undefined,
+preview_chrome: colors.Chrome = undefined,
theme_file_path: config.Settings.Text(limits.host_path_cap) = .{},
/// The ThemeFile last loaded whole: what /ctl and DumpConfig name, and
/// what a failed ThemeFile goes back to (colors.revertThemeFile).
theme_file_loaded: config.Settings.Text(limits.host_path_cap) = .{},
theme_file_generation: u32 = 0,
theme_file_pane: Pane.Id = .at(0),
-theme_chrome: colors.ChromeTheme = undefined,
+theme_chrome: colors.Chrome = undefined,
/// Every drawn frame's timings (FrameStats: the Debug box, PARDES_FRAMES):
/// its runner's (`Options.frames`), which its frontend writes as it draws
/// and reads input, never the core's memory; a core with no runner (a
@@ -2173,23 +2171,20 @@ fn sizes(p: *const Pardes, pane: *const Pane) bool {
return pane.sized_by == p.live;
}
-/// The theme in the old names, for what still reads a theme's own
-/// fields (colors.ChromeTheme.view).
-pub fn theme(p: *const Pardes) *const LegacyTheme {
- if (p.theme_preview == null) if (p.custom_theme) |*custom| return custom;
- return &p.chromeTheme().view;
-}
-
-/// The colours of the chrome: the theme's, set as it changes.
-pub fn chromeTheme(p: *const Pardes) *const ChromeTheme {
- if (p.theme_preview != null) return &p.preview_chrome;
- return &p.theme_chrome;
+/// The theme the window wears: one a picker previews, a theme file's, or
+/// the session's. Its name is what is read of it; a surface draws its
+/// chrome (`chrome`).
+pub fn theme(p: *const Pardes) *const colors.Theme {
+ if (p.theme_preview) |i| return &colors.themes[i];
+ if (p.custom_theme) |*custom| return custom;
+ return &colors.themes[p.settings.theme];
}
/// Every colour a surface draws (colors.Chrome), the theme's or the one a
/// picker previews: worked out as the theme changes, never a frame.
pub fn chrome(p: *const Pardes) *const colors.Chrome {
- return &p.chromeTheme().resolved;
+ if (p.theme_preview != null) return &p.preview_chrome;
+ return &p.theme_chrome;
}
/// When the core next needs a frame, on the `stepped_ns` timeline: a
@@ -2544,7 +2539,7 @@ test "startup config runs builtin lines in order and isolates bad lines" {
try std.testing.expectEqualStrings("acme", p.theme().name);
// The theme lands without a tween (the chrome is the theme's at once);
// the bad lines are said, so a notice may be up.
- try std.testing.expectEqual(ChromeTheme.fromTheme(p.theme()), p.chromeTheme().*);
+ try std.testing.expectEqual(colors.Chrome.of(p.theme()), p.chrome().*);
try std.testing.expect(!p.quit);
for (0..p.effects_len) |i| switch (p.effects[(p.effects_head + i) % p.effects.len]) {
.write => |w| {
@@ -3649,8 +3644,8 @@ test "startup config overrides restored styling before initFromDump returns" {
try std.testing.expectEqualStrings("acme", restored.theme().name);
try std.testing.expect(!source.animationActive());
try std.testing.expect(!restored.animationActive());
- try std.testing.expectEqual(ChromeTheme.fromTheme(source.theme()), source.chromeTheme().*);
- try std.testing.expectEqual(ChromeTheme.fromTheme(restored.theme()), restored.chromeTheme().*);
+ try std.testing.expectEqual(colors.Chrome.of(source.theme()), source.chrome().*);
+ try std.testing.expectEqual(colors.Chrome.of(restored.theme()), restored.chrome().*);
}
test "restored terminals keep monotonic nonzero pane identities" {
@@ -3743,7 +3738,7 @@ test "tabbed file aligns syntax cursor and mouse at the nearest insertion gap" {
const text_x = rect.x + config.GUTTER + config.PREFIX_W;
const body_y = rect.y + BOX_H;
// The keyword's ink shows the glyph boundaries.
- const kw: Color = .{ .rgb = p.theme().kw };
+ const kw: Color = .{ .rgb = p.theme().keyword };
for (0..config.tab_width) |col|
try std.testing.expect(!std.meta.eql(kw, surface.at(text_x + @as(u16, @intCast(col)), body_y).style.fg));
for (0.."return".len) |col|
diff --git a/core/File.zig b/core/File.zig
index d54d5011..1a25975f 100644
--- a/core/File.zig
+++ b/core/File.zig
@@ -3659,7 +3659,7 @@ test "Syntax takes a text's ink off in this view and puts it back, and another v
const id = p.view().active;
var arena: std.heap.ArenaAllocator = .init(gpa);
defer arena.deinit();
- const plain: pardes.Color = if (p.theme().fg) |c| .{ .rgb = c } else .default;
+ const plain: pardes.Color = if (p.theme().text) |c| .{ .rgb = c } else .default;
var inks: [16]pardes.Color = undefined;
const Frame = struct {
fn take(q: *Pardes, a: *std.heap.ArenaAllocator, shown: *const Pane, at: usize, out: []pardes.Color) !void {
diff --git a/core/Kind.zig b/core/Kind.zig
index 4841a55c..ffea8aa3 100644
--- a/core/Kind.zig
+++ b/core/Kind.zig
@@ -442,9 +442,9 @@ pub fn close(p: *Pardes, pane: *Pane) void {
pub fn draw(p: *Pardes, s: *surface.Surface, arena: std.mem.Allocator, pane: *Pane, id: usize, x: u16, y: u16, cols: u16, rows: u16) bool {
const slot = pane.addon orelse return true;
if (cols == 0 or rows == 0) return true;
- const th = p.theme();
- const fg: surface.Color = if (th.fg) |f| .{ .rgb = f } else .default;
- const bg: surface.Color = if (th.bg) |b| .{ .rgb = b } else .default;
+ const chrome = p.chrome();
+ const fg: surface.Color = if (chrome.host_page) .default else .{ .rgb = chrome.page.text };
+ const bg: surface.Color = if (chrome.host_page) .default else .{ .rgb = chrome.page.ground };
var frame: Frame = .{ .cols = cols, .rows = rows };
if (slot.ops == null and slot.live) {
// A client: a plain kind runs where it is shown, and this one lacks
@@ -791,7 +791,7 @@ pub fn viewOf(p: *const Pardes, k: u8, id: usize) c.pa_view {
// Its bands made again, never the copy a step or a park left: they are
// derived, so a client joined from a dump has none.
const notices = pardes.Messages.bands(p, pane, tag_rows, r).span();
- const th = p.theme();
+ const chrome = p.chrome();
const rgb = struct {
fn f(x: [3]u8) u32 {
return @as(u32, x[0]) << 16 | @as(u32, x[1]) << 8 | x[2];
@@ -803,10 +803,10 @@ pub fn viewOf(p: *const Pardes, k: u8, id: usize) c.pa_view {
.rows = (r.h -| tag_rows) -| notices,
.cell_w = v.cell_pixels.w,
.cell_h = v.cell_pixels.h,
- .fg = rgb(th.fg orelse th.tag_fg),
- .bg = rgb(th.bg orelse th.tag_bg),
- .sel = rgb(th.sel_bg),
- .link = rgb(th.box),
+ .fg = rgb(chrome.page.text),
+ .bg = rgb(chrome.page.ground),
+ .sel = rgb(chrome.page.selection.ground),
+ .link = rgb(chrome.page.key),
.dpi = policy.dpi,
.max_px = policy.max_dimension,
.fill = @intFromBool(policy.match_viewport),
diff --git a/core/body_layer.zig b/core/body_layer.zig
index a1d76784..7da2129d 100644
--- a/core/body_layer.zig
+++ b/core/body_layer.zig
@@ -1463,6 +1463,11 @@ test "the body's surfaces take every colour from the chrome: none reads a theme'
.{ "Pick.zig", @embedFile("Pick.zig") },
.{ "jj.zig", @embedFile("jj.zig") },
.{ "ansi.zig", @embedFile("ansi.zig") },
+ .{ "draw.zig", @embedFile("draw.zig") },
+ .{ "tagline.zig", @embedFile("tagline.zig") },
+ .{ "Band.zig", @embedFile("Band.zig") },
+ .{ "Messages.zig", @embedFile("Messages.zig") },
+ .{ "Kind.zig", @embedFile("Kind.zig") },
};
var wrong: usize = 0;
for (sources) |source| {
diff --git a/core/colors.zig b/core/colors.zig
index 711abfad..f89f81cc 100644
--- a/core/colors.zig
+++ b/core/colors.zig
@@ -71,16 +71,10 @@ fn luminanceContrast(x: f32, y: f32) f32 {
return (@max(x, y) + 0.05) / (@min(x, y) + 0.05);
}
-pub fn lerp(a: [3]u8, b: [3]u8, t: f32) [3]u8 {
- var out: [3]u8 = undefined;
- for (&out, a, b) |*o, x, y| o.* = @intFromFloat(std.math.clamp(@round(@as(f32, @floatFromInt(x)) + (@as(f32, @floatFromInt(y)) - @as(f32, @floatFromInt(x))) * t), 0, 255));
- return out;
-}
-
/// The rules between panes and columns: acme's contrast, black on white.
-/// A theme's own border, or its scroll track, as long as it stands off the
-/// page by 1.5:1; one that does not (on a near-black page, a dark rule all
-/// but vanishes) is lifted toward the text until it does, to 1.6:1.
+/// A theme's own rule, or its rail, as long as it stands off the page by
+/// 1.5:1; one that does not (on a near-black page, a dark rule all but
+/// vanishes) is held until it does, to 1.6:1 (R11, Chrome.separator_lift).
pub const separator_floor: f32 = 1.5;
/// The page a theme with none (`dark`: the host's own) is judged against:
/// the GUI's default ground, and a dark terminal's.
@@ -88,46 +82,6 @@ pub const null_page: [3]u8 = .{ 18, 18, 18 };
/// The ink of a theme with none, on a dark page and on a light one.
pub const null_text: [3]u8 = .{ 0xcc, 0xcc, 0xcc };
const null_text_light: [3]u8 = .{ 0x22, 0x22, 0x22 };
-fn separatorOf(th: *const LegacyTheme) [3]u8 {
- const base = th.border orelse th.scroll_track;
- const page = th.bg orelse null_page;
- if (contrast(base, page) >= separator_floor) return base;
- const ink = th.fg orelse th.tag_fg;
- var t: f32 = 0.05;
- while (t <= 1) : (t += 0.05) {
- const lifted = lerp(base, ink, t);
- if (contrast(lifted, page) >= 1.6) return lifted;
- }
- return ink;
-}
-
-/// The focused tag's tint, the main focus indicator: a theme's own, pushed
-/// further the way it already leans from the plain tag where the two are
-/// closer than the floor (1.5:1 on a dark page, where a tint is all that
-/// tells the focused tag at a glance; 1.25:1 on a light one), but never so
-/// far its text drops below its own contrast or 4.5. A theme with no tint
-/// (acme: the grip's button says it) keeps none.
-pub const focus_tint_floor: f32 = 1.25;
-pub const focus_tint_floor_dark: f32 = 1.5;
-pub fn focusTintFloor(th: *const LegacyTheme) f32 {
- return if (relativeLuminance(th.bg orelse null_page) < 0.18) focus_tint_floor_dark else focus_tint_floor;
-}
-fn focusTint(th: *const LegacyTheme) [3]u8 {
- const tint = th.tag_active_bg orelse return th.tag_bg;
- const floor = focusTintFloor(th);
- if (contrast(tint, th.tag_bg) >= floor) return tint;
- const ink = th.tag_active_fg orelse th.tag_fg;
- const text_floor = @min(contrast(ink, tint), 4.5);
- var best = tint;
- var k: f32 = 1.1;
- while (k <= 12) : (k += 0.1) {
- const pushed = lerp(th.tag_bg, tint, k);
- if (contrast(ink, pushed) < text_floor) break;
- best = pushed;
- if (contrast(pushed, th.tag_bg) >= floor) break;
- }
- return best;
-}
/// sRGB bytes to OKLab and back (Björn Ottosson's), and a mix in it.
fn toOklab(rgb: [3]u8) [3]f32 {
@@ -261,12 +215,6 @@ pub fn nameTintFloor(ink: [3]u8, ground: [3]u8) f32 {
return @min(4.5, contrast(ink, ground) - 0.5);
}
-pub fn mix(a: [3]u8, b: [3]u8) [3]u8 {
- var out: [3]u8 = undefined;
- for (&out, a, b) |*c, x, y| c.* = @intCast((@as(u16, x) + y) / 2);
- return out;
-}
-
/// The derivations' OKLab, with no pow (B9's budget): a byte's linear
/// light from `to_linear`, and back to a byte by the light where its
/// rounding turns. `toOklab` and `fromOklab` (their f32 pow) stay the old
@@ -315,6 +263,13 @@ const byte_turns: [255]f32 = blk: {
break :blk table;
};
+/// The least contrast `ink` has on any of `grounds`.
+fn leastContrast(ink: [3]u8, grounds: []const [3]u8) f32 {
+ var least: f32 = 21;
+ for (grounds) |g| least = @min(least, contrast(ink, g));
+ return least;
+}
+
/// `toward` in the derivations' OKLab.
fn towardOf(ink: [3]u8, ground: [3]u8, floor: f32) [3]u8 {
var line: Line = .init(ink, ground);
@@ -1093,29 +1048,6 @@ pub fn synInk(th: *const Theme, sy: @import("syntax.zig").Syn) ?[3]u8 {
};
}
-/// The grounds a style byte's high bits name (syntax.ground_add and the
-/// rest) in a theme, for the library: its chrome's added and deleted rows
-/// (R10). Syntax colours are drawn over a ground unchanged.
-pub const Grounds = struct {
- add: Ground,
- del: Ground,
-
- pub const Ground = Chrome.Diff;
-
- pub fn of(th: *const Theme) Grounds {
- const c = Chrome.of(th);
- return .{ .add = c.add, .del = c.del };
- }
-
- /// The ground of a byte's hue, if it has one.
- pub fn forStyle(g: *const Grounds, style: u8) ?Ground {
- const syntax = @import("syntax.zig");
- if (style & syntax.ground_add != 0) return g.add;
- if (style & syntax.ground_del != 0) return g.del;
- return null;
- }
-};
-
/// One family, its eight backgrounds a theme each (`curated`).
const seoul256 = @import("themes/seoul256.zig");
@@ -1412,154 +1344,6 @@ comptime {
@compileError("theme name \"" ++ c.name ++ "\" is both ours and generated; rename the vendored source");
}
-pub const ChromeTheme = struct {
- tag_bg: [3]u8,
- tag_fg: [3]u8,
- tagline_bg: [3]u8,
- tagline_fg: [3]u8,
- tag_active_bg: [3]u8,
- tag_active_fg: [3]u8,
- tag_name_fg: [3]u8,
- tag_active_name_fg: [3]u8,
- border: [3]u8,
- empty_col: [3]u8,
- search_bg: [3]u8,
- tag_reading_bg: [3]u8,
- diagnostic_error: [3]u8,
- diagnostic_warning: [3]u8,
- box: [3]u8,
- box_dim: [3]u8,
- column_box: [3]u8,
- column_box_dim: [3]u8,
- scroll_track: [3]u8,
- scroll_thumb: [3]u8,
- /// Everything B4 derives (`Chrome`), what the surfaces move to; the
- /// fields above are the old derivations' values, kept for
- /// the surfaces that still read them until they do (the themes
- /// programme's L2 lines), so no frame moves before its surface does.
- resolved: Chrome,
- /// The theme in the old names (`Pardes.theme()`), for what still reads
- /// a theme's own fields: a ThemeFile in them, itself; any other theme's
- /// filled from its chrome where the new names derive (`viewOf`).
- view: LegacyTheme,
-
- /// A theme in the old names' chrome.
- pub fn fromTheme(th: *const LegacyTheme) ChromeTheme {
- return .of(&.fromLegacy(th.*), th, .of(&.fromLegacy(th.*)));
- }
-
- /// A theme in the new names' chrome: the ring's, a ThemeFile's.
- pub fn ofTheme(theme: *const Theme) ChromeTheme {
- const resolved: Chrome = .of(theme);
- return .of(theme, &viewOf(theme, &resolved), resolved);
- }
-
- /// A theme's chrome, from the theme, its old names' view and what B4
- /// derives of it.
- fn of(theme: *const Theme, th: *const LegacyTheme, resolved: Chrome) ChromeTheme {
- const active_bg = focusTint(th);
- const active_fg = th.tag_active_fg orelse th.tag_fg;
- // A name is always tinted: a theme that names no tint gets one of
- // its own hues, on each ground. One that names only the plain tint
- // keeps it when focused too.
- const name_fg = th.tag_name_fg orelse (derivedNameTint(theme, th.tag_fg, th.tag_bg) orelse th.tag_fg);
- const active_name_fg = th.tag_active_name_fg orelse
- (th.tag_name_fg orelse (derivedNameTint(theme, active_fg, active_bg) orelse active_fg));
- const reading = readingOf(th);
- return .{
- .tag_bg = th.tag_bg,
- .tag_fg = th.tag_fg,
- .tagline_bg = th.tagline_bg orelse th.tag_bg,
- .tagline_fg = th.tagline_fg orelse th.tag_fg,
- .tag_active_bg = active_bg,
- .tag_active_fg = active_fg,
- .tag_name_fg = name_fg,
- .tag_active_name_fg = active_name_fg,
- .border = separatorOf(th),
- .empty_col = th.empty_col orelse separatorOf(th),
- .search_bg = th.search_bg orelse th.sel_bg,
- .tag_reading_bg = reading,
- // A theme's error ink, else its palette's red (UX E3).
- .diagnostic_error = th.diagnostic_error orelse if (th.palette) |pal| pal[1] else (th.fg orelse th.tag_fg),
- .diagnostic_warning = th.diagnostic_warning orelse (th.fg orelse th.tag_fg),
- // The focused grip the chrome's (the accent held 3:1, R6).
- .box = resolved.grip.focus,
- .box_dim = th.box_dim,
- .column_box = th.column_box orelse th.num,
- .column_box_dim = th.column_box_dim orelse mix(th.column_box orelse th.num, th.tag_bg),
- .scroll_track = th.scroll_track,
- .scroll_thumb = th.scroll_thumb,
- .resolved = resolved,
- .view = th.*,
- };
- }
-};
-
-/// A theme in the new names as the old names say it: the fields they
-/// require and the new ones derive, from its chrome. `box_dim`, a resting
-/// grip's fill: the tag's own ground where the theme rings its grips itself
-/// (acme's clean button, R6), else the resting ring. The focused name the
-/// chrome's, unless it lands on the theme's own focused ink, which the old
-/// surfaces draw unheld (ferra's #fecdb2): then the plain tag's.
-fn viewOf(theme: *const Theme, r: *const Chrome) LegacyTheme {
- const fill = if (theme.grip_ring != null) r.tag[0].ground else r.grip.ring;
- const own_focus_ink = theme.tag_focus_text orelse theme.tag_text;
- const focused_name = if (std.mem.eql(u8, &r.name[1], &own_focus_ink)) r.name[0] else r.name[1];
- return theme.toLegacy(.{
- .sel_fg = r.page.selection.text,
- .lineno = r.line_number,
- .scroll_track = r.rail,
- .scroll_thumb = r.rail_thumb,
- .box_dim = fill,
- .tag_active_name_fg = focused_name,
- .column_box_dim = r.grip.column_rest,
- });
-}
-
-fn leastContrast(ink: [3]u8, grounds: []const [3]u8) f32 {
- var least: f32 = 21;
- for (grounds) |g| least = @min(least, contrast(ink, g));
- return least;
-}
-
-/// A reading pane's tag (UX DESIGN.md D4): the theme's own where it stands
-/// off the tag, else the tag shifted toward paper yellow by 0.04 in OKLab
-/// and lighter by half that on a dark tag (darker on a light), so it reads
-/// as a page; then less light, or darker, where its text would lose
-/// contrast, and further where the bytes cannot show so small a step (a
-/// near-black tag).
-fn readingOf(th: *const LegacyTheme) [3]u8 {
- const reading_distance = 0.04;
- if (th.tag_reading_bg) |own| if (oklabDistance(toOklab(own), toOklab(th.tag_bg)) >= reading_distance) return own;
- const tag = toOklab(th.tag_bg);
- const paper = toOklab(.{ 0xdc, 0xc8, 0x78 });
- const da = paper[1] - tag[1];
- const db = paper[2] - tag[2];
- const n = @max(@sqrt(da * da + db * db), 1e-6);
- const sign: f32 = if (relativeLuminance(th.tag_bg) < 0.18) 1 else -1;
- // Away from the text's lightness, where the first lean costs it.
- const away: f32 = if (relativeLuminance(th.tag_fg) > relativeLuminance(th.tag_bg)) -1 else 1;
- const inks = [2][3]u8{ th.tag_fg, th.tag_active_fg orelse th.tag_fg };
- var best = th.tag_bg;
- var best_text: f32 = -21;
- var reach: f32 = reading_distance;
- while (reach <= 0.2) : (reach *= 1.25) {
- for ([_]f32{ sign * 0.5, 0, away * 0.5, away, away * 1.5 }) |lean| {
- const c = fromOklab(.{ tag[0] + lean * reach, tag[1] + da / n * reach, tag[2] + db / n * reach });
- if (oklabDistance(toOklab(c), tag) < reading_distance) continue;
- // Each ink by its own floor: 7:1, or what it has on the tag.
- var text: f32 = 21;
- for (inks) |ink| text = @min(text, contrast(ink, c) - (@min(7, contrast(ink, th.tag_bg)) - 0.01));
- if (text >= 0) return c;
- if (text > best_text) {
- best = c;
- best_text = text;
- }
- }
- }
- return best;
-}
-
fn nextThemeFileGeneration(p: *Pardes) u32 {
p.theme_file_generation +%= 1;
if (p.theme_file_generation == 0) p.theme_file_generation = 1;
@@ -1697,32 +1481,23 @@ pub fn loadThemeFile(p: *Pardes, generation: u32, bytes: []const u8) bool {
var diagnostics: std.zon.parse.Diagnostics = undefined;
const options: std.zon.parse.Options = .{ .gpa = p.gpa, .arena = arena.allocator(), .source = source, .diagnostics = &diagnostics };
// A file in the old names (every one written before 2026-11-25: a
- // user's own, an older DumpThemes') is read in them and renamed; its
- // old names' view is the file itself.
- var theme: Theme = undefined;
- var chrome: ChromeTheme = undefined;
- if (inOldNames(source)) {
- const view = std.zon.parse.fromSlice(LegacyTheme, options) catch |err| return zonFailed(p, request, err, &diagnostics);
- chrome = .fromTheme(&view);
- theme = .fromLegacy(view);
- } else {
- theme = std.zon.parse.fromSlice(Theme, options) catch |err| return zonFailed(p, request, err, &diagnostics);
- chrome = .ofTheme(&theme);
- }
+ // user's own, an older DumpThemes') is read in them and renamed.
+ var theme: Theme = if (inOldNames(source))
+ .fromLegacy(std.zon.parse.fromSlice(LegacyTheme, options) catch |err| return zonFailed(p, request, err, &diagnostics))
+ else
+ std.zon.parse.fromSlice(Theme, options) catch |err| return zonFailed(p, request, err, &diagnostics);
if (theme.name.len == 0 or theme.name.len > 255) {
themeFileError(p, request, error.InvalidThemeName);
return false;
}
- var view = chrome.view;
- view.name = p.gpa.dupe(u8, theme.name) catch |err| {
+ theme.name = p.gpa.dupe(u8, theme.name) catch |err| {
themeFileError(p, request, err);
return false;
};
- chrome.view.name = view.name;
- p.theme_chrome = chrome;
+ p.theme_chrome = .of(&theme);
const old = p.custom_theme;
- p.custom_theme = view;
+ p.custom_theme = theme;
if (old) |theme_value| p.gpa.free(theme_value.name);
_ = p.theme_file_loaded.set(request.path);
_ = p.scratch.reset(.{ .retain_with_limit = pardes.memory.limits.scratch_kept });
@@ -1759,7 +1534,7 @@ fn inOldNames(source: [:0]const u8) bool {
/// The session's theme's chrome, at its start (Pardes.init, a Restore):
/// never one the window previews (`previewTheme`).
pub fn finishThemeInitialization(p: *Pardes) void {
- p.theme_chrome = if (p.custom_theme) |*custom| .fromTheme(custom) else .ofTheme(&themes[p.settings.theme]);
+ p.theme_chrome = .of(if (p.custom_theme) |*custom| custom else &themes[p.settings.theme]);
}
/// Themes near `name`, a line of them, for a Theme given a name there is
@@ -1839,14 +1614,14 @@ pub fn previewTheme(p: *Pardes, index: ?usize) void {
if (i >= themes.len) return;
if (p.theme_preview) |had| if (had == i) return;
p.theme_preview = @intCast(i);
- p.preview_chrome = .ofTheme(&themes[i]);
+ p.preview_chrome = .of(&themes[i]);
}
pub fn setThemeIndex(p: *Pardes, index: usize) void {
if (index >= themes.len or
(p.custom_theme == null and p.theme_file_path.get().len == 0 and
index == @as(usize, p.settings.theme))) return;
- p.theme_chrome = .ofTheme(&themes[index]);
+ p.theme_chrome = .of(&themes[index]);
if (p.custom_theme) |theme_value| {
p.custom_theme = null;
p.gpa.free(theme_value.name);
@@ -1860,58 +1635,9 @@ pub fn setThemeIndex(p: *Pardes, index: usize) void {
p.settings.theme = @intCast(index);
}
-test "every native theme's separators stand off its page, and its focus tint off its tag" {
- for (themes[0..native_count]) |*ring_theme| {
- const view = ChromeTheme.ofTheme(ring_theme).view;
- const theme = &view;
- const chrome = ChromeTheme.fromTheme(theme);
- const page = theme.bg orelse null_page;
- try std.testing.expect(contrast(chrome.border, page) >= separator_floor);
- // A focused tag of its own stands off the plain one (R4 derives the
- // rest: the ring test's `focus`).
- if (theme.tag_active_bg) |own| {
- try std.testing.expect(contrast(chrome.tag_active_bg, theme.tag_bg) >= focusTintFloor(theme));
- // And its text still reads.
- const ink = theme.tag_active_fg orelse theme.tag_fg;
- try std.testing.expect(contrast(ink, chrome.tag_active_bg) >= @min(contrast(ink, own), 4.5) - 0.01);
- }
- }
-}
-
-test "every faithful port meets pardes's chrome floors in its own colours, with nothing left to derive" {
- const first = comptime indexOfTheme("dark_plus");
- const last = comptime indexOfTheme("helix");
- for (themes[first..last]) |*ring_theme| {
- const view = ChromeTheme.ofTheme(ring_theme).view;
- const th = &view;
- const chrome = ChromeTheme.fromTheme(th);
- const page = th.bg.?;
- // Written out already adjusted: the run-time lift and push leave
- // the file's own values, so what the file says is what is drawn.
- try std.testing.expectEqual(th.border.?, chrome.border);
- try std.testing.expectEqual(th.tag_active_bg.?, chrome.tag_active_bg);
- try std.testing.expect(contrast(th.border.?, page) >= separator_floor);
- try std.testing.expect(contrast(th.tag_active_bg.?, th.tag_bg) >= focusTintFloor(th));
- try std.testing.expect(contrast(th.tag_fg, th.tag_bg) >= 4.5);
- try std.testing.expect(contrast(th.tag_active_fg.?, th.tag_active_bg.?) >= 4.5);
- try std.testing.expect(contrast(th.box_dim, th.tag_bg) >= 1.5);
- try std.testing.expect(th.palette != null);
- // A status bar of its own reads as tag text does; without one the
- // tagline is the tag's.
- try std.testing.expect(contrast(chrome.tagline_fg, chrome.tagline_bg) >= 4.5);
- if (th.tagline_bg == null) try std.testing.expectEqual(th.tag_bg, chrome.tagline_bg);
- }
-}
-
-test "a derived separator or tint keeps the theme's own when it already stands off" {
- const view = ChromeTheme.ofTheme(&themes[comptime indexOfTheme("forge")]).view;
- const forge = &view;
- const chrome = ChromeTheme.fromTheme(forge);
- try std.testing.expectEqual(forge.border.?, chrome.border);
- // forge's own tint is 1.23:1 off its tag: pushed on the way it leans.
- try std.testing.expect(!std.meta.eql(forge.tag_active_bg.?, chrome.tag_active_bg));
- for (chrome.tag_active_bg, forge.tag_active_bg.?, forge.tag_bg) |pushed, own, plain|
- try std.testing.expect(pushed >= own and own >= plain);
+test "a theme's own rule is kept where it already stands off its page" {
+ const forge = &themes[comptime indexOfTheme("forge")];
+ try std.testing.expectEqual(forge.rule.?, Chrome.of(forge).rule);
}
test "an OKLab fade holds its ends exactly and keeps a mid-way bright" {
@@ -1923,7 +1649,7 @@ test "an OKLab fade holds its ends exactly and keeps a mid-way bright" {
// OKLab it keeps its lightness.
const red: [3]u8 = .{ 255, 0, 0 };
const green: [3]u8 = .{ 0, 200, 0 };
- const srgb_mid = mix(red, green);
+ const srgb_mid: [3]u8 = .{ 128, 100, 0 };
const lab_mid = mixOklab(red, green, 0.5);
try std.testing.expect(relativeLuminance(lab_mid) > relativeLuminance(srgb_mid) * 1.3);
}
@@ -2037,8 +1763,8 @@ test "ThemeFile parses ZON atomically and Theme returns to the compiled ring" {
try std.zon.stringify.serialize(custom, .{ .whitespace = true }, &encoded.writer);
try std.testing.expect(loadThemeFile(p, request_effect.generation, encoded.written()));
try std.testing.expectEqualStrings("mine", p.theme().name);
- try std.testing.expectEqual(@as(?[3]u8, .{ 1, 2, 3 }), p.theme().bg);
- try std.testing.expectEqual(ChromeTheme.fromTheme(p.theme()), p.chromeTheme().*);
+ try std.testing.expectEqual(@as(?[3]u8, .{ 1, 2, 3 }), p.theme().page);
+ try std.testing.expectEqual(Chrome.of(p.theme()), p.chrome().*);
// A half-written save is rejected without disturbing the last good value.
try std.testing.expect(!loadThemeFile(p, request_effect.generation, ".{ .name = "));
@@ -2046,7 +1772,7 @@ test "ThemeFile parses ZON atomically and Theme returns to the compiled ring" {
const said = p.messages.saidBy(p.panes[0].?);
try std.testing.expect(std.mem.indexOf(u8, said, ": line 1: ") != null and std.mem.indexOf(u8, said, "parse zon") == null);
try std.testing.expectEqualStrings("mine", p.theme().name);
- try std.testing.expectEqual(@as(?[3]u8, .{ 1, 2, 3 }), p.theme().bg);
+ try std.testing.expectEqual(@as(?[3]u8, .{ 1, 2, 3 }), p.theme().page);
setThemeIndex(p, default_theme);
try std.testing.expectEqualStrings(themes[default_theme].name, p.theme().name);
@@ -2060,35 +1786,34 @@ test "ThemeFile parses ZON atomically and Theme returns to the compiled ring" {
test "native themes keep text and UI roles readable on their own surfaces" {
for (designed) |name| {
- const th = ChromeTheme.ofTheme(&themes[themeIndex(name).?]).view;
- const chrome = ChromeTheme.fromTheme(&th);
+ const th = &themes[themeIndex(name).?];
+ const c = Chrome.of(th);
+ const page = th.page.?;
const minimum: f32 = if (std.mem.eql(u8, name, "ink") or std.mem.eql(u8, name, "daybreak")) 7 else 4.5;
- const text_colors = [_][3]u8{
- th.fg.?, th.kw, th.str, th.num, th.comment,
- } ++ chrome.resolved.page.severity;
- for (text_colors) |fg| try std.testing.expect(contrast(fg, th.bg.?) >= minimum);
+ const text_colors = [_][3]u8{ th.text.?, th.keyword, th.string, th.number, th.comment } ++ c.page.severity;
+ for (text_colors) |fg| try std.testing.expect(contrast(fg, page) >= minimum);
// Gutters are orientation aids, not source text: stay visible without
// competing with comments or pulling attention away from the body.
- try std.testing.expect(contrast(th.lineno, th.bg.?) >= 2.5);
- try std.testing.expect(contrast(th.lineno, th.bg.?) <= 4);
- try std.testing.expect(contrast(th.lineno_active.?, th.bg.?) >= contrast(th.lineno, th.bg.?));
- try std.testing.expect(contrast(th.lineno_active.?, th.bg.?) <= 4.5);
- try std.testing.expect(contrast(th.comment, th.bg.?) >= 5);
- try std.testing.expect(contrast(th.comment, th.bg.?) >= contrast(th.lineno, th.bg.?) + 2);
- try std.testing.expect(contrast(th.tag_fg, th.tag_bg) >= minimum);
- try std.testing.expect(contrast(chrome.tag_active_fg, chrome.tag_active_bg) >= minimum);
- try std.testing.expect(th.tag_name_fg != null);
- try std.testing.expect(contrast(chrome.tag_name_fg, th.tag_bg) >= minimum);
- try std.testing.expect(contrast(chrome.tag_active_name_fg, chrome.tag_active_bg) >= minimum);
+ try std.testing.expect(contrast(c.line_number, page) >= 2.5);
+ try std.testing.expect(contrast(c.line_number, page) <= 4);
+ try std.testing.expect(contrast(c.line_number_current, page) >= contrast(c.line_number, page));
+ try std.testing.expect(contrast(c.line_number_current, page) <= 4.5);
+ try std.testing.expect(contrast(th.comment, page) >= 5);
+ try std.testing.expect(contrast(th.comment, page) >= contrast(c.line_number, page) + 2);
+ try std.testing.expect(th.tag_name != null);
+ for (c.tag, c.name) |inks, tint| {
+ try std.testing.expect(contrast(inks.text, inks.ground) >= minimum);
+ try std.testing.expect(contrast(tint, inks.ground) >= minimum);
+ }
// Focus stays on the same tonal surface, rather than inverting a
// whole command strip. Text remains readable in both states.
- try std.testing.expect(contrast(chrome.tag_active_bg, th.tag_bg) <= 1.6);
- try std.testing.expect(contrast(chrome.tag_active_fg, th.tag_fg) <= 1.6);
- try std.testing.expect(contrast(th.sel_fg, th.sel_bg) >= minimum);
- try std.testing.expect(contrast(chrome.resolved.hit_current_text, chrome.resolved.hit_current) >= Chrome.text_floor);
+ try std.testing.expect(contrast(c.tag[1].ground, c.tag[0].ground) <= 1.6);
+ try std.testing.expect(contrast(c.tag[1].text, c.tag[0].text) <= 1.6);
+ try std.testing.expect(contrast(c.page.selection.text, c.page.selection.ground) >= minimum);
+ try std.testing.expect(contrast(c.hit_current_text, c.hit_current) >= Chrome.text_floor);
// ANSI black can intentionally match the page (for backgrounds). All
// other ANSI foregrounds, including bright black, remain legible.
- for (th.palette.?[1..]) |fg| try std.testing.expect(contrast(fg, th.bg.?) >= minimum);
+ for (c.ansi[1..]) |fg| try std.testing.expect(contrast(fg, page) >= minimum);
}
}
@@ -2124,16 +1849,16 @@ test "native filename tints change hue without changing perceived lightness" {
test "native dark palettes choose near-black or deliberately soft contrast" {
for (designed) |name| {
- const th = ChromeTheme.ofTheme(&themes[themeIndex(name).?]).view;
- if (contrast(th.bg.?, .{ 0, 0, 0 }) > 10) continue; // light paper
+ const th = &themes[themeIndex(name).?];
+ if (contrast(th.page.?, .{ 0, 0, 0 }) > 10) continue; // light paper
const soft = std.mem.eql(u8, th.name, "dusk") or std.mem.eql(u8, th.name, "lagoon") or
std.mem.eql(u8, th.name, "solarium") or std.mem.eql(u8, th.name, "forge_soft");
if (soft) {
- try std.testing.expect(contrast(th.fg.?, th.bg.?) >= 4.5);
- try std.testing.expect(contrast(th.fg.?, th.bg.?) <= 7);
+ try std.testing.expect(contrast(th.text.?, th.page.?) >= 4.5);
+ try std.testing.expect(contrast(th.text.?, th.page.?) <= 7);
} else {
- for (th.bg.?) |channel| try std.testing.expect(channel <= 0x14);
- try std.testing.expect(contrast(th.fg.?, th.bg.?) >= 14);
+ for (th.page.?) |channel| try std.testing.expect(channel <= 0x14);
+ try std.testing.expect(contrast(th.text.?, th.page.?) >= 14);
}
}
const forge = curated.forge.theme;
@@ -2152,10 +1877,10 @@ test "line numbers stay quiet without a current-line tag background" {
const pane = try p.setTestFile("first\nsecond\n");
pane.body.cur_pinned = true;
pane.body.cur_row = 0;
- var custom = ChromeTheme.ofTheme(&themes[default_theme]).view;
+ var custom = themes[default_theme];
custom.name = try gpa.dupe(u8, "quiet-gutter");
- custom.lineno = .{ 70, 70, 70 };
- custom.lineno_active = .{ 95, 95, 95 };
+ custom.line_number = .{ 70, 70, 70 };
+ custom.line_number_current = .{ 95, 95, 95 };
p.custom_theme = custom;
finishThemeInitialization(p);
p.sync();
@@ -2164,17 +1889,17 @@ test "line numbers stay quiet without a current-line tag background" {
const surface = try p.render(p.scratch.allocator());
try std.testing.expectEqual(Color{ .rgb = .{ 95, 95, 95 } }, surface.at(x, y).style.fg);
try std.testing.expectEqual(Color{ .rgb = .{ 70, 70, 70 } }, surface.at(x, y + 1).style.fg);
- try std.testing.expectEqual(Color{ .rgb = custom.bg.? }, surface.at(x, y).style.bg);
+ try std.testing.expectEqual(Color{ .rgb = custom.page.? }, surface.at(x, y).style.bg);
try std.testing.expect(surface.at(x, y).style.bold);
try std.testing.expect(!surface.at(x, y + 1).style.bold);
// Old ThemeFile palettes need no new field: the current number is the
// text toward the page to 4.5:1 (R12), and the block not regained.
- p.custom_theme.?.lineno_active = null;
+ p.custom_theme.?.line_number_current = null;
finishThemeInitialization(p);
const fallback = try p.render(p.scratch.allocator());
try std.testing.expectEqual(Color{ .rgb = p.chrome().line_number_current }, fallback.at(x, y).style.fg);
- try std.testing.expect(contrast(p.chrome().line_number_current, custom.bg.?) >= Chrome.text_floor - 0.05);
- try std.testing.expectEqual(Color{ .rgb = custom.bg.? }, fallback.at(x, y).style.bg);
+ try std.testing.expect(contrast(p.chrome().line_number_current, custom.page.?) >= Chrome.text_floor - 0.05);
+ try std.testing.expectEqual(Color{ .rgb = custom.page.? }, fallback.at(x, y).style.bg);
try std.testing.expect(fallback.at(x, y).style.bold);
// Moving the caret clears the previous cue; editing the tag parks it.
pane.body.cur_row = 1;
@@ -2186,48 +1911,6 @@ test "line numbers stay quiet without a current-line tag background" {
try std.testing.expect(!tag_edit.at(x, y + 1).style.bold);
}
-test "legacy ThemeFile documents inherit Pardes UI roles without new fields" {
- @setEvalBranchQuota(10000);
- var encoded: std.Io.Writer.Allocating = .init(std.testing.allocator);
- defer encoded.deinit();
- try std.zon.stringify.serialize(ChromeTheme.ofTheme(&themes[comptime indexOfTheme("helix")]).view, .{ .whitespace = false }, &encoded.writer);
- // helix without the focused tag's pair it has since gained, and the
- // names' and column grip's dim fills: a document written before those
- // fields existed.
- var legacy: std.ArrayList(u8) = .empty;
- defer legacy.deinit(std.testing.allocator);
- var rest: []const u8 = encoded.written();
- while (true) {
- var at = rest.len;
- for ([_][]const u8{ ".tag_active_bg", ".tag_active_fg", ".tag_active_name_fg", ".column_box_dim" }) |field| at = @min(at, std.mem.indexOf(u8, rest, field) orelse rest.len);
- try legacy.appendSlice(std.testing.allocator, rest[0..at]);
- if (at == rest.len) break;
- rest = rest[at + std.mem.indexOfScalar(u8, rest[at..], '}').? + 1 ..];
- rest = std.mem.trimStart(u8, rest, " ,");
- }
- const source = try std.testing.allocator.dupeSentinel(u8, legacy.items, 0);
- defer std.testing.allocator.free(source);
- var arena: std.heap.ArenaAllocator = .init(std.testing.allocator);
- defer arena.deinit();
- var diagnostics: std.zon.parse.Diagnostics = undefined;
- const parsed = try std.zon.parse.fromSlice(LegacyTheme, .{ .gpa = std.testing.allocator, .arena = arena.allocator(), .source = source, .diagnostics = &diagnostics });
- try std.testing.expectEqual(@as(?[3]u8, null), parsed.tag_active_bg);
- try std.testing.expectEqual(@as(?[3]u8, null), parsed.tag_name_fg);
- try std.testing.expectEqual(@as(?[3]u8, null), parsed.tag_active_name_fg);
- try std.testing.expectEqual(@as(?[3]u8, null), parsed.column_box);
- try std.testing.expectEqual(@as(?[3]u8, null), parsed.column_box_dim);
- try std.testing.expectEqual(@as(?[3]u8, null), parsed.search_bg);
- const chrome = ChromeTheme.fromTheme(&parsed);
- try std.testing.expectEqual(parsed.tag_bg, chrome.tag_active_bg);
- // Its names take a tint of its own hues, never the plain ink.
- try std.testing.expect(!std.meta.eql(parsed.tag_fg, chrome.tag_name_fg));
- try std.testing.expect(!std.meta.eql(chrome.tag_active_fg, chrome.tag_active_name_fg));
- try std.testing.expectEqual(parsed.num, chrome.column_box);
- try std.testing.expectEqual(mix(parsed.num, parsed.tag_bg), chrome.column_box_dim);
- try std.testing.expectEqual(parsed.sel_bg, chrome.search_bg);
- try std.testing.expectEqual(parsed.fg.?, chrome.diagnostic_error);
-}
-
test "column grip colors remain distinct from pane grips across native themes" {
for (designed) |name| {
const th = &themes[themeIndex(name).?];
@@ -2243,37 +1926,6 @@ test "column grip colors remain distinct from pane grips across native themes" {
try std.testing.expect(distance >= 30 * 30);
}
}
- var custom = ChromeTheme.ofTheme(&themes[default_theme]).view;
- custom.column_box = .{ 90, 130, 170 };
- custom.column_box_dim = null;
- var chrome = ChromeTheme.fromTheme(&custom);
- try std.testing.expectEqual(custom.column_box.?, chrome.column_box);
- try std.testing.expectEqual(mix(custom.column_box.?, custom.tag_bg), chrome.column_box_dim);
- custom.column_box_dim = .{ 40, 60, 80 };
- chrome = ChromeTheme.fromTheme(&custom);
- try std.testing.expectEqual(custom.column_box_dim.?, chrome.column_box_dim);
-}
-
-test "custom filename tints preserve optional active fallback precedence" {
- var theme = ChromeTheme.ofTheme(&themes[default_theme]).view;
- theme.tag_name_fg = null;
- theme.tag_active_name_fg = null;
- var chrome = ChromeTheme.fromTheme(&theme);
- // Neither named: each derived, on its own ground.
- try std.testing.expectEqual(derivedNameTint(&.fromLegacy(theme), theme.tag_fg, theme.tag_bg).?, chrome.tag_name_fg);
- try std.testing.expectEqual(derivedNameTint(&.fromLegacy(theme), theme.tag_active_fg.?, chrome.tag_active_bg).?, chrome.tag_active_name_fg);
- theme.tag_name_fg = .{ 120, 130, 140 };
- chrome = ChromeTheme.fromTheme(&theme);
- try std.testing.expectEqual(theme.tag_name_fg.?, chrome.tag_name_fg);
- try std.testing.expectEqual(theme.tag_name_fg.?, chrome.tag_active_name_fg);
- theme.tag_active_name_fg = .{ 150, 160, 170 };
- chrome = ChromeTheme.fromTheme(&theme);
- try std.testing.expectEqual(theme.tag_name_fg.?, chrome.tag_name_fg);
- try std.testing.expectEqual(theme.tag_active_name_fg.?, chrome.tag_active_name_fg);
- theme.tag_name_fg = null;
- chrome = ChromeTheme.fromTheme(&theme);
- try std.testing.expectEqual(derivedNameTint(&.fromLegacy(theme), theme.tag_fg, theme.tag_bg).?, chrome.tag_name_fg);
- try std.testing.expectEqual(theme.tag_active_name_fg.?, chrome.tag_active_name_fg);
}
test "every theme tints its names off the tag's ink, and they read on both grounds" {
@@ -2705,11 +2357,13 @@ test "a theme file in the old names, a user's own or an older DumpThemes', and D
requestThemeFile(p, 0, "themes/one_dark_zed_mod.zon");
try std.testing.expect(loadThemeFile(p, p.theme_file_generation, own));
const want = p.chrome().*;
- // The old names' view is the file itself, unset fields their defaults.
- try std.testing.expectEqual([3]u8{ 70, 75, 87 }, p.theme().box_dim);
- try std.testing.expectEqual(@as(?[3]u8, null), p.theme().tag_active_bg);
- var old = p.theme().*;
- old.name = "one_dark_zed";
+ // The file in its old names, unset fields their defaults.
+ var arena: std.heap.ArenaAllocator = .init(gpa);
+ defer arena.deinit();
+ var diagnostics: std.zon.parse.Diagnostics = undefined;
+ const old = try std.zon.parse.fromSlice(LegacyTheme, .{ .gpa = gpa, .arena = arena.allocator(), .source = own, .diagnostics = &diagnostics });
+ try std.testing.expectEqual([3]u8{ 70, 75, 87 }, old.box_dim);
+ try std.testing.expectEqual(@as(?[3]u8, null), old.tag_active_bg);
try std.testing.expectEqual(Chrome.of(&.fromLegacy(old)), want);
// An older DumpThemes' shape: every old field, the unset ones null.
var older: std.Io.Writer.Allocating = .init(gpa);
@@ -2726,8 +2380,8 @@ test "a theme file in the old names, a user's own or an older DumpThemes', and D
try std.testing.expect(loadThemeFile(p, p.theme_file_generation, file));
try std.testing.expectEqualStrings("one_dark_zed", p.theme().name);
try std.testing.expectEqual(want, p.chrome().*);
- // What the old names' readers see of it is what they saw of the file.
- for ([_][3]u8{ p.theme().sel_fg, p.theme().tag_bg, p.theme().box, p.theme().lineno, p.theme().scroll_track }, [_][3]u8{ old.sel_fg, old.tag_bg, old.box, old.lineno, old.scroll_track }) |got, was|
+ // The theme worn is the file's, in the new names.
+ for ([_][3]u8{ p.theme().tag, p.theme().accent, p.theme().selection, p.theme().keyword }, [_][3]u8{ old.tag_bg, old.box, old.sel_bg, old.kw }) |got, was|
try std.testing.expectEqual(was, got);
}
// A file in the new names with a typo is refused in the new names' words.
diff --git a/core/lib_syntax.zig b/core/lib_syntax.zig
index 448ac7f3..584b003e 100644
--- a/core/lib_syntax.zig
+++ b/core/lib_syntax.zig
@@ -60,8 +60,9 @@ pub const analyzeSource = syntax.analyzeSource;
/// hunk's code in the language of the file its section names (old and new
/// side each parsed whole), and over that an added or removed line's
/// grounds (`ground_add`, `ground_del`; its first byte `ground_emph`, the
-/// strong row). A byte's low bits (`syn_bits`) are a `Syn`; `Grounds` are
-/// a theme's colours for the rest.
+/// strong row). A byte's low bits (`syn_bits`) are a `Syn`; a theme's
+/// `Chrome` has the rest: its `add` and `del` rows (each a row, its strong
+/// and faint grounds and its marker's ink).
pub const diff = @import("diff.zig");
pub const highlightDiff = syntax.highlightDiff;
pub const syn_bits = syntax.syn_bits;
@@ -69,7 +70,7 @@ pub const ground_add = syntax.ground_add;
pub const ground_del = syntax.ground_del;
pub const ground_emph = syntax.ground_emph;
pub const ground_line = syntax.ground_line;
-pub const Grounds = colors.Grounds;
+pub const Chrome = colors.Chrome;
/// A unified diff stacked as pardes's patch view (its +Diff) shows it:
/// `formatPatch` gives a `Patch`, its text (each line without its end: no
diff --git a/core/root.zig b/core/root.zig
index 1b107d59..14f9fede 100644
--- a/core/root.zig
+++ b/core/root.zig
@@ -37,9 +37,7 @@ pub const Stream = @import("Stream.zig");
pub const Handover = @import("Handover.zig");
pub const colors = @import("colors.zig");
pub const Theme = colors.Theme;
-pub const LegacyTheme = colors.LegacyTheme;
pub const themes = colors.themes;
-pub const ChromeTheme = colors.ChromeTheme;
/// The screen types live in surface.zig; every shell names them through here.
pub const Color = @import("surface.zig").Color;
pub const FontRole = @import("surface.zig").FontRole;
diff --git a/core/syntax.zig b/core/syntax.zig
index 9fbad3cf..78bb6fd5 100644
--- a/core/syntax.zig
+++ b/core/syntax.zig
@@ -1550,7 +1550,7 @@ fn childOfKind(node: ts.Node, kind: []const u8) ?ts.Node {
}
/// A style byte: a Syn in its low bits (syn_bits), and over them the
-/// grounds a theme resolves (colors.Grounds): `ground_add` or `ground_del`,
+/// grounds a theme resolves (colors.Chrome's add and del): `ground_add` or `ground_del`,
/// a row added or removed (its hue); `ground_emph`, the stronger ground;
/// `ground_line`, the faint one. A row's first byte says its row's ground:
/// emph the stronger to the pane's edge, line the faint one, neither none
diff --git a/core/theme_schema.zig b/core/theme_schema.zig
index 788cf3bf..f2f05d68 100644
--- a/core/theme_schema.zig
+++ b/core/theme_schema.zig
@@ -98,46 +98,6 @@ pub const Theme = struct {
out.deleted = null;
return out;
}
-
- /// The old names' view of a theme, for what still reads them: the
- /// fields the new names leave to the derivation (`derived`) filled in
- /// from it; `added`, `deleted` and `mode`, which the old names have no
- /// field for, left out.
- pub fn toLegacy(th: *const Theme, derived: Derived) LegacyTheme {
- var out: LegacyTheme = undefined;
- inline for (renames) |r| {
- const from = @field(th, r[1]);
- const same = comptime @FieldType(LegacyTheme, r[0]) == @TypeOf(from);
- @field(out, r[0]) = if (same) from else from orelse @field(derived, r[0]);
- }
- inline for (dropped) |name| @field(out, name) = @field(derived, name);
- if (th.sweeps) |sweeps| {
- out.sweep_bg = undefined;
- out.sweep_fg = undefined;
- for (sweeps, &out.sweep_bg.?, &out.sweep_fg.?) |s, *ground, *ink| {
- ground.* = s.ground;
- ink.* = s.text;
- }
- } else {
- out.sweep_bg = null;
- out.sweep_fg = null;
- }
- return out;
- }
-
- /// What `toLegacy` takes from the derivation: the old names' required
- /// fields the new ones make optional, and the ones they leave out.
- pub const Derived = struct {
- sel_fg: [3]u8,
- lineno: [3]u8,
- scroll_track: [3]u8,
- scroll_thumb: [3]u8,
- box_dim: [3]u8,
- column_box_dim: ?[3]u8 = null,
- tag_active_name_fg: ?[3]u8 = null,
- search_fg: ?[3]u8 = null,
- tag_reading_bg: ?[3]u8 = null,
- };
};
/// Old name, new name: the mechanical layer (DESIGN.md G6). Without the
@@ -229,7 +189,7 @@ pub const LegacyTheme = struct {
palette: ?[16][3]u8,
// Pardes UI roles. Optional so existing ThemeFile documents and imported
- // editor palettes keep working; ChromeTheme resolves their legacy defaults.
+ // editor palettes keep working; Theme.fromLegacy and Chrome.of derive them.
tag_active_bg: ?[3]u8 = null,
tag_active_fg: ?[3]u8 = null,
/// The workspace row (the tagline): an editor's status bar in its own
@@ -257,8 +217,8 @@ pub const LegacyTheme = struct {
lineno_active: ?[3]u8 = null,
/// A tag's selection, where it differs from the body's (acme's #9eeeee).
tag_sel_bg: ?[3]u8 = null,
- /// The tag of a reading pane, one a jump steps (Trail.zig): unset, or
- /// too near the tag to see, the tag toward paper yellow (readingOf).
+ /// The tag of a reading pane, one a jump steps (Trail.zig): read and
+ /// dropped (DESIGN.md G1': a reading pane is marked on its grip).
tag_reading_bg: ?[3]u8 = null,
/// Each pointer button's sweep, select, exec and look (Mouse.Button
/// order), and the ink over it. Unset, tints of `sel_bg` in `sel_fg`.
diff --git a/dev/file_watch.zig b/dev/file_watch.zig
index fd6bf06f..85b099bc 100644
--- a/dev/file_watch.zig
+++ b/dev/file_watch.zig
@@ -994,7 +994,7 @@ test "theme watch reloads valid ZON and keeps the last theme across a bad save"
request.generation,
true,
));
- try std.testing.expectEqual(@as(?[3]u8, .{ 1, 2, 3 }), core.theme().bg);
+ try std.testing.expectEqual(@as(?[3]u8, .{ 1, 2, 3 }), core.theme().page);
try std.testing.expect(watches[theme_slot] != null);
var second = first;
@@ -1004,11 +1004,11 @@ test "theme watch reloads valid ZON and keeps the last theme across a bad save"
try std.zon.stringify.serialize(second, .{ .whitespace = true }, &second_zon.writer);
try tmp.dir.writeFile(io, .{ .sub_path = "mine.zon", .data = second_zon.written() });
try std.testing.expect(!reloadTheme(core, gpa, &watches, false));
- try std.testing.expectEqual(@as(?[3]u8, .{ 9, 8, 7 }), core.theme().bg);
+ try std.testing.expectEqual(@as(?[3]u8, .{ 9, 8, 7 }), core.theme().page);
try tmp.dir.writeFile(io, .{ .sub_path = "mine.zon", .data = ".{ .name = " });
try std.testing.expect(!reloadTheme(core, gpa, &watches, false));
- try std.testing.expectEqual(@as(?[3]u8, .{ 9, 8, 7 }), core.theme().bg);
+ try std.testing.expectEqual(@as(?[3]u8, .{ 9, 8, 7 }), core.theme().page);
}
test "a watched file deleted wakes the watch at once, and its pane says so" {
diff --git a/runtime/macos.zig b/runtime/macos.zig
index afce23ee..7485f472 100644
--- a/runtime/macos.zig
+++ b/runtime/macos.zig
@@ -479,7 +479,7 @@ export fn pardes_animating() bool {
export fn pardes_theme_bg() u32 {
pardes.turn.wake();
defer pardes.turn.rest();
- const page = if (state) |*st| st.core.theme().bg else pardes.themes[pardes.colors.default_theme].page;
+ const page = if (state) |*st| st.core.theme().page else pardes.themes[pardes.colors.default_theme].page;
const bg = page orelse return color_default;
return @as(u32, bg[0]) << 16 | @as(u32, bg[1]) << 8 | bg[2];
}
@@ -543,7 +543,7 @@ export fn pardes_topbar_pane_border_rgb() u32 {
defer pardes.turn.rest();
const rgb = pardes.config.gui_topbar_pane_border_rgb orelse fromTheme: {
const st = state orelse return color_default;
- break :fromTheme st.core.chromeTheme().border;
+ break :fromTheme st.core.chrome().rule;
};
return @as(u32, rgb[0]) << 16 | @as(u32, rgb[1]) << 8 | rgb[2];
}
@@ -1417,7 +1417,7 @@ export fn pardes_tag_layer_value(index: u32, field: u32) u32 {
// A tag at its pane's foot: there is no Tagbottom now.
11 => 0,
12 => rgb: {
- const border = st.core.chromeTheme().border;
+ const border = st.core.chrome().rule;
break :rgb @as(u32, border[0]) << 16 | @as(u32, border[1]) << 8 | border[2];
},
else => 0,
@@ -2651,7 +2651,7 @@ test "mac tag layer ABI preserves logical capacity and physical grip" {
try std.testing.expectEqual(@as(u32, 12), pardes_tag_layer_value(0, 0));
try std.testing.expectEqual(@as(u32, 0x123456), pardes_tag_layer_value(0, 10));
try std.testing.expectEqual(@as(u32, 0), pardes_tag_layer_value(0, 11));
- const border = core.chromeTheme().border;
+ const border = core.chrome().rule;
const border_rgb = @as(u32, border[0]) << 16 | @as(u32, border[1]) << 8 | border[2];
try std.testing.expectEqual(border_rgb, pardes_tag_layer_value(0, 12));
try std.testing.expectEqual(pardes.config.gui_topbar_pane_border_rgb orelse border, .{
diff --git a/test/consumer/lib.zig b/test/consumer/lib.zig
index 2832bdf1..949afd5c 100644
--- a/test/consumer/lib.zig
+++ b/test/consumer/lib.zig
@@ -140,12 +140,10 @@ test "a diff is a language: its hunks coloured as their file's, its added and re
// a row's hue in a theme: a ground between the page and the theme's green, a stronger and a fainter one
const th = pardes.theme("Orchard").?;
- const g = pardes.Grounds.of(th);
- const ground = g.forStyle(styles[added]).?;
- try std.testing.expectEqual(g.add, ground);
- try std.testing.expectEqual(g.del, g.forStyle(styles[removed]).?);
- try std.testing.expectEqual(null, g.forStyle(@backingInt(pardes.Syn.keyword)));
- try std.testing.expect(!std.mem.eql(u8, &ground.row, &pardes.page(th)) and !std.mem.eql(u8, &ground.row, &ground.emph) and !std.mem.eql(u8, &ground.row, &ground.line));
+ const c = pardes.Chrome.of(th);
+ for ([2]pardes.Chrome.Diff{ c.add, c.del }) |ground|
+ try std.testing.expect(!std.mem.eql(u8, &ground.row, &pardes.page(th)) and !std.mem.eql(u8, &ground.row, &ground.emph) and !std.mem.eql(u8, &ground.row, &ground.line));
+ try std.testing.expect(!std.mem.eql(u8, &c.add.row, &c.del.row));
// what a row points at: the new line a `+` row is
var lines: std.ArrayList([]const u8) = .empty;
diff --git a/test/output.zig b/test/output.zig
index f2a35c01..8f4048f0 100644
--- a/test/output.zig
+++ b/test/output.zig
@@ -103,7 +103,7 @@ test "output callers opt into location highlighting instead of matching prose co
const surface = try p.render(frame.allocator());
const line = modal.lineSlice(file.content, 0);
const before_colon = std.mem.indexOfScalar(u8, line, ':').?;
- const normal: pardes.Color = if (p.theme().fg) |fg| .{ .rgb = fg } else .default;
+ const normal: pardes.Color = if (p.theme().text) |fg| .{ .rgb = fg } else .default;
for (0..before_colon + 2) |byte| {
const cell = outputCell(p, surface, id, byte);
try std.testing.expectEqual(normal, cell.style.fg);
@@ -140,7 +140,7 @@ test "location producers retain rendered location match and diagnostic styles" {
}
if (!diagnostic) {
const number = start + std.mem.indexOf(u8, code, "42").?;
- try std.testing.expectEqual(pardes.Color{ .rgb = p.theme().num }, outputCell(p, surface, id, number).style.fg);
+ try std.testing.expectEqual(pardes.Color{ .rgb = p.theme().number }, outputCell(p, surface, id, number).style.fg);
}
}
}
@@ -454,7 +454,7 @@ test "Mini syntax colors survive themes and rendering without source access" {
const rect = p.view().rects[id];
const x = rect.x + config.GUTTER + panes.File.gutterWidth(mini) + @as(u16, @intCast(column));
const y = p.bodyTop(mini, rect) + @as(u16, @intCast(position.row));
- try std.testing.expectEqualDeep(pardes.Color{ .rgb = p.theme().kw }, surface.at(x, y).style.fg);
+ try std.testing.expectEqualDeep(pardes.Color{ .rgb = p.theme().keyword }, surface.at(x, y).style.fg);
try std.testing.expectEqual(colors, mini.file.?.mini.?.colors.ptr);
try std.testing.expectEqual(@as(usize, 0), mini.file.?.highlights.len);
_ = frame.reset(.retain_capacity);
diff --git a/test/panes.zig b/test/panes.zig
index 497fe884..063832f3 100644
--- a/test/panes.zig
+++ b/test/panes.zig
@@ -787,13 +787,12 @@ const TagNameTintTests = struct {
fn configure(p: *Pardes) void {
var theme = p.theme().*;
- theme.tag_name_fg = name_fg;
- theme.tag_active_name_fg = null;
- theme.tag_fg = tag_fg;
+ theme.tag_name = name_fg;
+ theme.tag_text = tag_fg;
// The focused tag's ink is the plain one, as an unfocused tag's.
- theme.tag_active_fg = null;
+ theme.tag_focus_text = null;
p.custom_theme = theme;
- p.theme_chrome = pardes.ChromeTheme.fromTheme(p.theme());
+ p.theme_chrome = .of(p.theme());
}
fn check(p: *Pardes, id: usize, name: []const u8) !usize {
@@ -890,10 +889,10 @@ const TagNameTintTests = struct {
pane.file.?.path = try p.gpa.dupe(u8, "/dir/file.zig");
configure(p);
defer p.custom_theme = null;
- p.custom_theme.?.tag_name_fg = null;
+ p.custom_theme.?.tag_name = null;
const active_fg = [3]u8{ 175, 183, 194 };
- p.custom_theme.?.tag_active_fg = active_fg;
- p.theme_chrome = pardes.ChromeTheme.fromTheme(p.theme());
+ p.custom_theme.?.tag_focus_text = active_fg;
+ p.theme_chrome = .of(p.theme());
var arena = std.heap.ArenaAllocator.init(p.gpa);
defer arena.deinit();
const surface = try p.render(arena.allocator());
@@ -987,7 +986,7 @@ test "terminal overlay recoloring never materializes unrelated history" {
const body_y = bodyY(p, rect);
const cell = surface.at(rect.x + config.GUTTER, body_y);
try testing.expectEqualStrings("c", cell.grapheme());
- try testing.expectEqual(pardes.Color{ .rgb = p.theme().palette.?[2] }, cell.style.fg);
+ try testing.expectEqual(pardes.Color{ .rgb = p.theme().ansi.?[2] }, cell.style.fg);
}
test "terminal output keeps following new rows after scrollback eviction" {
@@ -1035,7 +1034,7 @@ test "terminal output keeps following new rows after scrollback eviction" {
for (last, 0..) |byte, col| {
const cell = surface.at(x + @as(u16, @intCast(col)), y);
try std.testing.expectEqualStrings(&.{byte}, cell.grapheme());
- try std.testing.expectEqual(pardes.Color{ .rgb = p.theme().palette.?[2] }, cell.style.fg);
+ try std.testing.expectEqual(pardes.Color{ .rgb = p.theme().ansi.?[2] }, cell.style.fg);
}
while (p.nextEffect()) |_| {}
p.update(.{ .key = .{ .cp = 'f', .text = "f" } });
@@ -3608,7 +3607,7 @@ test "Zig keywords keep every rendered byte colored across line-number widths" {
try std.testing.expectEqual(@as(u16, @intCast(y)), surface.cursor.?.y);
} else if_position = .{ .x = @intCast(x), .y = @intCast(y) };
for ([_]*pardes.Cell{ first, second }) |cell| {
- const expected: pardes.Color = .{ .rgb = p.theme().kw };
+ const expected: pardes.Color = .{ .rgb = p.theme().keyword };
if (!std.meta.eql(expected, cell.style.fg)) std.debug.print(
"\nline={d} wrap={} horizontal={d} sample={s} cell={s}\n",
.{ line, view.wrap, view.horizontal, sample, cell.grapheme() },
@@ -3644,7 +3643,7 @@ test "terminal overlays preserve trailing blank styles without coloring inserted
const rect = p.view().rects[0];
const x = rect.x + config.GUTTER;
const y = bodyY(p, rect);
- const palette = p.theme().palette.?;
+ const palette = p.theme().ansi.?;
const colors = [_]pardes.Color{ .{ .rgb = palette[1] }, .{ .rgb = palette[2] }, .{ .rgb = palette[4] } };
const original = try p.render(frame.allocator());
for (colors, 0..) |color, row| {
diff --git a/test/terminal.zig b/test/terminal.zig
index 1168fac7..3c74cd11 100644
--- a/test/terminal.zig
+++ b/test/terminal.zig
@@ -393,14 +393,14 @@ test "terminal Filter keys indexed truecolor OSC and background-only cells throu
p.update(.{ .output = .{ .pane = .at(0), .bytes = "\x1b]104;1\x1b\\" } });
var custom = p.theme().*;
custom.name = try p.gpa.dupe(u8, "same-name");
- custom.palette = pardes.colors.xterm[0..16].*;
- custom.palette.?[1] = .{ 1, 2, 3 };
+ custom.ansi = pardes.colors.xterm[0..16].*;
+ custom.ansi.?[1] = .{ 1, 2, 3 };
p.custom_theme = custom;
pardes.colors.finishThemeInitialization(p);
_ = frame.reset(.retain_capacity);
const custom_first = try p.render(frame.allocator());
try testing.expectEqual(plain.Color{ .rgb = .{ 1, 2, 3 } }, custom_first.at(tx, body_y).style.fg);
- if (p.custom_theme) |*theme| theme.palette.?[1] = .{ 4, 5, 6 };
+ if (p.custom_theme) |*theme| theme.ansi.?[1] = .{ 4, 5, 6 };
pardes.colors.finishThemeInitialization(p);
_ = frame.reset(.retain_capacity);
const custom_second = try p.render(frame.allocator());
@@ -465,9 +465,9 @@ test "terminal Filter preserves exact palette-null light theme default roles" {
var light = p.theme().*;
light.name = try p.gpa.dupe(u8, "filter-light-defaults");
- light.bg = .{ 0xf8, 0xf8, 0xf8 };
- light.fg = .{ 0x38, 0x38, 0x38 };
- light.palette = null;
+ light.page = .{ 0xf8, 0xf8, 0xf8 };
+ light.text = .{ 0x38, 0x38, 0x38 };
+ light.ansi = null;
p.custom_theme = light;
pardes.colors.finishThemeInitialization(p);
@@ -482,14 +482,14 @@ test "terminal Filter preserves exact palette-null light theme default roles" {
const tx = r.x + config.GUTTER;
const body_y = p.bodyTop(pane, r);
const ordinary = try p.render(frame.allocator());
- try testing.expectEqual(plain.Color{ .rgb = light.fg.? }, ordinary.at(tx, body_y).style.fg);
- try testing.expectEqual(plain.Color{ .rgb = light.bg.? }, ordinary.at(tx, body_y).style.bg);
+ try testing.expectEqual(plain.Color{ .rgb = light.text.? }, ordinary.at(tx, body_y).style.fg);
+ try testing.expectEqual(plain.Color{ .rgb = light.page.? }, ordinary.at(tx, body_y).style.bg);
p.update(.{ .output = .{ .pane = .at(0), .bytes = "\x1b[?5h" } });
_ = frame.reset(.retain_capacity);
const reversed = try p.render(frame.allocator());
- try testing.expectEqual(plain.Color{ .rgb = light.bg.? }, reversed.at(tx, body_y).style.fg);
- try testing.expectEqual(plain.Color{ .rgb = light.fg.? }, reversed.at(tx, body_y).style.bg);
+ try testing.expectEqual(plain.Color{ .rgb = light.page.? }, reversed.at(tx, body_y).style.fg);
+ try testing.expectEqual(plain.Color{ .rgb = light.text.? }, reversed.at(tx, body_y).style.bg);
}
test "terminal Filter maps the default roles before it maps anything else" {
@@ -631,8 +631,8 @@ test "tty ansi colors follow the prompt hug into normal mode" {
const r = p.view().rects[0];
const tx = r.x + config.GUTTER;
const body_y = p.bodyTop(pane, r);
- const red: plain.Color = .{ .rgb = p.theme().palette.?[1] };
- const blue: plain.Color = .{ .rgb = p.theme().palette.?[4] };
+ const red: plain.Color = .{ .rgb = p.theme().ansi.?[1] };
+ const blue: plain.Color = .{ .rgb = p.theme().ansi.?[4] };
// tty mode projects the emulator's ansi colours cell for cell.
pane.body.mode = .tty;
@@ -672,7 +672,7 @@ test "a prompt row hidden end to end paints nothing at all" {
const s = try p.render(frame.allocator());
try testing.expectEqualStrings(" ", s.at(tx, body_y).grapheme());
- try testing.expect(!std.meta.eql(plain.Color{ .rgb = p.theme().palette.?[1] }, s.at(tx, body_y).style.bg));
+ try testing.expect(!std.meta.eql(plain.Color{ .rgb = p.theme().ansi.?[1] }, s.at(tx, body_y).style.bg));
}
test "a program that asked for focus reports hears CSI I and CSI O as its pane takes and gives up the keyboard, and as the window does" {