summaryrefslogtreecommitdiff
path: root/test/hxdiff.zig
diff options
context:
space:
mode:
Diffstat (limited to 'test/hxdiff.zig')
-rw-r--r--test/hxdiff.zig32
1 files changed, 9 insertions, 23 deletions
diff --git a/test/hxdiff.zig b/test/hxdiff.zig
index 62638e23..2170961e 100644
--- a/test/hxdiff.zig
+++ b/test/hxdiff.zig
@@ -30,9 +30,7 @@
// text always ends in one, so this restores byte-for-byte comparability.
// Keys are helix notation: printables verbatim, <esc> <ret> <tab> <space>
// <backspace> <del> <up/down/left/right> <home/end> <pageup/pagedown>
-// <C-x> <A-x> <lt> <gt>. The clipboard round-trips through a fake:
-// set_clipboard stores the core's yank register, get_clipboard answers with
-// Event.paste, so y-then-p behaves like a live session.
+// <C-x> <A-x> <lt> <gt>.
const std = @import("std");
const libc = std.c;
const pardes = @import("pardes");
@@ -182,9 +180,8 @@ fn runCase(arena: std.mem.Allocator, case: Case) !Result {
// greeting. Live-session contract: sizes arrive as the first resize event.
const core = try pardes.Pardes.init(gpa, .{ .tty_only = true });
defer core.deinit();
- var clip: []const u8 = "";
core.update(.{ .resize = .{ .cols = 80, .rows = 24 } });
- pump(core, arena, &clip);
+ pump(core);
if (std.mem.eql(u8, case.pane, "file")) {
_ = try core.hxOpenFileContent(case.text);
@@ -196,13 +193,13 @@ fn runCase(arena: std.mem.Allocator, case: Case) !Result {
try cooked.append(arena, ch);
}
core.update(.{ .output = .{ .pane = 0, .bytes = cooked.items } });
- pump(core, arena, &clip);
+ pump(core);
// leave tty mode the way a live session does: Ctrl-<tty_toggle>,
// then park the cursor at (0,0) — the helix harness's initial
// Selection::single(0,1) equivalent (a live exit would leave the
// modal cursor tracking the shell cursor below the output)
core.update(.{ .key = .{ .cp = core.opts.tty_toggle, .ctrl = true } });
- pump(core, arena, &clip);
+ pump(core);
if (core.panes[core.active]) |pane| {
pane.cur_row = 0;
pane.cur_col = 0;
@@ -273,7 +270,7 @@ fn runCase(arena: std.mem.Allocator, case: Case) !Result {
ki += 1;
}
core.update(.{ .key = key });
- pump(core, arena, &clip);
+ pump(core);
}
// one contract result line off the active pane's final state
@@ -313,21 +310,10 @@ fn runCase(arena: std.mem.Allocator, case: Case) !Result {
};
}
-/// Drain queued effects. The fake clipboard: set_clipboard snapshots the
-/// core's yank register, get_clipboard answers with Event.paste — the async
-/// OSC 52 round trip of a live shell, collapsed to a synchronous reply.
-/// Everything else (spawn, write, resize_pty, ...) is ignored: no real pty.
-fn pump(core: *pardes.Pardes, arena: std.mem.Allocator, clip: *[]const u8) void {
- while (true) {
- var want_paste = false;
- while (core.nextEffect()) |eff| switch (eff) {
- .set_clipboard => clip.* = if (core.yank) |y| (arena.dupe(u8, y) catch "") else "",
- .get_clipboard => want_paste = true,
- else => {},
- };
- if (!want_paste) return;
- core.update(.{ .paste = clip.* });
- }
+/// Drain queued effects, all ignored (spawn, write, resize_pty, ...): no
+/// real pty, and p/P read the core's own yank register.
+fn pump(core: *pardes.Pardes) void {
+ while (core.nextEffect()) |_| {}
}
fn readFileAlloc(arena: std.mem.Allocator, path: []const u8) ![]u8 {