summaryrefslogtreecommitdiff
path: root/src/builtins.zig
diff options
context:
space:
mode:
authorGabriel Schneider <[email protected]>2026-10-02 00:50:41 -0300
committerGabriel Schneider <[email protected]>2026-10-02 01:43:04 -0300
commit97c939b981bc7fbf1a58511a9d83d9f1e12a8f16 (patch)
tree168f1c1cb7005d4b684be312a36be205e642f7df /src/builtins.zig
parentd65ec3394ff619118d9208718477469c673a5598 (diff)
downloadpardes-97c939b981bc7fbf1a58511a9d83d9f1e12a8f16.tar.gz
pardes-97c939b981bc7fbf1a58511a9d83d9f1e12a8f16.zip
An Edit filter that can never be reaped no longer holds the Edit's answer: at the limit the command's group is killed and reaped off the answer's path, the stdin writer owning its input, so a filter writing its own ctl with > or >> answers EIO at 10 s instead of hanging; a running Edit keeps its own copies of the names it reports, and the panes it changes refuse Del, delete, rmdir, Undo, Redo, Get and Zerox (busy, EBUSY); e and r say unreadable files in Get's words; the reference says both sides of a filter's own ctl write need <>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Diffstat (limited to 'src/builtins.zig')
-rw-r--r--src/builtins.zig5
1 files changed, 5 insertions, 0 deletions
diff --git a/src/builtins.zig b/src/builtins.zig
index 77e1169d..84904959 100644
--- a/src/builtins.zig
+++ b/src/builtins.zig
@@ -1141,6 +1141,7 @@ pub const Get = struct {
pub const takes_arg = true;
pub fn run(c: Ctx) void {
const ctl = @import("ninep/ctl.zig");
+ if (@import("edit_cmd.zig").busyOn(c.p, c.id)) return c.p.reportFailure(c.id, "Get: " ++ @import("edit_cmd.zig").e_busy);
const f = if (c.pane.file) |*file| file else return c.p.reportFailure(c.id, "Get: only a file pane takes it");
const typed = std.mem.trim(u8, c.arg orelse "", " \t\r\n");
// A directory pane: the directory read again (Dir.zig), as acme's
@@ -1247,6 +1248,7 @@ pub const Incl = struct {
/// unsaved state, with a scroll and a cursor of its own (File.zerox).
pub const Zerox = struct {
pub fn run(c: Ctx) void {
+ if (@import("edit_cmd.zig").busyOn(c.p, c.id)) return c.p.reportFailure(c.id, "Zerox: " ++ @import("edit_cmd.zig").e_busy);
const f = c.pane.file orelse return c.p.reportFailure(c.id, "Zerox: only a file pane takes it");
if (f.output != null or f.listing != null or f.mini != null) return c.p.reportFailure(c.id, "Zerox: only a file pane takes it");
const free = c.p.freeSlot() orelse return c.p.reportError(c.id, "Zerox", error.NoPaneSlots);
@@ -1302,6 +1304,7 @@ pub const Del = struct {
pub const takes_arg = true;
pub fn run(c: Ctx) void {
const side = std.mem.trim(u8, c.arg orelse "", " \t\r\n");
+ if (@import("edit_cmd.zig").busyOn(c.p, c.id)) return c.p.reportFailure(c.id, "Del: " ++ @import("edit_cmd.zig").e_busy);
// acme's Del asks winclean first (exec.c del): unsaved text is warned
// about once, and the same Del again, nothing edited since, closes.
if (warnModifiedIn(c, .Del, .{ .pane = c.id })) return;
@@ -1380,6 +1383,7 @@ pub const Edit = struct {
/// limits.undo_max steps (256).
pub const Undo = struct {
pub fn run(c: Ctx) void {
+ if (@import("edit_cmd.zig").busyOn(c.p, c.id)) return c.p.reportFailure(c.id, "Undo: " ++ @import("edit_cmd.zig").e_busy);
if (c.pane.file) |f| if (f.history.undo_len == 0) return c.p.setMessage(c.id, "Undo: nothing to undo");
edit.doUndo(c.p, &c.pane.body);
}
@@ -1388,6 +1392,7 @@ pub const Undo = struct {
/// Redo the last undone edit.
pub const Redo = struct {
pub fn run(c: Ctx) void {
+ if (@import("edit_cmd.zig").busyOn(c.p, c.id)) return c.p.reportFailure(c.id, "Redo: " ++ @import("edit_cmd.zig").e_busy);
if (c.pane.file) |f| if (f.history.redo_len == 0) return c.p.setMessage(c.id, "Redo: nothing to redo");
edit.doRedo(c.p, &c.pane.body);
}