summaryrefslogtreecommitdiff
path: root/src/dump.zig
diff options
context:
space:
mode:
authorGabriel Schneider <[email protected]>2026-10-24 10:05:01 -0300
committerGabriel Schneider <[email protected]>2026-10-24 10:14:38 -0300
commit873f81ccb1449119846de8d4e6e0e8899236100a (patch)
tree66ad8ca2e913e4a954be947c54aa0b31a0c9fdb0 /src/dump.zig
parent19c83c90ebed4817acd7a12d4d225f5af0957bc1 (diff)
downloadpardes-873f81ccb1449119846de8d4e6e0e8899236100a.tar.gz
pardes-873f81ccb1449119846de8d4e6e0e8899236100a.zip
Search converge 1/6: attached panes, a pane under its owner on the owner's rows alone, fixed height, moving, folding and closing with it
Diffstat (limited to 'src/dump.zig')
-rw-r--r--src/dump.zig17
1 files changed, 17 insertions, 0 deletions
diff --git a/src/dump.zig b/src/dump.zig
index c8c302ab..0ce44c40 100644
--- a/src/dump.zig
+++ b/src/dump.zig
@@ -264,6 +264,9 @@ pub const Pane = struct {
/// Exact editable tail when the user touched it. Null retains the live
/// default; a present empty slice deliberately restores an empty tail.
tag_tail: ?[]const u8 = null,
+ /// The index in `panes` of the pane this one is attached to (layout.zig,
+ /// "Attached panes"); null when it is attached to none, and in older dumps.
+ attached_to: ?usize = null,
terminal: ?Terminal = null,
file: ?File = null,
image: ?Image = null,
@@ -744,6 +747,13 @@ pub fn dumpState(p: *Pardes) !void {
dump_panes[panes_len] = dp;
panes_len += 1;
}
+ // An attachment names its owner by its place in the dump: serials are
+ // handed out again on a Restore.
+ for (0..p.panes.len) |id| {
+ const i = slot_to_pane[id] orelse continue;
+ const owner = layout.ownerOf(p, id) orelse continue;
+ dump_panes[i].attached_to = slot_to_pane[owner];
+ }
// Zerox's twins: the text once, in the first; each other names it.
for (p.panes, 0..) |slot, id| {
const f = (slot orelse continue).file orelse continue;
@@ -1020,6 +1030,13 @@ fn initDump(gpa: std.mem.Allocator, opts: Options, zon_bytes: []const u8, previo
p.col_n[c] = @min(col.panes.len, MAX_PANES);
for (col.panes[0..p.col_n[c]], 0..) |pid, k| p.col_panes[c][k] = pid;
}
+ // A dump's pane i is restored into slot i: its owner's serial now.
+ for (st.panes[0..@min(st.panes.len, MAX_PANES)], 0..) |src, i| {
+ const owner = src.attached_to orelse continue;
+ if (owner >= MAX_PANES or owner == i) continue;
+ const pane = p.panes[i] orelse continue;
+ pane.attached_to = (p.panes[owner] orelse continue).serial;
+ }
p.active = @min(st.active, MAX_PANES - 1);
p.sync();
exec.applyStartupConfig(p);