summaryrefslogtreecommitdiff
path: root/src/look.zig
diff options
context:
space:
mode:
authorGabriel Schneider <[email protected]>2026-11-04 23:42:22 -0300
committerGabriel Schneider <[email protected]>2026-11-04 23:42:22 -0300
commit5a927d1a4e92750bc0d48994df2c2e552d669b01 (patch)
tree7301943c90d813a561400468967e774c39c6d376 /src/look.zig
parent63e6ceefc7ab33e31c9d4f83387183e44089e443 (diff)
downloadpardes-5a927d1a4e92750bc0d48994df2c2e552d669b01.tar.gz
pardes-5a927d1a4e92750bc0d48994df2c2e552d669b01.zip
exec, look: pointerOperand, isFile and langOf, one-line wrappers with one caller or four, go to their callers (pardes.zig's recentKeeps asks kindOf), as do the unused themes, BOX_H and pathUnder and look's second alias of fs.zig; missedLine and lookPdfPage take their one type, not anytype; isRecentList drops a .cmd = .Recent origin nothing makes; executeFrom's doc moves off isComment, and a comment look.zig said twice is said once
Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_016Y9MNAtZenFv4weoMD3cge
Diffstat (limited to 'src/look.zig')
-rw-r--r--src/look.zig26
1 files changed, 11 insertions, 15 deletions
diff --git a/src/look.zig b/src/look.zig
index f8c1e24b..05cdd581 100644
--- a/src/look.zig
+++ b/src/look.zig
@@ -5,9 +5,8 @@ const pardes = @import("pardes.zig");
const exec = @import("exec.zig");
const config = @import("config.zig");
const pdf_enabled = @import("pardes_config").mupdf;
-const fs = @import("fs.zig");
const diff = @import("diff.zig");
-const platform_has_fs = fs.platform_has_fs;
+const platform_has_fs = filesystem.platform_has_fs;
const layout = @import("layout.zig");
const animation = @import("animation.zig");
const modal = @import("modal.zig");
@@ -26,7 +25,6 @@ const Layer = @import("Layer.zig");
const TagHit = pardes.TagHit;
const BOX_H = pardes.BOX_H;
const TAG_TEXT_INSET = pardes.TAG_TEXT_INSET;
-const pathUnder = pardes.pathUnder;
const Mouse = pardes.Mouse;
const Key = pardes.Key;
const Event = pardes.Event;
@@ -372,7 +370,7 @@ pub fn resolve(p: ?*pardes.Pardes, word_raw: []const u8, cwd: []const u8, realbu
if (std.mem.startsWith(u8, trimmed, scheme)) return .{ .url = trimmed };
}
- const found = fs.resolve(p, word, cwd, realbuf) orelse return .none;
+ 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,
@@ -979,7 +977,7 @@ pub fn advanceLookHover(p: *Pardes) void {
pane.pdf.?.invalidateRaster(probe.page);
return;
};
- const operand = exec.pointerOperand(p, pane, pointed.sel);
+ const operand = exec.operandAt(p, pane, pointed.sel, true, true);
if (operand.text == null or operand.text.?.len == 0) {
p.look_hover_refused = waiting.*;
return cancelLookHover(p);
@@ -1255,7 +1253,7 @@ fn pdfPaneOf(p: *Pardes, path: []const u8) ?*panes.Pdf.State {
return null;
}
-fn missedLine(p: *Pardes, id: usize, path: []const u8, line: anytype) void {
+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 });
}
@@ -1535,7 +1533,7 @@ fn lookAddress(p: *Pardes, id: usize, path: []const u8, expr: []const u8) void {
/// 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 {
+fn lookPdfPage(p: *Pardes, id: usize, target: usize, pv: *panes.Pdf.State, expr: []const u8) void {
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;
@@ -1645,14 +1643,14 @@ pub fn reopenAt(p: *Pardes, from: usize, path: []const u8, at: Spot) void {
}
}
-/// Whether `pane` is the +Recent or the Jumplist list, whose rows are
-/// remembered places: a look at one clamps to the file as it is now.
+/// Whether `pane` is the Recent query pane or the Jumplist list, whose rows
+/// are remembered places: a look at one clamps to the file as it is now.
fn isRecentList(pane: *const Pane) bool {
// A query pane over the recent files: its rows are remembered places.
if (pane.query) |q| if (q.source == .recent) return true;
const f = pane.file orelse return false;
const o = f.output orelse return false;
- return std.meta.eql(o.from, panes.Output.Origin{ .cmd = .Recent }) or std.meta.eql(o.from, panes.Output.Origin{ .cmd = .Jumplist });
+ return std.meta.eql(o.from, panes.Output.Origin{ .cmd = .Jumplist });
}
// ---- a look on a diff line ----
@@ -1770,8 +1768,6 @@ pub fn lookAt(p: *Pardes, id: usize, operand_raw: []const u8) void {
if (comptime pdf_enabled) if (pane.hasPdf() and trimmed.len > 1 and trimmed[0] == ':')
return lookAddress(p, id, "", trimmed[1..]);
const pl = parsePathLine(trimmed);
- // `file:3:0`: columns count from 1, as addr's do, and a zero is refused
- // in addr's words rather than taken as no column.
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;
@@ -2371,7 +2367,7 @@ test "Look on a diff: headers and a hunk line's prefix are the whole line, hover
const y = p.bodyTop(pane, rect) + at.row;
// The hover's span is the click's operand.
const pointed = edit.pointerTextSelection(p, 0, x, y, null, null) orelse return error.NothingPointed;
- const operand = exec.pointerOperand(p, pane, pointed.sel);
+ const operand = exec.operandAt(p, pane, pointed.sel, true, true);
const lines = diffLines(p, pane).?; // scratch: good until the next update
const span = operand.file_word orelse return error.NoHoverSpan;
try std.testing.expectEqual(@as(i32, at.row), span.row);
@@ -2446,7 +2442,7 @@ test "a click, a 9P whole-line look and an empty event write-back take one expan
const x = rect.x + config.GUTTER + panes.File.gutterWidth(pane) + at.col;
const y = p.bodyTop(pane, rect) + at.row;
const pointed = edit.pointerTextSelection(p, 0, x, y, null, null) orelse return error.NothingPointed;
- const clicked = exec.pointerOperand(p, pane, pointed.sel).text orelse return error.NothingClicked;
+ const clicked = exec.operandAt(p, pane, pointed.sel, true, true).text orelse return error.NothingClicked;
try std.testing.expectEqualStrings(at.want, clicked);
// An empty record written back to event, at the same byte.
const body = pane.file.?.content;
@@ -2719,7 +2715,7 @@ test "Look outside a diff pane expands and looks as ever" {
const rect = p.rects[0];
const x = rect.x + config.GUTTER + panes.File.gutterWidth(pane) + 0;
const pointed = edit.pointerTextSelection(p, 0, x, p.bodyTop(pane, rect) + 2, null, null).?;
- const operand = exec.pointerOperand(p, pane, pointed.sel);
+ const operand = exec.operandAt(p, pane, pointed.sel, true, true);
try std.testing.expect(operand.text == null or !std.mem.eql(u8, operand.text.?, "+const a = 1;"));
}