diff options
| author | Gabriel Schneider <[email protected]> | 2026-11-25 06:20:03 -0300 |
|---|---|---|
| committer | Gabriel Schneider <[email protected]> | 2026-11-25 06:20:03 -0300 |
| commit | ea9a19700cc1c0bc22c08b1d31d7a62e5853b802 (patch) | |
| tree | 58ddd9ef63f447b7517f2d1a75dec74d0931ed10 /core/Pick.zig | |
| parent | 5c897d00fe064cf8463ef76ea804b0aff6b62f0a (diff) | |
| download | pardes-ea9a19700cc1c0bc22c08b1d31d7a62e5853b802.tar.gz pardes-ea9a19700cc1c0bc22c08b1d31d7a62e5853b802.zip | |
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 <[email protected]>
Claude-Session: https://claude.ai/code/session_016Y9MNBFhdevVu48bvL9kCE
Diffstat (limited to 'core/Pick.zig')
| -rw-r--r-- | core/Pick.zig | 42 |
1 files changed, 38 insertions, 4 deletions
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(); |
