From 5354090b6122faf0d18e246a55e8a4ead0955394 Mon Sep 17 00:00:00 2001 From: Gabriel Schneider Date: Tue, 17 Nov 2026 00:17:45 -0300 Subject: Term: output and view through the interface: Term.feed takes one read and the rows the core keeps positions on and gives back a Term.Told (where each went, erased or not, cleared, alive, a pin missed), Term.grid is the plain record of the view and the cursor (total, offset, len, the cursor, whether it shows, the view's row or null while it follows), Term.scroll, Term.follow, Term.viewTo, Term.resize (now or for later) and Term.resizeDeferred move it, Term.cellPixels sizes its cells in pixels and Term.replies hands over what it answered its program; the core's half is the core's: Pane.feedOutput and its row tracking (the edit copy's rows, the cursors and selections, their undo and the pointer's rows, gathered as rows and moved as the feed told, ingestWithPositions's core) and Pane.followOutput, Pane.resizeGrid and Pane.panFor in panes.zig with panes.resizeDeferred, the cursor a program shows read from the grid where the body draws it, tape.viewOnly beside tape.authorityOnly; scrollbar, gridOffset, gridCursor, visibleCursor, viewOf, atBottom and their types go; nothing else changes --- src/dump.zig | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) (limited to 'src/dump.zig') diff --git a/src/dump.zig b/src/dump.zig index 19ba25ce..075bb8cc 100644 --- a/src/dump.zig +++ b/src/dump.zig @@ -1002,12 +1002,13 @@ test "a loaded terminal's history stays above its banner, the cursor where it wa const p = try Pardes.init(gpa, .{ .tty_only = true, .cols = 40, .rows = 12 }); defer p.deinit(); while (p.nextEffect()) |_| {} - term.feedOutput(p, p.panes[0].?, "one\r\ntwo\r\n$ "); - const before = term.gridCursor(p.panes[0].?); + p.panes[0].?.feedOutput(p, "one\r\ntwo\r\n$ "); + const before = pardes.Term.grid(p.panes[0].?.terminal); try dumpState(p); const loaded = try load(gpa, .{ .tty_only = true, .cols = 40, .rows = 12 }, p.dump_out.?, null); defer loaded.deinit(); - try std.testing.expectEqual(before, term.gridCursor(loaded.panes[0].?)); + const after = pardes.Term.grid(loaded.panes[0].?.terminal); + try std.testing.expectEqual([2]u16{ before.cursor_x, before.cursor_y }, [2]u16{ after.cursor_x, after.cursor_y }); const q = try initFromDump(gpa, .{ .tty_only = true, .cols = 40, .rows = 12 }, p.dump_out.?); defer q.deinit(); const text = try term.screenTextAlloc(q.panes[0].?, gpa); @@ -1019,11 +1020,10 @@ test "a loaded terminal's history stays above its banner, the cursor where it wa test "an upgraded session's dump keeps its views and its running terminal as they were, and settings the startup config would change" { if (comptime isolated) return error.SkipZigTest; const gpa = std.testing.allocator; - const term = pardes.panes.terminal; const p = try Pardes.init(gpa, .{ .tty_only = true, .cols = 40, .rows = 12, .startup_config = "Verbose off\n" }); defer p.deinit(); while (p.nextEffect()) |_| {} - term.feedOutput(p, p.panes[0].?, "one\r\n\x1b[?1049h$ vim"); + p.panes[0].?.feedOutput(p, "one\r\n\x1b[?1049h$ vim"); try std.testing.expect(p.executeBuiltinLine(p.view().active, "Verbose on")); _ = p.openView().?; const bytes = try dumpBytes(p); @@ -1035,7 +1035,9 @@ test "an upgraded session's dump keeps its views and its running terminal as the try std.testing.expectEqual(@as(usize, 2), views.count(q)); try std.testing.expect(q.settings.verbose); // The program's own screen, no banner, and no shell asked for. - try std.testing.expectEqual(term.gridCursor(p.panes[0].?), term.gridCursor(q.panes[0].?)); + const was = pardes.Term.grid(p.panes[0].?.terminal); + const is = pardes.Term.grid(q.panes[0].?.terminal); + try std.testing.expectEqual([2]u16{ was.cursor_x, was.cursor_y }, [2]u16{ is.cursor_x, is.cursor_y }); try std.testing.expect(q.panes[0].?.terminal.?.vt.screens.active_key == .alternate); while (q.nextEffect()) |e| try std.testing.expect(e != .spawn); // Not kept, the same terminal is a new shell's under its history. -- cgit v1.3