From 47952d7797b25f41a3e29ec0dc349564c0185fd4 Mon Sep 17 00:00:00 2001 From: Gabriel Schneider Date: Thu, 26 Nov 2026 04:30:06 -0300 Subject: gen_themes: the importer reads what the helix and zed sources already say (the themes programme's L4; DESIGN.md B7, R3, E1): HELIX: the text the theme draws code in, `variable` where it is a neutral ink (OKLab chroma under 0.04) that reads 4.5:1 on the page, else `ui.text` (github's muted #8b949e gives way to its #c9d1d9; github_dark_dimmed's 3.9:1 to 7.6:1); the tag the inactive status bar where the theme has one, the active one its focused tag where it is tone on tone, the tag's ink the status bar's (an inactive bar's is often faded, neonotte's #555973); the four severities from `diagnostic.*` (often an underline only, no fg) and the plain `error`/`warning`/`info`/`hint` scopes, error else the theme's own palette red (UX E3), never the terminal's guessed one; `added`/`deleted` from `diff.plus`/`diff.minus` where they are a green and a red (each a hue, within 60 degrees: a grey, a yellow deleted or a tritan blue cannot be told apart as R10's rows: ashen, wolf_alabaster's four, zenburn, github_light_tritanopia and modus_operandi_tritanopia failed the ring's diff check on them, and keep pardes's); the caret's line number from `ui.linenr.selected`; a program's sixteen from the theme's own palette where it names red, green, yellow, blue, magenta (or purple) and cyan (or aqua), their light or bright ones, black, white and a grey (else the page, the ink, the comment), else null for R14; ZED: the active tab the focused tag, error/warning/info/hint, created/deleted (the same green-and-red rule), the search match as drawn (its alpha over the editor's page, not dropped), the active line number; R3, THE IMPORT RULE (L1 left it to the importer: a theme carries no import flag): a status bar on the other side of light from its page is no tag: the tag is the page a 1.15:1 step off in its own hue (its light scaled), in the text; E1's import FIXES, a table in the generator (a name no vendored theme has is a build error): everforest_light's and hex_toxic's search hit, their own yellow as a ground their soft text reads on (#ffe699 1.14:1 off the page, the text 4.53:1; #2f3200 1.11:1, 4.27:1; R8 takes it at R0's 1.1:1 with 0.08 OKLab, L3); the generator does the little colour maths it needs (luminance, contrast, OKLab a/b, the step), the dependency-free host tool it was; across the 203 imports: 202 errors, 202 warnings, 196 infos, 198 hints, 178 added/deleted pairs, 195 caret line numbers, 59 focused tags, 13 hits of their own; RUN (TEST FIRST): tools/gen_themes.zig's own tests, a minimal toml or json each, now in core-test (build/tests.zig, on the host): "B7: the text is helix's `variable` ...", "B7: the tag is the inactive status bar, and the active one its focus where it is tone on tone", "R3, the import rule: ...", "B7: the severities from diagnostic.* and the plain scopes ...", "B7: added and deleted from diff.plus and diff.minus ... (a yellow deleted, a grey added: none)", "B7: a program's sixteen from the palette ...", "B7, zed: ... a search match as drawn over the page": on L3's generator none compiles (no field for any of them); the ring test with L4's six taken off its list: everforest_light and hex_toxic fail hit, github_dark_dimmed text, gruvbox_material_light_hard/_medium/_soft severities4; with the mapping the diff rows of the eight above failed until the green-and-red rule: 272 of 285 themes pass (266 at L3), 13 on the list (L5 1, L7 8, soft 4); colors.zig's neonotte84 golden re-pinned where B7 moves it: its match ink and current hit, the hits' amber, #e29e47 (the warning pardes derived) to #e59d3c (its own palette's yellow now its warning); core-test 1140/1313 (173 skipped: L3's 1133/1306 + the importer's 7; the full run's one failure the neonotte84 golden, re-pinned after it, its test alone passing); OUTSIDE my files: build/tests.zig (the importer's tests in core-test, 5 lines); no dump or digest change Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_016Y9MNBFhdevVu48bvL9kCE --- build/tests.zig | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'build') diff --git a/build/tests.zig b/build/tests.zig index 8cf42acd..c35857f7 100644 --- a/build/tests.zig +++ b/build/tests.zig @@ -76,6 +76,11 @@ pub fn add(b: *std.Build, c: struct { core_test_step.dependOn(&run_core_test.step); if (core_match) |check| check.addArtifactArg(core_test); } + // The theme importer's own tests (tools/gen_themes.zig): its mapping, + // rule by rule, on the machine that builds. + const gen_themes_test = b.addTest(.{ .root_module = b.createModule(.{ .root_source_file = b.path("tools/gen_themes.zig"), .target = b.graph.host, .optimize = .debug }), .filters = c.test_filters }); + core_test_step.dependOn(&b.addRunArtifact(gen_themes_test).step); + if (core_match) |check| check.addArtifactArg(gen_themes_test); // The terminal module's own tests (core/term/): the emulator without a core. const run_term_test = units.add(b, b.addTest(.{ .root_module = c.parts.term, .filters = c.test_filters }), null); b.step("term-test", "run the terminal module's own tests (core/term/)").dependOn(&run_term_test.step); -- cgit v1.3 From 77b22e7c7623696feb52292bb86839870e20050d Mon Sep 17 00:00:00 2001 From: Gabriel Schneider Date: Thu, 26 Nov 2026 04:37:03 -0300 Subject: 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=` (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 Claude-Session: https://claude.ai/code/session_016Y9MNBFhdevVu48bvL9kCE --- build/core.zig | 9 +- core/colors.zig | 167 +- core/dump.zig | 10 +- core/exec.zig | 7 + core/ninep/ctl.zig | 2 +- core/themes/seoul256.zig | 78 +- tools/gen_themes.zig | 12 +- vendor/themes/ayu.LICENSE | 21 - vendor/themes/ayu.json | 1228 --------------- vendor/themes/ayu_dark_helix.toml | 92 -- vendor/themes/base/ayu_dark_helix.toml | 92 ++ vendor/themes/base/hex_steel.toml | 127 ++ vendor/themes/base/nord_helix.toml | 199 +++ vendor/themes/base16_default_light.toml | 79 - vendor/themes/base16_terminal.toml | 55 - vendor/themes/base16_transparent.toml | 84 - vendor/themes/bogster_light.toml | 103 -- vendor/themes/cyan_light.toml | 5 - vendor/themes/eldritch_transparent.toml | 7 - vendor/themes/gruvbox-material.toml | 6 - vendor/themes/gruvbox.LICENSE | 21 - vendor/themes/gruvbox.json | 2539 ------------------------------- vendor/themes/hex_lavender.toml | 41 - vendor/themes/hex_poison.toml | 41 - vendor/themes/hex_steel.toml | 127 -- vendor/themes/ingrid.toml | 77 - vendor/themes/iroaseta.toml | 162 -- vendor/themes/nord_helix.toml | 199 --- vendor/themes/nord_light.toml | 90 -- vendor/themes/nyxvamp-transparent.toml | 54 - vendor/themes/peachpuff.toml | 66 - vendor/themes/seoul256-dark-hard.toml | 16 - vendor/themes/seoul256-dark-soft.toml | 15 - vendor/themes/seoul256-dark.toml | 161 -- vendor/themes/seoul256-light-hard.toml | 16 - vendor/themes/seoul256-light-soft.toml | 16 - vendor/themes/seoul256-light.toml | 51 - vendor/themes/term16_dark.toml | 80 - vendor/themes/term16_light.toml | 85 -- vendor/themes/tokyonight.toml | 136 -- vendor/themes/ttox.toml | 33 - vendor/themes/ttox_soft.toml | 37 - vendor/themes/vesper-transparent.toml | 25 - vendor/themes/zed_onedark.toml | 114 -- vendor/themes/zed_onelight.toml | 62 - 45 files changed, 575 insertions(+), 6072 deletions(-) delete mode 100644 vendor/themes/ayu.LICENSE delete mode 100644 vendor/themes/ayu.json delete mode 100644 vendor/themes/ayu_dark_helix.toml create mode 100644 vendor/themes/base/ayu_dark_helix.toml create mode 100644 vendor/themes/base/hex_steel.toml create mode 100644 vendor/themes/base/nord_helix.toml delete mode 100644 vendor/themes/base16_default_light.toml delete mode 100644 vendor/themes/base16_terminal.toml delete mode 100644 vendor/themes/base16_transparent.toml delete mode 100644 vendor/themes/bogster_light.toml delete mode 100644 vendor/themes/cyan_light.toml delete mode 100644 vendor/themes/eldritch_transparent.toml delete mode 100644 vendor/themes/gruvbox-material.toml delete mode 100644 vendor/themes/gruvbox.LICENSE delete mode 100644 vendor/themes/gruvbox.json delete mode 100644 vendor/themes/hex_lavender.toml delete mode 100644 vendor/themes/hex_poison.toml delete mode 100644 vendor/themes/hex_steel.toml delete mode 100644 vendor/themes/ingrid.toml delete mode 100644 vendor/themes/iroaseta.toml delete mode 100644 vendor/themes/nord_helix.toml delete mode 100644 vendor/themes/nord_light.toml delete mode 100644 vendor/themes/nyxvamp-transparent.toml delete mode 100644 vendor/themes/peachpuff.toml delete mode 100644 vendor/themes/seoul256-dark-hard.toml delete mode 100644 vendor/themes/seoul256-dark-soft.toml delete mode 100644 vendor/themes/seoul256-dark.toml delete mode 100644 vendor/themes/seoul256-light-hard.toml delete mode 100644 vendor/themes/seoul256-light-soft.toml delete mode 100644 vendor/themes/seoul256-light.toml delete mode 100644 vendor/themes/term16_dark.toml delete mode 100644 vendor/themes/term16_light.toml delete mode 100644 vendor/themes/tokyonight.toml delete mode 100644 vendor/themes/ttox.toml delete mode 100644 vendor/themes/ttox_soft.toml delete mode 100644 vendor/themes/vesper-transparent.toml delete mode 100644 vendor/themes/zed_onedark.toml delete mode 100644 vendor/themes/zed_onelight.toml (limited to 'build') diff --git a/build/core.zig b/build/core.zig index f9cb450f..c787fdc8 100644 --- a/build/core.zig +++ b/build/core.zig @@ -131,9 +131,11 @@ fn patchesHash(b: *std.Build, io: std.Io) u64 { return h; } -fn vendoredThemes(b: *std.Build, io: std.Io) []const []const u8 { +/// The theme sources in `sub` of vendor/themes, sorted: the ring's (`.`), +/// or the retired ones kept themes inherit from (`base`, read, never rung). +fn vendoredThemes(b: *std.Build, io: std.Io, sub: []const u8) []const []const u8 { var names: std.ArrayList([]const u8) = .empty; - var dir = b.root.root_dir.handle.openDir(io, "vendor/themes", .{ .iterate = true }) catch @panic("open vendor/themes"); + var dir = b.root.root_dir.handle.openDir(io, b.pathJoin(&.{ "vendor/themes", sub }), .{ .iterate = true }) catch @panic("open vendor/themes"); defer dir.close(io); var it = dir.iterate(); while (it.next(io) catch @panic("read vendor/themes")) |e| { @@ -161,7 +163,8 @@ pub fn generatedThemes(b: *std.Build, io: std.Io, target: std.Build.ResolvedTarg }); const run_theme_gen = b.addRunArtifact(theme_gen); const themes_out = run_theme_gen.addOutputDirectoryArg("themes"); - for (vendoredThemes(b, io)) |name| run_theme_gen.addFileArg(b.path(b.fmt("vendor/themes/{s}", .{name}))); + for (vendoredThemes(b, io, ".")) |name| run_theme_gen.addFileArg(b.path(b.fmt("vendor/themes/{s}", .{name}))); + for (vendoredThemes(b, io, "base")) |name| run_theme_gen.addPrefixedFileArg("base=", b.path(b.fmt("vendor/themes/base/{s}", .{name}))); return b.createModule(.{ .target = target, .optimize = optimize, 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); +} diff --git a/core/dump.zig b/core/dump.zig index 2dde9c8c..69eda35e 100644 --- a/core/dump.zig +++ b/core/dump.zig @@ -422,10 +422,8 @@ fn loadKnowing(gpa: std.mem.Allocator, opts: Options, bytes: []const u8, notes: const was = try l.get(OnDisk); if (on_disk) |out| out.* = was; const theme = try l.get([]const u8); - // This build's place for that theme; one it has not, its first. - p.settings.theme = for (colors.themes, 0..) |t, i| { - if (std.mem.eql(u8, t.name, theme)) break i; - } else if (p.settings.theme < colors.themes.len) p.settings.theme else 0; + // This build's place for that theme, a retired one's successor's. + p.settings.theme = colors.restoredIndex(theme, p.settings.theme); // A mount this process was started with stands; one of the same name // to elsewhere is refused, never silently put over it. for (mounts) |m| { @@ -515,9 +513,7 @@ fn loadImage(gpa: std.mem.Allocator, opts: Options, bytes: []const u8, notes: ?* if (on_disk) |out| out.* = was; const theme: []const u8 = if (try walk.Get.member(root, "theme")) |c| try l.get([]const u8, c) else ""; defer gpa.free(theme); - p.settings.theme = for (colors.themes, 0..) |t, i| { - if (std.mem.eql(u8, t.name, theme)) break i; - } else if (p.settings.theme < colors.themes.len) p.settings.theme else 0; + p.settings.theme = colors.restoredIndex(theme, p.settings.theme); for (mounts) |m| { const existing = for (p.fs.mounts.items) |e| { if (std.mem.eql(u8, e.name, m.name)) break e; diff --git a/core/exec.zig b/core/exec.zig index a56c17f9..44cfea64 100644 --- a/core/exec.zig +++ b/core/exec.zig @@ -1008,6 +1008,13 @@ pub fn applySettingBuiltin(p: *Pardes, setting: config.Settings.Setting, arg: ?[ .theme => { const want = std.mem.trim(u8, arg orelse return, " \t\r\n"); if (colors.themeIndex(want)) |i| return colors.setThemeIndex(p, i); + // A retired theme's name (DESIGN.md E): its successor, said. + if (colors.successorOf(want)) |i| { + colors.setThemeIndex(p, i); + var said: pardes.Kind.Buf(128) = .{}; + _ = pardes.Messages.say(p, .notice, v.active, said.print("Theme {s} was retired: {s} instead", .{ want[0..@min(want.len, 40)], colors.themes[i].name })); + return; + } // A failure is said, the init file's too (applyStartupConfig // logs it with its line): never silent. // All of it within the 128 bytes a 9P error carries, so a write diff --git a/core/ninep/ctl.zig b/core/ninep/ctl.zig index 2411b20f..80d1176c 100644 --- a/core/ninep/ctl.zig +++ b/core/ninep/ctl.zig @@ -555,7 +555,7 @@ fn checkBuiltin(p: *Pardes, req: Req, line: []const u8, scope: builtins.Scope) ? if (arg.len == 0 and builtins.registry.requiresArg(b)) return refuse(p, req, "wrong #args in control message", line); const setting = config.Settings.find(word) orelse return null; const takes = switch (setting.action) { - .theme => if (pardes.colors.themeIndex(arg) != null) true else { + .theme => if (pardes.colors.themeIndex(arg) != null or pardes.colors.successorOf(arg) != null) true else { // `refuse` quotes the line after it, all in the 128 bytes an // Rerror carries: the names get what is left. const head = "bad value in control message; like it: "; diff --git a/core/themes/seoul256.zig b/core/themes/seoul256.zig index 0c4c17ab..5940d485 100644 --- a/core/themes/seoul256.zig +++ b/core/themes/seoul256.zig @@ -1,7 +1,8 @@ //! Seoul256 (junegunn/seoul256.vim), as close to the original as pardes -//! can draw it: its dark style at each of its backgrounds 233 to 239 and its -//! light one at 252 to 256, a theme each (`dark`, `light`; colors.zig rings -//! them as seoul256_