summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGabriel Schneider <[email protected]>2026-11-25 10:02:29 -0300
committerGabriel Schneider <[email protected]>2026-11-25 10:04:37 -0300
commit635829a5c17be4fd4bc30866e2b361c4ea2876e1 (patch)
tree239c786326408e44a8d1f1bba42be492e88beea0
parent98f5abfc10d9984a69940a6805d974018e5ea01e (diff)
downloadpardes-635829a5c17be4fd4bc30866e2b361c4ea2876e1.tar.gz
pardes-635829a5c17be4fd4bc30866e2b361c4ea2876e1.zip
colors, tools/gen_themes.zig: the err role falls back from a theme's diagnostic.error ink to its error ink, then to its red (UX D4/D14, E3, E5 fix 7), so an invalid pattern's reason in a prompt (Prompt.head's .err span, drawn in roles.err) and a message's error glyph and ghosts are red on the imported themes: THE CAUSE: the generator wrote no diagnostic_error for a helix theme (neonotte's "diagnostic.error" is an underline only) and colors.zig fell back to the body's ink, so UX2 measured the reason in fg #cdd6f4 (P2-L 13); THE FIX: gen_themes.zig's Theme has diagnostic_error, a helix theme's from diagnostic.error's fg, else error's fg, else its red (its [palette] red, else the terminal's), a zed theme's from its `error` status colour; colors.zig's ChromeTheme.diagnostic_error and Roles.err fall back to the palette's red (index 1) before the ink, for a theme that names none and has a palette (acme: #aa2222; dark and helix keep their ink: no palette); the err role is still pushed to 4.5:1 on the tags and the page (the floors test passes for every bundled theme); ChromeTheme.diagnostic_error also colours a +Errors row, a diagnostic's underline and the notice row's error glyph, which move to the same red on those themes (the themes pardes ships its own colours for, orchard first, are as they were); TEST FIRST: colors.zig "the err role falls back from diagnostic.error's ink to error's, then to the theme's red (UX E3): ..." (on the base: neonotte84's diagnostic_error null, colors.zig:1628); passes now, with every colors test
Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_016Y9MNBFhdevVu48bvL9kCE
-rw-r--r--core/colors.zig18
-rw-r--r--tools/gen_themes.zig7
2 files changed, 23 insertions, 2 deletions
diff --git a/core/colors.zig b/core/colors.zig
index b2069465..3325671c 100644
--- a/core/colors.zig
+++ b/core/colors.zig
@@ -586,7 +586,8 @@ pub const ChromeTheme = struct {
.search_bg = th.search_bg orelse th.sel_bg,
.search_fg = th.search_fg orelse th.sel_fg,
.tag_reading_bg = reading,
- .diagnostic_error = th.diagnostic_error orelse (th.fg orelse th.tag_fg),
+ // A theme's error ink, else its palette's red (UX E3).
+ .diagnostic_error = th.diagnostic_error orelse if (th.palette) |pal| pal[1] else (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),
.diagnostic_hint = th.diagnostic_hint orelse (th.fg orelse th.tag_fg),
@@ -692,7 +693,7 @@ pub const Roles = struct {
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.err = pushAway(th.diagnostic_error orelse if (th.palette) |pal| pal[1] else 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);
@@ -1621,3 +1622,16 @@ test "neonotte84's and acme's roles are the ones UX derived (DESIGN.md D4, tools
};
}
}
+
+test "the err role falls back from diagnostic.error's ink to error's, then to the theme's red (UX E3): neonotte84's (its diagnostic.error an underline only) is its red, acme's its palette's" {
+ const neonotte = &themes[themeIndex("neonotte84").?];
+ // neonotte.toml: "error" = { fg = "red" }, its palette's red #ff7ea2.
+ try std.testing.expectEqual([3]u8{ 0xff, 0x7e, 0xa2 }, neonotte.diagnostic_error.?);
+ for ([_][]const u8{ "neonotte84", "acme" }) |name| {
+ const chrome = ChromeTheme.fromTheme(&themes[themeIndex(name).?]);
+ const err = chrome.roles.err;
+ // Red: its red channel well over the others, on the page and the tags.
+ try std.testing.expect(err[0] > err[1] + 40 and err[0] > err[2] + 40);
+ }
+ try std.testing.expectEqual([3]u8{ 0xaa, 0x22, 0x22 }, ChromeTheme.fromTheme(&themes[themeIndex("acme").?]).diagnostic_error);
+}
diff --git a/tools/gen_themes.zig b/tools/gen_themes.zig
index 4f3946ad..b9a9adb0 100644
--- a/tools/gen_themes.zig
+++ b/tools/gen_themes.zig
@@ -72,6 +72,10 @@ const Theme = struct {
lineno: Rgb,
scroll_track: Rgb,
scroll_thumb: Rgb,
+ /// A message's error ink (colors.Roles.err): diagnostic.error's, else
+ /// error's, else the theme's red (UX E3: neonotte's diagnostic.error is
+ /// an underline only).
+ diagnostic_error: ?Rgb = null,
palette: ?[16]Rgb,
};
@@ -361,6 +365,7 @@ fn helixTheme(arena: std.mem.Allocator, stem: []const u8, h: Helix) !Theme {
// anything else in the theme's greys) for the thumb riding it
.scroll_track = h.get("ui.statusline", .bg) orelse page,
.scroll_thumb = sel,
+ .diagnostic_error = h.first(&.{ .{ "diagnostic.error", .fg }, .{ "error", .fg } }) orelse h.color("red"),
.palette = null,
};
}
@@ -575,6 +580,8 @@ fn readZed(arena: std.mem.Allocator, gpa: std.mem.Allocator, path: []const u8, t
.lineno = z.need("editor.line_number"),
.scroll_track = z.need("scrollbar.thumb.border"),
.scroll_thumb = z.need("scrollbar.thumb.background"),
+ // its status colour, else the palette's red (colors.zig)
+ .diagnostic_error = if (z.style.get("error") != null) z.need("error") else null,
.palette = pal,
});
}