summaryrefslogtreecommitdiff
path: root/addons
diff options
context:
space:
mode:
authorGabriel Schneider <[email protected]>2026-11-18 17:44:54 -0300
committerGabriel Schneider <[email protected]>2026-11-18 17:44:54 -0300
commit41f665c986886790e474bef78928f4b0d3b05c21 (patch)
treefe14dc9afdbcc36e42fbdcb17e7257083dda9d98 /addons
parente3e9a2d35ded6b668c2bb668845bb39d86e0412b (diff)
parentf3a38a45c00eb02f0aaaca7185e5601ab7224913 (diff)
downloadpardes-41f665c986886790e474bef78928f4b0d3b05c21.tar.gz
pardes-41f665c986886790e474bef78928f4b0d3b05c21.zip
integration: addons in a client part 4 (the scroll bench's clock, a view laid out as the active one, the Shadow path deleted, address P:H on a late joiner) with the client path's round 4 and Zig 0.17.1: no conflict; on Zig 0.17.1: replicas with five clients: diverged 0, unequal 0, deltas checked/wrong 1782/0, 1769/0, 1871/0, quiet checks 582/0, 773/0, 791/0; tui core-test 819/960 (141 skipped), shell-test 995/998, behaviour-test 274/274 and its replay 20 seeds with 0 failures, pane-test 183/184; gui frame corpus 77/77 Debug and ReleaseFast against mbase171, unit-test 1592/1596, the tui build has no SDL symbol; the perf window, each of its three runs now the gated tree's: corpus2x -0.096% (spread 0.19%), corpus-snake -0.164%: the +0.77% that held this merge was the gate measuring another workspace (the helper that ignored GATE_W)
Co-Authored-By: Claude Fable 5.2 <[email protected]> Claude-Session: https://claude.ai/code/session_016Y9MNBECMWcJD5pdS4SR6T
Diffstat (limited to 'addons')
-rw-r--r--addons/pdf/pdf.zig36
1 files changed, 18 insertions, 18 deletions
diff --git a/addons/pdf/pdf.zig b/addons/pdf/pdf.zig
index c9a49b7c..8f314bbe 100644
--- a/addons/pdf/pdf.zig
+++ b/addons/pdf/pdf.zig
@@ -614,7 +614,7 @@ pub const Pdf = extern struct {
var said: [160]u8 = undefined;
if (page == 0 or page > st.pages) return miss(std.fmt.bufPrint(&said, "has no page {d}", .{page}));
const f = &st.find;
- if (second > 0 and (f.len == 0 or !f.counted or countsOf(st, ownOf(st))[page - 1] < second)) return miss(std.fmt.bufPrint(&said, "has no search hit {d} on page {d}", .{ second, page }));
+ if (second > 0 and (f.len == 0 or !f.counted or countOn(st, ownOf(st), page - 1) < second)) return miss(std.fmt.bufPrint(&said, "has no search hit {d} on page {d}", .{ second, page }));
dropSel(st);
goPage(st, page - 1);
if (second > 0) f.hit, f.reveal = .{ second - 1, true };
@@ -913,7 +913,7 @@ const Strip = struct {
/// What a pane's process holds beside its block, found by the block's
/// address: functions of the file and the block, never read by a key, the
/// mouse or a tick but through these (`stripOf`, `rasterOf`, `pageText`,
-/// `hitsOf`, `countsOf`, `selOf`), which make what they lack again (a
+/// `hitsOf`, `countOn`, `selOf`), which make what they lack again (a
/// client joined late has none of what the state jobs answered before).
const Own = struct {
of: ?*const Pdf = null,
@@ -1034,24 +1034,19 @@ fn hitsOf(st: *const Pdf, o: *Own) []const m.pardes_pdf_search_quad {
return o.hits;
}
-/// Each page's count of the search's hits: the job's, else counted here.
-fn countsOf(st: *const Pdf, o: *Own) []const u32 {
+/// Page `p`'s count of the search's hits: the job's, else that page's
+/// alone found here (a client joined after the search has no counts, and
+/// every page's would hold its loop for seconds on a long file).
+fn countOn(st: *const Pdf, o: *const Own, p: u32) u32 {
const f = &st.find;
- if (o.counts.len == st.pages and std.mem.eql(u8, &o.counts_of, &f.query)) return o.counts;
- heap.free(o.counts);
- o.counts = heap.alloc(u32, st.pages) catch &.{};
- @memset(o.counts, 0);
- o.counts_of = f.query;
- const d = o.d orelse return o.counts;
+ if (o.counts.len == st.pages and std.mem.eql(u8, &o.counts_of, &f.query)) return o.counts[p];
+ const d = o.d orelse return 0;
var q: [257]u8 = @splat(0);
@memcpy(q[0..f.len], f.query[0..f.len]);
- for (o.counts, 0..) |*n, p| {
- var r: m.pardes_pdf_search_result = undefined;
- if (m.pardes_pdf_search_page(d.base, @intCast(p), &q, &r) != ok) continue;
- n.* = @intCast(r.hit_count);
- m.pardes_pdf_drop_search_result(d.base, r.handle);
- }
- return o.counts;
+ var r: m.pardes_pdf_search_result = undefined;
+ if (m.pardes_pdf_search_page(d.base, @intCast(p), &q, &r) != ok) return 0;
+ defer m.pardes_pdf_drop_search_result(d.base, r.handle);
+ return @intCast(r.hit_count);
}
/// The selection made: its quads and text, MuPDF's from the block's.
@@ -1209,7 +1204,12 @@ fn layout(st: *Pdf, l: *Layout, k: usize) void {
}
if (l.rev != st.rev) { // a pixel's: P:F rounds
const sp = stripOf(st, ownOf(st), k);
- l.top = @round(f64Of(sp.y[st.page]) + std.math.clamp(st.frac, 0, 1) * f64Of(sp.ph[st.page]));
+ // Laid as the active view is (a window of its size in another
+ // process): the active's top as it is, a fraction and all, so the
+ // two show the same pixels (from P:F, rounded, one showed its page
+ // a pixel off the other's).
+ const same = if (pixels(st, st.active)) |a| a != l and a.rev == st.rev and a.vw == vw and a.vh == vh and a.fit == l.fit else false;
+ l.top = if (same) st.views[st.active - 1].top else @round(f64Of(sp.y[st.page]) + std.math.clamp(st.frac, 0, 1) * f64Of(sp.ph[st.page]));
l.rev = st.rev;
}
l.top = std.math.clamp(l.top, 0, f64Of(l.height -| l.vh));