From 98f5abfc10d9984a69940a6805d974018e5ea01e Mon Sep 17 00:00:00 2001 From: Gabriel Schneider Date: Wed, 25 Nov 2026 10:02:29 -0300 Subject: Messages, body_layer, normal, mouse, Core: a message's detail unrolls only on request (UX D13, E5 fix 3): K with one selection on a line a message with a detail names, SPC e there, or a Look (B3) on its words after the line unrolls it under that line, and the caret leaving the line (or the keyboard another pane) rolls it up; the caret passing a line never inserts or removes rows; THE CAUSE: Messages.detailUnder showed the detail of the message naming the caret's line whenever the caret was on it (C's rule, spec §10.2), so j over a build error pushed the text below down and k pulled it back (UX A16, E2 "detail still unrolls under the caret"); THE FIX: Said.open (the question's Diff's flag, already in the dump and the digest; its doc said "whatever the caret" and nothing read it) is the request: detailUnder shows the message whose words the caret's line shows (the first naming it, firstAt, as messageGhosts draws them) only while it is open, and a question's Diff under its place whatever the caret; Messages.detailAt finds it (not a question's: its Diff is `d`); normal.zig's K takes it with one selection, else keep's prompt as before; Messages.act (SPC e) unrolls it first when the caret's line has one not shown, the walk as before when asked again; mouse.zig: a Look on its words after the line (body_layer.messageAt: from their glyph two blanks after the line, read from the frame drawn last, as wordAt reads a detail's word; wordAt and it share drawnRow) toggles it; Core.update: around a key and a click, Messages.unrolledAt/rollUp roll every unrolled detail (not a question's Diff) up when the keyboard's pane or its caret's line changed (a motion along the line, or a click on the detail, which puts the caret on the line it explains, keeps it: C's G-fixed rule holds, the detail's rows are read-only text for the mouse); nothing read with no detail unrolled; the Message builtin's doc says it (docs/typ/builtins-tui.json and -gui.json the same text); TEST FIRST: body_layer.zig "a message's detail unrolls only on request (UX D13): the caret passing its line inserts no rows; K there unrolls it ...; K with two selections is keep's" (fails on the base at body_layer.zig:1346: the caret on line 3 put its detail under it); C's two tests ask for the detail (err.open, and K after k k) where they set the caret; core-test 1084/1255 (171 skipped), process-test 0 of 147 failed (no golden moved); a user hit it: every build error and diagnostic with detail lines pushed the text below down as the caret passed 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/Core.zig | 9 ++++- core/Messages.zig | 98 +++++++++++++++++++++++++++++++++++++-------- core/body_layer.zig | 113 ++++++++++++++++++++++++++++++++++++++++++++++++---- core/builtins.zig | 5 ++- core/mouse.zig | 6 +++ core/normal.zig | 11 ++++- 6 files changed, 213 insertions(+), 29 deletions(-) (limited to 'core') diff --git a/core/Core.zig b/core/Core.zig index 5b6eba75..056af9db 100644 --- a/core/Core.zig +++ b/core/Core.zig @@ -1795,9 +1795,16 @@ fn updateInner(p: *Pardes, ev: Event) void { p.can_ask = true; defer p.can_ask = false; p.typedInto(); + // A detail unrolled on request rolls up at the next motion (UX D13). + const was = Messages.unrolledAt(p); @import("keys.zig").handleKey(p, key); + Messages.rollUp(p, was); + }, + .mouse => |m| { + const was = Messages.unrolledAt(p); + mouse.handleMouse(p, m); + Messages.rollUp(p, was); }, - .mouse => |m| mouse.handleMouse(p, m), .paste => |bytes| { p.typedInto(); edit.applyPaste(p, bytes) catch |err| p.reportError(.at(v.active), "paste", err); diff --git a/core/Messages.zig b/core/Messages.zig index 2cb196f6..b821ab35 100644 --- a/core/Messages.zig +++ b/core/Messages.zig @@ -129,15 +129,17 @@ pub const Said = struct { text: Buf(256) = .{}, places: [max_places]Place = undefined, places_len: u8 = 0, - /// The lines that explain it, shown under its first place's line while - /// the caret is on it. + /// The lines that explain it, shown under the line it names when asked + /// (`open`). detail: [max_detail]Buf(128) = undefined, detail_len: u8 = 0, /// The serial of the pane it is about, 0 for none in particular. pane: u32 = 0, asks: Ask = .none, - /// Its detail shown under its first place's line whatever the caret - /// (a question's Diff). + /// Its detail unrolled, on request only (UX D13): K, SPC e or a Look on + /// its words on the caret's line (detailAt), shown under that line until + /// the caret leaves it (rollUp); a question's Diff under its place + /// whatever the caret, until `d` again. open: bool = false, /// How many times in a row it was said. n: u16 = 1, @@ -520,8 +522,9 @@ pub fn answer(p: *Pardes, i: usize, key: u8) bool { return true; } -/// SPC e (the Message word, SPEC §10.4), on the message the notice row -/// leads with: an error that names places lands them as a list in pane +/// SPC e (the Message word, SPEC §10.4): on a line a message names, its +/// detail not unrolled, that detail (UX D13); else on the message the +/// notice row leads with: an error that names places lands them as a list in pane /// `id`'s walk (Pick's `list`, its word `✗ ` in the trail), the /// first landed on, n and N walking the rest, and the error goes (a /// +Search under the pane where jumps do not walk, or for a 9P script: @@ -529,6 +532,13 @@ pub fn answer(p: *Pardes, i: usize, key: u8) bool { /// else, or nothing, opens the history. pub fn act(p: *Pardes, id: usize) void { const m = &p.messages; + // On a line a message names, its detail not unrolled: unrolled (UX + // D13), the message kept; asked again, the walk below. + if (id < MAX_PANES) if (p.panes[id]) |pane| if (pane.focus == .body) if (detailAt(p, pane, pane.body.cur_row)) |s| if (!s.open) { + s.open = true; + p.needs_frame = true; + return; + }; const lead = m.headline() orelse return history(p, id); if (lead.kind == .question) { p.view().answering = lead.pane; @@ -949,29 +959,83 @@ pub fn collectNotices(p: *Pardes, pane: *Pane, r: Rect) void { } } -/// A message's detail under the caret's line (SPEC §10.2), as a body of -/// `body_h` rows shows it: the row of that line's last row, how many of the -/// detail's lines fit under it, the message (the first naming the line, as -/// the words after it are); only in the pane with the keyboard, in its body. -/// Bounded by the live messages' places and the rows shown. +/// A message's detail unrolled (SPEC §10.2, UX D13: on request only), as a +/// body of `body_h` rows shows it: the row of its line's last row, how many +/// of the detail's lines fit under it, the message. The line is the +/// caret's, where it was asked (the caret leaving it rolls it up), or a +/// question's place; its message the first naming it, as the words after +/// it are (firstAt). The caret passing a line never unrolls one. Only in +/// the pane with the keyboard, in its body. Bounded by the live messages' +/// places and the rows shown. pub fn detailUnder(p: *const Pardes, pane: *Pane, active: bool, body_h: u16) ?struct { row: u16, rows: u16, said: *const Said } { if (!active or pane.focus != .body or p.messages.live_len == 0) return null; const f = pane.file orelse return null; - const caret = @max(0, pane.body.cur_row); - const said = found: for (p.messages.live[0..p.messages.live_len]) |*s| { - for (s.places[0..s.places_len]) |*place| if (place.line == caret + 1 and std.mem.eql(u8, place.path.slice(), f.path)) break :found s; - } else return null; + const m = &p.messages; + const caret: u32 = @intCast(@max(0, pane.body.cur_row)); + const said, const line = found: { + if (m.firstAt(f.path, caret + 1)) |i| if (m.live[i].open) break :found .{ &m.live[i], @as(i32, @intCast(caret)) }; + for (m.live[0..m.live_len], 0..) |*s, i| if (s.open and s.kind == .question and s.places_len > 0 and std.mem.eql(u8, s.places[0].path.slice(), f.path)) + if (m.firstAt(f.path, s.places[0].line) == i) break :found .{ s, @as(i32, @intCast(s.places[0].line -| 1)) }; + return null; + }; if (said.detail_len == 0) return null; var row: u16 = 0; while (row < body_h) : (row += 1) { - if (pane.wrapAt(p.settings.tab, row).line != caret) continue; - if (row + 1 < body_h and pane.wrapAt(p.settings.tab, row + 1).line == caret) continue; + if (pane.wrapAt(p.settings.tab, row).line != line) continue; + if (row + 1 < body_h and pane.wrapAt(p.settings.tab, row + 1).line == line) continue; const k: u16 = @intCast(@min(said.detail_len, body_h - row - 1)); return if (k == 0) null else .{ .row = row, .rows = k, .said = said }; } return null; } +/// The first live message naming line `line` (1-based) of `path`: the one +/// whose words are drawn after that line (body_layer messageGhosts). +fn firstAt(m: *const Messages, path: []const u8, line: u32) ?usize { + for (m.live[0..m.live_len], 0..) |*s, i| for (s.places[0..s.places_len]) |*place| { + if (line > 0 and place.line == line and std.mem.eql(u8, place.path.slice(), path)) return i; + }; + return null; +} + +/// The message whose words line `row` (0-based) of `pane`'s file shows, +/// when it has a detail to unroll (UX D13): what K with one selection, SPC +/// e and a Look on those words ask for. Not a question's (its Diff is `d`). +pub fn detailAt(p: *Pardes, pane: *const Pane, row: i32) ?*Said { + const f = pane.file orelse return null; + if (row < 0) return null; + const s = &p.messages.live[p.messages.firstAt(f.path, @intCast(row + 1)) orelse return null]; + if (s.detail_len == 0 or s.kind == .question) return null; + return s; +} + +/// The keyboard's pane and its caret's line while a detail is unrolled on +/// request; null with none (nothing to roll up: nothing else read). +pub const Caret = struct { active: usize, row: i32 }; + +pub fn unrolledAt(p: *const Pardes) ?Caret { + const v = p.view(); + for (p.messages.live[0..p.messages.live_len]) |*s| if (s.open and s.kind != .question) { + const pane = p.panes[v.active] orelse return .{ .active = v.active, .row = -1 }; + return .{ .active = v.active, .row = pane.body.cur_row }; + }; + return null; +} + +/// After a key or a click (Core.update): the caret left its line, or the +/// keyboard went to another pane, since `was`: every detail unrolled on +/// request rolls up (UX D13: the next motion; a motion along the line, or +/// a click on the detail, which puts the caret on the line it explains, +/// keeps it), a question's Diff stays. +pub fn rollUp(p: *Pardes, was: ?Caret) void { + const before = was orelse return; + const now = unrolledAt(p) orelse return; + if (std.meta.eql(before, now)) return; + for (p.messages.live[0..p.messages.live_len]) |*s| if (s.kind != .question) { + s.open = false; + }; +} + /// The bands a pane shows over `r` below its `tag_rows`: the live view's /// each step, and any view's for its kind's facts (Kind.viewOf), made from /// what a dump keeps (the bands are derived). diff --git a/core/body_layer.zig b/core/body_layer.zig index 0107b3e0..f00da4a9 100644 --- a/core/body_layer.zig +++ b/core/body_layer.zig @@ -641,6 +641,28 @@ fn messageGhosts(p: *Pardes, s: *Surface, pane: *Pane, tx: u16, tw: u16, body_y: /// frame drawn last (its body layer when it has one, else the grid): a /// message's detail is text no buffer holds, read as it is shown. pub fn wordAt(p: *Pardes, arena: std.mem.Allocator, id: usize, row: usize, col: usize) !?[]const u8 { + const text = try drawnRow(p, arena, id, row) orelse return null; + const b = pardes.tagline.wordBoundsAtCol(text, panes.File.rawAtDisplay(p.settings.tab, text, col)) orelse return null; + if (b.lo == b.hi) return null; + return text[b.lo..b.hi]; +} + +/// The message whose words are drawn after its line at body row `row`, +/// text column `col` of pane `id` in the frame drawn last, when it has a +/// detail: a Look there unrolls it (UX D13). The words start at their +/// glyph, two blanks after the line (messageGhosts). +pub fn messageAt(p: *Pardes, arena: std.mem.Allocator, id: usize, row: u16, col: usize) !?*pardes.Messages.Said { + const pane = p.panes[id] orelse return null; + const said = pardes.Messages.detailAt(p, pane, pane.wrapAt(p.settings.tab, pane.textRow(row)).line) orelse return null; + const text = try drawnRow(p, arena, id, row) orelse return null; + var mark: [8]u8 = undefined; + const at = std.mem.lastIndexOf(u8, text, std.fmt.bufPrint(&mark, " {s} ", .{said.kind.glyph()}) catch return null) orelse return null; + return if (panes.File.rawAtDisplay(p.settings.tab, text, col) >= at + 2) said else null; +} + +/// Body row `row` of pane `id` as the frame drawn last shows it: its body +/// layer's when it has one, else the grid's. +fn drawnRow(p: *Pardes, arena: std.mem.Allocator, id: usize, row: usize) !?[]const u8 { const layer = &p.surface.body_layers[id]; const body = (p.surface.region(.body, id) orelse return null).rect; var text: std.ArrayList(u8) = .empty; @@ -651,9 +673,7 @@ pub fn wordAt(p: *Pardes, arena: std.mem.Allocator, id: usize, row: usize, col: if (row >= body.h) return null; for (0..body.w) |x| try text.appendSlice(arena, p.surface.at(body.x + @as(u16, @intCast(x)), body.y + @as(u16, @intCast(row))).grapheme()); } - const b = pardes.tagline.wordBoundsAtCol(text.items, panes.File.rawAtDisplay(p.settings.tab, text.items, col)) orelse return null; - if (b.lo == b.hi) return null; - return text.items[b.lo..b.hi]; + return text.items; } /// A picker's landing line (UX D7): its text on the hit ground across @@ -1141,7 +1161,7 @@ fn rowText(s: *const Surface, x: u16, y: u16, buf: []u8) []const u8 { return buf[0..n]; } -test "a build error is said where its cause is: the mark on its file's tag, its words after its line, its detail under the caret's line pushing the rows below down, the walk on the notice row" { +test "a build error is said where its cause is: the mark on its file's tag, its words after its line, its detail, asked for, under its line pushing the rows below down, the walk on the notice row" { const p = try Pardes.init(std.testing.allocator, .{ .cols = 80, .rows = 20 }); defer p.deinit(); const pane = try p.setTestFile("one\ntwo\nthree\nfour\nfive\nsix\n"); @@ -1172,8 +1192,10 @@ test "a build error is said where its cause is: the mark on its file's tag, its // elsewhere. try std.testing.expect(std.mem.indexOf(u8, rowText(s, body.x, body.y + 2, &buf), "three \u{2717} expected 2 argument(s), found 3") != null); try std.testing.expect(std.mem.indexOf(u8, rowText(s, body.x, body.y + 3, &buf), "four") != null); - // The caret on line 3: its detail under it, the rows below two rows down. + // The caret on line 3 and its detail asked for (K, UX D13): under the + // line, the rows below two rows down. pane.body.cur_row = 2; + err.open = true; _ = frame.reset(.retain_capacity); s = try p.render(frame.allocator()); try std.testing.expect(std.mem.indexOf(u8, rowText(s, body.x, body.y + 3, &buf), "const x = f(1, 2, 3);") != null); @@ -1202,6 +1224,7 @@ test "a click under a message's detail lands on the row drawn there, a click on err.detail_len = 2; pane.focus = .body; pane.body.cur_row = 2; + err.open = true; p.sync(); var frame = std.heap.ArenaAllocator.init(std.testing.allocator); defer frame.deinit(); @@ -1215,9 +1238,14 @@ test "a click under a message's detail lands on the row drawn there, a click on p.update(.{ .mouse = .{ .button = .left, .kind = .press, .col = x, .row = body.y + 6 } }); p.update(.{ .mouse = .{ .button = .left, .kind = .release, .col = x, .row = body.y + 6 } }); try std.testing.expectEqual(@as(i32, 4), pane.body.cur_row); - // On line 3 again, its detail drawn: a click on the detail is on the - // line it explains, and the detail stays. - pane.body.cur_row = 2; + // On line 3 again, its detail asked for again (the click, a motion, + // rolled it up): a click on the detail is on the line it explains, and + // the detail stays. + try std.testing.expect(!err.open); + p.update(.{ .key = .{ .cp = 'k' } }); + p.update(.{ .key = .{ .cp = 'k' } }); + p.update(.{ .key = .{ .cp = 'K' } }); + try std.testing.expect(err.open); _ = frame.reset(.retain_capacity); s = try p.render(frame.allocator()); const wrap_at = std.mem.indexOf(u8, rowText(s, body.x, body.y + 3, &buf), "Wrap").?; @@ -1317,3 +1345,72 @@ test "a motion root's level paints its targets in place of their lines' numbers, s = try p.render(a); try std.testing.expectEqualStrings("5", Field.of(s, gutter, body.y + 4, number, &buf)); } + +test "a message's detail unrolls only on request (UX D13): the caret passing its line inserts no rows; K there unrolls it under the line and the caret leaving the line rolls it up; SPC e there unrolls it; a Look on its words after the line unrolls it; K with two selections is keep's" { + const p = try Pardes.init(std.testing.allocator, .{ .cols = 80, .rows = 20 }); + defer p.deinit(); + const pane = try p.setTestFile("one\ntwo\nthree\nfour\nfive\nsix\n"); + const id = p.view().active; + const err = pardes.Messages.keep(p, .@"error", 0, "@p9 zig build", "exit 1"); + err.places[0] = .{ .line = 3, .col = 1 }; + err.places[0].path.set("/test.txt"); + err.places[0].text.set("expected 2 argument(s), found 3"); + err.places_len = 1; + err.detail[0] = .{}; + err.detail[0].set("const x = f(1, 2, 3);"); + err.detail_len = 1; + pane.focus = .body; + p.sync(); + var frame = std.heap.ArenaAllocator.init(std.testing.allocator); + defer frame.deinit(); + var buf: [512]u8 = undefined; + // The caret onto line 3 and past it: no row inserted or removed. + p.update(.{ .key = .{ .cp = 'j' } }); + p.update(.{ .key = .{ .cp = 'j' } }); + try std.testing.expectEqual(@as(i32, 2), pane.body.cur_row); + var s = try p.render(frame.allocator()); + const body = s.region(.body, id).?.rect; + try std.testing.expect(std.mem.indexOf(u8, rowText(s, body.x, body.y + 2, &buf), "three \u{2717} expected") != null); + try std.testing.expect(std.mem.indexOf(u8, rowText(s, body.x, body.y + 3, &buf), "four") != null); + // K there: its detail under the line, the rows below one lower; no + // keep prompt. + p.update(.{ .key = .{ .cp = 'K' } }); + try std.testing.expectEqual(pardes.TagState.Kind.rest, p.view().tag_state.kind); + _ = frame.reset(.retain_capacity); + s = try p.render(frame.allocator()); + try std.testing.expect(std.mem.indexOf(u8, rowText(s, body.x, body.y + 3, &buf), "const x = f(1, 2, 3);") != null); + try std.testing.expect(std.mem.indexOf(u8, rowText(s, body.x, body.y + 4, &buf), "four") != null); + // The next motion rolls it up; back on the line, nothing comes back. + p.update(.{ .key = .{ .cp = 'j' } }); + p.update(.{ .key = .{ .cp = 'k' } }); + try std.testing.expect(!err.open); + _ = frame.reset(.retain_capacity); + s = try p.render(frame.allocator()); + try std.testing.expect(std.mem.indexOf(u8, rowText(s, body.x, body.y + 3, &buf), "four") != null); + // SPC e there: unrolled, the error still live; K rolls it up. + p.update(.{ .key = .{ .cp = ' ' } }); + p.update(.{ .key = .{ .cp = 'e' } }); + try std.testing.expect(err.open); + try std.testing.expectEqual(@as(usize, 1), p.messages.live_len); + _ = frame.reset(.retain_capacity); + s = try p.render(frame.allocator()); + try std.testing.expect(std.mem.indexOf(u8, rowText(s, body.x, body.y + 3, &buf), "const x = f(1, 2, 3);") != null); + p.update(.{ .key = .{ .cp = 'K' } }); + try std.testing.expect(!err.open); + // A Look (B3) on its words after the line: unrolled, the caret where + // it was. + _ = frame.reset(.retain_capacity); + s = try p.render(frame.allocator()); + const words = std.mem.indexOf(u8, rowText(s, body.x, body.y + 2, &buf), "expected").?; + const wx = body.x + @as(u16, @intCast(words)) + 1; + p.update(.{ .mouse = .{ .button = .right, .kind = .press, .col = wx, .row = body.y + 2 } }); + p.update(.{ .mouse = .{ .button = .right, .kind = .release, .col = wx, .row = body.y + 2 } }); + while (p.nextEffect()) |_| {} + try std.testing.expect(err.open); + try std.testing.expectEqual(@as(i32, 2), pane.body.cur_row); + // K with two selections is keep's prompt, the detail as it was. + p.update(.{ .key = .{ .cp = 'C' } }); + try std.testing.expect(pane.body.nsel > 0); + p.update(.{ .key = .{ .cp = 'K' } }); + try std.testing.expectEqual(pardes.TagState.Kind.prompt, p.view().tag_state.kind); +} diff --git a/core/builtins.zig b/core/builtins.zig index 33f5824f..7aaeee40 100644 --- a/core/builtins.zig +++ b/core/builtins.zig @@ -1727,8 +1727,9 @@ pub const LocationsConfig = struct { /// Act on the message the notice row leads with. /// -/// An error that names places lands them as a list in the pane's walk, n -/// and N walking them (where jumps do not walk, a +Search the Look walk +/// On a line a message names, its detail not shown yet: that detail, under +/// the line until the caret leaves it. Else an error that names places +/// lands them as a list in the pane's walk, n and N walking them (where jumps do not walk, a +Search the Look walk /// steps through); a question takes the keyboard in its pane's tag (its /// answer's key answers it, Esc leaves it waiting); anything else opens the /// history. diff --git a/core/mouse.zig b/core/mouse.zig index 6516ea71..72f599dd 100644 --- a/core/mouse.zig +++ b/core/mouse.zig @@ -884,6 +884,12 @@ pub fn handleMouse(p: *Pardes, event: Mouse) void { const word = (body_layer.wordAt(p, arena, id, row, @intCast(@max(0, pointed.sel.c0))) catch return) orelse return; return exec.runBuiltin(p, if (m.button == config.exec_button) config.exec_cmd else config.look_cmd, id, "", arena.dupe(u8, word) catch return); } + // A Look on a message's words after its line: its + // detail unrolled, or rolled up (UX D13). + if (m.button == config.look_button and !pointed.on_tag and mrow >= body_y) if (body_layer.messageAt(p, p.scratch.allocator(), id, mrow - body_y, @intCast(@max(0, pointed.sel.c0))) catch null) |said| { + said.open = !said.open; + return; + }; pane.clearPointerSelection(@backingInt(m.button)); pane.sel[@backingInt(m.button)] = pointed.sel; v.drag = .{ diff --git a/core/normal.zig b/core/normal.zig index 3aad765d..e6d6dbb0 100644 --- a/core/normal.zig +++ b/core/normal.zig @@ -1369,7 +1369,16 @@ fn executeNormalAction(p: *Pardes, t: *Text, a: modal.Normal.Action) edit.Error! .page_up => return t.scrollViewMove(p.settings.tab, text, range, -@as(i32, pane.rows)), // s, S and | answer for the text they are pressed in; `/` searches // the body wherever it is pressed, as acme's Look from a tag does. - inline .select_regex, .split_regex, .keep_regex, .remove_regex => |role| return startSelRegex(p, pane, t, @field(modal.Normal.RegexMode, @tagName(role)[0 .. @tagName(role).len - "_regex".len])), + // K with one selection on a line a message with a detail names: + // that detail unrolled, or rolled up (UX D13); else keep's prompt. + .keep_regex => { + if (t == &pane.body and t.nsel == 0) if (pardes.Messages.detailAt(p, pane, t.cur_row)) |said| { + said.open = !said.open; + return; + }; + return startSelRegex(p, pane, t, .keep); + }, + inline .select_regex, .split_regex, .remove_regex => |role| return startSelRegex(p, pane, t, @field(modal.Normal.RegexMode, @tagName(role)[0 .. @tagName(role).len - "_regex".len])), // Language shortcuts run the same builtins as tags and leader commands. .goto_definition => return exec.runBuiltin(p, .Def, v.active, "", null), .goto_references => return exec.runBuiltin(p, .Refs, v.active, "", null), -- cgit v1.3 From 635829a5c17be4fd4bc30866e2b361c4ea2876e1 Mon Sep 17 00:00:00 2001 From: Gabriel Schneider Date: Wed, 25 Nov 2026 10:02:29 -0300 Subject: colors, tools/gen_themes.zig: the err role falls back from a theme's diagnostic.error ink to its error ink, then to its red (UX D4/D14, E3, E5 fix 7), so an invalid pattern's reason in a prompt (Prompt.head's .err span, drawn in roles.err) and a message's error glyph and ghosts are red on the imported themes: THE CAUSE: the generator wrote no diagnostic_error for a helix theme (neonotte's "diagnostic.error" is an underline only) and colors.zig fell back to the body's ink, so UX2 measured the reason in fg #cdd6f4 (P2-L 13); THE FIX: gen_themes.zig's Theme has diagnostic_error, a helix theme's from diagnostic.error's fg, else error's fg, else its red (its [palette] red, else the terminal's), a zed theme's from its `error` status colour; colors.zig's ChromeTheme.diagnostic_error and Roles.err fall back to the palette's red (index 1) before the ink, for a theme that names none and has a palette (acme: #aa2222; dark and helix keep their ink: no palette); the err role is still pushed to 4.5:1 on the tags and the page (the floors test passes for every bundled theme); ChromeTheme.diagnostic_error also colours a +Errors row, a diagnostic's underline and the notice row's error glyph, which move to the same red on those themes (the themes pardes ships its own colours for, orchard first, are as they were); TEST FIRST: colors.zig "the err role falls back from diagnostic.error's ink to error's, then to the theme's red (UX E3): ..." (on the base: neonotte84's diagnostic_error null, colors.zig:1628); passes now, with every colors test Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_016Y9MNBFhdevVu48bvL9kCE --- core/colors.zig | 18 ++++++++++++++++-- tools/gen_themes.zig | 7 +++++++ 2 files changed, 23 insertions(+), 2 deletions(-) (limited to 'core') diff --git a/core/colors.zig b/core/colors.zig index b2069465..3325671c 100644 --- a/core/colors.zig +++ b/core/colors.zig @@ -586,7 +586,8 @@ pub const ChromeTheme = struct { .search_bg = th.search_bg orelse th.sel_bg, .search_fg = th.search_fg orelse th.sel_fg, .tag_reading_bg = reading, - .diagnostic_error = th.diagnostic_error orelse (th.fg orelse th.tag_fg), + // A theme's error ink, else its palette's red (UX E3). + .diagnostic_error = th.diagnostic_error orelse if (th.palette) |pal| pal[1] else (th.fg orelse th.tag_fg), .diagnostic_warning = th.diagnostic_warning orelse (th.fg orelse th.tag_fg), .diagnostic_info = th.diagnostic_info orelse (th.fg orelse th.tag_fg), .diagnostic_hint = th.diagnostic_hint orelse (th.fg orelse th.tag_fg), @@ -692,7 +693,7 @@ pub const Roles = struct { if (contrast(r.hit_current, page) < contrast(r.hit, page)) r.hit_current = r.hit; const message_grounds = [_][3]u8{ plain, focused, reading, page }; const ink = th.fg orelse th.tag_fg; - r.err = pushAway(th.diagnostic_error orelse ink, &message_grounds, ink_floor); + r.err = pushAway(th.diagnostic_error orelse if (th.palette) |pal| pal[1] else ink, &message_grounds, ink_floor); r.warn = pushAway(th.diagnostic_warning orelse ink, &message_grounds, ink_floor); r.question = pushAway(th.diagnostic_info orelse ink, &message_grounds, ink_floor); r.hint = pushAway(th.diagnostic_hint orelse ink, &message_grounds, ink_floor); @@ -1621,3 +1622,16 @@ test "neonotte84's and acme's roles are the ones UX derived (DESIGN.md D4, tools }; } } + +test "the err role falls back from diagnostic.error's ink to error's, then to the theme's red (UX E3): neonotte84's (its diagnostic.error an underline only) is its red, acme's its palette's" { + const neonotte = &themes[themeIndex("neonotte84").?]; + // neonotte.toml: "error" = { fg = "red" }, its palette's red #ff7ea2. + try std.testing.expectEqual([3]u8{ 0xff, 0x7e, 0xa2 }, neonotte.diagnostic_error.?); + for ([_][]const u8{ "neonotte84", "acme" }) |name| { + const chrome = ChromeTheme.fromTheme(&themes[themeIndex(name).?]); + const err = chrome.roles.err; + // Red: its red channel well over the others, on the page and the tags. + try std.testing.expect(err[0] > err[1] + 40 and err[0] > err[2] + 40); + } + try std.testing.expectEqual([3]u8{ 0xaa, 0x22, 0x22 }, ChromeTheme.fromTheme(&themes[themeIndex("acme").?]).diagnostic_error); +} diff --git a/tools/gen_themes.zig b/tools/gen_themes.zig index 4f3946ad..b9a9adb0 100644 --- a/tools/gen_themes.zig +++ b/tools/gen_themes.zig @@ -72,6 +72,10 @@ const Theme = struct { lineno: Rgb, scroll_track: Rgb, scroll_thumb: Rgb, + /// A message's error ink (colors.Roles.err): diagnostic.error's, else + /// error's, else the theme's red (UX E3: neonotte's diagnostic.error is + /// an underline only). + diagnostic_error: ?Rgb = null, palette: ?[16]Rgb, }; @@ -361,6 +365,7 @@ fn helixTheme(arena: std.mem.Allocator, stem: []const u8, h: Helix) !Theme { // anything else in the theme's greys) for the thumb riding it .scroll_track = h.get("ui.statusline", .bg) orelse page, .scroll_thumb = sel, + .diagnostic_error = h.first(&.{ .{ "diagnostic.error", .fg }, .{ "error", .fg } }) orelse h.color("red"), .palette = null, }; } @@ -575,6 +580,8 @@ fn readZed(arena: std.mem.Allocator, gpa: std.mem.Allocator, path: []const u8, t .lineno = z.need("editor.line_number"), .scroll_track = z.need("scrollbar.thumb.border"), .scroll_thumb = z.need("scrollbar.thumb.background"), + // its status colour, else the palette's red (colors.zig) + .diagnostic_error = if (z.style.get("error") != null) z.need("error") else null, .palette = pal, }); } -- cgit v1.3 From 88c7a663468ab78ee3dbbc9726093dc4c3cf362f Mon Sep 17 00:00:00 2001 From: Gabriel Schneider Date: Wed, 25 Nov 2026 10:08:22 -0300 Subject: Prompt: a search's count keeps ` · N lines` after it, in the dim ink, and drops it with the hints (UX E7: E5 fix 8 reversed, the prototype's own `9/38 · 34 lines`); a wrap's `↻` is the count's, before it (`1/7 ↻ · 5 lines`, as n's echo says `1/3 ↻ · line 1`): THE CAUSE: Prompt.count wrote `3/7 · 5 lines ↻` all in the count's text ink, in the right block's count, which never drops (UX2: "`2/6 · 6 lines` in the count", D3 wants the count alone to stay); THE FIX: count returns where its ` · N lines` starts; head gives it a dim span and keeps it only while it and the hints fit beside the count with the right block's two gaps (Builder.right drops the hints alone, so head asks the same room for both, a cell or two sooner at most where the field already ends in blanks), else the count alone at the row's end; TEST FIRST: Prompt.zig "a search's count keeps ` · N lines` after it in the dim ink, and drops it with the hints where they do not fit beside it; a wrap's ↻ is the count's (UX E7, D3)" (200 and 52 columns, and a search from the last line round the end): fails on the base at Prompt.zig:1686 (no dim span), passes now; GOLDEN: fsearch regenerated (process-test -- --update fsearch), one row: the reader's tag row 16, cells 127-137 (` · 5 lines`) in the dim ink #79836f where they were the text ink #becfc4, its text the same; core-test 1086/1257 (171 skipped), process-test 1 of 147 failed before the golden (fsearch), 0 of 1 after 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/Prompt.zig | 84 ++++++++++++++++++++++++++++++++++++------- test/snapshots/fsearch.golden | 2 +- 2 files changed, 73 insertions(+), 13 deletions(-) (limited to 'core') diff --git a/core/Prompt.zig b/core/Prompt.zig index 9dfe9ec2..ad2cfbed 100644 --- a/core/Prompt.zig +++ b/core/Prompt.zig @@ -1083,7 +1083,11 @@ pub fn head(p: *Pardes, arena: std.mem.Allocator, pane: *Pane) !TagState.Head { } } // The count and the hints at the row's right end (UX D3). + const left = b.col(); const at = text.items.len; + // Where a search's ` · N lines` starts after its count: dim, and gone + // with the hints (UX E7). + var tail: ?usize = null; if (line.len > 0) { // A pattern that is no regex: why, in the err ink, in place of the // hints (UX D14), what is shown meanwhile dim; in the count's place, @@ -1095,11 +1099,23 @@ pub fn head(p: *Pardes, arena: std.mem.Allocator, pane: *Pane) !TagState.Head { return .{ .text = text.items, .spans = spans.items, .cells = 1, .caret = caret }; } else if (behavior(pr.op) != null) { try pipeCount(p, arena, text, spans, pane, pr, line); - } else try count(arena, text, pane, pr); + } else tail = try count(arena, text, pane, pr); } if (pr.op == .command) try Command.count(p, arena, text); const hints = text.items.len; - try styled(arena, text, spans, info.get(pr.op).hint, .dim); + const hint = info.get(pr.op).hint; + if (tail) |t| { + // Both beside the count, or neither: as much room as the right + // block asks for its two gaps (Builder.right drops the hints alone). + const cells = File.displayWidth(p.settings.tab, std.mem.trimStart(u8, text.items[at..], " ")) + File.displayWidth(p.settings.tab, hint); + if (left + 2 + cells + 2 > b.width) { + text.shrinkRetainingCapacity(t); + try b.right(at, t); + return .{ .text = text.items, .spans = spans.items, .cells = 1, .caret = caret }; + } + try spans.append(arena, .{ .lo = @intCast(t), .hi = @intCast(hints), .style = .dim }); + } + try styled(arena, text, spans, hint, .dim); try b.right(at, hints); return .{ .text = text.items, .spans = spans.items, .cells = 1, .caret = caret }; } @@ -1111,24 +1127,34 @@ fn styled(arena: std.mem.Allocator, text: *std.ArrayList(u8), spans: *std.ArrayL } /// The prompt's count after its field: what it found (`4 selections in 6 -/// lines`, `keeps 3 of 9`, `3/7 · 5 lines`, `3/⋯` while its places are -/// found, `0`). -fn count(arena: std.mem.Allocator, text: *std.ArrayList(u8), pane: *Pane, pr: *const Prompt) !void { +/// lines`, `keeps 3 of 9`, `3/7 · 5 lines`, `1/7 ↻ · 5 lines`, `3/⋯` while +/// its places are found, `0`); where a search's ` · N lines` starts. +fn count(arena: std.mem.Allocator, text: *std.ArrayList(u8), pane: *Pane, pr: *const Prompt) !?usize { switch (pr.op) { .search, .search_back => { const set = &pane.places; - if (!set.shows(pane)) return; + if (!set.shows(pane)) return null; const hits = set.hits.items; - if (set.complete() and hits.len == 0) return text.appendSlice(arena, " 0"); + if (set.complete() and hits.len == 0) { + try text.appendSlice(arena, " 0"); + return null; + } try text.appendSlice(arena, " "); const at = if (set.current) |c| (if (c < hits.len) c else null) else null; if (at) |c| try text.print(arena, "{d}", .{c + 1}) else try text.appendSlice(arena, "–"); - if (!set.complete()) return text.appendSlice(arena, "/⋯"); - try text.print(arena, "/{d} · {d} line{s}", .{ hits.len, pr.lines, plural(pr.lines) }); + if (!set.complete()) { + try text.appendSlice(arena, "/⋯"); + return null; + } + try text.print(arena, "/{d}", .{hits.len}); // Round the end from where it began. - const c = at orelse return; - const origin = set.origin(pane); - if (if (pr.op == .search) hits[c].start < origin else hits[c].start > origin) try text.appendSlice(arena, " ↻"); + if (at) |c| { + const origin = set.origin(pane); + if (if (pr.op == .search) hits[c].start < origin else hits[c].start > origin) try text.appendSlice(arena, " ↻"); + } + const tail = text.items.len; + try text.print(arena, " · {d} line{s}", .{ pr.lines, plural(pr.lines) }); + return tail; }, .select, .split => if (pr.found == 0) try text.appendSlice(arena, " 0") @@ -1137,6 +1163,7 @@ fn count(arena: std.mem.Allocator, text: *std.ArrayList(u8), pane: *Pane, pr: *c .keep, .remove => try text.print(arena, " keeps {d} of {d}", .{ pr.found, pane.nsel_snap }), else => {}, } + return null; } /// A pipe prompt's count: `6 lines → 5 · exit 0`, `6 runs · 5 ok · 1 exit 2 @@ -1668,3 +1695,36 @@ test "Alt-Enter in / or s keeps the result as a list (SPEC §7.2): where jumps w try std.testing.expectEqual(TagState.Kind.rest, p.view().tag_state.kind); try std.testing.expect(p.panes[p.view().active].?.query != null); } + +test "a search's count keeps ` · N lines` after it in the dim ink, and drops it with the hints where they do not fit beside it; a wrap's ↻ is the count's (UX E7, D3)" { + for ([_]u16{ 200, 52 }) |cols| { + const p = try Pardes.init(std.testing.allocator, .{ .tty_only = true, .cols = cols, .rows = 30 }); + defer p.deinit(); + const pane = try p.setTestFile(dirty); + pane.body.cur_row = 2; + pane.body.cur_col = 6; + typeKeys(p, "/dirty"); + const h = try head(p, p.scratch.allocator(), pane); + const lines = std.mem.indexOf(u8, h.text, " \u{b7} 5 lines"); + if (cols == 200) { + try std.testing.expect(has(h.text, "3/7 \u{b7} 5 lines \u{23ce} land")); + const dim = for (h.spans) |span| { + if (span.lo == lines.? and span.style == .dim) break span; + } else return error.TestUnexpectedResult; + try std.testing.expectEqualStrings(" \u{b7} 5 lines", h.text[dim.lo..dim.hi]); + } else { + // No room for the hints: the count alone, at the row's end. + try std.testing.expect(lines == null); + try std.testing.expect(std.mem.indexOf(u8, h.text, "\u{23ce} land") == null); + try std.testing.expect(std.mem.endsWith(u8, h.text, "3/7")); + } + } + // From the last line round the end: `↻` after the count, before its lines. + const p = try Pardes.init(std.testing.allocator, .{ .tty_only = true, .cols = 200, .rows = 30 }); + defer p.deinit(); + const pane = try p.setTestFile(dirty); + pane.body.cur_row = 7; + pane.body.cur_col = 6; + typeKeys(p, "/dirty"); + try std.testing.expect(has(try tagOf(p), "1/7 \u{21bb} \u{b7} 5 lines \u{23ce} land")); +} diff --git a/test/snapshots/fsearch.golden b/test/snapshots/fsearch.golden index 59a1b0bb..e7814fb5 100644 --- a/test/snapshots/fsearch.golden +++ b/test/snapshots/fsearch.golden @@ -52,7 +52,7 @@ |13: 0-0 d,#608269, 1-89 d,#0d1410, 90-90 d,#608269, 91-179 d,#0d1410, |14: 0-0 d,#608269, 1-89 d,#0d1410, 90-90 d,#608269, 91-179 d,#0d1410, |15: 0-0 d,#608269, 1-89 d,#0d1410, 90-90 d,#608269, 91-179 d,#0d1410, -|16: 0-1 d,#496656, 2-30 #b2c3b8,#1d2824, 31-40 #d3b0d9,#1d2824, 41-89 #b2c3b8,#1d2824, 90-91 #000000,#add38a, 92-98 #becfc4,#2c2c0f, 99-99 #bada9d,#2c2c0f,b 100-100 #bada9d,#2c2c0f, 101-106 #becfc4,#2c2c0f, 107-113 #79836f,#2c2c0f, 114-137 #becfc4,#2c2c0f, 138-179 #79836f,#2c2c0f, +|16: 0-1 d,#496656, 2-30 #b2c3b8,#1d2824, 31-40 #d3b0d9,#1d2824, 41-89 #b2c3b8,#1d2824, 90-91 #000000,#add38a, 92-98 #becfc4,#2c2c0f, 99-99 #bada9d,#2c2c0f,b 100-100 #bada9d,#2c2c0f, 101-106 #becfc4,#2c2c0f, 107-113 #79836f,#2c2c0f, 114-126 #becfc4,#2c2c0f, 127-179 #79836f,#2c2c0f, |17: 0-0 d,#608269, 1-1 d,#0d1410, 2-89 #e5eee5,#0d1410, 90-90 #e5eee5,#608269, 91-94 #e5eee5,#0d1410, 95-96 #59675c,#0d1410, 97-179 #e5eee5,#0d1410, |18: 0-0 d,#608269, 1-1 d,#0d1410, 2-89 #e5eee5,#0d1410, 90-90 #e5eee5,#e5eee5, 91-91 #e5eee5,#0d1410, 92-94 #e5eee5,#0d1410,b 95-95 #616f64,#0d1410,b 96-96 #bada9d,#0d1410,b 97-100 #f5f7ee,#3c614a, 101-101 #f5f7ee,#0d1410, 102-179 #e5eee5,#0d1410, |19: 0-0 d,#608269, 1-89 d,#0d1410, 90-90 d,#608269, 91-94 d,#0d1410, 95-96 #59675c,#0d1410, 97-179 #e5eee5,#0d1410, -- cgit v1.3 From b17ff3c29dc5b0eb03fe471be9b96098cbb631f8 Mon Sep 17 00:00:00 2001 From: Gabriel Schneider Date: Wed, 25 Nov 2026 10:16:33 -0300 Subject: Pick: a list of places (a Grep's hits, All's, a list's: Refs, SPC e's errors, a server's symbols) shows each row's place in the dim ink and its text after it in one column, the widest place shown before it (UX E7 2b, D4/D5): THE CAUSE: Pick.rowAt wrote `path:line code` with one blank between them and the band drew its `pre` (the place) in the tag's name tint, so every row repeated `Jump.zig:76` as loud as the code (8.4:1 against the code's 8.8:1) and the code started at a ragged column (UX2/before: the old +Search grouped hits under a file line with the code in one column, `path:line:col` dim); THE FIX: Pick.steps, for those sources, gives each row whose place has text after it Band.Row.quiet over the place up to its blank (a column `:3:1` and the `:` of a compiler's `path:line:col: words` are the place's), which the band draws in the dim ink of its ground over the name tint, and pads the place to the widest one shown, the matched letters moved with the text; bounded by the rows shown (the band's window), nothing at rest or for any other picker; TEST FIRST: Pick.zig "a list of places (a Grep's, a list's) shows each row's `path:line` in the dim ink and its text after it in one column, the widest place shown before it (UX E7 2b)" (fails on the base: Row.quiet 0..0); GOLDENS: fsearch's list and ctrln snaps (rows 18 and 19: `g.txt:2:1: MARK a`, `g.txt:6:1: MARK b` padded to `g.txt:10:1: MARK c`'s column) and lsp's symbols snap (rows 4 and 5: `a.zig:1:7-9 std`, `a.zig:3:4-9 helper` padded to `a.zig:7:8-11 main`'s), regenerated with process-test -- --update fsearch / lsp and read, no other row moved (these snaps keep no style rows for the band); core-test 1087/1258 (171 skipped), process-test 2 of 147 failed before the goldens (fsearch, lsp), 0 after Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_016Y9MNBFhdevVu48bvL9kCE --- core/Pick.zig | 61 +++++++++++++++++++++++++++++++++++++++++++ test/snapshots/fsearch.golden | 8 +++--- test/snapshots/lsp.golden | 4 +-- 3 files changed, 67 insertions(+), 6 deletions(-) (limited to 'core') diff --git a/core/Pick.zig b/core/Pick.zig index c5b639cd..8239be6a 100644 --- a/core/Pick.zig +++ b/core/Pick.zig @@ -715,6 +715,30 @@ pub fn steps(p: *Pardes, arena: std.mem.Allocator) ![]Band.Step { const r = try rowAt(p, pk, arena, i); row.* = .{ .text = r.text, .key = r.key, .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 }; } + // A place's text (a Grep's line, a list's): its `path:line` in the dim + // ink and the text after it in one column, the widest place shown + // before it (UX E7 2b: the old +Search's column). Bounded by the rows + // shown. + if (pk.source == .grep or pk.source == .all or pk.source == .list) { + var widest: usize = 0; + for (rows) |row| if (row.pre > 0 and row.pre < row.text.len) { + widest = @max(widest, File.displayWidth(p.settings.tab, row.text[0 .. std.mem.indexOfScalarPos(u8, row.text, row.pre, ' ') orelse row.text.len])); + }; + for (rows) |*row| if (row.pre > 0 and row.pre < row.text.len) { + // The place up to its blank: a column (`:3:1`) and the `:` a + // compiler's `path:line:col: words` puts after it are its. + const end = std.mem.indexOfScalarPos(u8, row.text, row.pre, ' ') orelse row.text.len; + row.quiet = .{ 0, @intCast(end) }; + const pad = widest - File.displayWidth(p.settings.tab, row.text[0..end]); + if (pad == 0) continue; + const blanks = try arena.alloc(u8, pad); + @memset(blanks, ' '); + row.text = try std.mem.concat(arena, u8, &.{ row.text[0..end], blanks, row.text[end..] }); + const marks = try arena.alloc(u16, row.marks.len); + for (marks, row.marks) |*m, at| m.* = if (at >= end) at + @as(u16, @intCast(pad)) else at; + row.marks = marks; + }; + } out[0] = .{ .rows = rows }; return out; } @@ -2395,3 +2419,40 @@ test "a picker's preview is legible as one (UX D7): its landing line on the hit p.update(.{ .key = .{ .cp = pardes.Key.escape } }); try std.testing.expect(!pardes.Messages.noticeRow(p, 120, &buf).quiet_left); } + +test "a list of places (a Grep's, a list's) shows each row's `path:line` in the dim ink and its text after it in one column, the widest place shown before it (UX E7 2b)" { + const p = try Pardes.init(std.testing.allocator, .{ .tty_only = true, .cols = 140, .rows = 40 }); + defer p.deinit(); + p.settings.jumps = .walk; + var tmp = std.testing.tmpDir(.{}); + defer tmp.cleanup(); + const a_path = try testFile(p, &tmp, "a.zig", "one\ntwo\nconst x = 1;\n"); + defer p.gpa.free(a_path); + const b_path = try testFile(p, &tmp, "a_longer_name.zig", "fn y() void {}\n"); + defer p.gpa.free(b_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}:3:1 const x = 1;\n{s}:1:4 fn y() void {{}}\n", .{ a_path, b_path }); + defer std.testing.allocator.free(rows); + open(p, asker, .list, "Refs", "", rows); + p.update(.tick); + var frame = std.heap.ArenaAllocator.init(std.testing.allocator); + defer frame.deinit(); + const got = (try steps(p, frame.allocator()))[0].rows; + try std.testing.expectEqual(@as(usize, 2), got.len); + const code = [2][]const u8{ "const x = 1;", "fn y() void {}" }; + var col: [2]usize = undefined; + for (got, code, &col) |row, text, *c| { + const at = std.mem.indexOf(u8, row.text, text).?; + c.* = File.displayWidth(8, row.text[0..at]); + // The place dim up to its blank (`path:3:1`); the text after it not. + try std.testing.expect(row.pre > 0); + try std.testing.expectEqual(@as(u16, 0), row.quiet[0]); + try std.testing.expectEqual(':', row.text[row.quiet[1] - 2]); + try std.testing.expectEqual(' ', row.text[row.quiet[1]]); + } + try std.testing.expectEqual(col[0], col[1]); + // One cell after the widest place. + try std.testing.expectEqual(File.displayWidth(8, b_path) + ":1:4 ".len, col[1]); +} diff --git a/test/snapshots/fsearch.golden b/test/snapshots/fsearch.golden index e7814fb5..c0e3f076 100644 --- a/test/snapshots/fsearch.golden +++ b/test/snapshots/fsearch.golden @@ -70,8 +70,8 @@ == snap list grid=180x31 cursor=110,16 |16: /tmp/pardes-snap/fsearch/cwd Term+bash Save Mode Filter Collapse Del ^ ‹@p1 › ␣ l /MARK/ 1/3 |17: ls │ │ Walk Look Split Newcol Grep Edit Copy Keep Drop | Find Grep Recent Panes … -|18: g.txt │ │ ▶ /tmp/pardes-snap/fsearch/cwd/g.txt:2:1: MARK a -|19: │ │ /tmp/pardes-snap/fsearch/cwd/g.txt:6:1: MARK b +|18: g.txt │ │ ▶ /tmp/pardes-snap/fsearch/cwd/g.txt:2:1: MARK a +|19: │ │ /tmp/pardes-snap/fsearch/cwd/g.txt:6:1: MARK b |20: │ │ /tmp/pardes-snap/fsearch/cwd/g.txt:10:1: MARK c |21: │ │ |22: 1 l1 @@ -85,8 +85,8 @@ |30: ⏎ lands here · its text is the preview · S-⏎ a new pane 1 message · SPC h m == snap ctrln grid=180x31 cursor=110,16 |16: /tmp/pardes-snap/fsearch/cwd Term+bash Save Mode Filter Collapse Del ^ ‹@p1 › ␣ l /MARK/ 2/3 -|18: g.txt │ │ /tmp/pardes-snap/fsearch/cwd/g.txt:2:1: MARK a -|19: │ │ ▶ /tmp/pardes-snap/fsearch/cwd/g.txt:6:1: MARK b +|18: g.txt │ │ /tmp/pardes-snap/fsearch/cwd/g.txt:2:1: MARK a +|19: │ │ ▶ /tmp/pardes-snap/fsearch/cwd/g.txt:6:1: MARK b |22: 3 l3 |23: 4 l4 |24: 5 l5 diff --git a/test/snapshots/lsp.golden b/test/snapshots/lsp.golden index 5d536a0f..c680700d 100644 --- a/test/snapshots/lsp.golden +++ b/test/snapshots/lsp.golden @@ -59,8 +59,8 @@ == snap symbols grid=120x41 cursor=24,2 |2: ^ a.zig:8 › ␣ l Symbols 1/3 |3: │ │ Walk Look Split Newcol Grep Edit Copy Keep Drop | Find Grep Recent Panes Symbols All Jumplist -|4: │ │ ▶ a.zig:1:7-9 std -|5: │ │ a.zig:3:4-9 helper +|4: │ │ ▶ a.zig:1:7-9 std +|5: │ │ a.zig:3:4-9 helper |6: │ │ a.zig:7:8-11 main |7: │ │ |8: 1▸const std = @import("std"); -- cgit v1.3 From 26022c82993777248b7958f1c97d452729139153 Mon Sep 17 00:00:00 2001 From: Gabriel Schneider Date: Wed, 25 Nov 2026 10:34:20 -0300 Subject: colors: a picker's landing line stands 1.5:1 off the page and its matched span 1.9:1 (UX E7 7b, D7/D4): the hit grounds are found on toward the theme's search hue, the least way that stands off the page that far where the body's ink still reads on them at 4.5:1 (by halves, seven mixes: the first frame's role derivation, P2's perf fix, stays a fixed handful of contrasts), before the old move toward the ink: THE CAUSE: Roles.hit_floor 1.25 and hit_current_floor 1.6 (D4) with the ground mixed 18 % / 32 % toward the warm accent, so neonotte84's landing line was #36282a at 1.29:1 on its page against the prototype's 1.88:1 ("much fainter", UX2 E7); THE FIX: hit_floor 1.5, hit_current_floor 1.9, and colors.hitOf bisects the mix toward the hue between where it starts and the hue itself for the least one at the floor (only where the hue stands that far off and the ink reads on it; else as before, on toward the ink); the same grounds are a prompt's search hits and its current one (D14), which stand out as much; a theme's own search_bg counts only at 1.5:1 now; neonotte84's hit #47322e 1.52:1 and current #5f3f33 1.94:1, acme's #e6cdae 1.51:1 and #d9b490 1.91:1 (the UX-derived values test updated to them, noting the step past UX's 18 % / 32 %); TEST FIRST: P2's floors test "every theme's walk UI roles meet their floors ..." asks the landing line 1.5:1 and its span 1.9:1 (on the base: 340 hit grounds under those, dusk's 1.27, paper's 1.27 and 1.63, ...), passes for every bundled theme now; core-test 1087/1258 (171 skipped), process-test 0 of 147 failed (orchard's own search ground already stands off its page: no golden moved) Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_016Y9MNBFhdevVu48bvL9kCE --- core/colors.zig | 36 +++++++++++++++++++++++++++++------- 1 file changed, 29 insertions(+), 7 deletions(-) (limited to 'core') diff --git a/core/colors.zig b/core/colors.zig index 3325671c..4f58aed5 100644 --- a/core/colors.zig +++ b/core/colors.zig @@ -644,8 +644,8 @@ pub const Roles = struct { pub const rule_floor: f32 = 1.8; pub const rule_ceiling: f32 = 2.5; pub const ink_floor: f32 = 4.5; - pub const hit_floor: f32 = 1.25; - pub const hit_current_floor: f32 = 1.6; + pub const hit_floor: f32 = 1.5; + pub const hit_current_floor: f32 = 1.9; pub const reading_distance: f32 = 0.04; pub fn on(r: *const Roles, ground: TagGround) *const Inks { @@ -795,8 +795,10 @@ fn selectionOf(own: [3]u8, ground: [3]u8, text: [3]u8) [3]u8 { /// A ground off `page` toward `hue` at `t` (past 1, beyond the hue, as far /// as the gamut goes), held where the body's `ink` reads on it at 4.5:1 -/// (or its own on the page, where that is less); moved on toward the ink -/// until it stands off the page at `floor`, as far as the ink allows. +/// (or its own on the page, where that is less); on toward the hue, the +/// least way that stands off the page at `floor`, where the ink still +/// reads on it; else moved on toward the ink until it stands off the page +/// at `floor`, as far as the ink allows. fn hitOf(page: [3]u8, hue: [3]u8, ink: [3]u8, t: f32, floor: f32) [3]u8 { const a = toOklab(page); const b = toOklab(hue); @@ -807,6 +809,22 @@ fn hitOf(page: [3]u8, hue: [3]u8, ink: [3]u8, t: f32, floor: f32) [3]u8 { k -= t / 50; c = fromOklab(.{ a[0] + (b[0] - a[0]) * k, a[1] + (b[1] - a[1]) * k, a[2] + (b[2] - a[2]) * k }); } + // Found by halves, seven mixes: the nearer the hue, the further off + // the page (UX E7 7b: a landing line 1.5:1, its span 1.9:1). + if (contrast(c, page) < floor and k < 1 and contrast(hue, page) >= floor) { + var lo = k; + var hi: f32 = 1; + var far = hue; + for (0..7) |_| { + const mid = (lo + hi) / 2; + const m = fromOklab(.{ a[0] + (b[0] - a[0]) * mid, a[1] + (b[1] - a[1]) * mid, a[2] + (b[2] - a[2]) * mid }); + if (contrast(m, page) < floor) lo = mid else { + hi = mid; + far = m; + } + } + if (contrast(ink, far) >= ink_floor) c = far; + } const start = c; var step: f32 = 1; while (contrast(c, page) < floor and step <= 50) : (step += 1) { @@ -1587,7 +1605,9 @@ test "every theme's walk UI roles meet their floors on every ground they are dra for ([_][3]u8{ th.tag_fg, th.tag_active_fg orelse th.tag_fg }) |ink| try checks.append(a, .{ .what = "text on reading", .got = contrast(ink, chrome.tag_reading_bg), .floor = @min(7, contrast(ink, th.tag_bg)) - 0.02 }); const ink_floor = @min(Roles.ink_floor, contrast(body_ink, page)); - for ([_][3]u8{ r.hit, r.hit_current }, [_]f32{ Roles.hit_floor, Roles.hit_current_floor }) |ground, floor| { + // A preview's landing line 1.5:1 off the page, its matched span (the + // current hit) a step stronger, 1.9:1 (UX E7 7b: 1.29 read as faint). + for ([_][3]u8{ r.hit, r.hit_current }, [_]f32{ 1.5, 1.9 }) |ground, floor| { const on = contrast(body_ink, ground); try checks.append(a, .{ .what = "hit", .got = contrast(ground, page), .floor = if (on < ink_floor + 0.3) 0 else floor }); try checks.append(a, .{ .what = "ink on hit", .got = on, .floor = ink_floor - 0.01 }); @@ -1603,13 +1623,15 @@ test "every theme's walk UI roles meet their floors on every ground they are dra test "neonotte84's and acme's roles are the ones UX derived (DESIGN.md D4, tools/roles.py)" { const Want = struct { name: []const u8, text: ?[3]u8, dim: [3]u8, rule: [3]u8, key: [3]u8, match: [3]u8, reading: [3]u8, hit: [3]u8, hit_current: [3]u8 }; + // The hit grounds past UX's 18 % / 32 % mix, to 1.5:1 and 1.9:1 off the + // page (UX E7 7b). const wants = [_]Want{ - .{ .name = "neonotte84", .text = .{ 0xb5, 0xbf, 0xe3 }, .dim = .{ 0x70, 0x76, 0x8f }, .rule = .{ 0x4c, 0x50, 0x63 }, .key = .{ 0xf8, 0xde, 0xd9 }, .match = .{ 0xf1, 0xa2, 0x71 }, .reading = .{ 0x29, 0x27, 0x1e }, .hit = .{ 0x36, 0x28, 0x2a }, .hit_current = .{ 0x52, 0x38, 0x31 } }, + .{ .name = "neonotte84", .text = .{ 0xb5, 0xbf, 0xe3 }, .dim = .{ 0x70, 0x76, 0x8f }, .rule = .{ 0x4c, 0x50, 0x63 }, .key = .{ 0xf8, 0xde, 0xd9 }, .match = .{ 0xf1, 0xa2, 0x71 }, .reading = .{ 0x29, 0x27, 0x1e }, .hit = .{ 0x47, 0x32, 0x2e }, .hit_current = .{ 0x5f, 0x3f, 0x33 } }, // acme's key and match a little darker than UX's #5c5c8d and // #974d00 (which hold on its tag and its #9eeeee): a reading pane's // band's selection is pushed off the reading ground (#9eeeee is // 1.12:1 off #f3f0cc), and they read on that one too. - .{ .name = "acme", .text = null, .dim = .{ 0x7a, 0x86, 0x86 }, .rule = .{ 0xa8, 0xb7, 0xb7 }, .key = .{ 0x55, 0x55, 0x83 }, .match = .{ 0x8f, 0x48, 0x00 }, .reading = .{ 0xf3, 0xf0, 0xcc }, .hit = .{ 0xec, 0xd8, 0xbb }, .hit_current = .{ 0xdd, 0xbc, 0x99 } }, + .{ .name = "acme", .text = null, .dim = .{ 0x7a, 0x86, 0x86 }, .rule = .{ 0xa8, 0xb7, 0xb7 }, .key = .{ 0x55, 0x55, 0x83 }, .match = .{ 0x8f, 0x48, 0x00 }, .reading = .{ 0xf3, 0xf0, 0xcc }, .hit = .{ 0xe6, 0xcd, 0xae }, .hit_current = .{ 0xd9, 0xb4, 0x90 } }, }; for (wants) |want| { const chrome = ChromeTheme.fromTheme(&themes[themeIndex(want.name).?]); -- cgit v1.3 From ae138cd257f862f226f3f9561b98b7c0518bfcf5 Mon Sep 17 00:00:00 2001 From: Gabriel Schneider Date: Wed, 25 Nov 2026 10:34:20 -0300 Subject: Pick: a code action Enter cannot apply shows so before Enter: a command's (no edit) and one whose edit reaches other files are dim rows with the meta `command` or `other files` at their right end (UX E5 12, D4/D5), where they looked like every other row and Enter on them said it after the fact (P3's apply refusals, UX E4 P3.2); THE FIX: rowAt's actions arm reads the action first and marks those two with Band.Row.dim and Band.Row.meta (P2's right-aligned dim meta, given way before the title), the rest as before; the edit's first line already sits ⌈rows/3⌉ down the body (the merge's look.focusPaneLine .third, D7/E3): the test asks it; TEST FIRST: Pick.zig "code actions: a row that cannot be applied (a command's, an edit reaching other files) is dim, its meta `command` or `other files`; the edit under the cursor a third of the way down the body (UX E5 12, D7)" (fails on the base at Pick.zig:2480: the command's row not dim), passes now with P3's code actions test; core-test 1088/1259 (171 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 | 49 ++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 48 insertions(+), 1 deletion(-) (limited to 'core') diff --git a/core/Pick.zig b/core/Pick.zig index 8239be6a..1d0df89f 100644 --- a/core/Pick.zig +++ b/core/Pick.zig @@ -559,11 +559,19 @@ fn rowAt(p: *Pardes, pk: *const Pick, arena: std.mem.Allocator, i: usize) !Row { // changes, which the body is moved to while it is previewed. .actions => { row.key = @intFromBool(cand.ref < 9); + const act = action(pk, cand.ref) orelse return row; + // One Enter cannot apply (apply's refusals): dim, saying why + // (UX E5 12). + if (act.records.len == 0 or std.mem.eql(u8, act.records, "@elsewhere\n")) { + row.dim = true; + row.meta = if (act.records.len == 0) "command" else "other files"; + return row; + } const owner = p.panes[p.paneBySerial(pk.landing) orelse return row].?; // With the `Changes` layer's lines shown the body stays where it is. const f = if (owner.file) |*file| file else return row; if (f.layer.lines.len > 0 or f.revision != pk.revision) return row; - const edits = pardes.lsp.Ask.parseLspEdits(arena, (action(pk, cand.ref) orelse return row).records, null) orelse return row; + const edits = pardes.lsp.Ask.parseLspEdits(arena, act.records, null) orelse return row; if (edits[0].start > f.content.len) return row; const line = @import("Places.zig").lineOf(try File.lineIndex(p.gpa, f), edits[0].start); row.target = .{ .place = .{ .path = f.path, .at = .{ .line = line + 1 } } }; @@ -2456,3 +2464,42 @@ test "a list of places (a Grep's, a list's) shows each row's `path:line` in the // One cell after the widest place. try std.testing.expectEqual(File.displayWidth(8, b_path) + ":1:4 ".len, col[1]); } + +test "code actions: a row that cannot be applied (a command's, an edit reaching other files) is dim, its meta `command` or `other files`; the edit under the cursor a third of the way down the body (UX E5 12, D7)" { + const Key_ = pardes.Key; + const p = try Pardes.init(std.testing.allocator, .{ .tty_only = true, .cols = 100, .rows = 40 }); + defer p.deinit(); + var frame = std.heap.ArenaAllocator.init(std.testing.allocator); + defer frame.deinit(); + p.settings.jumps = .walk; + var text: std.ArrayList(u8) = .empty; + defer text.deinit(std.testing.allocator); + for (1..81) |i| try text.print(std.testing.allocator, "line {d}\n", .{i}); + const pane = try p.setTestFile(text.items); + const id = p.view().active; + // Line 50 starts after lines 1-49. + var at: usize = 0; + for (1..50) |i| at += std.fmt.count("line {d}\n", .{i}); + const rows = try std.fmt.allocPrint(frame.allocator(), "x:1:1 extract\nx:1:1 move to a new file\n@elsewhere\nx:1:1 rename\n@put {d} {d} LINE\n", .{ at, at + 4 }); + open(p, id, .actions, "", "", rows); + live(p).?.revision = pane.file.?.revision; + const got = (try steps(p, frame.allocator()))[0].rows; + try std.testing.expectEqual(@as(usize, 3), got.len); + try std.testing.expect(got[0].dim); + try std.testing.expectEqualStrings("command", got[0].meta); + try std.testing.expect(got[1].dim); + try std.testing.expectEqualStrings("other files", got[1].meta); + try std.testing.expect(!got[2].dim); + try std.testing.expectEqualStrings("", got[2].meta); + // The rename's: its line (50) a third of the way down the body. + p.update(.{ .key = .{ .cp = Key_.down } }); + p.update(.{ .key = .{ .cp = Key_.down } }); + settle(p); + p.sync(); + var row_at: ?u16 = null; + for (0..pane.rows) |row| if (pane.wrapAt(p.settings.tab, @intCast(row)).line == 49) { + row_at = @intCast(row); + break; + }; + try std.testing.expectEqual(@as(?u16, @intCast((pane.rows + 2) / 3)), row_at); +} -- cgit v1.3