summaryrefslogtreecommitdiff
path: root/core/colors.zig
diff options
context:
space:
mode:
authorGabriel Schneider <[email protected]>2026-11-26 04:37:03 -0300
committerGabriel Schneider <[email protected]>2026-11-26 04:41:35 -0300
commit77b22e7c7623696feb52292bb86839870e20050d (patch)
treef923275a1d118bc4227a349842c7202f74004d7d /core/colors.zig
parentfed268f2282a6d393a116d103e1fd88da87ecbff (diff)
downloadpardes-77b22e7c7623696feb52292bb86839870e20050d.tar.gz
pardes-77b22e7c7623696feb52292bb86839870e20050d.zip
themes, vendor, colors, gen_themes, exec, ctl, dump: DESIGN.md E's 44 themes retired, each name standing for its successor wherever it is still read (the themes programme's L7; DESIGN.md E, F): GONE: 28 helix sources (base16_default_light, base16_terminal, base16_transparent, bogster_light, cyan_light, eldritch_transparent, gruvbox-material, hex_lavender, hex_poison, ingrid, iroaseta, nord_light, nyxvamp-transparent, peachpuff, the six helix seoul256s, term16_dark, term16_light, tokyonight, ttox, ttox_soft, vesper-transparent, zed_onedark, zed_onelight), zed's ayu.json and gruvbox.json (every variant in them retired: ayu_dark/light/mirage_zed, the six gruvbox_*_zed) and their licences (ayu.LICENSE, gruvbox.LICENSE: zed's, covering those files alone; helix's licences each cover a kept theme), seoul256's 238, 239, 252 and 253 (their rows, their citations, their lines in its G4 block); vendor/themes/base/ holds the retired three kept themes inherit from (ayu_dark_helix, hex_steel, nord_helix; the designer's list named seven, but no kept theme inherits seoul256_dark/_light, term16_dark or zed_onedark once their children retire), passed to the generator as `base=<path>` (build/core.zig `vendoredThemes` per directory), read for `inherits`, never rung; THE SUCCESSORS: `colors.retired`, 44 names and the kept one each stands for (the kept twin, the nearest kept seoul256 step, dark or light for the terminal-colour themes, the default where there is none: ingrid), read by `successorOf`: a `Theme` (an init file's line, a click, a /ctl write) naming one wears its successor and says so once, as a notice: "Theme gruvbox_dark_zed was retired: gruvbox instead" (exec.applySettingBuiltin); /ctl takes such a write (ctl.zig); a dump or Restore naming one restores its successor (`colors.restoredIndex`, dump.zig's two readers, which said the same loop twice; one this build has nothing of keeps the theme in effect as before, else the default by name, where it was index 0, dark's now); an unknown name keeps today's path and words; THE RING TEST'S LIST: empty, so gone (`ring_expected` and its bookkeeping: every theme in the ring passes every floor it is held to, or the test names it); RUN (TEST FIRST): colors.zig "a retired theme's name stands for its successor in an init file and a dump, said once; an unknown one leaves the default, in today's words" (an init `Theme gruvbox_dark_zed`, `Theme TTOX` (any case), `Theme ingrid` and `Theme no-such-theme`: gruvbox, dark, orchard and orchard, each with its one message; a dump of a session in acme with `ttox` put in for its theme's name, as an older build's: restored in dark): fails on L5 (gruvbox_dark_zed still in the ring, worn as itself), passes now; "every retired theme's successor is in the ring, and no retired name is" (44); the ring test: 245 of 245 themes pass every floor (289 at L5, 44 retired); "seoul256's eight backgrounds ring in their order"; the G4 test holds every port's file; core-test 1142/1315 (173 skipped: L5's 1140/1313 + the two retirement tests); OUTSIDE my files: build/core.zig (`vendoredThemes` per directory, the base arguments), core/exec.zig (`Theme`'s retired branch, 7 lines), core/ninep/ctl.zig (1 line), core/dump.zig (its two readers, `restoredIndex`); the dump's bytes and layout unchanged and a name in this build's ring restored as before (restoredIndex's first loop is the old one), so a join or a restore within a build never reaches the new branches: no fuzz or soak
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.zig167
1 files changed, 126 insertions, 41 deletions
diff --git a/core/colors.zig b/core/colors.zig
index 9091760f..960123e2 100644
--- a/core/colors.zig
+++ b/core/colors.zig
@@ -1092,7 +1092,7 @@ pub const Grounds = struct {
}
};
-/// One family, its twelve backgrounds a theme each (`curated`).
+/// One family, its eight backgrounds a theme each (`curated`).
const seoul256 = @import("themes/seoul256.zig");
const curated = struct {
@@ -1156,10 +1156,6 @@ const curated = struct {
pub const seoul256_dark_235 = seoul256.dark(235);
pub const seoul256_dark_236 = seoul256.dark(236);
pub const seoul256_dark_237 = seoul256.dark(237);
- pub const seoul256_dark_238 = seoul256.dark(238);
- pub const seoul256_dark_239 = seoul256.dark(239);
- pub const seoul256_light_252 = seoul256.light(252);
- pub const seoul256_light_253 = seoul256.light(253);
pub const seoul256_light_254 = seoul256.light(254);
pub const seoul256_light_255 = seoul256.light(255);
pub const seoul256_light_256 = seoul256.light(256);
@@ -1271,6 +1267,71 @@ const theme_groups = [_]ThemeGroup{
/// The theme a session starts in, by name: never a place in the ring.
pub const default_theme = indexOfTheme("orchard");
+/// The themes retired (DESIGN.md E, under the user's ruling of 2026-11-25)
+/// and the kept one each stands for where its name is still read: an init
+/// file's `Theme`, a /ctl write, a dump; null, the default.
+const retired = [_]struct { []const u8, ?[]const u8 }{
+ .{ "seoul256_dark_238", "seoul256_dark_237" },
+ .{ "seoul256_dark_239", "seoul256_dark_237" },
+ .{ "seoul256_light_252", "seoul256_light_254" },
+ .{ "seoul256_light_253", "seoul256_light_254" },
+ .{ "ayu_dark_helix", "ayu_dark" },
+ .{ "ayu_dark_zed", "ayu_dark" },
+ .{ "ayu_light_zed", "ayu_light" },
+ .{ "ayu_mirage_zed", "ayu_mirage" },
+ .{ "base16_default_light", "base16_default_dark" },
+ .{ "base16_terminal", "dark" },
+ .{ "base16_transparent", "base16_default_dark" },
+ .{ "bogster_light", "bogster" },
+ .{ "cyan_light", "jetbrains_cyan_light" },
+ .{ "eldritch_transparent", "eldritch" },
+ .{ "gruvbox_dark_hard_zed", "gruvbox_dark_hard" },
+ .{ "gruvbox_dark_soft_zed", "gruvbox_dark_soft" },
+ .{ "gruvbox_dark_zed", "gruvbox" },
+ .{ "gruvbox_light_hard_zed", "gruvbox_light_hard" },
+ .{ "gruvbox_light_soft_zed", "gruvbox_light_soft" },
+ .{ "gruvbox_light_zed", "gruvbox_light" },
+ .{ "gruvbox_material", "gruvbox_material_dark_medium" },
+ .{ "hex_lavender", "hex_toxic" },
+ .{ "hex_poison", "hex_toxic" },
+ .{ "hex_steel", "hex_toxic" },
+ .{ "ingrid", null },
+ .{ "iroaseta", "ao" },
+ .{ "nord_helix", "nord" },
+ .{ "nord_light", "nord" },
+ .{ "nyxvamp_transparent", "nyxvamp_veil" },
+ .{ "peachpuff", "dark" },
+ .{ "seoul256_dark", "seoul256_dark_235" },
+ .{ "seoul256_dark_hard", "seoul256_dark_233" },
+ .{ "seoul256_dark_soft", "seoul256_dark_237" },
+ .{ "seoul256_light", "seoul256_light_254" },
+ .{ "seoul256_light_hard", "seoul256_light_256" },
+ .{ "seoul256_light_soft", "seoul256_light_254" },
+ .{ "term16_dark", "dark" },
+ .{ "term16_light", "light" },
+ .{ "tokyonight", "tokyonight_night" },
+ .{ "ttox", "dark" },
+ .{ "ttox_soft", "dark" },
+ .{ "vesper_transparent", "vesper" },
+ .{ "zed_onedark", "one_dark_zed" },
+ .{ "zed_onelight", "one_light_zed" },
+};
+
+/// The ring's place for the kept theme a retired `name` stands for,
+/// whatever its case.
+pub fn successorOf(name: []const u8) ?usize {
+ for (retired) |r| if (std.ascii.eqlIgnoreCase(r[0], name)) return if (r[1]) |kept| themeIndex(kept).? else default_theme;
+ return null;
+}
+
+/// The theme a dump naming `name` restores: that one, a retired one's
+/// successor, else the one in effect (`was`) where this build has it, else
+/// the default.
+pub fn restoredIndex(name: []const u8, was: usize) usize {
+ for (themes, 0..) |t, i| if (std.mem.eql(u8, t.name, name)) return i;
+ return successorOf(name) orelse if (was < themes.len) was else default_theme;
+}
+
fn indexOfTheme(comptime name: []const u8) usize {
return comptime blk: {
@setEvalBranchQuota(100000);
@@ -2030,11 +2091,10 @@ test "the picker's sections run in ring order and cover it" {
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" {
+test "seoul256's eight backgrounds ring in their order, after Catppuccin and before Zenbones" {
const names = [_][]const u8{
- "seoul256_dark_233", "seoul256_dark_234", "seoul256_dark_235", "seoul256_dark_236",
- "seoul256_dark_237", "seoul256_dark_238", "seoul256_dark_239", "seoul256_light_252",
- "seoul256_light_253", "seoul256_light_254", "seoul256_light_255", "seoul256_light_256",
+ "seoul256_dark_233", "seoul256_dark_234", "seoul256_dark_235", "seoul256_dark_236",
+ "seoul256_dark_237", "seoul256_light_254", "seoul256_light_255", "seoul256_light_256",
};
const first = indexOfTheme("seoul256_dark_233");
for (names, themes[first..][0..names.len]) |name, t| try std.testing.expectEqualStrings(name, t.name);
@@ -2658,21 +2718,6 @@ fn ringFailures(th: *const Theme, c: *const Chrome, designed_here: bool) std.Enu
return f;
}
-/// The themes that fail a check they are held to until the line that fixes
-/// 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 }{
- // L7: retired.
- .{ "seoul256_dark_238", "L7: retired" },
- .{ "seoul256_dark_239", "L7: retired" },
- .{ "seoul256_light_252", "L7: retired" },
- .{ "seoul256_light_253", "L7: retired" },
- .{ "hex_lavender", "L7: retired" },
- .{ "hex_poison", "L7: retired" },
- .{ "hex_steel", "L7: retired" },
- .{ "ingrid", "L7: retired" },
-};
-
/// 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).
@@ -2684,7 +2729,6 @@ test "every theme in the ring meets every floor pardes owns (DESIGN.md B4), nati
const ports = comptime indexOfTheme("dark_plus");
const helix = comptime indexOfTheme("helix");
var passing: usize = 0;
- var wrong: usize = 0;
for (&themes, 0..) |*th, i| {
const c = Chrome.of(th);
// The original's own (B1.5): never moved.
@@ -2707,24 +2751,17 @@ test "every theme in the ring meets every floor pardes owns (DESIGN.md B4), nati
if (check.original() and !ours and !(std.mem.startsWith(u8, @tagName(check), "ansi") and th.ansi == null)) continue;
held.insert(check);
}
- const expected = for (ring_expected) |e| {
- if (std.mem.eql(u8, e[0], th.name)) break true;
- } else false;
- if (held.count() == 0) passing += 1;
- if (held.count() > 0 and !expected) {
- wrong += 1;
- std.debug.print("{s} fails:", .{th.name});
- var failed = held.iterator();
- while (failed.next()) |check| std.debug.print(" {s}", .{@tagName(check)});
- std.debug.print("\n", .{});
- }
- if (held.count() == 0 and expected) {
- wrong += 1;
- std.debug.print("{s} passes now: take it off ring_expected\n", .{th.name});
+ if (held.count() == 0) {
+ passing += 1;
+ continue;
}
+ std.debug.print("{s} fails:", .{th.name});
+ var failed = held.iterator();
+ while (failed.next()) |check| std.debug.print(" {s}", .{@tagName(check)});
+ std.debug.print("\n", .{});
}
- std.debug.print("ring floors: {d} of {d} themes pass; {d} on the expected list\n", .{ passing, themes.len, ring_expected.len });
- try std.testing.expectEqual(0, wrong);
+ std.debug.print("ring floors: {d} of {d} themes pass\n", .{ passing, themes.len });
+ try std.testing.expectEqual(themes.len, passing);
}
/// A faithful port's own colours pardes moves where they miss a floor: its
@@ -2873,3 +2910,51 @@ 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, ".{ .name = \"x\", .page = null, .txet = null }"));
try std.testing.expectEqualStrings("one_dark_zed", p.theme().name);
}
+
+test "a retired theme's name stands for its successor in an init file and a dump, said once; an unknown one leaves the default, in today's words (DESIGN.md E)" {
+ const gpa = std.testing.allocator;
+ const Said = struct {
+ fn count(p: *const Pardes, needle: []const u8) usize {
+ var n: usize = 0;
+ for (p.messages.log[0..p.messages.len]) |m| {
+ if (std.mem.indexOf(u8, m.text[0..m.len], needle) != null) n += 1;
+ }
+ return n;
+ }
+ };
+ for ([_][3][]const u8{
+ .{ "gruvbox_dark_zed", "gruvbox", "Theme gruvbox_dark_zed was retired: gruvbox instead" },
+ .{ "TTOX", "dark", "Theme TTOX was retired: dark instead" },
+ // a retired one with no kept twin: the default
+ .{ "ingrid", "orchard", "Theme ingrid was retired: orchard instead" },
+ .{ "no-such-theme", "orchard", "Theme: no theme \"no-such-theme\"; like it: " },
+ }) |case| {
+ const line = try std.fmt.allocPrint(gpa, "Theme {s}\n", .{case[0]});
+ defer gpa.free(line);
+ const p = try Pardes.init(gpa, .{ .tty_only = true, .startup_config = line });
+ defer p.deinit();
+ try std.testing.expectEqualStrings(case[1], p.theme().name);
+ try std.testing.expectEqual(1, Said.count(p, case[2]));
+ }
+ // A dump naming one (this build writes none: a dump of an older one,
+ // its theme's name put in): its successor.
+ const source = try Pardes.init(gpa, .{ .tty_only = true, .startup_config = "Theme acme\n" });
+ defer source.deinit();
+ try @import("dump.zig").dumpState(source);
+ const bytes = try gpa.dupe(u8, source.dump_out.?);
+ defer gpa.free(bytes);
+ const at = std.mem.indexOf(u8, bytes, "acme").?;
+ try std.testing.expect(std.mem.indexOfPos(u8, bytes, at + 4, "acme") == null);
+ @memcpy(bytes[at..][0..4], "ttox");
+ const restored = try @import("dump.zig").initFromDump(gpa, .{ .tty_only = true }, bytes);
+ defer restored.deinit();
+ try std.testing.expectEqualStrings("dark", restored.theme().name);
+}
+
+test "every retired theme's successor is in the ring, and no retired name is" {
+ for (retired) |r| {
+ try std.testing.expectEqual(null, themeIndex(r[0]));
+ if (r[1]) |kept| try std.testing.expect(themeIndex(kept) != null);
+ }
+ try std.testing.expectEqual(44, retired.len);
+}