summaryrefslogtreecommitdiff
path: root/src/look.zig
diff options
context:
space:
mode:
Diffstat (limited to 'src/look.zig')
-rw-r--r--src/look.zig16
1 files changed, 11 insertions, 5 deletions
diff --git a/src/look.zig b/src/look.zig
index 21148b37..3ae0578c 100644
--- a/src/look.zig
+++ b/src/look.zig
@@ -1481,17 +1481,23 @@ fn lookAddress(p: *Pardes, id: usize, path: []const u8, expr: []const u8) void {
}
/// A PDF's address is its page: `:N` turns to page N, one past its last a
-/// miss. It has no text to hold a byte offset (`#N`) or a pattern: any
-/// other address is refused with what it takes.
+/// miss, and `:N:H` to page N's search hit H, as `book.pdf:N:H` (a PDF
+/// search's row) does. It has no text to hold a byte offset (`#N`) or a
+/// pattern: any other address is refused with what it takes.
fn lookPdfPage(p: *Pardes, id: usize, target: usize, pv: anytype, expr: []const u8) void {
var cut: [miss_path_cap + "…".len]u8 = undefined;
- const page = std.fmt.parseInt(usize, std.mem.trim(u8, expr, " \t"), 10) catch
- return missed(p, id, "{s}: a PDF has no text to address; its address is a page, :N", .{missText(pv.path, &cut)});
+ const trimmed = std.mem.trim(u8, expr, " \t");
+ const colon = std.mem.indexOfScalar(u8, trimmed, ':') orelse trimmed.len;
+ const no_text = "{s}: a PDF has no text to address; its address is a page, :N";
+ const page = std.fmt.parseInt(usize, trimmed[0..colon], 10) catch
+ return missed(p, id, no_text, .{missText(pv.path, &cut)});
+ const hit = if (colon < trimmed.len) std.fmt.parseInt(usize, trimmed[colon + 1 ..], 10) catch
+ return missed(p, id, no_text, .{missText(pv.path, &cut)}) else 0;
if (page == 0) return missedPage(p, id, pv.path, 0);
if (page > pv.page_count) return missedPage(p, id, pv.path, page);
const pane = p.panes[target].?;
clearNavigationSelection(p, pane);
- if (pv.focusLocation(p.pdf_gpa, page, 0)) panes.Pdf.resetPageChrome(pane);
+ if (pv.focusLocation(p.pdf_gpa, page, hit)) panes.Pdf.resetPageChrome(pane);
p.active = target;
}