summaryrefslogtreecommitdiff
path: root/src/pardes.zig
diff options
context:
space:
mode:
Diffstat (limited to 'src/pardes.zig')
-rw-r--r--src/pardes.zig16
1 files changed, 14 insertions, 2 deletions
diff --git a/src/pardes.zig b/src/pardes.zig
index bea79b18..fbc19b8a 100644
--- a/src/pardes.zig
+++ b/src/pardes.zig
@@ -4709,13 +4709,25 @@ pub const Pardes = struct {
return exec.isFile(local);
}
- /// A file pane closing: its place noted in Recent, when Recent keeps it.
+ /// A file, PDF or image pane closing: its place noted in Recent, when
+ /// Recent keeps it.
fn noteClosed(p: *Pardes, pane: *const Pane) void {
- const d = recentDot(pane) orelse return;
+ const d = recentPlace(pane) orelse return;
if (p.recent.get(d.path) == null and !recentKeeps(d.path)) return;
p.recent.closedSel(p.recentGpa(), d.path, d.line, d.col, d.aline, d.acol);
}
+ pub const RecentPlace = struct { path: []const u8, line: u32, col: u32, aline: u32 = 0, acol: u32 = 0 };
+
+ /// Where a pane is, as Recent keeps it: a file's dot, a PDF's page
+ /// (`:page:1`), an image's path alone (line 0). Null for any other.
+ pub fn recentPlace(pane: *const Pane) ?RecentPlace {
+ if (recentDot(pane)) |d| return .{ .path = d.path, .line = d.line, .col = d.col, .aline = d.aline, .acol = d.acol };
+ if (pane.pdfPath()) |path| return .{ .path = path, .line = @intCast(pane.pdfPage().? + 1), .col = 1 };
+ if (pane.image) |iv| return .{ .path = iv.path, .line = 0, .col = 0 };
+ return null;
+ }
+
fn recentDot(pane: *const Pane) ?struct { path: []const u8, line: u32, col: u32, aline: u32 = 0, acol: u32 = 0 } {
const f = pane.file orelse return null;
if (f.output != null) return null;