summaryrefslogtreecommitdiff
path: root/test/panes.zig
diff options
context:
space:
mode:
authorGabriel Schneider <[email protected]>2026-09-22 09:31:11 -0300
committerGabriel Schneider <[email protected]>2026-10-01 00:12:14 -0300
commita1d5ee19a648abc65b557dffa14a3b2f70577286 (patch)
treeef36c11168bcc2f7bbb9b7a6a29519c7e0882fab /test/panes.zig
parent43b9d696f9e25ad7589527b91a74666e71ff0472 (diff)
downloadpardes-a1d5ee19a648abc65b557dffa14a3b2f70577286.tar.gz
pardes-a1d5ee19a648abc65b557dffa14a3b2f70577286.zip
Notices become chips that float over the body, not rows taken from it
A notice is an overlay now, which is the one place it is NOT like the tree-sitter context: it takes no row from the body and moves no text. Each one is a chip as wide as its own message plus a blank cell either side, anchored to the pane right edge on the body top rows. The rest of each of those rows is ordinary body text that still reads and still answers a click -- Notices.left records where each chip starts, and the hit test refuses only the cells it covers rather than the whole row. The width is counted in GRID columns rather than scaled into the tagline face the chip is drawn in, because the canonical grid is what a terminal client draws and a chip narrower than its own text there would clip it; the narrower tagline face simply leaves a little more room inside the chip. The tag layer takes the geometry the grid pass already chose, so the two cannot disagree and the GUI skipping the cells a tag layer covers leaves no stub behind. Pane.body_offset is gone with the reservation it existed for, and bodyTop takes only a rect. The body layer keeps every row it had, the scrollbar runs the full body again, and the GUI smooth-scroll extents go back to the pane. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Diffstat (limited to 'test/panes.zig')
-rw-r--r--test/panes.zig26
1 files changed, 11 insertions, 15 deletions
diff --git a/test/panes.zig b/test/panes.zig
index 69628cd9..8e71e69d 100644
--- a/test/panes.zig
+++ b/test/panes.zig
@@ -468,7 +468,7 @@ const TreeContextTests = struct {
try std.testing.expectEqual(@as(i32, 59), pane.wrapAt(visible.row).line);
const cursor = surface.cursor orelse return error.MissingLookCursor;
const rect = p.rects[0];
- const y = p.bodyTop(pane, rect);
+ const y = p.bodyTop(rect);
try std.testing.expectEqual(y + @as(u16, @intCast(visible.row)), cursor.y);
}
}
@@ -490,7 +490,7 @@ const TreeContextTests = struct {
try std.testing.expectEqual(@as(i32, 7), pane.wrapAt(pane.context_rows).line);
const rect = p.rects[0];
const x = rect.x + config.GUTTER + panes.File.gutterWidth(pane);
- const y = p.bodyTop(pane, rect);
+ const y = p.bodyTop(rect);
ClickCursorTests.click(p, .left, x + 6, y);
try std.testing.expectEqual(@as(i32, 0), pane.cur_row);
try std.testing.expectEqual(@as(i32, 6), pane.cur_col);
@@ -499,7 +499,7 @@ const TreeContextTests = struct {
try std.testing.expectEqual(x + 6, cursor.x);
// Read the body top again: the click cleared the announcement band the
// builtin above put up, and the body moved back up with it.
- try std.testing.expectEqual(p.bodyTop(pane, p.rects[0]), cursor.y);
+ try std.testing.expectEqual(p.bodyTop(p.rects[0]), cursor.y);
p.update(.{ .key = .{ .cp = 'i' } });
p.update(.{ .key = .{ .cp = 'Z', .text = "Z" } });
try std.testing.expect(std.mem.startsWith(u8, pane.file.?.content, "const ZBox = struct {"));
@@ -538,7 +538,7 @@ const TreeContextTests = struct {
const surface = try p.render(frame.allocator());
try std.testing.expectEqual(@as(u16, 3), pane.context_rows);
const rect = p.rects[0];
- const y = p.bodyTop(pane, rect);
+ const y = p.bodyTop(rect);
var glyph_x: ?u16 = null;
for (0..surface.cols) |col| {
if (std.mem.eql(u8, surface.at(@intCast(col), y).grapheme(), "界")) glyph_x = @intCast(col);
@@ -552,7 +552,7 @@ const TreeContextTests = struct {
try std.testing.expectEqual(x, cursor.x);
// Read the body top again: the click cleared the announcement band the
// builtin above put up, so the body moved with it.
- try std.testing.expectEqual(p.bodyTop(pane, p.rects[0]), cursor.y);
+ try std.testing.expectEqual(p.bodyTop(p.rects[0]), cursor.y);
panes.File.setContent(p, &pane.file.?, try p.gpa.dupe(u8, "// no enclosing declaration\n" ** 18));
_ = try p.render(frame.allocator());
try std.testing.expectEqual(@as(u16, 0), pane.context_rows);
@@ -580,16 +580,12 @@ const TreeContextTests = struct {
target = .{ .x = @intCast(col), .y = @intCast(row) };
};
const glyph = target orelse return error.MissingWrappedContextBody;
- const offset = pane.body_offset;
ClickCursorTests.click(p, .left, glyph.x + 1, glyph.y);
try std.testing.expectEqual(@as(i32, 2), pane.cur_row);
try std.testing.expectEqual(@as(i32, @intCast(std.mem.indexOf(u8, body, "界").?)), pane.cur_col);
const cursor = (try p.render(frame.allocator())).cursor orelse return error.MissingContextBodyCursor;
try std.testing.expectEqual(glyph.x, cursor.x);
- // The scan above ran with the builtin's announcement band up; the click
- // cleared it, so the row the glyph was found on has moved up with the
- // body it belongs to.
- try std.testing.expectEqual(glyph.y - offset, cursor.y);
+ try std.testing.expectEqual(glyph.y, cursor.y);
}
};
@@ -615,7 +611,7 @@ const TtySelectionTests = struct {
_ = try p.render(frame.allocator());
const rect = p.rects[0];
const x = rect.x + config.GUTTER;
- const y = p.bodyTop(pane, rect);
+ const y = p.bodyTop(rect);
JumpSelectionTests.drag(p, x + 1, y, x + 3, y);
try std.testing.expectEqualStrings("lph", p.yank orelse return error.MissingAutomaticTtyYank);
p.update(.{ .key = .{ .cp = p.opts.tty_toggle, .ctrl = true } });
@@ -645,7 +641,7 @@ const TtySelectionTests = struct {
_ = try p.render(frame.allocator());
const rect = p.rects[0];
const x = rect.x + config.GUTTER;
- const y = p.bodyTop(pane, rect);
+ const y = p.bodyTop(rect);
JumpSelectionTests.drag(p, x + @as(u16, if (prompt) 0 else 1), y, x + 3, y + @as(u16, if (prompt) 0 else 1));
const expected = if (prompt) "$ ab" else "lph\nrav";
try std.testing.expectEqual(Pane.Mode.tty, pane.mode);
@@ -960,7 +956,7 @@ const JumpSelectionTests = struct {
if (wrap) try std.testing.expectEqual(pane.wrap_line[0], pane.wrap_line[1]);
const rect = p.rects[0];
const x = rect.x + config.GUTTER + panes.File.gutterWidth(pane);
- const y = p.bodyTop(pane, rect);
+ const y = p.bodyTop(rect);
if (reverse)
drag(p, x + last_col, y + 1, x + first_col, y)
else
@@ -991,7 +987,7 @@ const JumpSelectionTests = struct {
// A selection created after Back must also disappear on Forward.
// Back announces itself, so the body sits under a notice band now.
- const y2 = p.bodyTop(pane, p.rects[0]);
+ const y2 = p.bodyTop(p.rects[0]);
drag(p, x + 1, y2, x + 3, y2 + 1);
try std.testing.expect(pardes.test_api.heldSelection(p, 0) != null);
p.update(.{ .key = .{ .cp = 'i', .ctrl = true } });
@@ -4127,7 +4123,7 @@ test "cancelled normal gestures leave no count or subprefix after mouse and focu
.body, .tag => {
const rect = p.rects[0];
const tag_y = if (p.settings.tag_bottom) rect.y + rect.h - pardes.BOX_H else rect.y;
- const body_y = p.bodyTop(pane, rect);
+ const body_y = p.bodyTop(rect);
const x = rect.x + config.GUTTER + @as(u16, @intCast(panes.File.gutterWidth(pane))) + 3;
const y = if (gesture == .tag) tag_y else body_y;
p.update(.{ .mouse = .{ .button = config.select_button, .kind = .press, .col = x, .row = y } });