summaryrefslogtreecommitdiff
path: root/src/dump.zig
diff options
context:
space:
mode:
Diffstat (limited to 'src/dump.zig')
-rw-r--r--src/dump.zig23
1 files changed, 17 insertions, 6 deletions
diff --git a/src/dump.zig b/src/dump.zig
index abc52f5a..c33ac02c 100644
--- a/src/dump.zig
+++ b/src/dump.zig
@@ -142,11 +142,13 @@ pub fn defaultDirectory(buf: []u8) ?[]const u8 {
/// A session's dump: its core, everything it is but what is the host's,
/// the frame's or worked out again (`replica` in each type, src/walk.zig),
-/// then its 9P mounts, which live with the 9P server's own state, and which
-/// of its panes' files were on disk when it was made (one gone by its load
-/// is said deleted: its text is nowhere else now).
-const Session = walk.Dump(&.{ Pardes, []const filesystem.Mount, OnDisk });
-const SessionLoad = walk.Load(&.{ Pardes, []const filesystem.Mount, OnDisk });
+/// then its 9P mounts, which live with the 9P server's own state, which of
+/// its panes' files were on disk when it was made (one gone by its load is
+/// said deleted: its text is nowhere else now), and its theme's name: the
+/// setting is a place in this build's ring of themes, another build's
+/// ring is another.
+const Session = walk.Dump(&.{ Pardes, []const filesystem.Mount, OnDisk, []const u8 });
+const SessionLoad = walk.Load(&.{ Pardes, []const filesystem.Mount, OnDisk, []const u8 });
const OnDisk = [MAX_PANES]bool;
fn onDisk(pane: *const pardes.panes.Pane) bool {
@@ -176,6 +178,8 @@ pub fn dumpBytes(p: *Pardes) ![]u8 {
on.* = onDisk(pane);
};
try d.put(OnDisk, &on_disk);
+ const theme: []const u8 = colors.themes[@min(p.settings.theme, colors.themes.len - 1)].name;
+ try d.put([]const u8, &theme);
return d.finish();
}
@@ -233,6 +237,12 @@ fn loadKnowing(gpa: std.mem.Allocator, opts: Options, bytes: []const u8, notes:
}
const was = try l.get(OnDisk);
if (on_disk) |out| out.* = was;
+ const theme = try l.get([]const u8);
+ defer gpa.free(theme);
+ // This build's place for that theme; one it has not, its first.
+ p.settings.theme = for (colors.themes, 0..) |t, i| {
+ if (std.mem.eql(u8, t.name, theme)) break i;
+ } else if (p.settings.theme < colors.themes.len) p.settings.theme else 0;
// A mount this process was started with stands; one of the same name
// to elsewhere is refused, never silently put over it.
for (mounts) |m| {
@@ -411,7 +421,8 @@ fn revivePane(p: *Pardes, id: usize, pane: *pardes.panes.Pane, was_on_disk: bool
// Its file gone from disk since the dump: its text is nowhere else, so
// it is said deleted, and Del, Exit and Restore ask first. One never on
// disk (a name not yet saved) comes back as it was.
- if (was_on_disk and !onDisk(pane)) pardes.panes.File.deleted(p, @intCast(id));
+ // (A host with no disk of its own, the web's, asks nothing.)
+ if (comptime pardes.hosted) if (was_on_disk and !onDisk(pane)) pardes.panes.File.deleted(p, @intCast(id));
}
// ---- one pane to and from a dump: the store's, a handover's ----