From 0788ce68c4c43148d3d5fa173b4fe46aa10371c9 Mon Sep 17 00:00:00 2001 From: Gabriel Schneider Date: Thu, 26 Nov 2026 03:40:00 -0300 Subject: themes, colors, gen_themes: every theme file in the v2 names, values unchanged (the themes programme's L3; DESIGN.md B2, B3, B8, E1, G4, G6), the fields the new names derive deleted, the comptime fold of the old names gone, each faithful port's file saying each own colour pardes moves to meet a floor, and E1's five fixes: THE FILES: core/themes/*.zig renamed by a script (bg page, fg text, tag_bg tag, tag_fg tag_text, box accent, sel_bg selection, kw keyword, str string, num number, palette ansi, sel_fg selection_text, tag_active_* tag_focus*, tag_name_fg tag_name, tagline_* workspace*, lineno* line_number*, search_bg hit, diagnostic_* the severities, border rule, scroll_* rail*, empty_col empty_column, box_border grip_ring, box_dirty dirty, column_box column_grip, tag_sel_bg tag_selection; seoul256's level rows and their citations too), box_dim, column_box_dim, tag_active_name_fg, search_fg and acme's tag_reading_bg deleted with the lines citing them (B8: always derived; G1': acme's #f3f0cc reading tint goes with the ground), acme's sweep_bg and sweep_fg one `sweeps`; tools/gen_themes.zig writes the generated ones in the same names (its emitted box_dim, the selection again, gone); `colors.fold` folds the files into `Theme` itself (a field no Theme has is a compile error; `as` turns acme's sweep literals into Theme.Sweep, which a literal's own struct type does not coerce to); `legacy_themes`, the ring folded in the old names at comptime, deleted: THE OLD NAMES' VIEW (what draw.zig and the old ChromeTheme and Roles still read until L2a) is a ring theme's chrome's, `ChromeTheme.view`, filled from its Chrome as L1 filled a new-names ThemeFile's (`viewOf`: the old required fields a theme leaves unset, and the derived ones: box_dim a resting grip's fill, the tag's own ground where a theme rings its grips itself (acme's clean button, so its grid grip keeps its look) else the resting ring; tag_active_name_fg `name[1]`, column_box_dim `grip.column_rest`); `Pardes.theme()` reads it (a ThemeFile's, the file itself, as before); ChromeTheme.box, the focused grip the grid fills, is the chrome's `grip.focus` (the accent held 3:1, R6: ayu_light's accent, 2:1 on its tag, was its resting ring too, and the grid drew its focused and resting grips alike); the library's `Theme` and `themes` are the v2 ones (lib_syntax: page, ink and synInk read page, text, keyword, string, number, comment; Grounds.of takes a Theme), runtime/macos.zig's bare page reads `themes[0].page`; E1's FIXES (the ring test's L3 list): acme's sixteen each 4.5:1 on its page, the native floor (6, 8 and 13 held darker in their hue; 10, 11 and 14, held there, landed on their normal colour and go 0.06 OKLab darker than it, R14's bright on a light page: #038384 #757575 #016e08 #785300 #b942b9 #017070); solarized_dark's, solarized_light's and seoul256's light levels' search hit their own hue as a ground the text reads on (#1d180e, #ffeb99, #a6e6fe; each file says from what and why); R8 takes a theme's own hit at R0's visible alternative, 1.1:1 off the page with 0.08 OKLab, only where its text leaves no room for 1.5:1 (no ground that far off keeps the text its floor: those four and forge_soft and ayu_light, whose own hits are taken now where an amber stood; no other theme's hit moves), else E1's `hit` fixes could not be met; G4: core/themes' ports say, under "Moved by pardes as it loads", each own colour Chrome.of moves (focused tag and grip, the resting and unsaved grip, the selection and its ink, the hit, the four severities on the page; 267 lines over 54 files, written from the test's own output by .scratch/themes/L3457/tools/g4_headers.py); RUN (TEST FIRST): colors.zig "every faithful port's file says each of its own colours pardes moves to meet a floor (DESIGN.md G4)" (each port's own value Chrome.of moves, as `role #own -> #got`, found in its file): fails on the renamed files with 273 unsaid, passes now; "every theme in the ring meets every floor ..." with L3's five taken off its list: acme fails ansi and ansi_pro, solarized_dark, solarized_light, seoul256_light_254 and _255 fail hit, all five pass now: 266 of 285 themes pass (261 at L1), 19 on the list (L4 6, L5 1, L7 8, soft 4); draw.zig's "an unfocused reading pane's box in the grid is its ring round the reading tint where the box's fill is the tag's own ground (acme's)" failed on the first view (acme's resting fill its ring), passes with the tag's ground; "a grip's four states ... are each its own" failed in ayu_light on the raw accent, passes on grip.focus; the old tests that pinned the deleted fields' file values keep what is still a file's (a name's tint at its tag ink's lightness, the accent off the column grip; the helix document test strips the derived fields too; the names test reads Chrome's names, an ink held to white or black its own name, ao's and modus_vivendi's); the consumer's lib.zig pins orchard's page, ink and syntax unchanged (dark's page its `.tag`); the ring's values unchanged by the rename (the ring test's count and every original's colour asserted unmoved); core-test 1133/1306 (173 skipped: L2b's 1132/1305 + the G4 test); OUTSIDE my files: core/Core.zig `theme()` (the view), core/lib_syntax.zig (v2 Theme), runtime/macos.zig `pardes_theme_bg` (one line), test/consumer/lib.zig (`.tag`); the process goldens move with the view (the grid's resting grip, the focused name's tint, the column grip at rest, acme's reading grip) and are re-recorded and read at the programme's end gate; no dump or digest change (the view is the chrome's, a `local` field) Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_016Y9MNBFhdevVu48bvL9kCE --- core/lib_syntax.zig | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'core/lib_syntax.zig') diff --git a/core/lib_syntax.zig b/core/lib_syntax.zig index fa6812ee..2c771b72 100644 --- a/core/lib_syntax.zig +++ b/core/lib_syntax.zig @@ -102,21 +102,21 @@ pub const NodeWalk = syntax.NodeWalk; pub const Span = syntax.Span; pub const walkNodes = syntax.walkNodes; -pub const Theme = colors.LegacyTheme; +pub const Theme = colors.Theme; /// Every theme: pardes's own, then those imported from helix and zed. The /// first is the default. -pub const themes: []const Theme = &colors.legacy_themes; +pub const themes: []const Theme = &colors.themes; /// The theme named `name`, whatever its case. pub fn theme(name: []const u8) ?*const Theme { - return &colors.legacy_themes[colors.themeIndex(name) orelse return null]; + return &colors.themes[colors.themeIndex(name) orelse return null]; } /// A theme's page and its text's ink as a file pane has them: its own, or /// its tag's for the one theme with none (`dark`, a terminal's own). pub fn page(th: *const Theme) [3]u8 { - return th.bg orelse th.tag_bg; + return th.page orelse th.tag; } pub fn ink(th: *const Theme) [3]u8 { - return th.fg orelse th.tag_fg; + return th.text orelse th.tag_text; } pub const synInk = colors.synInk; -- cgit v1.3 From fed268f2282a6d393a116d103e1fd88da87ecbff Mon Sep 17 00:00:00 2001 From: Gabriel Schneider Date: Thu, 26 Nov 2026 04:36:36 -0300 Subject: 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 Claude-Session: https://claude.ai/code/session_016Y9MNBFhdevVu48bvL9kCE --- core/colors.zig | 177 +++++++++++++++++++++++++++++--------------- core/config.zig | 2 +- core/lib_syntax.zig | 5 +- core/themes/dark.zig | 55 +++++++------- core/themes/light.zig | 30 ++++++++ core/themes/mono.zig | 31 ++++++++ core/themes/okabe.zig | 32 ++++++++ core/themes/sepia.zig | 30 ++++++++ runtime/macos.zig | 2 +- test/consumer/lib.zig | 2 +- test/process/tty_themes.zig | 177 +++++++++++++++++++++++++++++--------------- tools/gen_themes.zig | 17 ++++- 12 files changed, 406 insertions(+), 154 deletions(-) create mode 100644 core/themes/light.zig create mode 100644 core/themes/mono.zig create mode 100644 core/themes/okabe.zig create mode 100644 core/themes/sepia.zig (limited to 'core/lib_syntax.zig') 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/ // .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; -} - -/// Original and classic-inspired Pardes palettes precede retained imports. -pub const native_theme_count = 15; + return if (index >= native_count) import_heads[index - native_count] else null; +} + +/// 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); } diff --git a/core/config.zig b/core/config.zig index 03cb6044..dc1d98dc 100644 --- a/core/config.zig +++ b/core/config.zig @@ -614,7 +614,7 @@ pub const kill_to_line_start: []const Chord = &.{.{ .cp = 'u', .ctrl = true }}; pub const kill_to_line_end: []const Chord = &.{.{ .cp = 'k', .ctrl = true }}; pub const Settings = struct { - theme: usize = 0, + theme: usize = pardes.colors.default_theme, wrap: bool = true, debug: bool = false, /// The workspace tag row. Native shells with their own chrome (the macOS diff --git a/core/lib_syntax.zig b/core/lib_syntax.zig index 2c771b72..448ac7f3 100644 --- a/core/lib_syntax.zig +++ b/core/lib_syntax.zig @@ -103,9 +103,10 @@ pub const Span = syntax.Span; pub const walkNodes = syntax.walkNodes; pub const Theme = colors.Theme; -/// Every theme: pardes's own, then those imported from helix and zed. The -/// first is the default. +/// Every theme: pardes's own, then those imported from helix and zed. pub const themes: []const Theme = &colors.themes; +/// The one a session starts in (`orchard`), its place in `themes`. +pub const default_theme = colors.default_theme; /// The theme named `name`, whatever its case. pub fn theme(name: []const u8) ?*const Theme { return &colors.themes[colors.themeIndex(name) orelse return null]; diff --git a/core/themes/dark.zig b/core/themes/dark.zig index 51768f56..24506f6b 100644 --- a/core/themes/dark.zig +++ b/core/themes/dark.zig @@ -1,33 +1,36 @@ -//! pardes's own dark theme, and the boot default until the helix capture -//! displaced it. It stays in the ring because it is the only one that leaves -//! `bg`/`fg` NULL: the page keeps the host terminal's own default cell, so -//! pardes sits inside whatever the surrounding terminal already looks like and -//! only paints its chrome. Every other theme here dresses the whole page. -//! -//! The selection pair is the warm tan pardes used to paint EVERY theme's -//! selection with, back when those six numbers were module constants. This is -//! the theme it belongs to: a null page is the host terminal's, and a tan that -//! reads as keyboard-driven on whatever dark cell that turns out to be is -//! exactly what it was picked for. +//! pardes dark: the host terminal's own page, white comments, violet stuff. +//! The one theme that leaves `page` and `text` NULL: in a terminal the page +//! is the host's own cell, ink and sixteen, so pardes sits inside whatever +//! the terminal already looks like and paints only its chrome; a window +//! draws colors.null_page (#121212) and #cccccc, and its sixteen below. +//! DESIGN.md part C: comments the brightest ink (#f0f0f0, 16.4:1), keywords +//! violet (#d76ef0, 6.6:1), a lilac tag, a violet grip that reads (#a58bff, +//! 3.4:1 on the focused tag) and a violet selection (#46337a) so the hits +//! keep amber; its own severities and sixteen (the window's). pub const theme = .{ .name = "dark", .page = null, .text = null, - .selection = .{ 0x51, 0x3c, 0x17 }, - .selection_text = .{ 0xd8, 0xc8, 0xa8 }, .tag = .{ 0x2c, 0x2a, 0x3e }, - .tag_text = .{ 0x96, 0x96, 0x96 }, - // The focused tag: its band lighter in its own hue (1.54:1 off the - // plain one), its ink lighter to keep reading on it. - .tag_focus = .{ 0x48, 0x45, 0x66 }, - .tag_focus_text = .{ 0xc8, 0xc8, 0xc8 }, - .accent = .{ 0x66, 0x3f, 0xe0 }, - .keyword = .{ 0xda, 0x5e, 0xea }, - .string = .{ 0x85, 0xc3, 0x6f }, - .number = .{ 0xe1, 0xcb, 0x5f }, + .tag_text = .{ 0xab, 0xa9, 0xc3 }, + .tag_focus_text = .{ 0xd6, 0xd4, 0xe8 }, + .accent = .{ 0xa5, 0x8b, 0xff }, + .selection = .{ 0x46, 0x33, 0x7a }, + .selection_text = .{ 0xf4, 0xf0, 0xff }, + .keyword = .{ 0xd7, 0x6e, 0xf0 }, + .string = .{ 0x8f, 0xca, 0x78 }, + .number = .{ 0xe3, 0xcd, 0x64 }, .comment = .{ 0xf0, 0xf0, 0xf0 }, - .line_number = .{ 0x5a, 0x5a, 0x5a }, - .rail = .{ 0x2a, 0x2a, 0x2a }, - .rail_thumb = .{ 0x52, 0x52, 0x52 }, - .ansi = null, + .line_number = .{ 0x5c, 0x5c, 0x66 }, + .line_number_current = .{ 0x8e, 0x8c, 0x9e }, + .@"error" = .{ 0xff, 0x6e, 0x7f }, + .warning = .{ 0xff, 0xb4, 0x54 }, + .info = .{ 0x7f, 0xa8, 0xff }, + .hint = .{ 0x62, 0xd2, 0xc4 }, + .ansi = .{ + .{ 0x2c, 0x2a, 0x3e }, .{ 0xff, 0x6e, 0x7f }, .{ 0x8f, 0xca, 0x78 }, .{ 0xe3, 0xcd, 0x64 }, + .{ 0x7f, 0xa8, 0xff }, .{ 0xd7, 0x6e, 0xf0 }, .{ 0x62, 0xd2, 0xc4 }, .{ 0xc4, 0xc4, 0xcc }, + .{ 0x7e, 0x7b, 0x96 }, .{ 0xff, 0x95, 0xa1 }, .{ 0xae, 0xe3, 0x9a }, .{ 0xf2, 0xe0, 0x8a }, + .{ 0xa6, 0xc3, 0xff }, .{ 0xe6, 0x9c, 0xf7 }, .{ 0x8f, 0xe6, 0xda }, .{ 0xf0, 0xf0, 0xf0 }, + }, }; diff --git a/core/themes/light.zig b/core/themes/light.zig new file mode 100644 index 00000000..681c000a --- /dev/null +++ b/core/themes/light.zig @@ -0,0 +1,30 @@ +//! pardes light: dark's daylight sibling (DESIGN.md part D). White paper, +//! the comments the darkest ink as dark's are the brightest, violet keywords +//! and grip, a lilac-grey tag, a pale violet selection. For dark's users at a +//! sunny desk, or a phone outdoors. +pub const theme = .{ + .name = "light", + .page = .{ 0xfb, 0xfb, 0xfd }, + .text = .{ 0x34, 0x32, 0x3f }, + .tag = .{ 0xe9, 0xe7, 0xf3 }, + .tag_text = .{ 0x4b, 0x48, 0x62 }, + .accent = .{ 0x6a, 0x3f, 0xd8 }, + .selection = .{ 0xdd, 0xd3, 0xfb }, + .selection_text = .{ 0x1c, 0x1a, 0x24 }, + .keyword = .{ 0x8b, 0x2a, 0xb8 }, + .string = .{ 0x2f, 0x6e, 0x1f }, + .number = .{ 0x8a, 0x57, 0x00 }, + .comment = .{ 0x0d, 0x0c, 0x12 }, + .line_number = .{ 0xa3, 0xa1, 0xb0 }, + .line_number_current = .{ 0x6e, 0x6b, 0x80 }, + .@"error" = .{ 0xc0, 0x23, 0x3a }, + .warning = .{ 0x9a, 0x5a, 0x00 }, + .info = .{ 0x24, 0x57, 0xc5 }, + .hint = .{ 0x0f, 0x76, 0x6e }, + .ansi = .{ + .{ 0xe9, 0xe7, 0xf3 }, .{ 0xc0, 0x23, 0x3a }, .{ 0x2f, 0x6e, 0x1f }, .{ 0x8a, 0x57, 0x00 }, + .{ 0x24, 0x57, 0xc5 }, .{ 0x8b, 0x2a, 0xb8 }, .{ 0x0f, 0x76, 0x6e }, .{ 0x55, 0x53, 0x6a }, + .{ 0x73, 0x71, 0x84 }, .{ 0xd2, 0x36, 0x4d }, .{ 0x35, 0x82, 0x21 }, .{ 0xa0, 0x67, 0x00 }, + .{ 0x39, 0x6c, 0xde }, .{ 0xa4, 0x3f, 0xd4 }, .{ 0x04, 0x81, 0x77 }, .{ 0x0d, 0x0c, 0x12 }, + }, +}; diff --git a/core/themes/mono.zig b/core/themes/mono.zig new file mode 100644 index 00000000..f0dd109a --- /dev/null +++ b/core/themes/mono.zig @@ -0,0 +1,31 @@ +//! pardes mono: acme at night (DESIGN.md part D). Syntax by lightness +//! alone: keywords the brightest, strings a warm off-white, numbers the +//! text's, comments a step down (5.6:1). Hue only where pardes says a state: +//! the selection, hits, severities, added and deleted. For acme and Plan 9 +//! users, anyone who finds syntax colour noise, and screen sharing. +pub const theme = .{ + .name = "mono", + .page = .{ 0x11, 0x11, 0x13 }, + .text = .{ 0xbf, 0xc0, 0xc6 }, + .tag = .{ 0x1e, 0x1f, 0x24 }, + .tag_text = .{ 0xa2, 0xa4, 0xad }, + .accent = .{ 0xe6, 0xe7, 0xec }, + .selection = .{ 0x3b, 0x3d, 0x47 }, + .selection_text = .{ 0xf2, 0xf2, 0xf5 }, + .keyword = .{ 0xf2, 0xf2, 0xf5 }, + .string = .{ 0xd4, 0xd0, 0xc4 }, + .number = .{ 0xbf, 0xc0, 0xc6 }, + .comment = .{ 0x8a, 0x8b, 0x94 }, + .line_number = .{ 0x55, 0x56, 0x5e }, + .line_number_current = .{ 0x80, 0x81, 0x8b }, + .@"error" = .{ 0xff, 0x7b, 0x72 }, + .warning = .{ 0xe3, 0xb3, 0x41 }, + .info = .{ 0x79, 0xc0, 0xff }, + .hint = .{ 0xa5, 0xd6, 0xa7 }, + .ansi = .{ + .{ 0x1e, 0x1f, 0x24 }, .{ 0xff, 0x7b, 0x72 }, .{ 0x7e, 0xe7, 0x87 }, .{ 0xe3, 0xb3, 0x41 }, + .{ 0x79, 0xc0, 0xff }, .{ 0xd2, 0xa8, 0xff }, .{ 0x76, 0xe3, 0xea }, .{ 0xbf, 0xc0, 0xc6 }, + .{ 0x7b, 0x7d, 0x86 }, .{ 0xff, 0xa1, 0x98 }, .{ 0xa5, 0xf0, 0xb0 }, .{ 0xf2, 0xcc, 0x60 }, + .{ 0xa5, 0xd6, 0xff }, .{ 0xe2, 0xc5, 0xff }, .{ 0xb3, 0xf0, 0xff }, .{ 0xf2, 0xf2, 0xf5 }, + }, +}; diff --git a/core/themes/okabe.zig b/core/themes/okabe.zig new file mode 100644 index 00000000..ba8b1888 --- /dev/null +++ b/core/themes/okabe.zig @@ -0,0 +1,32 @@ +//! pardes okabe: colour-blind safe (DESIGN.md part D): Okabe and Ito's +//! eight hues, lightened for a dark page. Added is blue, deleted vermilion, +//! errors vermilion and warnings yellow: nothing says red against green. For +//! the 8 % of men with a colour vision deficiency, and anyone reading diffs. +pub const theme = .{ + .name = "okabe", + .page = .{ 0x0e, 0x12, 0x18 }, + .text = .{ 0xd8, 0xde, 0xe8 }, + .tag = .{ 0x1b, 0x22, 0x2c }, + .tag_text = .{ 0xa9, 0xb4, 0xc4 }, + .accent = .{ 0x56, 0xb4, 0xe9 }, + .selection = .{ 0x27, 0x41, 0x5e }, + .selection_text = .{ 0xee, 0xf3, 0xfa }, + .keyword = .{ 0x6c, 0xc0, 0xf0 }, + .string = .{ 0x3c, 0xcf, 0xa4 }, + .number = .{ 0xf0, 0xa8, 0x30 }, + .comment = .{ 0xd7, 0xcf, 0x7a }, + .line_number = .{ 0x4e, 0x58, 0x66 }, + .line_number_current = .{ 0x7d, 0x88, 0x98 }, + .@"error" = .{ 0xff, 0x8a, 0x4c }, + .warning = .{ 0xf0, 0xe4, 0x42 }, + .info = .{ 0x8c, 0xc8, 0xf0 }, + .hint = .{ 0xe5, 0x94, 0xc8 }, + .added = .{ 0x56, 0xb4, 0xe9 }, + .deleted = .{ 0xff, 0x8a, 0x4c }, + .ansi = .{ + .{ 0x1b, 0x22, 0x2c }, .{ 0xff, 0x8a, 0x4c }, .{ 0x3c, 0xcf, 0xa4 }, .{ 0xf0, 0xe4, 0x42 }, + .{ 0x56, 0xb4, 0xe9 }, .{ 0xe5, 0x94, 0xc8 }, .{ 0x8f, 0xd8, 0xf0 }, .{ 0xc4, 0xcc, 0xd8 }, + .{ 0x73, 0x7e, 0x8e }, .{ 0xff, 0xab, 0x7c }, .{ 0x6f, 0xe0, 0xbd }, .{ 0xf6, 0xee, 0x80 }, + .{ 0x86, 0xcc, 0xf2 }, .{ 0xf0, 0xb4, 0xda }, .{ 0xb4, 0xe6, 0xf6 }, .{ 0xee, 0xf3, 0xfa }, + }, +}; diff --git a/core/themes/sepia.zig b/core/themes/sepia.zig new file mode 100644 index 00000000..06cf96c1 --- /dev/null +++ b/core/themes/sepia.zig @@ -0,0 +1,30 @@ +//! pardes sepia: long reading by daylight (DESIGN.md part D). Warm paper, +//! brown-black ink, earth hues, a calm comment that still reads 5.9:1, and a +//! cool grey-blue selection so the hits keep their amber. For prose, docs and +//! PDFs side by side, and long sessions where white paper glares. +pub const theme = .{ + .name = "sepia", + .page = .{ 0xf4, 0xec, 0xdb }, + .text = .{ 0x3a, 0x2e, 0x22 }, + .tag = .{ 0xe6, 0xd8, 0xba }, + .tag_text = .{ 0x4b, 0x3d, 0x2b }, + .accent = .{ 0xa0, 0x56, 0x2a }, + .selection = .{ 0xc9, 0xd4, 0xdc }, + .selection_text = .{ 0x23, 0x1a, 0x10 }, + .keyword = .{ 0x94, 0x35, 0x1c }, + .string = .{ 0x4c, 0x6a, 0x1f }, + .number = .{ 0x7b, 0x4b, 0x9a }, + .comment = .{ 0x6a, 0x57, 0x3e }, + .line_number = .{ 0xa8, 0x98, 0x7c }, + .line_number_current = .{ 0x76, 0x65, 0x4b }, + .@"error" = .{ 0xb3, 0x26, 0x1e }, + .warning = .{ 0x8a, 0x5a, 0x00 }, + .info = .{ 0x2f, 0x5f, 0x8f }, + .hint = .{ 0x3f, 0x6f, 0x5f }, + .ansi = .{ + .{ 0xe6, 0xd8, 0xba }, .{ 0xb3, 0x26, 0x1e }, .{ 0x4c, 0x6a, 0x1f }, .{ 0x8a, 0x5a, 0x00 }, + .{ 0x2f, 0x5f, 0x8f }, .{ 0x7b, 0x4b, 0x9a }, .{ 0x2f, 0x6f, 0x6a }, .{ 0x5a, 0x4a, 0x36 }, + .{ 0x7a, 0x68, 0x4b }, .{ 0xc1, 0x39, 0x28 }, .{ 0x52, 0x75, 0x17 }, .{ 0x8f, 0x60, 0x00 }, + .{ 0x36, 0x6d, 0xa2 }, .{ 0x88, 0x54, 0xa7 }, .{ 0x29, 0x76, 0x71 }, .{ 0x23, 0x1a, 0x10 }, + }, +}; diff --git a/runtime/macos.zig b/runtime/macos.zig index 2778507f..0e47fb02 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[0].page; + const page = if (state) |*st| st.core.theme().bg 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]; } diff --git a/test/consumer/lib.zig b/test/consumer/lib.zig index 68134cc3..2832bdf1 100644 --- a/test/consumer/lib.zig +++ b/test/consumer/lib.zig @@ -88,7 +88,7 @@ test "a C and a Zig source are coloured, outlined and walked as pardes has them, try std.testing.expectEqual(null, pardes.parse("main.rs", "fn main() {}")); const orchard = pardes.theme("Orchard").?; - try std.testing.expectEqual(orchard, &pardes.themes[0]); + try std.testing.expectEqual(orchard, &pardes.themes[pardes.default_theme]); try std.testing.expectEqual([3]u8{ 0x0d, 0x14, 0x10 }, pardes.page(orchard)); try std.testing.expectEqual([3]u8{ 0xe5, 0xee, 0xe5 }, pardes.ink(orchard)); try std.testing.expectEqual([3]u8{ 0xc9, 0xa7, 0xed }, pardes.synInk(orchard, .keyword).?); diff --git a/test/process/tty_themes.zig b/test/process/tty_themes.zig index 1975c02b..8c49b77f 100644 --- a/test/process/tty_themes.zig +++ b/test/process/tty_themes.zig @@ -17,6 +17,10 @@ pub const cases = .{ fn theme(gpa: std.mem.Allocator, exe: [:0]const u8) !void { var t = try Tty.init(gpa, exe, "theme"); defer t.deinit(); + // From the ring's first, dark (the host's page: the tty's own cells), + // through pardes's own, those after a classic and acme's, into the first + // faithful ports (DESIGN.md E's groups). + try t.config("Theme dark"); try t.file("t.txt", "x"); try t.start(31, 100, &.{ "-n", "3" }); try t.wait(8000, "t.txt"); @@ -30,13 +34,23 @@ fn theme(gpa: std.mem.Allocator, exe: [:0]const u8) !void { try t.key("esc"); try t.settle(100); try t.stable(700, 10000); + try t.snap("dark"); + try t.style("dark"); + try t.press("middle", "@NextColor", 1); + try t.release("middle", "@NextColor", 1); + try t.stable(700, 10000); + try t.snap("light"); + try t.style("light"); + try t.press("middle", "@NextColor", 1); + try t.release("middle", "@NextColor", 1); + try t.stable(700, 10000); try t.snap("orchard"); try t.style("orchard"); try t.press("middle", "@NextColor", 1); try t.release("middle", "@NextColor", 1); try t.stable(700, 10000); - try t.snap("dusk"); - try t.style("dusk"); + try t.snap("orchard-black"); + try t.style("orchard-black"); try t.press("middle", "@NextColor", 1); try t.release("middle", "@NextColor", 1); try t.stable(700, 10000); @@ -45,6 +59,21 @@ fn theme(gpa: std.mem.Allocator, exe: [:0]const u8) !void { try t.press("middle", "@NextColor", 1); try t.release("middle", "@NextColor", 1); try t.stable(700, 10000); + try t.snap("mono"); + try t.style("mono"); + try t.press("middle", "@NextColor", 1); + try t.release("middle", "@NextColor", 1); + try t.stable(700, 10000); + try t.snap("okabe"); + try t.style("okabe"); + try t.press("middle", "@NextColor", 1); + try t.release("middle", "@NextColor", 1); + try t.stable(700, 10000); + try t.snap("sepia"); + try t.style("sepia"); + try t.press("middle", "@NextColor", 1); + try t.release("middle", "@NextColor", 1); + try t.stable(700, 10000); try t.snap("paper"); try t.style("paper"); try t.press("middle", "@NextColor", 1); @@ -55,8 +84,13 @@ fn theme(gpa: std.mem.Allocator, exe: [:0]const u8) !void { try t.press("middle", "@NextColor", 1); try t.release("middle", "@NextColor", 1); try t.stable(700, 10000); - try t.snap("atelier"); - try t.style("atelier"); + try t.snap("dusk"); + try t.style("dusk"); + try t.press("middle", "@NextColor", 1); + try t.release("middle", "@NextColor", 1); + try t.stable(700, 10000); + try t.snap("lapis"); + try t.style("lapis"); try t.press("middle", "@NextColor", 1); try t.release("middle", "@NextColor", 1); try t.stable(700, 10000); @@ -65,6 +99,16 @@ fn theme(gpa: std.mem.Allocator, exe: [:0]const u8) !void { try t.press("middle", "@NextColor", 1); try t.release("middle", "@NextColor", 1); try t.stable(700, 10000); + try t.snap("forge-black"); + try t.style("forge-black"); + try t.press("middle", "@NextColor", 1); + try t.release("middle", "@NextColor", 1); + try t.stable(700, 10000); + try t.snap("forge-soft"); + try t.style("forge-soft"); + try t.press("middle", "@NextColor", 1); + try t.release("middle", "@NextColor", 1); + try t.stable(700, 10000); try t.snap("lagoon"); try t.style("lagoon"); try t.press("middle", "@NextColor", 1); @@ -90,28 +134,13 @@ fn theme(gpa: std.mem.Allocator, exe: [:0]const u8) !void { try t.press("middle", "@NextColor", 1); try t.release("middle", "@NextColor", 1); try t.stable(700, 10000); - try t.snap("forge-black"); - try t.style("forge-black"); - try t.press("middle", "@NextColor", 1); - try t.release("middle", "@NextColor", 1); - try t.stable(700, 10000); - try t.snap("forge-soft"); - try t.style("forge-soft"); - try t.press("middle", "@NextColor", 1); - try t.release("middle", "@NextColor", 1); - try t.stable(700, 10000); - try t.snap("orchard-black"); - try t.style("orchard-black"); - try t.press("middle", "@NextColor", 1); - try t.release("middle", "@NextColor", 1); - try t.stable(700, 10000); try t.snap("acme"); try t.style("acme"); try t.press("middle", "@NextColor", 1); try t.release("middle", "@NextColor", 1); try t.stable(700, 10000); - try t.snap("lapis"); - try t.style("lapis"); + try t.snap("atelier"); + try t.style("atelier"); try t.press("middle", "@NextColor", 1); try t.release("middle", "@NextColor", 1); try t.stable(700, 10000); @@ -120,7 +149,6 @@ fn theme(gpa: std.mem.Allocator, exe: [:0]const u8) !void { try t.press("middle", "@NextColor", 1); try t.release("middle", "@NextColor", 1); try t.stable(700, 10000); - // After orchard_black: acme and lapis, then the first faithful ports. try t.snap("solarized-dark"); try t.style("solarized-dark"); try t.done(); @@ -138,10 +166,10 @@ fn theme(gpa: std.mem.Allocator, exe: [:0]const u8) !void { // running it and stopping. There is still no preview state, nothing to confirm // and nothing to cancel: the row you ran is the theme you have. // -// The whole ring is in the buffer, in sections: the fifteen native themes, -// acme and lapis, the faithful ports a family at a time, the legacy helix and -// dark, then everything exported from the vendored helix .toml and zed .json -// files, sorted. The colors below are +// The whole ring is in the buffer, in sections (DESIGN.md E): pardes's own, +// those after a classic, acme's, the faithful ports a family at a time, the +// captured helix, then everything imported from the vendored helix .toml and +// zed .json files, a family at a time and the lone ones last, sorted. The colors below are // read with snapstyle, so this proves the generated themes are real data and // not just names in a list. fn themesel(gpa: std.mem.Allocator, exe: [:0]const u8) !void { @@ -159,66 +187,77 @@ fn themesel(gpa: std.mem.Allocator, exe: [:0]const u8) !void { // fresh output buffer is where the walk's ring starts, so the first n goes // into the list and every one after it carries on down it. try t.key("space t t"); - try t.wait(10000, "Theme orchard"); + try t.wait(10000, "Theme dark"); try t.stable(700, 15000); try t.snap("list"); - // n selects row 1 whole and Tab runs it: `Theme orchard`, which is already the - // boot theme, so only the selection moves. That is the honest first step — an - // idempotent command has to be safe to run. + // n selects row 1 whole and Tab runs it: `Theme dark`, the ring's first; + // the theme changes under the cursor one row at a time, a section's + // heading and its blank line skipped (Output.isWalkRow). + try t.key("space j n"); + try t.key("tab"); + try t.stable(700, 15000); + try t.snap("step-dark"); + try t.style("step-dark"); + try t.key("space j n"); + try t.key("tab"); + try t.stable(700, 15000); + try t.snap("step-light"); + try t.style("step-light"); try t.key("space j n"); try t.key("tab"); try t.stable(700, 15000); try t.snap("step-orchard"); try t.style("step-orchard"); - // ...and now the theme really does change under the cursor, one row at a time try t.key("space j n"); try t.key("tab"); try t.stable(700, 15000); - try t.snap("step-dusk"); - try t.style("step-dusk"); - // Selection alone can skip rows without previewing or applying their themes. - // Four steps reach atelier, the Acme homage; Tab then applies it. - try t.key("space j n"); + try t.snap("step-orchard-black"); + try t.style("step-orchard-black"); try t.key("space j n"); + try t.key("tab"); + try t.stable(700, 15000); + try t.snap("step-ink"); + try t.style("step-ink"); try t.key("space j n"); + try t.key("tab"); + try t.stable(700, 15000); + try t.snap("step-mono"); + try t.style("step-mono"); try t.key("space j n"); try t.key("tab"); try t.stable(700, 15000); - try t.snap("step-atelier"); - try t.style("step-atelier"); + try t.snap("step-okabe"); + try t.style("step-okabe"); try t.key("space j n"); try t.key("tab"); try t.stable(700, 15000); - try t.snap("step-forge"); - try t.style("step-forge"); + try t.snap("step-sepia"); + try t.style("step-sepia"); try t.key("space j n"); try t.key("tab"); try t.stable(700, 15000); - try t.snap("step-lagoon"); - try t.style("step-lagoon"); + try t.snap("step-paper"); + try t.style("step-paper"); try t.key("space j n"); try t.key("tab"); try t.stable(700, 15000); - try t.snap("step-solarium"); - try t.style("step-solarium"); + try t.snap("step-daybreak"); + try t.style("step-daybreak"); try t.key("space j n"); try t.key("tab"); try t.stable(700, 15000); - try t.snap("step-spectrum"); - try t.style("step-spectrum"); + try t.snap("step-dusk"); + try t.style("step-dusk"); try t.key("space j n"); try t.key("tab"); try t.stable(700, 15000); - try t.snap("step-harvest"); - try t.style("step-harvest"); + try t.snap("step-lapis"); + try t.style("step-lapis"); try t.key("space j n"); try t.key("tab"); try t.stable(700, 15000); - try t.snap("step-clay"); - try t.style("step-clay"); - // The three native contrast variants precede acme and lapis, and then the first - // ported family's section. Its heading - // and blank separator are not stops in the n/N command walk. + try t.snap("step-forge"); + try t.style("step-forge"); try t.key("space j n"); try t.key("tab"); try t.stable(700, 15000); @@ -232,8 +271,28 @@ fn themesel(gpa: std.mem.Allocator, exe: [:0]const u8) !void { try t.key("space j n"); try t.key("tab"); try t.stable(700, 15000); - try t.snap("step-orchard-black"); - try t.style("step-orchard-black"); + try t.snap("step-lagoon"); + try t.style("step-lagoon"); + try t.key("space j n"); + try t.key("tab"); + try t.stable(700, 15000); + try t.snap("step-solarium"); + try t.style("step-solarium"); + try t.key("space j n"); + try t.key("tab"); + try t.stable(700, 15000); + try t.snap("step-spectrum"); + try t.style("step-spectrum"); + try t.key("space j n"); + try t.key("tab"); + try t.stable(700, 15000); + try t.snap("step-harvest"); + try t.style("step-harvest"); + try t.key("space j n"); + try t.key("tab"); + try t.stable(700, 15000); + try t.snap("step-clay"); + try t.style("step-clay"); try t.key("space j n"); try t.key("tab"); try t.stable(700, 15000); @@ -242,17 +301,13 @@ fn themesel(gpa: std.mem.Allocator, exe: [:0]const u8) !void { try t.key("space j n"); try t.key("tab"); try t.stable(700, 15000); - try t.snap("step-lapis"); - try t.style("step-lapis"); + try t.snap("step-atelier"); + try t.style("step-atelier"); try t.key("space j n"); try t.key("tab"); try t.stable(700, 15000); try t.snap("step-dark-plus"); try t.style("step-dark-plus"); - // across the Visual Studio Code section into Solarized: a section heading and - // its blank line are skipped like the first. (The imported half, past the - // legacy section, is sorted by name, so the ring is the same everywhere - // whatever order the directory read handed the files over in.) try t.key("space j n"); try t.key("tab"); try t.stable(700, 15000); diff --git a/tools/gen_themes.zig b/tools/gen_themes.zig index c369b744..62aafcf5 100644 --- a/tools/gen_themes.zig +++ b/tools/gen_themes.zig @@ -124,8 +124,12 @@ pub fn main(init: std.process.Init) !void { t.hit = f.hit; } // sorted, so the ring's tail is the same on every machine whatever order - // the directory happened to be read in - std.mem.sort(Theme, themes.items, {}, byName); + // the directory happened to be read in: a family at a time (a name's + // first word, two themes or more), the lone ones after every family, so + // the picker heads each family once (colors.zig `import_heads`) + var families: std.StringHashMapUnmanaged(u32) = .empty; + for (themes.items) |t| (try families.getOrPutValue(arena, family(t.name), 0)).value_ptr.* += 1; + std.mem.sort(Theme, themes.items, &families, byFamily); var dir = try std.Io.Dir.cwd().openDir(io, args[1], .{}); defer dir.close(io); @@ -150,7 +154,14 @@ fn write(io: std.Io, dir: std.Io.Dir, arena: std.mem.Allocator, stem: []const u8 try file.writeStreamingAll(io, text); } -fn byName(_: void, a: Theme, b: Theme) bool { +fn family(name: []const u8) []const u8 { + return name[0 .. std.mem.indexOfScalar(u8, name, '_') orelse name.len]; +} + +fn byFamily(families: *const std.StringHashMapUnmanaged(u32), a: Theme, b: Theme) bool { + const lone_a = families.get(family(a.name)).? < 2; + const lone_b = families.get(family(b.name)).? < 2; + if (lone_a != lone_b) return lone_b; return std.mem.order(u8, a.name, b.name) == .lt; } -- cgit v1.3