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 /core/Core.zig | |
| 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 'core/Core.zig')
| -rw-r--r-- | core/Core.zig | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/core/Core.zig b/core/Core.zig index 91f647d4..8616aa35 100644 --- a/core/Core.zig +++ b/core/Core.zig @@ -2013,6 +2013,16 @@ pub fn sync(p: *Pardes) void { tagline.revealHeader(p); } +/// Pane `id`'s pty as its host is to size it: its grid (or `cells`, a +/// size 9P's pty/ctl gave), in pixels at the cell of the view that sizes +/// it: a program sizes its kitty graphics by them. +pub fn ptySize(p: *const Pardes, id: Pane.Id, cells: ?[2]u16) pardes.PtySize { + const pane = p.panes[id.index()] orelse return .{ .cols = 1, .rows = 1 }; + const c = cells orelse .{ pane.cols, pane.rows }; + const cell = (p.views[pane.sized_by] orelse p.views[p.live].?).cell_pixels; + return .{ .cols = @max(c[0], 1), .rows = @max(c[1], 1), .w_px = std.math.cast(u16, @as(u32, c[0]) * cell.w) orelse 0, .h_px = std.math.cast(u16, @as(u32, c[1]) * cell.h) orelse 0 }; +} + /// The view typing goes into is the one its terminal is sized for /// (`sizes`). fn typedInto(p: *Pardes) void { @@ -2888,7 +2898,7 @@ test "a spawn is for the pane it was made for, not whatever took the slot since" var command: [32]u8 = undefined; var core: *Pardes = undefined; const vtable: Host.VTable = .{ .spawn = spawn }; - fn spawn(_: ?*anyopaque, id: pardes.Pane.Id, _: []const u8) void { + fn spawn(_: ?*anyopaque, id: pardes.Pane.Id, _: []const u8, _: pardes.PtySize) void { const pane = id.index(); spawns += 1; const line = core.panes[pane].?.command.?; |
