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 /test | |
| 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 'test')
| -rw-r--r-- | test/kitty.zig | 16 | ||||
| -rw-r--r-- | test/panes.zig | 26 | ||||
| -rw-r--r-- | test/perf.zig | 14 | ||||
| -rw-r--r-- | test/replicas.zig | 2 |
4 files changed, 28 insertions, 30 deletions
diff --git a/test/kitty.zig b/test/kitty.zig index 7b5347e0..4341677e 100644 --- a/test/kitty.zig +++ b/test/kitty.zig @@ -66,7 +66,7 @@ const Rig = struct { fn init(shells: u8) !Rig { // f=100 decodes through wuffs, its resize through stb_image_resize, // which the shells start at launch. - pardes.TerminalImages.start(gpa); + pardes.Term.start(gpa); // ghostty warns of every refused command; the refusals are the point. std.testing.log_level = .err; // A core boots one shell or the classic three. @@ -86,7 +86,7 @@ const Rig = struct { for (&r.read) |*b| b.deinit(gpa); r.frame.deinit(); r.p.deinit(); - pardes.TerminalImages.stop(); + pardes.Term.stop(); } fn drain(r: *Rig) void { @@ -642,14 +642,14 @@ test "kitty: an image follows its text when the shell scrolls, resizes and reflo try std.testing.expectEqual(o.y + 2, (try r.placesOf(10))[0].dst.y); // A narrower pane reflows the text; the image stays on its row. const pane = r.pane(0); - terminal.resizeGrid(pane, 40, pane.rows); + pane.resizeGrid(40, pane.rows); const text = try terminal.screenTextAlloc(pane, r.frame.allocator()); var row: usize = 0; var lines = std.mem.splitScalar(u8, text, '\n'); while (lines.next()) |line| : (row += 1) if (std.mem.startsWith(u8, line, "marker")) break; const drawn = try r.placesOf(10); try std.testing.expectEqual(@as(usize, 1), drawn.len); - const viewport_top: usize = @intCast(terminal.gridOffset(pane)); + const viewport_top: usize = pardes.Term.grid(pane.terminal).offset; try std.testing.expectEqual(o.y + @as(u16, @intCast(row - viewport_top)), drawn[0].dst.y); } @@ -822,7 +822,7 @@ test "kitty: an animation's frames play" { // Stopped (s=1), nothing more to wake for. r.feed(0, apc("a=a,i=70,s=1,q=2", "")); _ = try r.places(); - try std.testing.expectEqual(@as(?u64, null), terminal.animationDueMs(r.pane(0))); + try std.testing.expectEqual(@as(?u64, null), pardes.Term.due(r.pane(0).terminal.?)); } test "kitty: a placement relative to another (P=, Q=) is drawn at its parent's cell plus H/V" { @@ -1168,7 +1168,7 @@ fn fuzzRun(seed: u64, steps: usize, trace: bool) !bool { r.p.update(.{ .resize = .{ .cols = cols, .rows = rows, .cell_pixels = .{ .w = 1 + rng.uintLessThan(u16, 30), .h = 1 + rng.uintLessThan(u16, 60) } } }); r.drain(); }, - 1 => terminal.resizeGrid(r.pane(0), 1 + rng.uintLessThan(u16, 120), 1 + rng.uintLessThan(u16, 40)), + 1 => r.pane(0).resizeGrid(1 + rng.uintLessThan(u16, 120), 1 + rng.uintLessThan(u16, 40)), 2, 3 => { const drawn = try r.places(); if (trace) std.debug.print(" {d} places, {d} placements, {d} images\n", .{ drawn.len, r.placementCount(0), r.storage(0).images.count() }); @@ -1225,13 +1225,13 @@ test "kitty: scrolled back by pardes, an image shows on its row; scrolled forwar r.feed(0, &nl); try std.testing.expectEqual(@as(usize, 0), (try r.placesOf(20)).len); // Back to the top of the history: the marker row is the body's first. - terminal.scrollGrid(pane, -1000); + pardes.Term.scroll(pane.terminal.?, -1000); const o = r.origin(0); const drawn = try r.placesOf(20); try std.testing.expectEqual(@as(usize, 1), drawn.len); try std.testing.expectEqual(o.y, drawn[0].dst.y); try std.testing.expectEqual(o.x + 6, drawn[0].dst.x); - terminal.followOutput(pane); + pane.followOutput(); try std.testing.expectEqual(@as(usize, 0), (try r.placesOf(20)).len); } 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); diff --git a/test/perf.zig b/test/perf.zig index 205fcd24..b8514d26 100644 --- a/test/perf.zig +++ b/test/perf.zig @@ -315,12 +315,12 @@ fn measureCreation(io: std.Io, reps: usize, json: bool) !void { const allocator = counter.allocator(); const begin = nowNs(); const pane = if (terminal) - try pardes.panes.terminal.create(allocator, screen_cols, screen_rows) + try pardes.panes.createTerminal(allocator, screen_cols, screen_rows) else - try pardes.panes.terminal.createDoc(allocator, screen_cols, screen_rows); + try pardes.panes.createDoc(allocator, screen_cols, screen_rows); const constructed = nowNs(); const retained = counter.live; - pardes.panes.terminal.deinitEmulator(pane, allocator); + if (pane.terminal) |state| pardes.Term.close(state, allocator); allocator.destroy(pane); const destroyed = nowNs(); if (counter.live != 0) return error.LeakedPaneMemory; @@ -814,7 +814,7 @@ fn checkTerminalTail(core: *pardes.Pardes, surface: *pardes.Surface, batch: usiz const pane = core.panes[0] orelse return error.MissingTerminal; const rect = core.view().rects[0]; const x = rect.x + pardes.config.GUTTER; - const y = rect.y + pardes.BOX_H + pardes.panes.terminal.gridCursor(pane).y; + const y = rect.y + pardes.BOX_H + pardes.Term.grid(pane.terminal).cursor_y; var expected_buffer: [32]u8 = undefined; const expected = try std.fmt.bufPrint(&expected_buffer, "TURN {d:0>10} READY", .{batch}); for (expected, 0..) |byte, col| { @@ -889,7 +889,7 @@ fn measureUndoOutput(core: *pardes.Pardes, counter: *Allocations, arena: *std.he for (pane.body.ed_undo[0..pane.body.ed_undo_len]) |snapshot| if (snapshot.ovl) |overlay| core.gpa.free(overlay.text); pane.body.ed_undo_len = 0; } - pardes.panes.terminal.enterTty(core, 0); + pardes.keys.enterTty(core, 0); pump(core); const tracked_before = pages.countTrackedPins(); const start = try pages.trackPin(pages.pin(.{ .screen = .{ .y = @intCast(first) } }).?); @@ -1001,7 +1001,7 @@ fn measureTerminalSession(io: std.Io, mib: usize, reps: usize, json: bool) !void } const stream_wall_ns = nowNs() - stream_begin; const live_after_output = counter.live; - const first_row = @as(i32, @intCast(state.vt.screens.active.pages.scrollbar().offset)) + @as(i32, pardes.panes.terminal.gridCursor(pane).y); + const first_row = @as(i32, @intCast(state.vt.screens.active.pages.scrollbar().offset)) + @as(i32, pardes.Term.grid(pane.terminal).cursor_y); _ = arena.reset(.retain_capacity); const modal_begin = nowNs(); core.update(.{ .key = .{ .cp = core.opts.tty_toggle, .ctrl = true } }); @@ -1049,7 +1049,7 @@ fn measureTerminalSession(io: std.Io, mib: usize, reps: usize, json: bool) !void const begin = nowNs(); core.update(.{ .output = .{ .pane = 0, .bytes = update } }); pump(core); - const cursor_row = pardes.panes.terminal.gridOffset(pane) + @as(i32, pardes.panes.terminal.gridCursor(pane).y); + const cursor_row = @as(i32, @intCast(pardes.Term.grid(pane.terminal).offset)) + @as(i32, pardes.Term.grid(pane.terminal).cursor_y); pane.ovl.?.row = if (phase == 0) 0 else cursor_row - 1; pane.body.cur_row = pane.ovl.?.row; pane.body.cur_col = 0; diff --git a/test/replicas.zig b/test/replicas.zig index 56e08607..8035e051 100644 --- a/test/replicas.zig +++ b/test/replicas.zig @@ -516,7 +516,7 @@ fn sendUnit(q: *std.PriorityQueue(Msg, void, Msg.order), n: *u64, unit: []const } screens.filled(core); // The sizes its steps gave terminals, after their rows (Peers.unit). - pardes.panes.terminal.resizeDeferred(core); + pardes.panes.resizeDeferred(core); totals.unit_bytes += unit.len * down.len; if (flooding) totals.flood_unit_bytes += unit.len * down.len; for (down, 1..) |*l, who| { |
