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/gui | |
| 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/gui')
| -rw-r--r-- | src/gui/gui.zig | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/src/gui/gui.zig b/src/gui/gui.zig index 86c69ff6..f044ca17 100644 --- a/src/gui/gui.zig +++ b/src/gui/gui.zig @@ -6,6 +6,7 @@ const libc = std.c; const vaxis = @import("vaxis"); // test modes only: the stdin escape-seq parser const ghostty_vt = @import("ghostty-vt"); // 256-color palette for .index cells const pardes = @import("../pardes.zig"); +const dump = @import("../dump.zig"); const config = @import("../config.zig"); const look = @import("../look.zig"); const message = pardes.Messages.Message; @@ -1298,7 +1299,7 @@ test "GUI PTY Restore joins a real reader waiting for queue space" { const gpa = std.testing.allocator; var core = try pardes.Pardes.init(gpa, .{ .tty_only = true }); defer core.deinit(); - try core.dumpState(); + try dump.dumpState(core); var workers: LspWorkers = .{}; var queue: Queue = .{ .gpa = gpa, .lsp_allocator = gpa, .lsp_workers = &workers, .sdl_wake = false }; defer queue.deinit(); @@ -1321,7 +1322,7 @@ test "GUI PTY Restore joins a real reader waiting for queue space" { try std.testing.expect(host_io.writeFd(child.file.handle, "printf 'after-full'; exit\n")); try PtyTests.waitBlocked(&queue); const old_serial = core.panes[0].?.serial; - const replacement = try core.restore(core.dump_out.?); + const replacement = try dump.restore(core, core.dump_out.?); shell.stopPtys(); core.deinit(); core = replacement; @@ -2453,7 +2454,7 @@ fn localSession( var core = if (opts.load_path) |lp| blk: { const bytes = try @import("../fs.zig").readFile(gpa, lp); defer gpa.free(bytes); - break :blk try pardes.Pardes.initFromDump(allocs.pardes, opts, bytes); + break :blk try pardes.dump.initFromDump(allocs.pardes, opts, bytes); } else try pardes.Pardes.init(allocs.pardes, opts); defer core.deinit(); core.native_images = true; @@ -2559,7 +2560,7 @@ fn localSession( break :blk; }; defer gpa.free(bytes); - const nc = core.restore(bytes) catch |err| { + const nc = dump.restore(core, bytes) catch |err| { core.reportError(core.active, "Restore", err); break :blk; }; @@ -2772,7 +2773,7 @@ fn runGrid(init: std.process.Init, opts_in: pardes.Options) !void { const core = if (opts.load_path) |lp| blk: { const bytes = try @import("../fs.zig").readFile(gpa, lp); defer gpa.free(bytes); - break :blk try pardes.Pardes.initFromDump(allocs.pardes, opts, bytes); + break :blk try pardes.dump.initFromDump(allocs.pardes, opts, bytes); } else try pardes.Pardes.init(allocs.pardes, opts); defer core.deinit(); if (opts.load_path == null) |
