summaryrefslogtreecommitdiff
path: root/src/panes.zig
diff options
context:
space:
mode:
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;
}