diff options
| author | Gabriel Schneider <[email protected]> | 2026-09-27 22:34:56 -0300 |
|---|---|---|
| committer | Gabriel Schneider <[email protected]> | 2026-10-01 00:12:14 -0300 |
| commit | 7ba54de4bd498c2a56ea3d0d43c88356759f7b1f (patch) | |
| tree | 2e661d1785ef6e74c158ca6b2e1aa96b763ec7bc /src/macos.zig | |
| parent | 52049344c1992850ea712e029eb5c4a88a7dfe19 (diff) | |
| download | pardes-7ba54de4bd498c2a56ea3d0d43c88356759f7b1f.tar.gz pardes-7ba54de4bd498c2a56ea3d0d43c88356759f7b1f.zip | |
Move saving and loading a whole editor out of pardes.zig into dump.zig
Pure move, no behaviour change (acme keeps dump and load in rows.c):
dumpState, restore, initFromDump and initDump go verbatim to the end of
dump.zig, after the dump format they read and write. Inside dump.zig the
moved code's `dump.` prefix drops, so `Pane` there is the dump record; the
one editor pane it names is spelled `pardes.panes.Pane`, and its other
`panes.X` references become `pardes.panes.X` because dump.zig's own tests
use `panes` as a local name.
The methods become free functions taking `p: *Pardes`: `p.dumpState()`
becomes `dump.dumpState(p)`, `core.restore(bytes)` becomes
`dump.restore(core, bytes)` and `Pardes.initFromDump(..)` becomes
`dump.initFromDump(..)`, in pardes.zig, the shells, layout.zig,
Terminal.zig, builtins.zig and the tests (38 receiver rewrites plus the
initFromDump calls). The tag-tail restore helpers stay with the tag code.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Diffstat (limited to 'src/macos.zig')
| -rw-r--r-- | src/macos.zig | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/src/macos.zig b/src/macos.zig index f83fb8b4..78356810 100644 --- a/src/macos.zig +++ b/src/macos.zig @@ -6,6 +6,7 @@ const builtin = @import("builtin"); const posix = std.posix; const libc = std.c; const pardes = @import("pardes.zig"); +const dump = @import("dump.zig"); const mouse = @import("mouse.zig"); const colors = @import("colors.zig"); const look = @import("look.zig"); @@ -1344,7 +1345,7 @@ fn restoreCore(st: *State) bool { return false; }; defer st.gpa.free(bytes); - const replacement = st.core.restore(bytes) catch |err| { + const replacement = dump.restore(st.core, bytes) catch |err| { st.core.reportError(st.core.active, "Restore", err); return false; }; @@ -1411,7 +1412,7 @@ test "mac Restore keeps host state and rejects callbacks from the old core" { const old_serial = core.panes[0].?.serial; st.gens[0] = 23; const old_watch = try st.file_watches.replace(gpa, 0, "/test.txt", old_serial, .{ .text = 0 }); - try core.dumpState(); + try dump.dumpState(core); try tmp.dir.writeFile(std.testing.io, .{ .sub_path = "restore.zon", .data = core.dump_out.? }); while (core.nextEffect()) |_| {} @@ -1501,7 +1502,7 @@ test "mac Restore cancels a PTY reader waiting for output capacity" { defer st.config_arena.deinit(); defer st.file_watches.deinit(gpa); defer st.inbox.close(gpa, io); - try st.core.dumpState(); + try dump.dumpState(st.core); try tmp.dir.writeFile(io, .{ .sub_path = "restore.zon", .data = st.core.dump_out.? }); while (st.core.nextEffect()) |_| {} for (0..inbox_output_limit) |_| try st.inbox.pushOutput(gpa, io, .{ |
