summaryrefslogtreecommitdiff
path: root/core/Core.zig
diff options
context:
space:
mode:
Diffstat (limited to 'core/Core.zig')
-rw-r--r--core/Core.zig12
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.?;