summaryrefslogtreecommitdiff
path: root/src/builtins.zig
diff options
context:
space:
mode:
authorGabriel Schneider <[email protected]>2026-09-29 22:59:43 -0300
committerGabriel Schneider <[email protected]>2026-10-01 00:12:17 -0300
commit6d148bb9c433814835935ead30020e43781b7f03 (patch)
tree49e42dbbbff64119ead447598a896a69e638e061 /src/builtins.zig
parentb1485c97b493f7eaf65c6afdfb82e3065306b8fe (diff)
parentd4960472375ea68f709c56a677d8a37571419ff7 (diff)
downloadpardes-6d148bb9c433814835935ead30020e43781b7f03.tar.gz
pardes-6d148bb9c433814835935ead30020e43781b7f03.zip
Release Pardes 0.6
Merge: audit top-five cuts + tag sweeps + Config/DumpConfig (on the audit bug fixes C9, C2). Co-Authored-By: Claude Opus 5.5 <[email protected]>
Diffstat (limited to 'src/builtins.zig')
-rw-r--r--src/builtins.zig32
1 files changed, 30 insertions, 2 deletions
diff --git a/src/builtins.zig b/src/builtins.zig
index c549b17f..c40b2e00 100644
--- a/src/builtins.zig
+++ b/src/builtins.zig
@@ -1283,10 +1283,38 @@ pub const Help = struct {
}
};
-/// Open the settings in effect, each a word to click.
+/// Open the startup file, `init`, in a pane: its pane when it is open, else
+/// the file, else a pane of that name for Save to make it and its directory.
pub const Config = struct {
pub const scope: Scope = .session;
- pub const output: OutputTraits = .{ .name = config.config_buffer };
+ pub fn run(c: Ctx) void {
+ const path = c.p.opts.startup_config_path orelse
+ return c.p.reportFailure(c.id, "Config: no startup file here: no configuration directory");
+ var real_buf: [4096]u8 = undefined;
+ const real = if (pardes.filesystem.resolveOs(path, &real_buf)) |r| r.path else null;
+ for (c.p.panes, 0..) |slot, id| {
+ const pane = slot orelse continue;
+ const f = pane.file orelse continue;
+ if (f.output != null) continue;
+ if (!std.mem.eql(u8, f.path, path) and !(if (real) |r| std.mem.eql(u8, f.path, r) else false)) continue;
+ return look.focusPaneLine(c.p, id, .{}, .keep);
+ }
+ if (real != null) return look.lookAt(c.p, c.id, path);
+ // Not there yet: a pane named for it, which Save makes.
+ const free = c.p.freeSlot() orelse return c.p.reportError(c.id, "Config", error.NoPaneSlots);
+ c.p.newScratchFor(c.id, .scratch);
+ const pane = c.p.panes[free] orelse return;
+ @import("ninep/pane.zig").nameBuffer(c.p, free, path, false) catch |err| return c.p.reportError(c.id, "Config", err);
+ pane.file.?.make_dirs = true;
+ c.p.active = free;
+ }
+};
+
+/// Open the settings in effect, each a word to click, and the startup
+/// file's path.
+pub const DumpConfig = struct {
+ pub const scope: Scope = .session;
+ pub const output: OutputTraits = .{ .name = config.dump_config_buffer };
pub fn run(c: Ctx) void {
panes.Output.openConfig(c.p, c.id) catch |err| c.p.reportError(c.id, "config", err);
}