diff options
Diffstat (limited to 'src/exec.zig')
| -rw-r--r-- | src/exec.zig | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/src/exec.zig b/src/exec.zig index 5a421f19..c673aab2 100644 --- a/src/exec.zig +++ b/src/exec.zig @@ -959,6 +959,12 @@ pub fn runBuiltinFrom(p: *Pardes, b: Builtin, id: usize, txt: []const u8, arg: ? p.fs.unlogged = false; pane.msg_announcement = true; } + // A word for one kind of pane, on another: refused with why, not a + // silent nothing (Palette on a file, Filter on a PDF). + if (builtins.registry.needs(b)) |kind| if (p.panes[id] == null or !kind.has(pane)) { + var said: [96]u8 = undefined; + return p.reportFailure(id, std.fmt.bufPrint(&said, "{s}: only {s} pane takes it", .{ @tagName(b), kind.noun() }) catch "only another kind of pane takes it"); + }; const c: builtins.Ctx = .{ .p = p, .pane = pane, .id = id, .txt = txt, .arg = arg, .from_body = from_body }; builtins.registry.dispatch(b, c); } @@ -1009,12 +1015,13 @@ pub fn applySettingBuiltin(p: *Pardes, setting: config.Runtime.Setting, arg: ?[] return p.reportFailure(p.active, std.fmt.bufPrint(&text, "Shell: {s}", .{refused}) catch "Shell: no such shell"); } } - if (!p.settings.apply(setting, want) and p.announce) p.reportFailure(p.active, "Shell: does not take that value"); + if (!p.settings.apply(setting, want) and p.announce) p.reportFailure(p.active, "Shell: takes " ++ comptime config.Runtime.takes(.shell).?); }, + // Said with what it takes: its words, its range. else => if (!p.settings.apply(setting, arg) and p.announce) { - var text: [96]u8 = undefined; - const takes = if (setting.action == .toggle) "takes on or off" else "does not take that value"; - p.reportFailure(p.active, std.fmt.bufPrint(&text, "{s}: {s}", .{ setting.word, takes }) catch takes); + var text: [160]u8 = undefined; + const why = if (config.Runtime.takes(setting.action)) |values| std.fmt.bufPrint(&text, "{s}: takes {s}", .{ setting.word, values }) else std.fmt.bufPrint(&text, "{s}: does not take that value", .{setting.word}); + p.reportFailure(p.active, why catch "does not take that value"); }, } if (p.settings.colors != previous_colors) { |
