summaryrefslogtreecommitdiff
path: root/src/views.zig
diff options
context:
space:
mode:
Diffstat (limited to 'src/views.zig')
-rw-r--r--src/views.zig16
1 files changed, 16 insertions, 0 deletions
diff --git a/src/views.zig b/src/views.zig
index bf9b9147..b9760143 100644
--- a/src/views.zig
+++ b/src/views.zig
@@ -215,6 +215,7 @@ pub fn undumped(p: *Pardes, others: []const Dumped) !void {
/// for one client (a Restore, `-l`) is one view.
pub fn only(p: *Pardes) void {
for (0..max) |k| if (k != p.view) close(p, @intCast(k));
+ emptied(p, p.view);
const k = p.view;
if (k == 0) return;
std.mem.swap(?*Parked, &p.parked[0], &p.parked[k]);
@@ -390,6 +391,19 @@ pub fn to(p: *Pardes, k: u8) void {
if (k == p.view) return;
park(p);
unpark(p, k);
+ emptied(p, k);
+}
+
+/// View `k` is live: its slot, stale until it parks again (written whole
+/// then), keeps no pointer to what it handed the live fields. A rollback
+/// copy walks every slot (src/rollback.zig): one left there, freed by the
+/// live view and the memory another's since, would be saved and its old
+/// bytes put back over the other's. (A pane's share holds no pointer but
+/// its selections, which `unpark` hands over.)
+fn emptied(p: *Pardes, k: u8) void {
+ const slot = p.parked[k] orelse return;
+ slot.view = .{ .screen_w = p.screen_w, .screen_h = p.screen_h };
+ slot.view.col_tags = @splat(.{ .what = .column, .gpa = p.gpa });
}
/// A new view, as the live one is laid out and focused, with its panes
@@ -431,6 +445,7 @@ pub fn close(p: *Pardes, k: u8) void {
} else unreachable;
park(p);
unpark(p, other);
+ emptied(p, other);
}
const v = &p.parked[k].?.view;
for (&v.col_tags) |*t| t.deinit(p.gpa);
@@ -478,6 +493,7 @@ pub fn drawOthers(p: *Pardes, h: pardes.Host) !void {
park(p);
defer {
copy(&fields, p, &p.parked[live].?.view);
+ emptied(p, live);
p.view = live;
for (p.panes) |s| if (s) |pane| {
const pv = &pane.pv[live];