diff options
| author | Gabriel Schneider <[email protected]> | 2026-11-25 10:45:43 -0300 |
|---|---|---|
| committer | Gabriel Schneider <[email protected]> | 2026-11-25 10:45:43 -0300 |
| commit | 854f2d4851044dc726f062ea2055c2f946f3a812 (patch) | |
| tree | 58a58b97ff59504900d4f8d239b9cb24bca6900b /core/Band.zig | |
| parent | 01139e1614e457367bc634b0de0dd9a5e0bd388e (diff) | |
| download | pardes-854f2d4851044dc726f062ea2055c2f946f3a812.tar.gz pardes-854f2d4851044dc726f062ea2055c2f946f3a812.zip | |
Band: Help's rows say the chord, two blanks and the word, the group right-aligned in the dim ink as the row's meta (P2's Band.Row.meta), and a list that is the band's last step takes the band's remaining width, so a row's meta stands at the band's right edge (UX D5/D4 as E3 amends them, DESIGN.md E5.6: "`SPC l k Hover` … `lsp`, the ` · ` joins go"; E3: "A rows step that is the last step takes the band's remaining width (52 only when a step follows it)"); TEST FIRST: Band.zig "Help's rows say the chord, two blanks and the word; the group is the row's meta, right-aligned at its step's edge in the dim ink: no ` · ` (UX D5, D4)" (`SPC ? wrap`: on the base the cursor row read `SPC t w · Wrap · view`, no meta); THE CHANGE: Band.helpSteps splits a leaf's `chord · word · group` (bindings.flat's rows and an addon word's, unchanged: Help's filter still matches the whole row) into the text `chord word`, its chord in the key ink as before, and `meta = group`, which Band.line places at the step's right end when it fits after the whole text (P2's rule: the meta gives way before the text is cut) and joinBand draws in the dim ink; the query's matched letters are marked in the shown text (a match only in the group marks none); Band.place, after the give-way, widens the last step when it is a list of one column to what the band has left (a two-column level keeps its lanes); WHAT MOVES: Help's rows (and the themes picker's `in use`, a picker's rows, the registers' names when the doc gave way) at the band's right edge; a picker's rows are no longer cut at 52 cells when no step follows them, and the cursor row's ground runs to the band's edge with them; GOLDENS: ttyhelp: the row reads `▶ SPC h t Tutor help │ t Tutor` (the ` · ` joins gone, `help` at the step's right end), so the step and the doc's rule are two cells narrower; tty_terminals.zig ttyhelp waits for `SPC h t Tutor` (it waited for the row with its joins: ExpectFailed before); no other golden moved; core-test 1089/1260 (171 skipped), process-test 1 of 147 failed before (ttyhelp), 0 after the wait and the golden
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 | 68 |
1 files changed, 61 insertions, 7 deletions
diff --git a/core/Band.zig b/core/Band.zig index f03a2c53..f2a86d07 100644 --- a/core/Band.zig +++ b/core/Band.zig @@ -215,8 +215,9 @@ pub fn of(p: *Pardes, arena: std.mem.Allocator, pane: *Pane, id: usize) !?Band { return band; } -/// Help's rows (`chord · word · group`, the query's bytes in the match -/// tint) around the cursor, and the cursor's leaf's doc beside them. +/// Help's rows around the cursor (`SPC t w Wrap`, the query's bytes in +/// the match tint, the group `view` its meta: UX D5), and the cursor's +/// leaf's doc beside them. fn helpSteps(band: *Band, p: *Pardes, arena: std.mem.Allocator, s: *const TagState) !void { if (s.nhits == 0) { const none = try arena.alloc(Row, 1); @@ -230,15 +231,18 @@ fn helpSteps(band: *Band, p: *Pardes, arena: std.mem.Allocator, s: *const TagSta for (rows, w.lo..) |*row, i| { const buf = try arena.create([TagState.row_max]u8); const leaf = TagState.helpLeaf(p, s.hits[i], buf); + // Its leaf's `chord · word · group` as the chord (the key ink), two + // blanks and the word; the group its meta (dim, at the right). + var parts = std.mem.splitSequence(u8, leaf.row, " · "); + const chord = parts.first(); + const text = try std.mem.concat(arena, u8, &.{ chord, " ", parts.next() orelse "" }); var marks: [Names.max_query * 4]u16 = undefined; var nmarks: usize = 0; if (std.mem.trim(u8, q, " ").len > 0) { - const low = try std.ascii.allocLowerString(arena, leaf.row); - _ = Names.match(q, leaf.row, low, 0, &marks, &nmarks); + const low = try std.ascii.allocLowerString(arena, text); + if (Names.match(q, text, low, 0, &marks, &nmarks) == null) nmarks = 0; } - // Its chord (`SPC h t`, before the first ` · `) in the key ink. - const chord = std.mem.indexOf(u8, leaf.row, " · ") orelse 0; - row.* = .{ .text = leaf.row, .on = i == s.rows.at, .chord = @intCast(@min(chord, 255)), .marks = try arena.dupe(u16, marks[0..nmarks]), .index = @intCast(i), .dim = bindings.dimmed(p.panes[p.view().active].?, leaf.child) }; + row.* = .{ .text = text, .meta = parts.rest(), .on = i == s.rows.at, .chord = @intCast(@min(chord.len, 255)), .marks = try arena.dupe(u16, marks[0..nmarks]), .index = @intCast(i), .dim = bindings.dimmed(p.panes[p.view().active].?, leaf.child) }; } band.add(.{ .rows = rows }); var buf: [TagState.row_max]u8 = undefined; @@ -460,6 +464,12 @@ fn place(band: *Band, p: *Pardes, arena: std.mem.Allocator, pane: *Pane, id: usi kept += 1; } band.nsteps = kept; + // The last step, a list, takes what the band has left (UX E3): 52 cells + // only when a step follows it; its meta at the band's right edge. + if (kept > 0 and !band.steps[kept - 1].doc and !band.steps[kept - 1].two) { + const last = &band.steps[kept - 1]; + last.width = @max(last.width, band.columns -| last.x); + } } /// The display columns of the head's key cells: a spine hangs under each, @@ -702,6 +712,50 @@ test "steps stand apart: one blank, the rule, one blank between a step and the n }; } +test "Help's rows say the chord, two blanks and the word; the group is the row's meta, right-aligned at its step's edge in the dim ink: no ` · ` (UX D5, D4)" { + const Cells = struct { + /// The cell `word` starts at, a grapheme a cell. + fn find(cells: []const pardes.Cell, word: []const u8) ?usize { + var at: usize = 0; + while (at + word.len <= cells.len) : (at += 1) { + for (word, cells[at..][0..word.len]) |c, cell| { + if (cell.len != 1 or cell.text[0] != c) break; + } else return at; + } + return null; + } + }; + const p = try Pardes.init(std.testing.allocator, .{ .tty_only = true, .cols = 140, .rows = 40 }); + defer p.deinit(); + const pane = try p.setTestFile("one\n"); + const id = p.view().active; + var frame = std.heap.ArenaAllocator.init(std.testing.allocator); + defer frame.deinit(); + const a = frame.allocator(); + const selected = p.chromeTheme().roles.selectedOn(if (pardes.Trail.reading(p, pane)) .reading_focused else .focused); + for ([_]u21{ ' ', '?', 'w', 'r', 'a', 'p' }) |c| p.update(.{ .key = .{ .cp = c } }); + const band = (try of(p, a, pane, id)).?; + const step = band.steps[0]; + var found = false; + for (step.rows) |row| { + try std.testing.expect(std.mem.indexOf(u8, row.text, " · ") == null); + if (!std.mem.eql(u8, row.text, "SPC t w Wrap")) continue; + try std.testing.expectEqualStrings("view", row.meta); + found = true; + } + try std.testing.expect(found); + _ = try p.render(a); + const layer = bandLayer(p, id).?; + for (0..layer.rows) |y| { + const cells = layer.cells[y * layer.cols ..][0..layer.cols]; + if (Cells.find(cells, "SPC t w Wrap") == null) continue; + const at = Cells.find(cells, "view").?; + try std.testing.expectEqual(@as(usize, step.x + step.width - "view".len), at); + try std.testing.expectEqual(pardes.Color{ .rgb = selected.dim }, cells[at].style.fg); + break; + } else return error.TestUnexpectedResult; +} + 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(); |
