summaryrefslogtreecommitdiff
path: root/core/Band.zig
diff options
context:
space:
mode:
authorGabriel Schneider <[email protected]>2026-11-25 10:36:18 -0300
committerGabriel Schneider <[email protected]>2026-11-25 10:36:19 -0300
commit01139e1614e457367bc634b0de0dd9a5e0bd388e (patch)
tree8fdc6091970f179c6233bee4cb387a72440578fa /core/Band.zig
parentd7eec005d9f56384f439a09a92c2d05a571e96e8 (diff)
downloadpardes-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
Diffstat (limited to 'core/Band.zig')
-rw-r--r--core/Band.zig27
1 files changed, 24 insertions, 3 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();