summaryrefslogtreecommitdiff
path: root/src/look.zig
diff options
context:
space:
mode:
authorGabriel Schneider <[email protected]>2026-11-06 06:24:42 -0300
committerGabriel Schneider <[email protected]>2026-11-06 11:19:44 -0300
commitc1917b949b9580de8bf0977874a210f0266812da (patch)
tree447dd2235ea00634f662cd3becf4bceb8a895f41 /src/look.zig
parent76c55b5bce0f181b0b15b16596c900397dfef544 (diff)
downloadpardes-c1917b949b9580de8bf0977874a210f0266812da.tar.gz
pardes-c1917b949b9580de8bf0977874a210f0266812da.zip
kinds #14, the core's PDF code gone: pdf.zig and pdf_view.zig leave and every pdf_enabled branch with them; look, Jump, Recent, dumps (one from before the addon opens as its pane), the watch, mouse, keys, the rail and the tag go through Kind for any kind's pane; test/pdf.zig's behaviours are T1 cases over 9P (addons_pdf.zig) and pane cases (a Shadow over a replica, a file changed under it), the harnesses load pdf.so by path
Co-Authored-By: Claude Fable 5.1 <[email protected]> Claude-Session: https://claude.ai/code/session_016Y9MNAtZenFv4weoMD3cge
Diffstat (limited to 'src/look.zig')
-rw-r--r--src/look.zig301
1 files changed, 76 insertions, 225 deletions
diff --git a/src/look.zig b/src/look.zig
index 42ed0fb1..7ac8798b 100644
--- a/src/look.zig
+++ b/src/look.zig
@@ -5,7 +5,6 @@ const libc = std.c;
const pardes = @import("pardes.zig");
const exec = @import("exec.zig");
const config = @import("config.zig");
-const pdf_enabled = @import("pardes_config").mupdf;
const diff = @import("diff.zig");
const platform_has_fs = filesystem.platform_has_fs;
const layout = @import("layout.zig");
@@ -18,7 +17,6 @@ const normal = @import("normal.zig");
const edit = @import("edit.zig");
const colors = @import("colors.zig");
const Color = @import("surface.zig").Color;
-const pdf = panes.Pdf.pdf;
const Pane = panes.Pane;
const MAX_PANES = pardes.MAX_PANES;
const Layer = @import("Layer.zig");
@@ -174,54 +172,22 @@ test "parsePathLine: `end` separates a whole-token target from a lenient read" {
try std.testing.expectEqualStrings(whole, parsePathLine(whole).path);
}
-pub const FileKind = if (pdf_enabled) enum { text, pdf } else enum { text };
-
pub const FileTarget = struct {
path: []const u8,
at: Spot,
- kind: FileKind = .text,
};
pub const Target = union(enum) {
none,
dir: []const u8, // resolved absolute path, in caller's buf
file: FileTarget,
- /// A file a kind opens (Kind.forPath): a picture.
- kind: struct { path: []const u8, kind: u8 },
+ /// A file a kind opens (Kind.forPath): a picture, a PDF; `at` the place
+ /// written after it (`book.pdf:12:3`), the kind's to take.
+ kind: struct { path: []const u8, kind: u8, at: Spot = .{} },
url: []const u8,
pane: struct { id: usize, at: Spot },
};
-pub fn isPdfPath(path: []const u8) bool {
- if (comptime !pdf_enabled) return false;
- return std.ascii.endsWithIgnoreCase(path, ".pdf");
-}
-
-test "PDF file kinds exist only in MuPDF-enabled builds" {
- try std.testing.expectEqual(pdf_enabled, isPdfPath("manual.PDF"));
- try std.testing.expect(!isPdfPath("manual.pdf.txt"));
- try std.testing.expectEqual(
- pdf_enabled,
- std.meta.stringToEnum(FileKind, "pdf") != null,
- );
- try std.testing.expect(std.meta.stringToEnum(std.meta.Tag(Target), "pdf") == null);
-}
-
-test ".pdf Look paths are ordinary files when MuPDF is disabled" {
- if (!platform_has_fs) return;
- var realbuf: [4096]u8 = undefined;
- const target = resolve(null, "docs/design.pdf", ".", &realbuf);
- switch (target) {
- .file => |file| {
- if (comptime pdf_enabled)
- try std.testing.expectEqual(FileKind.pdf, file.kind)
- else
- try std.testing.expectEqual(FileKind.text, file.kind);
- },
- else => return error.PdfDidNotResolveAsFile,
- }
-}
-
pub const Span = struct { start: usize, end: usize };
const lead_trim = "([{<\"'`*";
@@ -366,12 +332,7 @@ pub fn resolve(p: ?*pardes.Pardes, word_raw: []const u8, cwd: []const u8, realbu
const found = filesystem.resolve(p, word, cwd, realbuf) orelse return .none;
if (found.dir) return .{ .dir = found.path };
- if (comptime pdf_enabled) if (isPdfPath(found.path)) return .{ .file = .{
- .path = found.path,
- .at = pl.at,
- .kind = .pdf,
- } };
- if (p) |pp| if (pp.kinds.forPath(found.path)) |k| return .{ .kind = .{ .path = found.path, .kind = k } };
+ if (p) |pp| if (pp.kinds.forPath(found.path)) |k| return .{ .kind = .{ .path = found.path, .kind = k, .at = pl.at } };
return .{ .file = .{ .path = found.path, .at = pl.at } };
}
@@ -406,19 +367,6 @@ pub const FileWordSpan = struct {
hi: i32, // exclusive
};
-pub const PdfWordPreview = if (pdf_enabled) struct {
- col: u16,
- row: u16,
- pane: usize,
- serial: u32,
- probe: panes.Pdf.WordProbe,
-
- fn deinit(preview: *@This(), gpa: std.mem.Allocator) void {
- preview.probe.deinit(gpa);
- preview.* = undefined;
- }
-} else void;
-
fn noteLookSource(p: *Pardes, id: usize) void {
const pane = p.panes[id] orelse return;
var w: usize = 0;
@@ -586,19 +534,11 @@ pub fn runSearch(p: *Pardes, id: usize, pat_raw: []const u8, start: SearchStart,
var out_len: usize = 0;
var nrows: usize = 0;
var anchor: ?usize = null;
- if (pane.hasPdf()) {
- if (comptime pdf_enabled) {
- const found = try panes.Pdf.searchRows(
- pane.pdf.?,
- p.pdf_gpa,
- pat,
- start == .cursor,
- out,
- );
- out_len = found.bytes;
- nrows = found.rows;
- anchor = found.anchor;
- }
+ if (pane.addon != null) {
+ // A kind's own rows, if it has a search.
+ const rows = Kind.search(p, id, pat, out) orelse "";
+ out_len = rows.len;
+ nrows = std.mem.count(u8, rows, "\n");
} else {
const lines = try edit.paneCursorLines(p, &pane.body);
// a real file names itself; a terminal or an output buffer has no path
@@ -889,20 +829,11 @@ 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|
- pv.invalidateRaster(preview.probe.page);
- };
- preview.deinit(p.pdf_gpa);
- p.pdf_hover_preview = null;
- };
p.look_hover_wait = null;
p.look_hover_preview = null;
}
pub fn lookHoverPane(p: *const Pardes) ?usize {
- if (comptime pdf_enabled) if (p.pdf_hover_preview) |preview| return preview.pane;
if (p.look_hover_preview) |preview| return preview.pane;
if (p.look_hover_wait) |waiting| return waiting.pane;
return null;
@@ -913,8 +844,6 @@ fn noteLookHover(p: *Pardes, col: u16, row: u16, body_hit: ?Mouse.BodyHit, tag_h
const pane = p.panes[id] orelse return cancelLookHover(p);
_ = edit.pointerTextSelection(p, id, col, row, body_hit, tag_hit) orelse return cancelLookHover(p);
- if (comptime pdf_enabled) if (p.pdf_hover_preview) |shown|
- if (shown.col == col and shown.row == row and shown.pane == id and shown.serial == pane.serial) return;
if (p.look_hover_preview) |shown|
if (shown.col == col and shown.row == row and shown.pane == id and shown.serial == pane.serial and mouse.sameBodyCell(shown.body_hit, body_hit) and Layer.sameCell(shown.tag_hit, tag_hit)) return;
if (p.look_hover_wait) |waiting|
@@ -954,21 +883,6 @@ pub fn advanceLookHover(p: *Pardes) void {
p.look_hover_refused = waiting.*;
return cancelLookHover(p);
};
- if (comptime pdf_enabled) if (!pointed.on_tag and panes.Pdf.paneNativeReady(p, pane)) {
- const probe = panes.Pdf.probeAt(p, pane, waiting.col, waiting.row) orelse
- return cancelLookHover(p);
- const ready = waiting.*;
- p.look_hover_wait = null;
- p.pdf_hover_preview = .{
- .col = ready.col,
- .row = ready.row,
- .pane = ready.pane,
- .serial = ready.serial,
- .probe = probe,
- };
- pane.pdf.?.invalidateRaster(probe.page);
- return;
- };
const operand = exec.operandAt(p, pane, pointed.sel, true, true);
if (operand.text == null or operand.text.?.len == 0) {
p.look_hover_refused = waiting.*;
@@ -995,14 +909,8 @@ pub fn focusPaneLine(p: *Pardes, id: usize, at: Spot, landing: enum { center, ke
p.view().active = id;
if (pane.collapsed) layout.toggleCollapse(p, id);
pane.body.normal.clear();
- if (pane.hasPdf()) {
- if (landing == .keep) return;
- if (comptime pdf_enabled) {
- const pv = pane.pdf.?;
- if (pv.focusLocation(p.pdf_gpa, at.line, at.col)) panes.Pdf.resetPageChrome(pane);
- }
- return;
- }
+ // A kind's place is its `address`'s (lookKind).
+ if (pane.addon != null) return;
if (at.line == 0) return;
if (pane.file) |*f| {
if (at.line > panes.File.nlines(p.gpa, f)) return;
@@ -1036,9 +944,6 @@ fn openPaneTarget(p: *const Pardes, path: []const u8, at: Spot) ?Target {
for (p.panes, 0..) |slot, i| {
const tt = slot orelse continue;
if (tt.addon) |k| if (std.mem.eql(u8, k.path, path)) {
- return .{ .pane = .{ .id = i, .at = .{} } };
- };
- 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;
@@ -1066,10 +971,6 @@ 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| {
- state.clearDrag();
- state.clearSelection(p.pdf_gpa);
- };
if (v.drag == .select and p.panes[v.drag.select.id] == pane) v.drag = .none;
}
@@ -1142,7 +1043,6 @@ 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 (pane.addon) |k| if (k.path.len > 0) return locationText(p, k.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);
@@ -1150,47 +1050,6 @@ 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 id = panes.paneIdOf(p, pane) orelse return null;
- return switch (link.destination) {
- .none => null,
- .internal => |dest| if (dest.page < state.document.pages)
- locationText(p, state.path, .{ .line = dest.page + 1 })
- else
- null,
- .external => |uri| canonicalLookLocation(p, id, uri),
- };
-}
-
-pub fn followPdfLink(p: *Pardes, id: usize, probe: *const panes.Pdf.WordProbe) void {
- if (comptime !pdf_enabled) return;
- const pane = p.panes[id] orelse return;
- const link = probe.link orelse return;
- const target = pdfLinkLocation(p, pane, link) orelse return;
- clearNavigationSelection(p, pane);
- if (canonicalLookLocation(p, id, probe.text)) |visible| {
- if (!std.mem.eql(u8, visible, target)) {
- const content = std.fmt.allocPrint(p.gpa, "{s}\n{s}\n", .{ visible, target }) catch |err|
- return p.reportError(id, "PDF link choices", err);
- panes.Output.fillResults(p, id, std.fs.path.dirname(pane.pdf.?.path) orelse ".", .pdf_links, "", content, null) catch |err|
- return p.reportError(id, "PDF link choices", err);
- return;
- }
- }
- switch (link.destination) {
- .internal => |dest| {
- p.noteHaptic(.look);
- noteLookSource(p, id);
- p.view().active = id;
- panes.Pdf.revealOutlineDestination(p, pane, dest);
- },
- .external => lookAt(p, id, target),
- .none => {},
- }
-}
-
/// A look that found nothing: said on the message row, logged as an `err`
/// record, and marked so that /look reads back nothing (ninep/ctl.zig run).
/// The most of a looked-at path or text a miss repeats; past it, its
@@ -1227,25 +1086,6 @@ fn lookOpenFailed(p: *Pardes, id: usize, path: []const u8, err: anyerror) void {
p.reportError(id, std.fmt.bufPrint(&said, "look: {s}", .{missText(path, &cut)}) catch "look", err);
}
-fn missedPage(p: *Pardes, id: usize, path: []const u8, page: usize) void {
- var cut: [miss_path_cap + "…".len]u8 = undefined;
- missed(p, id, "{s} has no page {d}", .{ missText(path, &cut), page });
-}
-
-/// `file.pdf:P:H` names hit H of the pane's search on page P: none there,
-/// or no search, is a miss as a page past the last is.
-fn missedHit(p: *Pardes, id: usize, path: []const u8, page: usize, hit: usize) void {
- var cut: [miss_path_cap + "…".len]u8 = undefined;
- missed(p, id, "{s} has no search hit {d} on page {d}", .{ missText(path, &cut), hit, page });
-}
-
-/// 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;
- return null;
-}
-
fn missedLine(p: *Pardes, id: usize, path: []const u8, line: usize) void {
var cut: [miss_path_cap + "…".len]u8 = undefined;
missed(p, id, "{s} has no line {d}", .{ missText(path, &cut), line });
@@ -1481,7 +1321,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 (pane.addon != null) return lookKind(p, id, target, expr, open == null and target != id);
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;
@@ -1521,26 +1361,40 @@ fn lookAddress(p: *Pardes, id: usize, path: []const u8, expr: []const u8) void {
v.active = target;
}
-/// A PDF's address is its page: `:N` turns to page N, one past its last a
-/// 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: *panes.Pdf.State, expr: []const u8) void {
+/// A place in a kind's pane, its `address`'s: one looked at in a list the
+/// kind made (`text`, a +PdfSections) handed with the list's name first.
+/// A miss is said as the kind said it (`<path> has no page 99`), and a
+/// pane opened for it goes again, as for a file's line past its end.
+fn lookKind(p: *Pardes, id: usize, target: usize, expr_raw: []const u8, opened: bool) void {
+ const slot = p.panes[target].?.addon.?;
+ const expr = std.mem.trim(u8, expr_raw, " \t");
+ var buf: [512]u8 = undefined;
+ const from: []const u8 = if (p.panes[id]) |src| if (src.file) |f| if (f.output) |o| if (o.from == .kind) o.arg() else "" else "" else "" else "";
+ const text = if (from.len > 0) std.fmt.bufPrint(&buf, "{s} {s}", .{ from, expr }) catch expr else expr;
+ var said: Kind.Buf(160) = .{};
+ if (Kind.address(p, target, text, &said)) {
+ if (p.panes[target]) |pane| clearNavigationSelection(p, pane);
+ p.view().active = target;
+ return;
+ }
+ var serial_name: [32]u8 = undefined;
+ const subject = if (slot.path.len > 0) slot.path else std.fmt.bufPrint(&serial_name, config.pane_addr ++ "{d}", .{p.panes[target].?.serial}) catch "the pane";
var cut: [miss_path_cap + "…".len]u8 = undefined;
- 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);
- if (!pv.hitExists(p.pdf_gpa, page, hit)) return missedHit(p, id, pv.path, page, hit);
- const pane = p.panes[target].?;
- clearNavigationSelection(p, pane);
- if (pv.focusLocation(p.pdf_gpa, page, hit)) panes.Pdf.resetPageChrome(pane);
- p.view().active = target;
+ const name = missText(subject, &cut);
+ if (opened) {
+ var kept: [miss_path_cap + "…".len]u8 = undefined;
+ @memcpy(kept[0..name.len], name);
+ p.removePane(target, null) catch {};
+ if (p.panes[id] != null) p.view().active = id;
+ return missed(p, id, "{s} {s}", .{ kept[0..name.len], if (said.len > 0) said.slice() else "is no text to address" });
+ }
+ missed(p, id, "{s} {s}", .{ name, if (said.len > 0) said.slice() else "is no text to address" });
+}
+
+/// A place as `address` takes it: `12`, `12:3`.
+fn spotText(at: Spot, buf: *[32]u8) []const u8 {
+ if (at.col == 0) return std.fmt.bufPrint(buf, "{d}", .{at.line}) catch "";
+ return std.fmt.bufPrint(buf, "{d}:{d}", .{ at.line, at.col }) catch "";
}
fn closeAndMiss(p: *Pardes, id: usize, opened: usize, name: []const u8, why: []const u8) void {
@@ -1599,9 +1453,11 @@ pub fn reopenAt(p: *Pardes, from: usize, path: []const u8, at: Spot) void {
lookAt(p, from, path);
const id = p.view().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 (at.line > 0 and pv.focusLocation(p.pdf_gpa, @min(at.line, pv.page_count), 0)) panes.Pdf.resetPageChrome(pane);
+ // A kind's place is its `address`'s (a PDF's page), quietly.
+ if (pane.addon) |k| if (std.mem.eql(u8, k.path, path)) {
+ var said: Kind.Buf(160) = .{};
+ var place: [32]u8 = undefined;
+ if (at.line > 0) _ = Kind.address(p, id, spotText(.{ .line = at.line }, &place), &said);
return;
};
const f = if (pane.file) |*file| file else return;
@@ -1757,12 +1613,11 @@ pub fn lookAt(p: *Pardes, id: usize, operand_raw: []const u8) void {
// (or, after line 0, as an address).
if (zeroColumnTail(trimmed)) return p.reportFailure(id, @import("ninep/addr.zig").e_col_zero);
if (addressed(trimmed)) |ad| return lookAddress(p, id, ad.path, ad.expr);
- // `:N` on a PDF is its page N, never a search for the text.
- if (comptime pdf_enabled) if (pane.hasPdf() and trimmed.len > 1 and trimmed[0] == ':')
+ // `:N` on a kind's pane is its place N (a PDF's page), never a search
+ // for the text.
+ if (pane.addon != null and trimmed.len > 1 and trimmed[0] == ':')
return lookAddress(p, id, "", trimmed[1..]);
const pl = parsePathLine(trimmed);
- if (comptime pdf_enabled) if (pane.hasPdf()) clearNavigationSelection(p, pane);
- if (comptime pdf_enabled) if (panes.Pdf.lookSection(p, id, pl.path, pl.at)) return;
var realbuf: [4096]u8 = undefined;
// What is looked for is the place without its trailing `:`, `@p33:`
// and `a.txt:` as much as `a.txt:2:`.
@@ -1797,13 +1652,11 @@ pub fn lookAt(p: *Pardes, id: usize, operand_raw: []const u8) void {
return missed(p, id, "no pane {s}", .{pl.path[0..@min(pl.path.len, 32)]});
}
const target = p.panes[t.id].?;
- // 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 (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);
- };
+ // A place in a kind's pane is its `address`'s, a miss its to say.
+ if (target.addon != null and t.at.line > 0) {
+ var place: [32]u8 = undefined;
+ return lookKind(p, id, t.id, spotText(t.at, &place), false);
+ }
// A directory's pane, looked at again: read again.
if (target.file) |f| if (f.listing != null) return panes.Dir.show(p, id, t.id);
const before = v.active;
@@ -1823,25 +1676,6 @@ pub fn lookAt(p: *Pardes, id: usize, operand_raw: []const u8) void {
panes.Dir.look(p, id, dir);
},
.file => |target| {
- if (comptime pdf_enabled) if (target.kind == .pdf) {
- // A hit of a search: one of the open pane's, checked by
- // focusPaneByPath's pane; a PDF not open has none.
- if (target.at.col > 0) if (pdfPaneOf(p, target.path)) |pv| {
- if (!pv.hitExists(p.pdf_gpa, @max(1, target.at.line), target.at.col)) return missedHit(p, id, target.path, @max(1, target.at.line), target.at.col);
- } else return missedHit(p, id, target.path, @max(1, target.at.line), target.at.col);
- if (focusPaneByPath(p, target.path, target.at)) return;
- const free = p.freeSlot() orelse return p.reportError(id, "look", error.NoPaneSlots);
- // Said with its path and why, as an image that cannot be read
- // is; a page past its last is a miss, as for an open one.
- _ = panes.Pdf.openPane(p, free, target.path, target.at.line, .refuse) catch |err| {
- if (err == error.NoSuchPage) return missedPage(p, id, target.path, target.at.line);
- var said: [miss_path_cap + 64]u8 = undefined;
- var cut: [miss_path_cap + "…".len]u8 = undefined;
- return p.reportError(id, std.fmt.bufPrint(&said, "look: {s}: not a PDF pardes can read", .{missText(target.path, &cut)}) catch "look: not a PDF pardes can read", err);
- };
- exec.placeNew(p, id, id, free, .doc);
- return;
- };
// An open pane on this path too short for the line: a miss that
// touches nothing.
if (openPaneTarget(p, target.path, target.at)) |open| if (p.panes[open.pane.id].?.file) |*f|
@@ -1884,7 +1718,23 @@ pub fn lookAt(p: *Pardes, id: usize, operand_raw: []const u8) void {
settleLine(p, id, target.path, target.at, before, opened);
},
.kind => |target| {
- if (focusPaneByPath(p, target.path, .{})) return;
+ var place: [32]u8 = undefined;
+ // A row of a list a kind's pane made (a +PdfSections) is that
+ // pane's place, never another's of the same file: none once it
+ // is gone.
+ const from_list = if (p.panes[id]) |src| if (src.file) |f| if (f.output) |o| o.from == .kind else false else false else false;
+ if (from_list) {
+ for (p.panes, 0..) |slot, owner| if (slot) |op| if (op.search_pane == id) if (op.addon) |k| if (std.mem.eql(u8, k.path, target.path)) {
+ if (target.at.line > 0) return lookKind(p, id, owner, spotText(target.at, &place), false);
+ p.view().active = owner;
+ return;
+ };
+ return missed(p, id, "{s}: the pane its list is of is gone", .{target.path});
+ }
+ if (focusPaneByPath(p, target.path, .{})) {
+ if (target.at.line > 0) lookKind(p, id, v.active, spotText(target.at, &place), false);
+ return;
+ }
const free = p.freeSlot() orelse return p.reportError(id, "look", error.NoPaneSlots);
const made = Kind.openFile(p, free, target.kind, target.path) catch |err|
return lookOpenFailed(p, id, target.path, err);
@@ -1898,6 +1748,7 @@ pub fn lookAt(p: *Pardes, id: usize, operand_raw: []const u8) void {
return p.reportFailure(id, std.fmt.bufPrint(&said, "look: {s}: {s}", .{ missText(target.path, &cut), made.addon.?.refused.slice() }) catch "look: refused");
}
exec.placeNew(p, id, id, free, .doc);
+ if (target.at.line > 0) lookKind(p, id, free, spotText(target.at, &place), true);
},
}
}