summaryrefslogtreecommitdiff
path: root/core/colors.zig
diff options
context:
space:
mode:
Diffstat (limited to 'core/colors.zig')
-rw-r--r--core/colors.zig18
1 files changed, 16 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);
+}