diff options
Diffstat (limited to 'src/Output.zig')
| -rw-r--r-- | src/Output.zig | 22 |
1 files changed, 13 insertions, 9 deletions
diff --git a/src/Output.zig b/src/Output.zig index 29e49180..359db1cf 100644 --- a/src/Output.zig +++ b/src/Output.zig @@ -905,7 +905,7 @@ fn openStepped(p: *Pardes, id: usize, from: Origin, content: []u8) !void { look.armLookWalk(p, free); } -fn helpContent(gpa: std.mem.Allocator, prefix: []const u8) ![]u8 { +fn helpContent(p: *const Pardes, gpa: std.mem.Allocator, prefix: []const u8) ![]u8 { const full_header = "pardes builtins, and how to run each:\nSPC and its keys, a chord, a button, the\ntopbar - or the name, executed anywhere.\n\n"; const group_header = "pardes builtins under SPC"; const calls_help = "\nCallstack: static caller chains,\nwith signatures and clickable call sites.\nCallers / Callees: one direction at a time.\n"; @@ -934,8 +934,10 @@ fn helpContent(gpa: std.mem.Allocator, prefix: []const u8) ![]u8 { } for (pardes.builtin_rows) |row| { // a path-less builtin filters as the empty path: in the full listing - // (which starts with nothing) and out of every group + // (which starts with nothing) and out of every group; a window's own + // word is none in a terminal's view if (!std.mem.startsWith(u8, row.path orelse "", prefix)) continue; + if (!builtins.registry.here(p, row.cmd)) continue; try w.print("{s}\n", .{row.line}); } if (show_calls_help) try w.writeAll(calls_help); @@ -966,21 +968,23 @@ fn helpContent(gpa: std.mem.Allocator, prefix: []const u8) ![]u8 { } pub fn openHelp(p: *Pardes, id: usize, prefix: []const u8) !void { - const content = try helpContent(p.gpa, prefix); + const content = try helpContent(p, p.gpa, prefix); // content is handed off unfreed on purpose: openRead adopts it or frees // it, and nothing between the alloc above and this line can fail. return openRead(p, id, .{ .cmd = .Help }, prefix, content); } test "full Help renders builtin rows, a call hierarchy guide, then language keys" { - const content = try helpContent(std.testing.allocator, ""); + const core = try Pardes.init(std.testing.allocator, .{ .tty_only = true }); + defer core.deinit(); + const content = try helpContent(core, std.testing.allocator, ""); defer std.testing.allocator.free(content); // FIRST blank line: the end of the header (the footer opens with one too) const body = content[(std.mem.indexOf(u8, content, "\n\n") orelse return error.MissingHelpHeader) + 2 ..]; var lines = std.mem.splitScalar(u8, body, '\n'); - for (pardes.builtin_rows) |row| + for (pardes.builtin_rows) |row| if (builtins.registry.here(core, row.cmd)) try std.testing.expectEqualStrings(row.line, lines.next() orelse return error.MissingBuiltinHelpRow); // The short call guide disambiguates the three related commands. @@ -995,7 +999,7 @@ test "full Help renders builtin rows, a call hierarchy guide, then language keys return error.MissingLanguageKeys); try std.testing.expect(std.mem.indexOf(u8, body, "\ngd gD gy gi gr goto: definition,\n") != null); // The language group also explains call commands, without the motion footer. - const group = try helpContent(std.testing.allocator, "l"); + const group = try helpContent(core, std.testing.allocator, "l"); defer std.testing.allocator.free(group); try std.testing.expect(std.mem.indexOf(u8, group, "language keys") == null); try std.testing.expect(std.mem.indexOf(u8, group, "Callstack: static caller chains") != null); @@ -1013,13 +1017,13 @@ pub fn openConfig(p: *Pardes, id: usize) !void { .locations = located.written(), .default_dump_dir = if (host_fs) (pardes.dump.defaultDirectory(&dir_buf) orelse "") else "", .startup_config_path = p.opts.startup_config_path, - .platform = @tagName(pardes.platform), + .platform = builtins.viewPlatform(p), .theme_name = p.theme().name, .theme_file = pardes.colors.loadedThemeFile(p), .compiled_default_shell = config.defaultShell(), .hover_delay_frames = config.look_preview_delay_frames, .native_images = p.native_images, - .capabilities = builtins.capabilities, + .capabilities = builtins.viewCapabilities(p), .state = &p.settings, }); const content = try out.toOwnedSlice(); @@ -1061,7 +1065,7 @@ pub fn openEffectCode(p: *Pardes, id: usize, argument: []const u8) !void { .transition, .scene => {}, else => return error.NotAnEffect, } - if (!setting.enabled(builtins.capabilities)) return error.EffectUnavailable; + if (!setting.enabled(builtins.viewCapabilities(p))) return error.EffectUnavailable; // Without -Dembed-sources the paths would name nothing this build can open. if (!limits.embedded_sources) return error.EffectUnavailable; const paths = effect_sources.forSetting(setting) orelse |
