summaryrefslogtreecommitdiff
path: root/src/image.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/image.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/image.zig')
-rw-r--r--src/image.zig63
1 files changed, 0 insertions, 63 deletions
diff --git a/src/image.zig b/src/image.zig
index 20d6d6f0..8f193674 100644
--- a/src/image.zig
+++ b/src/image.zig
@@ -11,7 +11,6 @@ const pdf_enabled = @import("pardes_config").mupdf;
const pardes = @import("pardes.zig");
const config = @import("config.zig");
const filesystem = @import("fs.zig");
-const dump = @import("dump.zig");
// Glyph matching adapted from caioluders/petsciinator.
pub const GlyphArt = struct {
pub const commodore = [16][3]u8{
@@ -990,68 +989,6 @@ pub fn create(p: *pardes.Pardes, id: usize, path: []const u8, raw: []u8) !*parde
return pane;
}
-/// Serialize the binary image record used by images and, for dump-schema
-/// compatibility, PDFs. Common pane metadata is supplied by the core.
-pub fn dumpPane(
- p: *pardes.Pardes,
- arena: std.mem.Allocator,
- pane: *const pardes.Pane,
- tag: []const u8,
- body: []const u8,
- scroll: usize,
- path: []const u8,
- raw: []const u8,
-) !dump.Pane {
- // A picture or PDF on disk is read from there at Restore, as a clean
- // file's text is: the dump keeps only the bytes of one that is not
- // (megabytes of a PDF per dump, and a stale copy, otherwise).
- _ = p;
- const on_disk = if (comptime !pardes.hosted) false else if (filesystem.localPath(path)) |local| @import("exec.zig").kindOf(local) == .file else false;
- const bytes: []const u8 = if (on_disk) &.{} else raw;
- return .{
- .kind = .image,
- .tag = tag,
- .body = body,
- .scroll = scroll,
- .cols = pane.cols,
- .rows = pane.rows,
- .vweight = pane.vweight,
- .collapsed = pane.collapsed,
- .image = .{
- .path = path,
- .bytes_b64 = if (bytes.len > 0) try dump.encodeBytes(arena, bytes) else "",
- .petscii = if (pane.image) |state| state.glyph_art else false,
- .palette = if (pane.image) |state| switch (state.pmode) {
- .commodore => .commodore,
- .terminal => .terminal,
- } else .commodore,
- .ascii = if (pane.image) |state| state.ascii else true,
- .pdf_fit = if (comptime pardes.pdf_enabled) (if (pane.pdf) |pv| @tagName(pv.fit) else "") else "",
- .pdf_tint = if (comptime pardes.pdf_enabled) (if (pane.pdf) |pv| @tagName(pv.tint) else "") else "",
- },
- };
-}
-
-pub fn restore(p: *pardes.Pardes, id: usize, src: dump.Pane) !*pardes.Pane {
- const saved = src.image.?;
- var raw: []u8 = if (saved.bytes_b64.len > 0)
- try dump.decodeBytes(p.image_gpa, saved.bytes_b64)
- else
- &.{};
- errdefer if (raw.len > 0) p.image_gpa.free(raw);
- const pane = try create(p, id, saved.path, raw);
- raw = &.{};
- pane.image.?.glyph_art = saved.petscii;
- pane.image.?.pmode = switch (saved.palette) {
- .commodore => .commodore,
- .terminal => .terminal,
- };
- pane.image.?.ascii = saved.ascii;
- pane.cols = @max(1, src.cols);
- pane.rows = @max(1, src.rows);
- return pane;
-}
-
pub fn toggleGlyphArt(state: *State) void {
state.glyph_art = !state.glyph_art;
}