summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGabriel Schneider <[email protected]>2026-11-22 14:14:40 -0300
committerGabriel Schneider <[email protected]>2026-11-22 15:36:59 -0300
commit9041c9d48326ac13e30ffbb0d6df636cc058c6dc (patch)
treeb2487a0824cb691d469afde843ee1039a9501b67
parentb0e96978b619e1111ee2fb30e3c4a48f9fac38b3 (diff)
downloadpardes-9041c9d48326ac13e30ffbb0d6df636cc058c6dc.tar.gz
pardes-9041c9d48326ac13e30ffbb0d6df636cc058c6dc.zip
views: a closed view sizes no terminal, and none takes its size until a view types into it (pardes-term-join-9, item 2 (B), point (b)): `sizes` handed a terminal whose sizing view had closed to whichever view was live at the next `sync`, a view nobody looks at among them, and a client given the closed view's index later sized it without typing; now `Pane.sized_by` is `?u8`, `views.dropView` clears it (the terminal keeps the size it has), `closeKeeping` hands it to the view that takes the closing one's place (the session's own laid out as it was: the size it promised to keep), and `sizes` is `sized_by == live` alone, typing (`typedInto`) the one act that moves it; test (core/views.zig "a terminal shown at two sizes ...", extended): the pty's pixels at the sizing view's cell whichever view is live (point (c) of the change before); the sizing view closed, the size stays until the view left types; a view opened at the closed index sizes nothing until it types (on the base the size moved at the close)
Co-Authored-By: Claude Opus <[email protected]> Claude-Session: https://claude.ai/code/session_016Y9MNBECMWcJD5pdS4SR6T
-rw-r--r--core/Core.zig17
-rw-r--r--core/panes.zig7
-rw-r--r--core/views.zig25
3 files changed, 35 insertions, 14 deletions
diff --git a/core/Core.zig b/core/Core.zig
index 8616aa35..1dd03524 100644
--- a/core/Core.zig
+++ b/core/Core.zig
@@ -2019,7 +2019,7 @@ pub fn sync(p: *Pardes) void {
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;
+ 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 };
}
@@ -2030,16 +2030,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 {
diff --git a/core/panes.zig b/core/panes.zig
index a2e383c1..d9759d18 100644
--- a/core/panes.zig
+++ b/core/panes.zig
@@ -367,9 +367,10 @@ pub const Pane = struct {
/// The views `pv` holds a share for (a pane retired before a view came
/// has none of it).
pv_known: u8 = 0,
- /// The view that last typed into it: a terminal shown at two sizes takes
- /// that view's (Pardes.sync).
- sized_by: u8 = 0,
+ /// The view that last typed into it, while that view is open: a
+ /// terminal shown at two sizes takes that view's (Pardes.sync); none,
+ /// it keeps the size it has.
+ sized_by: ?u8 = 0,
/// A terminal shown in a view shorter than it (one that does not size
/// it): the rows its top is passed over by, so its cursor stays in
/// sight (Pane.panFor); 0 everywhere else.
diff --git a/core/views.zig b/core/views.zig
index 704fc859..663610c3 100644
--- a/core/views.zig
+++ b/core/views.zig
@@ -423,6 +423,7 @@ pub fn closeKeeping(p: *Pardes, k: u8) void {
inline for (sized ++ laid_out) |name| @field(v, name) = @field(p.views[k].?, name);
v.jumps.force = force;
for (p.panes) |s| if (s) |pane| {
+ if (pane.sized_by == k) pane.sized_by = other;
if (pane.pv_known & bit(other) != 0 and pane.pv[other].body.sels.len > 0) p.gpa.free(pane.pv[other].body.sels);
pane.pv[other] = fresh(pane);
pane.pv_known |= bit(other);
@@ -447,8 +448,10 @@ fn dropView(p: *Pardes, k: u8) void {
}
pane.pv[k].body.sels = &.{};
pane.pv_known &= ~bit(k);
- // A name it was drafting goes with it.
+ // A name it was drafting goes with it; a terminal it sized keeps
+ // its size (Pardes.sizes), for no view that is not typed in.
if (pane.prompt == .name and pane.prompt_view == k) pane.closePrompt();
+ if (pane.sized_by == k) pane.sized_by = null;
};
p.views_open &= ~bit(k);
p.views_away &= ~bit(k);
@@ -700,10 +703,28 @@ test "a terminal shown at two sizes takes the size of the view that typed into i
try testing.expectEqual(big, .{ term.cols, term.rows });
p.update(.{ .key = .{ .cp = Key.right } });
try testing.expectEqual(small, .{ term.cols, term.rows });
- // That view gone, the one left sizes it.
+ // Its pty in pixels at the cell of the view that sizes it, whichever
+ // is live.
+ p.views[k.index()].?.cell_pixels = .{ .w = 10, .h = 20 };
+ p.update(.{ .key = .{ .cp = Key.right } });
+ p.toView(k);
+ p.update(.{ .key = .{ .cp = Key.right } });
+ p.toView(.at(0));
+ try testing.expectEqual(pardes.PtySize{ .cols = big[0], .rows = big[1], .w_px = big[0] * 10, .h_px = big[1] * 20 }, p.ptySize(.at(p.view().active), null));
+ p.update(.{ .key = .{ .cp = Key.right } });
+ try testing.expectEqual(pardes.PtySize{ .cols = small[0], .rows = small[1], .w_px = small[0] * 8, .h_px = small[1] * 16 }, p.ptySize(.at(p.view().active), null));
+ // That view gone, the size stays until the one left types into it; a
+ // view opened in its place sizes nothing it has not typed into.
p.toView(k);
p.closeView(.at(0));
try testing.expectEqual(k.index(), p.live);
+ try testing.expectEqual(small, .{ term.cols, term.rows });
+ const again = p.openView().?;
+ p.toView(again);
+ p.update(.{ .resize = .{ .cols = 100, .rows = 30 } });
+ try testing.expectEqual(small, .{ term.cols, term.rows });
+ p.toView(k);
+ p.update(.{ .key = .{ .cp = Key.right } });
try testing.expectEqual(big, .{ term.cols, term.rows });
}