summaryrefslogtreecommitdiff
path: root/core
diff options
context:
space:
mode:
Diffstat (limited to 'core')
-rw-r--r--core/Core.zig14
-rw-r--r--core/File.zig21
-rw-r--r--core/Messages.zig12
-rw-r--r--core/Output.zig25
-rw-r--r--core/Pick.zig30
-rw-r--r--core/Places.zig59
-rw-r--r--core/Prompt.zig26
-rw-r--r--core/Query.zig62
-rw-r--r--core/Tables.zig8
-rw-r--r--core/body_layer.zig220
-rw-r--r--core/colors.zig133
-rw-r--r--core/draw.zig9
-rw-r--r--core/look.zig3
-rw-r--r--core/root.zig4
14 files changed, 330 insertions, 296 deletions
diff --git a/core/Core.zig b/core/Core.zig
index cbcf4324..e458dab4 100644
--- a/core/Core.zig
+++ b/core/Core.zig
@@ -351,8 +351,6 @@ custom_theme: ?LegacyTheme = null,
/// session's own theme untouched under it.
theme_preview: ?u16 = null,
preview_chrome: ChromeTheme = undefined,
-/// bodyChrome's: the theme it was worked out for, and it.
-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).
@@ -547,7 +545,7 @@ pub const replica = .{
"opts", "dump_out", "dump_export",
"tape",
},
- .derived = .{ "shell_rows", "diff_output", "locations_cache", "retired_panes", "tty_filter_palette", "body_chrome", "theme_preview", "preview_chrome" },
+ .derived = .{ "shell_rows", "diff_output", "locations_cache", "retired_panes", "tty_filter_palette", "theme_preview", "preview_chrome" },
// The host's handles, the state file every session of the user
// shares (and Recent read from it), this session's closed panes, and
// the files of a host with no file system of its own. (The 9P
@@ -2175,16 +2173,6 @@ 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
-/// per theme: its contrast searches take pow calls, too many for a
-/// grapheme or a row).
-pub fn bodyChrome(p: *Pardes) *const ChromeTheme {
- const th = p.theme();
- if (p.body_chrome) |*cached| if (std.meta.eql(cached.theme, th.*)) return &cached.chrome;
- p.body_chrome = .{ .theme = th.*, .chrome = ChromeTheme.fromTheme(th) };
- return &p.body_chrome.?.chrome;
-}
-
/// When the core next needs a frame, on the `stepped_ns` timeline: a
/// frame from now while work goes on (places to find, a picture
/// decoding, a PDF page on a lane), the end of the wait while something
diff --git a/core/File.zig b/core/File.zig
index 332499b4..e246285c 100644
--- a/core/File.zig
+++ b/core/File.zig
@@ -2917,7 +2917,8 @@ pub const Layers = struct {
pub const SynStyle = struct { fg: [3]u8, bold: bool };
pub fn synStyle(p: *Pardes, sy: syntax.Syn) ?SynStyle {
- return .{ .fg = Colors.synInk(p.theme(), sy) orelse return null, .bold = false };
+ if (sy == .none) return null;
+ return .{ .fg = p.chrome().syntax[@intFromEnum(sy)], .bold = false };
}
/// syntax colors: recolor each content cell from its tree-sitter style byte;
@@ -2940,8 +2941,8 @@ pub fn recolorSyntax(p: *Pardes, s: *Surface, pane: *Pane, f: *State, r: pardes.
const tz_recolor = tracy.zone(@src(), "synRecolor");
defer tz_recolor.end();
// A row whose first byte names a hue (syntax.ground_add, _del): its
- // grounds, the theme's, worked out once a frame and only for one.
- var grounds: ?Colors.Grounds = null;
+ // grounds, the chrome's (R10).
+ const chrome = p.chrome();
const ink = ansi.inkOf(p);
var filtered_storage: pardes.Term.Filter = undefined;
const filtered: ?*pardes.Term.Filter = if (pane.tty_filter and spans.len > 0) blk: {
@@ -2980,14 +2981,11 @@ pub fn recolorSyntax(p: *Pardes, s: *Surface, pane: *Pane, f: *State, r: pardes.
const row_index: usize = @intCast(@max(0, pane.wrapAt(p.settings.tab, vr).line));
const metadata: ?locations.Row = if (row_index < f.location_rows.len) f.location_rows[row_index] else null;
const decoration = Output.decorateRow(f.output, line, metadata);
- const chrome: ?*const pardes.ChromeTheme = if (decoration.plain()) null else p.bodyChrome();
+ const decorated = !decoration.plain();
// The row's first byte: its hue and its ground, on every wrapped
// row of it (syntax.ground_add).
const lead: u8 = if (base >= highlight_start and base - highlight_start < highlights.len) highlights[base - highlight_start] else 0;
- const tint: ?Colors.Grounds.Ground = if (lead & (syntax.ground_add | syntax.ground_del) == 0) null else (grounds orelse ground: {
- grounds = .of(p.theme());
- break :ground grounds.?;
- }).forStyle(lead);
+ const tint: ?*const Colors.Chrome.Diff = if (lead & syntax.ground_add != 0) &chrome.add else if (lead & syntax.ground_del != 0) &chrome.del else null;
// 2, the patch: the row's ground.
if (tint) |t| if (prefix_width < tw) {
const ground: ?[3]u8 = if (lead & syntax.ground_emph != 0) t.row else if (lead & syntax.ground_line != 0) t.line else null;
@@ -3004,7 +3002,7 @@ pub fn recolorSyntax(p: *Pardes, s: *Surface, pane: *Pane, f: *State, r: pardes.
var c: usize = 0;
const pad: usize = if (vr < pane.wrap_n) pane.wrap_pad[vr] else 0;
for (0..@min(pad, tw -| prefix_width)) |col| {
- s.at(tx + @as(u16, @intCast(prefix_width + col)), body_y + vr).style.fg = .{ .rgb = p.bodyChrome().diagnostic_info };
+ s.at(tx + @as(u16, @intCast(prefix_width + col)), body_y + vr).style.fg = .{ .rgb = chrome.page.dim };
}
var screen_c: usize = pad;
var table_buf: [Tables.max_pads]Tables.Pad = undefined;
@@ -3052,7 +3050,7 @@ pub fn recolorSyntax(p: *Pardes, s: *Surface, pane: *Pane, f: *State, r: pardes.
}
// Results keep their exact live text. Only the location,
// matched source range and diagnostic label gain emphasis.
- if (if (chrome) |ch| decoration.styleAt(ch, hs + c) else null) |style| {
+ if (if (decorated) decoration.styleAt(chrome, hs + c) else null) |style| {
var fill: usize = 0;
while (fill < cells and prefix_width + screen_c + fill < tw) : (fill += 1) {
const cell = s.at(tx + @as(u16, @intCast(prefix_width + screen_c + fill)), body_y + vr);
@@ -3104,6 +3102,7 @@ pub fn paintWordSelection(
word_lo: i32,
word_hi: i32,
bg: [3]u8,
+ fg: ?[3]u8,
) void {
const tx = r.x + config.GUTTER;
const tw = r.w - config.GUTTER;
@@ -3122,7 +3121,7 @@ pub fn paintWordSelection(
const c1 = @as(i32, prefix_width) + here.pad + displayEndOffset(p.settings.tab, pane, row, here.at, hi - 1);
const col = @max(@as(i32, prefix_width), c0);
const end = @min(c1 + 1, @as(i32, tw));
- if (col < end) s.tint(tx + @as(u16, @intCast(col)), body_y + @as(u16, @intCast(vr)), @intCast(end - col), bg, null);
+ if (col < end) s.tint(tx + @as(u16, @intCast(col)), body_y + @as(u16, @intCast(vr)), @intCast(end - col), bg, fg);
}
}
diff --git a/core/Messages.zig b/core/Messages.zig
index e05961b5..eca5ec9f 100644
--- a/core/Messages.zig
+++ b/core/Messages.zig
@@ -435,6 +435,18 @@ pub fn ink(chrome: *const pardes.colors.ChromeTheme, kind: Kind) [3]u8 {
};
}
+/// A message's ink on a ground of the chrome (R9): an error's, a warning's
+/// and a question's their severity's held there (a question info's), an
+/// echo, a notice and progress the ground's dim ink.
+pub fn inkOn(inks: *const pardes.colors.Chrome.Inks, kind: Kind) [3]u8 {
+ return switch (kind) {
+ .@"error" => inks.severity[0],
+ .warn => inks.severity[1],
+ .question => inks.severity[2],
+ .echo, .notice, .progress => inks.dim,
+ };
+}
+
/// The places a compiler's report names put on `s`: each
/// `path:line:col: error|warning|note: words` row (a relative path is
/// `dir`'s), its words there, each place once, and the rows after the
diff --git a/core/Output.zig b/core/Output.zig
index fe1543fe..8807e55d 100644
--- a/core/Output.zig
+++ b/core/Output.zig
@@ -70,27 +70,20 @@ const RowDecoration = struct {
return row.guide_end == 0 and !row.declaration and row.location_end == 0 and row.prefix_end == 0 and row.mark_end <= row.mark_start;
}
- /// `chrome` is the theme's own (Pardes.bodyChrome): body paper changes
- /// immediately, so its ink must change with it even while the
- /// surrounding tags are still fading. Once a frame, never a grapheme:
- /// working it out takes the contrast searches' pow calls.
- pub fn styleAt(row: RowDecoration, chrome: *const pardes.ChromeTheme, byte: usize) ?pardes.CellStyle {
+ /// On the page (`chrome`, Pardes.chrome): a tree's guides in the dim
+ /// ink, a location in the line numbers', the match a hit, a
+ /// diagnostic's label in its severity's ink (R8, R9).
+ pub fn styleAt(row: RowDecoration, chrome: *const pardes.colors.Chrome, byte: usize) ?pardes.CellStyle {
if (row.plain()) return null;
- if (byte < row.guide_end) return .{ .fg = .{ .rgb = chrome.diagnostic_info } };
+ if (byte < row.guide_end) return .{ .fg = .{ .rgb = chrome.page.dim } };
if (row.declaration or byte < @max(row.location_end, row.prefix_end))
- return .{ .fg = .{ .rgb = chrome.lineno } };
+ return .{ .fg = .{ .rgb = chrome.line_number } };
if (byte < row.mark_start or byte >= row.mark_end) return null;
if (row.severity == .none) return .{
- .fg = .{ .rgb = chrome.search_fg },
- .bg = .{ .rgb = chrome.search_bg },
+ .fg = .{ .rgb = chrome.page.text },
+ .bg = .{ .rgb = chrome.hit },
};
- return .{ .fg = .{ .rgb = switch (row.severity) {
- .err => chrome.diagnostic_error,
- .warning => chrome.diagnostic_warning,
- .info => chrome.diagnostic_info,
- .hint => chrome.diagnostic_hint,
- .none => unreachable,
- } }, .bold = true };
+ return .{ .fg = .{ .rgb = chrome.page.severity[@intFromEnum(row.severity) - 1] }, .bold = true };
}
};
diff --git a/core/Pick.zig b/core/Pick.zig
index 1d332f25..7c40a234 100644
--- a/core/Pick.zig
+++ b/core/Pick.zig
@@ -1176,8 +1176,8 @@ pub fn ghosts(p: *Pardes, s: *Surface, arena: std.mem.Allocator, pane: *Pane, r:
if (rows <= first) return;
const w: usize = s.cols;
const old = try arena.dupe(Cell, s.cells[(y0 + first) * w .. (y0 + rows) * w]);
- const grounds = colors.Grounds.of(p.theme());
- const ink = p.theme().fg orelse p.theme().tag_fg;
+ const chrome = p.chrome();
+ const ink = chrome.page.text;
const x0 = r.x + config.GUTTER + File.gutterWidth(pane);
const width = r.w -| (x0 - r.x);
var out: usize = first;
@@ -1194,15 +1194,15 @@ pub fn ghosts(p: *Pardes, s: *Surface, arena: std.mem.Allocator, pane: *Pane, r:
if (out >= rows) break;
const y: u16 = @intCast(y0 + out);
s.fill(0, y, @intCast(s.cols), 1, .{});
- s.fill(x0, y, width, 1, .{ .bg = .{ .rgb = grounds.add.row } });
- _ = s.print(x0, y, width, l, .{ .fg = .{ .rgb = ink }, .bg = .{ .rgb = grounds.add.row } });
+ s.fill(x0, y, width, 1, .{ .bg = .{ .rgb = chrome.add.row } });
+ _ = s.print(x0, y, width, l, .{ .fg = .{ .rgb = ink }, .bg = .{ .rgb = chrome.add.row } });
out += 1;
};
}
}
if (out >= rows) break;
@memcpy(s.cells[(y0 + out) * w ..][0..w], old[(vr - first) * w ..][0..w]);
- if (g < groups.items.len and line >= groups.items[g].lo and line < groups.items[g].hi) s.tint(x0, @intCast(y0 + out), width, grounds.del.row, null);
+ if (g < groups.items.len and line >= groups.items[g].lo and line < groups.items[g].hi) s.tint(x0, @intCast(y0 + out), width, chrome.del.row, null);
out += 1;
}
}
@@ -2585,15 +2585,15 @@ test "code actions: a picker in the asking pane's tag, the one under the cursor
const r = p.view().rects[id];
const x = r.x + config.GUTTER + File.gutterWidth(pane);
const y = p.bodyTop(pane, r);
- const grounds = colors.Grounds.of(p.theme());
+ const chrome = p.chrome();
for ([_][]const u8{ "o", "t", "t", "t" }, [_][]const u8{ "n", "w", "w", "h" }, 0..) |c0, c1, row| {
try std.testing.expectEqualStrings(c0, shot.at(x, y + @as(u16, @intCast(row))).grapheme());
try std.testing.expectEqualStrings(c1, shot.at(x + 1, y + @as(u16, @intCast(row))).grapheme());
}
try std.testing.expectEqualStrings("a", shot.at(x + 4, y + 1).grapheme());
try std.testing.expectEqualStrings("s", shot.at(x + 4, y + 2).grapheme());
- try std.testing.expectEqual(pardes.Color{ .rgb = grounds.del.row }, shot.at(x, y + 1).style.bg);
- try std.testing.expectEqual(pardes.Color{ .rgb = grounds.add.row }, shot.at(x, y + 2).style.bg);
+ try std.testing.expectEqual(pardes.Color{ .rgb = chrome.del.row }, shot.at(x, y + 1).style.bg);
+ try std.testing.expectEqual(pardes.Color{ .rgb = chrome.add.row }, shot.at(x, y + 2).style.bg);
try std.testing.expectEqualStrings("one\ntwo add\nthree\n", pane.file.?.content);
// An action lands nowhere: no landing line, no `▸` before the line it
// changes, no sentence of where Enter lands (UX D7's are a jump's; an
@@ -2610,10 +2610,10 @@ test "code actions: a picker in the asking pane's tag, the one under the cursor
frame = std.heap.ArenaAllocator.init(std.testing.allocator);
shot = try p.render(frame.allocator());
try std.testing.expectEqualStrings("/", shot.at(x, y).grapheme());
- try std.testing.expectEqual(pardes.Color{ .rgb = grounds.add.row }, shot.at(x, y).style.bg);
+ try std.testing.expectEqual(pardes.Color{ .rgb = chrome.add.row }, shot.at(x, y).style.bg);
try std.testing.expectEqualStrings("o", shot.at(x, y + 1).grapheme());
- try std.testing.expect(!std.meta.eql(pardes.Color{ .rgb = grounds.del.row }, shot.at(x, y + 1).style.bg));
- try std.testing.expect(!std.meta.eql(pardes.Color{ .rgb = p.chromeTheme().roles.hit }, shot.at(x, y + 1).style.bg));
+ try std.testing.expect(!std.meta.eql(pardes.Color{ .rgb = chrome.del.row }, shot.at(x, y + 1).style.bg));
+ try std.testing.expect(!std.meta.eql(pardes.Color{ .rgb = p.chrome().hit }, shot.at(x, y + 1).style.bg));
// `3`: the rename applied, the tag at rest; one undo takes it back.
p.update(.{ .key = .{ .cp = '3', .text = "3" } });
try std.testing.expectEqual(TagState.Kind.rest, s.kind);
@@ -2720,16 +2720,16 @@ test "a picker's preview is legible as one (UX D7): its landing line on the hit
};
try std.testing.expectEqual(@as(?u16, @intCast((pane.rows + 2) / 3)), at);
const y = body_y + at.?;
- const roles = &p.chromeTheme().roles;
+ const c = p.chrome();
const tx = r.x + pardes.config.GUTTER;
const gutter = File.gutterWidth(pane);
// Its text on the hit ground across the row; the row above as it was.
- for (gutter..r.w - pardes.config.GUTTER) |x| try std.testing.expectEqual(pardes.Color{ .rgb = roles.hit }, s.at(tx + @as(u16, @intCast(x)), y).style.bg);
- try std.testing.expect(!std.meta.eql(s.at(tx + gutter + 2, y - 1).style.bg, pardes.Color{ .rgb = roles.hit }));
+ for (gutter..r.w - pardes.config.GUTTER) |x| try std.testing.expectEqual(pardes.Color{ .rgb = c.hit }, s.at(tx + @as(u16, @intCast(x)), y).style.bg);
+ try std.testing.expect(!std.meta.eql(s.at(tx + gutter + 2, y - 1).style.bg, pardes.Color{ .rgb = c.hit }));
// `▸` in the key ink in the gutter's cell after the number.
const mark = s.at(tx + gutter - 1, y);
try std.testing.expectEqualStrings("▸", mark.grapheme());
- try std.testing.expectEqual(pardes.Color{ .rgb = roles.key }, mark.style.fg);
+ try std.testing.expectEqual(pardes.Color{ .rgb = c.page.key }, mark.style.fg);
// The notice row: where Enter lands, the owner's address a word in it.
var buf: [pardes.Messages.notice_row_cap]u8 = undefined;
const said = pardes.Messages.noticeRow(p, 120, &buf);
diff --git a/core/Places.zig b/core/Places.zig
index 8563d7c8..63f9ced6 100644
--- a/core/Places.zig
+++ b/core/Places.zig
@@ -659,19 +659,17 @@ pub fn origin(set: *const Places, pane: *Pane) usize {
}
/// Every place on the rows shown, tinted over the text: the hit ground,
-/// the current one the current hit's (colors.Roles, UX D4, D14).
+/// the current one solid in the hue with the page's ink (R8, UX D14); a
+/// search prompt's pattern that is no regex, its last places dimmed: the
+/// current on the hit ground, the rest faint.
pub fn paint(set: *Places, p: *Pardes, s: *Surface, pane: *Pane, r: pardes.Rect, body_h: u16) void {
if (!set.shows(pane)) return;
const f = &pane.file.?;
- const th = p.theme();
- const roles = &p.chromeTheme().roles;
- var strong = roles.hit_current;
- var quiet = roles.hit;
- // A search prompt's pattern that is no regex: its last places, dimmed.
- if (pardes.Prompt.dims(p, pane)) {
- strong = quiet;
- quiet = colors.mix(th.bg orelse th.tag_bg, quiet);
- }
+ const c = p.chrome();
+ const dim = pardes.Prompt.dims(p, pane);
+ const strong = if (dim) c.hit else c.hit_current;
+ const strong_ink: ?[3]u8 = if (dim) null else c.hit_current_text;
+ const quiet = if (dim) c.hit_faint else c.hit;
const hits = set.hits.items;
if (hits.len == 0) return;
const nlines = File.nlines(p.gpa, f);
@@ -697,7 +695,7 @@ pub fn paint(set: *Places, p: *Pardes, s: *Surface, pane: *Pane, r: pardes.Rect,
const b = @min(hits[i].end, le) - ls;
if (b <= a) continue;
const current = set.current != null and set.current.? == i;
- File.paintWordSelection(p, s, pane, r, line, @intCast(a), @intCast(b), if (current) strong else quiet);
+ File.paintWordSelection(p, s, pane, r, line, @intCast(a), @intCast(b), if (current) strong else quiet, if (current) strong_ink else null);
}
}
}
@@ -903,3 +901,42 @@ test "a session's places loaded from its dump find what an edit makes as the ses
b.panes[b.view().active].?.file.?.mtime = a.panes[a.view().active].?.file.?.mtime;
try std.testing.expectEqual(pardes.walk.digest(Pardes, a), pardes.walk.digest(Pardes, b));
}
+
+test "places: each on the hit ground in its text's own ink, the current one solid, the hue its ground and the page its ink (R8, G7), the selection over it; a search whose field is no regex dims them, the rest faint" {
+ const p = try Pardes.init(std.testing.allocator, .{ .tty_only = true, .cols = 80, .rows = 24 });
+ defer p.deinit();
+ colors.setThemeIndex(p, colors.themeIndex("orchard").?);
+ const pane = try p.setTestFile("alpha beta\ngamma alpha\nb\nb\nb\nb\nb\nb\nb\nzeta alpha\n");
+ // Landed on the first, the caret then moved off it: the places stay.
+ typeKeys(p, "/alpha");
+ p.update(.{ .key = .{ .cp = pardes.Key.enter } });
+ typeKeys(p, "j");
+ try std.testing.expect(pane.places.shows(pane));
+ try std.testing.expectEqual(@as(?usize, 0), pane.places.current);
+ const c = p.chrome();
+ var frame: std.heap.ArenaAllocator = .init(std.testing.allocator);
+ defer frame.deinit();
+ const r = p.view().rects[0];
+ const x = r.x + pardes.config.GUTTER + File.gutterWidth(pane);
+ const y = p.bodyTop(pane, r);
+ var s = try p.render(frame.allocator());
+ for (0..5) |i| {
+ const current = s.at(x + @as(u16, @intCast(i)), y).style;
+ try std.testing.expectEqual(pardes.Color{ .rgb = c.hit_current }, current.bg);
+ try std.testing.expectEqual(pardes.Color{ .rgb = c.hit_current_text }, current.fg);
+ const other = s.at(x + 6 + @as(u16, @intCast(i)), y + 1).style;
+ try std.testing.expectEqual(pardes.Color{ .rgb = c.hit }, other.bg);
+ try std.testing.expectEqual(pardes.Color{ .rgb = c.page.text }, other.fg);
+ }
+ // Searched again from line 2: its place current and selected, the
+ // selection over the hit; then `(`, no regex: the others faint (line
+ // 10's: the prompt's words lie over the top rows).
+ typeKeys(p, "/alpha");
+ try std.testing.expectEqual(@as(?usize, 1), pane.places.current);
+ s = try p.render(frame.allocator());
+ for (0..4) |i| try std.testing.expectEqual(pardes.Color{ .rgb = c.page.selection.ground }, s.at(x + 6 + @as(u16, @intCast(i)), y + 1).style.bg);
+ typeKeys(p, "(");
+ try std.testing.expect(pardes.Prompt.dims(p, pane));
+ s = try p.render(frame.allocator());
+ for (5..10) |i| try std.testing.expectEqual(pardes.Color{ .rgb = c.hit_faint }, s.at(x + @as(u16, @intCast(i)), y + 9).style.bg);
+}
diff --git a/core/Prompt.zig b/core/Prompt.zig
index b76b2d9a..49a9645d 100644
--- a/core/Prompt.zig
+++ b/core/Prompt.zig
@@ -874,7 +874,7 @@ pub fn paintGutter(p: *Pardes, s: *Surface, pane: *Pane, r: pardes.Rect, body_h:
const tab = p.settings.tab;
const x = gutterX(pane, r);
const y = p.bodyTop(pane, r);
- const ink = p.chromeTheme().roles.key;
+ const ink = p.chrome().page.key;
const nlines = File.nlines(p.gpa, f);
// `▸` on the current place's line alone: the lines with places are the
// rail's ticks (Places.addTicks), never glyphs of their own (UX D14).
@@ -953,8 +953,8 @@ pub fn ghosts(p: *Pardes, s: *Surface, arena: std.mem.Allocator, pane: *Pane, r:
if (rows <= first) return;
const w: usize = s.cols;
const old = try arena.dupe(Cell, s.cells[(y0 + first) * w .. (y0 + rows) * w]);
- const grounds = colors.Grounds.of(p.theme());
- const ink = p.theme().fg orelse p.theme().tag_fg;
+ const chrome = p.chrome();
+ const ink = chrome.page.text;
const x0 = r.x + config.GUTTER + File.gutterWidth(pane);
const width = r.w -| (x0 - r.x);
const ranges = live_run.ranges[0..live_run.nranges];
@@ -969,18 +969,18 @@ pub fn ghosts(p: *Pardes, s: *Surface, arena: std.mem.Allocator, pane: *Pane, r:
// `!`: its output before the selection's first line.
var j = k;
if (how == .insert and opens) while (j < ranges.len and lineAt(index, @min(ranges[j].anchor, ranges[j].head)) == line) : (j += 1) {
- out = ghostRows(s, live_run, j, out, rows, y0, x0, width, grounds.add.row, ink);
+ out = ghostRows(s, live_run, j, out, rows, y0, x0, width, chrome.add.row, ink);
};
if (out >= rows) break;
@memcpy(s.cells[(y0 + out) * w ..][0..w], old[(vr - first) * w ..][0..w]);
j = k;
while (j < ranges.len and lineAt(index, @min(ranges[j].anchor, ranges[j].head)) <= line) : (j += 1) {
- if (how == .replace and outcome(live_run, j) == 0) s.tint(x0, @intCast(y0 + out), width, grounds.del.row, null);
+ if (how == .replace and outcome(live_run, j) == 0) s.tint(x0, @intCast(y0 + out), width, chrome.del.row, null);
}
out += 1;
// `|` and `A-!`: after the selection's last line.
if (how != .insert and closes) while (k < ranges.len and lineAt(index, @max(ranges[k].anchor, ranges[k].head) -| 1) == line) : (k += 1) {
- out = ghostRows(s, live_run, k, out, rows, y0, x0, width, grounds.add.row, ink);
+ out = ghostRows(s, live_run, k, out, rows, y0, x0, width, chrome.add.row, ink);
};
}
// What was pushed past the view leaves blank rows behind it, none.
@@ -1027,7 +1027,7 @@ fn fence(p: *Pardes, s: *Surface, pane: *Pane, r: pardes.Rect, body_h: u16) void
if (snap.len == 0) return;
const x = gutterX(pane, r);
const y = p.bodyTop(pane, r);
- const ink = p.chromeTheme().box;
+ const ink = p.chrome().page.key;
const nlines = File.nlines(p.gpa, f);
const op = p.view().tag_state.prompt.op;
var kept: [Text.max_selections]modal.Selection = undefined;
@@ -1500,12 +1500,12 @@ test "/ searches the body as it is typed: the current place selected, `▸` in t
{
const s = try p.render(frame.allocator());
const r = p.view().rects[0];
- const roles = &p.chromeTheme().roles;
+ const c = p.chrome();
const x = r.x + config.GUTTER + File.gutterWidth(pane);
const y = p.bodyTop(pane, r);
- try std.testing.expectEqual(pardes.Color{ .rgb = roles.key }, s.at(x - 1 - File.laneCells(pane) - pane.layers.heat, y + 2).style.fg);
+ try std.testing.expectEqual(pardes.Color{ .rgb = c.page.key }, s.at(x - 1 - File.laneCells(pane) - pane.layers.heat, y + 2).style.fg);
// Line 1's place (`dirty` at its start) on the hit ground.
- try std.testing.expectEqual(pardes.Color{ .rgb = roles.hit }, s.at(x, y).style.bg);
+ try std.testing.expectEqual(pardes.Color{ .rgb = c.hit }, s.at(x, y).style.bg);
}
p.update(.{ .key = .{ .cp = Key.enter } });
try std.testing.expectEqual(TagState.Kind.rest, p.view().tag_state.kind);
@@ -1651,8 +1651,10 @@ test "a pipe prompt runs a known filter live, a run a selection: the outputs gho
const x = r.x + config.GUTTER + File.gutterWidth(pane);
const y = p.bodyTop(pane, r);
for ([_][]const u8{ "b", "B", "a", "A", "c" }, 0..) |want, row| try std.testing.expectEqualStrings(want, s.at(x, y + @as(u16, @intCast(row))).grapheme());
- try std.testing.expectEqual(pardes.Color{ .rgb = colors.Grounds.of(p.theme()).del.row }, s.at(x, y).style.bg);
- try std.testing.expectEqual(pardes.Color{ .rgb = colors.Grounds.of(p.theme()).add.row }, s.at(x, y + 1).style.bg);
+ // On the chrome's diff rows (R10), the ghost in the page's text.
+ try std.testing.expectEqual(pardes.Color{ .rgb = p.chrome().del.row }, s.at(x, y).style.bg);
+ try std.testing.expectEqual(pardes.Color{ .rgb = p.chrome().add.row }, s.at(x, y + 1).style.bg);
+ try std.testing.expectEqual(pardes.Color{ .rgb = p.chrome().page.text }, s.at(x, y + 1).style.fg);
try std.testing.expectEqualStrings("b\na\nc\n", pane.file.?.content);
// Enter: what the live run made, applied.
p.update(.{ .key = .{ .cp = Key.enter } });
diff --git a/core/Query.zig b/core/Query.zig
index 2b2abebb..f3673dd6 100644
--- a/core/Query.zig
+++ b/core/Query.zig
@@ -471,8 +471,8 @@ fn makeNameRows(p: *Pardes, id: usize) !void {
var rows: std.ArrayList(locations.Row) = .empty;
var spans: std.ArrayList(pardes.Term.Span) = .empty;
errdefer spans.deinit(p.gpa);
- const chrome = p.bodyChrome();
- const tint: pardes.CellStyle = .{ .fg = .{ .rgb = chrome.search_fg }, .bg = .{ .rgb = chrome.search_bg }, .bold = true };
+ const chrome = p.chrome();
+ const tint: pardes.CellStyle = .{ .fg = .{ .rgb = chrome.page.text }, .bg = .{ .rgb = chrome.hit }, .bold = true };
const shown = @min(q.names.hits.items.len, Names.max_rows);
var marks: [Names.max_query * 4]u16 = undefined;
const base = lineOne(rp.file.?.content).len + 1;
@@ -510,7 +510,7 @@ fn makeNameRows(p: *Pardes, id: usize) !void {
// A closed pane's row is dimmer, the gutter's colour, between its
// marks (spans are walked in order, never overlapping).
const dim = q.source == .panes and p.paneBySerial(cand.ref) == null;
- const dimmed: pardes.CellStyle = .{ .fg = .{ .rgb = chrome.lineno } };
+ const dimmed: pardes.CellStyle = .{ .fg = .{ .rgb = chrome.line_number } };
var gap: usize = 0;
var k: usize = 0;
while (k < nmarks) {
@@ -2092,8 +2092,7 @@ pub fn tagPrefix(q: *const Query, arena: std.mem.Allocator, path: []const u8) er
pub fn paintMark(p: *Pardes, s: *Surface, pane: *Pane, r: pardes.Rect, body_h: u16) void {
const q = pane.query orelse return;
const c = q.current orelse return;
- const th = p.theme();
- const mark = colors.mix(th.bg orelse th.tag_bg, th.sel_bg);
+ const mark = p.chrome().selection_secondary;
const tx = r.x + config.GUTTER;
const tw = r.w -| config.GUTTER;
const col = File.gutterWidth(pane);
@@ -2106,13 +2105,11 @@ pub fn paintMark(p: *Pardes, s: *Surface, pane: *Pane, r: pardes.Rect, body_h: u
/// The other places on a hit row's line tinted, from the pane its rows are
/// in (the first is the row's own mark, Output.decorateRow): the current
-/// one strongest, as in that pane's text.
+/// one solid, as in that pane's text (Places.paint).
pub fn paint(p: *Pardes, s: *Surface, pane: *Pane, r: pardes.Rect, body_h: u16) void {
const q = pane.query orelse return;
const f = if (pane.file) |*file| file else return;
- const th = p.theme();
- const strong = p.chromeTheme().search_bg;
- const quiet = colors.mix(th.bg orelse th.tag_bg, strong);
+ const c = p.chrome();
var vr: i32 = 0;
var last: i32 = -1;
while (vr < body_h) : (vr += 1) {
@@ -2144,7 +2141,7 @@ pub fn paint(p: *Pardes, s: *Surface, pane: *Pane, r: pardes.Rect, body_h: u16)
const b = @min(line.len, meta.code_start + (@min(h.end, next) - ls - meta.source_column));
if (b <= a or a >= line.len) continue;
const current = set.current != null and set.current.? == hi;
- File.paintWordSelection(p, s, pane, r, row, @intCast(a), @intCast(b), if (current) strong else quiet);
+ File.paintWordSelection(p, s, pane, r, row, @intCast(a), @intCast(b), if (current) c.hit_current else c.hit, if (current) c.hit_current_text else null);
}
}
}
@@ -2815,3 +2812,48 @@ test "Grep: a row whose numbers a Found cannot hold (a column past u32) is passe
// Taken or passed over, each: never cast (main: Query.zig:1267).
try std.testing.expect(q.found.items.len <= 3);
}
+
+test "a query pane's hits are the body's: a row's match on the hit ground in the text's ink, the owner's current place solid in the hue with the page's ink, the current row marked with the selection's faint half" {
+ const p = try Pardes.init(std.testing.allocator, .{ .tty_only = true, .cols = 100, .rows = 40 });
+ defer p.deinit();
+ p.settings.jumps = .@"new-pane";
+ colors.setThemeIndex(p, colors.themeIndex("orchard").?);
+ const pane = try p.setTestFile("alpha one alpha\nbeta\ngamma alpha\n");
+ slash(p, "/alpha");
+ const qid = queryPane(p).?;
+ const qp = p.panes[qid].?;
+ try std.testing.expectEqual(@as(?usize, 0), qp.query.?.current);
+ try std.testing.expectEqual(@as(?usize, 0), pane.places.current);
+ var frame = std.heap.ArenaAllocator.init(std.testing.allocator);
+ defer frame.deinit();
+ const s = try p.render(frame.allocator());
+ const c = p.chrome();
+ const r = p.view().rects[qid];
+ // Row 1 (line 1 is the query) the first place's line, row 2 the third's.
+ var rows: [2][]const u8 = undefined;
+ for (&rows, 1..) |*row, k| {
+ var text: std.ArrayList(u8) = .empty;
+ for (0..r.w) |x| try text.appendSlice(frame.allocator(), s.at(r.x + @as(u16, @intCast(x)), p.bodyTop(qp, r) + @as(u16, @intCast(k))).grapheme());
+ row.* = text.items;
+ }
+ const y = p.bodyTop(qp, r) + 1;
+ const first = std.mem.indexOf(u8, rows[0], "alpha").?;
+ const second = std.mem.lastIndexOf(u8, rows[0], "alpha").?;
+ const third = std.mem.indexOf(u8, rows[1], "alpha").?;
+ try std.testing.expect(second > first + 5);
+ for (0..5) |i| {
+ const current = s.at(r.x + @as(u16, @intCast(first + i)), y).style;
+ try std.testing.expectEqual(pardes.Color{ .rgb = c.hit_current }, current.bg);
+ try std.testing.expectEqual(pardes.Color{ .rgb = c.hit_current_text }, current.fg);
+ const other = s.at(r.x + @as(u16, @intCast(second + i)), y).style;
+ try std.testing.expectEqual(pardes.Color{ .rgb = c.hit }, other.bg);
+ try std.testing.expectEqual(pardes.Color{ .rgb = c.page.text }, other.fg);
+ const below = s.at(r.x + @as(u16, @intCast(third + i)), y + 1).style;
+ try std.testing.expectEqual(pardes.Color{ .rgb = c.hit }, below.bg);
+ try std.testing.expectEqual(pardes.Color{ .rgb = c.page.text }, below.fg);
+ }
+ // The current row's mark between its places and to its end; none below.
+ try std.testing.expectEqual(pardes.Color{ .rgb = c.selection_secondary }, s.at(r.x + @as(u16, @intCast(first + 6)), y).style.bg);
+ try std.testing.expectEqual(pardes.Color{ .rgb = c.selection_secondary }, s.at(r.x + r.w - 2, y).style.bg);
+ try std.testing.expectEqual(pardes.Color{ .rgb = c.page.ground }, s.at(r.x + r.w - 2, y + 1).style.bg);
+}
diff --git a/core/Tables.zig b/core/Tables.zig
index a0256d8a..99e464ac 100644
--- a/core/Tables.zig
+++ b/core/Tables.zig
@@ -645,16 +645,16 @@ fn glyph(cell: *Cell, g: []const u8) void {
/// A pane's table rows drawn as tables: every unescaped `|` a rule, the
/// delimiter row one rule across (its dashes, its blanks and its pads, its
/// `:` kept in the rule's colour, since they say the alignment), the header
-/// row bold on the tag's ground, as compact context rows are. Only glyphs
+/// row bold on the tag's ground, as compact context rows are, the rules in
+/// the page's rule ink (R11). Only glyphs
/// and colours change, on the cells the row has: where each byte is and how
/// wide is fillBody's, so nothing is drawn over anything, B1 on a rule is
/// B1 on its `|`, and a selection's tint lies over the rules as over text.
pub fn paint(p: *Pardes, s: *Surface, pane: *Pane, r: pardes.Rect, tx: u16, tw: u16, body_h: u16) void {
const f = if (pane.file) |*file| file else return;
if (f.tables.list.items.len == 0) return;
- const th = p.theme();
- const rule_fg: Color = .{ .rgb = th.border orelse th.lineno };
- const head_bg: Color = .{ .rgb = th.tag_bg };
+ const rule_fg: Color = .{ .rgb = p.chrome().page.rule };
+ const head_bg: Color = .{ .rgb = p.chrome().tag[0].ground };
const prefix: usize = File.gutterWidth(pane);
const body_y = p.bodyTop(pane, r);
var vr: u16 = 0;
diff --git a/core/body_layer.zig b/core/body_layer.zig
index 513f9a6d..1eb3bf54 100644
--- a/core/body_layer.zig
+++ b/core/body_layer.zig
@@ -148,21 +148,12 @@ pub fn paintPointerSelection(
}
}
-/// The selection colour of each pointer button's sweep: the select button's
-/// and the look and exec buttons', each tinted toward its own accent.
-pub fn buttonTints(th: *const colors.LegacyTheme) [3][3]u8 {
- if (th.sweep_bg) |own| return own;
- const accent2 = if (std.mem.eql(u8, &th.num, &th.str)) th.comment else th.num;
- return .{
- colors.mix(th.sel_bg, colors.mix(th.sel_bg, th.kw)),
- colors.mix(th.sel_bg, colors.mix(th.sel_bg, th.str)),
- colors.mix(th.sel_bg, colors.mix(th.sel_bg, accent2)),
- };
-}
-
-/// The ink over each button's sweep.
-pub fn buttonInks(th: *const colors.LegacyTheme) [3][3]u8 {
- return th.sweep_fg orelse @splat(th.sel_fg);
+/// The rail's column in the theme's rail and thumb, and the column right
+/// of it the page.
+fn paintRail(c: *const colors.Chrome, s: *Surface, bar: pardes.Region) void {
+ s.fill(bar.rect.x, bar.rect.y, 1, bar.rect.h, .{ .bg = .{ .rgb = c.rail } });
+ s.fill(bar.rect.x + 1, bar.rect.y, 1, bar.rect.h, .{ .bg = if (c.host_page) .default else .{ .rgb = c.page.ground } });
+ s.fill(bar.rect.x, bar.rect.y + bar.thumb_y, 1, bar.thumb_h, .{ .bg = .{ .rgb = c.rail_thumb } });
}
/// A pane's body, painted once. A file body with compact tree-sitter
@@ -221,14 +212,7 @@ pub fn joinBody(p: *Pardes, s: *Surface, arena: std.mem.Allocator, pane: *Pane,
if (layer.cursor) |cursor| if (cursor.y < viewport_rows) {
s.cursor = .{ .x = body.rect.x + cursor.x, .y = body.rect.y + cursor.y, .bar = cursor.bar };
};
- const chrome = p.chromeTheme();
- const theme = p.theme();
- const pane_bg: Color = if (theme.bg) |c| .{ .rgb = c } else .default;
- if (rail.rect.h > 0) {
- s.fill(rail.rect.x, rail.rect.y, 1, rail.rect.h, .{ .bg = .{ .rgb = chrome.scroll_track } });
- s.fill(rail.rect.x + 1, rail.rect.y, 1, rail.rect.h, .{ .bg = pane_bg });
- s.fill(rail.rect.x, rail.rect.y + rail.thumb_y, 1, rail.thumb_h, .{ .bg = .{ .rgb = chrome.scroll_thumb } });
- }
+ if (rail.rect.h > 0) paintRail(p.chrome(), s, rail);
}
fn drawGutter(p: *Pardes, s: *Surface, pane: *Pane, r: pardes.Rect, tx: u16, tw: u16, body_h: u16, active: bool) void {
@@ -239,12 +223,13 @@ fn drawGutter(p: *Pardes, s: *Surface, pane: *Pane, r: pardes.Rect, tx: u16, tw:
const cur_line: i32 = if (active and typing_body) gcrow else std.math.minInt(i32);
// the body's first row, the way renderPane derives it
const body_y = p.bodyTop(pane, r);
- const context_bg = p.theme().tag_bg;
+ const chrome = p.chrome();
+ // The context rows on the tag's ground, as a header.
for (0..@min(pane.context_rows, body_h)) |context_row| {
for (0..tw) |col| {
const cell = s.at(tx + @as(u16, @intCast(col)), body_y + @as(u16, @intCast(context_row)));
cell.default = false;
- cell.style.bg = .{ .rgb = context_bg };
+ cell.style.bg = .{ .rgb = chrome.tag[0].ground };
cell.style.font_role = .tagline;
}
}
@@ -259,10 +244,7 @@ fn drawGutter(p: *Pardes, s: *Surface, pane: *Pane, r: pardes.Rect, tx: u16, tw:
while (c < prefix_width and c < tw) : (c += 1) {
const cell = s.at(tx + c, body_y + vr);
cell.default = false; // paints blank gutter rows too
- cell.style.fg = .{ .rgb = if (on_cursor)
- p.theme().lineno_active orelse p.theme().lineno
- else
- p.theme().lineno };
+ cell.style.fg = .{ .rgb = if (on_cursor) chrome.line_number_current else chrome.line_number };
cell.style.bold = on_cursor;
}
}
@@ -280,7 +262,7 @@ fn drawWrapMarkers(
) void {
if (tw <= panes.File.gutterWidth(pane) + 1) return;
const body_y = p.bodyTop(pane, r);
- const marker_fg = p.chromeTheme().lineno;
+ const marker_fg = p.chrome().line_number;
var row: u16 = 0;
while (row + 1 < pane.wrap_n and row + 1 < body_h) : (row += 1) {
if (pane.wrap_line[row + 1] != pane.wrap_line[row] or pane.wrap_col[row] < 0) continue;
@@ -292,21 +274,20 @@ fn drawWrapMarkers(
}
pub fn renderBody(p: *Pardes, s: *Surface, arena: std.mem.Allocator, pane: *Pane, r: Rect, id: usize, active: bool, rail: ?pardes.Region) !void {
- const th = p.theme();
- const chrome = p.chromeTheme();
+ const c = p.chrome();
const tx = r.x + config.GUTTER;
const tw = r.w - config.GUTTER;
// Below the notice bands: they are stacked at the top of the body the
// way tree-sitter context rows are, so the body starts under them
// rather than being painted over by them.
const body_y = p.bodyTop(pane, r);
- const pane_bg: Color = if (th.bg) |c| .{ .rgb = c } else .default;
- const page_rgb = th.bg orelse th.tag_bg;
+ // A theme that leaves its page to the host leaves it its text too.
+ const pane_bg: Color = if (c.host_page) .default else .{ .rgb = c.page.ground };
// body: emulator rows, prompt rows hidden outside tty mode
const body_h = r.h -| pane.tag_rows;
const body_bottom = r.h;
const body_style: CellStyle = .{
- .fg = if (th.fg) |c| .{ .rgb = c } else .default,
+ .fg = if (c.host_page) .default else .{ .rgb = c.page.text },
.bg = pane_bg,
};
const tz_body = tracy.zone(@src(), "bodyText");
@@ -319,7 +300,7 @@ pub fn renderBody(p: *Pardes, s: *Surface, arena: std.mem.Allocator, pane: *Pane
// the rows, which paint over it.
const sweep = pane.sel[pardes.sel_slot];
if (sweep.state != .none and (sweep.state != .done or pardes.sel_slot == 0) and @min(sweep.r0, sweep.r1) < pane.tag_rows)
- paintPointerSelection(p, s, pane, r, sweep, pane.tag_rows, th.sel_bg, th.sel_fg);
+ paintPointerSelection(p, s, pane, r, sweep, pane.tag_rows, c.sweeps[pardes.sel_slot].ground, c.sweeps[pardes.sel_slot].text);
{
// The rows themselves. `bodyText` above is only the string BUILD;
// this is what writes it into the surface.
@@ -363,16 +344,14 @@ pub fn renderBody(p: *Pardes, s: *Surface, arena: std.mem.Allocator, pane: *Pane
tz_color.end();
if (pane.isTerminal()) ansi.images(p, s, pane, id, tx, tw, body_y, body_h);
- const sel_btn = buttonTints(th);
if (p.look_hover_preview) |preview| {
if (preview.pane == id and preview.serial == pane.serial) {
// Preserve body ink, then let every real user selection below
// win over this quiet affordance.
- const preview_bg = colors.mix(page_rgb, colors.mix(page_rgb, th.sel_bg));
if (preview.file_word) |word|
- panes.File.paintWordSelection(p, s, pane, r, word.row, word.lo, word.hi, preview_bg)
+ panes.File.paintWordSelection(p, s, pane, r, word.row, word.lo, word.hi, c.selection_secondary, null)
else if (preview.sel) |sel|
- paintPointerSelection(p, s, pane, r, sel, pane.tag_rows, preview_bg, null);
+ paintPointerSelection(p, s, pane, r, sel, pane.tag_rows, c.selection_secondary, null);
}
}
const modal_hover = if (p.look_hover_preview) |preview|
@@ -385,7 +364,7 @@ pub fn renderBody(p: *Pardes, s: *Surface, arena: std.mem.Allocator, pane: *Pane
// A select sweep over the tag is the tag's selection, painted there
// in the tag's own selection colours.
if (b == pardes.sel_slot and @min(sl.r0, sl.r1) < pane.tag_rows) continue;
- paintPointerSelection(p, s, pane, r, sl, pane.tag_rows, sel_btn[b], buttonInks(th)[b]);
+ paintPointerSelection(p, s, pane, r, sl, pane.tag_rows, c.sweeps[b].ground, c.sweeps[b].text);
}
// A selecting prompt's live result (Prompt.zig), dimmed while its
// field is no regex.
@@ -408,12 +387,11 @@ pub fn renderBody(p: *Pardes, s: *Surface, arena: std.mem.Allocator, pane: *Pane
} else pane.body.sels[si];
const bnd = edit.cellBounds(sr);
const hover_only = primary and modal_hover and pane.body.mode != .normal and !preview;
- const bg = if (hover_only or (selecting != null and selecting.?.dim))
- colors.mix(page_rgb, colors.mix(page_rgb, th.sel_bg))
- else if (primary)
- th.sel_bg
- else
- colors.mix(th.sel_bg, page_rgb);
+ // The primary on the selection in its ink; every other range,
+ // a hover and a dimmed preview on its faint half, the text's
+ // own ink kept (R7).
+ const full = primary and !hover_only and !(selecting != null and selecting.?.dim);
+ const bg = if (full) c.page.selection.ground else c.selection_secondary;
var vr: i32 = 0;
while (vr + @as(i32, pane.tag_rows) < @as(i32, body_bottom)) : (vr += 1) {
const w = pane.wrapAt(p.settings.tab, vr);
@@ -452,7 +430,7 @@ pub fn renderBody(p: *Pardes, s: *Surface, arena: std.mem.Allocator, pane: *Pane
@as(i32, tw) - 1;
const col: i32 = @max(cstart, vpfx);
const end = @min(cend + 1, tw);
- if (col < end) s.tint(tx + @as(u16, @intCast(col)), body_y + @as(u16, @intCast(vr)), @intCast(end - col), bg, if (hover_only) null else th.sel_fg);
+ if (col < end) s.tint(tx + @as(u16, @intCast(col)), body_y + @as(u16, @intCast(vr)), @intCast(end - col), bg, if (full) c.page.selection.text else null);
}
if (primary and !preview and !hover_only) continue; // the hardware cursor IS the primary's
if (hover_only) continue; // quiet preview preserves the source ink
@@ -473,8 +451,8 @@ pub fn renderBody(p: *Pardes, s: *Surface, arena: std.mem.Allocator, pane: *Pane
if (crow >= pane.tag_rows and crow < @as(i32, body_bottom) and ccol >= vpfx and ccol < tw) {
const cell = s.at(tx + @as(u16, @intCast(ccol)), body_y + @as(u16, @intCast(crow - pane.tag_rows)));
cell.default = false;
- cell.style.bg = .{ .rgb = th.sel_fg };
- cell.style.fg = .{ .rgb = th.sel_bg };
+ cell.style.bg = .{ .rgb = c.page.selection.text };
+ cell.style.fg = .{ .rgb = c.page.selection.ground };
}
}
}
@@ -492,7 +470,7 @@ pub fn renderBody(p: *Pardes, s: *Surface, arena: std.mem.Allocator, pane: *Pane
if (pane.jump.items.len > 0) labels: {
const flat = edit.flatSurface(p.editor(), &pane.body) catch break :labels;
const letters = config.jump_label_alphabet;
- const style: CellStyle = .{ .fg = .{ .rgb = th.sel_fg }, .bg = .{ .rgb = th.sel_bg }, .bold = true };
+ const style: CellStyle = .{ .fg = .{ .rgb = c.page.selection.text }, .bg = .{ .rgb = c.page.selection.ground }, .bold = true };
for (pane.jump.items, 0..) |word, i| {
if (pane.jump_first) |first| if (i / letters.len != first) continue;
var at = @min(word.anchor, word.head);
@@ -563,14 +541,10 @@ pub fn renderBody(p: *Pardes, s: *Surface, arena: std.mem.Allocator, pane: *Pane
if (pane.file != null) try pardes.Prompt.ghosts(p, s, arena, pane, r, body_h);
// A code action's edit, previewed (Pick.zig).
if (pane.file != null) try pardes.Pick.ghosts(p, s, arena, pane, r, body_h);
- if (rail) |bar| if (bar.rect.h > 0) {
- // The rail covers the notice bands too: nothing else paints those
- // two gutter columns, so a gap there keeps the frame-wide border
- // fill and reads as a notch cut out of the scrollbar.
- s.fill(bar.rect.x, bar.rect.y, 1, bar.rect.h, .{ .bg = .{ .rgb = chrome.scroll_track } });
- s.fill(bar.rect.x + 1, bar.rect.y, 1, bar.rect.h, .{ .bg = pane_bg });
- s.fill(bar.rect.x, bar.rect.y + bar.thumb_y, 1, bar.thumb_h, .{ .bg = .{ .rgb = chrome.scroll_thumb } });
- };
+ // The rail covers the notice bands too: nothing else paints those two
+ // gutter columns, so a gap there keeps the frame-wide border fill and
+ // reads as a notch cut out of the scrollbar.
+ if (rail) |bar| if (bar.rect.h > 0) paintRail(c, s, bar);
}
/// A message at the lines it names, drawn and never written (SPEC §10.2,
@@ -585,9 +559,8 @@ pub fn renderBody(p: *Pardes, s: *Surface, arena: std.mem.Allocator, pane: *Pane
fn messageGhosts(p: *Pardes, s: *Surface, pane: *Pane, tx: u16, tw: u16, body_y: u16, body_h: u16) void {
const Messages = pardes.Messages;
const f = pane.file.?;
- const chrome = p.chromeTheme();
- const th = p.theme();
- const pane_bg: Color = if (th.bg) |c| .{ .rgb = c } else .default;
+ const page = &p.chrome().page;
+ const pane_bg: Color = if (p.chrome().host_page) .default else .{ .rgb = page.ground };
const Hit = struct { line: usize, said: *const Messages.Said, place: *const Messages.Place };
var hits: [Messages.max_live * Messages.Said.max_places]Hit = undefined;
var n: usize = 0;
@@ -615,7 +588,7 @@ fn messageGhosts(p: *Pardes, s: *Surface, pane: *Pane, tx: u16, tw: u16, body_y:
if (at < tw) {
var buf: [160]u8 = undefined;
const words = std.fmt.bufPrint(&buf, "{s} {s}", .{ hit.said.kind.glyph(), hit.place.text.slice() }) catch &buf;
- _ = s.print(tx + @as(u16, @intCast(at)), body_y + row, @intCast(tw - at), words, .{ .fg = .{ .rgb = Messages.ink(chrome, hit.said.kind) }, .bg = pane_bg });
+ _ = s.print(tx + @as(u16, @intCast(at)), body_y + row, @intCast(tw - at), words, .{ .fg = .{ .rgb = Messages.inkOn(page, hit.said.kind) }, .bg = pane_bg });
}
if (pane.ghost_rows > 0 and row == pane.ghost_at) detail = hit.said;
}
@@ -634,7 +607,7 @@ fn messageGhosts(p: *Pardes, s: *Surface, pane: *Pane, tx: u16, tw: u16, body_y:
for (said.detail[0..k], 0..) |*text, i| {
const y = body_y + under_row + 1 + @as(u16, @intCast(i));
s.fill(tx, y, tw, 1, .{ .bg = pane_bg });
- if (gutter + 2 < tw) _ = s.print(tx + gutter + 2, y, tw - gutter - 2, text.slice(), .{ .fg = .{ .rgb = Messages.ink(chrome, said.kind) }, .bg = pane_bg });
+ if (gutter + 2 < tw) _ = s.print(tx + gutter + 2, y, tw - gutter - 2, text.slice(), .{ .fg = .{ .rgb = Messages.inkOn(page, said.kind) }, .bg = pane_bg });
}
}
@@ -682,7 +655,7 @@ fn drawnRow(p: *Pardes, arena: std.mem.Allocator, id: usize, row: usize) !?[]con
/// number (the one a prompt's current place has, Prompt.paintGutter), on
/// each row it wraps onto.
fn paintLanding(p: *Pardes, s: *Surface, pane: *Pane, r: Rect, tx: u16, tw: u16, body_h: u16, line: usize) void {
- const roles = &p.chromeTheme().roles;
+ const c = p.chrome();
const gutter = File.gutterWidth(pane);
const number = gutter -| File.laneCells(pane) -| pane.layers.heat -| 1;
const body_y = p.bodyTop(pane, r);
@@ -693,18 +666,19 @@ fn paintLanding(p: *Pardes, s: *Surface, pane: *Pane, r: Rect, tx: u16, tw: u16,
for (gutter..tw) |x| {
const cell = s.at(tx + @as(u16, @intCast(x)), body_y + vr);
cell.default = false;
- cell.style.bg = .{ .rgb = roles.hit };
+ cell.style.bg = .{ .rgb = c.hit };
}
if (gutter > 0 and w.at == 0) {
var style = s.at(tx + number, body_y + vr).style;
- style.fg = .{ .rgb = roles.key };
+ style.fg = .{ .rgb = c.page.key };
s.set(tx + number, body_y + vr, "▸", style);
}
}
}
-/// The landing line's matched span (a Grep's match at the row's column) on
-/// the current hit's ground, over the places lit on it (UX D7).
+/// The landing line's matched span (a Grep's match at the row's column) as
+/// the current hit, solid in the hue with the page's ink, over the places
+/// lit on it (UX D7, R8).
fn paintLandingSpan(p: *Pardes, s: *Surface, pane: *Pane, r: Rect, f: *panes.File.State, line: usize) void {
if (!pane.places.shows(pane)) return;
const hits = pane.places.hits.items;
@@ -713,7 +687,7 @@ fn paintLandingSpan(p: *Pardes, s: *Surface, pane: *Pane, r: Rect, f: *panes.Fil
var i = panes.Places.firstFrom(hits, ls);
while (i < hits.len and hits[i].start <= caret) : (i += 1) {
if (hits[i].end <= caret) continue;
- File.paintWordSelection(p, s, pane, r, @intCast(line), @intCast(hits[i].start - ls), @intCast(hits[i].end - ls), p.chromeTheme().roles.hit_current);
+ File.paintWordSelection(p, s, pane, r, @intCast(line), @intCast(hits[i].start - ls), @intCast(hits[i].end - ls), p.chrome().hit_current, p.chrome().hit_current_text);
return;
}
}
@@ -768,9 +742,7 @@ fn paintTargets(p: *Pardes, s: *Surface, arena: std.mem.Allocator, pane: *Pane,
.hi = if (line == last) to - lineStart(f, line) else File.sourceLine(pane, @intCast(line)).len,
.to_edge = line != last,
};
- const th = p.theme();
- const page = th.bg orelse th.tag_bg;
- paintSourceSelection(p, s, pane, r, rows, colors.mix(page, colors.mix(page, th.sel_bg)), null);
+ paintSourceSelection(p, s, pane, r, rows, p.chrome().selection_secondary, null);
return;
}
if (cur.root != .goto and cur.root != .next and cur.root != .prev) return;
@@ -796,7 +768,7 @@ fn paintTargets(p: *Pardes, s: *Surface, arena: std.mem.Allocator, pane: *Pane,
// row's keys, as many as they hold, right-aligned to its last digit,
// bold in the key ink on the gutter's ground. With no numbers, over
// the line's first cells on the selection's ground. Never a shift.
- const ink = p.chromeTheme().roles.key;
+ const ink = p.chrome().page.key;
const number = File.gutterWidth(pane) -| File.laneCells(pane) -| pane.layers.heat -| 1;
const cells = @min(if (number > 0) number else tw, tw);
for (rows[0..n], 0..) |row, i| {
@@ -811,7 +783,7 @@ fn paintTargets(p: *Pardes, s: *Surface, arena: std.mem.Allocator, pane: *Pane,
for (rows[i..n], keys[i..n]) |other, key| {
if (other != row) continue;
if (x >= (if (number > 0) cells else shown)) break;
- const bg = if (number > 0) s.at(tx + x, y).style.bg else pardes.Color{ .rgb = p.theme().sel_bg };
+ const bg = if (number > 0) s.at(tx + x, y).style.bg else pardes.Color{ .rgb = p.chrome().page.selection.ground };
s.set(tx + x, y, bindings.keyName(key), .{ .fg = .{ .rgb = ink }, .bg = bg, .bold = true });
x += 1;
}
@@ -844,13 +816,14 @@ fn hoverGhosts(p: *Pardes, s: *Surface, pane: *Pane, tx: u16, tw: u16, body_y: u
const from = @as(usize, body_y + dst - k) * s.cols + tx;
@memcpy(s.cells[to..][0..tw], s.cells[from..][0..tw]);
}
- const th = p.theme();
- const style: CellStyle = .{ .fg = .{ .rgb = th.tag_fg }, .bg = .{ .rgb = th.tag_bg } };
+ // On the tag's ground in its ink, as a header.
+ const tag = &p.chrome().tag[0];
+ const style: CellStyle = .{ .fg = .{ .rgb = tag.text }, .bg = .{ .rgb = tag.ground } };
const gutter: u16 = File.gutterWidth(pane);
var lines = std.mem.splitScalar(u8, text, '\n');
for (0..k) |i| {
const y = body_y + at + 1 + @as(u16, @intCast(i));
- s.fill(tx, y, tw, 1, .{ .bg = .{ .rgb = th.tag_bg } });
+ s.fill(tx, y, tw, 1, .{ .bg = .{ .rgb = tag.ground } });
if (gutter + 2 < tw) _ = s.print(tx + gutter + 2, y, tw - gutter - 2, lines.next() orelse "", style);
}
}
@@ -865,9 +838,8 @@ fn renameGhosts(p: *Pardes, s: *Surface, pane: *Pane, tx: u16, tw: u16, body_y:
const old = @import("lsp/Ask.zig").renamedWord(pane) orelse return;
const new = p.view().tag_state.field.text();
const tab = p.settings.tab;
- const chrome = p.chromeTheme();
- const th = p.theme();
- const added: CellStyle = .{ .fg = .{ .rgb = chrome.diagnostic_hint }, .bg = if (th.bg) |c| .{ .rgb = c } else .default, .bold = true };
+ const chrome = p.chrome();
+ const added: CellStyle = .{ .fg = .{ .rgb = chrome.page.severity[3] }, .bg = if (chrome.host_page) .default else .{ .rgb = chrome.page.ground }, .bold = true };
const wide: u16 = @intCast(@min(File.displayWidth(tab, new), tw));
const gutter: i32 = File.gutterWidth(pane);
var row: u16 = pane.context_rows;
@@ -894,7 +866,7 @@ fn renameGhosts(p: *Pardes, s: *Surface, pane: *Pane, tx: u16, tw: u16, body_y:
while (c < c1) : (c += 1) {
const cell = s.at(tx + c, y);
cell.style.strikethrough = true;
- cell.style.fg = .{ .rgb = chrome.diagnostic_error };
+ cell.style.fg = .{ .rgb = chrome.page.severity[0] };
}
const x: u16 = @intCast(c1);
if (x + wide < tw) {
@@ -1193,6 +1165,12 @@ test "a build error is said where its cause is: the mark on its file's tag, its
// elsewhere.
try std.testing.expect(std.mem.indexOf(u8, rowText(s, body.x, body.y + 2, &buf), "three \u{2717} expected 2 argument(s), found 3") != null);
try std.testing.expect(std.mem.indexOf(u8, rowText(s, body.x, body.y + 3, &buf), "four") != null);
+ // In the error's ink on the page (R9).
+ const mark = for (0..body.w) |i| {
+ const cell = s.at(body.x + @as(u16, @intCast(i)), body.y + 2);
+ if (std.mem.eql(u8, cell.grapheme(), "\u{2717}")) break cell;
+ } else return error.TestUnexpectedResult;
+ try std.testing.expectEqual(pardes.Color{ .rgb = p.chrome().page.severity[0] }, mark.style.fg);
// The caret on line 3 and its detail asked for (K, UX D13): under the
// line, the rows below two rows down.
pane.body.cur_row = 2;
@@ -1312,7 +1290,7 @@ test "a motion root's level paints its targets in place of their lines' numbers,
try std.testing.expectEqualStrings("p", Field.of(s, gutter, body.y + 4, number, &buf));
const key = s.at(gutter + number - 1, body.y + 4);
try std.testing.expectEqualStrings("p", key.grapheme());
- try std.testing.expectEqual(pardes.Color{ .rgb = p.chromeTheme().roles.key }, key.style.fg);
+ try std.testing.expectEqual(pardes.Color{ .rgb = p.chrome().page.key }, key.style.fg);
try std.testing.expect(key.style.bold);
try std.testing.expect(std.mem.indexOfScalar(u8, Field.of(s, gutter, body.y + 5, number, &buf), 'g') != null);
try std.testing.expect(std.mem.indexOfAny(u8, Field.of(s, gutter, body.y + 5, number, &buf), "0123456789") == null);
@@ -1417,3 +1395,79 @@ test "a message's detail unrolls only on request (UX D13): the caret passing its
p.update(.{ .key = .{ .cp = 'K' } });
try std.testing.expectEqual(pardes.TagState.Kind.prompt, p.view().tag_state.kind);
}
+
+test "the body's selections are one family (R7): the primary on the selection in its ink, another range on its faint half in the text's own ink, its head the selection reversed, a B2 sweep on the chrome's exec sweep" {
+ const p = try Pardes.init(std.testing.allocator, .{ .tty_only = true, .cols = 80, .rows = 20 });
+ defer p.deinit();
+ colors.setThemeIndex(p, colors.themeIndex("orchard").?);
+ const pane = try p.setTestFile("alpha beta\ngamma delta\n");
+ const id = p.view().active;
+ pane.focus = .body;
+ // `e` selects alpha, `C` copies it below: gamma the primary.
+ for ("eC") |c| p.update(.{ .key = .{ .cp = c, .text = &[_]u8{c} } });
+ try std.testing.expectEqual(@as(i32, 1), pane.body.cur_row);
+ try std.testing.expect(pane.body.vsel.active and pane.body.nsel == 1);
+ var frame = std.heap.ArenaAllocator.init(std.testing.allocator);
+ defer frame.deinit();
+ const c = p.chrome();
+ const r = p.view().rects[id];
+ const x = r.x + config.GUTTER + panes.File.gutterWidth(pane);
+ const y = p.bodyTop(pane, r);
+ var s = try p.render(frame.allocator());
+ for (0..5) |i| {
+ const primary = s.at(x + @as(u16, @intCast(i)), y + 1).style;
+ try std.testing.expectEqual(pardes.Color{ .rgb = c.page.selection.ground }, primary.bg);
+ if (i < 4) try std.testing.expectEqual(pardes.Color{ .rgb = c.page.selection.text }, primary.fg);
+ const other = s.at(x + @as(u16, @intCast(i)), y).style;
+ if (i < 4) {
+ try std.testing.expectEqual(pardes.Color{ .rgb = c.selection_secondary }, other.bg);
+ try std.testing.expectEqual(pardes.Color{ .rgb = c.page.text }, other.fg);
+ } else {
+ try std.testing.expectEqual(pardes.Color{ .rgb = c.page.selection.text }, other.bg);
+ try std.testing.expectEqual(pardes.Color{ .rgb = c.page.selection.ground }, other.fg);
+ }
+ }
+ // B2 swept over beta, not let go: the exec sweep.
+ p.update(.{ .mouse = .{ .button = .middle, .kind = .press, .col = x + 6, .row = y } });
+ p.update(.{ .mouse = .{ .button = .middle, .kind = .drag, .col = x + 9, .row = y } });
+ _ = frame.reset(.retain_capacity);
+ s = try p.render(frame.allocator());
+ for (6..10) |i| {
+ const swept = s.at(x + @as(u16, @intCast(i)), y).style;
+ try std.testing.expectEqual(pardes.Color{ .rgb = c.sweeps[1].ground }, swept.bg);
+ try std.testing.expectEqual(pardes.Color{ .rgb = c.sweeps[1].text }, swept.fg);
+ }
+}
+
+test "the body's surfaces take every colour from the chrome: none reads a theme's own fields or the old views (DESIGN.md B6)" {
+ const sources = [_]struct { []const u8, []const u8 }{
+ .{ "body_layer.zig", @embedFile("body_layer.zig") },
+ .{ "Places.zig", @embedFile("Places.zig") },
+ .{ "Query.zig", @embedFile("Query.zig") },
+ .{ "Output.zig", @embedFile("Output.zig") },
+ .{ "Tables.zig", @embedFile("Tables.zig") },
+ .{ "File.zig", @embedFile("File.zig") },
+ .{ "Prompt.zig", @embedFile("Prompt.zig") },
+ .{ "Pick.zig", @embedFile("Pick.zig") },
+ .{ "jj.zig", @embedFile("jj.zig") },
+ .{ "ansi.zig", @embedFile("ansi.zig") },
+ };
+ var wrong: usize = 0;
+ for (sources) |source| {
+ const name, const text = source;
+ // The code, not its tests.
+ const code = text[0 .. std.mem.indexOf(u8, text, "\ntest \"") orelse text.len];
+ // A theme is read for its name alone.
+ var at: usize = 0;
+ while (std.mem.indexOfPos(u8, code, at, "theme()")) |i| : (at = i + 1) {
+ if (std.mem.startsWith(u8, code[i + "theme()".len ..], ".name")) continue;
+ std.debug.print("{s}: a theme's own colours read at byte {d}\n", .{ name, i });
+ wrong += 1;
+ }
+ for ([_][]const u8{ "chromeTheme()", "bodyChrome", ".roles", "Grounds", "LegacyTheme" }) |old| if (std.mem.indexOf(u8, code, old)) |i| {
+ std.debug.print("{s}: `{s}` at byte {d}\n", .{ name, old, i });
+ wrong += 1;
+ };
+ }
+ try std.testing.expectEqual(@as(usize, 0), wrong);
+}
diff --git a/core/colors.zig b/core/colors.zig
index 315d1fc9..44a2d415 100644
--- a/core/colors.zig
+++ b/core/colors.zig
@@ -553,10 +553,13 @@ pub const Chrome = struct {
selection_secondary: [3]u8,
/// The pointer buttons' sweeps: select, exec, look (acme's meanings).
sweeps: [3]Theme.Sweep,
- /// Search: a hit's ground, and the current one's ground and ink.
+ /// Search: a hit's ground, and the current one's ground and ink; a
+ /// search's last places while its field is no regex, dimmed: the page
+ /// halfway toward the hit (as `selection_secondary` is the selection's).
hit: [3]u8,
hit_current: [3]u8,
hit_current_text: [3]u8,
+ hit_faint: [3]u8,
add: Diff,
del: Diff,
/// The Changes layer's lanes, a pin each (`lanes_len` of them), and
@@ -726,6 +729,7 @@ pub const Chrome = struct {
// ink (vim's IncSearch): room for it in every theme.
c.hit_current = hold(hue, &.{page}, text_floor);
c.hit_current_text = page;
+ c.hit_faint = mixOklab(page, c.hit, 0.5);
// Every ground's inks; on the tags and the status row, the
// tag's selection rebuilt on each where it stands too near it.
@@ -1061,31 +1065,17 @@ pub fn synInk(th: *const LegacyTheme, sy: @import("syntax.zig").Syn) ?[3]u8 {
}
/// The grounds a style byte's high bits name (syntax.ground_add and the
-/// rest) in a theme: a row added or removed on a ground a little way from
-/// the page toward the theme's green or red (its own ANSI ones where it has
-/// a palette), a stronger one, a faint one, and the row's marker in that
-/// hue, pushed toward the ink until it reads on the row's ground. Syntax
-/// colours are drawn over a ground unchanged.
+/// rest) in a theme, for the library: its chrome's added and deleted rows
+/// (R10). Syntax colours are drawn over a ground unchanged.
pub const Grounds = struct {
add: Ground,
del: Ground,
- pub const Ground = struct { row: [3]u8, emph: [3]u8, line: [3]u8, ink: [3]u8 };
+ pub const Ground = Chrome.Diff;
pub fn of(th: *const LegacyTheme) Grounds {
- const page = th.bg orelse th.tag_bg;
- const ink = th.fg orelse th.tag_fg;
- const green: [3]u8 = if (th.palette) |pal| pal[2] else .{ 0x2e, 0xa0, 0x43 };
- const red: [3]u8 = if (th.palette) |pal| pal[1] else .{ 0xcf, 0x22, 0x2e };
- return .{ .add = ground(page, ink, green), .del = ground(page, ink, red) };
- }
-
- fn ground(page: [3]u8, ink: [3]u8, hue: [3]u8) Ground {
- const row = mixOklab(page, hue, 0.18);
- var marker = hue;
- var step: usize = 0;
- while (step < 4 and contrast(marker, row) < 3) : (step += 1) marker = mixOklab(marker, ink, 0.4);
- return .{ .row = row, .emph = mixOklab(page, hue, 0.28), .line = mixOklab(page, hue, 0.07), .ink = marker };
+ const c = Chrome.of(&.fromLegacy(th.*));
+ return .{ .add = c.add, .del = c.del };
}
/// The ground of a byte's hue, if it has one.
@@ -1294,17 +1284,13 @@ pub const ChromeTheme = struct {
border: [3]u8,
empty_col: [3]u8,
search_bg: [3]u8,
- search_fg: [3]u8,
tag_reading_bg: [3]u8,
diagnostic_error: [3]u8,
diagnostic_warning: [3]u8,
- diagnostic_info: [3]u8,
- diagnostic_hint: [3]u8,
box: [3]u8,
box_dim: [3]u8,
column_box: [3]u8,
column_box_dim: [3]u8,
- lineno: [3]u8,
scroll_track: [3]u8,
scroll_thumb: [3]u8,
roles: Roles,
@@ -1342,18 +1328,14 @@ pub const ChromeTheme = struct {
.border = separatorOf(th),
.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 = reading,
// 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),
.box = th.box,
.box_dim = th.box_dim,
.column_box = th.column_box orelse th.num,
.column_box_dim = th.column_box_dim orelse mix(th.column_box orelse th.num, th.tag_bg),
- .lineno = th.lineno,
.scroll_track = th.scroll_track,
.scroll_thumb = th.scroll_thumb,
.roles = .of(th, th.tag_bg, active_bg, reading),
@@ -1387,10 +1369,6 @@ pub const Roles = struct {
/// 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,
@@ -1403,8 +1381,6 @@ pub const Roles = struct {
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.5;
- pub const hit_current_floor: f32 = 1.9;
pub const reading_distance: f32 = 0.04;
pub fn on(r: *const Roles, ground: TagGround) *const RoleInks {
@@ -1436,20 +1412,6 @@ pub const Roles = struct {
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 if (th.palette) |pal| pal[1] else ink, &message_grounds, ink_floor);
@@ -1552,48 +1514,6 @@ fn selectionOf(own: [3]u8, ground: [3]u8, text: [3]u8) [3]u8 {
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); on toward the hue, the
-/// least way that stands off the page at `floor`, where the ink still
-/// reads on it; else 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 });
- }
- // Found by halves, seven mixes: the nearer the hue, the further off
- // the page (UX E7 7b: a landing line 1.5:1, its span 1.9:1).
- if (contrast(c, page) < floor and k < 1 and contrast(hue, page) >= floor) {
- var lo = k;
- var hi: f32 = 1;
- var far = hue;
- for (0..7) |_| {
- const mid = (lo + hi) / 2;
- const m = fromOklab(.{ a[0] + (b[0] - a[0]) * mid, a[1] + (b[1] - a[1]) * mid, a[2] + (b[2] - a[2]) * mid });
- if (contrast(m, page) < floor) lo = mid else {
- hi = mid;
- far = m;
- }
- }
- if (contrast(ink, far) >= ink_floor) c = far;
- }
- 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
@@ -1791,7 +1711,6 @@ pub fn loadThemeFile(p: *Pardes, generation: u32, bytes: []const u8) bool {
theme.name = view.name;
p.theme_chrome = .of(&theme, &view);
- p.body_chrome = .{ .theme = view, .chrome = p.theme_chrome };
const old = p.custom_theme;
p.custom_theme = view;
if (old) |theme_value| p.gpa.free(theme_value.name);
@@ -1828,13 +1747,10 @@ fn inOldNames(source: [:0]const u8) bool {
}
/// The session's theme's chrome, at its start (Pardes.init, a Restore):
-/// never one the window previews (`previewTheme`); the body's copy of it
-/// (Core.bodyChrome's, keyed by the theme) made with it, not again at the
-/// first frame.
+/// never one the window previews (`previewTheme`).
pub fn finishThemeInitialization(p: *Pardes) void {
const theme = if (p.custom_theme) |*custom| custom else &legacy_themes[p.settings.theme];
p.theme_chrome = if (p.custom_theme != null) .fromTheme(theme) else .of(&themes[p.settings.theme], theme);
- p.body_chrome = .{ .theme = theme.*, .chrome = p.theme_chrome };
}
/// Themes near `name`, a line of them, for a Theme given a name there is
@@ -1915,7 +1831,6 @@ pub fn previewTheme(p: *Pardes, index: ?usize) void {
if (p.theme_preview) |had| if (had == i) return;
p.theme_preview = @intCast(i);
p.preview_chrome = .of(&themes[i], &legacy_themes[i]);
- p.body_chrome = .{ .theme = legacy_themes[i], .chrome = p.preview_chrome };
}
pub fn setThemeIndex(p: *Pardes, index: usize) void {
@@ -1923,7 +1838,6 @@ pub fn setThemeIndex(p: *Pardes, index: usize) void {
(p.custom_theme == null and p.theme_file_path.get().len == 0 and
index == @as(usize, p.settings.theme))) return;
p.theme_chrome = .of(&themes[index], &legacy_themes[index]);
- p.body_chrome = .{ .theme = legacy_themes[index], .chrome = p.theme_chrome };
if (p.custom_theme) |theme_value| {
p.custom_theme = null;
p.gpa.free(theme_value.name);
@@ -2131,9 +2045,8 @@ test "native themes keep text and UI roles readable on their own surfaces" {
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{
- th.fg.?, th.kw, th.str, th.num, th.comment,
- chrome.diagnostic_error, chrome.diagnostic_warning, chrome.diagnostic_info, chrome.diagnostic_hint,
- };
+ th.fg.?, th.kw, th.str, th.num, th.comment,
+ } ++ chrome.resolved.page.severity;
for (text_colors) |fg| try std.testing.expect(contrast(fg, th.bg.?) >= minimum);
// Gutters are orientation aids, not source text: stay visible without
// competing with comments or pulling attention away from the body.
@@ -2153,7 +2066,7 @@ test "native themes keep text and UI roles readable on their own surfaces" {
try std.testing.expect(contrast(chrome.tag_active_bg, th.tag_bg) <= 1.6);
try std.testing.expect(contrast(chrome.tag_active_fg, th.tag_fg) <= 1.6);
try std.testing.expect(contrast(th.sel_fg, th.sel_bg) >= minimum);
- try std.testing.expect(contrast(chrome.search_fg, chrome.search_bg) >= minimum);
+ try std.testing.expect(contrast(chrome.resolved.hit_current_text, chrome.resolved.hit_current) >= Chrome.text_floor);
// ANSI black can intentionally match the page (for backgrounds). All
// other ANSI foregrounds, including bright black, remain legible.
for (th.palette.?[1..]) |fg| try std.testing.expect(contrast(fg, th.bg.?) >= minimum);
@@ -2219,6 +2132,7 @@ test "line numbers stay quiet without a current-line tag background" {
custom.lineno = .{ 70, 70, 70 };
custom.lineno_active = .{ 95, 95, 95 };
p.custom_theme = custom;
+ finishThemeInitialization(p);
p.sync();
const x = p.view().rects[0].x + config.GUTTER;
const y = p.view().rects[0].y + BOX_H;
@@ -2228,10 +2142,13 @@ test "line numbers stay quiet without a current-line tag background" {
try std.testing.expectEqual(Color{ .rgb = custom.bg.? }, surface.at(x, y).style.bg);
try std.testing.expect(surface.at(x, y).style.bold);
try std.testing.expect(!surface.at(x, y + 1).style.bold);
- // Old ThemeFile palettes need no new field, and do not regain the block.
+ // Old ThemeFile palettes need no new field: the current number is the
+ // text toward the page to 4.5:1 (R12), and the block not regained.
p.custom_theme.?.lineno_active = null;
+ finishThemeInitialization(p);
const fallback = try p.render(p.scratch.allocator());
- try std.testing.expectEqual(Color{ .rgb = .{ 70, 70, 70 } }, fallback.at(x, y).style.fg);
+ try std.testing.expectEqual(Color{ .rgb = p.chrome().line_number_current }, fallback.at(x, y).style.fg);
+ try std.testing.expect(contrast(p.chrome().line_number_current, custom.bg.?) >= Chrome.text_floor - 0.05);
try std.testing.expectEqual(Color{ .rgb = custom.bg.? }, fallback.at(x, y).style.bg);
try std.testing.expect(fallback.at(x, y).style.bold);
// Moving the caret clears the previous cue; editing the tag parks it.
@@ -2374,7 +2291,6 @@ test "every theme's walk UI roles meet their floors on every ground they are dra
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 ++ [1]RoleInks{r.notice}) |inks| {
@@ -2401,15 +2317,6 @@ test "every theme's walk UI roles meet their floors on every ground they are dra
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));
- // A preview's landing line 1.5:1 off the page, its matched span (the
- // current hit) a step stronger, 1.9:1 (UX E7 7b: 1.29 read as faint).
- for ([_][3]u8{ r.hit, r.hit_current }, [_]f32{ 1.5, 1.9 }) |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 });
diff --git a/core/draw.zig b/core/draw.zig
index 7f178bfb..e90535b5 100644
--- a/core/draw.zig
+++ b/core/draw.zig
@@ -842,8 +842,8 @@ fn renderHeaderLayer(p: *Pardes, layer: *pardes.Layer, kind: TagKind, id: u16, v
var col = panes.File.rawDisplayCol(p.settings.tab, shown, @max(swept.lo, start) - start) -| scroll;
const stop = panes.File.rawDisplayCol(p.settings.tab, shown, @min(swept.hi, end) - start) -| scroll;
while (col < stop and col < columns) : (col += 1) {
- surface.at(@intCast(col), 0).style.bg = .{ .rgb = body_layer.buttonTints(p.theme())[button] };
- surface.at(@intCast(col), 0).style.fg = .{ .rgb = body_layer.buttonInks(p.theme())[button] };
+ surface.at(@intCast(col), 0).style.bg = .{ .rgb = p.chrome().sweeps[button].ground };
+ surface.at(@intCast(col), 0).style.fg = .{ .rgb = p.chrome().sweeps[button].text };
}
}
} else |_| {};
@@ -1221,12 +1221,11 @@ fn paintPaneTag(p: *Pardes, s: *Surface, arena: std.mem.Allocator, pane: *Pane,
body_layer.paintPointerSelection(p, s, pane, r, sel, 0, preview_bg, null);
};
}
- const sel_btn = body_layer.buttonTints(th);
- const sel_ink = body_layer.buttonInks(th);
+ const sweeps = &p.chrome().sweeps;
for (pane.sel, 0..) |selection, button| {
if (selection.state == .none or (selection.state == .done and button != 0)) continue;
if (button == pardes.sel_slot or @min(selection.r0, selection.r1) >= rows) continue;
- body_layer.paintPointerSelection(p, s, pane, r, selection, 0, sel_btn[button], sel_ink[button]);
+ body_layer.paintPointerSelection(p, s, pane, r, selection, 0, sweeps[button].ground, sweeps[button].text);
}
}
diff --git a/core/look.zig b/core/look.zig
index 41c59cf3..d9dfe0e1 100644
--- a/core/look.zig
+++ b/core/look.zig
@@ -2134,8 +2134,9 @@ test "Look hover waits without mutating the pane and input cancels it" {
_ = frame.reset(.retain_capacity);
const surface = try p.render(frame.allocator());
+ // On the selection's faint half (R7); a tag's (below) is the tags' own.
+ try std.testing.expectEqual(Color{ .rgb = p.chrome().selection_secondary }, surface.at(word_x, body_y).style.bg);
const expected_bg = colors.mix(p.theme().bg orelse p.theme().tag_bg, colors.mix(p.theme().bg orelse p.theme().tag_bg, p.theme().sel_bg));
- try std.testing.expectEqual(Color{ .rgb = expected_bg }, surface.at(word_x, body_y).style.bg);
// Background traffic in another pane does not change the text or geometry
// under this pointer and must not strand a stationary hover unarmed.
diff --git a/core/root.zig b/core/root.zig
index 11cb5058..e07cbed6 100644
--- a/core/root.zig
+++ b/core/root.zig
@@ -764,11 +764,11 @@ test "what core/ asks of the machine is where the list says, with why: a new lin
/// state did not make it diverged a client: Pane.notices, then Tables'
/// reading, 2026-11-19). A file, its names, the reason.
const kept_out = [_]struct { []const u8, []const u8, []const u8 }{
- .{ "Core.zig", "surface facts frames own_frames theme_chrome frame_arena scratch echo undrawn", "the frame's own and the views drawn here: written by frames (and chrome by a theme's step), read by frames and the runner; no step reads them" },
+ .{ "Core.zig", "surface facts frames own_frames theme_chrome frame_arena scratch echo undrawn", "the frame's own and the views drawn here: written by frames (and chrome by a theme's step), read by frames and the runner, and the chrome by a query's rows for colours only (out of their digest, locations.Row.digest); no step's outcome reads them" },
.{ "Core.zig", "needs_frame", "whether to draw: steps set it, the loop reads it; no step's outcome reads it" },
.{ "Core.zig", "effects effects_head effects_len in_q in_head in_len opts dump_out dump_export tape", "this process's queues, options and tape, drained or set by its host" },
.{ "Core.zig", "shell_rows", "a terminal's rows as read here, swept at every update; the terminal's own digest covers its active area, not its history (Term.zig `calls`)" },
- .{ "Core.zig", "diff_output locations_cache tty_filter_palette body_chrome", "caches of pure functions of their key (a text, a theme): a step finds what it would make; a query row's colours from them are out of its digest (locations.Row.digest), and what a step asks a worker to paint is never decided by them (Stream.paintRows)" },
+ .{ "Core.zig", "diff_output locations_cache tty_filter_palette", "caches of pure functions of their key (a text, a theme): a step finds what it would make; a query row's colours from them are out of its digest (locations.Row.digest), and what a step asks a worker to paint is never decided by them (Stream.paintRows)" },
.{ "Core.zig", "retired_panes", "panes torn down this step, freed at its end" },
.{ "Core.zig", "theme_preview preview_chrome", "a themes picker's preview (colors.previewTheme): made from the live picker's cursor, in the digest with it, after every step (Pick.produceAll) and gone at its roll-up; a step reading a theme meanwhile reads the one its own state previews" },
.{ "Core.zig", "multi_first multi_stop multi_index multi_count exec_depth exec_column", "a step's own: set by a key's replay across the ranges (normal.replaySels) and a word's run (exec.zig), each put back before the step ends; between steps what `init` makes, so a load takes them as it makes them (a dump's said 2^30 ranges once: a yank sized its register by it)" },