summaryrefslogtreecommitdiff
path: root/src/main.zig
diff options
context:
space:
mode:
authorGabriel Schneider <[email protected]>2026-10-24 13:47:11 -0300
committerGabriel Schneider <[email protected]>2026-10-24 15:43:44 -0300
commitf3405aaef8db79094b2741a9caaeaa5328ab6288 (patch)
tree5130b95da1d545a5f669710feca9bfa4dfba1a98 /src/main.zig
parent9db48c4c8a9b2d239680a59d451cd8c1e290ff56 (diff)
downloadpardes-f3405aaef8db79094b2741a9caaeaa5328ab6288.tar.gz
pardes-f3405aaef8db79094b2741a9caaeaa5328ab6288.zip
Store 2/3: one bounded store every window shares (Store.zig): Recent as records read on use, the panes a session closes kept as one-pane dumps; Panes lists them (closed), Enter or a look at @pN brings one back beside the pane that took its rows
An append-only log under $XDG_STATE_HOME/pardes/store, framed records with a CRC, flock on store.lock (never blocking a step), a stat on use, garbage passed over and compacted away by the next writer, compaction by rename, 100 MiB cap. dump.dumpPane/restorePane lifted out of dumpState/initDump; layout.giveBack; Options.recent_path is store_path. Host calls yield one at a time; /recent refreshes only when no step is out. Tests: two windows and a busy lock, the cap, garbage/torn/partial records, a closed pane's reopen with the layout invariant; fs.py: two live sessions over 9P.
Diffstat (limited to 'src/main.zig')
-rw-r--r--src/main.zig13
1 files changed, 7 insertions, 6 deletions
diff --git a/src/main.zig b/src/main.zig
index 9086fa90..26431324 100644
--- a/src/main.zig
+++ b/src/main.zig
@@ -707,7 +707,7 @@ fn nativeMain(std_init: std.process.Init) !void {
opts.startup_config = found.bytes;
opts.startup_config_path = found.path;
opts.config_dir = found.dir;
- opts.recent_path = recentPath(init.io, arena, init.environ_map);
+ opts.store_path = storePath(init.io, arena, init.environ_map);
if (found.dir) |d| @import("crash.zig").setDir(d);
if (detach) |name| {
const named = if (name.len != 0)
@@ -789,10 +789,11 @@ test {
if (comptime pardes.font_picker) _ = @import("fonts.zig");
}
-/// Where the list of files opened lately is kept: $XDG_STATE_HOME/pardes
-/// /recent, else ~/.local/state/pardes/recent, the directory made if need
-/// be; null with no home to keep it in (the list then lasts the session).
-fn recentPath(io: std.Io, arena: std.mem.Allocator, env: *const std.process.Environ.Map) ?[]const u8 {
+/// Where the store every window shares is kept (Store.zig):
+/// $XDG_STATE_HOME/pardes/store, else ~/.local/state/pardes/store, the
+/// directory made if need be; null with no home to keep it in (Recent and
+/// the closed panes then last the session).
+fn storePath(io: std.Io, arena: std.mem.Allocator, env: *const std.process.Environ.Map) ?[]const u8 {
const dir = dir: {
if (env.get("XDG_STATE_HOME")) |base| if (base.len != 0 and std.fs.path.isAbsolute(base))
break :dir std.fs.path.join(arena, &.{ base, "pardes" }) catch return null;
@@ -801,5 +802,5 @@ fn recentPath(io: std.Io, arena: std.mem.Allocator, env: *const std.process.Envi
break :dir std.fs.path.join(arena, &.{ home, ".local", "state", "pardes" }) catch return null;
};
std.Io.Dir.cwd().createDirPath(io, dir) catch return null;
- return std.fs.path.join(arena, &.{ dir, "recent" }) catch null;
+ return std.fs.path.join(arena, &.{ dir, "store" }) catch null;
}