diff options
Diffstat (limited to 'src/host_io.zig')
| -rw-r--r-- | src/host_io.zig | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/src/host_io.zig b/src/host_io.zig index 4ebac9ee..b138a840 100644 --- a/src/host_io.zig +++ b/src/host_io.zig @@ -1409,6 +1409,17 @@ fn exportWinid(serial: u32) void { /// The longest line a command pane runs (exec.zig refuses a longer one). pub const exec_command_max = pardes.exec.command_max; +/// A pane's pty size, in cells and in pixels: a program sizes its kitty +/// graphics by the pixels (yazi's previews; pardes nested in a pane). +pub fn ptyWinsize(core: ?*const pardes.Pardes, cols: u16, rows: u16) posix.winsize { + var ws: posix.winsize = .{ .row = rows, .col = cols, .xpixel = 0, .ypixel = 0 }; + if (comptime pardes.pdf_enabled) if (core) |c| { + ws.xpixel = std.math.cast(u16, @as(u32, cols) * c.cell_pixels.w) orelse 0; + ws.ypixel = std.math.cast(u16, @as(u32, rows) * c.cell_pixels.h) orelse 0; + }; + return ws; +} + pub fn forkShell( core: ?*pardes.Pardes, pane: usize, @@ -1493,7 +1504,7 @@ pub fn forkShell( .command else if (core) |c| (if (c.settings.pager == .off) .terminal_off else .terminal) else .terminal; const envp = ChildEnv.build(&env_slots, paging); - const ws = posix.winsize{ .row = rows, .col = cols, .xpixel = 0, .ypixel = 0 }; + const ws = ptyWinsize(core, cols, rows); // The child says here why it could not become the shell (its chdir or // its exec failed, as for a script whose interpreter is not there): the // pipe closes on exec, so the parent reads nothing when the shell runs, |
