summaryrefslogtreecommitdiff
path: root/test/panes.zig
diff options
context:
space:
mode:
Diffstat (limited to 'test/panes.zig')
-rw-r--r--test/panes.zig104
1 files changed, 49 insertions, 55 deletions
diff --git a/test/panes.zig b/test/panes.zig
index c1c2ef9b..45302b6f 100644
--- a/test/panes.zig
+++ b/test/panes.zig
@@ -32,45 +32,42 @@ const TagLayerTests = struct {
}
test "compact tag layers render and edit Unicode text beyond body column capacity" {
- for ([_]bool{ false, true }) |bottom| {
- const p = try Pardes.init(std.testing.allocator, .{ .tty_only = true, .cols = 40, .rows = 16 });
- defer p.deinit();
- const pane = try p.setTestFile("body\n");
- p.settings.tag_bottom = bottom;
- p.row_metrics = .{ .body_w = 10, .body_h = 20, .tagline_w = 5, .tagline_h = 10 };
- p.gpa.free(pane.file.?.path);
- pane.file.?.path = try p.gpa.dupe(u8, "/x");
- try setTag(pane, " " ++ &@as([38]u8, @splat('a')) ++ "\t界 END");
- var frame = std.heap.ArenaAllocator.init(p.gpa);
- defer frame.deinit();
- _ = try p.render(frame.allocator());
- const layer = try findLayer(p, .pane, 0);
- const text = try pardes.tagline.tagText(p, frame.allocator(), pane);
- const at = std.mem.indexOf(u8, text, "END").?;
- const col = panes.File.displayWidth(text[0..at]);
- try std.testing.expect(col > p.rects[0].w);
- try std.testing.expect(col + 3 < layer.cols);
- try std.testing.expectEqualStrings("E", layer.cells[col].grapheme());
- try std.testing.expectEqual(@as(u16, 0), pane.tag_scroll);
- const x = @as(f32, @floatFromInt(layer.viewport.x)) * 10 + (@as(f32, @floatFromInt(col)) + 0.5) * 5;
- var stale = mouse(layer, x, .press);
- stale.tag_hit.?.serial +%= 1;
- p.update(.{ .mouse = stale });
- try std.testing.expect(pane.focus == .body);
- p.update(.{ .mouse = mouse(layer, x, .press) });
- p.update(.{ .mouse = mouse(layer, x, .release) });
- try std.testing.expect(pane.focus == .tag);
- try std.testing.expectEqual(at, @as(usize, @intCast(pane.tag.cur_col)));
- // A clicked tag is in normal mode: `i` types where it was clicked.
- p.update(.{ .key = .{ .cp = 'i', .text = "i" } });
- p.update(.{ .key = .{ .cp = 'X', .text = "X" } });
- _ = try p.render(frame.allocator());
- const edited = try pardes.tagline.tagText(p, frame.allocator(), pane);
- try std.testing.expect(std.mem.endsWith(u8, edited, "界 XEND"));
- try std.testing.expectEqual(@as(u16, 0), pane.tag_scroll);
- try std.testing.expectEqualStrings("body\n", pane.file.?.content);
- p.update(.{ .key = .{ .cp = Key.escape } });
- }
+ const p = try Pardes.init(std.testing.allocator, .{ .tty_only = true, .cols = 40, .rows = 16 });
+ defer p.deinit();
+ const pane = try p.setTestFile("body\n");
+ p.row_metrics = .{ .body_w = 10, .body_h = 20, .tagline_w = 5, .tagline_h = 10 };
+ p.gpa.free(pane.file.?.path);
+ pane.file.?.path = try p.gpa.dupe(u8, "/x");
+ try setTag(pane, " " ++ &@as([38]u8, @splat('a')) ++ "\t界 END");
+ var frame = std.heap.ArenaAllocator.init(p.gpa);
+ defer frame.deinit();
+ _ = try p.render(frame.allocator());
+ const layer = try findLayer(p, .pane, 0);
+ const text = try pardes.tagline.tagText(p, frame.allocator(), pane);
+ const at = std.mem.indexOf(u8, text, "END").?;
+ const col = panes.File.displayWidth(text[0..at]);
+ try std.testing.expect(col > p.rects[0].w);
+ try std.testing.expect(col + 3 < layer.cols);
+ try std.testing.expectEqualStrings("E", layer.cells[col].grapheme());
+ try std.testing.expectEqual(@as(u16, 0), pane.tag_scroll);
+ const x = @as(f32, @floatFromInt(layer.viewport.x)) * 10 + (@as(f32, @floatFromInt(col)) + 0.5) * 5;
+ var stale = mouse(layer, x, .press);
+ stale.tag_hit.?.serial +%= 1;
+ p.update(.{ .mouse = stale });
+ try std.testing.expect(pane.focus == .body);
+ p.update(.{ .mouse = mouse(layer, x, .press) });
+ p.update(.{ .mouse = mouse(layer, x, .release) });
+ try std.testing.expect(pane.focus == .tag);
+ try std.testing.expectEqual(at, @as(usize, @intCast(pane.tag.cur_col)));
+ // A clicked tag is in normal mode: `i` types where it was clicked.
+ p.update(.{ .key = .{ .cp = 'i', .text = "i" } });
+ p.update(.{ .key = .{ .cp = 'X', .text = "X" } });
+ _ = try p.render(frame.allocator());
+ const edited = try pardes.tagline.tagText(p, frame.allocator(), pane);
+ try std.testing.expect(std.mem.endsWith(u8, edited, "界 XEND"));
+ try std.testing.expectEqual(@as(u16, 0), pane.tag_scroll);
+ try std.testing.expectEqualStrings("body\n", pane.file.?.content);
+ p.update(.{ .key = .{ .cp = Key.escape } });
}
test "compact tag pointer keeps physical grips and adjacent header ownership" {
@@ -838,22 +835,19 @@ const TagNameTintTests = struct {
// A file pane's is test/behaviour/tags.zig's; a search pane's needs
// results put in through fillResults.
test "tag filename tint of a search pane excludes its directory and command" {
- for ([_]bool{ false, true }) |bottom| {
- const p = try Pardes.init(std.testing.allocator, .{ .tty_only = true, .cols = 100, .rows = 24 });
- defer p.deinit();
- p.locations_config.layout = .@"inline";
- const pane = try p.setTestFile("body\n");
- p.gpa.free(pane.file.?.path);
- pane.file.?.path = try p.gpa.dupe(u8, "/project/界file.zig");
- pane.file.?.revision += 1;
- configure(p);
- defer p.custom_theme = null;
- p.settings.tag_bottom = bottom;
- try panes.Output.fillResults(p, 0, "/project", .search, "tint", try p.gpa.dupe(u8, "no matches\n"), null);
- const id = pane.search_pane.?;
- p.update(.tick);
- try std.testing.expect((try check(p, id, p.panes[id].?.file.?.path)) > 0);
- }
+ const p = try Pardes.init(std.testing.allocator, .{ .tty_only = true, .cols = 100, .rows = 24 });
+ defer p.deinit();
+ p.locations_config.layout = .@"inline";
+ const pane = try p.setTestFile("body\n");
+ p.gpa.free(pane.file.?.path);
+ pane.file.?.path = try p.gpa.dupe(u8, "/project/界file.zig");
+ pane.file.?.revision += 1;
+ configure(p);
+ defer p.custom_theme = null;
+ try panes.Output.fillResults(p, 0, "/project", .search, "tint", try p.gpa.dupe(u8, "no matches\n"), null);
+ const id = pane.search_pane.?;
+ p.update(.tick);
+ try std.testing.expect((try check(p, id, p.panes[id].?.file.?.path)) > 0);
}
test "tag filename tint follows wrapped Unicode drafted names and yields to selection" {