summaryrefslogtreecommitdiff
path: root/src/Output.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/Output.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/Output.zig')
-rw-r--r--src/Output.zig26
1 files changed, 13 insertions, 13 deletions
diff --git a/src/Output.zig b/src/Output.zig
index 006ab7bd..20d672d2 100644
--- a/src/Output.zig
+++ b/src/Output.zig
@@ -27,7 +27,9 @@ pub const Origin = union(enum) {
query: lsp.Kind,
search,
errors,
- pdf_links,
+ /// A kind's list (`pa_api.text`: a +PdfSections, a +Links), named its
+ /// argument: rows of places n/N walk, a Look of one its kind's.
+ kind,
/// The panes a refusal (Exit, Restore, Del, Delcol, get) is over, kept
/// in +Unsaved rather than a notice that goes.
unsaved,
@@ -254,7 +256,7 @@ pub fn traits(o: Origin) Traits {
// rows are `location text`, so n/N walk them
.search => .{ .name = config.search_buffer, .steps = true, .locations = true },
.errors => .{ .name = config.errors_buffer, .doc = true },
- .pdf_links => .{ .name = config.pdf_links_buffer, .steps = true, .locations = true },
+ .kind => .{ .name = "", .steps = true, .locations = true },
.unsaved => .{ .name = config.unsaved_buffer, .doc = true },
.preview => .{ .name = config.preview_buffer, .doc = true },
// Named for its directory, not a `+` name in it.
@@ -291,7 +293,7 @@ pub fn traits(o: Origin) Traits {
pub fn usesLocationsConfig(from: Origin) bool {
const tr = traits(from);
- return tr.steps and !tr.commands and from != .pdf_links and
+ return tr.steps and !tr.commands and from != .kind and
!std.meta.eql(from, Origin{ .query = .completion }) and
!std.meta.eql(from, Origin{ .query = .callstack });
}
@@ -358,7 +360,7 @@ fn sortResults(arena: std.mem.Allocator, from: Origin, content: []u8, anchor: ?u
=> {},
else => return anchor,
},
- .errors, .pdf_links, .unsaved, .dir, .preview => return anchor,
+ .errors, .kind, .unsaved, .dir, .preview => return anchor,
}
if (content.len == 0) return anchor;
const trailing_newline = content[content.len - 1] == '\n';
@@ -437,7 +439,7 @@ pub fn nextResult(content: []const u8, rows: []const locations.Row, path: []cons
pub fn open(p: *Pardes, id: usize, dir: []const u8, from: Origin, arg: []const u8, content: []u8) !*Pane {
const path = try std.fmt.allocPrint(p.gpa, "{s}/{s}", .{
- std.mem.trimEnd(u8, dir, "/"), traits(from).name,
+ std.mem.trimEnd(u8, dir, "/"), if (from == .kind) arg else traits(from).name,
});
errdefer p.gpa.free(path);
var out: State = .{ .from = from };
@@ -630,8 +632,8 @@ pub fn openJumps(p: *Pardes, id: usize) !void {
// A closed file's entry: marked, and a look at it opens it again.
if (j.serial == 0) {
const e = p.recentByHash(j.path_hash) orelse continue;
- // A PDF's `col` is how far down its page, no Look's column.
- if (j.pdf) {
+ // A kind's place has no Look's column.
+ if (j.place.len > 0) {
try out.writer.print("{s}:{d} (closed)\n", .{ e.path, @max(1, j.line) });
continue;
}
@@ -640,25 +642,23 @@ pub fn openJumps(p: *Pardes, id: usize) !void {
}
const jp = p.panes[j.pane] orelse continue;
var idbuf: [16]u8 = undefined;
- const pdf_path: ?[]const u8 = if (comptime pardes.pdf_enabled) jp.pdfPath() else null;
- const has_path = if (jp.file) |f| f.output == null else pdf_path != null;
+ const kind_path: ?[]const u8 = if (jp.addon) |k| (if (k.path.len > 0) k.path else null) else null;
+ const has_path = if (jp.file) |f| f.output == null else kind_path != null;
const loc: []const u8 = if (has_path)
- (if (jp.file) |f| f.path else pdf_path.?)
+ (if (jp.file) |f| f.path else kind_path.?)
else
std.fmt.bufPrint(&idbuf, config.pane_addr ++ "{d}", .{jp.serial}) catch unreachable;
const what: []const u8 = if (jp.file) |f|
std.mem.trim(u8, modal.lineSlice(f.content, j.line -| 1), " \t\r")
else if (jp.addon) |k|
k.path
- else if (pdf_path) |path|
- path
else
jp.cwdSlice();
var cut = @min(what.len, 120);
while (cut > 0 and cut < what.len and what[cut] & 0xc0 == 0x80) cut -= 1;
if (j.line == 0)
try out.writer.print("{s} {s}\n", .{ loc, what[0..cut] })
- else if (j.pdf)
+ else if (j.place.len > 0)
try out.writer.print("{s}:{d} {s}\n", .{ loc, j.line, what[0..cut] })
else
try out.writer.print("{s}:{d}:{d} {s}\n", .{ loc, j.line, j.col, what[0..cut] });