diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/CHANGELOG.md | 4 | ||||
| -rw-r--r-- | src/config.zig | 35 | ||||
| -rw-r--r-- | src/ninep/ctl.zig | 58 |
3 files changed, 34 insertions, 63 deletions
diff --git a/src/CHANGELOG.md b/src/CHANGELOG.md index f21fcacc..0b10238f 100644 --- a/src/CHANGELOG.md +++ b/src/CHANGELOG.md @@ -2,6 +2,10 @@ ## Unreleased +- The root ctl reads the settings in DumpConfig's words: one this + frontend lacks is a `# Word unsupported` comment, which a write of it + back skips, `Font` is the path or name asked for, `Shader off` says the + chain has no file, and `DumpDir` is as it was written. - A mount keeps its connection, and sends each walk, open and first read or write together: an operation through it is one round trip (two for a directory or a file of no stated length) where it was six diff --git a/src/config.zig b/src/config.zig index eb5fe361..976c8a3d 100644 --- a/src/config.zig +++ b/src/config.zig @@ -1437,20 +1437,21 @@ pub const Runtime = struct { return error.NotOnOrOff; } - // Slices are borrowed for one writeReport call. + // Slices are borrowed for one writeReport call. A root ctl read + // (writeSettings) leaves what only the report's trailer says unset. pub const ReportContext = struct { - startup_config_path: ?[]const u8, - platform: []const u8, + startup_config_path: ?[]const u8 = null, + platform: []const u8 = "", theme_name: []const u8, /// The ThemeFile in effect, said as `ThemeFile <path>` in place /// of the theme's name. theme_file: ?[]const u8 = null, compiled_default_shell: []const u8, - hover_delay_frames: u16, + hover_delay_frames: u16 = look_preview_delay_frames, /// Where dumps go when `DumpDir` is unset; empty without a host /// filesystem. default_dump_dir: []const u8 = "", - native_images: bool, + native_images: bool = false, capabilities: Capabilities, state: *const Runtime, /// The `LocationsConfig` argument in effect, as it would be typed. @@ -1467,14 +1468,12 @@ pub const Runtime = struct { /// Each setting line reads as the command that would set it: the word, /// then the value you would type after it (a `# Word unsupported` - /// comment where this shell has no such setting). No colons, no units: `WindowOpacity 70` - /// is both what DumpConfig prints and what you write back. What is in - /// effect but set by no word follows, after a blank line. - pub fn writeReport(out: *std.Io.Writer, context: ReportContext) !void { + /// comment where this shell has no such setting). No colons, no units: + /// `WindowOpacity 70` is both what the root ctl and DumpConfig print and + /// what you write back. + pub fn writeSettings(out: *std.Io.Writer, context: ReportContext) !void { const state = context.state; - // TaglineSize is said wherever the shell sizes its tag, by its word - // or only at build time. - for (settings) |setting| if (!(if (setting.action == .tagline_size) context.capabilities.tagline_font_size else setting.enabled(context.capabilities))) + for (settings) |setting| if (!setting.enabled(context.capabilities)) try out.print("# {s} unsupported\n", .{setting.word}) else switch (setting.action) { .toggle => |field| { @@ -1538,10 +1537,16 @@ pub const Runtime = struct { .motion => try out.print("{s} {s}\n", .{ setting.word, @tagName(state.motion) }), }; if (context.locations.len > 0) try out.print("LocationsConfig {s}\n", .{context.locations}); + } - // In effect, and set by no word: each a `#` line, which runs as - // nothing (exec.executeFrom), so the report can be written back. + /// DumpConfig's: the settings, then what is in effect but set by no + /// word, after a blank line. + pub fn writeReport(out: *std.Io.Writer, context: ReportContext) !void { + try writeSettings(out, context); + // Each a `#` line, which runs as nothing (exec.executeFrom), so the + // report can be written back. try out.writeByte('\n'); + const state = context.state; try out.print("# Last shell spawned: {s}\n", .{shown(state.shell.effective.get())}); try out.print("# Shell change pending: {s}\n", .{onOff(state.shell.pending)}); if (find("Font").?.enabled(context.capabilities)) { @@ -1992,7 +1997,7 @@ pub const Runtime = struct { try writeReport(&out, defaults_context); const web_report = storage[0..out.end]; try std.testing.expect(std.mem.indexOf(u8, web_report, "PanelSlide unsupported\n") != null); - try std.testing.expect(std.mem.indexOf(u8, web_report, "TaglineSize 100\n") != null); + try std.testing.expect(std.mem.indexOf(u8, web_report, "# TaglineSize unsupported\n") != null); try std.testing.expect(std.mem.indexOf(u8, web_report, "# Tagline size: build-time only\n") != null); } }; 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 { |
