diff options
Diffstat (limited to 'src/host_io.zig')
| -rw-r--r-- | src/host_io.zig | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/src/host_io.zig b/src/host_io.zig index d6b9b72e..3a9a73fd 100644 --- a/src/host_io.zig +++ b/src/host_io.zig @@ -7,6 +7,7 @@ const selection_pipe = @import("selection_pipe.zig"); const ninep_io = @import("9p_io.zig"); const filesystem = @import("fs.zig"); const file_watch = @import("file_watch.zig"); +const replica = @import("replica.zig"); pub const Host = struct { ctx: ?*anyopaque = null, @@ -96,6 +97,29 @@ pub fn stopWorkers() void { pardes.syntax.stop(); } +/// A Restore's new core, from the dump at `path` (core.takeRestore), or +/// null once why it is not is said. ponytail: a Restore replaces the core +/// its clients replicate; they are let go, and attach again. The old +/// core's panes and theme are no longer watched; the frontend lets go of +/// its ptys and pipes and swaps the new core in. ponytail: a restored +/// session is one view, the live one's (the tty's terminal, the window's +/// window): the others are let go, as a detach of each. +pub fn restoreCore(gpa: std.mem.Allocator, core: *pardes.Pardes, path: []const u8, peers: *replica.Peers, inotify_fd: c_int, watches: *file_watch.Table) ?*pardes.Pardes { + peers.dropAll(core); + const bytes = filesystem.readRestore(gpa, path, core.settings.dump_dir.get()) catch |err| { + core.reportError(core.active, "Restore", err); + return null; + }; + defer gpa.free(bytes); + const nc = pardes.dump.restore(core, bytes, path) catch |err| { + core.reportError(core.active, "Restore", err); + return null; + }; + file_watch.unwatchAll(inotify_fd, watches); + _ = file_watch.applyThemeEffect(core, gpa, inotify_fd, watches, 0, false, false); + return nc; +} + pub const Fallback = struct { pub const dump_path = "pardes.dump"; |
