summaryrefslogtreecommitdiff
path: root/src/look.zig
diff options
context:
space:
mode:
authorGabriel Schneider <[email protected]>2026-09-27 22:30:58 -0300
committerGabriel Schneider <[email protected]>2026-10-01 00:12:14 -0300
commit52049344c1992850ea712e029eb5c4a88a7dfe19 (patch)
tree24d12755e9545470dda8021542299f0f72fd0baf /src/look.zig
parent82551f77833a09b313bd3e58371582abd1aedcc4 (diff)
downloadpardes-52049344c1992850ea712e029eb5c4a88a7dfe19.tar.gz
pardes-52049344c1992850ea712e029eb5c4a88a7dfe19.zip
Move exec out of pardes.zig into exec.zig
Pure move, no behaviour change (acme keeps this in exec.c): execute, commandText, max_exec_depth, executeBuiltinLine, applyStartupConfig, runBuiltin and applySettingBuiltin; the getarg-style operand code (withArg, PointerOperand, pointerOperand, heldSelection, chordEachSel); takesCommandLine and the terminals commands run in (spawnTty, spawnV9fsTty, spawnTtyWithMount, evictLonePristineTty, replaceStillborn, ttyForDir); placeDoc; and the save path (submitSave, saveFile, saveTo, askWrite), with the acme-chords test, go verbatim to exec.zig. The methods become free functions taking `p: *Pardes`. executeBuiltinLine is called from ~170 places as `p.executeBuiltinLine(..)`, so Pardes keeps one declaration alias for it and those call sites stay; the other 104 calls change from `p.execute(..)` to `exec.execute(p, ..)`. ninep/ctl.zig has a local named exec, so it writes `pardes.exec.execute` instead of importing the file. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Diffstat (limited to 'src/look.zig')
-rw-r--r--src/look.zig17
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);
},
}
}