summaryrefslogtreecommitdiff
path: root/core/draw.zig
diff options
context:
space:
mode:
authorGabriel Schneider <[email protected]>2026-11-26 09:29:45 -0300
committerGabriel Schneider <[email protected]>2026-11-26 11:19:58 -0300
commit6b2b63f654561ba9d64c134e6ccc6c0784e15220 (patch)
tree4d3c140f7c26714bb47cae6c2d811928f7170e57 /core/draw.zig
parent8959b031dc330b4da21c0e89e0831d6fadbcd757 (diff)
downloadpardes-6b2b63f654561ba9d64c134e6ccc6c0784e15220.tar.gz
pardes-6b2b63f654561ba9d64c134e6ccc6c0784e15220.zip
draw, colors, gui: the tags, grips, window and column rows and the notice row drawn from the chrome (the themes programme's L2a, DESIGN.md part F's L2a row, G1' and H): a tag's ground says focus only, two grounds (`chrome.on(.plain/.focus)`), a reading pane's on its focus's as a held one's, its mode on its grip; in a pane tag the trail, path, `Keep` and the user's text in the full ink (`text`, 7:1 where the gamut allows), its computed words (UX K'1, K'3) in the words' ink (`word`, 4.5:1), the basename in `name[g]`, its forward steps, fold and head hints `dim`, the walked word and the head's keys `key`, the head's error `severity[0]`, its own selection and a pointer sweep the ground's selection, window mode's outline the plain tag's selection whichever pane it is on (one outline walked from pane to pane), a hovered word its half selection (B5: `Selection.secondary`, new, the ground halfway to its selection, worked out with the ground's inks); the window row and the column tags on the page, no band and no focus, every word in `page.word` (a terminal's own page where the theme leaves it to the host: dark), their hovered word the page's half selection, a server's progress the page's dim ink; a column's grip `grip.column_rest` (2:1) at rest, `grip.column` (3:1) grabbed, never focus; the notice row on `status` (its ground, ink, dim and its lead's severity per ground); a pane's notice chips on the plain tag; the grid's grip (R5', R6): focused `grip.focus` with its glyph in `grip.ink`, or in `grip.mode_glyph` reading; at rest its ring `grip.ring` as the cell (the theme's own where it rings its grips, acme's #8888cc, lapis's #9aa6d9, where the cell was half that and the box's fill) with the tag's ink; reading unfocused the mode's mark `grip.mode` filled, glyph `grip.ink`; unsaved a bold `*` in `grip.ink` on `grip.dirty`; a message's mark in its kind's ink held on its fill (`Grip.marks`, new: each severity and the dim ink held at a theme change on the four fills a grid gives a grip, at rest and reading on the plain tag too, where a window draws them hollow), so the gui draws the cell's ink and its per-frame pushAway goes; both copies of `inkOn` deleted (draw.zig's, and the gui's use of pushAway); the rail's ticks the hit's and the current hit's (R8), the body's pan arrow the page's key ink, the debug box the rail and the tag's ink; the surface's chrome from the chrome alone (`tag_reading_bg` deleted, `tagline_bg` the page and `tagline_rows` over the column row too, so a window's underlay there is the page); the gui: no reading underlay, the column bar's focus cover and the reading cover gone (nothing reads them now), a column grip's band the page; Messages.ink deleted (`inkOn` takes a ground's inks or a fill's marks); THE BAND is untouched here (its inks are the next change's); RUN (TEST FIRST): draw.zig "a grip in the grid is the chrome's in every theme ..." (every theme in the ring, not the natives: focus, rest, mode, dirty, focused reading; the four each its own), "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 ..." (acme, orchard, dark, neonotte84; held and reading, focused and not), "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 ... the notice row on its own ground" (dark: the host's page), each failing on the base (the old grip mix, the reading tint, the tag's own unheld ink on `Del`, the tagline ground); re-pinned: Trail.zig's reading-tint tests (the reader on the focused ground and its grip region reading, the held one plain), the name tint test (against the full ink, not ` Del`'s), Core.zig's window-row hover and empty column, replica's themed dump, test/column_drag.zig, test/panes.zig's tint tests (the name in `name[g]`, the words in `word`, the rest in `text`), the gui's mark test (the cell's ink, held by the core), look.zig's tag hover (the focused ground's half selection), behaviour's column-tag sweep (the swept cells the selection, the hovered word its half) and tags' tint (the directory in the full ink, the computed words in the words'); GOLDENS (36 of 103, orchard unless said), each moved cell read by goldsum.py/rowpairs.py against the base: (1) the window and column rows to the page: tagline #b2c3b8 on #1d2824 to page.word #788079 on #0d1410 (3932 cells in 33) and their blanks (1834), the active column's #becfc4 on #314738 too (1268); (2) a pane tag's computed words in `word`: plain #819188 (1607), focused #a1b1a8 on the focus ground #394440 (1088); (3) the focused tag's ground #314738 (the old focus tint) to the chrome's #394440 and its full ink #becfc4 to #cadbd0 (991), the name tint on it (701); (4) a reading pane's tint #2c2c0f gone: focused to #394440 (746 + 647 words + 101 names), unfocused to the plain tag (234 + 219 words + 50 names), the head's dim on it to the focused dim #8e9d94 (165), its key #bada9d to #add38a (28 + 6); (5) grips: a reading unfocused one's ring #465a43 to the mode's sky #3096c0 (10 + 2), a focused reading one's glyph black to `mode_glyph` #06779d (6); (6) the rail's current tick, the text #e5eee5, to the current hit #917a53 (8 + 1); (7) a server's progress on the window row, hint #b7cb98, to the page's dim #666f68 (135, callstack, lsprelpath); (8) a hovered header word, the full selection, to the page's half #24382c in page.word (9 + 2, load, windowops); the tag's selection's ink #f5f7ee to the focused ink held on it #cadbd0 (65 + 1, tagpath); (9) blanks only: the dump's runs carry a blank cell's ink from the cell before it, so blanks after `Del`, on a grip's second cell and the column grips show the new ink with no glyph (271 + 253 + 22 + 18 + 6 + 4 + 4 + 4); theme.golden and themesel.golden (24 themes each), the same classes per theme: the window and column rows on each page (dark's the host's: `d`), dark_plus's blue status bar now the notice row's alone (H), acme's cyan header rows on its page #ffffea in #74746a, the focused tag on R4's step (acme #d1e6e6, dark_plus #565656, light #d1cfdb), the notice row's ink `status.text` (the tag's held), paper's and solarium's on the lifted plain tag (H's 1.1), acme's and lapis's resting grip their own ring as the cell; mini, collapse, ninep carry the same in their 9P captures' style rows; GATES (tui): core-test 1155/1329 (174 skipped), pane-test 184/185 (1 skipped), process-test 0 of 103 failed with --update (36 re-recorded, read above); THE END GATE's finds, fixed here: shell-test's look.zig tag hover and behaviour's column-tag sweep and tags' tint asked the old looks (re-pinned above), and behaviour's window mode lost its outline walking from the focused pane to another (each tag's own selection differs by ground: the outline is the plain tag's selection on every pane now); the whole stack's gates are in its last change's description; load 2.5 to 9.5; OUTSIDE draw.zig/Messages.zig: core/colors.zig (Selection.secondary, Grip.marks/Fill/Marks, three hunks), core/surface.zig (Chrome's reading underlay gone, two docs), dev/gui/gui.zig (underlay, gripFill, mark ink, gripDecor's band, coverFrame, two tests), core/Trail.zig, core/Core.zig, core/replica.zig, core/look.zig, test/column_drag.zig, test/panes.zig, test/behaviour/columns_and_tags.zig, test/behaviour/tags.zig (tests), test/snapshots (36)
Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_016Y9MNBFhdevVu48bvL9kCE
Diffstat (limited to 'core/draw.zig')
-rw-r--r--core/draw.zig493
1 files changed, 258 insertions, 235 deletions
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);
+ };
+ }
}