diff options
| author | Gabriel Schneider <[email protected]> | 2026-11-22 14:14:39 -0300 |
|---|---|---|
| committer | Gabriel Schneider <[email protected]> | 2026-11-22 15:36:59 -0300 |
| commit | b0e96978b619e1111ee2fb30e3c4a48f9fac38b3 (patch) | |
| tree | da0c3c266b52c84ab6d96f1652f17b80effab342 /runtime | |
| parent | 85e793ae92683808d14433cb7c99ccdab4c967dc (diff) | |
| download | pardes-b0e96978b619e1111ee2fb30e3c4a48f9fac38b3.tar.gz pardes-b0e96978b619e1111ee2fb30e3c4a48f9fac38b3.zip | |
pty: a shell forks at its pane's grid, and the core hands its host every pty's size, pixels too (pardes-term-join-9, item 2 (B), points (a) and (c)): the spawn host call took no size and both hosts forked at the session's live screen (dev/Ptys.zig `spawn`, runtime/macos.zig `spawnShell`: `core.view().screen_h/w`), so a shell started again into a pane already sized (pty/ctl's exec, a finished command pane run again by exec.zig `runCommand`, a Restore's `revivePane`) ran at the screen's size and nothing resized it, the grid unchanged and `sync` emitting nothing (`stty size` said 50 160 in a 44x158 pane); and a pty's pixels were the live view's (host_io.zig `ptyWinsize` read `core.view().cell_pixels`) whichever view sized it; now `Effect.PtySize` (cells and pixels) is what the core gives its host for `spawn` and `pty_resize`, made by `Core.ptySize` from the pane's grid (or 9P's numbers) at the cell of the view that sizes it, a spawn performed after its step's `sync` reading the laid-out grid, and the hosts fork and size from it alone (`Ptys.take` sizes an adopted shell from it too: 1x1 then the size, once, its forced redraw kept, an ioctl to the size a pty has already sending no SIGWINCH); test (test/process/terminals.zig, a new case): a Term pane's shell, the same shell started again by pty/ctl's exec and a finished command pane run again each say the grid their pty/ctl reads back (fails on the base: 50 160 against 44 158); not covered: a new command pane made over 9P is placed a step after its fork, so its first size can still be the screen's
Co-Authored-By: Claude Opus <[email protected]>
Claude-Session: https://claude.ai/code/session_016Y9MNBECMWcJD5pdS4SR6T
Diffstat (limited to 'runtime')
| -rw-r--r-- | runtime/macos.zig | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/runtime/macos.zig b/runtime/macos.zig index 23d70b27..3221737a 100644 --- a/runtime/macos.zig +++ b/runtime/macos.zig @@ -1649,14 +1649,14 @@ fn hostState(ctx: ?*anyopaque) *State { return @ptrCast(@alignCast(ctx.?)); } -fn spawnShell(ctx: ?*anyopaque, id: pardes.Pane.Id, cwd: []const u8) void { +fn spawnShell(ctx: ?*anyopaque, id: pardes.Pane.Id, cwd: []const u8, size: pardes.PtySize) void { const pane = id.index(); const st = hostState(ctx); const core = st.core; // The new shell starts before a running one goes: one that cannot // start leaves the running one be (pty/ctl's exec). const running = st.ptys[pane] != null; - const child = host_io.forkShell(core, pane, &st.prompt_rcs, core.shellBin(), cwd, core.view().screen_h, core.view().screen_w) catch |err| { + const child = host_io.forkShell(core, pane, &st.prompt_rcs, core.shellBin(), cwd, size) catch |err| { if (running) return core.restartFailed(id, err); return core.shellFailed(id, err); }; @@ -1685,11 +1685,11 @@ fn ptyWrite(ctx: ?*anyopaque, id: pardes.Pane.Id, bytes: []const u8) void { if (st.ptys[pane]) |pt| _ = host_io.writeFd(pt.file.handle, bytes); } -fn ptyResize(ctx: ?*anyopaque, id: pardes.Pane.Id, cols: u16, rows: u16) void { +fn ptyResize(ctx: ?*anyopaque, id: pardes.Pane.Id, size: pardes.PtySize) void { const pane = id.index(); const st = hostState(ctx); const pt = st.ptys[pane] orelse return; - const ws: posix.winsize = .{ .row = rows, .col = cols, .xpixel = 0, .ypixel = 0 }; + const ws = host_io.ptyWinsize(size); _ = posix.system.ioctl(pt.file.handle, TIOCSWINSZ, @intFromPtr(&ws)); } @@ -2339,7 +2339,7 @@ test "mac Restore cancels a PTY reader waiting for output capacity" { while (st.core.nextEffect()) |_| {} st.inbox.acceptReader(.at(1), 1); for (0..Inbox.output_capacity) |_| _ = st.inbox.pushOutput(.at(1), 1, try gpa.dupe(u8, "retained output")); - const child = try host_io.forkShell(null, 0, &st.prompt_rcs, "/bin/sh", "", 12, 40); + const child = try host_io.forkShell(null, 0, &st.prompt_rcs, "/bin/sh", "", .{ .cols = 40, .rows = 12 }); st.gens[0] = 1; st.ptys[0] = .{ .file = child.file, .pid = child.pid, .gen = 1, .reader = .{ .any_future = null, .result = {} } }; defer { |
