diff options
| author | Gabriel Schneider <[email protected]> | 2026-11-25 05:58:33 -0300 |
|---|---|---|
| committer | Gabriel Schneider <[email protected]> | 2026-11-25 05:58:33 -0300 |
| commit | 1d440373e90516ace8e45e8e64f2e4ae5d4a4773 (patch) | |
| tree | 2eb1247e10a143c37d4972d1d1f883a38e140a85 /core/Band.zig | |
| parent | 99c70953a0c3b8e32cc5b61121c2b18e5ee68edd (diff) | |
| download | pardes-1d440373e90516ace8e45e8e64f2e4ae5d4a4773.tar.gz pardes-1d440373e90516ace8e45e8e64f2e4ae5d4a4773.zip | |
TagState, Pick, Band: computed text breaks between its items only, a hanging indent under the spines, a rolled level three rows at most ending `+N ↓`, the picker's act row one row, a row too long cut with `…` (a path from the left) (walk UI polish P1, UX DESIGN.md D2): the rolled level was one long line wrapped by the tag's grapheme wrap, so a key fell apart from its label (`P`/`ClipPasteBefore`, `l ls`/`p…`, `D d`/`iagnostic end`) and its continuation rows started at the tag's first column under the box; the act row wrapped onto two (`Grep Rec`/`ent`); a band row was clipped at its step's edge; now (TagState.Builder) `keyCell` keeps each key cell's column and `row(indent)` starts a row of the head with a `│` under each key cell left of the indent (UX D5's spines through the tag's continuation rows; `// P2: the rule role`) and blanks up to it; the rolled level puts each child (`key label`) whole, a row's last child followed by the next row from the first child's column, three rows at most (a terminal's: the rows its own text takes, as before), the last one's last fitting child followed by a dim `+N ↓` (N the children not shown; the cells of it and of a struck key kept on the last row), its hints by the right block's rule on its last row (dropped where they do not fit); Pick.head's key cells are the builder's (its head's first spans, as every head's), its act row one row from two cells right of the last spine: the acts, `|`, the other sources, what does not fit dropped from the right (the sources first) and a dim `…` ending it (M-l, M-h reach them); Band.findSpines takes the key cells on whatever row they are (it wanted them on the tag's last row, so a picker's band had no spines and its steps started at the pane's edge: fsearch's list rows); Band.cutRow holds a row to its room with `…`: a path (its directory faint: Find's rows) cut from the left (`…r/Store.zig`), anything else from the right, its marks and faint bytes moved with it; TEST FIRST: TagState.zig "a rolled level breaks between its children only: ..." (SPC's level at 60 columns: three rows, the second and third `│ ` then a child, no row wider than the tag, every child shown whole, the rest counted in the last row's `+N ↓`; SPC h's on one row), Pick.zig "a picker's act row is one row under the spines ..." (60 columns: `│ │ Walk Look ` ... ` …`, a dim `…`), Band.zig "a row longer than its room is cut with `…` ..."; the SPC test reads a level of three rows at most; core-test 1066/1236 (170 skipped); process-test: 3 goldens regenerated and read: leader (the rolled level's second and third rows `│ ` from its first child's column, no child split, the hints at the last row's right end), find (`␣ f`'s hints at the row's end), fsearch (the list picker's act row one row ending `Panes …`, its band rows under spines from two cells right of the last, the body a row up); a user met the split words at every width under ~160 columns
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 | 63 |
1 files changed, 52 insertions, 11 deletions
diff --git a/core/Band.zig b/core/Band.zig index 024b6be4..0d4891aa 100644 --- a/core/Band.zig +++ b/core/Band.zig @@ -394,20 +394,16 @@ fn place(band: *Band, p: *Pardes, arena: std.mem.Allocator, pane: *Pane, id: usi band.nsteps = kept; } -/// The display columns of the head's key cells, when they are all on the -/// tag's last row (the spines hang from there). +/// The display columns of the head's key cells: a spine hangs under each, +/// through the tag's rows under them and the band's (UX D5). fn findSpines(band: *Band, p: *Pardes, arena: std.mem.Allocator, pane: *Pane, id: usize) !void { const h = (try TagState.head(p, arena, pane)) orelse return; const whole = try tagline.tagText(p, arena, pane); const shown = try tagline.wrapTag(p.settings.tab, arena, whole, tagline.tagWidth(p, id)); const lead = whole.len - h.text.len; - const last = shown.rows() -| 1; for (h.spans[0..h.cells]) |span| { const at = modal.positionAt(shown.text, shown.fromReal(lead + span.lo)); - if (at.row != last or band.nspines == max_spines) { - band.nspines = 0; - return; - } + if (band.nspines == max_spines) return; band.spines[band.nspines] = @intCast(File.rawDisplayCol(p.settings.tab, modal.lineSlice(shown.text, at.row), at.col)); band.nspines += 1; } @@ -484,16 +480,46 @@ pub fn line(band: *const Band, arena: std.mem.Allocator, tab: u16, y: u16) !Line const lead: []const u8 = if (step.doc) "" else if (row.on) "▶ " else if (row.mark) "• " else " "; try text.appendSlice(arena, lead); col += @intCast(File.displayWidth(tab, lead)); - try parts.append(arena, .{ .col = col, .width = per -| @as(u16, @intCast(File.displayWidth(tab, lead))), .row = row }); const room = per -| @as(u16, @intCast(File.displayWidth(tab, lead))); - const cut = File.byteAtDisplay(tab, row.text, room); - try text.appendSlice(arena, row.text[0..cut]); - col += @intCast(File.displayWidth(tab, row.text[0..cut])); + const fit = try cutRow(arena, tab, row, room); + try parts.append(arena, .{ .col = col, .width = room, .row = fit }); + try text.appendSlice(arena, fit.text); + col += @intCast(File.displayWidth(tab, fit.text)); } } return .{ .text = text.items, .parts = parts.items }; } +/// Row `row` held to `room` cells (UX D2): a longer one cut with `…`, a +/// path (its directory faint: Find's rows) from the left +/// (`…core/Store.zig`), anything else from the right; its marks and faint +/// bytes moved with its text. +fn cutRow(arena: std.mem.Allocator, tab: u16, row: Row, room: u16) !Row { + if (File.displayWidth(tab, row.text) <= room) return row; + var fit = row; + var marks: std.ArrayList(u16) = .empty; + if (row.faint > 0 and row.pre == 0 and room > 1) { + var from = row.text.len; + while (from > 0) { + const before = modal.prevGrapheme(row.text, from); + if (File.displayWidth(tab, row.text[before..]) > room - 1) break; + from = before; + } + fit.text = try std.mem.concat(arena, u8, &.{ "…", row.text[from..] }); + for (row.marks) |m| if (m >= from) try marks.append(arena, @intCast(m - from + "…".len)); + fit.faint = @intCast(if (row.faint > from) row.faint - from + "…".len else "…".len); + } else { + const cut = File.byteAtDisplay(tab, row.text, room -| 1); + fit.text = try std.mem.concat(arena, u8, &.{ row.text[0..cut], if (room > 0) "…" else "" }); + for (row.marks) |m| if (m < cut) try marks.append(arena, m); + fit.key = @intCast(@min(row.key, cut)); + fit.pre = @intCast(@min(row.pre, cut)); + fit.faint = @intCast(@min(row.faint, cut -| fit.pre)); + } + fit.marks = marks.items; + return fit; +} + /// The word under column `col` of band row `y` of pane `id`, at the /// tagline's pitch: what B2 executes and B3 looks at. pub fn wordAt(p: *Pardes, arena: std.mem.Allocator, id: usize, y: u16, col: u16) !?[]const u8 { @@ -518,6 +544,21 @@ fn layerRow(arena: std.mem.Allocator, layer: *const pardes.Layer, row: usize) 