summaryrefslogtreecommitdiff
path: root/src/builtins.zig
diff options
context:
space:
mode:
authorGabriel Schneider <[email protected]>2026-10-01 17:36:52 -0300
committerGabriel Schneider <[email protected]>2026-10-01 17:47:47 -0300
commit2dbb047a82523c578cb511058c6e1b745cfc8073 (patch)
tree4e03e5e59399a233f7f50f21dd883c707db57f40 /src/builtins.zig
parent322aff16a2ca0cfd73e1a62234b8904412b30844 (diff)
downloadpardes-2dbb047a82523c578cb511058c6e1b745cfc8073.tar.gz
pardes-2dbb047a82523c578cb511058c6e1b745cfc8073.zip
A look at a directory opens a pane listing it, as acme's directory window: named dir/, its entries in acme's columns (bytewise, dotfiles kept, a directory's marked /), a look at an entry from there, Get or a look again reads it again, never dirty, Save refused; DirLook terminal keeps ls in a terminal
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Diffstat (limited to 'src/builtins.zig')
-rw-r--r--src/builtins.zig10
1 files changed, 8 insertions, 2 deletions
diff --git a/src/builtins.zig b/src/builtins.zig
index 1a2f132f..1172fa78 100644
--- a/src/builtins.zig
+++ b/src/builtins.zig
@@ -1125,6 +1125,12 @@ pub const Save = struct {
// silent success.
if (c.pane.file == null and !c.pane.isTerminal())
return c.p.reportFailure(c.id, if (c.pane.hasPdf()) "Save: a PDF pane has no text to save" else "Save: an image pane has no text to save");
+ // A directory's listing is no file to write, bare or to a path, as
+ // acme's Put does nothing in a directory window.
+ if (c.pane.file) |file| if (file.listing != null) {
+ var said: [limits.host_path_cap + 48]u8 = undefined;
+ return c.p.reportFailure(c.id, std.fmt.bufPrint(&said, "Save: {s} is a directory", .{file.path[0..@min(file.path.len, limits.host_path_cap)]}) catch "Save: a directory pane has no file to save");
+ };
const path = std.mem.trim(u8, c.arg orelse "", " \t\r\n");
if (path.len > 0) return exec.saveTo(c.p, c.id, path);
// A `+` name is a generated pane's (+Tutor), no file of its own:
@@ -1505,7 +1511,7 @@ pub const LocationsConfig = struct {
try c.p.locations_config.write(&out.writer);
try out.writer.writeByte('\n');
const content = try out.toOwnedSlice();
- const dir = if (c.pane.file) |file| std.fs.path.dirname(file.path) orelse "/" else c.pane.cwdSlice();
+ const dir = if (c.pane.file) |file| panes.Dir.ofName(file.path) else c.pane.cwdSlice();
try panes.Output.fillResults(c.p, c.id, dir, .{ .cmd = .LocationsConfig }, "", content, null);
}
};
@@ -2085,7 +2091,7 @@ const Board = struct {
p.gpa.free(content);
return error.MissingPane;
};
- const dir = if (pane.file) |f| (std.fs.path.dirname(f.path) orelse "/") else pane.cwdSlice();
+ const dir = if (pane.file) |f| panes.Dir.ofName(f.path) else pane.cwdSlice();
try panes.Output.fillResults(p, id, dir, from, "", content, null);
}