diff options
Diffstat (limited to 'src/look.zig')
| -rw-r--r-- | src/look.zig | 17 |
1 files changed, 9 insertions, 8 deletions
diff --git a/src/look.zig b/src/look.zig index af0905a4..1534d332 100644 --- a/src/look.zig +++ b/src/look.zig @@ -2,6 +2,7 @@ const std = @import("std"); const builtin = @import("builtin"); 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 fs = @import("fs.zig"); @@ -528,7 +529,7 @@ fn lookFirstHit(p: *Pardes, id: usize) void { rp.vsel.active = false; rp.msel.active = false; rp.select = false; - p.runBuiltin(config.look_cmd, rid, "", txt); + exec.runBuiltin(p, config.look_cmd, rid, "", txt); } pub fn runSearch(p: *Pardes, id: usize, pat_raw: []const u8, kind: Search, start: SearchStart) !void { @@ -686,7 +687,7 @@ pub fn jumpResult(p: *Pardes, id: usize, row: usize) bool { rp.look_at = null; } if (tr.commands) { - p.runBuiltin(config.exec_cmd, rid, "", std.mem.trim(u8, ln, " \t\r")); + exec.runBuiltin(p, config.exec_cmd, rid, "", std.mem.trim(u8, ln, " \t\r")); } else if (span) |selected| { lookAt(p, rid, ln[selected.start..selected.end]); // This is the newly visited result, not a selection carried into @@ -922,7 +923,7 @@ pub fn advanceLookHover(p: *Pardes) void { pane.pdf.?.invalidateRaster(probe.page); return; }; - const operand = p.pointerOperand(pane, pointed.sel); + const operand = exec.pointerOperand(p, pane, pointed.sel); if (operand.text == null or operand.text.?.len == 0) return cancelLookHover(p); var preview = operand.preview; if (preview) |*sel| sel.state = .done; @@ -1136,7 +1137,7 @@ pub fn lookAt(p: *Pardes, id: usize, operand: []const u8) void { noteLookSource(p, id); const command = std.mem.trim(u8, operand, " \t\r\n"); if (config.commandWord(command)) |cmd| { - if (p.execute(id, cmd)) |dst| p.active = dst; + if (exec.execute(p, id, cmd)) |dst| p.active = dst; return; } // The operand may borrow selected terminal/PDF text released below. @@ -1171,7 +1172,7 @@ pub fn lookAt(p: *Pardes, id: usize, operand: []const u8) void { .url => |u| if (u.len <= 256) p.emit(.{ .open_link = .from(u) }), .dir => |dir| { for (p.panes, 0..) |slot, i| { - if (slot) |tt| if (std.mem.eql(u8, tt.cwdSlice(), dir) and p.takesCommandLine(i)) { + if (slot) |tt| if (std.mem.eql(u8, tt.cwdSlice(), dir) and exec.takesCommandLine(p, i)) { clearNavigationSelection(p, tt); p.active = i; p.emitWrite(i, "ls\r"); @@ -1194,7 +1195,7 @@ pub fn lookAt(p: *Pardes, id: usize, operand: []const u8) void { const free = p.freeSlot() orelse return p.reportError(id, "look", error.NoPaneSlots); const nt = panes.Pdf.openPane(p, free, target.path, target.at.line) catch |err| return p.reportError(id, "look", err); - p.placeDoc(id, free, nt); + exec.placeDoc(p, id, free, nt); return; }; // focus an existing pane on this path (rescrolled), else open @@ -1203,7 +1204,7 @@ pub fn lookAt(p: *Pardes, id: usize, operand: []const u8) void { const nt = panes.File.open(p, free, target.path, target.at.line) catch |err| return p.reportError(id, "look", err); if (target.at.col > 0) nt.cur_col = @intCast(target.at.col - 1); - p.placeDoc(id, free, nt); + exec.placeDoc(p, id, free, nt); layout.compute(p); nt.file.?.scroll -|= @max(1, p.rects[free].h -| BOX_H) / 2; if (target.at.end_line != 0) { @@ -1217,7 +1218,7 @@ pub fn lookAt(p: *Pardes, id: usize, operand: []const u8) void { const free = p.freeSlot() orelse return p.reportError(id, "look", error.NoPaneSlots); const nt = panes.Image.create(p, free, target.path, &.{}) catch |err| return p.reportError(id, "look", err); - p.placeDoc(id, free, nt); + exec.placeDoc(p, id, free, nt); }, } } |
