summaryrefslogtreecommitdiff
path: root/src/pardes.zig
diff options
context:
space:
mode:
Diffstat (limited to 'src/pardes.zig')
-rw-r--r--src/pardes.zig58
1 files changed, 28 insertions, 30 deletions
diff --git a/src/pardes.zig b/src/pardes.zig
index d490c6f3..324a9603 100644
--- a/src/pardes.zig
+++ b/src/pardes.zig
@@ -378,11 +378,17 @@ test "MuPDF pane renders, navigates, searches, and round-trips its page" {
p.setPdfPage(pane, next_page);
try std.testing.expectEqualStrings(long_query, pane.pdf.?.search_query);
+ // PDF dumps intentionally retain the existing image-compatible schema:
+ // page/path are restored, while pane-local tint starts from the fresh-PDF
+ // default rather than being serialized in the image record.
+ p.togglePdfTint(pane);
+ try std.testing.expectEqual(PdfTintMode.full, pane.pdf.?.tint);
try p.dumpState();
const restored = try Pardes.initFromDump(gpa, .{}, p.dump_out.?);
defer restored.deinit();
try std.testing.expect(hasPdf(restored.panes[0].?));
try std.testing.expectEqual(pane.pdf.?.page, restored.panes[0].?.pdf.?.page);
+ try std.testing.expectEqual(PdfTintMode.filtered, restored.panes[0].?.pdf.?.tint);
}
test "PDF normal adapter consumes unsupported actions and navigates page fallback" {
@@ -534,29 +540,31 @@ test "PdfTint cycles pane-local state and exposes it in the live PDF tag" {
const tint_builtin = std.meta.stringToEnum(Builtin, "PdfTint") orelse
return error.MissingPdfTintBuiltin;
- try std.testing.expectEqual(PdfTintMode.disabled, pv.tint);
+ try std.testing.expectEqual(PdfTintMode.filtered, pv.tint);
const initial_tag = try p.tagText(p.scratch.allocator(), pane);
try std.testing.expect(std.mem.indexOf(
u8,
initial_tag,
- "width PdfFit disabled PdfTint",
+ "width PdfFit filtered PdfTint",
) != null);
p.runBuiltin(tint_builtin, 0, "", null);
- try std.testing.expectEqual(PdfTintMode.filtered, pv.tint);
- const filtered_tag = try p.tagText(p.scratch.allocator(), pane);
- try std.testing.expect(std.mem.indexOf(u8, filtered_tag, "filtered PdfTint") != null);
+ try std.testing.expectEqual(PdfTintMode.full, pv.tint);
+ const full_tag = try p.tagText(p.scratch.allocator(), pane);
+ try std.testing.expect(std.mem.indexOf(u8, full_tag, "full PdfTint") != null);
// The launch companion is a terminal. Running the same pane-scoped word
// there cannot mutate the PDF next to it.
try std.testing.expect(!hasPdf(p.panes[1].?));
p.runBuiltin(tint_builtin, 1, "", null);
- try std.testing.expectEqual(PdfTintMode.filtered, pv.tint);
-
- p.runBuiltin(tint_builtin, 0, "", null);
try std.testing.expectEqual(PdfTintMode.full, pv.tint);
+
p.runBuiltin(tint_builtin, 0, "", null);
try std.testing.expectEqual(PdfTintMode.disabled, pv.tint);
+ const disabled_tag = try p.tagText(p.scratch.allocator(), pane);
+ try std.testing.expect(std.mem.indexOf(u8, disabled_tag, "disabled PdfTint") != null);
+ p.runBuiltin(tint_builtin, 0, "", null);
+ try std.testing.expectEqual(PdfTintMode.filtered, pv.tint);
try std.testing.expectEqual(PdfFitMode.width, pv.fit);
// `dark` intentionally leaves page bg/fg null. PDF tint resolves those
@@ -590,8 +598,9 @@ test "PDF tint and tinted theme changes rebuild every visible raster only" {
const viewport = p.pdfViewport(pane).?;
pv.document_scroll_y = @floatFromInt(pv.page_starts[1] -| viewport.pixel_h / 2);
_ = frame.reset(.retain_capacity);
- const plain_surface = try p.render(frame.allocator());
- try std.testing.expectEqual(@as(usize, 2), plain_surface.nimages);
+ const default_surface = try p.render(frame.allocator());
+ try std.testing.expectEqual(PdfTintMode.filtered, pv.tint);
+ try std.testing.expectEqual(@as(usize, 2), default_surface.nimages);
try std.testing.expectEqual(@as(usize, 2), pv.rasters.items.len);
const Snapshot = struct {
@@ -632,20 +641,9 @@ test "PDF tint and tinted theme changes rebuild every visible raster only" {
}
}
};
- const plain = try Capture.get(plain_surface);
-
- p.togglePdfTint(pane);
- try std.testing.expectEqual(PdfTintMode.filtered, pv.tint);
- for (pv.rasters.items) |raster| try std.testing.expect(!raster.tried);
- _ = frame.reset(.retain_capacity);
- const filtered_surface = try p.render(frame.allocator());
- const filtered = try Capture.get(filtered_surface);
- try Capture.expectGeometry(plain, filtered);
- try std.testing.expectEqual(@as(usize, 2), pv.rasters.items.len);
- for (plain, filtered) |old, new| {
- try std.testing.expect(new.revision > old.revision);
- try std.testing.expect(new.checksum != old.checksum);
- }
+ const default_filtered = try Capture.get(default_surface);
+ for (pv.rasters.items) |raster|
+ try std.testing.expectEqual(PdfTintMode.filtered, raster.tint_key.?.mode);
const dark_index = for (themes, 0..) |th, i| {
if (std.mem.eql(u8, th.name, "dark")) break i;
@@ -655,8 +653,8 @@ test "PDF tint and tinted theme changes rebuild every visible raster only" {
_ = frame.reset(.retain_capacity);
const themed_surface = try p.render(frame.allocator());
const themed = try Capture.get(themed_surface);
- try Capture.expectGeometry(filtered, themed);
- for (filtered, themed) |old, new| {
+ try Capture.expectGeometry(default_filtered, themed);
+ for (default_filtered, themed) |old, new| {
try std.testing.expect(new.revision > old.revision);
try std.testing.expect(new.checksum != old.checksum);
}
@@ -695,9 +693,9 @@ test "PDF tint and tinted theme changes rebuild every visible raster only" {
const disabled_surface = try p.render(frame.allocator());
const disabled = try Capture.get(disabled_surface);
try Capture.expectGeometry(full, disabled);
- for (plain, disabled) |original, restored| {
- try std.testing.expect(restored.revision > original.revision);
- try std.testing.expectEqual(original.checksum, restored.checksum);
+ for (full, disabled) |old, source| {
+ try std.testing.expect(source.revision > old.revision);
+ try std.testing.expect(source.checksum != old.checksum);
}
const acme_index = for (themes, 0..) |th, i| {
@@ -3132,7 +3130,7 @@ const PdfView = if (pdf_enabled) struct {
layout_anchor_fraction: f64 = 0,
next_raster_revision: u32 = 0,
fit: PdfFitMode = .width,
- tint: PdfTintMode = .disabled,
+ tint: PdfTintMode = .filtered,
/// Normalized 0..65535 pan positions. NativeGeometry maps the extrema
/// exactly onto the source overflow, independent of page or cell size.
pan_x: u16 = 0,