summaryrefslogtreecommitdiff
path: root/core
diff options
context:
space:
mode:
Diffstat (limited to 'core')
-rw-r--r--core/Core.zig16
-rw-r--r--core/Messages.zig20
-rw-r--r--core/Trail.zig35
-rw-r--r--core/colors.zig23
-rw-r--r--core/draw.zig493
-rw-r--r--core/look.zig3
-rw-r--r--core/replica.zig16
-rw-r--r--core/surface.zig14
8 files changed, 329 insertions, 291 deletions
diff --git a/core/Core.zig b/core/Core.zig
index 3a2e1f51..e727d27d 100644
--- a/core/Core.zig
+++ b/core/Core.zig
@@ -2571,21 +2571,23 @@ test "topbar hover highlights exactly the executable word" {
const hovered = try p.render(frame.allocator());
for (0..word.len) |col| {
const cell = hovered.at(word.at + @as(u16, @intCast(col)), 0);
- try std.testing.expectEqual(Color{ .rgb = p.theme().sel_bg }, cell.style.bg);
- try std.testing.expectEqual(Color{ .rgb = p.theme().sel_fg }, cell.style.fg);
+ // Hovered, the page's half selection (DESIGN.md B5), the word in
+ // its ink.
+ try std.testing.expectEqual(Color{ .rgb = p.chrome().page.selection.secondary }, cell.style.bg);
+ try std.testing.expectEqual(Color{ .rgb = p.chrome().page.word }, cell.style.fg);
}
- try std.testing.expectEqual(Color{ .rgb = p.chromeTheme().tag_bg }, hovered.at(word.at + word.len, 0).style.bg);
+ try std.testing.expectEqual(Color{ .rgb = p.chrome().page.ground }, hovered.at(word.at + word.len, 0).style.bg);
p.update(.{ .mouse = .{ .button = .none, .kind = .motion, .col = word.at + word.len, .row = 0 } });
_ = frame.reset(.retain_capacity);
const whitespace = try p.render(frame.allocator());
- try std.testing.expectEqual(Color{ .rgb = p.chromeTheme().tag_bg }, whitespace.at(word.at + 1, 0).style.bg);
+ try std.testing.expectEqual(Color{ .rgb = p.chrome().page.ground }, whitespace.at(word.at + 1, 0).style.bg);
}
p.update(.pointer_leave);
_ = frame.reset(.retain_capacity);
const left = try p.render(frame.allocator());
- try std.testing.expectEqual(Color{ .rgb = p.chromeTheme().tag_bg }, left.at(words + 1, 0).style.bg);
+ try std.testing.expectEqual(Color{ .rgb = p.chrome().page.ground }, left.at(words + 1, 0).style.bg);
}
test "pane-tag Exec prefers Term and argument builtins before shell fallback" {
@@ -2935,9 +2937,9 @@ test "an empty column shows its theme's empty_col under its tag: acme's white, e
defer arena.deinit();
const s = try p.render(arena.allocator());
const cell = s.at(p.view().col_x[1] + 3, p.view().screen_h - 2);
- const want = p.chromeTheme().empty_col;
+ const want = p.chrome().empty_column;
try std.testing.expectEqual(want, cell.style.bg.rgb);
- if (std.mem.eql(u8, name, "acme")) try std.testing.expectEqual([3]u8{ 0xff, 0xff, 0xff }, want) else try std.testing.expectEqual(p.chromeTheme().border, want);
+ if (std.mem.eql(u8, name, "acme")) try std.testing.expectEqual([3]u8{ 0xff, 0xff, 0xff }, want) else try std.testing.expectEqual(p.chrome().rule, want);
}
}
diff --git a/core/Messages.zig b/core/Messages.zig
index fb2c3cde..1e03f4e0 100644
--- a/core/Messages.zig
+++ b/core/Messages.zig
@@ -425,20 +425,12 @@ pub fn markOf(m: *const Messages, pane: *const Pane) ?Kind {
return best;
}
-/// A kind's ink, for its glyph, its mark and its words at a line.
-pub fn ink(chrome: *const pardes.colors.ChromeTheme, kind: Kind) [3]u8 {
- return switch (kind) {
- .@"error" => chrome.roles.err,
- .warn => chrome.roles.warn,
- .question => chrome.roles.question,
- else => chrome.roles.hint,
- };
-}
-
-/// 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 {
+/// A message's ink on a ground of the chrome (R9), its glyph's, its
+/// mark's and its words': 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. `inks` a ground's (colors.Chrome.Inks)
+/// or a grip fill's (colors.Chrome.Marks).
+pub fn inkOn(inks: anytype, kind: Kind) [3]u8 {
return switch (kind) {
.@"error" => inks.severity[0],
.warn => inks.severity[1],
diff --git a/core/Trail.zig b/core/Trail.zig
index e42ab1e2..cd115018 100644
--- a/core/Trail.zig
+++ b/core/Trail.zig
@@ -701,7 +701,7 @@ fn tagGroundOf(p: *Pardes, arena: *std.heap.ArenaAllocator, id: usize) !pardes.C
return s.at(r.x + pardes.TAG_TEXT_INSET, p.tagTop(p.panes[id].?, r)).style.bg;
}
-test "a file's pane is reading, its tag in the reading tint with Keep after its path; typed into, it is held, and Jumps new-pane reads none" {
+test "a file's pane is reading, Keep after its path and its grip in the mode's mark, its tag on its focus's ground (DESIGN.md G1'); typed into, it is held, and Jumps new-pane reads none" {
const p = try Pardes.init(std.testing.allocator, .{ .tty_only = true, .cols = 80, .rows = 24 });
defer p.deinit();
var arena: std.heap.ArenaAllocator = .init(std.testing.allocator);
@@ -710,12 +710,14 @@ test "a file's pane is reading, its tag in the reading tint with Keep after its
const pane = try p.setTestFile("alpha\nbeta\n");
try std.testing.expect(reading(p, pane));
try std.testing.expect(std.mem.startsWith(u8, try tagOf(p, pane), "/test.txt Keep "));
- try std.testing.expectEqual(pardes.Color{ .rgb = p.chromeTheme().tag_reading_bg }, try tagGroundOf(p, &arena, 0));
+ try std.testing.expectEqual(pardes.Color{ .rgb = p.chrome().on(.focus).ground }, try tagGroundOf(p, &arena, 0));
+ try std.testing.expect(p.surface.region(.grip, 0).?.reading);
// Under Jumps new-pane nothing reads: the tag as it always was.
p.settings.jumps = .@"new-pane";
try std.testing.expect(!reading(p, pane));
try std.testing.expectEqualStrings("/test.txt Del ", try tagOf(p, pane));
- try std.testing.expectEqual(pardes.Color{ .rgb = p.chromeTheme().tag_active_bg }, try tagGroundOf(p, &arena, 0));
+ try std.testing.expectEqual(pardes.Color{ .rgb = p.chrome().on(.focus).ground }, try tagGroundOf(p, &arena, 0));
+ try std.testing.expect(!p.surface.region(.grip, 0).?.reading);
p.settings.jumps = .walk;
// Typed into: held from now on, though Undo takes the text back.
typeKeys(p, "ix");
@@ -724,7 +726,8 @@ test "a file's pane is reading, its tag in the reading tint with Keep after its
try std.testing.expectEqualStrings("alpha\nbeta\n", pane.file.?.content);
try std.testing.expect(!reading(p, pane));
try std.testing.expect(std.mem.indexOf(u8, try tagOf(p, pane), "Keep") == null);
- try std.testing.expectEqual(pardes.Color{ .rgb = p.chromeTheme().tag_active_bg }, try tagGroundOf(p, &arena, 0));
+ try std.testing.expectEqual(pardes.Color{ .rgb = p.chrome().on(.focus).ground }, try tagGroundOf(p, &arena, 0));
+ try std.testing.expect(!p.surface.region(.grip, 0).?.reading);
}
test "Keep holds a reading pane; a scratch and a listing are never reading" {
@@ -927,9 +930,9 @@ test "the session of pick-ui §6.7: four jumps across three files, back by a cli
var arena: std.heap.ArenaAllocator = .init(std.testing.allocator);
defer arena.deinit();
const s = try p.render(arena.allocator());
- // In the dim ink of the reading tag's ground (UX D4: 3:1 at least).
+ // In the dim ink of the focused tag's ground (UX D4: 3:1 at least).
const dim = try tagCell(p, r, "place.zig:40");
- try std.testing.expectEqual(pardes.Color{ .rgb = p.chromeTheme().roles.on(.reading_focused).dim }, s.at(dim[0], dim[1]).style.fg);
+ try std.testing.expectEqual(pardes.Color{ .rgb = p.chrome().on(.focus).dim }, s.at(dim[0], dim[1]).style.fg);
// A click on a forward step goes forward to it.
try clickTag(p, r, "place.zig:9", .left);
r = p.view().active;
@@ -982,11 +985,13 @@ test "the walk drawn with a picker's list and the notice row (walk UI G 2e, SPEC
try std.testing.expect(std.mem.startsWith(u8, try tagOf(p, p.panes[rd].?), try std.fmt.bufPrint(&want, "‹@p{d} › rank.zig:12 › Refs 1/2 › {s}/place.zig Keep ", .{ owner, f.dir })));
var arena: std.heap.ArenaAllocator = .init(std.testing.allocator);
defer arena.deinit();
- // The reader's tag in the reading tint, the held one's not; the notice
- // row says what Ctrl-o goes back to (UX L'1), and with nothing said,
- // where the reader's caret is.
- try std.testing.expectEqual(pardes.Color{ .rgb = p.chromeTheme().tag_reading_bg }, try tagGroundOf(p, &arena, rd));
- try std.testing.expect(!std.meta.eql(pardes.Color{ .rgb = p.chromeTheme().tag_reading_bg }, try tagGroundOf(p, &arena, f.held)));
+ // The reader's tag on the focused ground, the held one's on the plain
+ // (G1': the mode is on the reader's grip); the notice row says what
+ // Ctrl-o goes back to (UX L'1), and with nothing said, where the
+ // reader's caret is.
+ try std.testing.expectEqual(pardes.Color{ .rgb = p.chrome().on(.focus).ground }, try tagGroundOf(p, &arena, rd));
+ try std.testing.expectEqual(pardes.Color{ .rgb = p.chrome().on(.plain).ground }, try tagGroundOf(p, &arena, f.held));
+ try std.testing.expect(p.surface.region(.grip, rd).?.reading and !p.surface.region(.grip, f.held).?.reading);
for ([_][]const u8{ "C-o back to Refs 1/2", try std.fmt.bufPrint(&want, "{s}/place.zig:8", .{f.dir}) }) |said| {
const s = try p.render(arena.allocator());
const foot = s.region(.notice_row, pardes.Region.none).?.rect;
@@ -1020,8 +1025,8 @@ test "a trail keeps its newest three back steps whole, older ones fold into one
defer arena.deinit();
const s = try p.render(arena.allocator());
const fold = try tagCell(p, r, "+2");
- // In the dim ink of the reading tag's ground (UX D4).
- try std.testing.expectEqual(pardes.Color{ .rgb = p.chromeTheme().roles.on(.reading_focused).dim }, s.at(fold[0], fold[1]).style.fg);
+ // In the dim ink of the focused tag's ground (UX D4).
+ try std.testing.expectEqual(pardes.Color{ .rgb = p.chrome().on(.focus).dim }, s.at(fold[0], fold[1]).style.fg);
try clickTag(p, r, "+2", .right);
try std.testing.expectEqualStrings("rank.zig:20", f.at(&at));
// Back at the first: five forward steps, the two nearest whole.
@@ -1111,7 +1116,7 @@ test "a step whose tag would take a row its column cannot give folds to its newe
defer arena.deinit();
const s = try p.render(arena.allocator());
const base = try tagCell(p, r, "long.zig");
- try std.testing.expectEqual(pardes.Color{ .rgb = p.chromeTheme().tag_active_name_fg }, s.at(base[0], base[1]).style.fg);
+ try std.testing.expectEqual(pardes.Color{ .rgb = p.chrome().name[1] }, s.at(base[0], base[1]).style.fg);
// A click on the path drafts a name: the whole path, its caret where
// the click was (on the first byte shown after the `…`).
const after = v.rects[r];
@@ -1206,7 +1211,7 @@ test "two steps whose files have the same name are told apart by the shortest pa
const word = try tagCell(p, r, "Find x 1/2");
try std.testing.expect(s.at(word[0], word[1]).style.ul == .single);
// In the key ink (UX D8, D4).
- try std.testing.expectEqual(pardes.Color{ .rgb = p.chromeTheme().roles.key }, s.at(word[0], word[1]).style.fg);
+ try std.testing.expectEqual(pardes.Color{ .rgb = p.chrome().on(.focus).key }, s.at(word[0], word[1]).style.fg);
const other = try tagCell(p, r, "place.zig");
try std.testing.expect(s.at(other[0], other[1]).style.ul != .single);
}
diff --git a/core/colors.zig b/core/colors.zig
index 6c83f5c8..7be5f008 100644
--- a/core/colors.zig
+++ b/core/colors.zig
@@ -604,7 +604,9 @@ pub const Chrome = struct {
severity: [4][3]u8,
selection: Selection,
};
- pub const Selection = struct { ground: [3]u8, text: [3]u8, dim: [3]u8 };
+ /// A selection on a ground, and that ground halfway to it (OKLab): a
+ /// second range, a hovered word (B5).
+ pub const Selection = struct { ground: [3]u8, text: [3]u8, dim: [3]u8, secondary: [3]u8 };
pub const Ground = enum(u1) { plain, focus };
pub const Severity = enum(u2) { @"error", warning, info, hint };
/// A diff's rows: a row's ground, its changed words', a faint line's,
@@ -612,8 +614,16 @@ pub const Chrome = struct {
pub const Diff = struct { row: [3]u8, emph: [3]u8, line: [3]u8, ink: [3]u8 };
/// The grips: focused, its ring at rest, a reading pane's mark (its
/// ring; a terminal's cell) and that mark as a glyph on a focused grip,
- /// unsaved, a column's grabbed and at rest, and the ink on any fill.
- pub const Grip = struct { focus: [3]u8, ring: [3]u8, mode: [3]u8, mode_glyph: [3]u8, dirty: [3]u8, column: [3]u8, column_rest: [3]u8, ink: [3]u8 };
+ /// unsaved, a column's grabbed and at rest, the ink on any fill, and a
+ /// message's mark on each fill a pane's grip has in a grid (`Fill`).
+ pub const Grip = struct { focus: [3]u8, ring: [3]u8, mode: [3]u8, mode_glyph: [3]u8, dirty: [3]u8, column: [3]u8, column_rest: [3]u8, ink: [3]u8, marks: [4]Marks };
+ /// A pane's grip in a grid, a cell: focused, unsaved (its second cell),
+ /// at rest its ring, a reading pane's its mode's mark (R5', R6).
+ pub const Fill = enum(u2) { focus, dirty, ring, mode };
+ /// A message's mark on a fill (Messages.inkOn): the severities and the
+ /// dim ink held there; at rest and reading on the plain tag too, where
+ /// a window draws those grips hollow (gui.zig gripFill).
+ pub const Marks = struct { severity: [4][3]u8, dim: [3]u8 };
// The floors (B4's table).
pub const text_floor: f32 = 4.5;
@@ -777,6 +787,12 @@ pub const Chrome = struct {
c.grip.column_rest = towardOf(hold(column, &.{page}, ring_floor), page, ring_floor);
const fills = [5][3]u8{ c.grip.focus, c.grip.dirty, c.grip.column, c.grip.column_rest, c.grip.mode };
c.grip.ink = hold(if (leastContrast(page, &fills) >= leastContrast(tag_text, &fills)) page else tag_text, &fills, text_floor);
+ for (&c.grip.marks, [4][3]u8{ c.grip.focus, c.grip.dirty, c.grip.ring, c.grip.mode }, 0..) |*marks, fill, i| {
+ const both = [2][3]u8{ fill, tag };
+ const grounds_of = if (i < @intFromEnum(Fill.ring)) both[0..1] else both[0..];
+ for (&marks.severity, c.tag[0].severity) |*ink, own| ink.* = hold(own, grounds_of, text_floor);
+ marks.dim = hold(c.tag[0].dim, grounds_of, dim_floor);
+ }
// R10: added and deleted.
c.add = diffOf(page, text, th.added orelse ansi[2], dark);
@@ -995,6 +1011,7 @@ fn groundInks(th: *const Theme, ground: [3]u8, text: [3]u8, sel: [3]u8, sel_text
.ground = sel,
.text = sel_text,
.dim = towardOf(sel_text, sel, Chrome.dim_floor),
+ .secondary = mixOklab(ground, sel, 0.5),
},
};
}
diff --git a/core/draw.zig b/core/draw.zig
index 42396aa1..3d4c47b6 100644
--- a/core/draw.zig
+++ b/core/draw.zig
@@ -176,34 +176,6 @@ pub fn place(p: *Pardes, s: *Surface) void {
if (foot > 0) s.addRegion(.{ .kind = .notice_row, .rect = .{ .x = 0, .y = s.rows - foot, .w = s.cols, .h = foot } });
}
-/// A pane's grip in the grid: `box` focused, else halfway between its ring
-/// and `box_dim`, so it shows on its tag without the ring a pixel shell
-/// draws (gui.zig draws its button from the region and Chrome instead).
-/// A grip cell's colour: the focused pane's button, else its ring mixed
-/// with the box's dim fill; where that fill is the tag's own ground
-/// (acme's), a reading pane's is its tint, as a window rings a reading
-/// pane's tag ground (gui.zig gripFill).
-fn gripBg(p: *const Pardes, active: bool, reading: bool) [3]u8 {
- const chrome = p.chromeTheme();
- if (active) return chrome.box;
- const fill = if (reading and std.mem.eql(u8, &chrome.box_dim, &chrome.tag_bg)) chrome.tag_reading_bg else chrome.box_dim;
- return colors.mix(boxBorder(p), fill);
-}
-
-/// An unfocused grip's ring, and a dirty one's fill (colors.Theme).
-fn boxBorder(p: *const Pardes) [3]u8 {
- return p.theme().box_border orelse p.chromeTheme().box_dim;
-}
-pub fn boxDirty(p: *const Pardes) [3]u8 {
- const th = p.theme();
- return th.box_dirty orelse th.diagnostic_warning orelse th.num;
-}
-
-fn inkOn(bg: [3]u8) [3]u8 {
- const lum = (@as(u16, bg[0]) * 3 + @as(u16, bg[1]) * 6 + @as(u16, bg[2])) / 10;
- return if (lum > 140) .{ 0x00, 0x00, 0x00 } else .{ 0xff, 0xff, 0xff };
-}
-
const Printed = struct { left: u16, dropped: usize };
/// Prints `text` flush with the right edge of the band, and answers the
@@ -235,7 +207,7 @@ fn printRight(tab: u16, s: *Surface, x: u16, row: u16, w: u16, text: []const u8,
/// grid's chip a copy of its right end, where its text is.
fn joinNotice(p: *Pardes, s: *Surface, arena: std.mem.Allocator, region: Region) !void {
const v = p.view();
- const chrome = p.chromeTheme();
+ const plain = &p.chrome().tag[0];
const id: usize = region.owner;
const pane = p.panes[id].?;
const i: usize = region.notice;
@@ -243,8 +215,8 @@ fn joinNotice(p: *Pardes, s: *Surface, arena: std.mem.Allocator, region: Region)
const r = v.rects[id];
const chip = region.rect.w;
const text = Messages.noticeText(pane, i);
- const bg = chrome.tag_bg;
- const fg = chrome.tag_fg;
+ const bg = plain.ground;
+ const fg = plain.text;
// Nothing to say, or too narrow for a layer: a blank chip on the grid.
if (text.len == 0 or r.w <= TAG_TEXT_INSET) {
s.fill(region.rect.x, region.rect.y, chip, 1, .{ .bg = .{ .rgb = bg }, .font_role = .tagline });
@@ -275,7 +247,7 @@ fn joinNotice(p: *Pardes, s: *Surface, arena: std.mem.Allocator, region: Region)
@memset(line[0..pad], ' ');
@memcpy(line[pad..], kept);
const layer = &s.tag_layers[NOTICE_LAYER_BASE + id * Pane.Notices.max + i];
- try renderHeaderLayer(p, layer, .notice, @intCast(id), region.rect, line, 0, bg, fg);
+ try renderHeaderLayer(p, layer, .notice, @intCast(id), region.rect, line, 0, plain, .{ .rgb = bg }, fg);
// The caret rides the band, where the prompt's glyphs are.
if (kind == .prompt and id == v.active and pane.prompt != .del_side and pane.prompt != .repl_choice) caret: {
const typed = panes.File.displayWidth(p.settings.tab, text[0..@min(@as(usize, @intCast(@max(0, pane.input.cur_col))), text.len)]);
@@ -335,38 +307,37 @@ pub fn render(p: *Pardes, arena: std.mem.Allocator) !*Surface {
for (&s.tag_layers) |*layer| layer.rows = 0;
s.placements.clearRetainingCapacity();
@memset(&s.gpu_frames, null);
- const chrome = p.chromeTheme();
- // The window's rules and grips from the chrome (the themes programme's
- // L2e; DESIGN.md R6, R11, G1').
- const resolved = p.chrome();
+ // The window's chrome (DESIGN.md B6): its rules, grips, the tags' two
+ // grounds (G1': a reading pane's is its focus's), and the window and
+ // column rows on the page (H).
+ const chrome = p.chrome();
s.chrome = .{
- .page = p.theme().bg,
- .fg = p.theme().fg,
- .border = resolved.rule,
- .topbar_rule = config.gui_topbar_pane_border_rgb orelse resolved.rule,
- .tag_bg = chrome.tag_bg,
- .tagline_bg = chrome.tagline_bg,
- .tag_focus_bg = chrome.tag_active_bg,
- .tag_reading_bg = chrome.tag_reading_bg,
- .tag_fg = chrome.tag_fg,
- .scroll_track = chrome.scroll_track,
- .scroll_thumb = chrome.scroll_thumb,
- .match_tick = chrome.search_bg,
- .match_current = p.theme().fg orelse chrome.tag_fg,
- .rule_px = resolved.rule_px,
- .grip_border = resolved.grip.ring,
- .grip_focus_ring = resolved.grip.focus,
- .grip_dirty = resolved.grip.dirty,
- .grip_mode = resolved.grip.mode,
- .grip_ink = resolved.grip.ink,
- .tag_rule = resolved.tag_rule,
- .rail_px = @intCast(@min(255, @as(u32, resolved.rail_px) * p.settings.grip_width / 100)),
+ .page = if (chrome.host_page) null else chrome.page.ground,
+ .fg = if (chrome.host_page) null else chrome.page.text,
+ .border = chrome.rule,
+ .topbar_rule = config.gui_topbar_pane_border_rgb orelse chrome.rule,
+ .tag_bg = chrome.tag[0].ground,
+ .tagline_bg = chrome.page.ground,
+ .tag_focus_bg = chrome.tag[1].ground,
+ .tag_fg = chrome.tag[0].text,
+ .scroll_track = chrome.rail,
+ .scroll_thumb = chrome.rail_thumb,
+ .match_tick = chrome.hit,
+ .match_current = chrome.hit_current,
+ .rule_px = chrome.rule_px,
+ .grip_border = chrome.grip.ring,
+ .grip_focus_ring = chrome.grip.focus,
+ .grip_dirty = chrome.grip.dirty,
+ .grip_mode = chrome.grip.mode,
+ .grip_ink = chrome.grip.ink,
+ .tag_rule = chrome.tag_rule,
+ .rail_px = @intCast(@min(255, @as(u32, chrome.rail_px) * p.settings.grip_width / 100)),
};
place(p, s);
// Separators have their own role; a scrollbar need not frame the page.
const whole = s.regions[0].rect;
- s.fill(whole.x, whole.y, whole.w, whole.h, .{ .bg = .{ .rgb = chrome.border } });
- for (0..p.view().ncol) |c| if (v.cols[c].n == 0) s.fill(v.col_x[c], p.topBarHeight() + layout.columnBarHeight(p), v.col_w[c], s.rows -| (p.topBarHeight() + layout.columnBarHeight(p) + layout.noticeRowHeight(p)), .{ .bg = .{ .rgb = chrome.empty_col } });
+ s.fill(whole.x, whole.y, whole.w, whole.h, .{ .bg = .{ .rgb = chrome.rule } });
+ for (0..p.view().ncol) |c| if (v.cols[c].n == 0) s.fill(v.col_x[c], p.topBarHeight() + layout.columnBarHeight(p), v.col_w[c], s.rows -| (p.topBarHeight() + layout.columnBarHeight(p) + layout.noticeRowHeight(p)), .{ .bg = .{ .rgb = chrome.empty_column } });
for (&p.panes, 0..) |*slot, id| {
const pane = slot.* orelse continue;
@@ -383,7 +354,7 @@ pub fn render(p: *Pardes, arena: std.mem.Allocator) !*Surface {
const y = p.tagTop(pane, r) + pane.tag_rows;
const rows = @min(at.over, r.h -| pane.tag_rows);
if (rows > 0) {
- s.fill(r.x, y, config.GUTTER, rows, .{ .bg = .{ .rgb = tagGround(p, pane, id == v.active) }, .font_role = .tagline });
+ s.fill(r.x, y, config.GUTTER, rows, .{ .bg = .{ .rgb = chrome.on(if (id == v.active) .focus else .plain).ground }, .font_role = .tagline });
if (s.cursor) |c| if (c.x >= r.x and c.x < r.x + r.w and c.y >= y and c.y < y + rows) {
s.cursor = null;
};
@@ -454,12 +425,12 @@ pub fn render(p: *Pardes, arena: std.mem.Allocator) !*Surface {
s.set(ox, by, "│", .{});
s.set(ox + ow - 1, by, "│", .{});
}
- s.fill(ox + 1, p.topBarHeight() + 1, ow - 2, oh - 2, .{ .bg = .{ .rgb = chrome.scroll_track } });
+ s.fill(ox + 1, p.topBarHeight() + 1, ow - 2, oh - 2, .{ .bg = .{ .rgb = chrome.rail } });
var lines = std.mem.splitScalar(u8, text, '\n');
var ly: u16 = p.topBarHeight() + 1;
while (lines.next()) |line| : (ly += 1) {
if (ly >= p.topBarHeight() + oh - 1) break;
- _ = s.print(ox + 1, ly, ow - 2, line, .{ .fg = .{ .rgb = chrome.tag_fg } });
+ _ = s.print(ox + 1, ly, ow - 2, line, .{ .fg = .{ .rgb = chrome.tag[0].text } });
}
}
};
@@ -470,13 +441,12 @@ fn renderPane(p: *Pardes, s: *Surface, arena: std.mem.Allocator, pane: *Pane, r:
const tz = tracy.zone(@src(), "renderPane");
defer tz.end();
if (r.w <= config.GUTTER or r.h == 0) return;
- const th = p.theme();
- const chrome = p.chromeTheme();
+ const chrome = p.chrome();
const tx = r.x + config.GUTTER; // text area (tag + body), right of the gutter
const tw = r.w - config.GUTTER;
const tag_y = p.tagTop(pane, r);
const body_y = p.bodyTop(pane, r);
- const pane_bg: Color = if (th.bg) |c| .{ .rgb = c } else .default;
+ const pane_bg: Color = if (chrome.host_page) .default else .{ .rgb = chrome.page.ground };
// text area resets to terminal-default cells (vaxis clear semantics);
// light themes paint the page over it.
@@ -485,19 +455,26 @@ fn renderPane(p: *Pardes, s: *Surface, arena: std.mem.Allocator, pane: *Pane, r:
const tz_clear = tracy.zone(@src(), "paneClear");
defer tz_clear.end();
s.clearRect(tx, r.y, tw, r.h);
- if (th.bg) |bg| s.fill(tx, r.y, tw, r.h, .{ .bg = .{ .rgb = bg } });
+ if (!chrome.host_page) s.fill(tx, r.y, tw, r.h, .{ .bg = pane_bg });
}
// The grip is acme's button: the focused pane's filled, the others'
- // a ring round the tag's ground, a dirty one's the dirty colour inside
- // its ring. A pixel shell draws the ring (gui.zig gripDecor); a grid,
- // which cannot, marks dirty in the grip's second cell with a bold `*`
- // on the dirty colour, a cue that survives any palette.
- const band = tagGround(p, pane, active);
+ // a ring round the tag's ground, a reading one's in the mode's mark
+ // (G1'), a dirty one's the dirty colour inside its ring. A pixel shell
+ // draws the ring (gui.zig gripDecor); a grid, which cannot, fills the
+ // cell: the ring at rest, the mode's mark reading, the focused one's
+ // glyph in the mode's mark where it reads (R5'); and marks dirty in
+ // the grip's second cell with a bold `*` on the dirty colour, a cue
+ // that survives any palette.
+ const band = chrome.on(if (active) .focus else .plain).ground;
const dirty = tagline.dirty(pane);
- const box_bg = gripBg(p, active, pardes.Trail.reading(p, pane));
+ const reading = pardes.Trail.reading(p, pane);
+ const grip = &chrome.grip;
+ const fill: colors.Chrome.Fill = if (active) .focus else if (reading) .mode else .ring;
+ const fills = [4][3]u8{ grip.focus, grip.dirty, grip.ring, grip.mode };
+ const box_bg = fills[@intFromEnum(fill)];
const box_style: CellStyle = .{
- .fg = .{ .rgb = inkOn(box_bg) },
+ .fg = .{ .rgb = if (fill == .ring) chrome.tag[0].text else if (fill == .focus and reading) grip.mode_glyph else grip.ink },
.bg = .{ .rgb = box_bg },
// Grips keep physical grid dimensions, independently of tag text.
.font_role = .tagline,
@@ -507,13 +484,15 @@ fn renderPane(p: *Pardes, s: *Surface, arena: std.mem.Allocator, pane: *Pane, r:
// as acme's button column does).
s.fill(r.x, tag_y, config.GUTTER, @min(1, pane.tag_rows), box_style);
if (dirty and pane.tag_rows > 0 and config.GUTTER > 1)
- s.set(r.x + config.GUTTER - 1, tag_y, "*", .{ .fg = .{ .rgb = inkOn(boxDirty(p)) }, .bg = .{ .rgb = boxDirty(p) }, .bold = true, .font_role = .tagline });
+ s.set(r.x + config.GUTTER - 1, tag_y, "*", .{ .fg = .{ .rgb = grip.ink }, .bg = .{ .rgb = grip.dirty }, .bold = true, .font_role = .tagline });
// The mark (pick-ui SPEC §2): the status of the most important live
// message about the pane, in the box's second cell, on the dirty ground
// when there is unsaved text: a cell of the box's, never the tag's
// text, so it moves nothing.
- if (pane.tag_rows > 0 and config.GUTTER > 1) if (p.messages.markOf(pane)) |kind|
- s.set(r.x + config.GUTTER - 1, tag_y, kind.glyph(), .{ .fg = .{ .rgb = Messages.ink(chrome, kind) }, .bg = .{ .rgb = if (dirty) boxDirty(p) else box_bg }, .bold = true, .font_role = .tagline });
+ if (pane.tag_rows > 0 and config.GUTTER > 1) if (p.messages.markOf(pane)) |kind| {
+ const on: colors.Chrome.Fill = if (dirty) .dirty else fill;
+ s.set(r.x + config.GUTTER - 1, tag_y, kind.glyph(), .{ .fg = .{ .rgb = Messages.inkOn(&grip.marks[@intFromEnum(on)], kind) }, .bg = .{ .rgb = if (dirty) grip.dirty else box_bg }, .bold = true, .font_role = .tagline });
+ };
s.fill(r.x, tag_y + 1, config.GUTTER, pane.tag_rows -| 1, .{
.bg = .{ .rgb = band },
.font_role = .tagline,
@@ -549,14 +528,14 @@ fn renderPane(p: *Pardes, s: *Surface, arena: std.mem.Allocator, pane: *Pane, r:
if (!pardes.Kind.draw(p, s, arena, pane, id, tx, body_y + shown, tw, body_h) and body_h > 0 and pardes.Pick.previewing(p, id)) {
const k = pane.addon.?;
if (pardes.Pick.nameLine(arena, k.path, k.nameOf(), k.size, "")) |line| {
- _ = s.print(tx, body_y + shown, tw, line, .{ .fg = if (th.fg) |c| .{ .rgb = c } else .default, .bg = pane_bg });
+ _ = s.print(tx, body_y + shown, tw, line, .{ .fg = if (chrome.host_page) .default else .{ .rgb = chrome.page.text }, .bg = pane_bg });
} else |_| {}
}
// The same one column as the real scrollbar below, running past
// the notice bands so the gutter has no notch in it; its thumb
// where this frame's paint said its window is in its whole (a
// PDF's strip), none for a kind that said nothing (an image).
- s.fill(rail.rect.x, rail.rect.y, 1, rail.rect.h, .{ .bg = .{ .rgb = chrome.scroll_track } });
+ s.fill(rail.rect.x, rail.rect.y, 1, rail.rect.h, .{ .bg = .{ .rgb = chrome.rail } });
s.fill(rail.rect.x + 1, rail.rect.y, 1, rail.rect.h, .{ .bg = pane_bg });
const k = pane.addon.?;
// (a body of no rows has no thumb: a pane squeezed to its tag)
@@ -566,7 +545,7 @@ fn renderPane(p: *Pardes, s: *Surface, arena: std.mem.Allocator, pane: *Pane, r:
rail.thumb_h = @intFromFloat(@min(track - @as(f32, @floatFromInt(rail.thumb_y)), @max(1, k.thumb_span * track)));
rail.thumb_at = k.thumb_at;
rail.thumb_span = k.thumb_span;
- s.fill(rail.rect.x, rail.rect.y + rail.thumb_y, 1, rail.thumb_h, .{ .bg = .{ .rgb = chrome.scroll_thumb } });
+ s.fill(rail.rect.x, rail.rect.y + rail.thumb_y, 1, rail.thumb_h, .{ .bg = .{ .rgb = chrome.rail_thumb } });
}
return;
}
@@ -581,7 +560,7 @@ fn renderPane(p: *Pardes, s: *Surface, arena: std.mem.Allocator, pane: *Pane, r:
if (pane.layers.heat > 0) @import("jj.zig").railHeat(p, s, pane, id, rail.rect);
// A terminal panned to its cursor in a view shorter than it: an arrow
// in the gutter's first body row says rows are above (views.zig).
- if (pane.pan > 0) s.set(r.x, p.bodyTop(pane, r), "↑", .{ .fg = .{ .rgb = chrome.box } });
+ if (pane.pan > 0) s.set(r.x, p.bodyTop(pane, r), "↑", .{ .fg = .{ .rgb = chrome.page.key } });
// A query's places' ticks, each in the track's cell of its row: chrome,
// painted with the rail (a pixel shell draws its own from the same list).
for (s.rail_ticks[0..s.nrail_ticks]) |tick| {
@@ -595,27 +574,34 @@ fn renderPane(p: *Pardes, s: *Surface, arena: std.mem.Allocator, pane: *Pane, r:
/// rows copies of those; the column grips, which are the grid's alone.
fn paintHeaders(p: *Pardes, s: *Surface) !void {
const v = p.view();
- const chrome = p.chromeTheme();
+ const chrome = p.chrome();
+ // The window row and the column tags are chrome words on the page, no
+ // band and no focus (DESIGN.md H): `page.word`, every word of them; a
+ // terminal's own page where the theme leaves it to the host.
+ const page = &chrome.page;
+ const page_bg: Color = if (chrome.host_page) .default else .{ .rgb = page.ground };
+ const column_rows = layout.columnBarHeight(p);
+ // A window draws its underlay under them in the page too (gui.zig).
+ s.chrome.tagline_rows = @intCast(p.topBarHeight() + column_rows);
// global tagbar: full width, top rows — unless a native shell has
// taken its commands over, in which case the rows are not ours to draw
if (s.region(.workspace_tag, Region.none)) |region| {
const top = if (v.header != null and p.headerColumn() == null) v.header_top else 0;
const layer = &s.tag_layers[MAX_PANES + MAX_COLS];
- s.chrome.tagline_rows = @intCast(region.rect.y + region.rect.h);
- // The window row (UX K'2), on the tagline's ground end to end: a
- // lone column's tag at its left (its region), in the row's inks;
- // the window's at its right end (tagline.windowRow).
- s.fill(region.rect.x, region.rect.y, region.rect.w, region.rect.h, .{ .bg = .{ .rgb = chrome.tagline_bg }, .fg = .{ .rgb = chrome.tagline_fg }, .font_role = .tagline });
+ // The window row (UX K'2), on the page end to end: a lone column's
+ // tag at its left (its region), in the row's inks; the window's at
+ // its right end (tagline.windowRow).
+ s.fill(region.rect.x, region.rect.y, region.rect.w, region.rect.h, .{ .bg = page_bg, .fg = .{ .rgb = page.word }, .font_role = .tagline });
if (s.region(.column_tag, 0)) |column| if (column.rect.y < region.rect.y + region.rect.h) {
const column_top = if (v.header != null and p.headerColumn() == 0) v.header_top else 0;
const column_layer = &s.tag_layers[MAX_PANES];
- try renderHeaderLayer(p, column_layer, .column, 0, column.rect, tagline.columnTag(p, 0), column_top, chrome.tagline_bg, chrome.tagline_fg);
- joinHeaderRows(s, column_layer, chrome.tagline_fg);
+ try renderHeaderLayer(p, column_layer, .column, 0, column.rect, tagline.columnTag(p, 0), column_top, page, page_bg, page.word);
+ joinHeaderRows(s, column_layer, page.word);
};
const words = tagline.windowRow(p).words;
const viewport: Rect = .{ .x = words, .y = region.rect.y, .w = region.rect.w -| words, .h = region.rect.h };
const text = tagline.topbar(p);
- try renderHeaderLayer(p, layer, .workspace, 0, viewport, text, top, chrome.tagline_bg, chrome.tagline_fg);
+ try renderHeaderLayer(p, layer, .workspace, 0, viewport, text, top, page, page_bg, page.word);
// A server's progress (a message of no pane) at its first row's
// right end, where the row has room for it.
if (layer.rows > 0 and top == 0) if (tagline.sessionProgress(p)) |said| {
@@ -625,33 +611,28 @@ fn paintHeaders(p: *Pardes, s: *Surface) !void {
const used = panes.File.displayWidth(p.settings.tab, modal.lineSlice(text, 0));
const room = layout.tagCapacity(p, viewport.w);
var row: Surface = .{ .cols = layer.cols, .rows = 1, .cells = layer.cells[0..layer.cols], .tab = p.settings.tab };
- if (used + 2 + width < room) _ = row.print(@intCast(room - 1 - width), 0, @intCast(width), shown, .{ .fg = .{ .rgb = Messages.ink(chrome, .progress) }, .bg = .{ .rgb = chrome.tagline_bg }, .font_role = .tagline });
+ if (used + 2 + width < room) _ = row.print(@intCast(room - 1 - width), 0, @intCast(width), shown, .{ .fg = .{ .rgb = Messages.inkOn(page, .progress) }, .bg = page_bg, .font_role = .tagline });
};
- joinHeaderRows(s, layer, chrome.tagline_fg);
+ joinHeaderRows(s, layer, page.word);
}
- const column_rows = layout.columnBarHeight(p);
if (column_rows > 0) for (0..p.view().ncol) |c| {
const region = s.region(.column_tag, c) orelse continue;
- const active = if (layout.findPane(p, v.active)) |found| found.col == c else false;
- const bg = if (active) chrome.tag_active_bg else chrome.tag_bg;
- const fg = if (active) chrome.tag_active_fg else chrome.tag_fg;
if (v.col_x[c] < s.cols) {
- // A grip is muted until it is grabbed; then it lights, as a
- // pane's box does for the active pane, so the drag shows what it
- // holds.
+ // A grip is a step quieter than a pane's at rest (2:1, H) until
+ // it is grabbed; then it lights (3:1), so the drag shows what it
+ // holds. It never shows focus.
const grip = @min(config.GUTTER, v.col_w[c]);
const inset = @min(TAG_TEXT_INSET, v.col_w[c]);
const grabbed = v.drag == .column_move and layout.columnBySerial(p, v.drag.column_move.serial) == c;
- const grip_bg = if (grabbed) chrome.column_box else chrome.column_box_dim;
- const ink = inkOn(grip_bg);
- s.fill(v.col_x[c], region.rect.y, grip, @min(1, column_rows), .{ .bg = .{ .rgb = grip_bg }, .fg = .{ .rgb = ink }, .font_role = .tagline });
- s.fill(v.col_x[c], region.rect.y + 1, grip, column_rows -| 1, .{ .bg = .{ .rgb = bg }, .font_role = .tagline });
- s.fill(v.col_x[c] + grip, region.rect.y, inset - grip, column_rows, .{ .bg = .{ .rgb = bg }, .font_role = .tagline });
+ const grip_bg = if (grabbed) chrome.grip.column else chrome.grip.column_rest;
+ s.fill(v.col_x[c], region.rect.y, grip, @min(1, column_rows), .{ .bg = .{ .rgb = grip_bg }, .fg = .{ .rgb = chrome.grip.ink }, .font_role = .tagline });
+ s.fill(v.col_x[c], region.rect.y + 1, grip, column_rows -| 1, .{ .bg = page_bg, .font_role = .tagline });
+ s.fill(v.col_x[c] + grip, region.rect.y, inset - grip, column_rows, .{ .bg = page_bg, .font_role = .tagline });
}
const top = if (v.header != null and p.headerColumn() == c) v.header_top else 0;
const layer = &s.tag_layers[MAX_PANES + c];
- try renderHeaderLayer(p, layer, .column, @intCast(c), region.rect, tagline.columnTag(p, c), top, bg, fg);
- if (v.col_x[c] < s.cols) joinHeaderRows(s, layer, fg);
+ try renderHeaderLayer(p, layer, .column, @intCast(c), region.rect, tagline.columnTag(p, c), top, page, page_bg, page.word);
+ if (v.col_x[c] < s.cols) joinHeaderRows(s, layer, page.word);
};
}
@@ -661,20 +642,20 @@ fn paintHeaders(p: *Pardes, s: *Surface) !void {
/// counts at the right end dimmed.
fn paintNoticeRow(p: *Pardes, s: *Surface) !void {
const region = s.region(.notice_row, Region.none) orelse return;
- const chrome = p.chromeTheme();
+ // The notice row's own ground and inks (DESIGN.md H: `status`).
+ const status = &p.chrome().status;
var viewport = region.rect;
const inset = @min(TAG_TEXT_INSET, viewport.w);
- s.fill(viewport.x, viewport.y, inset, viewport.h, .{ .bg = .{ .rgb = chrome.tagline_bg }, .font_role = .tagline });
+ s.fill(viewport.x, viewport.y, inset, viewport.h, .{ .bg = .{ .rgb = status.ground }, .font_role = .tagline });
viewport.x += inset;
viewport.w -= inset;
var buf: [Messages.notice_row_cap]u8 = undefined;
const row = Messages.noticeRow(p, layout.tagCapacity(p, viewport.w) -| 1, &buf);
const layer = &s.tag_layers[pardes.NOTICE_ROW_LAYER];
- try renderHeaderLayer(p, layer, .notice_row, 0, viewport, row.text, 0, chrome.tagline_bg, chrome.tagline_fg);
+ try renderHeaderLayer(p, layer, .notice_row, 0, viewport, row.text, 0, status, .{ .rgb = status.ground }, status.text);
if (layer.rows == 0) return;
- // The dim ink of the notice row's ground (colors.Roles: 3:1 at least).
- const dim: Color = .{ .rgb = chrome.roles.notice.dim };
- const ink: Color = .{ .rgb = chrome.tagline_fg };
+ const dim: Color = .{ .rgb = status.dim };
+ const ink: Color = .{ .rgb = status.text };
const cells = layer.cells[0..layer.cols];
const tab = p.settings.tab;
const left = @min(cells.len, panes.File.displayWidth(tab, row.text[0..row.left]));
@@ -689,7 +670,7 @@ fn paintNoticeRow(p: *Pardes, s: *Surface) !void {
}
if (row.lead) |lead| {
if (lead.kind == .@"error" or lead.kind == .warn) if (cells.len > 0 and std.meta.eql(cells[0].style.fg, ink)) {
- cells[0].style.fg = .{ .rgb = if (lead.kind == .@"error") chrome.diagnostic_error else chrome.diagnostic_warning };
+ cells[0].style.fg = .{ .rgb = Messages.inkOn(status, lead.kind) };
};
if (lead.faded(p.clock.now_ns, p.settings.message_linger_ms)) for (cells[0..left]) |*cell| {
if (std.meta.eql(cell.style.fg, ink)) cell.style.fg = dim;
@@ -698,7 +679,7 @@ fn paintNoticeRow(p: *Pardes, s: *Surface) !void {
for (cells[right..]) |*cell| if (std.meta.eql(cell.style.fg, ink)) {
cell.style.fg = dim;
};
- joinHeaderRows(s, layer, chrome.tagline_fg);
+ joinHeaderRows(s, layer, status.text);
}
/// Copy a header's layer into the grid under it, row by row, and its caret.
@@ -769,8 +750,10 @@ fn tagTintRange(p: *const Pardes, pane: *const Pane, tag: []const u8, prefix_len
/// A header or a notice band as a tag layer: `viewport.h` rows, line `top`
/// of `text` and on, laid out at the tagline's pitch -- as wide as its
-/// widest line and never narrower than its viewport.
-fn renderHeaderLayer(p: *Pardes, layer: *pardes.Layer, kind: TagKind, id: u16, viewport: Rect, text: []const u8, top: usize, bg: [3]u8, fg: [3]u8) !void {
+/// widest line and never narrower than its viewport -- on the ground of
+/// `inks` (`ground` in a cell: a terminal's own page where the theme leaves
+/// it to the host), in `fg`.
+fn renderHeaderLayer(p: *Pardes, layer: *pardes.Layer, kind: TagKind, id: u16, viewport: Rect, text: []const u8, top: usize, inks: *const colors.Chrome.Inks, ground: Color, fg: [3]u8) !void {
const v = p.view();
if (viewport.w == 0 or viewport.h == 0) {
// No layer, and nothing of an earlier frame's left in it.
@@ -791,7 +774,7 @@ fn renderHeaderLayer(p: *Pardes, layer: *pardes.Layer, kind: TagKind, id: u16, v
layer.cols = columns;
layer.rows = viewport.h;
layer.context_rows = 0;
- layer.bg = bg;
+ layer.bg = inks.ground;
layer.cursor = null;
// A notice band carries a PANE id, not a column index, so it must not
// answer to the column being edited -- that would scroll and select
@@ -806,9 +789,9 @@ fn renderHeaderLayer(p: *Pardes, layer: *pardes.Layer, kind: TagKind, id: u16, v
const line: u16 = @intCast(index);
const shown = modal.lineSlice(text, index + top);
var surface: Surface = .{ .cols = columns, .rows = 1, .cells = layer.cells[index * columns ..][0..columns], .tab = p.settings.tab };
- surface.fill(0, 0, columns, 1, .{ .bg = .{ .rgb = bg }, .font_role = .tagline });
+ surface.fill(0, 0, columns, 1, .{ .bg = ground, .font_role = .tagline });
// The scroll is the caret's line's: a shorter line shows nothing.
- _ = surface.print(0, 0, columns, shown[@min(shown.len, panes.File.rawAtDisplay(p.settings.tab, shown, scroll))..], .{ .fg = .{ .rgb = fg }, .bg = .{ .rgb = bg }, .font_role = .tagline });
+ _ = surface.print(0, 0, columns, shown[@min(shown.len, panes.File.rawAtDisplay(p.settings.tab, shown, scroll))..], .{ .fg = .{ .rgb = fg }, .bg = ground, .font_role = .tagline });
// The word under the pointer, a Look or Exec target: on a header even
// while it is edited, on a notice, and on the grid's copy of either
// (joined from this); not on a column a carried column's pointer is
@@ -826,10 +809,7 @@ fn renderHeaderLayer(p: *Pardes, layer: *pardes.Layer, kind: TagKind, id: u16, v
if (col) |hover| if (wordBoundsAtCol(shown, panes.File.rawAtDisplay(p.settings.tab, shown, hover + scroll))) |bounds| {
var cell = panes.File.rawDisplayCol(p.settings.tab, shown, bounds.lo) -| scroll;
const end = panes.File.rawDisplayCol(p.settings.tab, shown, bounds.hi) -| scroll;
- while (cell < end and cell < columns) : (cell += 1) {
- surface.at(@intCast(cell), 0).style.bg = .{ .rgb = p.theme().tag_sel_bg orelse p.theme().sel_bg };
- surface.at(@intCast(cell), 0).style.fg = .{ .rgb = p.theme().sel_fg };
- }
+ while (cell < end and cell < columns) : (cell += 1) surface.at(@intCast(cell), 0).style.bg = .{ .rgb = inks.selection.secondary };
};
}
if (editing) |t| {
@@ -837,8 +817,8 @@ fn renderHeaderLayer(p: *Pardes, layer: *pardes.Layer, kind: TagKind, id: u16, v
var col = panes.File.rawDisplayCol(p.settings.tab, shown, span.lo) -| scroll;
const end = panes.File.rawDisplayCol(p.settings.tab, shown, span.hi) -| scroll;
while (col < end and col < columns) : (col += 1) {
- surface.at(@intCast(col), 0).style.bg = .{ .rgb = p.theme().tag_sel_bg orelse p.theme().sel_bg };
- surface.at(@intCast(col), 0).style.fg = .{ .rgb = p.theme().sel_fg };
+ surface.at(@intCast(col), 0).style.bg = .{ .rgb = inks.selection.ground };
+ surface.at(@intCast(col), 0).style.fg = .{ .rgb = inks.selection.text };
}
}
const caret = panes.File.rawDisplayCol(p.settings.tab, shown, @min(@as(usize, @intCast(@max(0, t.cur_col))), shown.len)) -| scroll;
@@ -878,7 +858,7 @@ fn joinPaneTag(p: *Pardes, s: *Surface, arena: std.mem.Allocator, pane: *Pane, r
const capacity = layout.tagCapacity(p, r.w -| TAG_TEXT_INSET);
// Too narrow for a layer: only the grid's gap cell.
if (r.w <= TAG_TEXT_INSET) return paintPaneTag(p, s, arena, pane, r, id, active, rows);
- const chrome = p.chromeTheme();
+ const inks = p.chrome().on(if (active) .focus else .plain);
const region = s.region(.tag, id).?;
const tag = (try tagline.shownTag(p, arena, pane)).text;
// As wide as the widest row it shows, and never narrower than its
@@ -894,11 +874,13 @@ fn joinPaneTag(p: *Pardes, s: *Surface, arena: std.mem.Allocator, pane: *Pane, r
var temporary: Surface = .{ .cols = columns + TAG_TEXT_INSET, .rows = rows, .cells = storage, .tab = p.settings.tab };
try paintPaneTag(p, &temporary, arena, pane, .{ .x = 0, .y = 0, .w = columns + TAG_TEXT_INSET, .h = rows }, id, active, rows);
// Window mode (layout.windowKey): the outlined pane's tag in the
- // selection's colours.
+ // selection's colours, the plain tag's whichever pane it is (one
+ // outline, walked from pane to pane).
+ const outline = &p.chrome().tag[0].selection;
if (v.window_pick == id) {
- for (0..rows) |row| temporary.tint(0, @intCast(row), temporary.cols, p.theme().sel_bg, p.theme().sel_fg);
+ for (0..rows) |row| temporary.tint(0, @intCast(row), temporary.cols, outline.ground, outline.text);
}
- const tag_fg: Color = .{ .rgb = if (active) chrome.tag_active_fg else chrome.tag_fg };
+ const tag_fg: Color = .{ .rgb = inks.text };
// One layer, a row to each line the tag shows.
const layer = &s.tag_layers[id];
const count = @as(usize, columns) * rows;
@@ -910,7 +892,7 @@ fn joinPaneTag(p: *Pardes, s: *Surface, arena: std.mem.Allocator, pane: *Pane, r
layer.cols = columns;
layer.rows = rows;
layer.context_rows = 0;
- layer.bg = if (v.window_pick == id) p.theme().sel_bg else tagGround(p, pane, active);
+ layer.bg = if (v.window_pick == id) outline.ground else inks.ground;
layer.cursor = if (v.header != null) null else if (temporary.cursor) |cursor|
.{ .x = cursor.x - TAG_TEXT_INSET, .y = cursor.y, .bar = cursor.bar }
else
@@ -942,7 +924,7 @@ fn joinBand(p: *Pardes, s: *Surface, arena: std.mem.Allocator, pane: *Pane, r: R
const columns = @max(band.columns, 1);
// The walk UI's inks on this tag's ground (colors.Roles, UX DESIGN.md
// D4), and on its cursor row's selection.
- const ground = groundOf(p, pane, active);
+ const ground: colors.TagGround = if (pardes.Trail.reading(p, pane)) (if (active) .reading_focused else .reading) else if (active) .focused else .plain;
const inks = chrome.roles.on(ground);
const selected = chrome.roles.selectedOn(ground);
// A symbol's kind mark (colors.Chrome.Inks.kind): held on this tag's
@@ -1053,31 +1035,20 @@ fn inkTag(p: *Pardes, s: *Surface, shown: tagline.Shown, lines: []const []const
}
}
-/// A pane's tag's ground: a reading pane's tint (its focus is its grip's),
-/// else the focused tag's or the tag's.
-fn tagGround(p: *Pardes, pane: *const Pane, active: bool) [3]u8 {
- return p.chromeTheme().roles.on(groundOf(p, pane, active)).ground;
-}
-
-/// Which of a tag's grounds pane `pane`'s is: its walk UI inks
-/// (colors.Roles) are that ground's.
-fn groundOf(p: *Pardes, pane: *const Pane, active: bool) colors.TagGround {
- if (pardes.Trail.reading(p, pane)) return if (active) .reading_focused else .reading;
- return if (active) .focused else .plain;
-}
-
+/// A pane's tag on its ground, focused or not, whatever its mode (G1':
+/// a reading pane is marked on its grip): its trail, path, `Keep` and the
+/// user's text in the full ink, its computed words in the words' ink, the
+/// basename in the name's tint, hints dim (DESIGN.md H).
fn paintPaneTag(p: *Pardes, s: *Surface, arena: std.mem.Allocator, pane: *Pane, r: Rect, id: usize, active: bool, rows: u16) !void {
- const th = p.theme();
- const chrome = p.chromeTheme();
+ const chrome = p.chrome();
+ const g: colors.Chrome.Ground = if (active) .focus else .plain;
const tx = r.x + @min(TAG_TEXT_INSET, r.w);
const tw = r.w -| TAG_TEXT_INSET;
const tag_y = p.tagTop(pane, r);
- const page_rgb = th.bg orelse th.tag_bg;
// Focus is visible along the tag without changing its live text grid.
- const inks = chrome.roles.on(groundOf(p, pane, active));
+ const inks = chrome.on(g);
const tag_bg = inks.ground;
- const tag_fg = if (active) chrome.tag_active_fg else chrome.tag_fg;
- const tag_style: CellStyle = .{ .fg = .{ .rgb = tag_fg }, .bg = .{ .rgb = tag_bg }, .font_role = .tagline };
+ const tag_style: CellStyle = .{ .fg = .{ .rgb = inks.text }, .bg = .{ .rgb = tag_bg }, .font_role = .tagline };
// Padding belongs to the same font row but keeps its default ink: a
// role must not manufacture a foreground color for blank cells.
s.fill(tx, tag_y, tw, rows, .{
@@ -1089,8 +1060,6 @@ fn paintPaneTag(p: *Pardes, s: *Surface, arena: std.mem.Allocator, pane: *Pane,
const head = try TagState.head(p, arena, pane);
const tail = if (head) |h| h.text else tagline.curTail(pane);
const prefix_len = whole.len - tail.len;
- // Out of rest, the walk UI's text ink (at rest the tag's own, unchanged).
- const text_style: CellStyle = if (head == null) tag_style else .{ .fg = .{ .rgb = inks.text }, .bg = .{ .rgb = tag_bg }, .font_role = .tagline };
// A row per line shown, from `tag_top`: the tag's first line carries
// the prefix, the rest are the tag's own text alone.
const top = pane.tag_top;
@@ -1124,7 +1093,7 @@ fn paintPaneTag(p: *Pardes, s: *Surface, arena: std.mem.Allocator, pane: *Pane,
for (lines[0..rows], 0..) |line, row| {
// The scroll is the caret's line's: a shorter row shows nothing.
const start = @min(line.len, panes.File.rawAtDisplay(p.settings.tab, line, pane.tag_scroll));
- _ = s.print(tx, tag_y + @as(u16, @intCast(row)), tw, line[start..], text_style);
+ _ = s.print(tx, tag_y + @as(u16, @intCast(row)), tw, line[start..], tag_style);
}
// The pane's progress at its first row's right end, where the row has
// room for it (SPEC §10.2); out of rest the head's right block is
@@ -1135,14 +1104,21 @@ fn paintPaneTag(p: *Pardes, s: *Surface, arena: std.mem.Allocator, pane: *Pane,
const text = std.fmt.bufPrint(&buf, "{s} {s}", .{ Messages.Kind.progress.glyph(), said.words() }) catch break;
const width = panes.File.displayWidth(p.settings.tab, text);
const used = panes.File.displayWidth(p.settings.tab, lines[0]);
- if (used + 2 + width <= tw) _ = s.print(tx + @as(u16, @intCast(tw - width)), tag_y, @intCast(width), text, .{ .fg = .{ .rgb = Messages.ink(chrome, .progress) }, .bg = .{ .rgb = tag_bg }, .font_role = .tagline });
+ if (used + 2 + width <= tw) _ = s.print(tx + @as(u16, @intCast(tw - width)), tag_y, @intCast(width), text, .{ .fg = .{ .rgb = Messages.inkOn(inks, .progress) }, .bg = .{ .rgb = tag_bg }, .font_role = .tagline });
break;
};
// The name's tint, in the tag's first line, over whichever rows it
// wrapped onto.
const first_line = whole[0 .. std.mem.indexOfScalar(u8, whole, '\n') orelse whole.len];
+ // Its computed words (UX K'1), between its path and the user's text,
+ // at rest and not asking: the words' ink, quieter than the full one.
+ if (head == null and !TagState.asks(p, pane)) {
+ const words = tagline.computedWords(pane);
+ const end = prefix_len -| 1;
+ inkTag(p, s, shown, lines[0..rows], top, tx, tag_y, tw, end -| words.len, @min(end, first_line.len), inks.word, false);
+ }
if (tagTintRange(p, pane, first_line, prefix_len)) |name| if (name.lo < name.hi)
- inkTag(p, s, shown, lines[0..rows], top, tx, tag_y, tw, name.lo, @min(name.hi, first_line.len), if (active) chrome.tag_active_name_fg else chrome.tag_name_fg, false);
+ inkTag(p, s, shown, lines[0..rows], top, tx, tag_y, tw, name.lo, @min(name.hi, first_line.len), chrome.name[@intFromEnum(g)], false);
// A walk's forward steps, after the name, dimmed (Trail.zig); its fold
// `+N` too; the word n walks underlined in the key ink (UX D8).
const ahead = tagline.forwardSpan(p, pane);
@@ -1157,7 +1133,7 @@ fn paintPaneTag(p: *Pardes, s: *Surface, arena: std.mem.Allocator, pane: *Pane,
};
if (t.walked()) |i| if (!t.isFolded(i, kept)) {
const word = t.spanOf(i, kept);
- inkTag(p, s, shown, lines[0..rows], top, tx, tag_y, tw, word[0], @min(word[1], first_line.len), chrome.roles.key, true);
+ inkTag(p, s, shown, lines[0..rows], top, tx, tag_y, tw, word[0], @min(word[1], first_line.len), inks.key, true);
};
}
// A search word its places no longer light, dimmed (Prompt.zig).
@@ -1179,13 +1155,13 @@ fn paintPaneTag(p: *Pardes, s: *Surface, arena: std.mem.Allocator, pane: *Pane,
const style = &s.at(tx + @as(u16, @intCast(col)), y).style;
switch (span.style) {
.key => {
- style.fg = .{ .rgb = chrome.roles.key };
+ style.fg = .{ .rgb = inks.key };
style.bold = true;
},
.dim => style.fg = .{ .rgb = inks.dim },
.under => style.ul = .single,
.strike => style.strikethrough = true,
- .err => style.fg = .{ .rgb = chrome.roles.err },
+ .err => style.fg = .{ .rgb = inks.severity[0] },
.rule => style.fg = .{ .rgb = inks.rule },
}
}
@@ -1209,7 +1185,7 @@ fn paintPaneTag(p: *Pardes, s: *Surface, arena: std.mem.Allocator, pane: *Pane,
const to = @min(line.len, if (row == last.row) last.col else line.len);
const col = panes.File.rawDisplayCol(p.settings.tab, line, from) -| pane.tag_scroll;
const end = @min(panes.File.rawDisplayCol(p.settings.tab, line, to) -| pane.tag_scroll, tw);
- if (col < end) s.tint(tx + @as(u16, @intCast(col)), tag_y + @as(u16, @intCast(row - top)), @intCast(end - col), th.tag_sel_bg orelse th.sel_bg, th.sel_fg);
+ if (col < end) s.tint(tx + @as(u16, @intCast(col)), tag_y + @as(u16, @intCast(row - top)), @intCast(end - col), inks.selection.ground, inks.selection.text);
}
}
}
@@ -1236,15 +1212,14 @@ fn paintPaneTag(p: *Pardes, s: *Surface, arena: std.mem.Allocator, pane: *Pane,
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, th.tag_sel_bg orelse th.sel_bg, th.sel_fg);
+ body_layer.paintPointerSelection(p, s, pane, r, selection, 0, inks.selection.ground, inks.selection.text);
}
if (p.look_hover_preview) |preview| {
if (preview.pane == id and preview.serial == pane.serial) if (preview.sel) |sel| if (@min(sel.r0, sel.r1) < rows) {
- const preview_bg = colors.mix(page_rgb, colors.mix(page_rgb, th.sel_bg));
- body_layer.paintPointerSelection(p, s, pane, r, sel, 0, preview_bg, null);
+ body_layer.paintPointerSelection(p, s, pane, r, sel, 0, inks.selection.secondary, null);
};
}
- const sweeps = &p.chrome().sweeps;
+ const sweeps = &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;
@@ -1252,66 +1227,62 @@ fn paintPaneTag(p: *Pardes, s: *Surface, arena: std.mem.Allocator, pane: *Pane,
}
}
-test "an unfocused grip shows on its tag in the grid, in every native theme" {
- const p = try Pardes.init(std.testing.allocator, .{ .cols = 100, .rows = 30 });
- defer p.deinit();
- _ = try p.setTestFile("text\n");
- p.newScratchBelow(0);
- var arena: std.heap.ArenaAllocator = .init(std.testing.allocator);
- defer arena.deinit();
- var ok = true;
- for (pardes.themes[0..colors.native_count], 0..) |theme, index| {
- colors.setThemeIndex(p, index);
- p.view().active = 1;
- _ = arena.reset(.retain_capacity);
- const s = try p.render(arena.allocator());
- const r = p.view().rects[0];
- const grip = s.at(r.x, p.tagTop(p.panes[0].?, r)).style.bg.rgb;
- // Its tag's ground: a reading pane's the reading tint.
- const ratio = colors.contrast(grip, tagGround(p, p.panes[0].?, false));
- // ponytail: dark and helix have always had a faint grip (1.2:1); flagged, not changed here.
- const floor: f32 = if (std.mem.eql(u8, theme.name, "dark") or std.mem.eql(u8, theme.name, "helix")) 1.2 else 1.5;
- // Against a reading tint (UX D4's, lighter on a dark tag) a little
- // less: forestbones_dark's 1.486, nordbones' 1.488, monokai's 1.4999.
- if (ratio < floor - 0.02) std.debug.print("{s}: grip {d:.4}\n", .{ theme.name, ratio });
- ok = ok and ratio >= floor - 0.02;
- }
- try std.testing.expect(ok);
-}
-
-test "a grip's four states, focused or not and clean or dirty, are each its own in every native theme" {
- const p = try Pardes.init(std.testing.allocator, .{ .cols = 100, .rows = 30 });
+test "a grip in the grid is the chrome's in every theme: focused the accent, at rest its ring, reading the mode's mark (its glyph on a focused one), unsaved a bold `*` on the dirty fill; the four each its own (DESIGN.md R5', R6, G1')" {
+ const p = try Pardes.init(std.testing.allocator, .{ .cols = 60, .rows = 16 });
defer p.deinit();
const pane = try p.setTestFile("text\n");
p.newScratchBelow(0);
var arena: std.heap.ArenaAllocator = .init(std.testing.allocator);
defer arena.deinit();
- const State = struct { first: Cell, second: Cell, dirty: bool };
- for (0..colors.native_count) |index| {
+ const Grip = struct { first: Cell, second: Cell };
+ const State = struct { active: bool, held: bool, dirty: bool };
+ const states = [_]State{
+ .{ .active = true, .held = true, .dirty = false },
+ .{ .active = false, .held = true, .dirty = false },
+ .{ .active = false, .held = false, .dirty = false },
+ .{ .active = false, .held = true, .dirty = true },
+ .{ .active = true, .held = false, .dirty = false },
+ };
+ var failed: usize = 0;
+ for (pardes.themes, 0..) |theme, index| {
colors.setThemeIndex(p, index);
- var states: [4]State = undefined;
- for (&states, 0..) |*state, i| {
- p.view().active = if (i & 1 == 0) 0 else 1;
+ const grip = &p.chrome().grip;
+ var drawn: [states.len]Grip = undefined;
+ for (states, &drawn) |state, *got| {
+ p.view().active = if (state.active) 0 else 1;
+ pane.trail.held = state.held;
const saved = pane.file.?.saved_revision;
- pane.file.?.revision = if (i & 2 != 0) saved + 1 else saved;
+ pane.file.?.revision = if (state.dirty) saved + 1 else saved;
_ = arena.reset(.retain_capacity);
const s = try p.render(arena.allocator());
const r = p.view().rects[0];
const y = p.tagTop(pane, r);
- state.* = .{ .first = s.at(r.x, y).*, .second = s.at(r.x + 1, y).*, .dirty = s.region(.grip, 0).?.dirty };
- try std.testing.expectEqual(i & 2 != 0, state.dirty);
- if (i & 2 == 0) continue;
- // Dirty is more than a shade: the grid prints a bold `*` (one
- // grid for every shell; a pixel shell draws its button over it).
- try std.testing.expectEqualStrings("*", state.second.grapheme());
- try std.testing.expect(state.second.style.bold);
+ got.* = .{ .first = s.at(r.x, y).*, .second = s.at(r.x + 1, y).* };
}
- for (states, 0..) |a, i| for (states[i + 1 ..]) |b| {
- const same = std.meta.eql(a.first.style.bg, b.first.style.bg) and a.second.visuallyEqual(&b.second);
- try std.testing.expect(!same);
+ pane.file.?.revision = pane.file.?.saved_revision;
+ const want = [_][2][3]u8{
+ .{ grip.focus, grip.ink },
+ .{ grip.ring, p.chrome().tag[0].text },
+ .{ grip.mode, grip.ink },
+ .{ grip.ring, p.chrome().tag[0].text },
+ .{ grip.focus, grip.mode_glyph },
+ };
+ var ok = true;
+ for (drawn, want) |got, w| ok = ok and std.meta.eql(got.first.style.bg, Color{ .rgb = w[0] }) and std.meta.eql(got.first.style.fg, Color{ .rgb = w[1] });
+ // Dirty is more than a shade: the grid prints a bold `*` (one grid
+ // for every shell; a pixel shell draws its button over it).
+ const star = drawn[3].second;
+ ok = ok and std.mem.eql(u8, star.grapheme(), "*") and star.style.bold and std.meta.eql(star.style.bg, Color{ .rgb = grip.dirty }) and std.meta.eql(star.style.fg, Color{ .rgb = grip.ink });
+ for (drawn[0..4], 0..) |a, i| for (drawn[i + 1 .. 4]) |b| {
+ ok = ok and !(std.meta.eql(a.first.style.bg, b.first.style.bg) and a.second.visuallyEqual(&b.second));
};
+ if (!ok) {
+ std.debug.print("{s}: a grip not the chrome's, or two states alike\n", .{theme.name});
+ failed += 1;
+ }
}
- pane.file.?.revision = pane.file.?.saved_revision;
+ pane.trail.held = false;
+ try std.testing.expectEqual(@as(usize, 0), failed);
}
test "every theme draws a file's name, a +Errors and a Term word in a tint, never the tag's plain ink" {
@@ -1356,9 +1327,8 @@ test "every theme draws a file's name, a +Errors and a Term word in a tint, neve
};
}
const name = std.mem.indexOf(u8, row[0..len], probe.word) orelse return error.WordNotDrawn;
- const plain = std.mem.indexOf(u8, row[0..len], " Del") orelse return error.WordNotDrawn;
const tint = s.at(cols[name], y).style.fg;
- const ink = s.at(cols[plain + 1], y).style.fg;
+ const ink: Color = .{ .rgb = p.chrome().on(if (focused.id == probe.id) .focus else .plain).text };
if (std.meta.eql(tint, ink)) std.debug.print("{s}: {s} drawn in the tag's ink\n", .{ theme.name, probe.word });
try std.testing.expect(!std.meta.eql(tint, ink));
// The whole word, in the one tint.
@@ -1381,11 +1351,11 @@ test "a tag of three rows has its grip on the first, and band under it that stil
const r = p.view().rects[0];
const top = p.tagTop(pane, r);
try std.testing.expect(pane.tag_rows >= 3);
- const chrome = p.chromeTheme();
- const band = tagGround(p, pane, true);
+ const chrome = p.chrome();
+ const band = chrome.on(.focus).ground;
for (0..config.GUTTER) |dx| {
const x = r.x + @as(u16, @intCast(dx));
- try std.testing.expectEqual(Color{ .rgb = chrome.box }, s.at(x, top).style.bg);
+ try std.testing.expectEqual(Color{ .rgb = chrome.grip.focus }, s.at(x, top).style.bg);
for (1..pane.tag_rows) |line| {
const cell = s.at(x, top + @as(u16, @intCast(line)));
try std.testing.expectEqual(Color{ .rgb = band }, cell.style.bg);
@@ -1444,7 +1414,7 @@ test "place puts every part where the painters and layers put it, in every layou
for (0..rail.rect.h) |row| {
const y = rail.rect.y + @as(u16, @intCast(row));
const thumb = row >= rail.thumb_y and row < rail.thumb_y + rail.thumb_h;
- const want = if (thumb) p.chromeTheme().scroll_thumb else p.chromeTheme().scroll_track;
+ const want = if (thumb) p.chrome().rail_thumb else p.chrome().rail;
try std.testing.expectEqual(Color{ .rgb = want }, s.at(rail.rect.x, y).style.bg);
}
var notices: usize = 0;
@@ -1491,7 +1461,7 @@ test "the word under the pointer on the notice row is lit in its layer and in th
_ = arena.reset(.retain_capacity);
s = try p.render(arena.allocator());
const lit = s.cells[@as(usize, foot.rect.y) * s.cols ..][0..s.cols];
- const sel: Color = .{ .rgb = p.theme().tag_sel_bg orelse p.theme().sel_bg };
+ const sel: Color = .{ .rgb = p.chrome().status.selection.secondary };
for (lit[here..][0..4]) |cell| try std.testing.expectEqual(sel, cell.style.bg);
try std.testing.expect(!std.meta.eql(sel, lit[here - 2].style.bg));
const layer = &s.tag_layers[pardes.NOTICE_ROW_LAYER];
@@ -1869,8 +1839,7 @@ test "a tag out of rest draws its keys bold in the key ink and its hint in the d
var frame = std.heap.ArenaAllocator.init(std.testing.allocator);
defer frame.deinit();
const a = frame.allocator();
- const roles = &p.chromeTheme().roles;
- const inks = roles.on(if (pardes.Trail.reading(p, pane)) .reading_focused else .focused);
+ const inks = p.chrome().on(.focus);
// SPC's level rolled, after its delay: `␣ ▸ … l lsp… … ↓ unroll · ? help`.
p.clock.now_ns = 5 * std.time.ns_per_s;
p.clock.stepped_ns = p.clock.now_ns;
@@ -1896,35 +1865,89 @@ test "a tag out of rest draws its keys bold in the key ink and its hint in the d
try std.testing.expectEqual(Color{ .rgb = inks.dim }, row[hint].style.fg);
for (row) |cell| try std.testing.expect(!cell.style.dim);
var keys: usize = 0;
- for (row) |cell| if (std.meta.eql(cell.style.fg, Color{ .rgb = roles.key })) {
+ for (row) |cell| if (std.meta.eql(cell.style.fg, Color{ .rgb = inks.key })) {
try std.testing.expect(cell.style.bold);
keys += 1;
};
try std.testing.expect(keys > 3);
}
-test "an unfocused reading pane's box in the grid is its ring round the reading tint where the box's fill is the tag's own ground (acme's), as a window draws it; a held pane's, or another theme's, as before" {
+test "a pane tag's trail, path, Keep and the user's text are in its full ink, its computed words in the words' ink; the window row and the column tags on the page in its words' ink, a column's grip at rest 2:1; the notice row on its own ground (DESIGN.md H)" {
+ const p = try Pardes.init(std.testing.allocator, .{ .tty_only = true, .cols = 120, .rows = 30 });
+ defer p.deinit();
+ colors.setThemeIndex(p, colors.themeIndex("dark").?);
+ const pane = try p.setTestFile("one\n");
+ pane.tag.own = try p.gpa.dupe(u8, "mine");
+ const id = p.view().active;
+ try std.testing.expect(p.executeBuiltinLine(id, "Newcol"));
+ p.view().active = id;
+ p.sync();
+ var frame = std.heap.ArenaAllocator.init(std.testing.allocator);
+ defer frame.deinit();
+ const s = try p.render(frame.allocator());
+ const chrome = p.chrome();
+ const Find = struct {
+ fn at(sf: *Surface, y: u16, word: []const u8) ?u16 {
+ var x: u16 = 0;
+ while (x + word.len <= sf.cols) : (x += 1) {
+ for (word, 0..) |c, i| {
+ const cell = sf.at(x + @as(u16, @intCast(i)), y);
+ if (cell.len != 1 or cell.text[0] != c) break;
+ } else return x;
+ }
+ return null;
+ }
+ };
+ const inks = chrome.on(.focus);
+ try std.testing.expect(!std.mem.eql(u8, &inks.word, &inks.text));
+ const y = p.tagTop(pane, p.view().rects[id]);
+ for ([_][]const u8{ "Keep", "mine" }) |word| try std.testing.expectEqual(Color{ .rgb = inks.text }, s.at(Find.at(s, y, word).?, y).style.fg);
+ try std.testing.expectEqual(Color{ .rgb = inks.word }, s.at(Find.at(s, y, "Del").?, y).style.fg);
+ try std.testing.expectEqual(Color{ .rgb = inks.text }, s.at(Find.at(s, y, "/test.txt").?, y).style.fg);
+ // The window row's and the column tags' words, on the page (dark's the
+ // terminal's own).
+ const page = &chrome.page;
+ try std.testing.expect(chrome.host_page);
+ try std.testing.expect(layout.columnBarHeight(p) > 0);
+ const column_y = p.topBarHeight();
+ for ([_]struct { y: u16, word: []const u8 }{ .{ .y = 0, .word = "Exit" }, .{ .y = column_y, .word = "Delcol" } }) |at| {
+ const x = Find.at(s, at.y, at.word).?;
+ try std.testing.expectEqual(Color{ .rgb = page.word }, s.at(x, at.y).style.fg);
+ try std.testing.expectEqual(@as(Color, .default), s.at(x, at.y).style.bg);
+ }
+ // Each column's grip at rest, its active one's too: never focus.
+ for (0..p.view().ncol) |c| try std.testing.expectEqual(Color{ .rgb = chrome.grip.column_rest }, s.at(p.view().col_x[c], column_y).style.bg);
+ if (s.region(.notice_row, Region.none)) |row| try std.testing.expectEqual(Color{ .rgb = chrome.status.ground }, s.at(row.rect.x, row.rect.y).style.bg);
+}
+
+test "a reading pane's tag is on the plain or the focused ground, as a held one's; its grip carries the mode's mark, the held one's its ring (DESIGN.md G1', acme too)" {
const p = try Pardes.init(std.testing.allocator, .{ .tty_only = true, .cols = 100, .rows = 30 });
defer p.deinit();
const pane = try p.setTestFile("one\n");
const reader = p.view().active;
p.newScratchBelow(reader);
- colors.setThemeIndex(p, colors.themeIndex("acme").?);
- p.sync();
+ const other = p.view().active;
+ try std.testing.expect(other != reader);
var frame = std.heap.ArenaAllocator.init(std.testing.allocator);
defer frame.deinit();
- try std.testing.expect(pardes.Trail.reading(p, pane) and p.view().active != reader);
- var s = try p.render(frame.allocator());
- const r = p.view().rects[reader];
- const want = colors.mix(boxBorder(p), p.chromeTheme().tag_reading_bg);
- for (0..config.GUTTER) |x| try std.testing.expectEqual(Color{ .rgb = want }, s.at(r.x + @as(u16, @intCast(x)), r.y).style.bg);
- // Held, the ring round the plain box.
- pane.trail.held = true;
- s = try p.render(frame.allocator());
- try std.testing.expectEqual(Color{ .rgb = colors.mix(boxBorder(p), p.chromeTheme().tag_bg) }, s.at(r.x, r.y).style.bg);
- // orchard's box has a fill of its own: a reader's keeps it.
- pane.trail.held = false;
- colors.setThemeIndex(p, colors.themeIndex("orchard").?);
- s = try p.render(frame.allocator());
- try std.testing.expectEqual(Color{ .rgb = colors.mix(boxBorder(p), p.chromeTheme().box_dim) }, s.at(r.x, r.y).style.bg);
+ for ([_][]const u8{ "acme", "orchard", "dark", "neonotte84" }) |name| {
+ colors.setThemeIndex(p, colors.themeIndex(name).?);
+ const chrome = p.chrome();
+ const r = p.view().rects[reader];
+ for ([_]bool{ false, true }) |held| for ([_]bool{ false, true }) |active| {
+ pane.trail.held = held;
+ p.view().active = if (active) reader else other;
+ p.sync();
+ try std.testing.expectEqual(!held, pardes.Trail.reading(p, pane));
+ _ = frame.reset(.retain_capacity);
+ const s = try p.render(frame.allocator());
+ const g: colors.Chrome.Ground = if (active) .focus else .plain;
+ try std.testing.expectEqual(Color{ .rgb = chrome.on(g).ground }, s.at(r.x + TAG_TEXT_INSET, r.y).style.bg);
+ const grip = if (active) chrome.grip.focus else if (held) chrome.grip.ring else chrome.grip.mode;
+ for (0..config.GUTTER) |x| try std.testing.expectEqual(Color{ .rgb = grip }, s.at(r.x + @as(u16, @intCast(x)), r.y).style.bg);
+ // The window rings a reading grip in the mode's mark (gui.zig
+ // gripDecor), from the region.
+ try std.testing.expectEqual(!held, s.region(.grip, reader).?.reading);
+ };
+ }
}
diff --git a/core/look.zig b/core/look.zig
index 3ce1e48c..7a488b0c 100644
--- a/core/look.zig
+++ b/core/look.zig
@@ -2154,7 +2154,8 @@ test "Look hover waits without mutating the pane and input cancels it" {
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));
+ // On the tag, its own ground's half selection (DESIGN.md B5).
+ const expected_bg = p.chrome().on(.focus).selection.secondary;
// 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/replica.zig b/core/replica.zig
index 6c037cd2..c8bd5471 100644
--- a/core/replica.zig
+++ b/core/replica.zig
@@ -5415,21 +5415,21 @@ test "a replica joined from a themed dump paints its taglines in the restored th
defer a.core.gpa.free(bytes);
const r = try Replica.initDump(gpa, 1, 0, bytes, .{ .cols = 80, .rows = 24 });
defer r.deinit();
- const expected = pardes.colors.ChromeTheme.fromTheme(a.core.theme());
+ const expected = a.core.chrome().tag[0];
try std.testing.expectEqualStrings("rose_pine_moon", r.core().theme().name);
- try std.testing.expectEqual(expected.tag_bg, r.core().chromeTheme().tag_bg);
- try std.testing.expectEqual(expected.tag_fg, r.core().chromeTheme().tag_fg);
+ try std.testing.expectEqual(expected, r.core().chrome().tag[0]);
_ = r.draw(.{ .ctx = null, .f = null });
- try std.testing.expectEqual(expected.tag_bg, r.core().surface.chrome.tag_bg);
- try std.testing.expectEqual(expected.tag_fg, r.core().surface.chrome.tag_fg);
+ try std.testing.expectEqual(expected.ground, r.core().surface.chrome.tag_bg);
+ try std.testing.expectEqual(expected.text, r.core().surface.chrome.tag_fg);
try std.testing.expectEqual(digestOf(a), r.digest());
// A later theme is an ordinary confirmed unit, its chrome set at once.
r.confirm(try a.local(.{ .command = "Theme monokai_pro_classic" }));
r.settle();
_ = r.draw(.{ .ctx = null, .f = null });
- const changed = pardes.colors.ChromeTheme.fromTheme(a.core.theme());
- try std.testing.expectEqual(changed.tag_bg, r.core().surface.chrome.tag_bg);
- try std.testing.expectEqual(changed.tag_fg, r.core().surface.chrome.tag_fg);
+ const changed = a.core.chrome().tag[0];
+ try std.testing.expect(!std.meta.eql(changed, expected));
+ try std.testing.expectEqual(changed.ground, r.core().surface.chrome.tag_bg);
+ try std.testing.expectEqual(changed.text, r.core().surface.chrome.tag_fg);
try std.testing.expect(r.diverged == null);
try std.testing.expectEqual(digestOf(a), r.digest());
}
diff --git a/core/surface.zig b/core/surface.zig
index ce8898ad..7928c89e 100644
--- a/core/surface.zig
+++ b/core/surface.zig
@@ -119,8 +119,8 @@ pub const Region = struct {
active: bool = false,
/// A grip's pane has changes it has not saved.
dirty: bool = false,
- /// A grip's or a tag's pane reads (Trail.reading): its tag's ground is
- /// the reading tint (`Chrome.tag_reading_bg`), focused or not.
+ /// A grip's or a tag's pane reads (Trail.reading): its grip is ringed in
+ /// the mode's mark (DESIGN.md G1'), its tag's ground its focus's.
reading: bool = false,
/// A rail's thumb: rows from the rail's top, and how many. Zero rows is
/// a rail with no thumb (an image). A kind's thumb is where its paint
@@ -184,15 +184,13 @@ pub const Chrome = struct {
/// The rule under the workspace tag.
topbar_rule: [3]u8 = .{ 0, 0, 0 },
tag_bg: [3]u8 = .{ 0, 0, 0 },
- /// The workspace row's ground (a theme's status bar), and how many grid
- /// rows from the top it covers: the window paints its underlay there in
- /// this colour, not the tag's.
+ /// The window row's and the column tags' ground (the page, DESIGN.md
+ /// H), and how many grid rows from the top they cover: the window paints
+ /// its underlay there in this colour, not the tag's.
tagline_bg: [3]u8 = .{ 0, 0, 0 },
tagline_rows: u16 = 0,
- /// The focused pane's and column's tag underlay.
+ /// The focused pane's tag underlay, whatever its mode (G1').
tag_focus_bg: [3]u8 = .{ 0, 0, 0 },
- /// A reading pane's tag underlay (Region.reading).
- tag_reading_bg: [3]u8 = .{ 0, 0, 0 },
tag_fg: [3]u8 = .{ 0, 0, 0 },
scroll_track: [3]u8 = .{ 0, 0, 0 },
scroll_thumb: [3]u8 = .{ 0, 0, 0 },