summaryrefslogtreecommitdiff
path: root/core/Core.zig
diff options
context:
space:
mode:
Diffstat (limited to 'core/Core.zig')
-rw-r--r--core/Core.zig33
1 files changed, 21 insertions, 12 deletions
diff --git a/core/Core.zig b/core/Core.zig
index ae9ba52f..2b0a898d 100644
--- a/core/Core.zig
+++ b/core/Core.zig
@@ -950,8 +950,9 @@ fn reportFocus(p: *Pardes) void {
// A client's own step records what it told and writes nothing: the
// session's step makes the write, off the tape on both sides
// (tape.hostCall's pty_write), so the switch shows at once and the
- // program hears of it a round trip later.
- if (p.tape.speculating and p.tape.screen_state) return;
+ // program hears of it a round trip later (a write there would stop the
+ // speculation: pty_write is `keeps_stopping`'s).
+ if (p.tape.speculating) return;
if (v.focus_told) |old| if (p.panes[old.id]) |pane| {
if (pane.serial == old.serial and pardes.Term.modes(pane.terminal).focus) p.emitWrite(old.id, "\x1b[O");
};
@@ -1685,7 +1686,6 @@ fn updateInner(p: *Pardes, ev: Event) void {
pane.shell_spoke = true;
ctlfs.events.notePtyOutput(p, o.pane.index(), o.bytes);
pane.feedOutput(p, o.bytes);
- pane.term_images = if (p.tape.screen_state) p.tape.value(.images, pardes.Term.hasImages, .{pane.terminal}) else pardes.Term.hasImages(pane.terminal);
ctlfs.pty.noteMarks(p, o.pane.index(), pane);
exec.flushReplEnter(p, o.pane.index(), true);
},
@@ -2014,6 +2014,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 = (if (pane.sized_by) |k| p.views[k] orelse p.views[p.live].? else 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 {
@@ -2021,16 +2031,15 @@ fn typedInto(p: *Pardes) void {
}
/// Whether the live view sizes terminal `pane`: a terminal shown at two
-/// sizes takes the size of the view that typed into it last, and any
-/// view's once that one is gone. The others show it at that size, a
-/// shorter one passed down to its cursor (`Pane.pan`, Pane.panFor).
+/// sizes takes the size of the view that typed into it last, and keeps it
+/// once that view is gone until another types into it (views.dropView):
+/// a view nobody types in never takes it. The others show it at that
+/// size, a shorter one passed down to its cursor (`Pane.pan`,
+/// Pane.panFor).
// ponytail: a panned view's pointer reports to a terminal's program and
// its kitty images are placed as the unpanned rows are.
-fn sizes(p: *Pardes, pane: *Pane) bool {
- if (pane.sized_by == p.live) return true;
- if (Views.isOpen(p, pane.sized_by)) return false;
- pane.sized_by = p.live;
- return true;
+fn sizes(p: *const Pardes, pane: *const Pane) bool {
+ return pane.sized_by == p.live;
}
pub fn theme(p: *const Pardes) *const Theme {
@@ -2889,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.?;