summaryrefslogtreecommitdiff
path: root/src/look.zig
diff options
context:
space:
mode:
authorGabriel Schneider <[email protected]>2026-11-05 00:31:38 -0300
committerGabriel Schneider <[email protected]>2026-11-05 01:02:28 -0300
commit7d359addc420eca66bd1583d8fd8d6a104986a03 (patch)
tree2b8991a9a4e5b9c16a2b7683018d60c7c6985c1e /src/look.zig
parent96cabca7ebe287692ebdff0dba6bb2897eba9d3e (diff)
downloadpardes-7d359addc420eca66bd1583d8fd8d6a104986a03.tar.gz
pardes-7d359addc420eca66bd1583d8fd8d6a104986a03.zip
panes: a pane's PDF state is its own allocation, `pdf: ?*Pdf.State` (made by openPane with pdf_gpa, freed by deinitPane), as a terminal's is, where every Pane held the State inline, a text file's and a terminal's too: a Pane is 49232 bytes where it was 88936 (the State 39704), and a replica's rollback copy of a pane without a PDF is that much smaller; the dump and the wire change with it, the walk writing the slot as a pointer to a State where it wrote the State in place, so a dump written before this, or a peer of an older build, gives its PDF panes no PDF (the walk notes `Pane.pdf: its kind changed; its default taken`, and dump.ensureKind makes each a terminal); the 97 uses change form only (a `|*x|` capture or a `&` dropped, normal.zig's one among them), applyNormal untouched
Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_016Y9MNAtZenFv4weoMD3cge
Diffstat (limited to 'src/look.zig')
-rw-r--r--src/look.zig22
1 files changed, 11 insertions, 11 deletions
diff --git a/src/look.zig b/src/look.zig
index a4a64b14..f6095fb9 100644
--- a/src/look.zig
+++ b/src/look.zig
@@ -596,7 +596,7 @@ pub fn runSearch(p: *Pardes, id: usize, pat_raw: []const u8, start: SearchStart,
if (pane.hasPdf()) {
if (comptime pdf_enabled) {
const found = try panes.Pdf.searchRows(
- &pane.pdf.?,
+ pane.pdf.?,
p.pdf_gpa,
pat,
start == .cursor,
@@ -898,7 +898,7 @@ fn landLookSpot(p: *Pardes, id: usize, pane: *Pane, spot: Pane.LookSpot) void {
pub fn cancelLookHover(p: *Pardes) void {
if (comptime pdf_enabled) if (p.pdf_hover_preview) |*preview| {
if (preview.pane < p.panes.len) if (p.panes[preview.pane]) |pane| {
- if (pane.serial == preview.serial) if (pane.pdf) |*pv|
+ if (pane.serial == preview.serial) if (pane.pdf) |pv|
pv.invalidateRaster(preview.probe.page);
};
preview.deinit(p.pdf_gpa);
@@ -1005,7 +1005,7 @@ pub fn focusPaneLine(p: *Pardes, id: usize, at: Spot, landing: enum { center, ke
if (pane.hasPdf()) {
if (landing == .keep) return;
if (comptime pdf_enabled) {
- const pv = &pane.pdf.?;
+ const pv = pane.pdf.?;
if (pv.focusLocation(p.pdf_gpa, at.line, at.col)) panes.Pdf.resetPageChrome(pane);
}
return;
@@ -1045,7 +1045,7 @@ fn openPaneTarget(p: *const Pardes, path: []const u8, at: Spot) ?Target {
if (tt.image) |iv| if (std.mem.eql(u8, iv.path, path)) {
return .{ .pane = .{ .id = i, .at = .{} } };
};
- if (comptime pdf_enabled) if (tt.pdf) |*pv| if (std.mem.eql(u8, pv.path, path)) {
+ if (comptime pdf_enabled) if (tt.pdf) |pv| if (std.mem.eql(u8, pv.path, path)) {
return .{ .pane = .{ .id = i, .at = at } };
};
const ff = if (tt.file) |*f| f else continue;
@@ -1073,7 +1073,7 @@ pub fn clearNavigationSelection(p: *Pardes, pane: *Pane) void {
pane.body.sticky_col = -1;
for (0..pane.sel.len) |slot| pane.clearPointerSelection(slot);
pane.sel = @splat(.{});
- if (comptime pdf_enabled) if (pane.pdf) |*state| {
+ if (comptime pdf_enabled) if (pane.pdf) |state| {
state.clearDrag();
state.clearSelection(p.pdf_gpa);
};
@@ -1148,7 +1148,7 @@ fn canonicalLookLocation(p: *Pardes, id: usize, text: []const u8) ?[]const u8 {
if (target.id >= p.panes.len) return null;
const pane = p.panes[target.id] orelse return null;
if (pane.file) |file| return locationText(p, file.path, target.at);
- if (comptime pdf_enabled) if (pane.pdf) |*doc| return locationText(p, doc.path, target.at);
+ if (comptime pdf_enabled) if (pane.pdf) |doc| return locationText(p, doc.path, target.at);
if (pane.image) |iv| return locationText(p, iv.path, target.at);
var path: [32]u8 = undefined;
return locationText(p, std.fmt.bufPrint(&path, config.pane_addr ++ "{d}", .{pane.serial}) catch return null, target.at);
@@ -1158,7 +1158,7 @@ fn canonicalLookLocation(p: *Pardes, id: usize, text: []const u8) ?[]const u8 {
pub fn pdfLinkLocation(p: *Pardes, pane: *const Pane, link: if (pdf_enabled) pdf.Link else void) ?[]const u8 {
if (comptime !pdf_enabled) return null;
- const state = &(pane.pdf orelse return null);
+ const state = pane.pdf orelse return null;
const id = p.paneIdOf(pane) orelse return null;
return switch (link.destination) {
.none => null,
@@ -1248,7 +1248,7 @@ fn missedHit(p: *Pardes, id: usize, path: []const u8, page: usize, hit: usize) v
/// The open PDF pane showing `path`, if one does.
fn pdfPaneOf(p: *Pardes, path: []const u8) ?*panes.Pdf.State {
if (comptime !pdf_enabled) return null;
- for (p.panes) |slot| if (slot) |pane| if (pane.pdf) |*pv| if (std.mem.eql(u8, pv.path, path)) return pv;
+ for (p.panes) |slot| if (slot) |pane| if (pane.pdf) |pv| if (std.mem.eql(u8, pv.path, path)) return pv;
return null;
}
@@ -1487,7 +1487,7 @@ fn lookAddress(p: *Pardes, id: usize, path: []const u8, expr: []const u8) void {
}
const pane = p.panes[target] orelse return;
const f = pane.file orelse {
- if (comptime pdf_enabled) if (pane.pdf) |*pv| return lookPdfPage(p, id, target, pv, expr);
+ if (comptime pdf_enabled) if (pane.pdf) |pv| return lookPdfPage(p, id, target, pv, expr);
if ((by_serial or path.len == 0) and pane.isTerminal()) return lookTerminalAddress(p, id, target, expr);
// Named as the pane is, the bare `:addr` (path empty) included.
var serial_name: [32]u8 = undefined;
@@ -1606,7 +1606,7 @@ pub fn reopenAt(p: *Pardes, from: usize, path: []const u8, at: Spot) void {
const id = p.active;
const pane = p.panes[id] orelse return;
// A PDF's place is its page, the last if it has fewer now.
- if (comptime pdf_enabled) if (pane.pdf) |*pv| if (std.mem.eql(u8, pv.path, path)) {
+ if (comptime pdf_enabled) if (pane.pdf) |pv| if (std.mem.eql(u8, pv.path, path)) {
if (at.line > 0 and pv.focusLocation(p.pdf_gpa, @min(at.line, pv.page_count), 0)) panes.Pdf.resetPageChrome(pane);
return;
};
@@ -1805,7 +1805,7 @@ pub fn lookAt(p: *Pardes, id: usize, operand_raw: []const u8) void {
// A PDF's page past its last is a miss, as a line past a file's
// end is: never the last page in its place (opening one, the
// same: Pdf.openPane's .refuse).
- if (comptime pdf_enabled) if (target.pdf) |*pv| {
+ if (comptime pdf_enabled) if (target.pdf) |pv| {
if (t.at.line > pv.page_count) return missedPage(p, id, pv.path, t.at.line);
if (!pv.hitExists(p.pdf_gpa, @max(1, t.at.line), t.at.col)) return missedHit(p, id, pv.path, @max(1, t.at.line), t.at.col);
};