diff options
| author | Gabriel Schneider <[email protected]> | 2026-11-25 10:36:18 -0300 |
|---|---|---|
| committer | Gabriel Schneider <[email protected]> | 2026-11-25 10:36:19 -0300 |
| commit | 01139e1614e457367bc634b0de0dd9a5e0bd388e (patch) | |
| tree | 8fdc6091970f179c6233bee4cb387a72440578fa | |
| parent | d7eec005d9f56384f439a09a92c2d05a571e96e8 (diff) | |
| download | pardes-01139e1614e457367bc634b0de0dd9a5e0bd388e.tar.gz pardes-01139e1614e457367bc634b0de0dd9a5e0bd388e.zip | |
Band: one blank each side of the `│` between two steps, so a step's widest row never touches the rule (UX D5, DESIGN.md E5.5: `ClipPasteBefore│` P1 03, `yank│` P2 06, `lsp│` P1 04; P2's note to P1); TEST FIRST: Band.zig "steps stand apart: one blank, the rule, one blank between a step and the next, its widest row's text never touching the rule (UX D5)" (Help at 160 columns, its rows and its doc: on the base the widest row ran into the rule, ` │ ` not at the rule's cell); THE CHANGE: Band.place puts each step three cells after the one before it (a blank, the rule, a blank: `x += width + 3`, and the room the steps need counts the same), where it put it two after (the rule, a blank); Band.line draws the rule two cells before a step as before, so the blank before it is the new cell; the doc's width is what is left as before; GOLDEN: ttyhelp: Help's rows and the doc's rule one cell right (`help│ t Tutor` -> `help │ t Tutor`), nothing else; core-test 1088/1259 (171 skipped), process-test 1 of 147 failed before the golden (ttyhelp, regenerated)
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_016Y9MNBFhdevVu48bvL9kCE
| -rw-r--r-- | core/Band.zig | 27 | ||||
| -rw-r--r-- | test/snapshots/ttyhelp.golden | 8 |
2 files changed, 28 insertions, 7 deletions
diff --git a/core/Band.zig b/core/Band.zig index c1ae2c37..f03a2c53 100644 --- a/core/Band.zig +++ b/core/Band.zig @@ -413,7 +413,7 @@ pub fn docStep(p: *Pardes, arena: std.mem.Allocator, root: bindings.Root, path: } /// 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 +/// a rule's cell between steps with a blank each side of it; 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: @@ -433,7 +433,7 @@ fn place(band: *Band, p: *Pardes, arena: std.mem.Allocator, pane: *Pane, id: usi for (step.rows) |row| widest = @max(widest, File.displayWidth(tab, row.text) + if (row.meta.len > 0) 2 + File.displayWidth(tab, row.meta) else 0); const column: u16 = @intCast(@min(widest, row_cells) + 2); step.width = if (step.two) 2 * column + 1 else column; - need += step.width + 2; + need += step.width + 3; lists += 1; } // The last list alone where they do not all fit. @@ -455,7 +455,7 @@ fn place(band: *Band, p: *Pardes, arena: std.mem.Allocator, pane: *Pane, id: usi placed.width = @min(placed.width, @max(band.columns -| x, @min(min_width, band.columns))); } placed.x = x; - x +|= placed.width + 2; + x +|= placed.width + 3; band.steps[kept] = placed; kept += 1; } @@ -681,6 +681,27 @@ test "out of rest with no band, the rows a tag keeps from rest stay blank: a spi for (1..rest) |row| for (0..r.w) |x| try std.testing.expect(!std.mem.eql(u8, "│", s.at(r.x + @as(u16, @intCast(x)), tag_y + @as(u16, @intCast(row))).grapheme())); } +test "steps stand apart: one blank, the rule, one blank between a step and the next, its widest row's text never touching the rule (UX D5)" { + const p = try Pardes.init(std.testing.allocator, .{ .tty_only = true, .cols = 160, .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 tab = p.settings.tab; + // Help: its rows, the doc beside them. + p.update(.{ .key = .{ .cp = ' ' } }); + p.update(.{ .key = .{ .cp = '?' } }); + const band = (try of(p, a, pane, id)).?; + try std.testing.expect(band.nsteps >= 2); + for (band.steps[1..band.nsteps]) |step| for (0..band.height) |y| { + const ln = try band.line(a, tab, @intCast(y)); + const at = File.rawAtDisplay(tab, ln.text, step.x - 3); + try std.testing.expect(std.mem.startsWith(u8, ln.text[at..], " │ ")); + }; +} + 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(); diff --git a/test/snapshots/ttyhelp.golden b/test/snapshots/ttyhelp.golden index 93442263..41f429e0 100644 --- a/test/snapshots/ttyhelp.golden +++ b/test/snapshots/ttyhelp.golden @@ -50,10 +50,10 @@ |30: ✓ @p1 Help 1 message · SPC h m == snap leaderworks grid=100x31 cursor=12,5 |5: ^ Help tutor 1/1 -|6: ▶ SPC h t · Tutor · help│ t Tutor -|7: │ Open the tutor, a document to work through. -|8: │ keys SPC h t -|9: │ +|6: ▶ SPC h t · Tutor · help │ t Tutor +|7: │ Open the tutor, a document to work through. +|8: │ keys SPC h t +|9: │ |10: 1 pardes builtins: each one's keys and its name, then what it does. Run one by its keys, or by↩ |11: its name anywhere: B2 on the word, Exec <name>, a line of a ctl file, or `pardes do <name>`↩ |12: from a shell. `Help <name>` shows one builtin alone; `Help <keys>` (or SPC, those keys, the↩ |
