diff options
| author | Gabriel Schneider <[email protected]> | 2026-11-25 06:26:22 -0300 |
|---|---|---|
| committer | Gabriel Schneider <[email protected]> | 2026-11-25 06:26:22 -0300 |
| commit | 56ca48879da0dd335097d695fb7f4b4b6fe5157b (patch) | |
| tree | 4045a8fda6d4988b9d09d33ed4d7b64363e4658d /core/Band.zig | |
| parent | ea9a19700cc1c0bc22c08b1d31d7a62e5853b802 (diff) | |
| download | pardes-56ca48879da0dd335097d695fb7f4b4b6fe5157b.tar.gz pardes-56ca48879da0dd335097d695fb7f4b4b6fe5157b.zip | |
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
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_016Y9MNBFhdevVu48bvL9kCE
Diffstat (limited to 'core/Band.zig')
| -rw-r--r-- | core/Band.zig | 61 |
1 files changed, 52 insertions, 9 deletions
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(); |
