diff options
Diffstat (limited to 'src/Output.zig')
| -rw-r--r-- | src/Output.zig | 26 |
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] }); |
