diff options
| author | Gabriel Schneider <[email protected]> | 2026-11-26 04:36:36 -0300 |
|---|---|---|
| committer | Gabriel Schneider <[email protected]> | 2026-11-26 04:36:36 -0300 |
| commit | fed268f2282a6d393a116d103e1fd88da87ecbff (patch) | |
| tree | 0d213cf8de97a660cbccb924be24bd99211d010d /core/colors.zig | |
| parent | 47952d7797b25f41a3e29ec0dc349564c0185fd4 (diff) | |
| download | pardes-fed268f2282a6d393a116d103e1fd88da87ecbff.tar.gz pardes-fed268f2282a6d393a116d103e1fd88da87ecbff.zip | |
themes, colors, gen_themes: `dark` refreshed and four new pardes themes, light, mono, okabe and sepia, and the ring in DESIGN.md E's groups (the themes programme's L5; DESIGN.md C, D, E, G2, G3): DARK (C): still the one theme with no page and no text of its own, so a terminal keeps the host's cell, ink and sixteen (ansi.inkOf's `host`), and a window draws colors.null_page #121212 and #cccccc (G2 (a)); its comments the brightest ink, #f0f0f0; keywords violet #d76ef0 (6.6:1; was #da5eea, 5.9:1); the lilac tag #2c2a3e with #aba9c3 ink, focused #d6d4e8; the grip #a58bff (3.4:1 on its focused tag; was #663fe0, 1.45:1); a violet selection #46337a in #f4f0ff (G3 (a): the tan #513c17 sat in the hits' amber); its own severities #ff6e7f #ffb454 #7fa8ff #62d2c4, line numbers #5c5c66 / #8e8c9e, and a designed sixteen for the window (its ANSI 8 #7e7b96, 4.6:1, where L1's derived one was 3:1); its focused tag, mode ring, grip ring, dirty, rules, hits and diff rows Chrome.of's; LIGHT, MONO, OKABE, SEPIA (D): each its primitives as the designer's prototype resolved and audited them (.scratch/themes/C1/newthemes.py, swatches.md: page, text, tag and its ink, accent, selection and its ink, the four syntax hues, line numbers, the four severities, the sixteen; okabe's added blue #56b4e9 and deleted vermilion #ff8a4c), everything else Chrome.of's; THE RING (E): curated in the picker's sections: Pardes (dark, light, orchard, orchard_black, ink, mono, okabe, sepia, paper, daybreak, dusk, lapis), Pardes, after a classic (forge, forge_black, forge_soft, lagoon, solarium, spectrum, harvest, clay), acme (acme, atelier), the faithful ports a family at a time as before, Captured (helix; "Legacy themes" gone); the imported a family at a time, each under its heading (`Imported: gruvbox`, a family the name's first word, two themes or more), the lone ones last under one (`Imported, one of a kind`): the generator rings them so (gen_themes `byFamily`) and colors.zig heads them at comptime (`import_heads`, a compile error where a family rings after a lone theme); ORCHARD THE DEFAULT BY NAME (`colors.default_theme`: config.Settings' `theme`, the library's `default_theme`, macos.zig's bare page), never index 0, which is dark now; THE RING TEST: dusk, lagoon, solarium and forge_soft `soft` (`soft_themes`: held at AA, their text and tag text never to the pro 7:1; the coordinator's ruling) where they were on the expected list; the diff rows' "unless the text holds it nearer" exception for the ports and imports only, pardes's own held to 1.15:1 (the coordinator's ruling: every one of them meets it); pardes's own are every theme before the first faithful port, so dark and the new four are held to the pro floors with the natives; the old tests that read the first fifteen by place read the fifteen designed natives by name (`designed`; `native_theme_count` gone, B8); RUN (TEST FIRST): the ring test with dark off its list and the soft four marked failed on L4's dark (ansi_pro: its ANSI 8 3:1) and, with the soft mark on text alone, on lagoon's and solarium's tag_text7: 281 of 289 themes pass (272 of 285 at L4, the four new ones passing every floor, pro included), 8 on the list (L7's retired); colors.zig "the picker's sections run in ring order and cover it": dark first, orchard the default by name, each imported family's heading at its first, none after the lone ones' (fails on L4: "Pardes themes", orchard at 0); test/process/tty_themes.zig's `theme` case boots in dark (`Theme dark`, its own init line) and steps NextColor through the 24 of the new order into the first ports (dark, light, orchard, orchard-black, ink, mono, okabe, sepia, paper, daybreak, dusk, lapis, forge, ..., clay, acme, atelier, dark-plus, solarized-dark), `themesel` walks the Themes list from its first row the same 24 (both goldens re-recorded and read at the programme's end gate: the snaps are named for the new order); core-test 1140/1313 (173 skipped: as L4, the picker test grown); OUTSIDE my files: core/config.zig (the default, 1 line), core/lib_syntax.zig (`default_theme`), runtime/macos.zig (1 line), test/consumer/lib.zig (orchard is `default_theme`), test/process/tty_themes.zig (the two cases); no dump or digest change (a dump names its theme; settings.theme is a place in this build's ring, as before)
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_016Y9MNBFhdevVu48bvL9kCE
Diffstat (limited to 'core/colors.zig')
| -rw-r--r-- | core/colors.zig | 173 |
1 files changed, 116 insertions, 57 deletions
diff --git a/core/colors.zig b/core/colors.zig index b089a1b9..9091760f 100644 --- a/core/colors.zig +++ b/core/colors.zig @@ -1096,23 +1096,33 @@ pub const Grounds = struct { const seoul256 = @import("themes/seoul256.zig"); const curated = struct { + // DESIGN.md E's groups, the picker's sections (`theme_groups`): pardes's + // own, dark first (the host's page, the favourite), orchard the default + // (`default_theme`, by name). + pub const dark = @import("themes/dark.zig"); + pub const light = @import("themes/light.zig"); pub const orchard = @import("themes/orchard.zig"); - pub const dusk = @import("themes/dusk.zig"); + pub const orchard_black = @import("themes/orchard_black.zig"); pub const ink = @import("themes/ink.zig"); + pub const mono = @import("themes/mono.zig"); + pub const okabe = @import("themes/okabe.zig"); + pub const sepia = @import("themes/sepia.zig"); pub const paper = @import("themes/paper.zig"); pub const daybreak = @import("themes/daybreak.zig"); - pub const atelier = @import("themes/atelier.zig"); + pub const dusk = @import("themes/dusk.zig"); + pub const lapis = @import("themes/lapis.zig"); + // Pardes's, after a classic. pub const forge = @import("themes/forge.zig"); + pub const forge_black = @import("themes/forge_black.zig"); + pub const forge_soft = @import("themes/forge_soft.zig"); pub const lagoon = @import("themes/lagoon.zig"); pub const solarium = @import("themes/solarium.zig"); pub const spectrum = @import("themes/spectrum.zig"); pub const harvest = @import("themes/harvest.zig"); pub const clay = @import("themes/clay.zig"); - pub const forge_black = @import("themes/forge_black.zig"); - pub const forge_soft = @import("themes/forge_soft.zig"); - pub const orchard_black = @import("themes/orchard_black.zig"); + // acme's. pub const acme = @import("themes/acme.zig"); - pub const lapis = @import("themes/lapis.zig"); + pub const atelier = @import("themes/atelier.zig"); // Faithful ports of well-known themes, a family at a time (core/themes/ // <name>.zig says where each value came from): `theme_groups`. pub const dark_plus = @import("themes/dark_plus.zig"); @@ -1178,9 +1188,8 @@ const curated = struct { pub const ayu_light = @import("themes/ayu_light.zig"); pub const doom_one = @import("themes/doom_one.zig"); pub const doom_one_light = @import("themes/doom_one_light.zig"); - // The legacy pair last. + // Captured: an old helix setup, kept (it works). pub const helix = @import("themes/helix.zig"); - pub const dark = @import("themes/dark.zig"); }; /// A struct of theme files as themes: each file's `theme`, a field it @@ -1235,13 +1244,14 @@ pub const native_count = @typeInfo(curated).@"struct".decl_names.len; /// The picker's sections (`Themes`), in ring order, each running from /// the theme it names to the next section's; `NextColor` and `Theme` still -/// see one flat ring. The current pardes themes, then the faithful ports a -/// family at a time, then the legacy pair (`helix`, captured from an old -/// helix setup and the boot default before orchard; `dark`, the host -/// terminal's own ground), then everything imported. +/// see one flat ring (DESIGN.md E): pardes's own, those after a classic, +/// acme's, the faithful ports a family at a time, the captured helix setup; +/// then the imported, a family at a time (`import_heads`). pub const ThemeGroup = struct { title: []const u8, first: []const u8 }; const theme_groups = [_]ThemeGroup{ - .{ .title = "Pardes themes", .first = "orchard" }, + .{ .title = "Pardes", .first = "dark" }, + .{ .title = "Pardes, after a classic", .first = "forge" }, + .{ .title = "acme", .first = "acme" }, .{ .title = "Visual Studio Code", .first = "dark_plus" }, .{ .title = "Solarized", .first = "solarized_dark" }, .{ .title = "Dracula", .first = "dracula" }, @@ -1255,9 +1265,12 @@ const theme_groups = [_]ThemeGroup{ .{ .title = "Nord", .first = "nord" }, .{ .title = "Ayu", .first = "ayu_dark" }, .{ .title = "Doom One", .first = "doom_one" }, - .{ .title = "Legacy themes", .first = "helix" }, + .{ .title = "Captured", .first = "helix" }, }; +/// The theme a session starts in, by name: never a place in the ring. +pub const default_theme = indexOfTheme("orchard"); + fn indexOfTheme(comptime name: []const u8) usize { return comptime blk: { @setEvalBranchQuota(100000); @@ -1269,12 +1282,38 @@ fn indexOfTheme(comptime name: []const u8) usize { /// The heading of the picker section that starts at ring index `index`. pub fn groupAt(index: usize) ?[]const u8 { inline for (theme_groups) |g| if (index == comptime indexOfTheme(g.first)) return g.title; - if (index == native_count) return "Imported themes (helix, zed)"; - return null; + return if (index >= native_count) import_heads[index - native_count] else null; } -/// Original and classic-inspired Pardes palettes precede retained imports. -pub const native_theme_count = 15; +/// A theme's family: its name's first word (gruvbox_dark_hard's gruvbox). +fn familyOf(name: []const u8) []const u8 { + return name[0 .. std.mem.indexOfScalar(u8, name, '_') orelse name.len]; +} + +/// The imported themes' headings, a family's at its first (DESIGN.md E: a +/// heading per family, not one flat run), and one over the lone ones the +/// generator rings after every family (tools/gen_themes.zig `byFamily`). +const import_heads: [themes.len - native_count]?[]const u8 = blk: { + @setEvalBranchQuota(2_000_000); + const imported = themes[native_count..]; + var out: [imported.len]?[]const u8 = @splat(null); + var lone_seen = false; + for (imported, 0..) |t, i| { + const family = familyOf(t.name); + var members: usize = 0; + for (imported) |u| { + if (std.mem.eql(u8, familyOf(u.name), family)) members += 1; + } + if (members < 2) { + if (!lone_seen) out[i] = "Imported, one of a kind"; + lone_seen = true; + } else if (i == 0 or !std.mem.eql(u8, familyOf(imported[i - 1].name), family)) { + if (lone_seen) @compileError("imported family " ++ family ++ " rings after a lone theme (tools/gen_themes.zig byFamily)"); + out[i] = "Imported: " ++ family; + } + } + break :blk out; +}; comptime { if (themes.len > std.math.maxInt(u16) + 1) @@ -1904,9 +1943,8 @@ test "every native theme's separators stand off its page, and its focus tint off const chrome = ChromeTheme.fromTheme(theme); const page = theme.bg orelse null_page; try std.testing.expect(contrast(chrome.border, page) >= separator_floor); - // A dark page's focused tag is told by its band too, not the grip - // alone; acme's (light, and acme's own) is told by its button. - if (relativeLuminance(page) < 0.18) try std.testing.expect(theme.tag_active_bg != null); + // 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. @@ -1917,7 +1955,7 @@ test "every native theme's separators stand off its page, and its focus tint off } test "every faithful port meets pardes's chrome floors in its own colours, with nothing left to derive" { - const first = comptime indexOfTheme("lapis") + 1; + const first = comptime indexOfTheme("dark_plus"); const last = comptime indexOfTheme("helix"); for (themes[first..last]) |*ring_theme| { const view = ChromeTheme.ofTheme(ring_theme).view; @@ -1973,10 +2011,23 @@ test "the picker's sections run in ring order and cover it" { if (n == 0) try std.testing.expectEqual(@as(usize, 0), at) else try std.testing.expect(at > last); last = at; } - try std.testing.expectEqualStrings("Pardes themes", groupAt(0).?); + try std.testing.expectEqualStrings("Pardes", groupAt(0).?); + try std.testing.expectEqualStrings("dark", themes[0].name); + try std.testing.expectEqualStrings("orchard", themes[default_theme].name); // acme is a current theme, not a legacy one. try std.testing.expect(indexOfTheme("acme") < indexOfTheme("helix")); - try std.testing.expect(groupAt(native_count) != null); + // The imported a family at a time, each under its heading, the lone + // ones last under one. + try std.testing.expect(std.mem.startsWith(u8, groupAt(native_count).?, "Imported: ")); + const gruvbox = for (themes, 0..) |t, i| { + if (std.mem.eql(u8, t.name, "gruvbox")) break i; + } else unreachable; + try std.testing.expectEqualStrings("Imported: gruvbox", groupAt(gruvbox).?); + try std.testing.expectEqual(null, groupAt(gruvbox + 1)); + const lone = for (themes[native_count..], native_count..) |_, i| { + if (groupAt(i)) |title| if (std.mem.eql(u8, title, "Imported, one of a kind")) break i; + } else unreachable; + for (themes[lone + 1 ..], lone + 1..) |_, i| try std.testing.expectEqual(null, groupAt(i)); } test "seoul256's twelve backgrounds ring in their order, after Catppuccin and before Zenbones" { @@ -2054,7 +2105,7 @@ test "ThemeFile parses ZON atomically and Theme returns to the compiled ring" { return error.MissingThemeFileRequest; try std.testing.expectEqualStrings("/tmp/pardes-config/themes/mine.zon", request.path); - var custom = themes[0]; + var custom = themes[default_theme]; custom.name = "mine"; custom.page = .{ 1, 2, 3 }; custom.tag = .{ 4, 5, 6 }; @@ -2074,8 +2125,8 @@ test "ThemeFile parses ZON atomically and Theme returns to the compiled ring" { try std.testing.expectEqualStrings("mine", p.theme().name); try std.testing.expectEqual(@as(?[3]u8, .{ 1, 2, 3 }), p.theme().bg); - setThemeIndex(p, 0); - try std.testing.expectEqualStrings(themes[0].name, p.theme().name); + setThemeIndex(p, default_theme); + try std.testing.expectEqualStrings(themes[default_theme].name, p.theme().name); try std.testing.expect(themeFileRequest(p, request_effect.generation) == null); const stop = while (p.nextEffect()) |effect| switch (effect) { .theme_file => |theme_file| break theme_file, @@ -2085,11 +2136,8 @@ 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" { - const names = [_][]const u8{ "orchard", "dusk", "ink", "paper", "daybreak", "atelier", "forge", "lagoon", "solarium", "spectrum", "harvest", "clay", "forge_black", "forge_soft", "orchard_black" }; - try std.testing.expectEqual(names.len, native_theme_count); - for (themes[0..names.len], names) |own, name| { - const th = ChromeTheme.ofTheme(&own).view; - try std.testing.expectEqualStrings(name, th.name); + for (designed) |name| { + const th = ChromeTheme.ofTheme(&themes[themeIndex(name).?]).view; const chrome = ChromeTheme.fromTheme(&th); 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{ @@ -2121,8 +2169,14 @@ test "native themes keep text and UI roles readable on their own surfaces" { } } +/// The natives written before the colour system (DESIGN.md B), each with a +/// name tint and a column grip of its own: what the tests of their own +/// values below hold (the ring test holds every theme to B4's floors). +const designed = [_][]const u8{ "orchard", "dusk", "ink", "paper", "daybreak", "atelier", "forge", "lagoon", "solarium", "spectrum", "harvest", "clay", "forge_black", "forge_soft", "orchard_black" }; + test "native filename tints change hue without changing perceived lightness" { - for (themes[0..native_theme_count]) |*th| { + for (designed) |native| { + const th = &themes[themeIndex(native).?]; // The theme's own tint at its tag ink's lightness (the focused one // Chrome.of's, R13). const pairs = [1][2][3]u8{ @@ -2146,8 +2200,8 @@ test "native filename tints change hue without changing perceived lightness" { } test "native dark palettes choose near-black or deliberately soft contrast" { - for (themes[0..native_theme_count]) |ring_theme| { - const th = ChromeTheme.ofTheme(&ring_theme).view; + for (designed) |name| { + const th = ChromeTheme.ofTheme(&themes[themeIndex(name).?]).view; if (contrast(th.bg.?, .{ 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"); @@ -2175,7 +2229,7 @@ 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[0]).view; + var custom = ChromeTheme.ofTheme(&themes[default_theme]).view; custom.name = try gpa.dupe(u8, "quiet-gutter"); custom.lineno = .{ 70, 70, 70 }; custom.lineno_active = .{ 95, 95, 95 }; @@ -2252,7 +2306,8 @@ test "legacy ThemeFile documents inherit Pardes UI roles without new fields" { } test "column grip colors remain distinct from pane grips across native themes" { - for (themes[0..native_theme_count]) |*th| { + for (designed) |name| { + const th = &themes[themeIndex(name).?]; // The theme's own (their rest and grabbed inks Chrome.of's, R6, H). for ([_][2][3]u8{ .{ th.accent, th.column_grip.? }, @@ -2265,7 +2320,7 @@ test "column grip colors remain distinct from pane grips across native themes" { try std.testing.expect(distance >= 30 * 30); } } - var custom = ChromeTheme.ofTheme(&themes[0]).view; + var custom = ChromeTheme.ofTheme(&themes[default_theme]).view; custom.column_box = .{ 90, 130, 170 }; custom.column_box_dim = null; var chrome = ChromeTheme.fromTheme(&custom); @@ -2277,7 +2332,7 @@ test "column grip colors remain distinct from pane grips across native themes" { } test "custom filename tints preserve optional active fallback precedence" { - var theme = ChromeTheme.ofTheme(&themes[0]).view; + var theme = ChromeTheme.ofTheme(&themes[default_theme]).view; theme.tag_name_fg = null; theme.tag_active_name_fg = null; var chrome = ChromeTheme.fromTheme(&theme); @@ -2484,7 +2539,7 @@ const RingCheck = enum { }; /// The checks `th`'s chrome fails. -fn ringFailures(th: *const Theme, c: *const Chrome) std.EnumSet(RingCheck) { +fn ringFailures(th: *const Theme, c: *const Chrome, designed_here: bool) std.EnumSet(RingCheck) { var f: std.EnumSet(RingCheck) = .empty; const de = struct { fn of(a: [3]u8, b: [3]u8) f32 { @@ -2571,12 +2626,13 @@ fn ringFailures(th: *const Theme, c: *const Chrome) std.EnumSet(RingCheck) { f.setPresent(.severities4, apart4 < Chrome.severity_apart); const err = lch(c.page.severity[0]); f.setPresent(.error_red, !(err[1] >= 0.08 and (err[2] <= 50 or err[2] >= 330))); - // R10: each diff row 1.15:1 off the page, unless the text holds it - // nearer (never under its floor there: tokyonight_day's text, 4.9:1, - // leaves 1.11:1), and the two 0.05 apart. + // R10: each diff row 1.15:1 off the page, and the two 0.05 apart; a + // port's or an import's nearer where its own text holds it (never + // under its floor there: tokyonight_day's text, 4.9:1, leaves 1.11:1); + // pardes's own themes always (the coordinator's ruling). const diff_floor = @min(4.5, text * 0.9); for ([2][3]u8{ c.add.row, c.del.row }) |row| { - if (contrast(row, page) < Chrome.row_step - 0.005 and contrast(ink, row) > diff_floor + 0.05) f.insert(.diff); + if (contrast(row, page) < Chrome.row_step - 0.005 and (designed_here or contrast(ink, row) > diff_floor + 0.05)) f.insert(.diff); } if (de(c.add.row, c.del.row) < 0.05) f.insert(.diff); var ansi_least: f32 = 21; @@ -2606,8 +2662,6 @@ fn ringFailures(th: *const Theme, c: *const Chrome) std.EnumSet(RingCheck) { /// them lands (DESIGN.md E1, F): the list shrinks as each does, and a theme /// on it that passes fails the test, so it is taken off. const ring_expected = [_]struct { []const u8, []const u8 }{ - // L5: dark's own sixteen (its derived ANSI 8 is 3:1, under the pro 4.5). - .{ "dark", "L5: its designed ANSI (DESIGN.md C)" }, // L7: retired. .{ "seoul256_dark_238", "L7: retired" }, .{ "seoul256_dark_239", "L7: retired" }, @@ -2617,17 +2671,17 @@ const ring_expected = [_]struct { []const u8, []const u8 }{ .{ "hex_poison", "L7: retired" }, .{ "hex_steel", "L7: retired" }, .{ "ingrid", "L7: retired" }, - // No line: the soft natives' text is 4.5-7:1 by design (the native - // test below), under the professional 7:1. C1's ruling. - .{ "dusk", "soft by design: text under the pro 7:1" }, - .{ "lagoon", "soft by design: text under the pro 7:1" }, - .{ "solarium", "soft by design: text under the pro 7:1" }, - .{ "forge_soft", "soft by design: text under the pro 7:1" }, }; +/// The soft natives: their text 4.5-7:1 by design, held at AA, never the +/// professional 7:1, and never retuned (the coordinator's ruling; solarium +/// is the user's). +const soft_themes = [_][]const u8{ "dusk", "lagoon", "solarium", "forge_soft" }; + test "every theme in the ring meets every floor pardes owns (DESIGN.md B4), natives and dark the professional ones too; the original's own colours never moved" { - const lapis = comptime indexOfTheme("lapis"); - const dark = comptime indexOfTheme("dark"); + // pardes's own: every theme before the first faithful port (dark and + // the new ones among them), and the captured helix's originals. + const ports = comptime indexOfTheme("dark_plus"); const helix = comptime indexOfTheme("helix"); var passing: usize = 0; var wrong: usize = 0; @@ -2639,12 +2693,17 @@ test "every theme in the ring meets every floor pardes owns (DESIGN.md B4), nati if (th.page) |own| try std.testing.expectEqual(own, c.page.ground); if (th.ansi) |own| try std.testing.expectEqual(own, c.ansi); if (th.line_number) |own| try std.testing.expectEqual(own, c.line_number); - const ours = i <= lapis or i == dark or i == helix; - const failures = ringFailures(th, &c); + const ours = i < ports or i == helix; + const soft = for (soft_themes) |name| { + if (std.mem.eql(u8, name, th.name)) break true; + } else false; + const failures = ringFailures(th, &c, i < ports); var held: std.EnumSet(RingCheck) = .empty; var it = failures.iterator(); while (it.next()) |check| { - if (check.pro() and !(i <= lapis or i == dark)) continue; + if (check.pro() and i >= ports) continue; + // A soft theme's text is held at AA, 4.5:1, never the pro 7:1. + if (soft and (check == .text7 or check == .tag_text7)) continue; if (check.original() and !ours and !(std.mem.startsWith(u8, @tagName(check), "ansi") and th.ansi == null)) continue; held.insert(check); } |
