summaryrefslogtreecommitdiff
path: root/src/pdf_view.zig
diff options
context:
space:
mode:
authorGabriel Schneider <[email protected]>2026-10-29 17:01:35 -0300
committerGabriel Schneider <[email protected]>2026-10-29 21:13:33 -0300
commit70de5ec5ff3dad01afcc45244ad5e5a481486da6 (patch)
treecd4b723dcc2cfd94c4ba2361c134927b0e2df60b /src/pdf_view.zig
parent349790339897466f323ff28748916aa48aa344f7 (diff)
downloadpardes-70de5ec5ff3dad01afcc45244ad5e5a481486da6.tar.gz
pardes-70de5ec5ff3dad01afcc45244ad5e5a481486da6.zip
dump: one walker dump of the whole session, by name across builds, for Restore, -l, Handover and the store; dump.zig's hand-written schema gone
A dump is walk.zig's walk of the core with a table of every type it reaches (fields, enum and union names, number widths), read back by name; terminals are ghostty's snapshot (screens, history, kitty images); a failed load frees what it made. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Diffstat (limited to 'src/pdf_view.zig')
-rw-r--r--src/pdf_view.zig14
1 files changed, 14 insertions, 0 deletions
diff --git a/src/pdf_view.zig b/src/pdf_view.zig
index b2b9c5a3..0745a6fc 100644
--- a/src/pdf_view.zig
+++ b/src/pdf_view.zig
@@ -2848,6 +2848,20 @@ pub fn deinitPane(core: *pardes.Pardes, pane: *pardes.Pane, state: *State) void
state.deinit(core.pdf_gpa);
}
+/// A PDF pane loaded from a dump given its document again (MuPDF's, so
+/// never in the dump) from its file; one changed since is laid out anew.
+pub fn reopen(core: *pardes.Pardes, pane: *pardes.Pane) !void {
+ if (comptime !enabled) return;
+ const state = &(pane.pdf orelse return);
+ const local = filesystem.localPath(state.path) orelse return error.NonLocalPath;
+ const bytes = try filesystem.readFile(core.pdf_gpa, local);
+ defer core.pdf_gpa.free(bytes);
+ state.document = try Document.openBytes(bytes);
+ if (state.document.pages != state.page_count or fileKey(state.path, bytes) != state.file) {
+ try state.reload(core.pdf_gpa);
+ }
+}
+
pub fn reloadPane(
core: *pardes.Pardes,
pane: *pardes.Pane,