summaryrefslogtreecommitdiff
path: root/src/builtins.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/builtins.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/builtins.zig')
-rw-r--r--src/builtins.zig15
1 files changed, 8 insertions, 7 deletions
diff --git a/src/builtins.zig b/src/builtins.zig
index 21dd4fa9..19be62e2 100644
--- a/src/builtins.zig
+++ b/src/builtins.zig
@@ -1,6 +1,7 @@
//! Command structs and runtime settings form the builtin registry; bindings live in config.zig.
const std = @import("std");
const pardes = @import("pardes.zig");
+const exec = @import("exec.zig");
const look = @import("look.zig");
const edit = @import("edit.zig");
const colors = @import("colors.zig");
@@ -155,7 +156,7 @@ pub const registry = struct {
inline for (manualBuiltinList(), 0..) |T, i|
if (@intFromEnum(b) == i) return T.run(c);
inline for (comptime settingList(), manualBuiltinCount()..) |setting, i|
- if (@intFromEnum(b) == i) return c.p.applySettingBuiltin(setting, c.arg);
+ if (@intFromEnum(b) == i) return exec.applySettingBuiltin(c.p, setting, c.arg);
unreachable;
}
};
@@ -223,7 +224,7 @@ pub const Exec = struct {
pub fn run(c: Ctx) void {
// the destination pane is Look's business (it focuses what answered);
// an execute deliberately leaves you where you were
- _ = c.p.execute(c.id, c.arg orelse return);
+ _ = exec.execute(c.p, c.id, c.arg orelse return);
}
};
@@ -478,8 +479,8 @@ pub const Save = struct {
pub const takes_arg = true;
pub fn run(c: Ctx) void {
const path = std.mem.trim(u8, c.arg orelse "", " \t\r\n");
- if (path.len > 0) return c.p.saveTo(c.id, path);
- if (c.pane.file) |file| if (file.output == null) return c.p.saveFile(c.id);
+ if (path.len > 0) return exec.saveTo(c.p, c.id, path);
+ if (c.pane.file) |file| if (file.output == null) return exec.saveFile(c.p, c.id);
if (c.pane.file != null or c.pane.isTerminal()) c.p.startPrompt(c.pane, .save);
}
};
@@ -585,7 +586,7 @@ pub const DelBelow = struct {
/// pane's tagline: the fast path from wherever you are to a prompt there.
pub const Tty = struct {
pub fn run(c: Ctx) void {
- c.p.spawnTty(c.id);
+ exec.spawnTty(c.p, c.id);
}
};
@@ -593,7 +594,7 @@ pub const Tty = struct {
pub const Tty9p = struct {
pub const enabled = pardes.hosted and @import("builtin").os.tag == .linux;
pub fn run(c: Ctx) void {
- c.p.spawnV9fsTty(c.id);
+ exec.spawnV9fsTty(c.p, c.id);
}
};
@@ -609,7 +610,7 @@ pub const Tutor = struct {
pub fn run(c: Ctx) void {
const free = c.p.freeSlot() orelse return;
const nt = c.p.openTutorView(free) catch return;
- c.p.placeDoc(c.id, free, nt); // a doc like any other
+ exec.placeDoc(c.p, c.id, free, nt); // a doc like any other
}
};