summaryrefslogtreecommitdiff
path: root/src/main.zig
diff options
context:
space:
mode:
authorGabriel Schneider <[email protected]>2026-09-29 10:30:38 -0300
committerGabriel Schneider <[email protected]>2026-10-01 00:12:16 -0300
commit2d0c506583d18d6f004fc117282deb2faea1d17e (patch)
tree683d1dd2820df31222360c0308fb3333b64aae1e /src/main.zig
parentf207f1d4d56d1012766e6206e713f2b3da70579d (diff)
downloadpardes-2d0c506583d18d6f004fc117282deb2faea1d17e.tar.gz
pardes-2d0c506583d18d6f004fc117282deb2faea1d17e.zip
Recent lists the files opened lately, closed ones too, and a jump back to a closed file reopens it
A file closed by accident, its path forgotten, could not be found again: the jumplist dropped closed panes. Every file opened (a look, a Save of a scratch, a Restore, a rename) goes first in a list of 200, kept once, its dot noted when it closes, kept across sessions in $XDG_STATE_HOME/pardes/ recent. `Recent` (SPC f r) shows it in a reused +Recent, each row `path:line:col open|closed` a look reopens; /recent reads `open|closed <path>`. The jumplist keeps a closed file's entries, +Jumps marks them `(closed)`, and Back to one opens the file at its place. acme has no such thing; its dump and Load are the nearest. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Diffstat (limited to 'src/main.zig')
-rw-r--r--src/main.zig16
1 files changed, 16 insertions, 0 deletions
diff --git a/src/main.zig b/src/main.zig
index 86c302fe..b784ec97 100644
--- a/src/main.zig
+++ b/src/main.zig
@@ -369,6 +369,7 @@ fn nativeMain(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);
if (found.dir) |d| @import("crash.zig").setDir(d);
if (detach) |name| {
const named = if (name.len != 0)
@@ -427,3 +428,18 @@ test {
if (comptime pardes.platform == .gui) _ = @import("gui/gui.zig");
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 {
+ 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;
+ const home = env.get("HOME") orelse return null;
+ if (home.len == 0) return null;
+ 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;
+}