summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--core/Band.zig27
-rw-r--r--test/snapshots/ttyhelp.golden8
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↩