summaryrefslogtreecommitdiff
path: root/test/panes.zig
diff options
context:
space:
mode:
authorGabriel Schneider <[email protected]>2026-11-17 00:25:48 -0300
committerGabriel Schneider <[email protected]>2026-11-17 12:15:01 -0300
commit9c2fc736b9ccd7b7eea11e7f544ed540d2d2a6c2 (patch)
treeac4270b4e90867228534c01647e8a0e755b58d4a /test/panes.zig
parent5354090b6122faf0d18e246a55e8a4ead0955394 (diff)
downloadpardes-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 'test/panes.zig')
-rw-r--r--test/panes.zig26
1 files changed, 12 insertions, 14 deletions
diff --git a/test/panes.zig b/test/panes.zig
index 001441a8..0a5674af 100644
--- a/test/panes.zig
+++ b/test/panes.zig
@@ -614,7 +614,7 @@ const TtySelectionTests = struct {
const pane = p.panes[0].?;
try std.testing.expectEqual(panes.Text.Mode.tty, pane.body.mode);
if (bracketed) p.update(.{ .output = .{ .pane = 0, .bytes = "\x1b[?2004h" } });
- try std.testing.expectEqual(bracketed, panes.terminal.bracketedPaste(pane));
+ try std.testing.expectEqual(bracketed, pardes.Term.modes(pane.terminal).bracketed_paste);
try p.registers.put(p.gpa, '"', "one\ntwo", 0, 1, true); // what a `y` anywhere left behind
var buf: [256]u8 = undefined;
_ = childInput(p, &buf);
@@ -972,7 +972,7 @@ test "terminal overlay recoloring never materializes unrelated history" {
_ = try p.render(frame.allocator());
try testing.expect(p.shell_rows.pane == null);
- pane.ovl.?.row = panes.terminal.gridOffset(pane);
+ pane.ovl.?.row = @intCast(pardes.Term.grid(pane.terminal).offset);
p.gpa.free(pane.ovl.?.text);
pane.ovl.?.text = try p.gpa.dupe(u8, "caf\xc3\xa9 \xe7\x95\x8c");
_ = frame.reset(.retain_capacity);
@@ -1001,9 +1001,9 @@ test "terminal output keeps following new rows after scrollback eviction" {
for (0..3) |phase| {
if (phase > 0) {
pane.body.mode = .normal;
- panes.terminal.scrollGrid(pane, -30);
+ pardes.Term.scroll(pane.terminal.?, -30);
try std.testing.expect(pages.scrollbar().offset < pages.scrollbar().total - pane.rows);
- panes.terminal.enterTty(p, 0);
+ pardes.keys.enterTty(p, 0);
}
for (phase * 20_000..(phase + 1) * 20_000) |n| {
var buf: [64]u8 = undefined;
@@ -1123,7 +1123,7 @@ test "terminal edits and undo survive partial history clearing and whole-screen
if (action == .hidden_undo) {
gpa.free(pane.ovl.?.text);
pane.ovl = null;
- panes.terminal.enterTty(p, 0);
+ pardes.keys.enterTty(p, 0);
}
const bytes = switch (action) {
.clear_history, .partial_clear_history => "\x1b[3J",
@@ -1171,12 +1171,12 @@ test "terminal lower scroll regions do not move edits above them" {
pane.body.cur_row = 1;
pane.body.cur_pinned = true;
try panes.terminal.pushUndo(p, pane);
- const total = panes.terminal.scrollbar(pane).total;
+ const total = pardes.Term.grid(pane.terminal).total;
var setup: [64]u8 = undefined;
const bytes = try std.fmt.bufPrint(&setup, "\x1b[4;{d}r\x1b[{d};1H", .{ pane.rows, pane.rows });
p.update(.{ .output = .{ .pane = 0, .bytes = bytes } });
p.update(.{ .output = .{ .pane = 0, .bytes = std.mem.asBytes(&@as([50][6]u8, @splat("tail\r\n".*))) } });
- try std.testing.expectEqual(total, panes.terminal.scrollbar(pane).total);
+ try std.testing.expectEqual(total, pardes.Term.grid(pane.terminal).total);
try std.testing.expectEqual(@as(i32, 1), pane.ovl.?.row);
try std.testing.expectEqual(@as(i32, 1), pane.body.cur_row);
try std.testing.expectEqual(@as(i32, 1), pane.body.ed_undo[0].ovl.?.row);
@@ -2322,11 +2322,9 @@ const TerminalTests = struct {
// Tests asserting raw ANSI indices explicitly select helix, whose palette
// is inherited. Native-palette coverage lives in the overlay/eviction and
// trailing-blank tests and checks their concrete RGB values instead.
- const gridOffset = panes.terminal.gridOffset;
- const scrollGrid = panes.terminal.scrollGrid;
const promptInputReady = panes.terminal.promptInputReady;
- const forwardKey = panes.terminal.forwardKey;
- const enterTty = panes.terminal.enterTty;
+ const forwardKey = pardes.keys.forwardKey;
+ const enterTty = pardes.keys.enterTty;
// Align normal-mode glyphs with the VT grid and compare their styles.
fn modeStyleDiffs(p: *Pardes, pane: *Pane, gpa: std.mem.Allocator, note: []const u8) !usize {
@@ -2699,14 +2697,14 @@ const TerminalTests = struct {
p.update(.{ .output = .{ .pane = 0, .bytes = bytes } });
}
p.shell_rows.stale = true;
- scrollGrid(pane, -20);
+ pardes.Term.scroll(pane.terminal.?, -20);
// ONE buffer line standing in for SIX shell rows: everything below slides
// UP five, so the last rows of the body resolve past the viewport's bottom
// edge. `PageList.pin` answers for those rows anyway — it walks down the
// pagelist, not the viewport — so without a bound of its own this pass
// painted the scrollback's colours onto rows the text pass left blank.
- const anchor = gridOffset(pane);
+ const anchor: i32 = @intCast(pardes.Term.grid(pane.terminal).offset);
pane.ovl = .{ .row = anchor, .rows = 6, .text = try p.gpa.dupe(u8, "one") };
p.shell_rows.stale = true;
@@ -2971,7 +2969,7 @@ const TerminalTests = struct {
// a buffer whose covered span STRADDLES the viewport top is an ordinary
// state. tty mode does not apply the buffer, so it must not be moved by one
// either — and `surfRow`/`gridRow` are not inverses across that span.
- const anchor = gridOffset(pane);
+ const anchor: i32 = @intCast(pardes.Term.grid(pane.terminal).offset);
pane.ovl = .{ .row = anchor - 1, .rows = 4, .text = try p.gpa.dupe(u8, "one\ntwo") };
p.shell_rows.stale = true;
_ = frame.reset(.retain_capacity);