From 920aaa6e6c2317aa775937b01f727fa9418b7db2 Mon Sep 17 00:00:00 2001 From: Gabriel Schneider Date: Wed, 25 Nov 2026 04:58:53 -0300 Subject: tagline, Trail, Core, layout: the tag out of rest is the owner's word, the newest step's and the head, nothing else (walk UI polish P1, UX DESIGN.md D1, the coordinator's R1-CORRECTED: the user's "why the tagline is still showing the regular tagline text?"): out of rest the path, Keep, the forward steps, the progress and the tag's own words were drawn before the head, so the key cells and the band's spines hung 40-50 columns in (shot 02's spines at column 50) and a picker's tag named the PREVIEWED file as the pane's own (shot 04: `/tmp/.../core/Store.zig ␣ f Find re 2/3`); now `‹@p1 › rank.zig:20 › ␣ ▸ b buffer…`, the head from the tag's first text column when there is no walk (`␣ f Find re`), the spines at columns 2-4; THE CHANGE: Trail.Part `.newest` writes the owner's word and the newest back step's alone, each with ` › `, a word past 24 cells cut in its middle with `…` (D1 item 4), and `stepAt(.newest)` maps a Look or Exec on any of its cells to that step; tagline.pathPrefix returns it while Trail.outOfRest (the live view's host is the pane: asking is rest and keeps its path), the old body now `restPath`; `restPrefix`, the prefix as at rest whatever the state, is what Core.sync measures `tag_lead` by (the tag's cursor and selections are offsets in its text at rest: a head over its own text moves none of them; on the shown prefix they were shifted by the path's length and back, and `| in a tag pipes the tag's own text` piped 4 wrong bytes) and what layout.wantedTagRows counts the rest rows with (a tag out of rest keeps them at least); the heads no longer lead with a space (TagState's Help/Keys/Rename/level, Pick.head, Prompt.head: the out-of-rest prefix ends in its own ` › `); no name tint, forward-step ink, unlit search word or progress out of rest (draw.zig tagTintRange, paintPaneTag; Prompt.unlit); tagline.onName and forwardSpan are off out of rest; `Trail.folded` is gone (it only told out of rest, now `.newest`: at rest it is `shown_steps`), `nameAt` takes no Pardes; TEST FIRST: Trail.zig "Enter on a word of the walk ...": out of rest `‹@pN › rank.zig:20 › ␣ ▸ ` with no older step, no directory, no Keep (on the base `‹@pN › · › rank.zig:20 › /rank.zig`: fails), a step back hides its forward step out of rest, Look maps the newest word and the owner's to their steps, and the tag at rest byte-identical after Esc; Pick.zig's reader test: the picker's head starts the tag's text (`␣ f Find pick 1/1`), no previewed path; the heads' other tests drop their leading space; test/behaviour keys.zig's prompt case reads the tag file out of rest as the head alone (`s zq`, no `/test.txt`); behaviour-test 277/277; core-test 1062/1232 (170 skipped); process-test: 8 goldens regenerated and read, each changed row the out-of-rest tag with no path (leader, pipe, msg, selregex, find, fsearch, lsp, ttyhelp: the band's spines at columns 2-4, the steps right of them, the rows no longer pushed onto a second tag row; msg's `s EXT` head and fsearch's `/` head still wrap their hints mid-word: D3's); a user meets it in every state out of rest 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/draw.zig | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'core/draw.zig') diff --git a/core/draw.zig b/core/draw.zig index 68778667..179b7cfc 100644 --- a/core/draw.zig +++ b/core/draw.zig @@ -690,6 +690,8 @@ fn joinCells(s: *Surface, x: u16, y: u16, cells: []const Cell, from: usize, w: u } fn tagTintRange(p: *const Pardes, pane: *const Pane, tag: []const u8, prefix_len: usize) ?struct { lo: usize, hi: usize } { + // Out of rest no name is shown (UX D1). + if (pardes.Trail.outOfRest(p, pane)) return null; if (pane.isTerminal()) { // `tag` is the first row; a prefix longer than it ran to a second. var words = std.mem.tokenizeAny(u8, tag[@min(prefix_len, tag.len)..], " \t\r\n"); @@ -700,7 +702,7 @@ fn tagTintRange(p: *const Pardes, pane: *const Pane, tag: []const u8, prefix_len } return null; } - var start: usize = tagline.nameAt(p, pane); + var start: usize = tagline.nameAt(pane); const name = if (pane.file) |file| if (pane.prompt == .name) pane.input.own orelse file.path else file.path else if (pane.addon) |k| blk: { @@ -1013,7 +1015,7 @@ fn paintPaneTag(p: *Pardes, s: *Surface, arena: std.mem.Allocator, pane: *Pane, else if (pane.prompt == .name) caret: { // A drafted name is the prefix: its caret is on row 0 of the tag, // the rows it wrapped onto included. - const at = modal.positionAt(shown.text, shown.fromReal(tagline.nameAt(p, pane) + @as(usize, @intCast(@max(0, pane.input.cur_col))))); + const at = modal.positionAt(shown.text, shown.fromReal(tagline.nameAt(pane) + @as(usize, @intCast(@max(0, pane.input.cur_col))))); if (at.row < top or at.row >= top + rows) break :caret null; break :caret .{ .row = at.row - top, .at = @min(lines[at.row - top].len, at.col) }; } else if (pane.focus == .tag and pane.prompt == .none and head == null) caret: { @@ -1031,8 +1033,9 @@ fn paintPaneTag(p: *Pardes, s: *Surface, arena: std.mem.Allocator, pane: *Pane, _ = s.print(tx, tag_y + @as(u16, @intCast(row)), tw, line[start..], tag_style); } // The pane's progress at its first row's right end, where the row has - // room for it (SPEC §10.2). - if (top == 0 and rows > 0) for (p.messages.live[0..p.messages.live_len]) |*said| { + // room for it (SPEC §10.2); out of rest the head's right block is + // there (UX D1). + if (top == 0 and rows > 0 and !pardes.Trail.outOfRest(p, pane)) for (p.messages.live[0..p.messages.live_len]) |*said| { if (said.kind != .progress or said.pane != pane.serial) continue; var buf: [Messages.LoggedMessage.cap + 8]u8 = undefined; const text = std.fmt.bufPrint(&buf, "{s} {s}", .{ Messages.Kind.progress.glyph(), said.words() }) catch break; -- cgit v1.3 From 304ea98913c178de9645cad5c3fe45a5f13e25d5 Mon Sep 17 00:00:00 2001 From: Gabriel Schneider Date: Wed, 25 Nov 2026 05:07:21 -0300 Subject: draw: no pane dims while a tag is out of rest (walk UI polish P1, UX DESIGN.md D9): the other panes' every cell took `style.dim` while any tag was out of rest (SPEC §3.6's "slightly", built as the faint attribute: fg 12.5:1 to 4.5:1, comments 4.06:1 to 1.96:1 on neonotte84, UX A7), stacked on the user's own InactiveDim, flashed the whole screen at every SPC and repainted every pane per state change; now a tag out of rest changes its own pane and the notice row only, the others keep their look at rest (InactiveDim already applied to unfocused panes); THE CHANGE: render's pass over the other panes' cells and layers is deleted; TagState.previewing keeps its `.full` (the whole window wearing a theme, taken off at rest) and its doc says so: no pane's own bit is read any more, so Pick.unroll no longer sets the landing pane's (the field keeps its type: the wire and the dumps unchanged); TEST FIRST: Band.zig "a pane whose body would drop below four rows ... borrows them": the other pane's tag and body cells are not dim out of rest (on the base: dim, fails); core-test 1062/1232 (170 skipped); process-test: fsearch's golden regenerated and read: its `typing` style snap's left pane (the terminal) loses the `,f` (faint) on every cell, nothing else; a user saw it at every SPC, picker and prompt 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/Band.zig | 5 ++-- core/Pick.zig | 3 +-- core/TagState.zig | 6 ++--- core/draw.zig | 13 ---------- test/snapshots/fsearch.golden | 56 +++++++++++++++++++++---------------------- 5 files changed, 35 insertions(+), 48 deletions(-) (limited to 'core/draw.zig') diff --git a/core/Band.zig b/core/Band.zig index 2fcf4a3b..31205d87 100644 --- a/core/Band.zig +++ b/core/Band.zig @@ -595,12 +595,13 @@ test "a pane whose body would drop below four rows under its band borrows them f const r = p.view().rects[low]; try std.testing.expect(r.h > before); try std.testing.expect(r.h -| pane.tag_rows >= 4); - // The other panes dim; the one out of rest does not. + // No pane dims out of rest (UX D9): the others look as at rest. var frame = std.heap.ArenaAllocator.init(std.testing.allocator); defer frame.deinit(); const s = try p.render(frame.allocator()); const other = p.view().rects[top]; - try std.testing.expect(s.at(other.x + 3, other.y).style.dim); + try std.testing.expect(!s.at(other.x + 3, other.y).style.dim); + try std.testing.expect(!s.at(other.x + 3, other.y + 1).style.dim); try std.testing.expect(!s.at(r.x + 3, r.y).style.dim); p.update(.{ .key = .{ .cp = Key.escape } }); try std.testing.expectEqual(before, p.view().rects[low].h); diff --git a/core/Pick.zig b/core/Pick.zig index f4e26527..321b16b7 100644 --- a/core/Pick.zig +++ b/core/Pick.zig @@ -260,10 +260,9 @@ fn unroll(p: *Pardes, pk: *Pick, query: []const u8) void { s.rows = .{ .at = @intCast(@min(pk.at, std.math.maxInt(u16))) }; pk.unrolled = true; pk.shown = no_row; - // The whole window previews a theme: no pane dimmed (SPEC §3.6). + // The whole window previews a theme. if (pk.source == .themes) s.previewing = .full; if (p.paneBySerial(pk.landing)) |id| { - s.previewing.set(id); const pane = p.panes[id].?; pk.aside_row = pane.body.cur_row; pk.aside_col = pane.body.cur_col; diff --git a/core/TagState.zig b/core/TagState.zig index 938a45d1..8bead506 100644 --- a/core/TagState.zig +++ b/core/TagState.zig @@ -79,9 +79,9 @@ miss: u8 = 0, /// The leaf each group ran last, by its key (bindings.groups): the cursor /// starts there and the rolled level underlines it (SPEC §4.3). used: [bindings.ngroups]u8 = @splat(0), -/// The panes showing a preview of what the state would do (a picker's -/// landing pane, a pane an action draws ghosts in), by slot: not dimmed -/// while the others are (SPEC §3.6). Set by the state that previews. +/// `.full` while the whole window previews a theme (a themes picker's +/// row, `:theme `'s): its own again at rest. No pane dims out of rest +/// (UX D9), so no pane's own bit is read. previewing: std.StaticBitSet(pardes.MAX_PANES) = .empty, /// describe-key (SPEC §4.5), in the tag of pane `id`: the next keys are diff --git a/core/draw.zig b/core/draw.zig index 179b7cfc..17ac7514 100644 --- a/core/draw.zig +++ b/core/draw.zig @@ -361,19 +361,6 @@ pub fn render(p: *Pardes, arena: std.mem.Allocator) !*Surface { for (s.regionList()) |region| { if (region.kind == .notice) try joinNotice(p, s, arena, region); } - // A tag out of rest: the other panes dim a little so the eye goes to - // it, but a pane showing a preview (walk UI SPEC §3.6). - if (TagState.hostOf(p)) |host| for (p.panes, 0..) |slot, id| { - if (slot == null or id == host or v.tag_state.previewing.isSet(id)) continue; - const r = v.rects[id]; - for (r.y..r.y + r.h) |y| for (r.x..r.x + r.w) |x| { - s.at(@intCast(x), @intCast(y)).style.dim = true; - }; - for ([_]*pardes.Layer{ &s.body_layers[id], &s.tag_layers[id] }) |layer| for (layer.cells[0 .. @as(usize, layer.cols) * layer.rows]) |*cell| { - cell.style.dim = true; - }; - }; - try paintHeaders(p, s); try paintNoticeRow(p, s); diff --git a/test/snapshots/fsearch.golden b/test/snapshots/fsearch.golden index 450ea298..bf8957df 100644 --- a/test/snapshots/fsearch.golden +++ b/test/snapshots/fsearch.golden @@ -50,34 +50,34 @@ == style typing grid=180x31 |0: 0-1 d,#1d2824, 2-179 #b2c3b8,#1d2824, |1: 0-1 d,#887455, 2-89 #b2c3b8,#1d2824, 90-91 #b2c3b8,#887455, 92-179 #becfc4,#314738, -|2: 0-1 d,#496656,f 2-30 #b2c3b8,#1d2824,f 31-40 #d3b0d9,#1d2824,f 41-89 #b2c3b8,#1d2824,f 90-91 #b2c3b8,#496656,f 92-120 #b2c3b8,#1d2824,f 121-130 #d3b0d9,#1d2824,f 131-179 #b2c3b8,#1d2824,f -|3: 0-0 d,#608269,f 1-1 d,#0d1410,f 2-89 #e5eee5,#0d1410,f 90-90 #e5eee5,#608269,f 91-179 #e5eee5,#0d1410,f -|4: 0-0 d,#608269,f 1-1 d,#0d1410,f 2-89 #e5eee5,#0d1410,f 90-90 #e5eee5,#608269,f 91-179 #e5eee5,#0d1410,f -|5: 0-0 d,#608269,f 1-89 d,#0d1410,f 90-90 d,#608269,f 91-179 d,#0d1410,f -|6: 0-0 d,#608269,f 1-89 d,#0d1410,f 90-90 d,#608269,f 91-179 d,#0d1410,f -|7: 0-0 d,#608269,f 1-89 d,#0d1410,f 90-90 d,#608269,f 91-179 d,#0d1410,f -|8: 0-0 d,#608269,f 1-3 d,#0d1410,f 4-89 #e5eee5,#0d1410,f 90-90 #e5eee5,#608269,f 91-179 #e5eee5,#0d1410,f -|9: 0-0 d,#608269,f 1-89 d,#0d1410,f 90-90 d,#608269,f 91-179 d,#0d1410,f -|10: 0-0 d,#608269,f 1-89 d,#0d1410,f 90-90 d,#608269,f 91-179 d,#0d1410,f -|11: 0-0 d,#608269,f 1-89 d,#0d1410,f 90-90 d,#608269,f 91-179 d,#0d1410,f -|12: 0-0 d,#608269,f 1-89 d,#0d1410,f 90-90 d,#608269,f 91-179 d,#0d1410,f -|13: 0-0 d,#608269,f 1-89 d,#0d1410,f 90-90 d,#608269,f 91-179 d,#0d1410,f -|14: 0-0 d,#608269,f 1-89 d,#0d1410,f 90-90 d,#608269,f 91-179 d,#0d1410,f -|15: 0-0 d,#608269,f 1-89 d,#0d1410,f 90-90 d,#608269,f 91-179 d,#0d1410,f -|16: 0-1 d,#496656,f 2-30 #b2c3b8,#1d2824,f 31-40 #d3b0d9,#1d2824,f 41-89 #b2c3b8,#1d2824,f 90-91 #000000,#add38a, 92-98 #becfc4,#2c2819, 99-99 #add38a,#2c2819,b 100-100 #add38a,#2c2819, 101-104 #becfc4,#2c2819, 105-112 #becfc4,#2c2819,f 113-138 #becfc4,#2c2819, 139-179 #becfc4,#2c2819,f -|17: 0-0 d,#608269,f 1-1 d,#0d1410,f 2-89 #e5eee5,#0d1410,f 90-91 #e5eee5,#2c2819, 92-92 #becfc4,#2c2819,f 93-179 #becfc4,#2c2819, -|18: 0-0 d,#608269,f 1-1 d,#0d1410,f 2-89 #e5eee5,#0d1410,f 90-90 #e5eee5,#e5eee5, 91-94 #e5eee5,#0d1410, 95-96 #59675c,#0d1410, 97-179 #e5eee5,#0d1410, -|19: 0-0 d,#608269,f 1-89 d,#0d1410,f 90-90 d,#608269, 91-91 d,#0d1410, 92-94 d,#0d1410,b 95-95 #616f64,#0d1410,b 96-96 #add38a,#0d1410,b 97-100 #f5f7ee,#3c614a, 101-101 #f5f7ee,#0d1410, 102-179 #e5eee5,#0d1410, -|20: 0-0 d,#608269,f 1-89 d,#0d1410,f 90-90 d,#608269, 91-94 d,#0d1410, 95-96 #59675c,#0d1410, 97-179 #e5eee5,#0d1410, -|21: 0-0 d,#608269,f 1-89 d,#0d1410,f 90-90 d,#608269, 91-94 d,#0d1410, 95-96 #59675c,#0d1410, 97-179 #e5eee5,#0d1410, -|22: 0-0 d,#608269,f 1-89 d,#0d1410,f 90-90 d,#5e4923, 91-94 d,#0d1410, 95-96 #59675c,#0d1410, 97-179 #e5eee5,#0d1410, -|23: 0-0 d,#608269,f 1-89 d,#0d1410,f 90-90 d,#608269, 91-94 d,#0d1410, 95-95 #59675c,#0d1410, 96-96 #add38a,#0d1410, 97-100 #e5eee5,#352e19, 101-179 #e5eee5,#0d1410, -|24: 0-0 d,#608269,f 1-89 d,#0d1410,f 90-90 d,#608269, 91-94 d,#0d1410, 95-96 #59675c,#0d1410, 97-179 #e5eee5,#0d1410, -|25: 0-0 d,#608269,f 1-89 d,#0d1410,f 90-90 d,#608269, 91-94 d,#0d1410, 95-96 #59675c,#0d1410, 97-179 #e5eee5,#0d1410, -|26: 0-0 d,#608269,f 1-89 d,#0d1410,f 90-90 d,#608269, 91-94 d,#0d1410, 95-96 #59675c,#0d1410, 97-179 #e5eee5,#0d1410, -|27: 0-0 d,#608269,f 1-89 d,#0d1410,f 90-90 d,#5e4923, 91-93 d,#0d1410, 94-95 #59675c,#0d1410, 96-96 #add38a,#0d1410, 97-100 #e5eee5,#352e19, 101-179 #e5eee5,#0d1410, -|28: 0-0 d,#608269,f 1-89 d,#0d1410,f 90-90 d,#608269, 91-93 d,#0d1410, 94-96 #59675c,#0d1410, 97-179 #e5eee5,#0d1410, -|29: 0-0 d,#608269,f 1-89 d,#0d1410,f 90-90 d,#608269, 91-93 d,#0d1410, 94-96 #59675c,#0d1410, 97-179 #e5eee5,#0d1410, +|2: 0-1 d,#496656, 2-30 #b2c3b8,#1d2824, 31-40 #d3b0d9,#1d2824, 41-89 #b2c3b8,#1d2824, 90-91 #b2c3b8,#496656, 92-120 #b2c3b8,#1d2824, 121-130 #d3b0d9,#1d2824, 131-179 #b2c3b8,#1d2824, +|3: 0-0 d,#608269, 1-1 d,#0d1410, 2-89 #e5eee5,#0d1410, 90-90 #e5eee5,#608269, 91-179 #e5eee5,#0d1410, +|4: 0-0 d,#608269, 1-1 d,#0d1410, 2-89 #e5eee5,#0d1410, 90-90 #e5eee5,#608269, 91-179 #e5eee5,#0d1410, +|5: 0-0 d,#608269, 1-89 d,#0d1410, 90-90 d,#608269, 91-179 d,#0d1410, +|6: 0-0 d,#608269, 1-89 d,#0d1410, 90-90 d,#608269, 91-179 d,#0d1410, +|7: 0-0 d,#608269, 1-89 d,#0d1410, 90-90 d,#608269, 91-179 d,#0d1410, +|8: 0-0 d,#608269, 1-3 d,#0d1410, 4-89 #e5eee5,#0d1410, 90-90 #e5eee5,#608269, 91-179 #e5eee5,#0d1410, +|9: 0-0 d,#608269, 1-89 d,#0d1410, 90-90 d,#608269, 91-179 d,#0d1410, +|10: 0-0 d,#608269, 1-89 d,#0d1410, 90-90 d,#608269, 91-179 d,#0d1410, +|11: 0-0 d,#608269, 1-89 d,#0d1410, 90-90 d,#608269, 91-179 d,#0d1410, +|12: 0-0 d,#608269, 1-89 d,#0d1410, 90-90 d,#608269, 91-179 d,#0d1410, +|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,#2c2819, 99-99 #add38a,#2c2819,b 100-100 #add38a,#2c2819, 101-104 #becfc4,#2c2819, 105-112 #becfc4,#2c2819,f 113-138 #becfc4,#2c2819, 139-179 #becfc4,#2c2819,f +|17: 0-0 d,#608269, 1-1 d,#0d1410, 2-89 #e5eee5,#0d1410, 90-91 #e5eee5,#2c2819, 92-92 #becfc4,#2c2819,f 93-179 #becfc4,#2c2819, +|18: 0-0 d,#608269, 1-1 d,#0d1410, 2-89 #e5eee5,#0d1410, 90-90 #e5eee5,#e5eee5, 91-94 #e5eee5,#0d1410, 95-96 #59675c,#0d1410, 97-179 #e5eee5,#0d1410, +|19: 0-0 d,#608269, 1-89 d,#0d1410, 90-90 d,#608269, 91-91 d,#0d1410, 92-94 d,#0d1410,b 95-95 #616f64,#0d1410,b 96-96 #add38a,#0d1410,b 97-100 #f5f7ee,#3c614a, 101-101 #f5f7ee,#0d1410, 102-179 #e5eee5,#0d1410, +|20: 0-0 d,#608269, 1-89 d,#0d1410, 90-90 d,#608269, 91-94 d,#0d1410, 95-96 #59675c,#0d1410, 97-179 #e5eee5,#0d1410, +|21: 0-0 d,#608269, 1-89 d,#0d1410, 90-90 d,#608269, 91-94 d,#0d1410, 95-96 #59675c,#0d1410, 97-179 #e5eee5,#0d1410, +|22: 0-0 d,#608269, 1-89 d,#0d1410, 90-90 d,#5e4923, 91-94 d,#0d1410, 95-96 #59675c,#0d1410, 97-179 #e5eee5,#0d1410, +|23: 0-0 d,#608269, 1-89 d,#0d1410, 90-90 d,#608269, 91-94 d,#0d1410, 95-95 #59675c,#0d1410, 96-96 #add38a,#0d1410, 97-100 #e5eee5,#352e19, 101-179 #e5eee5,#0d1410, +|24: 0-0 d,#608269, 1-89 d,#0d1410, 90-90 d,#608269, 91-94 d,#0d1410, 95-96 #59675c,#0d1410, 97-179 #e5eee5,#0d1410, +|25: 0-0 d,#608269, 1-89 d,#0d1410, 90-90 d,#608269, 91-94 d,#0d1410, 95-96 #59675c,#0d1410, 97-179 #e5eee5,#0d1410, +|26: 0-0 d,#608269, 1-89 d,#0d1410, 90-90 d,#608269, 91-94 d,#0d1410, 95-96 #59675c,#0d1410, 97-179 #e5eee5,#0d1410, +|27: 0-0 d,#608269, 1-89 d,#0d1410, 90-90 d,#5e4923, 91-93 d,#0d1410, 94-95 #59675c,#0d1410, 96-96 #add38a,#0d1410, 97-100 #e5eee5,#352e19, 101-179 #e5eee5,#0d1410, +|28: 0-0 d,#608269, 1-89 d,#0d1410, 90-90 d,#608269, 91-93 d,#0d1410, 94-96 #59675c,#0d1410, 97-179 #e5eee5,#0d1410, +|29: 0-0 d,#608269, 1-89 d,#0d1410, 90-90 d,#608269, 91-93 d,#0d1410, 94-96 #59675c,#0d1410, 97-179 #e5eee5,#0d1410, |30: 0-1 d,#1d2824, 2-179 #67756e,#1d2824, == 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 -- cgit v1.3 From 5c897d00fe064cf8463ef76ea804b0aff6b62f0a Mon Sep 17 00:00:00 2001 From: Gabriel Schneider Date: Wed, 25 Nov 2026 06:06:54 -0300 Subject: Band, Core, draw, mouse, layout: a band over a terminal or a kind's pane is drawn over its body's top rows, so a transient state never resizes a pty or a kind's view (walk UI polish P1, G3's finding; UX DESIGN.md D6's borrowing and R3, drawn never written, my reading of D5/D6 for these bodies): a band's rows came out of the pane's body in every pane (Core.sync `tag_rows += band_rows`), so `:` or SPC Down in a terminal resized its pty smaller and back, the shell redrew under it and left its prompt row blank (tagnav's row 6 `$ `, ttytaken's prompt line moved two columns), and a PDF's view was re-sized each time; now Band.over (a terminal, a kind's pane) keeps its `band_rows` at 0, the pane's size the user's alone, and the band is painted after every pane's body (draw.render, Band.shownRows: what the band wants held to the body's rows) at the body's first row, its layer's viewport there; mouse.bandPoint reads the same rows; layout.floorRows borrows nothing for it; joinBand takes its rows; TEST FIRST: TagState.zig "a band over a terminal is drawn over its body's top rows: its pty keeps its size across the band's open and close" (a shell: SPC Down, then `:`: band_rows 0, the tag's rows, the pty's rows and columns as at rest, the band layer at the body's top, no resize_pty effect after Esc; on the parent it fails at band_rows: the band's rows were the body's); the terminal test of rolled levels loses its key-cell-alone step (D12 took that state away); core-test 1066/1237 (171 skipped), shell-test's terminal tests 12/12; process-test: tagnav and ttytaken regenerated and read: tagnav's tty-on and column-tag snaps have the shell's `$ ` on row 6 again (G2's golden), ttytaken's at-prompt row 5 is ` echo TAKEN''ONE` again (main's; E2's two-column shift was the resize's redraw); a user met it at every `:` or band in a terminal Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_016Y9MNBFhdevVu48bvL9kCE --- core/Band.zig | 16 ++++++++++++++++ core/Core.zig | 3 ++- core/TagState.zig | 42 ++++++++++++++++++++++++++++++++++++------ core/draw.zig | 15 +++++++++++---- core/layout.zig | 2 +- core/mouse.zig | 5 +++-- test/snapshots/tagnav.golden | 2 ++ test/snapshots/ttytaken.golden | 2 +- 8 files changed, 72 insertions(+), 15 deletions(-) (limited to 'core/draw.zig') diff --git a/core/Band.zig b/core/Band.zig index 0d4891aa..07c2f83d 100644 --- a/core/Band.zig +++ b/core/Band.zig @@ -113,6 +113,22 @@ pub fn takes(p: *Pardes, id: usize) u16 { return @max(doc_rows, levelRows(n)); } +/// A terminal's and a kind's band is drawn over the top rows of its body +/// (UX D6's borrowing, R3: drawn, never written): a transient state never +/// resizes a pty under a program or a kind's view (a PDF's), whose size +/// only the user's resize changes. Their `band_rows` stay 0. +pub fn over(pane: *const Pane) bool { + return pane.isTerminal() or pane.addon != null; +} + +/// The rows pane `id`'s band is drawn on: those it takes from the layout, +/// or over a terminal's or a kind's body, as many of its body rows as the +/// band wants. +pub fn shownRows(p: *Pardes, pane: *const Pane, id: usize) u16 { + if (pane.band_rows > 0 or !over(pane) or pane.collapsed) return pane.band_rows; + return @min(takes(p, id), p.view().rects[id].h -| pane.tag_rows); +} + fn levelRows(n: u16) u16 { return if (n > one_column) (n + 1) / 2 else n; } diff --git a/core/Core.zig b/core/Core.zig index e43f9e83..26860365 100644 --- a/core/Core.zig +++ b/core/Core.zig @@ -2062,7 +2062,8 @@ pub fn sync(p: *Pardes) void { } else pane.tag_top = 0; // The band unrolled under the tag's text pushes the body down: // the tag's rows, as everything under them counts them. - pane.band_rows = if (pane.collapsed) 0 else @min(pardes.Band.takes(p, id), r.h -| pane.tag_rows); + // A terminal's or a kind's is drawn over its body instead (Band.over). + pane.band_rows = if (pane.collapsed or pardes.Band.over(pane)) 0 else @min(pardes.Band.takes(p, id), r.h -| pane.tag_rows); pane.tag_rows += pane.band_rows; const cols = @max(1, r.w -| config.GUTTER); // The tag steals the top rows. The pty is what the pane shows diff --git a/core/TagState.zig b/core/TagState.zig index 18fd5fac..c364451a 100644 --- a/core/TagState.zig +++ b/core/TagState.zig @@ -1178,12 +1178,6 @@ test "a terminal's rolled level keeps its tag rows at every width, C-w's as SPC' p.sync(); const rows, const tag_rows = .{ pane.rows, pane.tag_rows }; p.update(.{ .key = root }); - // Its key cell alone, before the level shows: shorter than the - // tag's own text, the rows it had. - p.sync(); - try std.testing.expect(hostOf(p) == shell); - try std.testing.expectEqual(tag_rows, pane.tag_rows); - try std.testing.expectEqual(rows, pane.rows); p.advance(p.clock.now_ns); p.clock.now_ns = p.view().tag_state.due_ns; p.sync(); @@ -1193,6 +1187,42 @@ test "a terminal's rolled level keeps its tag rows at every width, C-w's as SPC' }; } +test "a band over a terminal is drawn over its body's top rows: its pty keeps its size across the band's open and close" { + if (pardes.Term.ops == null) return error.SkipZigTest; // a shell + const Key = pardes.Key; + const p = try Pardes.init(std.testing.allocator, .{ .file = "mise.toml", .cols = 100, .rows = 30 }); + defer p.deinit(); + _ = pardes.exec.spawnTty(p, 0); + const shell = p.view().active; + const pane = p.panes[shell].?; + pane.body.mode = .normal; + p.sync(); + while (p.nextEffect()) |_| {} + const rows, const cols, const tag_rows = .{ pane.rows, pane.cols, pane.tag_rows }; + var frame = std.heap.ArenaAllocator.init(std.testing.allocator); + defer frame.deinit(); + // SPC unrolled, then `:`'s rows (the tagnav case): a band each, over + // the body; no resize of the pty while it is open, nor when it goes. + for ([_][]const Key{ &.{ .{ .cp = ' ' }, .{ .cp = Key.down } }, &.{.{ .cp = ':' }} }) |keys| { + for (keys) |k| p.update(.{ .key = k }); + p.sync(); + try std.testing.expect(hostOf(p) == shell); + try std.testing.expectEqual(@as(u16, 0), pane.band_rows); + try std.testing.expectEqual(tag_rows, pane.tag_rows); + try std.testing.expectEqual(rows, pane.rows); + try std.testing.expectEqual(cols, pane.cols); + _ = frame.reset(.retain_capacity); + _ = try p.render(frame.allocator()); + const layer = &p.surface.tag_layers[pardes.BAND_LAYER]; + try std.testing.expect(layer.kind == .band and layer.rows > 0); + try std.testing.expectEqual(p.bodyTop(pane, p.view().rects[shell]), layer.viewport.y); + p.update(.{ .key = .{ .cp = Key.escape } }); + p.sync(); + try std.testing.expectEqual(rows, pane.rows); + while (p.nextEffect()) |e| try std.testing.expect(e != .resize_pty); + } +} + test "a tag out of rest keeps its rows at rest at least: a level shorter than its own text moves no body up" { const p = try Pardes.init(std.testing.allocator, .{ .tty_only = true, .cols = 40, .rows = 30 }); defer p.deinit(); diff --git a/core/draw.zig b/core/draw.zig index 17ac7514..f69f83c6 100644 --- a/core/draw.zig +++ b/core/draw.zig @@ -357,6 +357,12 @@ pub fn render(p: *Pardes, arena: std.mem.Allocator) !*Surface { s.body_layers[id].rows = 0; try renderPane(p, s, arena, pane, v.rects[id], id, id == v.active); } + // A band over a terminal's or a kind's body (Band.over), drawn after + // the body it covers. + if (TagState.hostOf(p)) |id| if (p.panes[id]) |pane| if (pane.band_rows == 0) { + const rows = pardes.Band.shownRows(p, pane, id); + if (rows > 0) try joinBand(p, s, arena, pane, v.rects[id], id, id == v.active, rows); + }; // Each notice once, as a tag layer, and the grid's chip a copy of it. for (s.regionList()) |region| { if (region.kind == .notice) try joinNotice(p, s, arena, region); @@ -495,7 +501,7 @@ fn renderPane(p: *Pardes, s: *Surface, arena: std.mem.Allocator, pane: *Pane, r: try joinPaneTag(p, s, arena, pane, r, id, active); // The keyboard is in the head's field: its caret, not the body's. const head_caret = if (typing) s.cursor else null; - if (pane.band_rows > 0) try joinBand(p, s, arena, pane, r, id, active); + if (pane.band_rows > 0) try joinBand(p, s, arena, pane, r, id, active, pane.band_rows); // Folded panes retain their body state, but neither body pixels nor // its cursor belong outside the one-row tag rectangle. @@ -868,14 +874,13 @@ fn joinPaneTag(p: *Pardes, s: *Surface, arena: std.mem.Allocator, pane: *Pane, r /// layer at the tagline's pitch, a row to a line, and copied into the /// grid: the spines and steps in the tag's tint, the keys in the key ink, /// the cursor's row tinted as a selection. -fn joinBand(p: *Pardes, s: *Surface, arena: std.mem.Allocator, pane: *Pane, r: Rect, id: usize, active: bool) !void { +fn joinBand(p: *Pardes, s: *Surface, arena: std.mem.Allocator, pane: *Pane, r: Rect, id: usize, active: bool, rows: u16) !void { const layer = &s.tag_layers[pardes.BAND_LAYER]; if (r.w <= TAG_TEXT_INSET) return; const band = (try pardes.Band.of(p, arena, pane, id)) orelse return; const th = p.theme(); const chrome = p.chromeTheme(); const tab = p.settings.tab; - const rows = pane.band_rows; const columns = @max(band.columns, 1); const bg = tagGround(p, pane, active); const fg = if (active) chrome.tag_active_fg else chrome.tag_fg; @@ -921,7 +926,9 @@ fn joinBand(p: *Pardes, s: *Surface, arena: std.mem.Allocator, pane: *Pane, r: R const count = @as(usize, columns) * rows; if (layer.cells.len != count) layer.cells = try p.gpa.realloc(layer.cells, count); @memcpy(layer.cells, storage); - const y0 = p.tagTop(pane, r) + (pane.tag_rows - rows); + // Under the tag's text rows; a terminal's or a kind's over its body's + // top rows (Band.over). + const y0 = p.tagTop(pane, r) + (pane.tag_rows - pane.band_rows); layer.kind = .band; layer.id = @intCast(id); layer.serial = pane.serial; diff --git a/core/layout.zig b/core/layout.zig index 0a773cab..de12294b 100644 --- a/core/layout.zig +++ b/core/layout.zig @@ -1476,7 +1476,7 @@ pub fn compute(p: *Pardes) void { /// (walk UI SPEC §3.6). fn floorRows(p: *Pardes, id: usize) u16 { const pane = p.panes[id] orelse return 0; - const band = pardes.Band.takes(p, id); + const band = if (pardes.Band.over(pane)) 0 else pardes.Band.takes(p, id); if (band > 0) return @max(1, pane.tag_rows -| pane.band_rows) + band + 4; return if (pane.isTerminal()) @max(1, pane.tag_rows) + min_body_rows else 1; } diff --git a/core/mouse.zig b/core/mouse.zig index 89a8c5c6..6516ea71 100644 --- a/core/mouse.zig +++ b/core/mouse.zig @@ -914,10 +914,11 @@ fn bandPoint(p: *Pardes, mcol: u16, mrow: u16) ?BandPoint { if (v.pointer_tag_hit) |hit| return if (hit.kind == .band) .{ .id = hit.id, .line = hit.line, .col = hit.col } else null; const id = paneAt(p, mcol, mrow) orelse return null; const pane = p.panes[id].?; - if (pane.band_rows == 0) return null; + const rows = pardes.Band.shownRows(p, pane, id); + if (rows == 0) return null; const r = v.rects[id]; const top = p.tagTop(pane, r) + (pane.tag_rows - pane.band_rows); - if (mrow < top or mrow >= top + pane.band_rows or mcol < r.x + TAG_TEXT_INSET) return null; + if (mrow < top or mrow >= top + rows or mcol < r.x + TAG_TEXT_INSET) return null; return .{ .id = id, .line = mrow - top, .col = mcol - (r.x + TAG_TEXT_INSET) }; } diff --git a/test/snapshots/tagnav.golden b/test/snapshots/tagnav.golden index 9bf061bc..1039c40a 100644 --- a/test/snapshots/tagnav.golden +++ b/test/snapshots/tagnav.golden @@ -42,12 +42,14 @@ == snap tty-on grid=100x31 cursor=54,6 |2: /tmp/pardes-snap/tagnav/cwd/w.txt Save Term Coll$ /tmp/pardes-snap/tagnav/cwd Term+bash Save Mode |4: 1 alpha $ ls +|6: 3 gamma $ |30: ✓ /tmp/pardes-snap/tagnav/cwd/w.txt Window 5 messages · SPC h m == snap tty-tag grid=100x31 cursor=95,2 == snap tty-restored grid=100x31 cursor=54,6 == snap column-tag grid=100x31 cursor=2,1 |2: /tmp/pardes-snap/tagnav/cwd/w.txt Save Term Coll /tmp/pardes-snap/tagnav/cwd Term+bash Save Mode |4: 1 alpha ls +|6: 3 gamma |30: ✓ /tmp/pardes-snap/tagnav/cwd/w.txt Up 8 messages · SPC h m == snap column-word grid=100x31 cursor=5,1 == snap workspace-tag grid=100x31 cursor=2,0 diff --git a/test/snapshots/ttytaken.golden b/test/snapshots/ttytaken.golden index a2011891..337072f1 100644 --- a/test/snapshots/ttytaken.golden +++ b/test/snapshots/ttytaken.golden @@ -32,7 +32,7 @@ | /tmp/pardes-snap/ttytaken/cwd == snap at-prompt grid=210x31 cursor=4,5 |2: /tmp/pardes-snap/ttytaken/cwd Term+bash Save Mode Filter Collapse Del @`echo TAKEN''ONE` -|5: echo TAKEN''ONE +|5: echo TAKEN''ONE |6: TAKENONE |30: ✓ @p1 Exec 1 message · SPC h m == snap paging grid=210x31 cursor=9,29 -- cgit v1.3 From 56ca48879da0dd335097d695fb7f4b4b6fe5157b Mon Sep 17 00:00:00 2001 From: Gabriel Schneider Date: Wed, 25 Nov 2026 06:26:22 -0300 Subject: Band, draw: drawing the band: its steps from two cells right of the last spine and the spines kept at every width, a list's rows 52 cells at most, a give-way that never clips, the cursor's row tinted across its step, the spines on through the tag's rows under the head (walk UI polish P1, UX DESIGN.md D5, geometry; the colours stay today's fields, `// P2: the rule role` where a spine is drawn): a band narrower than its steps dropped its spines and started its steps at the pane's left edge (shots 04-L, 08-L), a level or a list was as wide as its widest row whatever its length, and the tag's rows kept from rest under a one-row head were bare where the spines should run; now Band.place starts at the last spine + 2 always, makes a level's column its widest row and a list's 52 cells at most (`row_cells`), and gives way in UX D5's order: the head's hints first (D3), the doc leaves the band where it has no 24 cells, the last list unrolled (a picker's acts, M-l) takes the place of the others where they do not all fit, and one step left is held to the room there is (24 cells at least), its rows cut with `…` (D2's Band.cutRow): nothing runs off the right edge; draw.joinBand tints the cursor's row across its step's width, its `▶ ` lead too; draw.paintPaneTag draws a `│` under each key cell in the tag's rows under the head's own (the rows a tag keeps from rest, A2's rule), so the spines run unbroken from the head into the band; the box glyph stays on row 1 alone, the grip column under it the tag's ground (as it was in a terminal; the window's grip seams and the tag rule's place under the band are the window's: see the screenshots), the row meta of D5 is not built (no step has right-hand meta yet); TEST FIRST: Band.zig "a narrow band gives way and keeps its spines: the doc goes, the steps start two cells right of the last spine, no row past the band's edge; the spines run on through the tag's rows under the head" (44 columns, Help for SPC l: two spines, one step at the last spine + 2, every row within the band, `│` in the tag's second row under each key cell; on the parent the spines are dropped: 0, and the second row is blank); core-test 1069/1240 (171 skipped); process-test: fsearch regenerated and read: its nomatch snap's tag keeps two rows under a one-row prompt head, the second now with a `│` under the `/` key cell; a user saw the band lose its spines at 26 px 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/Band.zig | 61 ++++++++++++++++++++++++++++++++++++------- core/draw.zig | 21 +++++++++++++-- test/snapshots/fsearch.golden | 2 +- 3 files changed, 72 insertions(+), 12 deletions(-) (limited to 'core/draw.zig') diff --git a/core/Band.zig b/core/Band.zig index e34b6a49..2b688a61 100644 --- a/core/Band.zig +++ b/core/Band.zig @@ -71,6 +71,8 @@ pub const max_steps = 4; pub const max_spines = 12; /// The narrowest a step is drawn (SPEC §3.6: box, spines, one 24-cell column). pub const min_width = 24; +/// The widest a list's rows are laid out (UX D5). +const row_cells = 52; /// A doc's rows, the fewest a band with one has. const doc_rows = 4; /// The body rows a band leaves its pane at least: it gives way first (UX D6). @@ -375,26 +377,33 @@ pub fn docStep(p: *Pardes, arena: std.mem.Allocator, root: bindings.Root, path: return .{ .rows = rows.items, .doc = true }; } -/// Where each step goes: right of the spines, a rule's cell between steps; -/// a doc takes what is left, wrapped to it. Narrow, the doc goes first, -/// then the spines (the steps start at the band's left edge). +/// Where each step goes (UX D5): from two cells right of the last spine, +/// a rule's cell between steps; a level as wide as its widest row (two +/// columns past nine), a list of rows `row_cells` at most, a doc the width +/// the others leave, wrapped to it, `min_width` at least. Narrower than +/// the steps (the hints already gone from the head), the band gives way: +/// the doc leaves it, then the last step unrolled (a picker's acts) takes +/// the place of the others; one step left is held to the room there is, +/// its rows cut with `…` (Band.cutRow): the spines stay, nothing is clipped +/// off the right edge. fn place(band: *Band, p: *Pardes, arena: std.mem.Allocator, pane: *Pane, id: usize) !void { const tab = p.settings.tab; try band.findSpines(p, arena, pane, id); - var x: u16 = if (band.nspines > 0) band.spines[band.nspines - 1] + 2 else 0; + const x0: u16 = if (band.nspines > 0) band.spines[band.nspines - 1] + 2 else 0; var need: u16 = 0; + var lists: u8 = 0; 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)); - const column: u16 = @intCast(@min(widest + 2, std.math.maxInt(u16) / 4, @max(min_width, band.columns -| x))); + const column: u16 = @intCast(@min(widest, row_cells) + 2); step.width = if (step.two) 2 * column + 1 else column; need += step.width + 2; + lists += 1; } - if (x + need > band.columns) { - band.nspines = 0; - x = 0; - } + // The last list alone where they do not all fit. + var skip: u8 = if (x0 + need > band.columns and lists > 1) lists - 1 else 0; + var x = x0; var kept: u8 = 0; for (band.steps[0..band.nsteps]) |step| { var placed = step; @@ -403,6 +412,12 @@ fn place(band: *Band, p: *Pardes, arena: std.mem.Allocator, pane: *Pane, id: usi if (room < min_width) continue; placed.width = room; placed.rows = try wrap(arena, tab, step.rows, room -| 1, band.height); + } else { + if (skip > 0) { + skip -= 1; + continue; + } + placed.width = @min(placed.width, @max(band.columns -| x, @min(min_width, band.columns))); } placed.x = x; x +|= placed.width + 2; @@ -562,6 +577,34 @@ fn layerRow(arena: std.mem.Allocator, layer: *const pardes.Layer, row: usize) ![ return out.items; } +test "a narrow band gives way and keeps its spines: the doc goes, the steps start two cells right of the last spine, no row past the band's edge; the spines run on through the tag's rows under the head" { + const Key = pardes.Key; + const p = try Pardes.init(std.testing.allocator, .{ .tty_only = true, .cols = 44, .rows = 30 }); + defer p.deinit(); + const pane = try p.setTestFile("one\n"); + const id = p.view().active; + p.sync(); + try std.testing.expect(pane.tag_rows > 1); + var frame = std.heap.ArenaAllocator.init(std.testing.allocator); + defer frame.deinit(); + const a = frame.allocator(); + // Help for SPC l: its key cells `␣ l`, its rows, no room for a doc. + for ([_]u21{ ' ', 'l', '?' }) |c| p.update(.{ .key = .{ .cp = c } }); + p.sync(); + const band = (try of(p, a, pane, id)).?; + try std.testing.expectEqual(@as(u8, 2), band.nspines); + try std.testing.expectEqual(@as(u8, 1), band.nsteps); + try std.testing.expectEqual(band.spines[1] + 2, band.steps[0].x); + for (0..band.height) |y| try std.testing.expect(File.displayWidth(p.settings.tab, (try band.line(a, p.settings.tab, @intCast(y))).text) <= band.columns); + // The tag's second row, kept from rest under the head's one: a spine + // under each key cell. + const s = try p.render(a); + const r = p.view().rects[id]; + const tag_y = p.tagTop(pane, r); + for (band.spines[0..band.nspines]) |col| try std.testing.expectEqualStrings("│", s.at(r.x + pardes.TAG_TEXT_INSET + col, tag_y + 1).grapheme()); + p.update(.{ .key = .{ .cp = Key.escape } }); +} + test "a row longer than its room is cut with `…`: a path from the left, anything else from the right, its marks and faint bytes moved with it" { var arena: std.heap.ArenaAllocator = .init(std.testing.allocator); defer arena.deinit(); diff --git a/core/draw.zig b/core/draw.zig index f69f83c6..be4230c4 100644 --- a/core/draw.zig +++ b/core/draw.zig @@ -903,7 +903,8 @@ fn joinBand(p: *Pardes, s: *Surface, arena: std.mem.Allocator, pane: *Pane, r: R } for (ln.parts) |part| { const end = @min(columns, part.col + part.width); - if (part.row.on and part.col < end) t.tint(part.col, row, end - part.col, th.tag_sel_bg orelse th.sel_bg, th.sel_fg); + // The cursor's row across its step's width, its lead too (UX D5). + if (part.row.on and part.col < end) t.tint(part.col -| 2, row, end - (part.col -| 2), th.tag_sel_bg orelse th.sel_bg, th.sel_fg); var c = part.col; var b: usize = 0; while (b < part.row.text.len and c < end) : (c += 1) { @@ -999,7 +1000,11 @@ fn paintPaneTag(p: *Pardes, s: *Surface, arena: std.mem.Allocator, pane: *Pane, var lines: [MAX_TAG_ROWS][]const u8 = @splat(""); var split = std.mem.splitScalar(u8, shown.text, '\n'); for (0..top) |_| _ = split.next(); - for (lines[0..rows]) |*line| line.* = split.next() orelse ""; + var nlines: usize = 0; + for (lines[0..rows]) |*line| { + line.* = split.next() orelse continue; + nlines += 1; + } // The keyboard's caret, as a row and a byte offset in that row's // line: in the tag's own text when the tag has the keyboard, in the // path while a name is drafted. @@ -1026,6 +1031,18 @@ fn paintPaneTag(p: *Pardes, s: *Surface, arena: std.mem.Allocator, pane: *Pane, const start = @min(line.len, panes.File.rawAtDisplay(p.settings.tab, line, pane.tag_scroll)); _ = s.print(tx, tag_y + @as(u16, @intCast(row)), tw, line[start..], tag_style); } + // Out of rest the rows the tag keeps from rest under the head's own: + // the spines on through them, under the key cells (UX D5). + if (head) |h| if (top == 0 and nlines < rows and h.cells > 0) { + const first = lines[0]; + for (h.spans[0..h.cells]) |cell| { + const at = prefix_len + cell.lo; + if (at > first.len) break; + const col = panes.File.rawDisplayCol(p.settings.tab, first, at); + if (col >= tw) break; + for (nlines..rows) |row| s.set(tx + @as(u16, @intCast(col)), tag_y + @as(u16, @intCast(row)), "│", .{ .fg = .{ .rgb = chrome.box }, .bg = .{ .rgb = tag_bg }, .font_role = .tagline }); // P2: the rule role (UX D4) + } + }; // The pane's progress at its first row's right end, where the row has // room for it (SPEC §10.2); out of rest the head's right block is // there (UX D1). diff --git a/test/snapshots/fsearch.golden b/test/snapshots/fsearch.golden index 905d2ef0..59037755 100644 --- a/test/snapshots/fsearch.golden +++ b/test/snapshots/fsearch.golden @@ -130,4 +130,4 @@ == snap cancel grid=180x31 cursor=97,23 == snap nomatch grid=180x31 cursor=118,16 |16: /tmp/pardes-snap/fsearch/cwd Term+bash Save Mode Filter Collapse Del ^ ‹@p1 › /MARK/ 2/3 › / zzqq = Look /zzqq/ 0 ⏎ land · M-⏎ as a list · C-r history · esc -|17: ls +|17: ls │ -- cgit v1.3 From c51ecfb07e4c5d091d0155c609205c7e5f6bc0b1 Mon Sep 17 00:00:00 2001 From: Gabriel Schneider Date: Wed, 25 Nov 2026 06:31:43 -0300 Subject: Trail, tagline, draw, Prompt: the trail at rest: the steps past the newest three fold into one dim `+N ›` after the owner, fewer whole while the walk would add a row to the tag, the forward steps past two into one `› +N`, two files of the same name told apart by the shortest end of their paths, the word n walks underlined (walk UI polish P1, UX DESIGN.md D8, C3): each folded step was a `·` of its own (four cells each, nameless), the walk took the rows it wanted (05a-L, 05b-L: a reader's tag two rows at rest, so a jump moved the body), and two `x.zig` steps read alike; now Trail.foldOf names the folded steps (back: those older than the newest `whole`, never the owner; forward: those past `shown_ahead` = 2), Trail.wordIn writes the first of them as `+N` and nothing for the others (out of rest `.newest` as D1 made it), Trail.stepAt maps a click on `+N` to the step nearest the path among those it holds (a Look on `+2` goes back to the newest hidden step: the band step D8 asks for, the whole trail unrolled newest first, is not built), wordOf names a place by the shortest end of its path no other step's file shares (`core/rank.zig:2` beside `/rank.zig:12`; the same file at two lines keeps its basename), Trail.walked is the newest list or search back step (what Pick.walkList and the prompts' n walk) and draw.paintPaneTag underlines it in the box's ink (`// P2: the key role`), the fold's `+N` drawn in the forward steps' dim ink; tagline.folded is how many back steps stay whole: three, fewer down to the newest one while the walk's cells would make the tag at rest take more rows than it takes with no walk (the tag's cells, not its wrap: one line), which nameAt, forwardSpan, trailAt, onName, restPath and Prompt.unlit read (Trail.folded's constant `shown_steps` until now); seed 109 of ninep's random placements is NOT fixed by it (tried with the test under the walk: column 2 under its minimums at step 36, the newest step alone still adds a row in a column with no rows to give), so that test keeps `Jumps new-pane`; TEST FIRST: Trail.zig "a trail keeps its newest three back steps whole, older ones fold into one dim `+N` after the owner ..." (six steps at 400 columns: `‹@pN › +2 › rank.zig:30 › rank.zig:40 › rank.zig:50 ›`, the `+2` in the dim ink, a click on it back at rank.zig:20; back at the first, `› rank.zig:20 › rank.zig:30 › +3 Keep`; on the parent `· ›` per step: fails), "the walk never adds a row to a tag at rest ..." (a width 35 cells past the bare tag: one row with a `+N` fold; on the parent two rows), "two steps whose files have the same name are told apart ...; the word n walks is underlined"; core-test 1071/1242 (171 skipped); process-test: fsearch and lookrange regenerated and read: fsearch's landed/n/N reader tag `‹@p1 › +1 › /MARK/ 2/3 › …/g.txt Keep ...` (its two rows at rest: the newest alone still wraps there, g.txt:1 folded), lookrange's hit1/hit2/back style rows underline `/NEEDLE/ 2/2` (cols 2-13), the word n walks; a user saw the body move a row at a jump 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 | 4 +- core/Trail.zig | 192 +++++++++++++++++++++++++++++++++------- core/draw.zig | 35 ++++++-- core/tagline.zig | 53 ++++++++--- test/snapshots/fsearch.golden | 8 +- test/snapshots/lookrange.golden | 4 +- 6 files changed, 236 insertions(+), 60 deletions(-) (limited to 'core/draw.zig') diff --git a/core/Prompt.zig b/core/Prompt.zig index 27b59649..c3d9959a 100644 --- a/core/Prompt.zig +++ b/core/Prompt.zig @@ -811,9 +811,9 @@ pub fn execWord(p: *Pardes, id: usize) void { pub fn unlit(p: *const Pardes, pane: *Pane) ?[2]usize { if (Trail.outOfRest(p, pane)) return null; const t = &pane.trail; - const whole = Trail.shown_steps; + const whole = pardes.tagline.folded(p, pane); for (t.steps[0..t.cur], 0..) |*step, i| if (step.* == .search) { - if (lights(pane, &step.search) or t.cur - i > whole) return null; + if (lights(pane, &step.search) or t.isFolded(i, whole)) return null; return t.spanOf(i, whole); }; return null; diff --git a/core/Trail.zig b/core/Trail.zig index 58a72256..e22a58b6 100644 --- a/core/Trail.zig +++ b/core/Trail.zig @@ -318,18 +318,36 @@ pub fn walkBy(p: *Pardes, id: usize, delta: i32) bool { pub const Part = enum { back, forward, newest }; /// Step `i`'s word: `‹@p3`, `rank.zig:14`, a list's, search's or recipe's -/// own text; `·` when it is folded. -fn wordOf(t: *const Trail, i: usize, whole: usize, buf: *[max_text + 16]u8) []const u8 { - const s = &t.steps[i]; - if (s.* != .owner and i < t.cur and t.cur - i > whole) return "·"; +/// own text. A place's file is named by its basename, or where another +/// step's file has the same one, by the shortest end of its path the other +/// does not share (UX D8: `core/x.zig:3` beside `dev/x.zig:9`). +fn wordOf(t: *const Trail, i: usize, buf: *[max_text + 16]u8) []const u8 { // The step itself, not a copy: a word's text is the step's own bytes. - return switch (s.*) { + return switch (t.steps[i]) { .owner => |serial| std.fmt.bufPrint(buf, "‹" ++ config.pane_addr ++ "{d}", .{serial}) catch unreachable, // a u32 fits - .place => |at| std.fmt.bufPrint(buf, "{s}:{d}", .{ std.Io.Dir.path.basename(at.path.slice()), at.line }) catch unreachable, // a basename and a u32 fit + .place => |*at| place: { + const path = at.path.slice(); + var from = if (std.mem.lastIndexOfScalar(u8, path, '/')) |slash| slash + 1 else 0; + while (from > 0 and shared(t, i, path[from..])) from = if (std.mem.lastIndexOfScalar(u8, path[0 .. from - 1], '/')) |slash| slash + 1 else 0; + break :place std.fmt.bufPrint(buf, "{s}:{d}", .{ path[from..], at.line }) catch unreachable; // a path and a u32 fit + }, .list, .search, .recipe => |*w| w.text.slice(), }; } +/// Whether another step's file, not step `i`'s, has a path ending in `end` +/// at a `/`. +fn shared(t: *const Trail, i: usize, end: []const u8) bool { + const own = t.steps[i].place.path.slice(); + for (t.steps[0..t.n], 0..) |*s, j| { + if (j == i or s.* != .place) continue; + const path = s.place.path.slice(); + if (std.mem.eql(u8, path, own) or !std.mem.endsWith(u8, path, end)) continue; + if (path.len == end.len or path[path.len - end.len - 1] == '/') return true; + } + return false; +} + const sep = " › "; /// The steps a part writes. @@ -340,20 +358,36 @@ fn range(t: *const Trail, part: Part) [2]usize { }; } -/// Whether step `i` is in what `part` writes: out of rest the owner and -/// the newest back step only. -fn writes(t: *const Trail, part: Part, i: usize) bool { - return part != .newest or t.steps[i] == .owner or i + 1 == t.cur; +/// The forward steps written whole after the path at rest; the rest fold. +pub const shown_ahead = 2; + +/// Steps [lo, hi) of `part` folded into one dim `+N` word where the first +/// of them is (UX D8): at rest the back steps older than the newest +/// `whole` (never the owner), the forward steps past `shown_ahead`. +fn foldOf(t: *const Trail, part: Part, whole: usize) [2]usize { + return switch (part) { + .back => back: { + const lo: usize = @intFromBool(t.cur > 0 and t.steps[0] == .owner); + break :back .{ lo, @max(lo, t.cur -| whole) }; + }, + .forward => .{ @min(t.n, t.cur + 1 + shown_ahead), t.n }, + .newest => .{ 0, 0 }, + }; } /// The cells of the newest step's word out of rest: a longer one is cut /// in its middle (UX D1: `Find pick…3/6`). const newest_cells = 24; -/// Step `i`'s word as `part` writes it: out of rest a word longer than -/// `newest_cells` keeps its first and last cells around a `…`. -fn shownWord(t: *const Trail, part: Part, i: usize, whole: usize, buf: *[max_text + 16]u8, cut: *[max_text + 16]u8) []const u8 { - const word = wordOf(t, i, whole, buf); +/// Step `i`'s word as `part` writes it, null where it writes none: a +/// folded step's is the fold's `+N` on its first, none on the others; out +/// of rest the owner's and the newest step's alone, a word longer than +/// `newest_cells` keeping its first and last cells around a `…`. +fn wordIn(t: *const Trail, part: Part, whole: usize, i: usize, buf: *[max_text + 16]u8, cut: *[max_text + 16]u8) ?[]const u8 { + if (part == .newest and t.steps[i] != .owner and i + 1 != t.cur) return null; + const fold = foldOf(t, part, whole); + if (i >= fold[0] and i < fold[1]) return if (i == fold[0]) std.fmt.bufPrint(buf, "+{d}", .{fold[1] - fold[0]}) catch unreachable else null; + const word = wordOf(t, i, buf); if (part != .newest or word.len <= newest_cells) return word; const tab = 8; // a step's word holds no tab if (panes.File.displayWidth(tab, word) <= newest_cells) return word; @@ -364,15 +398,16 @@ fn shownWord(t: *const Trail, part: Part, i: usize, whole: usize, buf: *[max_tex } /// The back steps' words, each with the separator after it (before the -/// path), or the forward steps', each with one before it (after the path): -/// the newest `whole` back steps whole, older ones `·` (`folded`). +/// path), or the forward steps', each with one before it (after the path), +/// the folded ones as one `+N` (`foldOf`); out of rest (`newest`) the +/// owner's and the newest's. pub fn write(t: *const Trail, part: Part, whole: usize, w: *std.Io.Writer) std.Io.Writer.Error!void { var buf: [max_text + 16]u8 = undefined; var cut: [max_text + 16]u8 = undefined; const r = range(t, part); - for (r[0]..r[1]) |i| if (writes(t, part, i)) switch (part) { - .back, .newest => try w.print("{s}" ++ sep, .{shownWord(t, part, i, whole, &buf, &cut)}), - .forward => try w.print(sep ++ "{s}", .{wordOf(t, i, whole, &buf)}), + for (r[0]..r[1]) |i| if (wordIn(t, part, whole, i, &buf, &cut)) |word| switch (part) { + .back, .newest => try w.print("{s}" ++ sep, .{word}), + .forward => try w.print(sep ++ "{s}", .{word}), }; } @@ -382,12 +417,23 @@ pub fn bytes(t: *const Trail, part: Part, whole: usize) usize { var cut: [max_text + 16]u8 = undefined; var n: usize = 0; const r = range(t, part); - for (r[0]..r[1]) |i| if (writes(t, part, i)) { - n += shownWord(t, part, i, whole, &buf, &cut).len + sep.len; + for (r[0]..r[1]) |i| if (wordIn(t, part, whole, i, &buf, &cut)) |word| { + n += word.len + sep.len; }; return n; } +/// The back step `n` and N walk (Pick.walkList, Prompt): the newest list +/// or search; its word is underlined (UX D8). +pub fn walked(t: *const Trail) ?u8 { + var i: usize = t.cur; + while (i > 0) { + i -= 1; + if (t.steps[i] == .list or t.steps[i] == .search) return @intCast(i); + } + return null; +} + /// Whether pane `pane`'s tag is out of rest in the live view (UX D1: its /// path, its forward steps and its own words hidden, the owner and the /// newest step before the head). Asking is rest. @@ -396,13 +442,26 @@ pub fn outOfRest(p: *const Pardes, pane: *const Pane) bool { return p.panes[host] == pane; } -/// Where back step `i`'s word is in what `write` writes for the back -/// steps, the newest `whole` whole. +/// Where back step `i`'s word (the fold's `+N` for a folded one) is in +/// what `write` writes for the back steps, the newest `whole` whole. pub fn spanOf(t: *const Trail, i: usize, whole: usize) [2]usize { var buf: [max_text + 16]u8 = undefined; + var cut: [max_text + 16]u8 = undefined; var x: usize = 0; - for (0..i) |j| x += wordOf(t, j, whole, &buf).len + sep.len; - return .{ x, x + wordOf(t, i, whole, &buf).len }; + for (0..i) |j| if (wordIn(t, .back, whole, j, &buf, &cut)) |word| { + x += word.len + sep.len; + }; + const fold = foldOf(t, .back, whole); + const at = if (i >= fold[0] and i < fold[1]) fold[0] else i; + if (at < i) return spanOf(t, at, whole); + const word: []const u8 = wordIn(t, .back, whole, i, &buf, &cut) orelse ""; + return .{ x, x + word.len }; +} + +/// Whether back step `i` is in the fold's `+N`. +pub fn isFolded(t: *const Trail, i: usize, whole: usize) bool { + const fold = foldOf(t, .back, whole); + return i >= fold[0] and i < fold[1]; } /// The step whose word in `part` is at byte `off` of what `write` wrote @@ -412,12 +471,13 @@ pub fn stepAt(t: *const Trail, part: Part, whole: usize, off: usize) ?u8 { var cut: [max_text + 16]u8 = undefined; var x: usize = 0; const r = range(t, part); + const fold = foldOf(t, part, whole); for (r[0]..r[1]) |i| { - if (!writes(t, part, i)) continue; + const word = wordIn(t, part, whole, i, &buf, &cut) orelse continue; if (part == .forward) x += sep.len; - const n = shownWord(t, part, i, whole, &buf, &cut).len; - if (off >= x and off < x + n) return @intCast(i); - x += n; + // A fold's `+N` is the step nearest the path of those it holds. + if (off >= x and off < x + word.len) return @intCast(if (i == fold[0] and fold[0] < fold[1]) (if (part == .back) fold[1] - 1 else fold[0]) else i); + x += word.len; if (part != .forward) x += sep.len; } return null; @@ -761,19 +821,85 @@ test "the walk drawn with a picker's list and the notice row (walk UI G 2e, SPEC try std.testing.expect(std.mem.indexOf(u8, try tagOf(p, p.panes[rd].?), "› Refs 2/2 ›") != null); } -test "a trail keeps its newest three back steps whole, older ones fold to ·, and a click on a · goes back to its step" { +test "a trail keeps its newest three back steps whole, older ones fold into one dim `+N` after the owner, and a click on it goes back to the newest of them; forward steps past two fold the same way" { var f: Fixture = .{ .p = undefined, .tmp = undefined }; try f.init(60); defer f.deinit(); const p = f.p; const owner = p.panes[f.held].?.serial; - for ([_]usize{ 10, 20, 30, 40, 50 }) |line| f.look(f.held, "rank.zig", line); + for ([_]usize{ 10, 20, 30, 40, 50, 60 }) |line| f.look(f.held, "rank.zig", line); const r = p.view().active; + const pane = p.panes[r].?; + // Wide enough for the three newest whole on its one row. + p.update(.{ .resize = .{ .cols = 400, .rows = 60 } }); var buf: [4096 + 128]u8 = undefined; var at: [64]u8 = undefined; - try std.testing.expect(std.mem.startsWith(u8, try tagOf(p, p.panes[r].?), try std.fmt.bufPrint(&buf, "‹@p{d} › · › rank.zig:20 › rank.zig:30 › rank.zig:40 › {s}/rank.zig Keep ", .{ owner, f.dir }))); - try clickTag(p, r, "·", .right); + try std.testing.expect(std.mem.startsWith(u8, try tagOf(p, pane), try std.fmt.bufPrint(&buf, "‹@p{d} › +2 › rank.zig:30 › rank.zig:40 › rank.zig:50 › {s}/rank.zig Keep ", .{ owner, f.dir }))); + var arena: std.heap.ArenaAllocator = .init(std.testing.allocator); + defer arena.deinit(); + const s = try p.render(arena.allocator()); + const fold = try tagCell(p, r, "+2"); + try std.testing.expectEqual(pardes.Color{ .rgb = p.chromeTheme().lineno }, s.at(fold[0], fold[1]).style.fg); + try clickTag(p, r, "+2", .right); + try std.testing.expectEqualStrings("rank.zig:20", f.at(&at)); + // Back at the first: five forward steps, the two nearest whole. + try clickTag(p, r, "rank.zig:10", .right); try std.testing.expectEqualStrings("rank.zig:10", f.at(&at)); + try std.testing.expect(std.mem.indexOf(u8, try tagOf(p, pane), try std.fmt.bufPrint(&buf, "{s}/rank.zig › rank.zig:20 › rank.zig:30 › +3 Keep ", .{f.dir})) != null); +} + +test "the walk never adds a row to a tag at rest: its steps fold further, down to the newest alone, where they would" { + var f: Fixture = .{ .p = undefined, .tmp = undefined }; + try f.init(60); + defer f.deinit(); + const p = f.p; + f.look(f.held, "rank.zig", 10); + for ([_]usize{ 20, 30, 40, 50, 60, 70 }) |line| { + f.look(p.view().active, "place.zig", line); + f.look(p.view().active, "rank.zig", line); + } + const r = p.view().active; + const pane = p.panes[r].?; + try std.testing.expect(pane.trail.cur > 4); + // A width 35 cells past what the tag takes with no walk: room on its + // row for the owner, a fold and the newest, not for three. + const walk = pane.trail; + pane.trail.n = 0; + pane.trail.cur = 0; + const bare = panes.File.displayWidth(p.settings.tab, try tagOf(p, pane)); + pane.trail = walk; + const extra = p.view().screen_w - pardes.tagline.tagWidth(p, r); + p.update(.{ .resize = .{ .cols = @intCast(bare + 35 + extra), .rows = 60 } }); + p.sync(); + try std.testing.expectEqual(@as(u16, 1), pardes.layout.wantedTagRows(p, r)); + try std.testing.expect(std.mem.indexOf(u8, try tagOf(p, pane), " › +") != null); +} + +test "two steps whose files have the same name are told apart by the shortest path they do not share; the word n walks is underlined" { + var f: Fixture = .{ .p = undefined, .tmp = undefined }; + try f.init(60); + defer f.deinit(); + const p = f.p; + try f.tmp.dir.createDirPath(std.testing.io, "core"); + try f.tmp.dir.writeFile(std.testing.io, .{ .sub_path = "core/rank.zig", .data = "a\nb\nc\n" }); + f.look(f.held, "rank.zig", 12); + f.look(p.view().active, "core/rank.zig", 2); + f.look(p.view().active, "place.zig", 3); + const r = p.view().active; + var buf: [4096 + 128]u8 = undefined; + const tag = try tagOf(p, p.panes[r].?); + try std.testing.expect(std.mem.indexOf(u8, tag, try std.fmt.bufPrint(&buf, " › {s}/rank.zig:12 › core/rank.zig:2 › ", .{std.Io.Dir.path.basename(f.dir)})) != null); + // A list word: the one n walks, underlined. + p.panes[r].?.trail.steps[1] = .{ .list = .{} }; + p.panes[r].?.trail.steps[1].list.text.set("Find x 1/2"); + p.sync(); + var arena: std.heap.ArenaAllocator = .init(std.testing.allocator); + defer arena.deinit(); + const s = try p.render(arena.allocator()); + const word = try tagCell(p, r, "Find x 1/2"); + try std.testing.expect(s.at(word[0], word[1]).style.ul == .single); + const other = try tagCell(p, r, "place.zig"); + try std.testing.expect(s.at(other[0], other[1]).style.ul != .single); } test "Ctrl-o goes back one place in a reader's walk and Ctrl-i forward again; past its first place, or from a held pane, the jump list's" { diff --git a/core/draw.zig b/core/draw.zig index be4230c4..28b9f22d 100644 --- a/core/draw.zig +++ b/core/draw.zig @@ -695,7 +695,7 @@ fn tagTintRange(p: *const Pardes, pane: *const Pane, tag: []const u8, prefix_len } return null; } - var start: usize = tagline.nameAt(pane); + var start: usize = tagline.nameAt(p, pane); const name = if (pane.file) |file| if (pane.prompt == .name) pane.input.own orelse file.path else file.path else if (pane.addon) |k| blk: { @@ -945,7 +945,7 @@ fn joinBand(p: *Pardes, s: *Surface, arena: std.mem.Allocator, pane: *Pane, r: R /// Bytes `lo` to `hi` of a tag's text in `ink`, over whichever of its /// shown rows (`lines`, from shown row `top`, drawn at `x`, `y`, `w` /// wide) they wrapped onto. -fn inkTag(p: *Pardes, s: *Surface, shown: tagline.Shown, lines: []const []const u8, top: usize, x: u16, y: u16, w: u16, lo: usize, hi: usize, ink: [3]u8) void { +fn inkTag(p: *Pardes, s: *Surface, shown: tagline.Shown, lines: []const []const u8, top: usize, x: u16, y: u16, w: u16, lo: usize, hi: usize, ink: [3]u8, under: bool) void { const a = modal.positionAt(shown.text, shown.fromReal(lo)); const b = modal.positionAt(shown.text, shown.fromReal(hi)); var row = @max(a.row, top); @@ -956,8 +956,11 @@ fn inkTag(p: *Pardes, s: *Surface, shown: tagline.Shown, lines: []const []const var col = panes.File.rawDisplayCol(p.settings.tab, line, @min(from, line.len)); const end = panes.File.rawDisplayCol(p.settings.tab, line, @min(to, line.len)); const row_y = y + @as(u16, @intCast(row - top)); - while (col < end and col < w) : (col += 1) - s.at(x + @as(u16, @intCast(col)), row_y).style.fg = .{ .rgb = ink }; + while (col < end and col < w) : (col += 1) { + const style = &s.at(x + @as(u16, @intCast(col)), row_y).style; + style.fg = .{ .rgb = ink }; + if (under) style.ul = .single; + } } } @@ -1014,7 +1017,7 @@ fn paintPaneTag(p: *Pardes, s: *Surface, arena: std.mem.Allocator, pane: *Pane, else if (pane.prompt == .name) caret: { // A drafted name is the prefix: its caret is on row 0 of the tag, // the rows it wrapped onto included. - const at = modal.positionAt(shown.text, shown.fromReal(tagline.nameAt(pane) + @as(usize, @intCast(@max(0, pane.input.cur_col))))); + const at = modal.positionAt(shown.text, shown.fromReal(tagline.nameAt(p, pane) + @as(usize, @intCast(@max(0, pane.input.cur_col))))); if (at.row < top or at.row >= top + rows) break :caret null; break :caret .{ .row = at.row - top, .at = @min(lines[at.row - top].len, at.col) }; } else if (pane.focus == .tag and pane.prompt == .none and head == null) caret: { @@ -1059,12 +1062,26 @@ fn paintPaneTag(p: *Pardes, s: *Surface, arena: std.mem.Allocator, pane: *Pane, // wrapped onto. const first_line = whole[0 .. std.mem.indexOfScalar(u8, whole, '\n') orelse whole.len]; if (tagTintRange(p, pane, first_line, prefix_len)) |name| if (name.lo < name.hi) - inkTag(p, s, shown, lines[0..rows], top, tx, tag_y, tw, name.lo, @min(name.hi, first_line.len), if (active) chrome.tag_active_name_fg else chrome.tag_name_fg); - // A walk's forward steps, after the name, dimmed (Trail.zig). + inkTag(p, s, shown, lines[0..rows], top, tx, tag_y, tw, name.lo, @min(name.hi, first_line.len), if (active) chrome.tag_active_name_fg else chrome.tag_name_fg, false); + // A walk's forward steps, after the name, dimmed (Trail.zig); its fold + // `+N` too; the word n walks underlined in the key ink (UX D8). const ahead = tagline.forwardSpan(p, pane); - if (ahead[0] < ahead[1]) inkTag(p, s, shown, lines[0..rows], top, tx, tag_y, tw, ahead[0], @min(ahead[1], first_line.len), chrome.lineno); + if (ahead[0] < ahead[1]) inkTag(p, s, shown, lines[0..rows], top, tx, tag_y, tw, ahead[0], @min(ahead[1], first_line.len), chrome.lineno, false); + if (pane.file != null and pane.trail.n > 0 and !pardes.Trail.outOfRest(p, pane)) { + const kept = tagline.folded(p, pane); + const t = &pane.trail; + const first: usize = @intFromBool(t.steps[0] == .owner); + if (t.isFolded(first, kept)) { + const fold = t.spanOf(first, kept); + inkTag(p, s, shown, lines[0..rows], top, tx, tag_y, tw, fold[0], @min(fold[1], first_line.len), chrome.lineno, false); + } + if (t.walked()) |i| if (!t.isFolded(i, kept)) { + const word = t.spanOf(i, kept); + inkTag(p, s, shown, lines[0..rows], top, tx, tag_y, tw, word[0], @min(word[1], first_line.len), chrome.box, true); // P2: the key role + }; + } // A search word its places no longer light, dimmed (Prompt.zig). - if (pardes.Prompt.unlit(p, pane)) |span| inkTag(p, s, shown, lines[0..rows], top, tx, tag_y, tw, span[0], @min(span[1], first_line.len), chrome.lineno); + if (pardes.Prompt.unlit(p, pane)) |span| inkTag(p, s, shown, lines[0..rows], top, tx, tag_y, tw, span[0], @min(span[1], first_line.len), chrome.lineno, false); // The head's keys in the key ink, its dimmed, underlined and struck // words (TagState.Span), over whichever rows they wrapped onto. if (head) |h| for (h.spans) |span| { diff --git a/core/tagline.zig b/core/tagline.zig index 3256f824..5f7222e6 100644 --- a/core/tagline.zig +++ b/core/tagline.zig @@ -179,7 +179,7 @@ fn restPath(p: *const Pardes, arena: std.mem.Allocator, pane: *Pane) ![]const u8 // Its walk's back steps before the name, its forward steps after // it (Trail.zig), in the room `bytes` measures them. const keep_word = if (keep) " Keep" else ""; - const whole = pardes.Trail.shown_steps; + const whole = folded(p, pane); const room = try arena.alloc(u8, pane.trail.bytes(.back, whole) + name.len + pane.trail.bytes(.forward, whole) + keep_word.len); var w: std.Io.Writer = .fixed(room); pane.trail.write(.back, whole, &w) catch return error.OutOfMemory; @@ -200,15 +200,48 @@ fn restPath(p: *const Pardes, arena: std.mem.Allocator, pane: *Pane) ![]const u8 } /// Where a file's name starts in its tag: after its walk's back steps. -pub fn nameAt(pane: *const Pane) usize { - return if (pane.file != null and pane.trail.n > 0) pane.trail.bytes(.back, pardes.Trail.shown_steps) else 0; +pub fn nameAt(p: *const Pardes, pane: *const Pane) usize { + return if (pane.file != null and pane.trail.n > 0) pane.trail.bytes(.back, folded(p, pane)) else 0; +} + +/// The back steps a file's tag writes whole at rest (UX D8): the newest +/// three (Trail.shown_steps), fewer, down to the newest alone, while its +/// walk would make the tag take more rows than it takes with none: the +/// walk never adds a row to a tag at rest (as far as the newest alone +/// lets it). +pub fn folded(p: *const Pardes, pane: *const Pane) usize { + const t = &pane.trail; + const f = pane.file orelse return pardes.Trail.shown_steps; + if (t.n == 0) return pardes.Trail.shown_steps; + const id = panes.paneIdOf(p, pane) orelse return pardes.Trail.shown_steps; + const tab = p.settings.tab; + const width = tagWidth(p, id); + const name = if (pane.prompt == .name) pane.input.own orelse f.path else f.path; + const bare = panes.File.displayWidth(tab, name) + @as(usize, if (pardes.Trail.reading(p, pane)) " Keep".len else 0) + panes.File.displayWidth(tab, curTail(pane)); + var whole: usize = pardes.Trail.shown_steps; + while (whole > 1 and rowsOf(bare + walkCells(t, whole, tab), width) > rowsOf(bare, width)) whole -= 1; + return whole; +} + +/// The cells a walk's words take at rest with its newest `whole` back +/// steps whole. +fn walkCells(t: *const pardes.Trail, whole: usize, tab: u16) usize { + var room: [pardes.Trail.max_steps * (pardes.Trail.max_text + 32)]u8 = undefined; + var w: std.Io.Writer = .fixed(&room); + t.write(.back, whole, &w) catch {}; + t.write(.forward, whole, &w) catch {}; + return panes.File.displayWidth(tab, w.buffered()); +} + +fn rowsOf(cells: usize, width: usize) usize { + return @max(1, (cells + width - 1) / width); } /// The bytes of a file's tag its walk's forward steps take, after its name. pub fn forwardSpan(p: *const Pardes, pane: *const Pane) [2]usize { const f = pane.file orelse return .{ 0, 0 }; if (pane.trail.n == 0 or pardes.Trail.outOfRest(p, pane)) return .{ 0, 0 }; - const whole = pardes.Trail.shown_steps; + const whole = folded(p, pane); const name = if (pane.prompt == .name) pane.input.own orelse f.path else f.path; const lo = pane.trail.bytes(.back, whole) + name.len; return .{ lo, lo + pane.trail.bytes(.forward, whole) }; @@ -219,9 +252,9 @@ pub fn forwardSpan(p: *const Pardes, pane: *const Pane) [2]usize { pub fn trailAt(p: *const Pardes, pane: *const Pane, at: usize) ?u8 { if (pane.trail.n == 0 or pane.file == null) return null; if (pardes.Trail.outOfRest(p, pane)) return pane.trail.stepAt(.newest, 1, at); - const whole = pardes.Trail.shown_steps; + const whole = folded(p, pane); const ahead = forwardSpan(p, pane); - if (at < nameAt(pane)) return pane.trail.stepAt(.back, whole, at); + if (at < nameAt(p, pane)) return pane.trail.stepAt(.back, whole, at); if (at >= ahead[0] and at < ahead[1]) return pane.trail.stepAt(.forward, whole, at - ahead[0]); return null; } @@ -268,7 +301,7 @@ pub fn restPrefix(p: *const Pardes, arena: std.mem.Allocator, pane: *Pane) ![]u8 /// The tag's own text: what the user made of it, or until then the /// default a pane of its kind starts with. -pub fn curTail(pane: *Pane) []const u8 { +pub fn curTail(pane: *const Pane) []const u8 { return pane.tag.own orelse defaultTail(pane); } @@ -444,7 +477,7 @@ pub fn onName(p: *const Pardes, pane: *Pane, row: usize, col: usize) ?usize { const name = if (pane.prompt == .name) pane.input.own orelse f.path else f.path; var room: [pardes.Trail.max_steps * (pardes.Trail.max_text + 32)]u8 = undefined; var w: std.Io.Writer = .fixed(&room); - pane.trail.write(.back, pardes.Trail.shown_steps, &w) catch return null; + pane.trail.write(.back, folded(p, pane), &w) catch return null; const lead = panes.File.displayWidth(tab, w.buffered()); if (col < lead or col >= lead + panes.File.displayWidth(tab, name)) return null; return col - lead; @@ -459,8 +492,8 @@ pub fn typedIntoName(p: *Pardes, pane: *Pane, key: pardes.Key) bool { if (!panes.Output.fileTraits(f.output).saves or pane.tag.cur_row != 0) return false; // The name starts after its walk's words. const col: usize = @intCast(@max(0, pane.tag.cur_col)); - if (col < nameAt(pane)) return false; - const at = col - nameAt(pane); + if (col < nameAt(p, pane)) return false; + const at = col - nameAt(p, pane); const back = key.cp == pardes.Key.backspace or pardes.hit(key, config.insert_backspace_alias); const forward = key.cp == pardes.Key.delete or pardes.hit(key, config.insert_delete_alias); const typed = key.text.len > 0 and !key.ctrl and !key.alt; diff --git a/test/snapshots/fsearch.golden b/test/snapshots/fsearch.golden index 59037755..627fb21c 100644 --- a/test/snapshots/fsearch.golden +++ b/test/snapshots/fsearch.golden @@ -97,8 +97,8 @@ |28: 8 l8 |29: 9 l9 == snap landed grid=180x31 cursor=97,22 -|16: /tmp/pardes-snap/fsearch/cwd Term+bash Save Mode Filter Collapse Del ‹@p1 › g.txt:1 › /MARK/ 2/3 › /tmp/pardes-snap/fsearch/cwd/g.txt Keep Save Term Collapse -|17: ls Follow Del +|16: /tmp/pardes-snap/fsearch/cwd Term+bash Save Mode Filter Collapse Del ‹@p1 › +1 › /MARK/ 2/3 › /tmp/pardes-snap/fsearch/cwd/g.txt Keep Save Term Collapse Foll +|17: ls ow Del |18: g.txt 2 MARK a |19: 3 l3 |20: 4 l4 @@ -112,7 +112,7 @@ |28: 12 l12 |29: == snap n grid=180x31 cursor=97,27 -|16: /tmp/pardes-snap/fsearch/cwd Term+bash Save Mode Filter Collapse Del ‹@p1 › g.txt:1 › /MARK/ 3/3 › /tmp/pardes-snap/fsearch/cwd/g.txt Keep Save Term Collapse +|16: /tmp/pardes-snap/fsearch/cwd Term+bash Save Mode Filter Collapse Del ‹@p1 › +1 › /MARK/ 3/3 › /tmp/pardes-snap/fsearch/cwd/g.txt Keep Save Term Collapse Foll |18: g.txt 1 l1 |19: 2 MARK a |20: 3 l3 @@ -126,7 +126,7 @@ |28: 11 l11 |29: 12 l12 == snap N grid=180x31 cursor=97,23 -|16: /tmp/pardes-snap/fsearch/cwd Term+bash Save Mode Filter Collapse Del ‹@p1 › g.txt:1 › /MARK/ 2/3 › /tmp/pardes-snap/fsearch/cwd/g.txt Keep Save Term Collapse +|16: /tmp/pardes-snap/fsearch/cwd Term+bash Save Mode Filter Collapse Del ‹@p1 › +1 › /MARK/ 2/3 › /tmp/pardes-snap/fsearch/cwd/g.txt Keep Save Term Collapse Foll == snap cancel grid=180x31 cursor=97,23 == snap nomatch grid=180x31 cursor=118,16 |16: /tmp/pardes-snap/fsearch/cwd Term+bash Save Mode Filter Collapse Del ^ ‹@p1 › /MARK/ 2/3 › / zzqq = Look /zzqq/ 0 ⏎ land · M-⏎ as a list · C-r history · esc diff --git a/test/snapshots/lookrange.golden b/test/snapshots/lookrange.golden index a0cbd3be..1ea85a6e 100644 --- a/test/snapshots/lookrange.golden +++ b/test/snapshots/lookrange.golden @@ -100,7 +100,7 @@ |7: /NEEDLE/ 2/2 › /tmp/pardes-snap/lookrange/cwd/r.txt Save Term Collapse Follow Del |30: /tmp/pardes-snap/lookrange/cwd/r.txt:8 == style hit1 grid=150x31 -|7: 0-1 d,#add38a, 2-47 #becfc4,#314738, 48-53 #dfbce5,#314738, 54-149 #becfc4,#314738, +|7: 0-1 d,#add38a, 2-13 #add38a,#314738,u 14-14 #add38a,#314738, 15-47 #becfc4,#314738, 48-53 #dfbce5,#314738, 54-149 #becfc4,#314738, |14: 0-0 d,#608269, 1-4 d,#0d1410, 5-6 #59675c,#0d1410, 7-9 #e5eee5,#0d1410, 10-15 #e5eee5,#352e19, 16-149 #e5eee5,#0d1410, |15: 0-0 d,#608269, 1-1 d,#0d1410, 2-4 d,#0d1410,b 5-6 #616f64,#0d1410,b 7-11 #e5eee5,#0d1410, 12-17 #f5f7ee,#3c614a, 18-149 #f5f7ee,#0d1410, |16: 0-0 d,#608269, 1-4 d,#0d1410, 5-6 #59675c,#0d1410, 7-149 #e5eee5,#0d1410, @@ -110,7 +110,7 @@ |7: /NEEDLE/ 1/2 ↻ › /tmp/pardes-snap/lookrange/cwd/r.txt Save Term Collapse Follow Del |30: · /tmp/pardes-snap/lookrange/cwd/r.txt /NEEDLE/ 1/2 ↻ · line 7 1 message · SPC h m == style hit2 grid=150x31 -|7: 0-1 d,#add38a, 2-49 #becfc4,#314738, 50-55 #dfbce5,#314738, 56-149 #becfc4,#314738, +|7: 0-1 d,#add38a, 2-15 #add38a,#314738,u 16-16 #add38a,#314738, 17-49 #becfc4,#314738, 50-55 #dfbce5,#314738, 56-149 #becfc4,#314738, |14: 0-0 d,#608269, 1-1 d,#0d1410, 2-4 d,#0d1410,b 5-6 #616f64,#0d1410,b 7-9 #e5eee5,#0d1410, 10-15 #f5f7ee,#3c614a, 16-16 #f5f7ee,#0d1410, 17-149 #e5eee5,#0d1410, |15: 0-0 d,#608269, 1-4 d,#0d1410, 5-6 #59675c,#0d1410, 7-11 #e5eee5,#0d1410, 12-17 #e5eee5,#352e19, 18-149 #e5eee5,#0d1410, |22: 0-0 d,#e5eee5, 1-149 d,#0d1410, -- cgit v1.3 From eb8ecb8a451ae32d590c42755614b801f9cc0c09 Mon Sep 17 00:00:00 2001 From: Gabriel Schneider Date: Wed, 25 Nov 2026 07:03:02 -0300 Subject: views, dump, draw: a load makes each view's band rows again from its own tag state, and the tag's own rows are held to MAX_TAG_ROWS where the frame reads them (the coordinator's item from P3's soak: `index out of bounds: index 15, len 8` at draw.zig paintPaneTag, `for (lines[0..rows])`, from views.drawOne in a replica client's draw after a divergence); RUN FIRST: views.zig's new test on the parent, its band-rows check left out: `panic: index out of bounds: index 12, len 8` at draw.zig:1007 paintPaneTag, from joinPaneTag, renderPane, render, drawOne: the same fault; THE CAUSE: a tag's `tag_rows` counts its band's rows (Core.sync: the band unrolled under its text pushes the body down) and is dumped and in the digest, while `band_rows` is derived (views.PaneView and Pane: never dumped, made again at every sync); a load (a join's dump, a replica's rollback) zeroed `band_rows` and kept `tag_rows`, so a view drawn before its next step (drawOne: a replica client's own view, a pump's other views; no sync there) read the tag's own rows as `tag_rows - band_rows` = the band's too, 12 to 19, and indexed paintPaneTag's `[MAX_TAG_ROWS]` array past its 8; THE FIX: views.bandsLoaded (from dump.afterLoad, after TagState.loaded) makes each open view's `band_rows` again within that view from its own state as its sync does (`Band.takes`, 0 for a folded pane and Band.over's), into the pane's live field and the view's share (derived: the digest is unchanged, as the test checks); draw.joinPaneTag and paintPaneTag hold the tag's own rows to MAX_TAG_ROWS (`-|` and `@min`): production code never panics on a stale pair; TEST: views.zig "a view not live with its band open, dumped and loaded, draws before its next step: its band's rows made again from its state, its tag's rows never past MAX_TAG_ROWS" (SPC Down in view 0, another view live, byteDump, load: the digest equal, view 0's share's band rows 11 again (0 on the parent), drawOne draws it; with its band rows zeroed by hand drawOne draws it too); a user's client could abort on a join or a rollback while another view had a band open; core-test 1073/1244 (171 skipped) Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_016Y9MNBFhdevVu48bvL9kCE --- core/draw.zig | 7 ++++--- core/dump.zig | 1 + core/views.zig | 48 ++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 53 insertions(+), 3 deletions(-) (limited to 'core/draw.zig') diff --git a/core/draw.zig b/core/draw.zig index 28b9f22d..2ef72f0e 100644 --- a/core/draw.zig +++ b/core/draw.zig @@ -822,8 +822,9 @@ fn joinPaneTag(p: *Pardes, s: *Surface, arena: std.mem.Allocator, pane: *Pane, r const chrome = p.chromeTheme(); const region = s.region(.tag, id).?; const tag = (try tagline.shownTag(p, arena, pane)).text; - // The tag's text rows; the band's under them are its own layer. - const rows = pane.tag_rows - pane.band_rows; + // The tag's text rows; the band's under them are its own layer. A + // tag's own are MAX_TAG_ROWS at most (Pardes.sync). + const rows = @min(pane.tag_rows -| pane.band_rows, MAX_TAG_ROWS); // As wide as the widest row it shows, and never narrower than its // viewport. var widest: usize = 0; @@ -978,7 +979,7 @@ fn paintPaneTag(p: *Pardes, s: *Surface, arena: std.mem.Allocator, pane: *Pane, const tx = r.x + @min(TAG_TEXT_INSET, r.w); const tw = r.w -| TAG_TEXT_INSET; const tag_y = p.tagTop(pane, r); - const rows = pane.tag_rows - pane.band_rows; + const rows = @min(pane.tag_rows -| pane.band_rows, MAX_TAG_ROWS); const page_rgb = th.bg orelse th.tag_bg; // Focus is visible along the tag without changing its live text grid. const tag_bg = tagGround(p, pane, active); diff --git a/core/dump.zig b/core/dump.zig index 2dde9c8c..c0403c06 100644 --- a/core/dump.zig +++ b/core/dump.zig @@ -149,6 +149,7 @@ fn afterLoad(p: *Pardes) void { }; @import("jj.zig").loaded(p); pardes.TagState.loaded(p); + pardes.views.bandsLoaded(p); } /// A file kept slim in a dump (`dumpExit`, a closed pane's past its bound, diff --git a/core/views.zig b/core/views.zig index b05a116b..7bf30aa0 100644 --- a/core/views.zig +++ b/core/views.zig @@ -171,6 +171,24 @@ pub fn undumped(p: *Pardes, others: []const Shares) void { } } +/// After a load: each view's band rows (derived: never dumped nor in the +/// digest) made again from its own tag state as its last sync made them. +/// Its tag rows, which are dumped, count them, and a view drawn before its +/// next step (drawOne: a replica client's, a pump's other views) reads the +/// tag's own rows as their difference (draw.zig): with the band's rows +/// zeroed by the load, a band's became the tag's, past MAX_TAG_ROWS. +pub fn bandsLoaded(p: *Pardes) void { + for (0..max) |k| if (isOpen(p, @intCast(k))) within(p, @intCast(k), {}, bandsOf) catch {}; +} + +fn bandsOf(_: void, p: *Pardes) anyerror!void { + for (p.panes, 0..) |slot, id| if (slot) |pane| { + const rows = if (pane.collapsed or pardes.Band.over(pane)) 0 else @min(pardes.Band.takes(p, id), pane.tag_rows -| 1); + pane.band_rows = rows; + pane.pv[p.live].band_rows = rows; + }; +} + /// The views a dump before `Pardes.views` kept (`OldDumped`): each its /// share of the session into `views[k]`, the rest as `undumped`. What /// each view holds is the session's then; one refused is freed. @@ -581,6 +599,36 @@ pub fn within(p: *Pardes, k: u8, ctx: anytype, comptime f: fn (@TypeOf(ctx), *Pa const testing = std.testing; const Key = pardes.Key; +test "a view not live with its band open, dumped and loaded, draws before its next step: its band's rows made again from its state, its tag's rows never past MAX_TAG_ROWS" { + const gpa = std.testing.allocator; + const dump = @import("dump.zig"); + const p = try Pardes.init(gpa, .{ .tty_only = true, .cols = 80, .rows = 30 }); + defer p.deinit(); + const pane = try p.setTestFile("one\n"); + // SPC's level unrolled in view 0: its band's rows in the tag's. + p.update(.{ .key = .{ .cp = ' ' } }); + p.update(.{ .key = .{ .cp = Key.down } }); + p.sync(); + const band = pane.band_rows; + try testing.expect(band > 0 and pane.tag_rows - band <= pardes.MAX_TAG_ROWS and pane.tag_rows > pardes.MAX_TAG_ROWS); + // Another view live, view 0 parked, as a client's is when a join's + // (a replica's rollback's) dump is made. + const k = p.openView().?; + p.toView(k); + const bytes = try dump.byteDump(p); + defer gpa.free(bytes); + const q = try dump.load(gpa, .{ .tty_only = true, .cols = 80, .rows = 30 }, bytes, null); + defer q.deinit(); + try testing.expectEqual(pardes.walk.digest(Pardes, p), pardes.walk.digest(Pardes, q)); + // View 0 drawn with no step first (a client's draw, a pump's other + // views): its band as it was, the tag's own rows under the bound. + try testing.expectEqual(band, q.panes[0].?.pv[0].band_rows); + _ = try drawOne(q, 0, .{ .ctx = null, .f = null }); + // The bound itself: a share whose band's rows are not counted. + q.panes[0].?.pv[0].band_rows = 0; + _ = try drawOne(q, 0, .{ .ctx = null, .f = null }); +} + fn typeKeys(p: *Pardes, text: []const u8) void { for (text) |c| p.update(.{ .key = .{ .cp = c, .text = &[_]u8{c} } }); } -- cgit v1.3