summaryrefslogtreecommitdiff
path: root/src/ninep/ctl.zig
diff options
context:
space:
mode:
authorGabriel Schneider <[email protected]>2026-09-28 23:44:15 -0300
committerGabriel Schneider <[email protected]>2026-10-01 00:12:15 -0300
commitc284475c8681ad57c32497c7948e0b020281f4ed (patch)
treebe532b3fa33d6bfd32f7425a035e23e8b55ae6ad /src/ninep/ctl.zig
parentf842a4026348c65370a973e466c2b4f45063bdaf (diff)
downloadpardes-c284475c8681ad57c32497c7948e0b020281f4ed.tar.gz
pardes-c284475c8681ad57c32497c7948e0b020281f4ed.zip
A GUI-only setting says so on a terminal, and DumpDir reads back its directory
`Lift on` over ctl on a terminal answered "unknown control message" while Config listed Lift as unsupported, and the ctl's DumpDir line read bare while Config showed the path in effect. A setting word this frontend lacks is now refused as `Lift is GUI-only` (GripWidth too), and DumpDir reads back the directory in effect, as Config does. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Diffstat (limited to 'src/ninep/ctl.zig')
-rw-r--r--src/ninep/ctl.zig34
1 files changed, 32 insertions, 2 deletions
diff --git a/src/ninep/ctl.zig b/src/ninep/ctl.zig
index caf8914f..4faa7df7 100644
--- a/src/ninep/ctl.zig
+++ b/src/ninep/ctl.zig
@@ -259,7 +259,15 @@ fn checkBuiltin(p: *Pardes, req: Req, line: []const u8, scope: builtins.Scope) ?
const sp = std.mem.indexOfAny(u8, line, " \t");
const word = line[0 .. sp orelse line.len];
const arg = if (sp) |s| std.mem.trim(u8, line[s + 1 ..], " \t") else "";
- const b = std.meta.stringToEnum(Builtin, word) orelse return refuse(p, req, "unknown control message", line);
+ const b = std.meta.stringToEnum(Builtin, word) orelse {
+ // A setting this build's frontend cannot show (Lift, GripWidth on a
+ // terminal) is known, and says so rather than sound misspelt.
+ if (config.Runtime.find(word) != null) {
+ var why: [64]u8 = undefined;
+ return refuse(p, req, std.fmt.bufPrint(&why, "{s} is GUI-only", .{word}) catch "GUI-only", line);
+ }
+ return refuse(p, req, "unknown control message", line);
+ };
// Edit is the one pane word the root takes too: at the active pane.
if (builtins.registry.scope(b) != scope and b != .Edit)
return refuseTo(p, req, if (scope == .pane) "not a window control message" else "not a session control message", line, if (scope == .pane) "/ctl" else "pane/<n>/ctl");
@@ -353,7 +361,12 @@ fn writeSettings(p: *Pardes, w: *std.Io.Writer) !void {
},
.message_ms => |which| try w.print("{s} {d}\n", .{ word, @field(s, "message_" ++ @tagName(which) ++ "_ms") }),
// Bare, it names the default directory.
- .dump_dir => if (s.dump_dir.len > 0) try w.print("{s} {s}\n", .{ word, s.dump_dir.get() }) else try w.print("{s}\n", .{word}),
+ // The directory in effect, as Config reports it; bare only when
+ // there is none (no home to put the default in).
+ .dump_dir => {
+ var buf: [900]u8 = undefined;
+ if (pardes.dump.directory(&buf, s.dump_dir.get())) |dir| try w.print("{s} {s}\n", .{ word, dir }) else try w.print("{s}\n", .{word});
+ },
.transition => |effect| try w.print("{s} {s}\n", .{ word, if (s.panel_transition == effect) "on" else "off" }),
.scene => |effect| if (s.post.level(effect) == 0) try w.print("{s} off\n", .{word}) else try w.print("{s} {d}\n", .{ word, s.post.level(effect) }),
.shader => for (s.post.list()) |entry| if (entry.scene == null) try w.print("{s} {s}\n", .{ word, entry.path.get() }),
@@ -1264,3 +1277,20 @@ test "a Restore of a file that is no dump fails the write before any warning, an
p.dumpFailed("/nowhere/pardes.dump.zon", error.FileNotFound);
try testing.expectEqualStrings("Dump /nowhere/pardes.dump.zon: FileNotFound", p.fs.late_failure[0..p.fs.late_failure_len]);
}
+
+test "a setting this frontend cannot show says GUI-only, and DumpDir reads back the directory in effect" {
+ const p = try withFile(testing.allocator, "x\n");
+ defer p.deinit();
+ const root_ctl = @intFromEnum(tree.TopFile.ctl);
+ if (!builtins.capabilities.lift) {
+ try testing.expectEqualStrings("Lift is GUI-only \"Lift on\"", wr(p, root_ctl, "Lift on\n").reply.ename);
+ try testing.expectEqualStrings("GripWidth is GUI-only \"GripWidth 120\"", wr(p, root_ctl, "GripWidth 120\n").reply.ename);
+ }
+ try testing.expectEqualStrings("unknown control message \"Liftt on\"", wr(p, root_ctl, "Liftt on\n").reply.ename);
+ var buf: [900]u8 = undefined;
+ if (pardes.dump.directory(&buf, "")) |dir| {
+ var want: [920]u8 = undefined;
+ const line = try std.fmt.bufPrint(&want, "\nDumpDir {s}\n", .{dir});
+ try testing.expect(std.mem.indexOf(u8, rd(p, root_ctl, 0, 1 << 16).bytes, line) != null);
+ }
+}