diff options
Diffstat (limited to 'src/dump.zig')
| -rw-r--r-- | src/dump.zig | 17 |
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); |
