diff options
| author | Gabriel Schneider <[email protected]> | 2026-11-17 00:25:48 -0300 |
|---|---|---|
| committer | Gabriel Schneider <[email protected]> | 2026-11-17 12:15:01 -0300 |
| commit | 9c2fc736b9ccd7b7eea11e7f544ed540d2d2a6c2 (patch) | |
| tree | ac4270b4e90867228534c01647e8a0e755b58d4a /src/Core.zig | |
| parent | 5354090b6122faf0d18e246a55e8a4ead0955394 (diff) | |
| download | pardes-9c2fc736b9ccd7b7eea11e7f544ed540d2d2a6c2.tar.gz pardes-9c2fc736b9ccd7b7eea11e7f544ed540d2d2a6c2.zip | |
Term: input through the interface: Term.key writes a key's bytes as its program's keyboard protocol and modes ask, Term.mouse and Term.wheel a mouse event's and a wheel turn's, Term.paste a paste as xterm makes one, Term.modes is the plain record of the modes the core decides by (mouse, all motion, the wheel, focus, bracketed paste, the alternate screen) and Term.promptMoves how far a click on the prompt line moves the shell's cursor; the mouse's records (MouseMods, MouseButton, MouseAction) are the interface's; keys.forwardKey (the bytes queued, an error reported) and keys.enterTty (raw mode, the cursor handed to the shell) are the core's, in keys.zig, pardes.keys for the tests; bracketedPaste, reportsMouse, reportsFocus, ownsWheel, tracksAllMotion and onAlternateScreen go into the record; the tests that called them follow; nothing else changes
Diffstat (limited to 'src/Core.zig')
| -rw-r--r-- | src/Core.zig | 22 |
1 files changed, 11 insertions, 11 deletions
diff --git a/src/Core.zig b/src/Core.zig index 2bf02c5d..700ab7ab 100644 --- a/src/Core.zig +++ b/src/Core.zig @@ -862,9 +862,9 @@ fn reportFocus(p: *Pardes) void { }; if (std.meta.eql(want, v.focus_told)) return; if (v.focus_told) |old| if (p.panes[old.id]) |pane| { - if (pane.serial == old.serial and pardes.panes.terminal.reportsFocus(pane)) p.emitWrite(old.id, "\x1b[O"); + if (pane.serial == old.serial and pardes.Term.modes(pane.terminal).focus) p.emitWrite(old.id, "\x1b[O"); }; - if (want) |new| if (pardes.panes.terminal.reportsFocus(p.panes[new.id].?)) p.emitWrite(new.id, "\x1b[I"); + if (want) |new| if (pardes.Term.modes(p.panes[new.id].?.terminal).focus) p.emitWrite(new.id, "\x1b[I"); v.focus_told = want; } @@ -3098,10 +3098,10 @@ test "a command pane shows how its command ended, and the next command there run // A program that crashed out of its full screen leaves the emulator // in its modes; the next command starts clear of them. p.update(.{ .output = .{ .pane = @intCast(dst), .bytes = "\x1b[?1049h\x1b[?2004h\x1b[?1000h" } }); - try std.testing.expect(pardes.panes.terminal.bracketedPaste(pane)); + try std.testing.expect(pardes.Term.modes(pane.terminal).bracketed_paste); // Done, the directory's next command runs there, below what it showed. try std.testing.expectEqual(@as(?usize, dst), exec.execute(p, 1, "make test")); - try std.testing.expect(!pardes.panes.terminal.bracketedPaste(pane)); + try std.testing.expect(!pardes.Term.modes(pane.terminal).bracketed_paste); var respawned = false; while (p.nextEffect()) |effect| if (effect == .spawn and effect.spawn.pane == dst) { respawned = true; @@ -3791,7 +3791,7 @@ test "an unasked desktop paste reaches a tty pane's program, not its buffer" { _ = test_api.ptyBytes(p, null, &buf); const pane = p.panes[0].?; - pardes.panes.terminal.enterTty(p, 0); + pardes.keys.enterTty(p, 0); // No request behind it: the window manager's own paste, or SDL answering a // Ctrl-Shift-V the desktop handled. It still has to reach the shell. p.update(.{ .paste = "ls -la" }); @@ -3808,7 +3808,7 @@ test "a paste larger than the effect ring reaches the program whole and in order const buf = try gpa.alloc(u8, 2 << 20); defer gpa.free(buf); _ = test_api.ptyBytes(p, null, buf); - pardes.panes.terminal.enterTty(p, 0); + pardes.keys.enterTty(p, 0); const text = try gpa.alloc(u8, 1536 * 1024); defer gpa.free(text); @@ -3842,10 +3842,10 @@ test "a bracketed paste larger than the ring still closes its bracket" { const buf = try gpa.alloc(u8, 2 << 20); defer gpa.free(buf); _ = test_api.ptyBytes(p, null, buf); - pardes.panes.terminal.enterTty(p, 0); + pardes.keys.enterTty(p, 0); p.update(.{ .output = .{ .pane = 0, .bytes = "\x1b[?2004h" } }); - try std.testing.expect(pardes.panes.terminal.bracketedPaste(p.panes[0].?)); + try std.testing.expect(pardes.Term.modes(p.panes[0].?.terminal).bracketed_paste); const text = try gpa.alloc(u8, 1536 * 1024); defer gpa.free(text); @memset(text, 'z'); @@ -3864,7 +3864,7 @@ test "a terminal's answer to its program waits behind the paste still queued for const buf = try gpa.alloc(u8, 2 << 20); defer gpa.free(buf); _ = test_api.ptyBytes(p, null, buf); - pardes.panes.terminal.enterTty(p, 0); + pardes.keys.enterTty(p, 0); const text = try gpa.alloc(u8, 1536 * 1024); defer gpa.free(text); @@ -3890,7 +3890,7 @@ test "pasted bytes still queued at shutdown are freed, not leaked" { const buf = try gpa.alloc(u8, 2 << 20); defer gpa.free(buf); _ = test_api.ptyBytes(p, null, buf); - pardes.panes.terminal.enterTty(p, 0); + pardes.keys.enterTty(p, 0); const text = try gpa.alloc(u8, 1536 * 1024); defer gpa.free(text); @@ -3995,7 +3995,7 @@ test "entering tty walks the shell cursor to the column clicked past the prompt" sp.body.cur_col = 3; sp.body.cur_pinned = true; while (p.nextEffect()) |_| {} - pardes.panes.terminal.enterTty(p, shell); + pardes.keys.enterTty(p, shell); // The walk is arrow keys the shell understands. Seven lefts: readline's // cursor sits past the '9' and the click was on the '3'. |
