From 01ce658c7b40997e24ce5045b0e07f7b9ae98e71 Mon Sep 17 00:00:00 2001 From: Gabriel Schneider Date: Wed, 25 Nov 2026 04:51:32 -0300 Subject: colors, draw, Band: the walk UI's colour roles (UX DESIGN.md D4): text, dim, rule on each of a tag's four grounds (plain, focused, reading, reading focused) and on each one's cursor-row selection, key, match, hit, hit current, err/warn/question/hint, worked out once a theme with its chrome (ChromeTheme.roles, Roles.of; never a frame) and each held to its floor where it is drawn (text 4.5:1, dim 3.5 never under 3, rule 2:1, key and match 4.5:1 on every tag ground and selection, selection 1.4:1 off a dark tag and 1.25 off a light one with its text at 4.5, hit 1.25 and current 1.6 off the page with the body's ink at 4.5, a message's ink 4.5 on the tags and the page; where a theme's own colours leave no room, the most they allow: solarized's mid-grey tag, a tag whose text has no contrast to spare); the reading tint derived as D4 says (the theme's own where it stands 0.04 off the tag in OKLab, else the tag toward paper yellow by 0.04 and 0.02 lighter on a dark tag, darker on a light one, less or the other way where its text would drop under 7:1 or its own, further where the bytes cannot show the step): neonotte84's #262737 (0.029 off its tag, invisible) is #29271d now; and every painter of the new UI on them: the band's spines and step rules in the rule ink (they were the box's 11.5:1, the brightest thing in the band), `▶` and `•` in the key ink, a key bold in it, Help's chord (`SPC h t`, Row.chord) in it at the text's weight, a matched letter bold in the match ink on its row's own ground (it was the search ground, the selection's colour on neonotte84: on the cursor row the matches vanished), a dim row and a path's directory in the dim ink of their ground (the cursor row's selection's on it), never the faint attribute (fg 12.5:1 fell to 4.5 and a dimmed register value to 1.58); the head's dim spans in the dim ink, a key bold in the key ink, an error in the err role, the picker's act-row spines in the rule ink (TagState.Style.rule), its other sources' words, its `|` and the themes' hint dim, the levels', describe-key's and Rename's hints dim (they were at full label ink, louder than the content), the head's text in the text role (at rest the tag keeps its own ink: byte for byte); a walk's forward steps and a search word no place lights in the dim ink (they were the line numbers' ink, 1.57:1 on a reading tag); Messages.ink is the roles' (marks, end-of-line ghosts, progress); an LSP leaf in a pane no language server speaks for is dim and its doc step says `needs a language server` (POLISH 3; SPEC §4.2); UX's derived values reproduced (tools/roles.py: neonotte84's text, dim #70768f, rule #4c5063, key, match #f1a271, reading, hit #36282a, current #523831 within 2 a channel; acme's dim, rule, reading, hit, current; acme's key #555583 and match #8f4800 a step darker than UX's #5c5c8d and #974d00, which hold on its tag and #9eeeee: a reading pane's band's selection is pushed off #f3f0cc, 1.12:1, and they read on it too); TEST FIRST: Band.zig "a band is drawn in the theme's roles" (fails on the base painter at its first spine: the box's ink), draw.zig "a tag out of rest draws its keys bold in the key ink and its hint in the dim ink, never faint", colors.zig "every theme's walk UI roles meet their floors" (every bundled theme, dark and light, every floor; 497 floors missed by the first derivation, each class fixed by the rule above) and "neonotte84's and acme's roles are the ones UX derived"; Trail.zig's §6.7 session test now wants the forward step in the dim ink; core-test 1066/1236 (170 skipped) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_016Y9MNBFhdevVu48bvL9kCE --- core/Pick.zig | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'core/Pick.zig') diff --git a/core/Pick.zig b/core/Pick.zig index 3bab0970..6026f11b 100644 --- a/core/Pick.zig +++ b/core/Pick.zig @@ -589,7 +589,9 @@ pub fn head(p: *Pardes, arena: std.mem.Allocator, pane: *Pane) !?TagState.Head { if (pk.names.busy() or p.stream.busyFor(pk.id)) try text.appendSlice(arena, " ⋯"); // Themes have no acts and no other sources: no second row. if (pk.source == .themes) { + const hint: u32 = @intCast(text.items.len); try text.appendSlice(arena, " ⏎ wear it · esc"); + try spans.append(arena, .{ .lo = hint, .hi = @intCast(text.items.len), .style = .dim }); for (cells[0..ncells]) |c| try spans.append(arena, .{ .lo = c[0], .hi = c[1], .style = .key }); return .{ .text = text.items, .spans = spans.items, .cells = @intCast(ncells), .caret = caret }; } @@ -603,13 +605,15 @@ pub fn head(p: *Pardes, arena: std.mem.Allocator, pane: *Pane) !?TagState.Head { for (cells[0..ncells]) |c| { const at = lead + File.displayWidth(p.settings.tab, text.items[0..c[0]]); while (col < at) : (col += 1) try text.append(arena, ' '); - try spans.append(arena, .{ .lo = @intCast(text.items.len), .hi = @intCast(text.items.len + "│".len), .style = .key }); + try spans.append(arena, .{ .lo = @intCast(text.items.len), .hi = @intCast(text.items.len + "│".len), .style = .rule }); try text.appendSlice(arena, "│"); col += 1; } const nspines: u8 = @intCast(spans.items.len); try text.appendSlice(arena, if (ncells == 0) "" else " "); for (acts) |act| if (offered(pk, act)) try text.print(arena, "{s} ", .{act.word}); + // The other sources' words, and the `|` before them, dim (UX D4). + const sources: u32 = @intCast(text.items.len); try text.appendSlice(arena, "|"); var first = false; inline for (comptime std.enums.values(Source)) |src| if (src != .list and src != .messages and src != .themes) { @@ -619,6 +623,7 @@ pub fn head(p: *Pardes, arena: std.mem.Allocator, pane: *Pane) !?TagState.Head { try text.appendSlice(arena, words.get(src).word); } }; + try spans.append(arena, .{ .lo = sources, .hi = @intCast(text.items.len), .style = .dim }); for (cells[0..ncells]) |c| try spans.append(arena, .{ .lo = c[0], .hi = c[1], .style = .key }); return .{ .text = text.items, .spans = spans.items, .cells = nspines, .caret = caret }; } -- cgit v1.3 From 0e6c60d17dd5f0e48232a46096e3a7a92f8841cf Mon Sep 17 00:00:00 2001 From: Gabriel Schneider Date: Wed, 25 Nov 2026 05:27:43 -0300 Subject: Pick, Band, draw: the themes picker marks the theme in use (POLISH 12, UX DESIGN.md A15): its row says `in use` at its right end in the dim ink, whichever theme the window wears under the cursor, and the cursor opens on it as before; a band row's meta (Band.Row.meta: said right-aligned in its part, two cells off its text at least, the first to give way, as D5 asks; the step as wide as text and meta; Band.metaShown says whether it fits, so Band.line and draw.zig joinBand agree), placed from the part's own column (a step's rows start where the spines leave off, not always at its x); TEST FIRST: Pick.zig "the themes picker marks the theme in use" (fails without the mark at its `in use`; it holds the row's meta, one row only, the cells' dim ink on the cursor row's selection, and the mark staying on the theme in use while the window wears the next); core-test 1068/1238 (170 skipped) Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_016Y9MNBFhdevVu48bvL9kCE --- core/Band.zig | 17 ++++++++++++++++- core/Pick.zig | 60 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++--- core/draw.zig | 5 +++++ 3 files changed, 78 insertions(+), 4 deletions(-) (limited to 'core/Pick.zig') diff --git a/core/Band.zig b/core/Band.zig index a8d97bb4..e562da1d 100644 --- a/core/Band.zig +++ b/core/Band.zig @@ -56,6 +56,9 @@ pub const Row = struct { /// tint; the `faint` bytes after them dimmed (a path's directory). pre: u16 = 0, faint: u16 = 0, + /// Said at the row's right end in the dim ink, two cells off its text + /// at least, and the first to give way (UX D5): `in use`. + meta: []const u8 = "", }; /// A column of rows. A level of more than 9 rows flows into two columns @@ -375,7 +378,7 @@ fn place(band: *Band, p: *Pardes, arena: std.mem.Allocator, pane: *Pane, id: usi for (band.steps[0..band.nsteps]) |*step| { if (step.doc) continue; var widest: usize = 0; - for (step.rows) |row| widest = @max(widest, File.displayWidth(tab, row.text)); + for (step.rows) |row| widest = @max(widest, File.displayWidth(tab, row.text) + if (row.meta.len > 0) 2 + File.displayWidth(tab, row.meta) else 0); const column: u16 = @intCast(@min(widest + 2, std.math.maxInt(u16) / 4, @max(min_width, band.columns -| x))); step.width = if (step.two) 2 * column + 1 else column; need += step.width + 2; @@ -493,14 +496,26 @@ pub fn line(band: *const Band, arena: std.mem.Allocator, tab: u16, y: u16) !Line col += @intCast(File.displayWidth(tab, lead)); try parts.append(arena, .{ .col = col, .width = per -| @as(u16, @intCast(File.displayWidth(tab, lead))), .row = row }); const room = per -| @as(u16, @intCast(File.displayWidth(tab, lead))); + const at = col; const cut = File.byteAtDisplay(tab, row.text, room); try text.appendSlice(arena, row.text[0..cut]); col += @intCast(File.displayWidth(tab, row.text[0..cut])); + if (metaShown(tab, row, room)) { + const meta: u16 = @intCast(File.displayWidth(tab, row.meta)); + while (col < at + room - meta) : (col += 1) try text.append(arena, ' '); + try text.appendSlice(arena, row.meta); + col += meta; + } } } return .{ .text = text.items, .parts = parts.items }; } +/// Whether row `row`'s meta fits `room` cells after its text. +pub fn metaShown(tab: u16, row: Row, room: u16) bool { + return row.meta.len > 0 and File.displayWidth(tab, row.text) + 2 + File.displayWidth(tab, row.meta) <= room; +} + /// The word under column `col` of band row `y` of pane `id`, at the /// tagline's pitch: what B2 executes and B3 looks at. pub fn wordAt(p: *Pardes, arena: std.mem.Allocator, id: usize, y: u16, col: u16) !?[]const u8 { diff --git a/core/Pick.zig b/core/Pick.zig index 6026f11b..cb5f605d 100644 --- a/core/Pick.zig +++ b/core/Pick.zig @@ -458,7 +458,7 @@ const Target = union(enum) { none, place: struct { path: []const u8, at: look.Sp /// Row `i` as the band shows it and what it points at, its text in /// `arena`. -const Row = struct { text: []const u8, pre: u16 = 0, faint: u16 = 0, dim: bool = false, marks: []const u16 = &.{}, target: Target = .none }; +const Row = struct { text: []const u8, pre: u16 = 0, faint: u16 = 0, dim: bool = false, marks: []const u16 = &.{}, target: Target = .none, meta: []const u8 = "" }; fn rowAt(p: *Pardes, pk: *const Pick, arena: std.mem.Allocator, i: usize) !Row { const dir = pk.dir.slice(); @@ -526,7 +526,10 @@ fn rowAt(p: *Pardes, pk: *const Pick, arena: std.mem.Allocator, i: usize) !Row { const f = owner.file orelse return row; row.target = .{ .place = .{ .path = f.path, .at = .{ .line = cand.ref } } }; }, - .themes => {}, + // The theme in use says so, whichever the window wears (POLISH 12). + .themes => if (p.custom_theme == null and cand.ref == p.settings.theme) { + row.meta = "in use"; + }, .recent, .jumplist, .list, .grep, .all => { const t = look.parsePathLine(text); row.pre = @intCast(t.end); @@ -669,7 +672,7 @@ pub fn steps(p: *Pardes, arena: std.mem.Allocator) ![]Band.Step { const rows = try arena.alloc(Band.Row, w.hi - w.lo); for (rows, w.lo..) |*row, i| { const r = try rowAt(p, pk, arena, i); - row.* = .{ .text = r.text, .on = i == s.rows.at, .mark = marked(pk, idOf(pk, i)) != null, .dim = r.dim, .pre = r.pre, .faint = r.faint, .marks = r.marks, .index = @intCast(i) }; + row.* = .{ .text = r.text, .on = i == s.rows.at, .mark = marked(pk, idOf(pk, i)) != null, .dim = r.dim, .pre = r.pre, .faint = r.faint, .marks = r.marks, .index = @intCast(i), .meta = r.meta }; } out[0] = .{ .rows = rows }; return out; @@ -1930,3 +1933,54 @@ test "n and N walk the newest list or search word, or the one Looked at (SPEC § p.update(.{ .key = .{ .cp = 'n', .text = "n" } }); try std.testing.expect(pane.places.current != null and !std.meta.eql(was, pane.places.current)); } + +test "the themes picker marks the theme in use: `in use` at its row's right end in the dim ink, the cursor on it when it opens, the mark staying on it while the window wears another (POLISH 12, UX A15)" { + const Key_ = pardes.Key; + const p = try Pardes.init(std.testing.allocator, .{ .tty_only = true, .cols = 120, .rows = 40 }); + defer p.deinit(); + const pane = try p.setTestFile("one\n"); + const id = p.view().active; + var frame = std.heap.ArenaAllocator.init(std.testing.allocator); + defer frame.deinit(); + const a = frame.allocator(); + const was = p.settings.theme; + for (" tt") |c| p.update(.{ .key = .{ .cp = c } }); + const s = &p.view().tag_state; + try std.testing.expectEqual(@as(u16, @intCast(was)), s.rows.at); + const Find = struct { + fn row(band: Band, text: []const u8) ?Band.Row { + for (band.steps[0..band.nsteps]) |step| for (step.rows) |r| if (std.mem.eql(u8, r.text, text)) return r; + return null; + } + }; + var band = (try Band.of(p, a, pane, id)).?; + const worn = Find.row(band, pardes.colors.themes[was].name).?; + try std.testing.expectEqualStrings("in use", worn.meta); + try std.testing.expect(worn.on); + // One row says it. + var said: usize = 0; + for (band.steps[0..band.nsteps]) |step| for (step.rows) |r| { + said += @intFromBool(r.meta.len > 0); + }; + try std.testing.expectEqual(@as(usize, 1), said); + // Drawn at the row's right end, in the dim ink of the selection it is on. + _ = try p.render(a); + const layer = &p.surface.tag_layers[pardes.BAND_LAYER]; + const roles = &p.chromeTheme().roles; + const on = roles.selectedOn(if (pardes.Trail.reading(p, pane)) .reading_focused else .focused); + var found = false; + for (0..layer.rows) |row| { + const cells = layer.cells[row * layer.cols ..][0..layer.cols]; + var at: usize = 0; + while (at + 6 <= cells.len) : (at += 1) { + if (!std.mem.eql(u8, cells[at].grapheme(), "i") or !std.mem.eql(u8, cells[at + 1].grapheme(), "n") or !std.mem.eql(u8, cells[at + 3].grapheme(), "u")) continue; + try std.testing.expectEqual(pardes.Color{ .rgb = on.dim }, cells[at].style.fg); + found = true; + } + } + try std.testing.expect(found); + // The window wearing the next: the mark stays on the theme in use. + p.update(.{ .key = .{ .cp = if (was + 1 < pardes.colors.themes.len) Key_.down else Key_.up } }); + band = (try Band.of(p, a, pane, id)).?; + try std.testing.expectEqualStrings("in use", Find.row(band, pardes.colors.themes[was].name).?.meta); +} diff --git a/core/draw.zig b/core/draw.zig index 673d3386..9f9abb58 100644 --- a/core/draw.zig +++ b/core/draw.zig @@ -945,6 +945,11 @@ fn joinBand(p: *Pardes, s: *Surface, arena: std.mem.Allocator, pane: *Pane, r: R }; b = next; } + // Its meta, right-aligned in the part (Band.line), dim. + if (pardes.Band.metaShown(tab, part.row, part.width) and part.col + part.width <= columns) { + const meta: u16 = @intCast(panes.File.displayWidth(tab, part.row.meta)); + for (part.col + part.width - meta..part.col + part.width) |x| t.at(@intCast(x), row).style.fg = .{ .rgb = on.dim }; + } } } const count = @as(usize, columns) * rows; -- cgit v1.3 From e563ef0d896fc66c3e88c274b25f09bb75f80fea Mon Sep 17 00:00:00 2001 From: Gabriel Schneider Date: Wed, 25 Nov 2026 05:49:06 -0300 Subject: Pick, body_layer, look, Messages, draw, colors: a picker's preview legible as one (UX DESIGN.md D7; the user missed it: S's 04 showed a preview from body line 1 with no mark where a hit lands and a tag naming the file as the pane's own): its landing line, the body line the cursor row lands on in the landing pane while that pane shows the row's file (Pick.landingLine), on the hit ground across the body's width with `▸` in the key ink in the gutter's cell after its number (where a prompt's current place has it), the place its row points at (a Grep's match at the row's column) on the current hit's ground over the places lit; placed a third of the way down the body (look.focusPaneLine's `.third`: ⌈rows/3⌉ rows of context above, clamped at the top, a text that fits shown whole), where it was centred; a Find row lands on line 1 and that is marked (its Enter lands there); the notice row's left, while a picker previews, says `⏎ lands in @pN's reader · its text is the preview · S-⏎ a new pane` (`⏎ lands here · …` in the pane itself) in the dim ink with the owner's address in the text's (Pick.sentence, Messages.Row.quiet_left and word), before any message; the notice row's dim words in the dim ink of the tagline's ground (colors.Roles.notice, 3:1 at least; it was the tagline's ink half mixed to its ground); a preview whose next file is not read yet keeps the previous one (the read is synchronous: the body is never blank) and a row with no file leaves the body; TEST FIRST: Pick.zig "a picker's preview is legible as one" (on the parent the landing line has no ground, line 40 sits mid-body and the notice row says the path): line 40 of an 80-line file at ⌈rows/3⌉, its row on the hit ground and the one above not, `▸` in the key ink, the sentence and its address, the row its own again at rest; colors.zig's floors test holds the notice row's inks too (fromTheme's comptime quota raised for them); core-test 1069/1239 (170 skipped) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_016Y9MNBFhdevVu48bvL9kCE --- core/Messages.zig | 12 +++++-- core/Pick.zig | 98 ++++++++++++++++++++++++++++++++++++++++++++++++++++- core/body_layer.zig | 45 ++++++++++++++++++++++++ core/colors.zig | 7 ++-- core/draw.zig | 11 +++++- core/look.zig | 6 ++-- 6 files changed, 170 insertions(+), 9 deletions(-) (limited to 'core/Pick.zig') diff --git a/core/Messages.zig b/core/Messages.zig index 41344d1f..6231e3d1 100644 --- a/core/Messages.zig +++ b/core/Messages.zig @@ -679,6 +679,10 @@ pub const Row = struct { text: []const u8 = "", /// The message the left says, when it says one. lead: ?*const Said = null, + /// The left in the dim ink (a picker's sentence, UX D7), but for the + /// bytes `word` (an address, in the text's). + quiet_left: bool = false, + word: [2]usize = .{ 0, 0 }, }; /// Room for the notice row's line: the widest window's at the tagline's @@ -704,8 +708,10 @@ pub fn noticeRow(p: *const Pardes, width: usize, out: *[notice_row_cap]u8) Row { live += 1; if (s.kind == .question) questions += 1; } - const lead = m.headline(); - if (lead) |s| { + // While a picker previews, its sentence (UX D7), before any message. + const said = pardes.Pick.sentence(p, &w); + const lead = if (said == null) m.headline() else null; + if (said != null) {} else if (lead) |s| { w.print("{s} ", .{s.kind.glyph()}) catch {}; // Its cause first, unless its words name it already. const words = s.words(); @@ -743,7 +749,7 @@ pub fn noticeRow(p: *const Pardes, width: usize, out: *[notice_row_cap]u8) Row { for (0..gap) |_| w.writeByte(' ') catch {}; const right_at = w.end; w.writeAll(tail) catch {}; - return .{ .left = cut, .right = right_at, .text = w.buffered(), .lead = lead }; + return .{ .left = cut, .right = right_at, .text = w.buffered(), .lead = lead, .quiet_left = said != null, .word = said orelse .{ 0, 0 } }; } /// What notice band `i` says. The grid pass and the band layers both diff --git a/core/Pick.zig b/core/Pick.zig index cb5f605d..efadc881 100644 --- a/core/Pick.zig +++ b/core/Pick.zig @@ -680,6 +680,45 @@ pub fn steps(p: *Pardes, arena: std.mem.Allocator) ![]Band.Step { // ---- the preview ---- +/// The line (from 0) pane `pane`'s body lands the live picker's cursor row +/// on, while it is that picker's landing pane previewing that row's file +/// (UX D7: drawn on the hit ground, body_layer.zig); null else. +pub fn landingLine(p: *Pardes, arena: std.mem.Allocator, pane: *const Pane) ?usize { + const pk = live(p) orelse return null; + if (!pk.previews or pk.landing != pane.serial or pk.source == .themes) return null; + const s = &p.view().tag_state; + if (pk.shown != s.rows.at or count(p, pk) == 0) return null; + const row = rowAt(p, pk, arena, s.rows.at) catch return null; + const place = switch (row.target) { + .place => |t| t, + else => return null, + }; + const f = pane.file orelse return null; + if (!std.mem.eql(u8, f.path, place.path)) return null; + return @intCast(@max(0, pane.body.cur_row)); +} + +/// The notice row's sentence while a picker previews (UX D7), written to +/// `w`: where Enter lands (`here`, or the owner's reader by its address, +/// a word to Look at), that the body is the preview, and Shift-Enter's new +/// pane; the address's bytes in what was written, or null with no picker +/// previewing. +pub fn sentence(p: *const Pardes, w: *std.Io.Writer) ?[2]usize { + const pk = live(p) orelse return null; + if (!pk.previews or pk.source == .themes) return null; + if (pk.landing == pk.owner) { + w.writeAll("⏎ lands here") catch return null; + } else { + w.writeAll("⏎ lands in ") catch return null; + } + const lo = w.end; + if (pk.landing != pk.owner) w.print("@p{d}", .{pk.owner}) catch return null; + const hi = w.end; + if (pk.landing != pk.owner) w.writeAll("'s reader") catch return null; + w.writeAll(" · its text is the preview · S-⏎ a new pane") catch return null; + return .{ lo, hi }; +} + /// The landing pane's body showing the current row's place (SPEC §5.3): /// a file at its line, the query's matches lit for a Grep. Its own text is /// set aside the first time, put back when the picker rolls up. A file an @@ -745,7 +784,7 @@ fn preview(p: *Pardes, pk: *Pick) void { pane.body.cur_col = 0; return; } - look.focusPaneLine(p, id, at, .center); + look.focusPaneLine(p, id, at, .third); // A Grep's matches in the file lit, as its own pane would have them. if (pk.source == .grep) pane.places.search(p, pane, .list, pk.id, std.mem.trim(u8, s.field.text(), " "), true, null, false); } @@ -1984,3 +2023,60 @@ test "the themes picker marks the theme in use: `in use` at its row's right end band = (try Band.of(p, a, pane, id)).?; try std.testing.expectEqualStrings("in use", Find.row(band, pardes.colors.themes[was].name).?.meta); } + +test "a picker's preview is legible as one (UX D7): its landing line on the hit ground with `▸` in the gutter, a third of the body above it, and the notice row saying where Enter lands" { + const p = try Pardes.init(std.testing.allocator, .{ .tty_only = true, .cols = 140, .rows = 50 }); + defer p.deinit(); + p.settings.jumps = .walk; + var tmp = std.testing.tmpDir(.{}); + defer tmp.cleanup(); + var text: std.ArrayList(u8) = .empty; + defer text.deinit(std.testing.allocator); + for (1..81) |i| try text.print(std.testing.allocator, "line {d} of the file\n", .{i}); + const path = try testFile(p, &tmp, "long.zig", text.items); + defer p.gpa.free(path); + _ = try p.setTestFile("held\n"); + const asker = p.view().active; + Trail.keep(p.panes[asker].?); + const rows = try std.fmt.allocPrint(std.testing.allocator, "{s}:40:6 line 40 of the file\n", .{path}); + defer std.testing.allocator.free(rows); + open(p, asker, .list, "Refs", "", rows); + const pk = live(p).?; + const reader = p.paneBySerial(pk.landing).?; + p.update(.tick); + const pane = p.panes[reader].?; + try std.testing.expectEqualStrings(path, pane.file.?.path); + var frame = std.heap.ArenaAllocator.init(std.testing.allocator); + defer frame.deinit(); + const s = try p.render(frame.allocator()); + const r = p.view().rects[reader]; + const body_y = p.bodyTop(pane, r); + // Line 40 a third of the way down: ⌈rows/3⌉ rows of context above it. + var at: ?u16 = null; + for (0..pane.rows) |row| if (pane.wrapAt(p.settings.tab, @intCast(row)).line == 39) { + at = @intCast(row); + break; + }; + try std.testing.expectEqual(@as(?u16, @intCast((pane.rows + 2) / 3)), at); + const y = body_y + at.?; + const roles = &p.chromeTheme().roles; + const tx = r.x + pardes.config.GUTTER; + const gutter = File.gutterWidth(pane); + // Its text on the hit ground across the row; the row above as it was. + for (gutter..r.w - pardes.config.GUTTER) |x| try std.testing.expectEqual(pardes.Color{ .rgb = roles.hit }, s.at(tx + @as(u16, @intCast(x)), y).style.bg); + try std.testing.expect(!std.meta.eql(s.at(tx + gutter + 2, y - 1).style.bg, pardes.Color{ .rgb = roles.hit })); + // `▸` in the key ink in the gutter's cell after the number. + const mark = s.at(tx + gutter - 1, y); + try std.testing.expectEqualStrings("▸", mark.grapheme()); + try std.testing.expectEqual(pardes.Color{ .rgb = roles.key }, mark.style.fg); + // The notice row: where Enter lands, the owner's address a word in it. + var buf: [pardes.Messages.notice_row_cap]u8 = undefined; + const said = pardes.Messages.noticeRow(p, 120, &buf); + const want = try std.fmt.allocPrint(frame.allocator(), "⏎ lands in @p{d}'s reader · its text is the preview · S-⏎ a new pane", .{p.panes[asker].?.serial}); + try std.testing.expect(std.mem.startsWith(u8, said.text, want)); + try std.testing.expect(said.quiet_left); + try std.testing.expectEqualStrings(try std.fmt.allocPrint(frame.allocator(), "@p{d}", .{p.panes[asker].?.serial}), said.text[said.word[0]..said.word[1]]); + // At rest: no ground, no mark, the row back to its own. + p.update(.{ .key = .{ .cp = pardes.Key.escape } }); + try std.testing.expect(!pardes.Messages.noticeRow(p, 120, &buf).quiet_left); +} diff --git a/core/body_layer.zig b/core/body_layer.zig index 6ce2b6be..7bff3c31 100644 --- a/core/body_layer.zig +++ b/core/body_layer.zig @@ -349,7 +349,11 @@ pub fn renderBody(p: *Pardes, s: *Surface, arena: std.mem.Allocator, pane: *Pane panes.File.recolorSyntax(p, s, pane, f, r, tx, tw, body_h); panes.Tables.paint(p, s, pane, r, tx, tw, body_h); drawWrapMarkers(p, s, pane, r, tx, tw, body_h, pane_bg); + // A picker's landing line under the places it lights (UX D7). + const landing = pardes.Pick.landingLine(p, arena, pane); + if (landing) |line| paintLanding(p, s, pane, r, tx, tw, body_h, line); pane.places.paint(p, s, pane, r, body_h); + if (landing) |line| paintLandingSpan(p, s, pane, r, f, line); pardes.Prompt.paintGutter(p, s, pane, r, body_h); panes.Query.paint(p, s, pane, r, body_h); } else if (pane.isTerminal()) { @@ -650,6 +654,47 @@ pub fn wordAt(p: *Pardes, arena: std.mem.Allocator, id: usize, row: usize, col: return text.items[b.lo..b.hi]; } +/// A picker's landing line (UX D7): its text on the hit ground across +/// the body's width, and `▸` in the key ink in the gutter's cell after its +/// number (the one a prompt's current place has, Prompt.paintGutter), on +/// each row it wraps onto. +fn paintLanding(p: *Pardes, s: *Surface, pane: *Pane, r: Rect, tx: u16, tw: u16, body_h: u16, line: usize) void { + const roles = &p.chromeTheme().roles; + const gutter = File.gutterWidth(pane); + const number = gutter -| File.laneCells(pane) -| pane.layers.heat -| 1; + const body_y = p.bodyTop(pane, r); + var vr: u16 = pane.context_rows; + while (vr < body_h) : (vr += 1) { + const w = pane.wrapAt(p.settings.tab, vr); + if (w.line != @as(i32, @intCast(line))) continue; + for (gutter..tw) |x| { + const cell = s.at(tx + @as(u16, @intCast(x)), body_y + vr); + cell.default = false; + cell.style.bg = .{ .rgb = roles.hit }; + } + if (gutter > 0 and w.at == 0) { + var style = s.at(tx + number, body_y + vr).style; + style.fg = .{ .rgb = roles.key }; + s.set(tx + number, body_y + vr, "▸", style); + } + } +} + +/// The landing line's matched span (a Grep's match at the row's column) on +/// the current hit's ground, over the places lit on it (UX D7). +fn paintLandingSpan(p: *Pardes, s: *Surface, pane: *Pane, r: Rect, f: *panes.File.State, line: usize) void { + if (!pane.places.shows(pane)) return; + const hits = pane.places.hits.items; + const ls = File.lineStart(p.gpa, f, line); + const caret = ls + @as(usize, @intCast(@max(0, pane.body.cur_col))); + var i = panes.Places.firstFrom(hits, ls); + while (i < hits.len and hits[i].start <= caret) : (i += 1) { + if (hits[i].end <= caret) continue; + File.paintWordSelection(p, s, pane, r, @intCast(line), @intCast(hits[i].start - ls), @intCast(hits[i].end - ls), p.chromeTheme().roles.hit_current); + return; + } +} + /// Painted targets (SPEC §4.4), while a motion root's level shows in this /// body's tag: each of its keys at the line it would go to, in the gutter /// (`g e t b .` for `g`; for `]` the next and for `[` the previous diff --git a/core/colors.zig b/core/colors.zig index d4abf2b5..6b578f09 100644 --- a/core/colors.zig +++ b/core/colors.zig @@ -562,7 +562,7 @@ pub const ChromeTheme = struct { pub fn fromTheme(th: *const Theme) ChromeTheme { // The initial chrome is resolved at compile time: contrast takes pow. - @setEvalBranchQuota(200_000); + @setEvalBranchQuota(1_000_000); const active_bg = focusTint(th); const active_fg = th.tag_active_fg orelse th.tag_fg; // A name is always tinted: a theme that names no tint gets one of @@ -619,6 +619,8 @@ pub const Inks = struct { ground: [3]u8, text: [3]u8, dim: [3]u8, rule: [3]u8 }; pub const Roles = struct { tag: [4]Inks, selected: [4]Inks, + /// The notice row's (the tagline's ground): its dim words. + notice: Inks, /// Key cells, a level's or a row's key letters, `▶`, `•`, a target's /// keys: 4.5:1 on every tag ground and on the selection. key: [3]u8, @@ -669,6 +671,7 @@ pub const Roles = struct { inks.* = inksOn(ground, ink); selected.* = inksOn(selectionOf(th.tag_sel_bg orelse th.sel_bg, ground, inks.text), inks.text); } + r.notice = inksOn(th.tagline_bg orelse th.tag_bg, th.tagline_fg orelse th.tag_fg); const tag_grounds = [_][3]u8{ plain, focused, reading, r.selected[0].ground, r.selected[1].ground, r.selected[2].ground, r.selected[3].ground }; r.key = pushAway(th.box, &tag_grounds, ink_floor); r.match = pushAway(matchHue(th), &tag_grounds, ink_floor); @@ -1547,7 +1550,7 @@ test "every theme's walk UI roles meet their floors on every ground they are dra const body_ink = th.fg orelse th.tag_fg; const tags = [_][3]u8{ r.tag[0].ground, r.tag[1].ground, r.tag[2].ground, r.selected[0].ground, r.selected[1].ground, r.selected[2].ground, r.selected[3].ground }; const messages = [_][3]u8{ r.tag[0].ground, r.tag[1].ground, r.tag[2].ground, page }; - for (r.tag ++ r.selected) |inks| { + for (r.tag ++ r.selected ++ [1]Inks{r.notice}) |inks| { const text = contrast(inks.text, inks.ground); try checks.append(a, .{ .what = "text", .got = text, .floor = @min(Roles.text_floor, Reach.of(&.{inks.ground})) }); try checks.append(a, .{ .what = "dim", .got = contrast(inks.dim, inks.ground), .floor = @min(Roles.dim_floor, text) }); diff --git a/core/draw.zig b/core/draw.zig index 1e53d1d0..16dfde5e 100644 --- a/core/draw.zig +++ b/core/draw.zig @@ -640,12 +640,21 @@ fn paintNoticeRow(p: *Pardes, s: *Surface) !void { 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); if (layer.rows == 0) return; - const dim: Color = .{ .rgb = colors.mix(chrome.tagline_fg, chrome.tagline_bg) }; + // 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 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])); const right = @min(cells.len, panes.File.displayWidth(tab, row.text[0..row.right])); + // A picker's sentence: dim, its address in the text's ink. + if (row.quiet_left) { + const lo = panes.File.displayWidth(tab, row.text[0..@min(row.word[0], row.left)]); + const hi = panes.File.displayWidth(tab, row.text[0..@min(row.word[1], row.left)]); + for (cells[0..left], 0..) |*cell, x| if ((x < lo or x >= hi) and std.meta.eql(cell.style.fg, ink)) { + cell.style.fg = dim; + }; + } 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 }; diff --git a/core/look.zig b/core/look.zig index 21043250..b3354a5c 100644 --- a/core/look.zig +++ b/core/look.zig @@ -803,7 +803,7 @@ pub fn advanceLookHover(p: *Pardes) void { p.look_hover_wait = null; } -pub fn focusPaneLine(p: *Pardes, id: usize, at_in: Spot, landing: enum { center, keep }) void { +pub fn focusPaneLine(p: *Pardes, id: usize, at_in: Spot, landing: enum { center, third, keep }) void { if (id >= MAX_PANES) return; const pane = p.panes[id] orelse return; p.view().active = id; @@ -822,7 +822,9 @@ pub fn focusPaneLine(p: *Pardes, id: usize, at_in: Spot, landing: enum { center, if (at.line > panes.File.nlines(p.gpa, f)) return; // centred (its first row of text half the body's rows down, as // zz), clamped at the top; a text that fits is shown whole - if (landing == .center) panes.File.setTop(pane, if (pane.textFits()) .{ .line = 0 } else panes.File.walkRows(p.settings.tab, pane, .{ .line = at.line - 1, .row = panes.File.rowOf(p.settings.tab, pane, at.line - 1, 0) }, -@as(i64, pane.rows / 2)).to); + // or a third of them down (a picker's preview, UX D7: context above + // its landing line, the rest below) + if (landing != .keep) panes.File.setTop(pane, if (pane.textFits()) .{ .line = 0 } else panes.File.walkRows(p.settings.tab, pane, .{ .line = at.line - 1, .row = panes.File.rowOf(p.settings.tab, pane, at.line - 1, 0) }, -@as(i64, if (landing == .third) (pane.rows + 2) / 3 else pane.rows / 2)).to); } pane.body.cur_row = std.math.cast(i32, at.line - 1) orelse return; pane.body.cur_col = columnOn(pane, pane.body.cur_row, at.col); -- cgit v1.3