summaryrefslogtreecommitdiff
path: root/src/panes.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/panes.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/panes.zig')
-rw-r--r--src/panes.zig17
1 files changed, 10 insertions, 7 deletions
diff --git a/src/panes.zig b/src/panes.zig
index f7a3cf8a..95917b42 100644
--- a/src/panes.zig
+++ b/src/panes.zig
@@ -61,7 +61,10 @@ pub const Pane = struct {
col1: i32,
};
- const PdfSlot = if (Pdf.enabled) ?Pdf.State else void;
+ /// A PDF's state is its own allocation in the pdf region, as a
+ /// terminal's is its own: inline, its raster slots would be every
+ /// pane's, and every rollback copy's.
+ const PdfSlot = if (Pdf.enabled) ?*Pdf.State else void;
/// What an open prompt is asking. The answer is typed into `input`.
pub const Prompt = union(enum) {
@@ -509,12 +512,12 @@ pub const Pane = struct {
}
pub fn pdfPath(pane: *const Pane) ?[]const u8 {
- if (comptime Pdf.enabled) if (pane.pdf) |*pv| return pv.path;
+ if (comptime Pdf.enabled) if (pane.pdf) |pv| return pv.path;
return null;
}
pub fn pdfPage(pane: *const Pane) ?usize {
- if (comptime Pdf.enabled) if (pane.pdf) |*pv| return pv.page;
+ if (comptime Pdf.enabled) if (pane.pdf) |pv| return pv.page;
return null;
}
@@ -538,7 +541,7 @@ pub const Pane = struct {
/// current scroll offset: file top line, or the scrollback offset
pub fn scroll(pane: *Pane) i32 {
if (pane.file) |f| return @intCast(f.scroll);
- if (comptime Pdf.enabled) if (pane.pdf) |*pv| return @intCast(pv.text_scroll);
+ if (comptime Pdf.enabled) if (pane.pdf) |pv| return @intCast(pv.text_scroll);
return pane.surfRow(terminal.gridOffset(pane) + pane.pan);
}
@@ -576,7 +579,7 @@ pub const Pane = struct {
}
} else if (hasPdf(pane)) {
if (comptime Pdf.enabled) {
- const pv = &pane.pdf.?;
+ const pv = pane.pdf.?;
const max: i64 = @intCast(modal.lineCount(pv.text) -| 1);
pv.text_scroll = @intCast(std.math.clamp(
@as(i64, @intCast(pv.text_scroll)) + delta,
@@ -637,7 +640,7 @@ pub const Pane = struct {
to = @min(to, if (off == 0 and pane.textFits()) @max(pane.body.cur_row, lines - 1 - @intFromBool(std.mem.endsWith(u8, f.content, "\n"))) else lines - 1);
}
if (comptime Pdf.enabled) {
- if (pane.pdf) |*pv|
+ if (pane.pdf) |pv|
to = @min(to, @as(i32, @intCast(modal.lineCount(pv.text) -| 1)));
}
pane.scrollBy(@max(0, to - last));
@@ -684,7 +687,7 @@ pub const Pane = struct {
pub fn hasPdfSelection(pane: *const Pane) bool {
return if (comptime Pdf.enabled)
- if (pane.pdf) |*pv| pv.selection != null and pv.selection_text.len > 0 else false
+ if (pane.pdf) |pv| pv.selection != null and pv.selection_text.len > 0 else false
else
false;
}