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/Core.zig | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'core/Core.zig') diff --git a/core/Core.zig b/core/Core.zig index 2c04cc64..e43f9e83 100644 --- a/core/Core.zig +++ b/core/Core.zig @@ -2010,7 +2010,10 @@ pub fn sync(p: *Pardes) void { var wrap_fba = std.heap.FixedBufferAllocator.init(&wrap_room); const wa = wrap_fba.allocator(); const prefix: ?[]const u8 = tagline.prefixIn(p, wa, pane) catch null; - const lead = if (prefix) |made| made.len else pane.tag_lead; + // The tag's cursor and selections are offsets in its text at rest: + // a head shown over its own text moves none of them (UX D1). + const at_rest = if (pardes.Trail.outOfRest(p, pane)) tagline.restPrefix(p, wa, pane) catch null else prefix; + const lead = if (at_rest) |made| made.len else pane.tag_lead; if (lead != pane.tag_lead) { const t = &pane.tag; const old: i32 = @intCast(pane.tag_lead); -- 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/Core.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 ea9a19700cc1c0bc22c08b1d31d7a62e5853b802 Mon Sep 17 00:00:00 2001 From: Gabriel Schneider Date: Wed, 25 Nov 2026 06:20:03 -0300 Subject: Pick, layout, Core, Band: the band's height: a picker's from its list at open, four rows at least, 40 % of its column at most, never moved by typing; the body keeps 60 % of its pane and six rows, borrowed from its column, and the band gives way before the body drops under six (walk UI polish P1, UX DESIGN.md D6, C8): a picker's band was as tall as its list (three hits, three rows; no cap), so a short list's band was a sliver and a long one took a short pane's body down to four rows (shot 04-L: four body rows of 18); now Pick.bandRows is min(11, max(4, what the source has), 40 % of the rows of the host's column: its panes' rows, which a borrow only moves between them, so the height never changes while typing), the rows fewer than it leaving the band's ground (and its spines) under them; layout.floorRows keeps a band's pane its band and a body of one and a half times what is above it (60 % of the pane) and six rows at least (Band.body_rows), borrowed from the column's other panes as before; Core.sync's band takes what leaves the body six rows, so a column too short for 60 % shrinks the band, never the body under six; TEST FIRST: Pick.zig "a picker's band is sized from its list at open, 4 rows at least, and typing never moves it" (two files: four rows, the same after `zzq` with nothing matching; on the parent two rows), Band.zig "a band keeps its pane's body 60 % of the pane, borrowed from its column; where the column has not the rows, the band gives way before the body drops under 6" (three panes in 40 rows: the body 60 % of the pane; in 12 rows the band shorter than it wants, the body six), the borrow test's body six rows (was four); core-test 1068/1239 (171 skipped); process-test: find, fsearch, lsp regenerated and read: each picker band four rows where its list has two or three (find's two files, fsearch's three places, lsp's three symbols), the rows under the list the band's ground with the spines on through it, the body that much lower; a user saw a picker's band change size with its source, and a short pane's body crushed Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_016Y9MNBFhdevVu48bvL9kCE --- core/Band.zig | 35 +++++++++++++++++++++++++++++++++-- core/Core.zig | 2 +- core/Pick.zig | 42 ++++++++++++++++++++++++++++++++++++++---- core/layout.zig | 12 ++++++++---- test/snapshots/find.golden | 10 ++++++++-- test/snapshots/fsearch.golden | 27 +++++++++++++-------------- test/snapshots/lsp.golden | 25 +++++++++++++------------ 7 files changed, 114 insertions(+), 39 deletions(-) (limited to 'core/Core.zig') diff --git a/core/Band.zig b/core/Band.zig index 07c2f83d..e34b6a49 100644 --- a/core/Band.zig +++ b/core/Band.zig @@ -73,6 +73,8 @@ pub const max_spines = 12; pub const min_width = 24; /// 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). +pub const body_rows = 6; /// A level's rows past which it flows into two columns. const one_column = 9; @@ -635,7 +637,35 @@ test "SPC Down unrolls the level into a band under the tag's text, the body push try std.testing.expect(!p.view().tag_state.unrolled); } -test "a pane whose body would drop below four rows under its band borrows them from its column" { +test "a band keeps its pane's body 60 % of the pane, borrowed from its column; where the column has not the rows, the band gives way before the body drops under 6" { + const Key = pardes.Key; + const p = try Pardes.init(std.testing.allocator, .{ .tty_only = true, .cols = 120, .rows = 40 }); + defer p.deinit(); + _ = try p.setTestFile("one\n"); + const top = p.view().active; + p.newScratchBelow(top); + const low = p.view().active; + p.newScratchBelow(low); + p.view().active = low; + p.sync(); + p.update(.{ .key = .{ .cp = ' ' } }); + p.update(.{ .key = .{ .cp = Key.down } }); + const pane = p.panes[low].?; + const r = p.view().rects[low]; + try std.testing.expect(pane.band_rows >= doc_rows); + try std.testing.expect(@as(u32, r.h -| pane.tag_rows) * 5 >= @as(u32, r.h) * 3); + p.update(.{ .key = .{ .cp = Key.escape } }); + // A window of 12 rows: the band shrinks, the body keeps 6. + p.update(.{ .resize = .{ .cols = 120, .rows = 12 } }); + p.update(.{ .key = .{ .cp = ' ' } }); + p.update(.{ .key = .{ .cp = Key.down } }); + p.sync(); + const short = p.view().rects[low]; + try std.testing.expect(short.h -| pane.tag_rows >= 6 or pane.band_rows == 0); + try std.testing.expect(pane.band_rows < Band.takes(p, low)); +} + +test "a pane whose body would drop below six rows under its band borrows them from its column" { const Key = pardes.Key; const p = try Pardes.init(std.testing.allocator, .{ .tty_only = true, .cols = 120, .rows = 24 }); defer p.deinit(); @@ -652,7 +682,8 @@ test "a pane whose body would drop below four rows under its band borrows them f const pane = p.panes[low].?; const r = p.view().rects[low]; try std.testing.expect(r.h > before); - try std.testing.expect(r.h -| pane.tag_rows >= 4); + // Its body six rows at least (UX D6): a column too short for 60 %. + try std.testing.expect(r.h -| pane.tag_rows >= 6); // 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(); diff --git a/core/Core.zig b/core/Core.zig index 26860365..5b6eba75 100644 --- a/core/Core.zig +++ b/core/Core.zig @@ -2063,7 +2063,7 @@ pub fn sync(p: *Pardes) void { // The band unrolled under the tag's text pushes the body down: // the tag's rows, as everything under them counts them. // 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.band_rows = if (pane.collapsed or pardes.Band.over(pane)) 0 else @min(pardes.Band.takes(p, id), r.h -| pane.tag_rows -| pardes.Band.body_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/Pick.zig b/core/Pick.zig index 52976f15..52e9601d 100644 --- a/core/Pick.zig +++ b/core/Pick.zig @@ -624,13 +624,18 @@ pub fn head(p: *Pardes, arena: std.mem.Allocator, pane: *Pane) !?TagState.Head { return h; } -/// The band's rows: as many as the list will show, eleven at most, from -/// what the source has (not what the query keeps: typing never moves the -/// body). +/// The band's rows (UX D6): as many as the list will show, from what the +/// source has (not what the query keeps: typing never moves the body), +/// four at least, eleven at most, and 40 % of the host's column at most +/// (its panes' rows, which a borrow moves between them, never changes). pub fn bandRows(p: *const Pardes) u16 { const pk = live(p) orelse return 0; const have = if (!fuzzy(pk)) Band.Cursor.shown else pk.names.cands.items.len; - const rows: usize = @max(1, @min(Band.Cursor.shown, have)); + const v = p.view(); + const at = @import("layout.zig").findPane(p, TagState.hostOf(p) orelse return 0) orelse return 0; + var column: usize = 0; + for (v.cols[at.col].panes[0..v.cols[at.col].n]) |id| column += v.rects[id].h; + const rows: usize = @max(1, @min(Band.Cursor.shown, @max(4, have), column * 2 / 5)); // Its second step's rows too: the sources, the acts and what they act on. return @intCast(switch (pk.spine) { .sources => @max(rows, spine_rows.len), @@ -1578,6 +1583,35 @@ test "a picker's act row is one row under the spines, two cells right of the las try std.testing.expect(h.spans[h.spans.len - 1].style == .dim); } +test "a picker's band is sized from its list at open, 4 rows at least, and typing never moves it" { + const p = try Pardes.init(std.testing.allocator, .{ .tty_only = true, .cols = 100, .rows = 40 }); + defer p.deinit(); + p.settings.jumps = .walk; + var tmp = std.testing.tmpDir(.{}); + defer tmp.cleanup(); + const a_path = try testFile(p, &tmp, "alpha.zig", "const alpha = 1;\n"); + defer p.gpa.free(a_path); + _ = try p.setTestFile("held\n"); + const asker = p.view().active; + Trail.keep(p.panes[asker].?); + // In the test's directory: its two files listed. + p.gpa.free(p.panes[asker].?.file.?.path); + p.panes[asker].?.file.?.path = try std.Io.Dir.path.join(p.gpa, &.{ std.Io.Dir.path.dirname(a_path).?, "held.txt" }); + p.stream.engine = .walk; + open(p, asker, .find, "", "", ""); + settle(p); + const reader = p.paneBySerial(live(p).?.landing).?; + p.sync(); + const rows = p.panes[reader].?.band_rows; + // One or two files listed: four rows, ground under them. + try std.testing.expectEqual(@as(u16, 4), rows); + for ("zzq") |c| p.update(.{ .key = .{ .cp = c, .text = &[_]u8{c} } }); + settle(p); + p.sync(); + try std.testing.expectEqual(@as(usize, 0), count(p, live(p).?)); + try std.testing.expectEqual(rows, p.panes[reader].?.band_rows); +} + test "a picker's keys: Tab marks and moves, M-a all and none, C-SPC refines and Backspace undoes it, M-h switches source keeping the query" { const p = try Pardes.init(std.testing.allocator, .{ .tty_only = true, .cols = 140, .rows = 50 }); defer p.deinit(); diff --git a/core/layout.zig b/core/layout.zig index de12294b..5550ef4a 100644 --- a/core/layout.zig +++ b/core/layout.zig @@ -1471,13 +1471,17 @@ pub fn compute(p: *Pardes) void { /// The fewest rows a pane is laid out with: a terminal keeps its tag and /// `min_body_rows` (a shorter one loses its prompt and reads busy for /// ever), a text pane may shrink to its tag, as acme's windows do. A tag -/// out of rest keeps its band and four body rows, borrowed from the -/// column's other panes, which shrink to their tags until it rolls up -/// (walk UI SPEC §3.6). +/// out of rest keeps its band and a body of 60 % of the pane and 6 rows at +/// least (UX D6), borrowed from the column's other panes, which shrink to +/// their tags until it rolls up (walk UI SPEC §3.6). fn floorRows(p: *Pardes, id: usize) u16 { const pane = p.panes[id] orelse return 0; 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; + if (band > 0) { + const above = @max(1, pane.tag_rows -| pane.band_rows) + band; + // A body of 60 % is one and a half times what is above it. + return above + @max(pardes.Band.body_rows, (3 * above + 1) / 2); + } return if (pane.isTerminal()) @max(1, pane.tag_rows) + min_body_rows else 1; } diff --git a/test/snapshots/find.golden b/test/snapshots/find.golden index 6af0405d..da1b0e4e 100644 --- a/test/snapshots/find.golden +++ b/test/snapshots/find.golden @@ -77,7 +77,9 @@ |3: │ │ Walk Look Split Newcol Grep Edit Copy Keep Drop | Grep Recent Panes Symbols All Jumplist |4: │ │ nothing matches |5: │ │ -|6: 1 beta body +|6: │ │ +|7: │ │ +|8: 1 beta body |40: ✓ /tmp/pardes-snap/find/cwd/sub/ZQMARK-beta.txt Find 2 messages · SPC h m == snap cancel grid=120x41 cursor=7,3 |2: here.txt:1 › Find zqm 2/3 › /tmp/pardes-snap/find/cwd/sub/ZQMARK-beta.txt Keep Save Term Collapse Follow Del @@ -85,10 +87,14 @@ |4: |5: |6: +|7: +|8: == snap topbar grid=120x41 cursor=29,2 |2: ^ Find zqm 2/3 › ␣ f Find bod 0 |3: │ │ Walk Look Split Newcol Grep Edit Copy Keep Drop | Grep Recent Panes Symbols All Jumplist |4: │ │ nothing matches |5: │ │ -|6: 1 beta body +|6: │ │ +|7: │ │ +|8: 1 beta body |40: ✓ /tmp/pardes-snap/find/cwd/sub/ZQMARK-beta.txt Find ×2 2 messages · SPC h m diff --git a/test/snapshots/fsearch.golden b/test/snapshots/fsearch.golden index fe5a29ef..905d2ef0 100644 --- a/test/snapshots/fsearch.golden +++ b/test/snapshots/fsearch.golden @@ -75,7 +75,19 @@ |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: 1 l1 +|21: │ │ +|22: 1 l1 +|23: 2 MARK a +|24: 3 l3 +|25: 4 l4 +|26: 5 l5 +|27: 6 MARK b +|28: 7 l7 +|29: 8 l8 +== 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 |22: 2 MARK a |23: 3 l3 |24: 4 l4 @@ -84,19 +96,6 @@ |27: 7 l7 |28: 8 l8 |29: 9 l9 -== 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 -|21: 2 MARK a -|22: 3 l3 -|23: 4 l4 -|24: 5 l5 -|25: 6 MARK b -|26: 7 l7 -|27: 8 l8 -|28: 9 l9 -|29: 10 MARK c == 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 diff --git a/test/snapshots/lsp.golden b/test/snapshots/lsp.golden index 94958ba4..06127538 100644 --- a/test/snapshots/lsp.golden +++ b/test/snapshots/lsp.golden @@ -62,18 +62,19 @@ |4: │ │ ▶ a.zig:1:7-9 std |5: │ │ a.zig:3:4-9 helper |6: │ │ a.zig:7:8-11 main -|7: 1 const std = @import("std"); -|8: 2 -|9: 3 fn helper(x: u32) u32 { -|10: fn helper(x: u32) u32 -|11: (fn (u32) u32) -|12: 4 return x + 1; -|13: 5 } -|14: 6 -|15: 7 pub fn main() void { -|16: 8 _ = helper(41); -|17: 9 } -|18: ~ +|7: │ │ +|8: 1 const std = @import("std"); +|9: 2 +|10: 3 fn helper(x: u32) u32 { +|11: fn helper(x: u32) u32 +|12: (fn (u32) u32) +|13: 4 return x + 1; +|14: 5 } +|15: 6 +|16: 7 pub fn main() void { +|17: 8 _ = helper(41); +|18: 9 } +|19: ~ |40: ✓ /tmp/pardes-snap/lsp/cwd/a.zig Symbols 2 messages · SPC h m == snap step grid=120x41 cursor=27,2 |2: ^ a.zig:8 › ␣ l Symbols jn 0 -- cgit v1.3