diff options
| author | Gabriel Schneider <[email protected]> | 2026-11-25 04:51:32 -0300 |
|---|---|---|
| committer | Gabriel Schneider <[email protected]> | 2026-11-25 04:57:31 -0300 |
| commit | 01ce658c7b40997e24ce5045b0e07f7b9ae98e71 (patch) | |
| tree | 84ae35642444bb5005ca8fa9da169e7f95ef1d49 /core/colors.zig | |
| parent | 3c4b2c99b1a969abad0a530fa99b70b2cb564af3 (diff) | |
| download | pardes-01ce658c7b40997e24ce5045b0e07f7b9ae98e71.tar.gz pardes-01ce658c7b40997e24ce5045b0e07f7b9ae98e71.zip | |
colors, draw, Band: the walk UI's colour roles (UX DESIGN.md D4): text, dim, rule on each of a tag's four grounds (plain, focused, reading, reading focused) and on each one's cursor-row selection, key, match, hit, hit current, err/warn/question/hint, worked out once a theme with its chrome (ChromeTheme.roles, Roles.of; never a frame) and each held to its floor where it is drawn (text 4.5:1, dim 3.5 never under 3, rule 2:1, key and match 4.5:1 on every tag ground and selection, selection 1.4:1 off a dark tag and 1.25 off a light one with its text at 4.5, hit 1.25 and current 1.6 off the page with the body's ink at 4.5, a message's ink 4.5 on the tags and the page; where a theme's own colours leave no room, the most they allow: solarized's mid-grey tag, a tag whose text has no contrast to spare); the reading tint derived as D4 says (the theme's own where it stands 0.04 off the tag in OKLab, else the tag toward paper yellow by 0.04 and 0.02 lighter on a dark tag, darker on a light one, less or the other way where its text would drop under 7:1 or its own, further where the bytes cannot show the step): neonotte84's #262737 (0.029 off its tag, invisible) is #29271d now; and every painter of the new UI on them: the band's spines and step rules in the rule ink (they were the box's 11.5:1, the brightest thing in the band), `▶` and `•` in the key ink, a key bold in it, Help's chord (`SPC h t`, Row.chord) in it at the text's weight, a matched letter bold in the match ink on its row's own ground (it was the search ground, the selection's colour on neonotte84: on the cursor row the matches vanished), a dim row and a path's directory in the dim ink of their ground (the cursor row's selection's on it), never the faint attribute (fg 12.5:1 fell to 4.5 and a dimmed register value to 1.58); the head's dim spans in the dim ink, a key bold in the key ink, an error in the err role, the picker's act-row spines in the rule ink (TagState.Style.rule), its other sources' words, its `|` and the themes' hint dim, the levels', describe-key's and Rename's hints dim (they were at full label ink, louder than the content), the head's text in the text role (at rest the tag keeps its own ink: byte for byte); a walk's forward steps and a search word no place lights in the dim ink (they were the line numbers' ink, 1.57:1 on a reading tag); Messages.ink is the roles' (marks, end-of-line ghosts, progress); an LSP leaf in a pane no language server speaks for is dim and its doc step says `needs a language server` (POLISH 3; SPEC §4.2); UX's derived values reproduced (tools/roles.py: neonotte84's text, dim #70768f, rule #4c5063, key, match #f1a271, reading, hit #36282a, current #523831 within 2 a channel; acme's dim, rule, reading, hit, current; acme's key #555583 and match #8f4800 a step darker than UX's #5c5c8d and #974d00, which hold on its tag and #9eeeee: a reading pane's band's selection is pushed off #f3f0cc, 1.12:1, and they read on it too); TEST FIRST: Band.zig "a band is drawn in the theme's roles" (fails on the base painter at its first spine: the box's ink), draw.zig "a tag out of rest draws its keys bold in the key ink and its hint in the dim ink, never faint", colors.zig "every theme's walk UI roles meet their floors" (every bundled theme, dark and light, every floor; 497 floors missed by the first derivation, each class fixed by the rule above) and "neonotte84's and acme's roles are the ones UX derived"; Trail.zig's §6.7 session test now wants the forward step in the dim ink; core-test 1066/1236 (170 skipped)
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_016Y9MNBFhdevVu48bvL9kCE
Diffstat (limited to 'core/colors.zig')
| -rw-r--r-- | core/colors.zig | 332 |
1 files changed, 329 insertions, 3 deletions
diff --git a/core/colors.zig b/core/colors.zig index ef2d5aae..d4abf2b5 100644 --- a/core/colors.zig +++ b/core/colors.zig @@ -287,8 +287,8 @@ pub const Theme = struct { lineno_active: ?[3]u8 = null, /// A tag's selection, where it differs from the body's (acme's #9eeeee). tag_sel_bg: ?[3]u8 = null, - /// The tag of a reading pane, one a jump steps (Trail.zig): unset, the - /// page tinted toward the search's ground, so it reads as the body's. + /// The tag of a reading pane, one a jump steps (Trail.zig): unset, or + /// too near the tag to see, the tag toward paper yellow (readingOf). tag_reading_bg: ?[3]u8 = null, /// Each pointer button's sweep, select, exec and look (Mouse.Button /// order), and the ink over it. Unset, tints of `sel_bg` in `sel_fg`. @@ -558,6 +558,7 @@ pub const ChromeTheme = struct { lineno: [3]u8, scroll_track: [3]u8, scroll_thumb: [3]u8, + roles: Roles, pub fn fromTheme(th: *const Theme) ChromeTheme { // The initial chrome is resolved at compile time: contrast takes pow. @@ -570,6 +571,7 @@ pub const ChromeTheme = struct { const name_fg = th.tag_name_fg orelse (derivedNameTint(th, th.tag_fg, th.tag_bg) orelse th.tag_fg); const active_name_fg = th.tag_active_name_fg orelse (th.tag_name_fg orelse (derivedNameTint(th, active_fg, active_bg) orelse active_fg)); + const reading = readingOf(th); return .{ .tag_bg = th.tag_bg, .tag_fg = th.tag_fg, @@ -583,7 +585,7 @@ pub const ChromeTheme = struct { .empty_col = th.empty_col orelse separatorOf(th), .search_bg = th.search_bg orelse th.sel_bg, .search_fg = th.search_fg orelse th.sel_fg, - .tag_reading_bg = th.tag_reading_bg orelse mixOklab(th.bg orelse th.tag_bg, th.search_bg orelse th.sel_bg, 0.4), + .tag_reading_bg = reading, .diagnostic_error = th.diagnostic_error orelse (th.fg orelse th.tag_fg), .diagnostic_warning = th.diagnostic_warning orelse (th.fg orelse th.tag_fg), .diagnostic_info = th.diagnostic_info orelse (th.fg orelse th.tag_fg), @@ -595,10 +597,248 @@ pub const ChromeTheme = struct { .lineno = th.lineno, .scroll_track = th.scroll_track, .scroll_thumb = th.scroll_thumb, + .roles = .of(th, th.tag_bg, active_bg, reading), }; } }; +/// A tag's ground in the walk UI (UX DESIGN.md D4): the plain tag's, the +/// focused one's tint, a reading pane's tint, focused or not (its ink is +/// the focused tag's while it has the keyboard). +pub const TagGround = enum { plain, focused, reading, reading_focused }; + +/// The inks drawn on one ground: labels and rows (`text`, 4.5:1 at least), +/// hints, meta and forward steps (`dim`, 3.5:1, never under 3), and the +/// spines and the rules between steps (`rule`, 2:1). +pub const Inks = struct { ground: [3]u8, text: [3]u8, dim: [3]u8, rule: [3]u8 }; + +/// The walk UI's colour roles (UX DESIGN.md D4), worked out from a theme +/// once, with its chrome (never a frame), each held to its floor on every +/// ground it is drawn on: a tag's four (`tag`) and a band's cursor row on +/// each of them (`selected`, its ground that tag's selection). +pub const Roles = struct { + tag: [4]Inks, + selected: [4]Inks, + /// Key cells, a level's or a row's key letters, `▶`, `•`, a target's + /// keys: 4.5:1 on every tag ground and on the selection. + key: [3]u8, + /// The letters a query matched: an ink, never a ground, 4.5:1 on every + /// tag ground and on the selection. + match: [3]u8, + /// The body's places and a preview's landing line, and the current + /// one (its matched span): grounds off the page, its ink on them 4.5:1. + hit: [3]u8, + hit_current: [3]u8, + /// A message's ink by its kind (Messages.ink): 4.5:1 on the tags and + /// the page. + err: [3]u8, + warn: [3]u8, + question: [3]u8, + hint: [3]u8, + + pub const text_floor: f32 = 4.5; + pub const dim_floor: f32 = 3; + pub const rule_floor: f32 = 1.8; + pub const rule_ceiling: f32 = 2.5; + pub const ink_floor: f32 = 4.5; + pub const hit_floor: f32 = 1.25; + pub const hit_current_floor: f32 = 1.6; + pub const reading_distance: f32 = 0.04; + + pub fn on(r: *const Roles, ground: TagGround) *const Inks { + return &r.tag[@backingInt(ground)]; + } + + pub fn selectedOn(r: *const Roles, ground: TagGround) *const Inks { + return &r.selected[@backingInt(ground)]; + } + + /// The selection's floor off a tag's ground: 1.4:1 on a dark tag, 1.25 + /// on a light one. + pub fn selectionFloor(ground: [3]u8) f32 { + return if (relativeLuminance(ground) < 0.18) 1.4 else 1.25; + } + + fn of(th: *const Theme, plain: [3]u8, focused: [3]u8, reading: [3]u8) Roles { + const grounds = [4][3]u8{ plain, focused, reading, reading }; + const plain_ink = th.tag_fg; + const focused_ink = th.tag_active_fg orelse th.tag_fg; + const texts = [4][3]u8{ plain_ink, focused_ink, plain_ink, focused_ink }; + var r: Roles = undefined; + for (&r.tag, &r.selected, grounds, texts) |*inks, *selected, ground, ink| { + inks.* = inksOn(ground, ink); + selected.* = inksOn(selectionOf(th.tag_sel_bg orelse th.sel_bg, ground, inks.text), inks.text); + } + const tag_grounds = [_][3]u8{ plain, focused, reading, r.selected[0].ground, r.selected[1].ground, r.selected[2].ground, r.selected[3].ground }; + r.key = pushAway(th.box, &tag_grounds, ink_floor); + r.match = pushAway(matchHue(th), &tag_grounds, ink_floor); + const page = th.bg orelse null_page; + const body_ink = th.fg orelse th.tag_fg; + const dark = relativeLuminance(page) < 0.18; + // The theme's search ground where it stands off the page and the + // body reads on it; else the page a little way toward its hue (the + // warm accent's without one). The current one as far past the hit + // as 32 % is past 18 % (38 past 22 on a light page). + const hue = th.search_bg orelse th.num; + const own = th.search_bg != null and contrast(hue, page) >= hit_floor and contrast(body_ink, hue) >= ink_floor; + const at: f32 = if (own) 1 else if (dark) 0.18 else 0.22; + r.hit = if (own) hue else hitOf(page, hue, body_ink, at, hit_floor); + const past: f32 = if (dark) 0.32 / 0.18 else 0.38 / 0.22; + r.hit_current = hitOf(page, hue, body_ink, at * past, hit_current_floor); + // Never fainter than the hit, where the ink holds both short. + if (contrast(r.hit_current, page) < contrast(r.hit, page)) r.hit_current = r.hit; + const message_grounds = [_][3]u8{ plain, focused, reading, page }; + const ink = th.fg orelse th.tag_fg; + r.err = pushAway(th.diagnostic_error orelse ink, &message_grounds, ink_floor); + r.warn = pushAway(th.diagnostic_warning orelse ink, &message_grounds, ink_floor); + r.question = pushAway(th.diagnostic_info orelse ink, &message_grounds, ink_floor); + r.hint = pushAway(th.diagnostic_hint orelse ink, &message_grounds, ink_floor); + return r; + } +}; + +/// A tag's text, dim and rule inks on `ground`, from its ink (pushed to the +/// text floor where it has less). +fn inksOn(ground: [3]u8, ink: [3]u8) Inks { + const text = pushAway(ink, &.{ground}, Roles.text_floor); + return .{ .ground = ground, .text = text, .dim = toward(text, ground, 3.5), .rule = toward(text, ground, 2) }; +} + +/// `ink` mixed toward `ground` (OKLab) by hundredths as far as it still +/// reads at `floor` on it. +fn toward(ink: [3]u8, ground: [3]u8, floor: f32) [3]u8 { + const a = toOklab(ink); + const b = toOklab(ground); + var best = ink; + var step: f32 = 1; + while (step <= 100) : (step += 1) { + const t = step / 100; + const c = fromOklab(.{ a[0] + (b[0] - a[0]) * t, a[1] + (b[1] - a[1]) * t, a[2] + (b[2] - a[2]) * t }); + if (contrast(c, ground) < floor) break; + best = c; + } + return best; +} + +/// `ink` pushed by fiftieths toward white or black, whichever reads better +/// on all its grounds, until it reads at `floor` on every one; where no ink +/// does (solarized's mid-grey tag), that end, the most any ink reaches. +fn pushAway(ink: [3]u8, grounds: []const [3]u8, floor: f32) [3]u8 { + const white: [3]u8 = @splat(255); + const black: [3]u8 = @splat(0); + const end = if (leastContrast(white, grounds) >= leastContrast(black, grounds)) white else black; + const a = toOklab(ink); + const b = toOklab(end); + var step: f32 = 0; + while (step <= 50) : (step += 1) { + const t = step / 50; + const c = fromOklab(.{ a[0] + (b[0] - a[0]) * t, a[1] + (b[1] - a[1]) * t, a[2] + (b[2] - a[2]) * t }); + if (leastContrast(c, grounds) >= floor) return c; + } + return end; +} + +fn leastContrast(ink: [3]u8, grounds: []const [3]u8) f32 { + var least: f32 = 21; + for (grounds) |g| least = @min(least, contrast(ink, g)); + return least; +} + +/// The match's hue: the search's ink where it is a hue of its own (a port's +/// is often the page's or the tag's, set for the search's ground), else the +/// theme's warm accent. +fn matchHue(th: *const Theme) [3]u8 { + const own = th.search_fg orelse return th.num; + const lab = toOklab(own); + return if (@sqrt(lab[1] * lab[1] + lab[2] * lab[2]) >= name_tint_chroma) own else th.num; +} + +/// The selection a band's cursor row is drawn on over `ground`: the +/// theme's where it stands off it, else moved by hundredths toward the +/// text, then away from it, to the first that does with the text still at +/// 4.5:1 on it; where none does (a tag whose text has no contrast to +/// spare), the one furthest off it. +fn selectionOf(own: [3]u8, ground: [3]u8, text: [3]u8) [3]u8 { + var best = own; + var best_off: f32 = 0; + const away: [3]u8 = if (relativeLuminance(text) > relativeLuminance(own)) @splat(0) else @splat(255); + for ([2][3]u8{ text, away }) |end| { + var step: f32 = 0; + while (step <= 100) : (step += 1) { + const c = mixOklab(own, end, step / 100); + if (contrast(text, c) < Roles.text_floor) break; + const off = contrast(c, ground) / Roles.selectionFloor(ground); + if (off >= 1) return c; + if (off > best_off) { + best = c; + best_off = off; + } + } + } + return best; +} + +/// A ground off `page` toward `hue` at `t` (past 1, beyond the hue, as far +/// as the gamut goes), held where the body's `ink` reads on it at 4.5:1 +/// (or its own on the page, where that is less); moved on toward the ink +/// until it stands off the page at `floor`, as far as the ink allows. +fn hitOf(page: [3]u8, hue: [3]u8, ink: [3]u8, t: f32, floor: f32) [3]u8 { + const a = toOklab(page); + const b = toOklab(hue); + const ink_floor = @min(Roles.ink_floor, contrast(ink, page)); + var k = t; + var c = fromOklab(.{ a[0] + (b[0] - a[0]) * k, a[1] + (b[1] - a[1]) * k, a[2] + (b[2] - a[2]) * k }); + while (contrast(ink, c) < ink_floor and k > 0) { + k -= t / 50; + c = fromOklab(.{ a[0] + (b[0] - a[0]) * k, a[1] + (b[1] - a[1]) * k, a[2] + (b[2] - a[2]) * k }); + } + const start = c; + var step: f32 = 1; + while (contrast(c, page) < floor and step <= 50) : (step += 1) { + const next = mixOklab(start, ink, step / 100); + if (contrast(ink, next) < ink_floor) break; + c = next; + } + return c; +} + +/// A reading pane's tag (UX DESIGN.md D4): the theme's own where it stands +/// off the tag, else the tag shifted toward paper yellow by 0.04 in OKLab +/// and lighter by half that on a dark tag (darker on a light), so it reads +/// as a page; then less light, or darker, where its text would lose +/// contrast, and further where the bytes cannot show so small a step (a +/// near-black tag). +fn readingOf(th: *const Theme) [3]u8 { + if (th.tag_reading_bg) |own| if (oklabDistance(toOklab(own), toOklab(th.tag_bg)) >= Roles.reading_distance) return own; + const tag = toOklab(th.tag_bg); + const paper = toOklab(.{ 0xdc, 0xc8, 0x78 }); + const da = paper[1] - tag[1]; + const db = paper[2] - tag[2]; + const n = @max(@sqrt(da * da + db * db), 1e-6); + const sign: f32 = if (relativeLuminance(th.tag_bg) < 0.18) 1 else -1; + // Away from the text's lightness, where the first lean costs it. + const away: f32 = if (relativeLuminance(th.tag_fg) > relativeLuminance(th.tag_bg)) -1 else 1; + const inks = [2][3]u8{ th.tag_fg, th.tag_active_fg orelse th.tag_fg }; + var best = th.tag_bg; + var best_text: f32 = -21; + var reach = Roles.reading_distance; + while (reach <= 0.2) : (reach *= 1.25) { + for ([_]f32{ sign * 0.5, 0, away * 0.5, away, away * 1.5 }) |lean| { + const c = fromOklab(.{ tag[0] + lean * reach, tag[1] + da / n * reach, tag[2] + db / n * reach }); + if (oklabDistance(toOklab(c), tag) < Roles.reading_distance) continue; + // Each ink by its own floor: 7:1, or what it has on the tag. + var text: f32 = 21; + for (inks) |ink| text = @min(text, contrast(ink, c) - (@min(7, contrast(ink, th.tag_bg)) - 0.01)); + if (text >= 0) return c; + if (text > best_text) { + best = c; + best_text = text; + } + } + } + return best; +} + pub const initial_chrome = ChromeTheme.fromTheme(&themes[0]); fn nextThemeFileGeneration(p: *Pardes) u32 { @@ -1281,3 +1521,89 @@ test "every theme tints its names off the tag's ink, and they read on both groun } } } + +test "every theme's walk UI roles meet their floors on every ground they are drawn on, dark and light" { + // Where a theme's own colours leave no room for a floor, the most it + // allows: an ink's on a mid-grey tag (solarized's) is the better of + // white and black there; a ground's is where the ink it carries would + // drop under its floor. + const white: [3]u8 = @splat(255); + const black: [3]u8 = @splat(0); + const Reach = struct { + fn of(grounds: []const [3]u8) f32 { + return @max(leastContrast(white, grounds), leastContrast(black, grounds)); + } + }; + const a = std.testing.allocator; + const Check = struct { what: []const u8, got: f32, floor: f32 }; + var checks: std.ArrayList(Check) = .empty; + defer checks.deinit(a); + var failed: usize = 0; + for (&themes) |*th| { + checks.clearRetainingCapacity(); + const chrome = ChromeTheme.fromTheme(th); + const r = &chrome.roles; + const page = th.bg orelse null_page; + const body_ink = th.fg orelse th.tag_fg; + const tags = [_][3]u8{ r.tag[0].ground, r.tag[1].ground, r.tag[2].ground, r.selected[0].ground, r.selected[1].ground, r.selected[2].ground, r.selected[3].ground }; + const messages = [_][3]u8{ r.tag[0].ground, r.tag[1].ground, r.tag[2].ground, page }; + for (r.tag ++ r.selected) |inks| { + const text = contrast(inks.text, inks.ground); + try checks.append(a, .{ .what = "text", .got = text, .floor = @min(Roles.text_floor, Reach.of(&.{inks.ground})) }); + try checks.append(a, .{ .what = "dim", .got = contrast(inks.dim, inks.ground), .floor = @min(Roles.dim_floor, text) }); + try checks.append(a, .{ .what = "dim under text", .got = text - contrast(inks.dim, inks.ground), .floor = 0 }); + } + try checks.append(a, .{ .what = "key", .got = leastContrast(r.key, &tags), .floor = @min(Roles.ink_floor, Reach.of(&tags)) }); + try checks.append(a, .{ .what = "match", .got = leastContrast(r.match, &tags), .floor = @min(Roles.ink_floor, Reach.of(&tags)) }); + for (r.tag) |inks| { + try checks.append(a, .{ .what = "rule", .got = contrast(inks.rule, inks.ground), .floor = Roles.rule_floor }); + try checks.append(a, .{ .what = "rule ceiling", .got = Roles.rule_ceiling - contrast(inks.rule, inks.ground), .floor = 0 }); + } + for ([_][3]u8{ r.err, r.warn, r.question, r.hint }) |ink| + try checks.append(a, .{ .what = "message", .got = leastContrast(ink, &messages), .floor = @min(Roles.ink_floor, Reach.of(&messages)) }); + // A selection off its tag by 1.4:1 (1.25 light) with the text at + // 4.5:1 on it, where the text has that much over the tag. + for (r.tag, r.selected) |inks, selected| { + const floor = Roles.selectionFloor(inks.ground); + const room = contrast(inks.text, inks.ground) >= floor * Roles.text_floor * 1.03; + try checks.append(a, .{ .what = "selection", .got = contrast(selected.ground, inks.ground), .floor = if (room) floor else 0 }); + } + try checks.append(a, .{ .what = "reading", .got = oklabDistance(toOklab(chrome.tag_reading_bg), toOklab(th.tag_bg)), .floor = Roles.reading_distance }); + for ([_][3]u8{ th.tag_fg, th.tag_active_fg orelse th.tag_fg }) |ink| + try checks.append(a, .{ .what = "text on reading", .got = contrast(ink, chrome.tag_reading_bg), .floor = @min(7, contrast(ink, th.tag_bg)) - 0.02 }); + const ink_floor = @min(Roles.ink_floor, contrast(body_ink, page)); + for ([_][3]u8{ r.hit, r.hit_current }, [_]f32{ Roles.hit_floor, Roles.hit_current_floor }) |ground, floor| { + const on = contrast(body_ink, ground); + try checks.append(a, .{ .what = "hit", .got = contrast(ground, page), .floor = if (on < ink_floor + 0.3) 0 else floor }); + try checks.append(a, .{ .what = "ink on hit", .got = on, .floor = ink_floor - 0.01 }); + } + try checks.append(a, .{ .what = "current over hit", .got = contrast(r.hit_current, page) - contrast(r.hit, page), .floor = 0 }); + for (checks.items) |c| if (c.got < c.floor - 0.005) { + failed += 1; + std.debug.print("{s}: {s} {d:.2} under {d:.2}\n", .{ th.name, c.what, c.got, c.floor }); + }; + } + try std.testing.expectEqual(0, failed); +} + +test "neonotte84's and acme's roles are the ones UX derived (DESIGN.md D4, tools/roles.py)" { + const Want = struct { name: []const u8, text: ?[3]u8, dim: [3]u8, rule: [3]u8, key: [3]u8, match: [3]u8, reading: [3]u8, hit: [3]u8, hit_current: [3]u8 }; + const wants = [_]Want{ + .{ .name = "neonotte84", .text = .{ 0xb5, 0xbf, 0xe3 }, .dim = .{ 0x70, 0x76, 0x8f }, .rule = .{ 0x4c, 0x50, 0x63 }, .key = .{ 0xf8, 0xde, 0xd9 }, .match = .{ 0xf1, 0xa2, 0x71 }, .reading = .{ 0x29, 0x27, 0x1e }, .hit = .{ 0x36, 0x28, 0x2a }, .hit_current = .{ 0x52, 0x38, 0x31 } }, + // acme's key and match a little darker than UX's #5c5c8d and + // #974d00 (which hold on its tag and its #9eeeee): a reading pane's + // band's selection is pushed off the reading ground (#9eeeee is + // 1.12:1 off #f3f0cc), and they read on that one too. + .{ .name = "acme", .text = null, .dim = .{ 0x7a, 0x86, 0x86 }, .rule = .{ 0xa8, 0xb7, 0xb7 }, .key = .{ 0x55, 0x55, 0x83 }, .match = .{ 0x8f, 0x48, 0x00 }, .reading = .{ 0xf3, 0xf0, 0xcc }, .hit = .{ 0xec, 0xd8, 0xbb }, .hit_current = .{ 0xdd, 0xbc, 0x99 } }, + }; + for (wants) |want| { + const chrome = ChromeTheme.fromTheme(&themes[themeIndex(want.name).?]); + const plain = chrome.roles.on(.plain); + const got = [_][3]u8{ plain.text, plain.dim, plain.rule, chrome.roles.key, chrome.roles.match, chrome.tag_reading_bg, chrome.roles.hit, chrome.roles.hit_current }; + const expected = [_][3]u8{ want.text orelse plain.text, want.dim, want.rule, want.key, want.match, want.reading, want.hit, want.hit_current }; + for (got, expected, 0..) |g, e, i| for (g, e) |x, y| if (@abs(@as(i16, x) - y) > 2) { + std.debug.print("{s} role {d}: {x} for {x}\n", .{ want.name, i, g, e }); + return error.TestUnexpectedResult; + }; + } +} |
