From e960fb9a7d837c4e952a98890dc5ddf9c130d195 Mon Sep 17 00:00:00 2001 From: Gabriel Schneider Date: Wed, 25 Nov 2026 21:16:19 -0300 Subject: colors, theme_schema: the colour system's core (the themes programme's L1; DESIGN.md B2-B4, B6, G1', H): a theme says ten colours and the terminal's sixteen in names that say the role (`Theme`: page, text, tag, tag_text, accent, selection, keyword, string, number, comment, ansi, then B3's overrides and G1''s `mode`), and everything a surface draws is worked out from it once a theme change by one function, `Chrome.of` (R0-R16 by halves: `hold` moves an ink's lightness alone, `hued` steps a ground off another in a hue's tint), into one set, `Chrome`: the page's, the two tag grounds' (plain and focus, G1': the mode is a mark on the grip, `grip.mode`, never a ground) and the status row's inks, each held on its own ground (text, H's `word`, dim, rule, key, match, the four severities, a selection rebuilt there); the selection's faint and the three sweeps; hits and the solid current hit; added and deleted rows; lanes and churn; the grips (focus, ring, mode and its glyph, dirty, a column's grabbed and at rest); rules, rail, empty column; syntax, line numbers, names and the sixteen; read by `Pardes.chrome()`; H's tag: the plain tag lifted to a band 1.1:1 off the page (across it where the gamut ends) unless rules of 3:1 part panes (acme), the focused band a focus step off it and louder than it off the page, a mid-grey tag no ink reads on the page a step off, the full ink up to 7:1, command words toward the ground to 4.5:1; no surface reads `Chrome` yet: the L2 lines move them, so no frame moves here; THE SEAM: the theme files and every ThemeFile so far speak the old names (`LegacyTheme`, theme_schema.zig, the old struct verbatim): `fold` folds them as they are (`legacy_themes`) and renames them at comptime (`themes`, `Theme.fromLegacy`: one table of old and new names, the fields now always derived left out, a compile error for a field on either side without its line, so G6's rename stays one table to drop); `Pardes.theme()` hands the surfaces still reading a theme's own fields the old names' view (the ring's own, a ThemeFile's file itself, or a new-names file's view filled from its Chrome, `Theme.toLegacy`), and ChromeTheme, Roles and Grounds keep today's derivations on it, unchanged, beside the new set (`ChromeTheme.resolved`), until each surface moves; `custom_theme` keeps its type, so no dump or digest changes; a ThemeFile is read in the old names when it names `tag_bg` (the user's one_dark_zed_mod.zon, an older DumpThemes'), else in the new; DumpThemes writes the new; `initial_chrome` (comptime) goes: the chrome is resolved at the session's start (finishThemeInitialization, as before, into `theme_chrome`, the field `chrome()` reads it from), and each place that resolves one hands it to the body's cache (Core.bodyChrome), which made its own again at the first frame; B9's budget: the derivations convert to and from OKLab with no pow (`labOf`, `rgbOf`: `to_linear`, and the light where a byte's rounding turns; `toOklab`/`fromOklab` stay the old views' so none of their values moves), one ink's line toward its ground is walked once for its words, dim and rule, a status row that is the plain tag's takes its inks, and the name tint's search (today's, the old view's too) skips by luminance the candidates that cannot read before the bytes round them, and a source hue already tried, its answers the same over the whole ring (compared byte for byte); readings where DESIGN.md is silent or in tension, each in the report: `tag_name` for B3's `name` (the theme's own `name` holds its name), `@"error"`, `hold` wherever B4 says held (the prototype pushes tag, selection and ANSI inks toward white or black), the current hit the hue itself held (R8's words; the prototype held its rejected own ground), each tag ground's full ink its own (B1.3; hring holds one ink on both), a port's `column_grip` held on the page (B3; hring takes the number), the focus step tried lighter on a dark tag first, as the prototype does in effect (H's "away from the page" first would sink lagoon's and forge_soft's focused tags to #0b2722 and #020205), R3's status-bar swap left to the importer (L4: no import flag in a theme), B6's selection triple without key and match, no `filter[256]` (ghostty's, L2d) and no InactiveDim table (L2e); RUN (TEST FIRST): colors.zig "every theme in the ring meets every floor pardes owns ..." (every theme x the designer's checks, A8, with B4's per-ground inks, G1''s mark and H's words, band, loudest focus and column grip: the natives and dark held to the professional floors too; the original's text, syntax, comments, line numbers and sixteen asserted never moved): 261 of 285 pass, and the 24 on its list fail as it says: L3 5 (acme's ANSI 10 and 14; solarized_dark and _light, seoul256_light_254 and _255: a `hit`, `added`/`deleted` of their own), L4 6 (everforest_light, github_dark_dimmed, gruvbox_material_light_hard/_medium/_soft, hex_toxic), L5 1 (dark: its derived ANSI 8 at 3:1, under the pro 4.5), L7 8 (retired), and 4 no line fixes (dusk, lagoon, solarium, forge_soft: soft by design, their text under the pro 7:1: C1's ruling); "the whole ring resolves in 150 ms of CPU, no theme in over 0.5 ms (Debug)": 39 to 44 ms of CPU, the slowest theme 291 to 307 us (seoul256_dark_239, modus_vivendi), each the least of five (under a load of 8.7, before the speedups, it measured twice that: 871 us); "a theme file in the old names, a user's own or an older DumpThemes', and DumpThemes' now in the new names, load to the same Chrome" (one_dark_zed_mod.zon's shape copied into the test); the neonotte84 and acme goldens on Chrome, re-pinned where B4 moves them (text, dim, rule and key as D4's; the match the hits' amber on that ground alone, neonotte84 #e29e47, where D4's pushed #f1a271 over seven grounds at once, acme its number #a05200; the reading mark sky on the grip, #2b92bc and #1e8ab3, where D4 tinted the tag, #29271e, and acme's own #f3f0cc; the hit an amber ground 1.5:1 off the page, #4c301a and #ffc790; the current hit the hue itself, #e29e47 and #a05200, where D4 drew a 1.9:1 ground); the error ink red on the page and both tags; against C1's prototype over the ring's 285 (resolve.py, g1ring.py, hring.py; the R3 status-bar swap aside, L4's): the page's tokens (11,115 values) 84 % the same, 96 % within 2, 2 % over 6, each from a reading above (hold for push: ANSI 1 and 9 in 37 themes; the current hit in 46); with the prototype's own choices put back (an experiment), 17,081 of 20,520 the same and 59 over 6, at floors that a bisection and a 0.005 walk cross on different sides; H's tag grounds against hring.py the same or within 2 in 271 (plain) and 268 (focus) of 285, the others R3's status-bar swap (13, L4's) and monokai_pro_light_sun (its tag its page: lifted darker, hring lighter); G1's mark sky in 225, mint 50, violet 9, paper 1 (C1: 225, 50, 10); no frame moves: core-test 1115/1287 (172 skipped: +3, the ring, timing and loader tests; the two goldens rewritten in place), shell-test 1335/1338 (3 skipped: +3), pane-test 183/184 (1 skipped), behaviour-test 280/280 and --replay 20 seeds of 70 steps, 0 failures, process-test 0 of 147 failed (3 skipped, no golden moved), term-test 17/17, kitty-test 45/45, the gui unit-test 1938/1942 (4 skipped; its one failure the known BaselineHarnessMismatch); perfops against the installed tree (1e8787e0b2eb, its prefix built here) at 10 % a cell: PASS, 121 counts, the largest `open on small` +3.02 % (5,736,138 to 5,909,480 instructions: each cell boots a session, which now resolves its chrome at start where `initial_chrome` was comptime; +11.3 % before the body's cache took the start's chrome and create stopped resolving one of its own), the boots' setup +0.13 %, every operation within 0.01 %; the dump and the digest unchanged (`custom_theme` keeps its type, `theme_chrome` is local), so no fuzz or soak; load 2.0 to 10.2 Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_016Y9MNBFhdevVu48bvL9kCE --- core/Core.zig | 27 ++++++++++++++++----------- 1 file changed, 16 insertions(+), 11 deletions(-) (limited to 'core/Core.zig') diff --git a/core/Core.zig b/core/Core.zig index 8c946787..f9e32eec 100644 --- a/core/Core.zig +++ b/core/Core.zig @@ -47,7 +47,7 @@ const TAG_TEXT_INSET = pardes.TAG_TEXT_INSET; const TOPBAR_H = pardes.TOPBAR_H; const TagHit = pardes.TagHit; const Text = pardes.panes.Text; -const Theme = pardes.Theme; +const LegacyTheme = pardes.LegacyTheme; const builtins = pardes.builtins; const colors = pardes.colors; const column_weight_unit = layout.column_weight_unit; @@ -78,7 +78,6 @@ const sel_slot = pardes.sel_slot; const syntax = pardes.syntax; const tagline = pardes.tagline; const test_api = pardes.test_api; -const themes = pardes.themes; const turn = &pardes.turn; const Views = pardes.views; @@ -346,21 +345,21 @@ locations_config: locations.Config = .{}, locations_cache: locations.Cache = .{}, tty_filter_palette: pardes.Term.FilterPalette = .{}, font_request_taken: bool = false, -custom_theme: ?Theme = null, +custom_theme: ?LegacyTheme = null, /// The theme the window wears while a picker of them (or `:theme `) /// previews one, by index, and its chrome (colors.previewTheme); the /// session's own theme untouched under it. theme_preview: ?u16 = null, -preview_chrome: ChromeTheme = colors.initial_chrome, +preview_chrome: ChromeTheme = undefined, /// bodyChrome's: the theme it was worked out for, and it. -body_chrome: ?struct { theme: Theme, chrome: ChromeTheme } = null, +body_chrome: ?struct { theme: LegacyTheme, chrome: ChromeTheme } = null, theme_file_path: config.Settings.Text(limits.host_path_cap) = .{}, /// The ThemeFile last loaded whole: what /ctl and DumpConfig name, and /// what a failed ThemeFile goes back to (colors.revertThemeFile). theme_file_loaded: config.Settings.Text(limits.host_path_cap) = .{}, theme_file_generation: u32 = 0, theme_file_pane: Pane.Id = .at(0), -chrome: colors.ChromeTheme = colors.initial_chrome, +theme_chrome: colors.ChromeTheme = undefined, /// Every drawn frame's timings (FrameStats: the Debug box, PARDES_FRAMES): /// its runner's (`Options.frames`), which its frontend writes as it draws /// and reads input, never the core's memory; a core with no runner (a @@ -523,7 +522,7 @@ pub const replica = .{ // A frame, and the timings that make it. "surface", "facts", "frames", "own_frames", - "chrome", + "theme_chrome", "frame_arena", "scratch", "needs_frame", "echo", // Drained by every pump before its digest; a replica's queues @@ -2162,16 +2161,22 @@ fn sizes(p: *const Pardes, pane: *const Pane) bool { return pane.sized_by == p.live; } -pub fn theme(p: *const Pardes) *const Theme { - if (p.theme_preview) |i| return &themes[i]; +pub fn theme(p: *const Pardes) *const LegacyTheme { + if (p.theme_preview) |i| return &colors.legacy_themes[i]; if (p.custom_theme) |*custom| return custom; - return &themes[p.settings.theme]; + return &colors.legacy_themes[p.settings.theme]; } /// The colours of the chrome: the theme's, set as it changes. pub fn chromeTheme(p: *const Pardes) *const ChromeTheme { if (p.theme_preview != null) return &p.preview_chrome; - return &p.chrome; + return &p.theme_chrome; +} + +/// Every colour a surface draws (colors.Chrome), the theme's or the one a +/// picker previews: worked out as the theme changes, never a frame. +pub fn chrome(p: *const Pardes) *const colors.Chrome { + return &p.chromeTheme().resolved; } /// The theme's own chrome, not a fade's (`theme()`'s, worked out once -- cgit v1.3