summaryrefslogtreecommitdiff
path: root/src/ninep/ctl.zig
diff options
context:
space:
mode:
Diffstat (limited to 'src/ninep/ctl.zig')
-rw-r--r--src/ninep/ctl.zig58
1 files changed, 10 insertions, 48 deletions
diff --git a/src/ninep/ctl.zig b/src/ninep/ctl.zig
index 33d7acc5..cb4cfa97 100644
--- a/src/ninep/ctl.zig
+++ b/src/ninep/ctl.zig
@@ -644,54 +644,16 @@ pub fn writeSettingsOf(p: *Pardes, s: *const config.Runtime, w: *std.Io.Writer)
/// ...those a frontend of `caps` takes (the root ctl's: the live view's).
fn writeSettingsFor(p: *Pardes, s: *const config.Runtime, w: *std.Io.Writer, caps: config.Runtime.Capabilities) !void {
- inline for (config.Runtime.settings) |setting| skip: {
- if (comptime !setting.enabled(builtins.capabilities)) continue;
- if (!setting.enabled(caps)) break :skip;
- const word = setting.word;
- switch (setting.action) {
- .toggle => |field| try w.print("{s} {s}\n", .{ word, if (@field(s, @tagName(field))) "on" else "off" }),
- .theme => if (s == &p.settings) {
- if (pardes.colors.loadedThemeFile(p)) |path| try w.print("ThemeFile {s}\n", .{path}) else try w.print("{s} {s}\n", .{ word, p.theme().name });
- } else try w.print("{s} {s}\n", .{ word, pardes.themes[s.theme].name }),
- .shell => {
- const chosen = s.shell.requested.get();
- try w.print("{s} {s}\n", .{ word, if (chosen.len > 0) chosen else config.defaultShell() });
- },
- .font => {
- const requested = s.font.requested_name.get();
- const name = if (requested.len > 0) requested else s.font.effective_name.get();
- const size = if (s.font.requested_size_hundredths != 0) s.font.requested_size_hundredths else s.font.effective_size_hundredths;
- if (name.len > 0 and size != 0)
- try w.print("{s} {s}:{d}.{d:0>2}\n", .{ word, name, size / 100, size % 100 })
- else if (name.len > 0)
- try w.print("{s} {s}\n", .{ word, name });
- },
- .tagline_size => try w.print("{s} {d}\n", .{ word, s.font.tagline_percent }),
- .window_opacity => try w.print("{s} {d}\n", .{ word, s.window_opacity }),
- .window_blur => try w.print("{s} {d}\n", .{ word, s.window_blur }),
- .choice => |which| switch (which) {
- inline else => |field| try w.print("{s} {s}\n", .{ word, @tagName(@field(s, @tagName(field))) }),
- },
- .message_ms => |which| try w.print("{s} {d}\n", .{ word, @field(s, "message_" ++ @tagName(which) ++ "_ms") }),
- // The directory in effect, as DumpConfig 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() }),
- .shader_animation => try w.print("{s} {s}\n", .{ word, @tagName(s.shader_animation) }),
- .lift => try w.print("{s} {s}\n", .{ word, @tagName(s.lift) }),
- .motion => try w.print("{s} {s}\n", .{ word, @tagName(s.motion) }),
- .inactive_dim => try w.print("{s} {d}\n", .{ word, s.inactive_dim }),
- .grip_width => try w.print("{s} {d}\n", .{ word, s.grip_width }),
- .callstack_depth => try w.print("{s} {d}\n", .{ word, s.callstack_depth }),
- .search_rows => try w.print("{s} {d}\n", .{ word, s.search_rows }),
- .tab => try w.print("{s} {d}\n", .{ word, s.tab }),
- }
- }
+ // DumpConfig's words: a `# Word unsupported` comment for what `caps` lacks.
+ var dump_dir: [1024]u8 = undefined;
+ try config.Runtime.writeSettings(w, .{
+ .theme_name = p.theme().name,
+ .theme_file = pardes.colors.loadedThemeFile(p),
+ .compiled_default_shell = config.defaultShell(),
+ .default_dump_dir = pardes.dump.defaultDirectory(&dump_dir) orelse "",
+ .capabilities = caps,
+ .state = s,
+ });
}
pub fn rootLen(p: *Pardes) u64 {