diff options
| author | Gabriel Schneider <[email protected]> | 2026-10-01 20:53:19 -0300 |
|---|---|---|
| committer | Gabriel Schneider <[email protected]> | 2026-10-01 20:53:19 -0300 |
| commit | 778de441bc5645bf15ba8d3dff83766fbb70499e (patch) | |
| tree | d6ebd1a202abc2ff5574db8ca11c417d466919eb /src/dump.zig | |
| parent | 081e1b9ab9d3bb8afaae8ea040c7767cb6e4f863 (diff) | |
| download | pardes-778de441bc5645bf15ba8d3dff83766fbb70499e.tar.gz pardes-778de441bc5645bf15ba8d3dff83766fbb70499e.zip | |
Zerox twins survive a Dump and Restore: their text is dumped once, in the first, each other twin names it (twin_of), and Restore puts them back on one buffer with their dots
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Diffstat (limited to 'src/dump.zig')
| -rw-r--r-- | src/dump.zig | 26 |
1 files changed, 25 insertions, 1 deletions
diff --git a/src/dump.zig b/src/dump.zig index b64441d3..1ded9989 100644 --- a/src/dump.zig +++ b/src/dump.zig @@ -232,6 +232,9 @@ pub const File = struct { /// Its dot, q0 and q1 in bytes, as acme's dump keeps a window's; null /// in older dumps. dot: ?[2]u32 = null, + /// A Zerox twin: the index, in `panes`, of the earlier pane whose + /// buffer it shares, its text kept there once; null for none. + twin_of: ?u32 = null, }; pub const ImagePalette = enum { @@ -767,6 +770,22 @@ pub fn dumpState(p: *Pardes) !void { dump_panes[panes_len] = dp; panes_len += 1; } + // 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; + if (f.twin == 0) continue; + const i = slot_to_pane[id] orelse continue; + for (p.panes[0..id], 0..) |earlier, j_id| { + const of = (earlier orelse continue).file orelse continue; + if (of.twin != f.twin) continue; + const j = slot_to_pane[j_id] orelse break; + if (dump_panes[i].file) |*df| { + df.twin_of = @intCast(j); + df.content_b64 = ""; + } + break; + } + } var columns: [MAX_COLS]Column = undefined; var columns_len: usize = 0; @@ -963,7 +982,12 @@ fn initDump(gpa: std.mem.Allocator, opts: Options, zon_bytes: []const u8, previo if (t.petscii and pardes.panes.terminal.petscii(restored) == false) pardes.panes.terminal.togglePetscii(restored); break :terminal restored; }, - .file => try pardes.panes.File.restore(p, i, src), + .file => file: { + const restored = try pardes.panes.File.restore(p, i, src); + // A twin: on the earlier pane's buffer again. + if (src.file.?.twin_of) |j| if (j < i) pardes.panes.File.relink(p, j, i, src.file.?.dot); + break :file restored; + }, .image => restore_image: { const im = src.image.?; if (pardes.panes.Pdf.isPath(im.path)) { |
