summaryrefslogtreecommitdiff
path: root/core/Band.zig
diff options
context:
space:
mode:
Diffstat (limited to 'core/Band.zig')
-rw-r--r--core/Band.zig35
1 files changed, 31 insertions, 4 deletions
diff --git a/core/Band.zig b/core/Band.zig
index 507f1bee..c1ae2c37 100644
--- a/core/Band.zig
+++ b/core/Band.zig
@@ -626,14 +626,15 @@ fn layerRow(arena: std.mem.Allocator, layer: *const pardes.Layer, row: usize) ![
return out.items;
}
-test "a narrow band gives way and keeps its spines: the doc goes, the steps start two cells right of the last spine, no row past the band's edge; the spines run on through the tag's rows under the head" {
+test "a narrow band gives way and keeps its spines: the doc goes, the steps start two cells right of the last spine, no row past the band's edge; the band starts on the row under the head, in the rows the tag keeps from rest" {
const Key = pardes.Key;
const p = try Pardes.init(std.testing.allocator, .{ .tty_only = true, .cols = 44, .rows = 30 });
defer p.deinit();
const pane = try p.setTestFile("one\n");
const id = p.view().active;
p.sync();
- try std.testing.expect(pane.tag_rows > 1);
+ const rest = pane.tag_rows;
+ try std.testing.expect(rest > 1);
var frame = std.heap.ArenaAllocator.init(std.testing.allocator);
defer frame.deinit();
const a = frame.allocator();
@@ -645,15 +646,41 @@ test "a narrow band gives way and keeps its spines: the doc goes, the steps star
try std.testing.expectEqual(@as(u8, 1), band.nsteps);
try std.testing.expectEqual(band.spines[1] + 2, band.steps[0].x);
for (0..band.height) |y| try std.testing.expect(File.displayWidth(p.settings.tab, (try band.line(a, p.settings.tab, @intCast(y))).text) <= band.columns);
- // The tag's second row, kept from rest under the head's one: a spine
- // under each key cell.
+ // The band on the row under the head's one, in the row the tag keeps
+ // from rest (UX E3): never a blank row between the head and its rows,
+ // the body under whichever is lower.
const s = try p.render(a);
const r = p.view().rects[id];
const tag_y = p.tagTop(pane, r);
+ try std.testing.expectEqual(@as(u16, 1), pane.tag_rows - pane.band_rows);
+ try std.testing.expectEqual(@max(rest, 1 + band.height), pane.tag_rows);
+ try std.testing.expectEqual(tag_y + 1, bandLayer(p, id).?.viewport.y);
for (band.spines[0..band.nspines]) |col| try std.testing.expectEqualStrings("│", s.at(r.x + pardes.TAG_TEXT_INSET + col, tag_y + 1).grapheme());
+ try std.testing.expect(std.mem.indexOf(u8, try layerRow(a, bandLayer(p, id).?, 0), "▶") != null);
p.update(.{ .key = .{ .cp = Key.escape } });
}
+test "out of rest with no band, the rows a tag keeps from rest stay blank: a spine hangs only where a band row is" {
+ const p = try Pardes.init(std.testing.allocator, .{ .tty_only = true, .cols = 44, .rows = 30 });
+ defer p.deinit();
+ const pane = try p.setTestFile("one\n");
+ const id = p.view().active;
+ p.sync();
+ const rest = pane.tag_rows;
+ try std.testing.expect(rest > 1);
+ // A search prompt: a key cell in its head, no band under it.
+ p.update(.{ .key = .{ .cp = '/', .text = "/" } });
+ p.sync();
+ try std.testing.expectEqual(@as(u16, 0), pane.band_rows);
+ try std.testing.expectEqual(rest, pane.tag_rows);
+ var frame = std.heap.ArenaAllocator.init(std.testing.allocator);
+ defer frame.deinit();
+ const s = try p.render(frame.allocator());
+ const r = p.view().rects[id];
+ const tag_y = p.tagTop(pane, r);
+ 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 "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();