From 02ea4db25f9802e76112f3b4e69aa75e5a9464dc Mon Sep 17 00:00:00 2001 From: Gabriel Schneider Date: Tue, 15 Sep 2026 18:41:15 -0300 Subject: Default location results to stacked addresses and source previews --- src/pardes.zig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/pardes.zig') diff --git a/src/pardes.zig b/src/pardes.zig index d115bf2d..2729ef93 100644 --- a/src/pardes.zig +++ b/src/pardes.zig @@ -1121,7 +1121,7 @@ test "LocationsConfig command reports partial updates and survives restore" { const out = file.output orelse continue; if (!std.meta.eql(out.from, panes.Output.Origin{ .cmd = .LocationsConfig })) continue; reports += 1; - try std.testing.expectEqualStrings("LocationsConfig context:5 tscontext:on tslocations:off\n", file.content); + try std.testing.expectEqualStrings("LocationsConfig context:5 tscontext:on tslocations:off layout:stacked\n", file.content); } try std.testing.expectEqual(@as(usize, 1), reports); try p.dumpState(); -- cgit v1.3 From 3f4f26e0e40d06427e72f72e760d01adcdc0326c Mon Sep 17 00:00:00 2001 From: Gabriel Schneider Date: Tue, 15 Sep 2026 18:52:46 -0300 Subject: Reuse bounded source analysis and speed up result context traversal --- build.zig | 17 ++++ docs/config.md | 3 + docs/locations-performance.md | 45 +++++++++ src/locations.zig | 27 ++++-- src/locations_cache.zig | 213 ++++++++++++++++++++++++++++++++++++++++++ src/main.zig | 1 + src/pardes.zig | 2 + src/syntax.zig | 123 +++++++++++++++++++++--- test/locations_bench.zig | 61 ++++++++++++ test/output.zig | 139 +++++++++++++++++++++++++++ 10 files changed, 607 insertions(+), 24 deletions(-) create mode 100644 docs/locations-performance.md create mode 100644 src/locations_cache.zig create mode 100644 test/locations_bench.zig (limited to 'src/pardes.zig') diff --git a/build.zig b/build.zig index 8a5b4c41..aeae7443 100644 --- a/build.zig +++ b/build.zig @@ -1009,6 +1009,23 @@ pub fn build(b: *std.Build) void { const lspprobe_step = b.step("lspprobe", "one language query against the real seam (-- : [arg] [--reps N])"); lspprobe_step.dependOn(&run_lspprobe.step); + const locations_bench_step = b.step("locations-bench", "measure cold/warm result formatting (-Doptimize=ReleaseFast; CSV on stderr)"); + if (optimize != .ReleaseFast) { + locations_bench_step.dependOn(&b.addFail("locations-bench requires -Doptimize=ReleaseFast").step); + } else { + const locations_bench_module = b.createModule(.{ + .target = target, + .optimize = .ReleaseFast, + .root_source_file = b.path("test/locations_bench.zig"), + .link_libc = true, + }); + locations_bench_module.addImport("pardes", core_module); + const locations_bench = b.addTest(.{ .root_module = locations_bench_module, .filters = &.{"locations benchmark cold and warm formatting"} }); + const run_locations_bench = b.addRunArtifact(locations_bench); + run_locations_bench.has_side_effects = true; + locations_bench_step.dependOn(&run_locations_bench.step); + } + const perf_optimize: std.builtin.OptimizeMode = .ReleaseFast; const perf_options = b.addOptions(); const perf_target = std.Target.Query.fromTarget(&target.result); diff --git a/docs/config.md b/docs/config.md index 6f3273b9..972f9403 100644 --- a/docs/config.md +++ b/docs/config.md @@ -177,6 +177,9 @@ depth (for example, `main.zig:42 ***`). Ordinary neighboring source lines retain syntax colors; declaration headers do not. A declaration context line ends with ` ...` when source lines are omitted before the next displayed row from that file. +Source analysis is reused across result queries while the source bytes stay the +same. The cache retains at most 64 files and 64 MiB; it checks current buffer or +filesystem contents on each refresh. Open file buffers supply context from their current edits. Missing files still leave the original result available. These settings apply to subsequent result generation and survive `Dump`/`Restore`. Invalid fields reject the entire diff --git a/docs/locations-performance.md b/docs/locations-performance.md new file mode 100644 index 00000000..32ee08bd --- /dev/null +++ b/docs/locations-performance.md @@ -0,0 +1,45 @@ +# Location results performance + +Run `zig build locations-bench -Doptimize=ReleaseFast` from the repository root. +CSV measurements are written to stderr. The benchmark covers 100, 500 and +1,500 matches, both layouts, and ordinary/tree-sitter context separately and +together. Each configuration starts with an empty analysis cache and then +repeats twice with unchanged source and producer results. There are no timing +thresholds in the tests. + +The fixtures are open, unsaved Zig buffers: one module containing functions +with 20 local declarations and one match per function. The largest is +1,813,921 bytes. Timings cover `Output.fillResults`, including sorting, +formatting, metadata and refresh comparison. Source generation, input +allocation, filesystem I/O, subprocess startup and GUI drawing are excluded. + +## Measurement on September 15, 2026 + +Milliseconds for 1,500 matches on the development Linux machine: + +| Layout / context | Before optimization, repeated | After, cold | After, warm repeats | +| --- | ---: | ---: | ---: | +| Inline / declaration headers | 1,259 | 224 | 2.32 / 2.14 | +| Inline / headers and two neighboring lines | 1,250 | 291 | 4.80 / 4.66 | +| Stacked / declaration headers | — | 224 | 2.04 / 1.88 | +| Stacked / headers and two neighboring lines | — | 294 | 3.92 / 3.65 | + +The before figures are medians of three runs of the same fixture with the +previous parser/traversal path. After figures are one cold and two warm +samples from the repository benchmark. Stacked layout has no before figure. +These are focused formatter measurements, not end-to-end GUI latency promises. + +## Changes + +- Declaration traversal uses a tree cursor that retains its ancestor stack. +- Declarations and ordinary-context colors share a single parse. +- Muted declaration headers do not request unused source colors. +- Exact source snapshots cache complete analysis across queries. Unsaved + buffers take precedence; filesystem sources are reread to detect changes. +- The cache retains at most 64 entries and 64 MiB, evicting the least recently + used entry. Oversized analysis is used for the current result without being + retained. Pending context owns its selected color bytes so later eviction + cannot invalidate rows already collected. + +Cold parsing remains proportional to source size. Unchanged refreshes still +read/compare source bytes and assemble results, but skip parsing and analysis. diff --git a/src/locations.zig b/src/locations.zig index 97caf1d9..b34f7a6f 100644 --- a/src/locations.zig +++ b/src/locations.zig @@ -158,17 +158,19 @@ const Pending = struct { } }; -fn sourceText(p: *pardes.Pardes, arena: std.mem.Allocator, dir: []const u8, path: []const u8) ?[]const u8 { +const Source = struct { path: []const u8, bytes: []const u8 }; + +fn sourceText(p: *pardes.Pardes, arena: std.mem.Allocator, dir: []const u8, path: []const u8) ?Source { if (std.ascii.eqlIgnoreCase(std.fs.path.extension(path), ".pdf")) return null; const lexical = std.fs.path.resolvePosix(arena, &.{ dir, path }) catch return null; var pathbuf: [4096]u8 = undefined; const full = if (filesystem.resolve(p, path, dir, &pathbuf)) |resolved| resolved.path else lexical; for (p.panes) |slot| if (slot) |pane| { - if (pane.file) |file| if (file.output == null and (std.mem.eql(u8, file.path, full) or std.mem.eql(u8, file.path, lexical))) return file.content; + if (pane.file) |file| if (file.output == null and (std.mem.eql(u8, file.path, full) or std.mem.eql(u8, file.path, lexical))) return .{ .path = lexical, .bytes = file.content }; }; const bytes = filesystem.read(p, full) catch return null; defer p.gpa.free(bytes); - return arena.dupe(u8, bytes) catch null; + return .{ .path = lexical, .bytes = arena.dupe(u8, bytes) catch return null }; } /// Inputs are sorted results. Expand each source group, merge context with @@ -193,18 +195,22 @@ pub fn format(p: *pardes.Pardes, dir: []const u8, input: []const u8, anchor: ?us const group_start = pending.items.len; try pending.appendSlice(arena, matches.items[first..end]); if (expand and (p.locations_config.context > 0 or p.locations_config.tscontext)) { - if (sourceText(p, arena, dir, path)) |source| { + if (sourceText(p, arena, dir, path)) |text| { + const source = text.bytes; var source_lines: std.ArrayList([]const u8) = .empty; var source_split = std.mem.splitScalar(u8, source, '\n'); while (source_split.next()) |line| try source_lines.append(arena, line); const count = source_lines.items.len; const wanted = try arena.alloc(u8, count); @memset(wanted, 0); - const source_colors = syntax.highlightFileRange(arena, path, source, 0, source.len) catch &.{}; - const declarations = if (p.locations_config.tscontext) - syntax.contextDeclarations(arena, path, source) catch &.{} - else - &.{}; + // Muted declaration headers do not need a source-color pass. + // Exact bytes include unsaved edits and virtual/remote sources. + var cached = p.locations_cache.get(p.tree_sitter_gpa, text.path, source, p.locations_config.tscontext, p.locations_config.context > 0) catch + @import("locations_cache.zig").Result{ .analysis = syntax.analyzeSource(arena, text.path, source, p.locations_config.tscontext, p.locations_config.context > 0) catch .{} }; + defer cached.deinit(p.tree_sitter_gpa); + const analysis = cached.analysis; + const source_colors = analysis.colors; + const declarations = if (p.locations_config.tscontext) analysis.declarations else &.{}; for (pending.items[group_start..]) |*match| { const row = match.at.line -| 1; if (row >= count) continue; @@ -235,7 +241,8 @@ pub fn format(p: *pardes.Pardes, dir: []const u8, input: []const u8, anchor: ?us const declaration = kind & declaration_context != 0; const colors = if (!declaration and offset + line.len <= source_colors.len) source_colors[offset..][0..line.len] else &.{}; const hidden = !declaration or !p.locations_config.tslocations or kind & declaration_start == 0; - try appendContext(arena, &pending, path, line, row, declaration, hidden, colors); + // Later source groups may evict this analysis from the cache. + try appendContext(arena, &pending, path, line, row, declaration, hidden, try arena.dupe(u8, colors)); } } } diff --git a/src/locations_cache.zig b/src/locations_cache.zig new file mode 100644 index 00000000..a079226b --- /dev/null +++ b/src/locations_cache.zig @@ -0,0 +1,213 @@ +const std = @import("std"); +const syntax = @import("syntax.zig"); + +/// A cache hit borrows its analysis; an entry too large to retain transfers +/// ownership instead. Call deinit after consuming either result. +pub const Result = struct { + analysis: syntax.SourceAnalysis, + owned: bool = false, + + pub fn deinit(result: *Result, gpa: std.mem.Allocator) void { + if (result.owned) result.analysis.deinit(gpa); + result.* = undefined; + } +}; + +/// Owned source snapshots keep analysis valid across filesystem changes and +/// borrowed editor buffers. Entries are ordered from least to most recent. +pub const Cache = struct { + pub const max_bytes = 64 * 1024 * 1024; + pub const max_entries = 64; + + const Entry = struct { + path: []u8, + source: []u8, + analysis: syntax.SourceAnalysis, + declarations_ready: bool, + colors_ready: bool, + + fn size(entry: Entry) usize { + return entry.path.len + entry.source.len + entry.analysis.colors.len + + entry.analysis.declarations.len * @sizeOf(syntax.ContextDeclaration); + } + + fn deinit(entry: *Entry, gpa: std.mem.Allocator) void { + gpa.free(entry.path); + gpa.free(entry.source); + entry.analysis.deinit(gpa); + } + }; + + entries: [max_entries]Entry = undefined, + len: usize = 0, + bytes: usize = 0, + analyses: usize = 0, + hits: usize = 0, + + pub fn deinit(cache: *Cache, gpa: std.mem.Allocator) void { + for (cache.entries[0..cache.len]) |*entry| entry.deinit(gpa); + cache.* = .{}; + } + + /// Borrowed slices remain valid until the next get or cache deinit; an + /// owned result remains valid until Result.deinit. All calls for this + /// cache must use the same allocator. Unsupported languages + /// are cached too, including their empty analysis arrays. + pub fn get(cache: *Cache, gpa: std.mem.Allocator, path: []const u8, source: []const u8, want_declarations: bool, want_colors: bool) !Result { + return cache.getBounded(gpa, path, source, want_declarations, want_colors, max_bytes); + } + + fn getBounded(cache: *Cache, gpa: std.mem.Allocator, path: []const u8, source: []const u8, want_declarations: bool, want_colors: bool, budget: usize) !Result { + if (source.len > budget or path.len > budget - source.len) return error.SourceTooLarge; + var previous: ?usize = null; + var declarations = want_declarations; + var colors = want_colors; + for (cache.entries[0..cache.len], 0..) |entry, index| { + if (!std.mem.eql(u8, entry.path, path)) continue; + previous = index; + if (!std.mem.eql(u8, entry.source, source)) break; + if ((!want_declarations or entry.declarations_ready) and (!want_colors or entry.colors_ready)) { + // Moving the small ownership record keeps the underlying + // allocations intact and avoids timestamp/overflow state. + std.mem.copyForwards(Entry, cache.entries[index .. cache.len - 1], cache.entries[index + 1 .. cache.len]); + cache.entries[cache.len - 1] = entry; + cache.hits +|= 1; + return .{ .analysis = entry.analysis }; + } + declarations = declarations or entry.declarations_ready; + colors = colors or entry.colors_ready; + break; + } + // A supported full-source color map needs one byte per source byte. + // Reject that known minimum before parsing, so the caller's uncached + // path does not repeat an expensive analysis for oversized inputs. + const input_bytes = path.len + source.len; + if (colors and syntax.supportsPath(path) and source.len > budget - input_bytes) return error.SourceTooLarge; + var analysis = try syntax.analyzeSource(gpa, path, source, declarations, colors); + errdefer analysis.deinit(gpa); + cache.analyses +|= 1; + const analysis_bytes = analysis.colors.len + analysis.declarations.len * @sizeOf(syntax.ContextDeclaration); + if (analysis_bytes > budget - input_bytes) return .{ .analysis = analysis, .owned = true }; + const owned_path = try gpa.dupe(u8, path); + errdefer gpa.free(owned_path); + const owned_source = try gpa.dupe(u8, source); + errdefer gpa.free(owned_source); + const next: Entry = .{ + .path = owned_path, + .source = owned_source, + .analysis = analysis, + .declarations_ready = declarations, + .colors_ready = colors, + }; + // Commit only after every allocation succeeds. A failed refresh leaves + // the previous cached snapshot usable by the next request. + if (previous) |index| cache.remove(gpa, index); + while (cache.len == max_entries or cache.bytes > budget - next.size()) cache.remove(gpa, 0); + cache.entries[cache.len] = next; + cache.len += 1; + cache.bytes += next.size(); + return .{ .analysis = next.analysis }; + } + + fn remove(cache: *Cache, gpa: std.mem.Allocator, index: usize) void { + cache.bytes -= cache.entries[index].size(); + cache.entries[index].deinit(gpa); + std.mem.copyForwards(Entry, cache.entries[index .. cache.len - 1], cache.entries[index + 1 .. cache.len]); + cache.len -= 1; + } +}; + +test "locations cache validates exact source and path and upgrades analysis" { + const gpa = std.testing.allocator; + syntax.start(gpa); + defer syntax.stop(); + var cache: Cache = .{}; + defer cache.deinit(gpa); + const source = "const Thing = struct {\n value: u32,\n};\n"; + _ = try cache.get(gpa, "a.zig", source, true, false); + try std.testing.expectEqual(@as(usize, 1), cache.analyses); + _ = try cache.get(gpa, "a.zig", source, true, false); + try std.testing.expectEqual(@as(usize, 1), cache.analyses); + try std.testing.expectEqual(@as(usize, 1), cache.hits); + _ = try cache.get(gpa, "a.zig", source, false, true); + try std.testing.expectEqual(@as(usize, 2), cache.analyses); + try std.testing.expect(cache.entries[0].declarations_ready and cache.entries[0].colors_ready); + _ = try cache.get(gpa, "a.zig", source, true, true); + try std.testing.expectEqual(@as(usize, 2), cache.analyses); + _ = try cache.get(gpa, "a.zig", "const Thing = struct {\n other: u32,\n};\n", true, true); + try std.testing.expectEqual(@as(usize, 3), cache.analyses); + try std.testing.expectEqual(@as(usize, 1), cache.len); + _ = try cache.get(gpa, "a.txt", source, true, true); + try std.testing.expectEqual(@as(usize, 4), cache.analyses); + try std.testing.expectEqual(@as(usize, 2), cache.len); +} + +test "locations cache bounds memory and entries and evicts least recently used" { + const gpa = std.testing.allocator; + var cache: Cache = .{}; + defer cache.deinit(gpa); + for (0..Cache.max_entries) |index| { + var path: [32]u8 = undefined; + _ = try cache.get(gpa, try std.fmt.bufPrint(&path, "{d}.unknown", .{index}), "source", false, false); + } + _ = try cache.get(gpa, "0.unknown", "source", false, false); + _ = try cache.get(gpa, "new.unknown", "source", false, false); + try std.testing.expectEqual(Cache.max_entries, cache.len); + try std.testing.expectEqualStrings("2.unknown", cache.entries[0].path); + const count = cache.analyses; + _ = try cache.get(gpa, "0.unknown", "source", false, false); + try std.testing.expectEqual(count, cache.analyses); + cache.deinit(gpa); + _ = try cache.getBounded(gpa, "a.unknown", "source", false, false, 40); + _ = try cache.getBounded(gpa, "b.unknown", "source", false, false, 40); + _ = try cache.getBounded(gpa, "c.unknown", "source", false, false, 40); + try std.testing.expectEqual(@as(usize, 2), cache.len); + try std.testing.expect(cache.bytes <= 40); + try std.testing.expectEqualStrings("b.unknown", cache.entries[0].path); + try std.testing.expectError(error.SourceTooLarge, cache.getBounded(gpa, "large.unknown", "x" ** 41, false, false, 40)); + try std.testing.expectEqual(@as(usize, 2), cache.len); + if (syntax.supportsPath("large.zig")) { + const before = cache.analyses; + try std.testing.expectError(error.SourceTooLarge, cache.getBounded(gpa, "large.zig", "x" ** 25, true, true, 40)); + try std.testing.expectEqual(before, cache.analyses); + } + cache.deinit(gpa); + try std.testing.expectEqual(@as(usize, 0), cache.bytes); + try std.testing.expectEqual(@as(usize, 0), cache.len); +} + +test "locations cache keeps its previous snapshot after allocation failure" { + var failing = std.testing.FailingAllocator.init(std.testing.allocator, .{}); + const gpa = failing.allocator(); + var cache: Cache = .{}; + defer cache.deinit(gpa); + _ = try cache.get(gpa, "a.unknown", "old bytes", false, false); + const retained = cache.bytes; + failing.fail_index = failing.alloc_index; + try std.testing.expectError(error.OutOfMemory, cache.get(gpa, "a.unknown", "new bytes", false, false)); + try std.testing.expectEqual(@as(usize, 1), cache.len); + try std.testing.expectEqual(retained, cache.bytes); + try std.testing.expectEqualStrings("old bytes", cache.entries[0].source); + // This succeeds with allocations still disabled because the old entry + // remains valid and the hit path moves ownership records only. + _ = try cache.get(gpa, "a.unknown", "old bytes", false, false); + try std.testing.expectEqual(@as(usize, 1), cache.hits); +} + +test "locations cache transfers oversized completed analysis without reparsing" { + if (!syntax.supportsPath("large.zig")) return error.SkipZigTest; + const gpa = std.testing.allocator; + syntax.start(gpa); + defer syntax.stop(); + var cache: Cache = .{}; + defer cache.deinit(gpa); + const source = "const Thing = struct {\n value: u32,\n};\n"; + const budget = "large.zig".len + source.len; + var result = try cache.getBounded(gpa, "large.zig", source, true, false, budget); + defer result.deinit(gpa); + try std.testing.expect(result.owned); + try std.testing.expect(result.analysis.declarations.len > 0); + try std.testing.expectEqual(@as(usize, 1), cache.analyses); + try std.testing.expectEqual(@as(usize, 0), cache.len); + try std.testing.expectEqual(@as(usize, 0), cache.bytes); +} diff --git a/src/main.zig b/src/main.zig index 2ee295e1..40ec8667 100644 --- a/src/main.zig +++ b/src/main.zig @@ -369,6 +369,7 @@ test { _ = pardes.config.User; _ = @import("crash.zig"); _ = @import("memory.zig"); + _ = @import("locations_cache.zig"); _ = @import("fs.zig"); _ = @import("detached/wire.zig"); _ = @import("detached/server.zig"); diff --git a/src/pardes.zig b/src/pardes.zig index 2729ef93..c78d4702 100644 --- a/src/pardes.zig +++ b/src/pardes.zig @@ -5969,6 +5969,7 @@ pub const Pardes = struct { next_serial: u32 = 0, settings: config.Runtime = .{ .font = .{ .tagline_percent = config.gui_tagline_font_percent } }, locations_config: locations_config.Config = .{}, + locations_cache: @import("locations_cache.zig").Cache = .{}, tty_filter_palette: panes.Terminal.FilterPalette = .{}, font_request_taken: bool = false, custom_theme: ?Theme = null, @@ -6212,6 +6213,7 @@ pub const Pardes = struct { if (p.custom_theme) |theme_value| std.zon.parse.free(gpa, theme_value); if (p.chord_arg) |a| gpa.free(a); if (p.pipe_wait) |*wait| wait.deinit(gpa); + p.locations_cache.deinit(p.tree_sitter_gpa); p.fs.deinit(gpa); p.shell_rows.reset(gpa); p.scratch.deinit(); diff --git a/src/syntax.zig b/src/syntax.zig index 9e31669f..e637bf67 100644 --- a/src/syntax.zig +++ b/src/syntax.zig @@ -376,28 +376,58 @@ pub fn supportsPath(path: []const u8) bool { return false; } -pub fn contextDeclarations(gpa: std.mem.Allocator, path: []const u8, content: []const u8) ![]ContextDeclaration { - if (!enabled or content.len == 0) return &.{}; - const selected = (try forExt(std.fs.path.extension(path))) orelse return &.{}; - const tree = selected.parser.parseString(content, null) orelse return &.{}; +/// Owned source analysis. Both slices use the allocator passed to analyzeSource. +/// The parsed tree is released before returning; callers can cache this result. +pub const SourceAnalysis = struct { + declarations: []ContextDeclaration = &.{}, + colors: []u8 = &.{}, + + pub fn deinit(self: *SourceAnalysis, gpa: std.mem.Allocator) void { + gpa.free(self.declarations); + gpa.free(self.colors); + self.* = .{}; + } +}; + +pub fn analyzeSource(gpa: std.mem.Allocator, path: []const u8, content: []const u8, want_declarations: bool, want_colors: bool) !SourceAnalysis { + if (!enabled or content.len == 0 or (!want_declarations and !want_colors)) return .{}; + const selected = (try forExt(std.fs.path.extension(path))) orelse return .{}; + const tree = selected.parser.parseString(content, null) orelse return .{}; defer tree.destroy(); + var result: SourceAnalysis = .{}; + errdefer result.deinit(gpa); + if (want_declarations) result.declarations = try declarationsFromTree(gpa, content, tree); + if (want_colors) { + result.colors = try gpa.alloc(u8, content.len); + @memset(result.colors, 0); + paintTree(result.colors, content, selected, tree); + } + return result; +} + +pub fn contextDeclarations(gpa: std.mem.Allocator, path: []const u8, content: []const u8) ![]ContextDeclaration { + const analysis = try analyzeSource(gpa, path, content, true, false); + return analysis.declarations; +} + +fn declarationsFromTree(gpa: std.mem.Allocator, content: []const u8, tree: *ts.Tree) ![]ContextDeclaration { var result: std.ArrayList(ContextDeclaration) = .empty; errdefer result.deinit(gpa); - // Iterative preorder keeps declaration order and avoids recursive traversal - // on deeply nested, partly edited source. - var node = tree.rootNode(); + // The cursor retains its ancestor stack: sibling visits do not repeatedly + // reconstruct parents in broad syntax trees. Preorder preserves source order. + var cursor = tree.rootNode().walk(); + defer cursor.destroy(); while (true) { - if (contextSpan(node, content)) |span| { + const node = cursor.node(); + if (node.isNamed()) if (contextSpan(node, content)) |span| { if (result.items.len == 0 or result.items[result.items.len - 1].start_line != span.start_line or result.items[result.items.len - 1].end_line != span.end_line) try result.append(gpa, span); + }; + if (cursor.gotoFirstChild()) continue; + while (!cursor.gotoNextSibling()) { + if (!cursor.gotoParent()) return result.toOwnedSlice(gpa); } - if (node.namedChild(0)) |child| { - node = child; - continue; - } - while (node.nextNamedSibling() == null) node = node.parent() orelse return result.toOwnedSlice(gpa); - node = node.nextNamedSibling().?; } } @@ -492,6 +522,10 @@ fn contextSpan(node: ts.Node, source: []const u8) ?ContextDeclaration { fn paint(styles: []u8, source: []const u8, selected: Selected) void { const tree = selected.parser.parseString(source, null) orelse return; defer tree.destroy(); + paintTree(styles, source, selected, tree); +} + +fn paintTree(styles: []u8, source: []const u8, selected: Selected, tree: *ts.Tree) void { runQuery(styles, selected, tree, 0); if (std.mem.eql(u8, selected.name, "markdown")) { inject(styles, source, tree.rootNode(), true); @@ -1279,3 +1313,64 @@ test "syntax stacked addresses do not split multiline source groups" { for (styles[at..][0..label.len]) |style| try std.testing.expectEqual(@intFromEnum(Syn.none), style); } } + +test "syntax source analysis preserves declarations and injected colors" { + if (!enabled) return; + const gpa = std.testing.allocator; + start(gpa); + defer stop(); + const Fixture = struct { path: []const u8, source: []const u8 }; + for ([_]Fixture{ + .{ .path = "a.zig", .source = "const Outer = struct {\n // comment\n const Inner = struct {\n pub fn run(\n x: u32,\n ) u32 { return x; }\n };\n};\n" }, + .{ .path = "a.cpp", .source = "namespace Outer {\nstruct Inner {\nint run(\n int x\n) { return x; }\n};\n}\n" }, + .{ .path = "a.rs", .source = "mod outer {\nstruct Inner {}\nimpl Inner {\nfn run(\n &self\n) {}\n}\n}\n" }, + .{ .path = "a.js", .source = "function outer() {\nclass Inner {\nrun(\n x\n) { return x; }\n}\n}\n" }, + .{ .path = "a.py", .source = "class Outer:\n class Inner:\n def run(\n self, x\n ):\n return x\n" }, + .{ .path = "a.md", .source = "# Heading\n\n```zig\npub fn run() void {}\n```\n" }, + .{ .path = "a.typst", .source = "= Heading\n\n```zig\npub fn run() void {}\n```\n" }, + }) |fixture| { + if (!supportsPath(fixture.path)) continue; + var analysis = try analyzeSource(gpa, fixture.path, fixture.source, true, true); + defer analysis.deinit(gpa); + const colors = try highlightFileRange(gpa, fixture.path, fixture.source, 0, fixture.source.len); + defer gpa.free(colors); + try std.testing.expectEqualSlices(u8, colors, analysis.colors); + + // Compare the previous named-node walk to the cursor walk, including + // source ordering, wrapper deduplication and inclusive declaration ends. + const selected = (try forExt(std.fs.path.extension(fixture.path))).?; + const tree = selected.parser.parseString(fixture.source, null).?; + defer tree.destroy(); + var reference: std.ArrayList(ContextDeclaration) = .empty; + defer reference.deinit(gpa); + var node = tree.rootNode(); + walk: while (true) { + if (contextSpan(node, fixture.source)) |span| { + if (reference.items.len == 0 or reference.items[reference.items.len - 1].start_line != span.start_line or + reference.items[reference.items.len - 1].end_line != span.end_line) + try reference.append(gpa, span); + } + if (node.namedChild(0)) |child| { + node = child; + continue; + } + while (node.nextNamedSibling() == null) node = node.parent() orelse break :walk; + node = node.nextNamedSibling().?; + } + try std.testing.expectEqual(reference.items.len, analysis.declarations.len); + for (reference.items, analysis.declarations) |old, new| try std.testing.expect(std.meta.eql(old, new)); + + var declarations_only = try analyzeSource(gpa, fixture.path, fixture.source, true, false); + defer declarations_only.deinit(gpa); + try std.testing.expectEqual(@as(usize, 0), declarations_only.colors.len); + try std.testing.expectEqual(analysis.declarations.len, declarations_only.declarations.len); + var colors_only = try analyzeSource(gpa, fixture.path, fixture.source, false, true); + defer colors_only.deinit(gpa); + try std.testing.expectEqual(@as(usize, 0), colors_only.declarations.len); + try std.testing.expectEqualSlices(u8, analysis.colors, colors_only.colors); + } + var unsupported = try analyzeSource(gpa, "a.unknown", "text", true, true); + unsupported.deinit(gpa); + try std.testing.expectEqual(@as(usize, 0), unsupported.declarations.len); + try std.testing.expectEqual(@as(usize, 0), unsupported.colors.len); +} diff --git a/test/locations_bench.zig b/test/locations_bench.zig new file mode 100644 index 00000000..54cebb59 --- /dev/null +++ b/test/locations_bench.zig @@ -0,0 +1,61 @@ +const std = @import("std"); +const pds = @import("pardes"); +const loc = pds.locations_config; +fn now() u64 { + var ts: std.c.timespec = undefined; + _ = std.c.clock_gettime(.MONOTONIC, &ts); + return @as(u64, @intCast(ts.sec)) * 1_000_000_000 + @as(u64, @intCast(ts.nsec)); +} +// Run: zig build locations-bench -Doptimize=ReleaseFast +// Timed work is the real Output.fillResults pipeline. Fixtures are open unsaved +// sources; source generation, input duplication, rendering and subprocesses are +// excluded. Each layout/config starts with an empty source-analysis cache. +// Two repeats retain that cache and existing output. No latency threshold applies. +test "locations benchmark cold and warm formatting" { + if (!pds.syntax.supportsPath("large.zig")) return error.ZigGrammarRequired; + std.debug.print("layout,context,matches,source_bytes,phase,repeat,elapsed_ns\n", .{}); + const gpa = std.heap.smp_allocator; + for ([_]usize{ 100, 500, 1500 }) |functions| { + var source: std.Io.Writer.Allocating = .init(gpa); + defer source.deinit(); + var input: std.Io.Writer.Allocating = .init(gpa); + defer input.deinit(); + try source.writer.writeAll("pub const Module = struct {\n"); + var row: usize = 2; + for (0..functions) |i| { + try source.writer.print(" pub fn f{d}(x: u32) u32 {{\n", .{i}); + row += 1; + for (0..20) |j| { + try source.writer.print(" const v{d} = x + {d}; // explanatory source comment\n", .{ j, j }); + row += 1; + } + const line = " return x; // BENCH_MATCH"; + try source.writer.print("{s}\n }}\n", .{line}); + try input.writer.print("large.zig:{d}:1 {s}\n", .{ row, line }); + row += 2; + } + try source.writer.writeAll("};\n"); + const p = try pds.Pardes.init(gpa, .{ .tty_only = true, .cols = 120, .rows = 40 }); + defer p.deinit(); + const pane = try p.setTestFile(source.written()); + gpa.free(pane.file.?.path); + pane.file.?.path = try gpa.dupe(u8, "/bench/large.zig"); + for ([_]loc.Config.Layout{ .@"inline", .stacked }) |layout| { + for ([_]loc.Config{ .{ .context = 0, .tscontext = false }, .{ .context = 2, .tscontext = false }, .{ .context = 0, .tscontext = true }, .{ .context = 2, .tscontext = true } }, 0..) |config, mode| { + p.locations_config = config; + p.locations_cache.deinit(p.tree_sitter_gpa); + p.locations_cache = .{}; + p.locations_config.layout = layout; + for (0..3) |rep| { + _ = p.scratch.reset(.retain_capacity); + const data = try gpa.dupe(u8, input.written()); + const t = now(); + try pds.panes.Output.fillResults(p, 0, "/bench", .{ .cmd = .Grep }, "BENCH_MATCH", data, null); + const elapsed = now() - t; + const modes = [_][]const u8{ "off", "ordinary", "tree_sitter", "both" }; + std.debug.print("{s},{s},{d},{d},{s},{d},{d}\n", .{ @tagName(layout), modes[mode], functions, source.written().len, if (rep == 0) "cold" else "warm", rep, elapsed }); + } + } + } + } +} diff --git a/test/output.zig b/test/output.zig index c738a661..21e9f04c 100644 --- a/test/output.zig +++ b/test/output.zig @@ -1585,3 +1585,142 @@ test "stacked search and LSP results retain source tint navigation and dump owne } } } + +test "location analysis cache refreshes unsaved ancestry and query context" { + if (!pardes.syntax.enabled) return error.SkipZigTest; + const before = "const Outer = struct {\n" ++ + " fn first() void {\n" ++ + " marker();\n" ++ + " }\n" ++ + " fn second() void {\n" ++ + " marker();\n" ++ + " }\n" ++ + "};\n"; + const after = "pub fn revised() void {\n // new neighbor\n marker();\n}\n"; + const p = try Pardes.init(std.testing.allocator, .{ .tty_only = true }); + defer p.deinit(); + const source = try p.setTestFile(before); + p.gpa.free(source.file.?.path); + source.file.?.path = try p.gpa.dupe(u8, "/analysis-cache.zig"); + p.locations_config = .{ .context = 0, .tscontext = true, .tslocations = false }; + const Runner = struct { + fn fill(editor: *Pardes, line: usize) !void { + const path = editor.panes[0].?.file.?.path; + const input = try std.fmt.allocPrint(editor.gpa, "{s}:{d}:9-14 marker();\n", .{ path, line }); + try panes.Output.fillResults(editor, 0, "/", .search, "marker", input, 0); + } + }; + try Runner.fill(p, 3); + const id = source.search_pane.?; + const file = &p.panes[id].?.file.?; + try std.testing.expect(std.mem.indexOf(u8, file.content, "const Outer") != null); + try std.testing.expect(std.mem.indexOf(u8, file.content, "fn first") != null); + try std.testing.expect(std.mem.indexOf(u8, file.content, "fn second") == null); + const original = file.content.ptr; + const revision = file.revision; + const analyses = p.locations_cache.analyses; + const hits = p.locations_cache.hits; + try Runner.fill(p, 3); + try std.testing.expectEqual(id, source.search_pane.?); + try std.testing.expectEqual(original, file.content.ptr); + try std.testing.expectEqual(revision, file.revision); + try std.testing.expectEqual(analyses, p.locations_cache.analyses); + try std.testing.expect(p.locations_cache.hits > hits); + + // Reusing analysis must still choose the ancestry of the current match. + try Runner.fill(p, 6); + try std.testing.expectEqual(analyses, p.locations_cache.analyses); + try std.testing.expect(std.mem.indexOf(u8, file.content, "const Outer") != null); + try std.testing.expect(std.mem.indexOf(u8, file.content, "fn first") == null); + try std.testing.expect(std.mem.indexOf(u8, file.content, "fn second") != null); + const match = file.location_rows[source.search_row.?]; + try std.testing.expectEqual(.match, match.kind); + try std.testing.expectEqual(@as(usize, 6), match.at.line); + + // The path stays identical, but an unsaved replacement changes its tree. + panes.File.setContent(p, &source.file.?, try p.gpa.dupe(u8, after)); + try Runner.fill(p, 3); + try std.testing.expect(p.locations_cache.analyses > analyses); + try std.testing.expect(std.mem.indexOf(u8, file.content, "fn revised") != null); + try std.testing.expect(std.mem.indexOf(u8, file.content, "const Outer") == null); + try std.testing.expect(std.mem.indexOf(u8, file.content, "fn second") == null); + try std.testing.expect(std.mem.indexOf(u8, file.content, "new neighbor") == null); + + p.locations_config.context = 1; + try Runner.fill(p, 3); + try std.testing.expect(std.mem.indexOf(u8, file.content, "fn revised") != null); + try std.testing.expect(std.mem.indexOf(u8, file.content, "new neighbor") != null); + const expanded = try p.gpa.dupe(u8, file.content); + defer p.gpa.free(expanded); + const expanded_analyses = p.locations_cache.analyses; + p.locations_config.context = 0; + try Runner.fill(p, 3); + try std.testing.expect(std.mem.indexOf(u8, file.content, "new neighbor") == null); + p.locations_config.context = 1; + try Runner.fill(p, 3); + try std.testing.expectEqualStrings(expanded, file.content); + try std.testing.expectEqual(expanded_analyses, p.locations_cache.analyses); + p.locations_config.tscontext = false; + try Runner.fill(p, 3); + try std.testing.expect(std.mem.indexOf(u8, file.content, "fn revised") == null); + try std.testing.expect(std.mem.indexOf(u8, file.content, "new neighbor") != null); + try std.testing.expectEqualStrings(after, source.file.?.content); +} + +test "location cache eviction retains early colors and honors disk and unsaved replacements" { + if (!pardes.syntax.enabled) return error.SkipZigTest; + var tmp = std.testing.tmpDir(.{}); + defer tmp.cleanup(); + var dir_buf: [4096]u8 = undefined; + const dir = dir_buf[0..try tmp.dir.realPath(std.testing.io, &dir_buf)]; + const comment = "/* open\nconst int value = 42;\n*/\nneedle();\n"; + const code = "// open\nconst int value = 42;\n//\nneedle();\n"; + try std.testing.expectEqual(comment.len, code.len); + const p = try Pardes.init(std.testing.allocator, .{ .tty_only = true }); + defer p.deinit(); + const source = try p.setTestFile("notes\n"); + p.locations_config = .{ .context = 3, .tscontext = false }; + var input: std.Io.Writer.Allocating = .init(p.gpa); + defer input.deinit(); + for (0..65) |index| { + var name_buf: [32]u8 = undefined; + const name = try std.fmt.bufPrint(&name_buf, "f{d:0>2}.c", .{index}); + try tmp.dir.writeFile(std.testing.io, .{ .sub_path = name, .data = if (index == 0) comment else code }); + try input.writer.print("{s}:4:1-6 needle();\n", .{name}); + } + try panes.Output.fillResults(p, 0, dir, .search, "eviction", try p.gpa.dupe(u8, input.written()), null); + const id = source.search_pane.?; + const file = &p.panes[id].?.file.?; + try std.testing.expectEqual(@as(usize, 64), p.locations_cache.len); + try std.testing.expectEqual(@as(usize, 65), p.locations_cache.analyses); + const Color = struct { + fn valueColor(result: *const panes.File.State) !u8 { + for (result.location_rows, 0..) |row, index| { + if (row.kind != .context or row.at.line != 2 or !std.mem.endsWith(u8, row.path, "f00.c")) continue; + const line = modal.lineSlice(result.content, index); + const number = std.mem.indexOf(u8, line[row.code_start..], "42").?; + try std.testing.expectEqualStrings("const int value = 42;", line[row.code_start..]); + try std.testing.expectEqual(line.len - row.code_start, row.colors.len); + return row.colors[number]; + } + return error.MissingEarlyContext; + } + }; + try std.testing.expectEqual(@intFromEnum(pardes.syntax.Syn.comment), try Color.valueColor(file)); + const single = "f00.c:4:1-6 needle();\n"; + // Put the evicted file back before a same-size edit tests exact-byte keys. + try panes.Output.fillResults(p, 0, dir, .search, "eviction", try p.gpa.dupe(u8, single), null); + const analyses = p.locations_cache.analyses; + try tmp.dir.writeFile(std.testing.io, .{ .sub_path = "f00.c", .data = code }); + try panes.Output.fillResults(p, 0, dir, .search, "eviction", try p.gpa.dupe(u8, single), null); + try std.testing.expect(p.locations_cache.analyses > analyses); + try std.testing.expectEqual(@intFromEnum(pardes.syntax.Syn.number), try Color.valueColor(file)); + + // An open buffer has priority over that disk revision, even with equal size. + p.gpa.free(source.file.?.path); + source.file.?.path = try std.fs.path.join(p.gpa, &.{ dir, "f00.c" }); + panes.File.setContent(p, &source.file.?, try p.gpa.dupe(u8, comment)); + try panes.Output.fillResults(p, 0, dir, .search, "eviction", try p.gpa.dupe(u8, single), null); + try std.testing.expectEqual(@intFromEnum(pardes.syntax.Syn.comment), try Color.valueColor(file)); + try std.testing.expectEqualStrings(comment, source.file.?.content); +} -- cgit v1.3 From b7914a0bd59334f618b62e0b98271211bbec46b9 Mon Sep 17 00:00:00 2001 From: Gabriel Schneider Date: Tue, 15 Sep 2026 18:59:33 -0300 Subject: Clear previous selections before resolving Look destinations --- src/panes.zig | 5 ++- src/pardes.zig | 62 +++++++++++++++++++++++++++++--- test/panes.zig | 110 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ test/pdf.zig | 26 +++++++++----- 4 files changed, 189 insertions(+), 14 deletions(-) (limited to 'src/pardes.zig') diff --git a/src/panes.zig b/src/panes.zig index 59993148..c3fa732e 100644 --- a/src/panes.zig +++ b/src/panes.zig @@ -5371,7 +5371,10 @@ pub const Pdf = struct { const destination = owner.state.sectionDestination(core.pdf_gpa, at.col - 1) orelse return true; switch (destination) { - .internal => |internal| revealOutlineDestination(core, owner.pane, internal), + .internal => |internal| { + core.clearLookSelection(owner.pane); + revealOutlineDestination(core, owner.pane, internal); + }, .external => |uri| if (uri.len <= 256) core.emit(.{ .open_link = .from(uri) }), .none => unreachable, } diff --git a/src/pardes.zig b/src/pardes.zig index c78d4702..8bccfd89 100644 --- a/src/pardes.zig +++ b/src/pardes.zig @@ -9446,6 +9446,9 @@ pub const Pardes = struct { p.runBuiltin(config.exec_cmd, rid, "", std.mem.trim(u8, ln, " \t\r")); } else if (span) |selected| { p.lookAt(rid, ln[selected.start..selected.end]); + // This is the newly visited result, not a selection carried into + // the destination. Look cleared the previous source selection. + rp.msel = .{ .active = true, .r0 = r, .r1 = r }; } p.armLookWalk(rid); return true; @@ -12217,10 +12220,32 @@ pub const Pardes = struct { fn focusPaneByPath(p: *Pardes, path: []const u8, at: look.Spot) bool { const target = p.openPaneTarget(path, at) orelse return false; + p.clearLookSelection(p.panes[target.pane.id].?); p.focusPaneLine(target.pane.id, target.pane.at, .center); return true; } + /// Look starts a new selection; history navigation keeps the old one. + pub fn clearLookSelection(p: *Pardes, pane: *Pane) void { + pane.vsel = .{}; + pane.msel = .{}; + pane.nsel = 0; + pane.select = false; + pane.normal.clear(); + pane.append_at = null; + pane.sticky_col = -1; + for (0..pane.sel.len) |slot| pane.clearPointerSelection(slot); + pane.sel = @splat(.{}); + if (comptime pdf_enabled) if (pane.pdf) |*state| { + state.clearDrag(); + state.clearSelection(p.pdf_gpa); + }; + if (p.drag == .select and p.panes[p.drag.select.id] == pane) p.drag = .none; + if (p.jump_selection_cursor) |saved| if (saved.serial == pane.serial) { + p.jump_selection_cursor = null; + }; + } + /// Resolve without changing focus or falling back to search. PDF links use /// the same location rules as an ordinary Look before offering a choice. fn resolveLookTarget(p: *Pardes, id: usize, txt: []const u8, realbuf: *[4096]u8) look.Target { @@ -12308,6 +12333,7 @@ pub const Pardes = struct { const pane = p.panes[id] orelse return; const link = probe.link orelse return; const target = p.pdfLinkLocation(pane, link) orelse return; + p.clearLookSelection(pane); if (p.canonicalLookLocation(id, probe.text)) |visible| { if (!std.mem.eql(u8, visible, target)) { const content = std.fmt.allocPrint(p.gpa, "{s}\n{s}\n", .{ visible, target }) catch |err| @@ -12329,15 +12355,19 @@ pub const Pardes = struct { } } - pub fn lookAt(p: *Pardes, id: usize, txt: []const u8) void { + pub fn lookAt(p: *Pardes, id: usize, operand: []const u8) void { const pane = p.panes[id] orelse return; p.noteHaptic(.look); p.noteLookSource(id); - const trimmed = std.mem.trim(u8, txt, " \t\r\n"); - if (config.commandWord(trimmed)) |cmd| { + const command = std.mem.trim(u8, operand, " \t\r\n"); + if (config.commandWord(command)) |cmd| { if (p.execute(id, cmd)) |dst| p.active = dst; return; } + // The operand may borrow selected terminal/PDF text released below. + const txt = p.scratch.allocator().dupe(u8, operand) catch return; + const trimmed = std.mem.trim(u8, txt, " \t\r\n"); + p.clearLookSelection(pane); const pl = look.parsePathLine(trimmed); if (comptime pdf_enabled) if (panes.Pdf.lookSection(p, id, pl.path, pl.at)) return; var realbuf: [4096]u8 = undefined; @@ -12357,11 +12387,15 @@ pub const Pardes = struct { _ = p.searchStep(id, 1); } }, - .pane => |t| p.focusPaneLine(t.id, t.at, .center), + .pane => |t| { + p.clearLookSelection(p.panes[t.id].?); + p.focusPaneLine(t.id, t.at, .center); + }, .url => |u| if (u.len <= 256) p.emit(.{ .open_link = .from(u) }), .dir => |dir| { for (p.panes, 0..) |slot, i| { if (slot) |tt| if (std.mem.eql(u8, tt.cwdSlice(), dir) and p.takesCommandLine(i)) { + p.clearLookSelection(tt); p.active = i; p.emitWrite(i, "ls\r"); return; @@ -14931,6 +14965,26 @@ test "board heap: every allocation failure during boot is a clean OutOfMemory" { ); } +test "Look copies its operand before releasing pointer selection storage" { + const p = try Pardes.init(std.testing.allocator, .{ .cols = 60, .rows = 12 }); + defer p.deinit(); + const pane = try p.setTestFile("alpha beta\ngamma delta\nepsilon zeta\n"); + const operand = try p.gpa.dupe(u8, "/test.txt:3:2"); + pane.sel[0] = .{ .state = .done, .source_id = 1 }; + pane.pointer_selections[0] = .{ + .gesture = pane.sel[0], + .rows = try p.gpa.alloc(Pane.PointerRow, 0), + .raw_text = operand, + }; + p.drag = .{ .select = .{ .id = 0, .button = config.select_button } }; + p.lookAt(0, operand); + try std.testing.expectEqual(@as(i32, 2), pane.cur_row); + try std.testing.expectEqual(@as(i32, 1), pane.cur_col); + try std.testing.expect(pane.pointer_selections[0] == null); + try std.testing.expectEqual(.none, pane.sel[0].state); + try std.testing.expectEqual(.none, p.drag); +} + test "jump history preserves modal and mouse selections" { const p = try Pardes.init(std.testing.allocator, .{ .cols = 60, .rows = 12 }); defer p.deinit(); diff --git a/test/panes.zig b/test/panes.zig index 28af8141..cb2e8169 100644 --- a/test/panes.zig +++ b/test/panes.zig @@ -4256,3 +4256,113 @@ test "terminal overlays preserve trailing blank styles without coloring inserted try std.testing.expectEqual(colors[2], extended.at(x, y + 4).style.bg); try std.testing.expect(p.shell_rows.pane == null); } + +const LookResetTests = struct { + fn seed(pane: *Pane, operand: []const u8) !void { + pane.cur_row = 0; + pane.cur_col = 3; + pane.vsel = .{ .active = true, .explicit = true, .row = 0, .col = 0 }; + pane.msel = .{ .active = true, .r0 = 0, .r1 = 1 }; + pane.sels[0] = .{ .row = 1, .col = 2, .arow = 0, .acol = 1 }; + pane.nsel = 1; + pane.select = true; + pane.normal.count = 5; + pane.append_at = .{ .row = 0, .col = 3 }; + pane.sticky_col = 7; + for (0..pane.sel.len) |slot| { + pane.clearPointerSelection(slot); + pane.sel[slot] = .{ .state = .done, .source_id = slot + 1, .r0 = 1, .r1 = 1, .c0 = 0, .c1 = 3 }; + const rows = try pane.gpa.alloc(Pane.PointerRow, 1); + rows[0] = .{ .row = 0, .lo = 0, .hi = 4 }; + pane.pointer_selections[slot] = .{ + .gesture = pane.sel[slot], + .rows = rows, + .raw_text = try pane.gpa.dupe(u8, operand), + }; + } + } + + fn cleared(pane: *const Pane) !void { + try std.testing.expect(!pane.msel.active); + try std.testing.expectEqual(@as(u8, 0), pane.nsel); + try std.testing.expect(!pane.select); + try std.testing.expectEqual(modal.Normal.State{}, pane.normal); + try std.testing.expect(pane.append_at == null); + try std.testing.expectEqual(@as(i32, -1), pane.sticky_col); + for (pane.sel) |selection| try std.testing.expectEqual(.none, selection.state); + for (pane.pointer_selections) |selection| try std.testing.expect(selection == null); + } + + fn selected(pane: *const Pane) []const u8 { + if (!pane.vsel.active or pane.cur_row != pane.vsel.row) return ""; + const line = modal.lineSlice(pane.file.?.content, @intCast(pane.cur_row)); + const lo: usize = @intCast(@min(pane.cur_col, pane.vsel.col)); + const hi: usize = @intCast(@max(pane.cur_col, pane.vsel.col)); + return line[lo..modal.nextGrapheme(line, hi)]; + } + + test "Look replaces old selection for same-pane addresses ranges and text fallback" { + const p = try Pardes.init(std.testing.allocator, .{ .tty_only = true, .cols = 80, .rows = 24 }); + defer p.deinit(); + const pane = try p.setTestFile("alpha\nbravo\ncharlie\nneedle\n"); + try seed(pane, "/test.txt:3:2"); + // This operand is released by Look's selection cleanup. + p.lookAt(0, pane.pointer_selections[0].?.raw_text.?); + try cleared(pane); + try std.testing.expectEqual(@as(usize, 0), p.active); + try std.testing.expectEqual(@as(i32, 2), pane.cur_row); + try std.testing.expectEqual(@as(i32, 1), pane.cur_col); + try std.testing.expect(!pane.vsel.active); + + try seed(pane, "/test.txt:2:2-4"); + p.lookAt(0, pane.pointer_selections[0].?.raw_text.?); + try cleared(pane); + try std.testing.expectEqual(@as(i32, 1), pane.cur_row); + try std.testing.expectEqualStrings("rav", selected(pane)); + + p.gpa.free(pane.file.?.path); + pane.file.?.path = try p.gpa.dupe(u8, "/tmp/look-selection-source.txt"); + try seed(pane, "needle"); + p.lookAt(0, pane.pointer_selections[0].?.raw_text.?); + try cleared(pane); + try std.testing.expectEqual(@as(i32, 3), pane.cur_row); + try std.testing.expectEqualStrings("needle", selected(pane)); + } + + test "Look clears both source and existing destination selections before focus" { + const p = try Pardes.init(std.testing.allocator, .{ .tty_only = true, .cols = 100, .rows = 30 }); + defer p.deinit(); + const source = try p.setTestFile("source\nlines\n"); + const id = p.freeSlot().?; + const destination = try p.newDocPane(id); + destination.file = .{ + .path = try p.gpa.dupe(u8, "/look-destination.txt"), + .content = try p.gpa.dupe(u8, "alpha\nbravo\ncharlie\n"), + .history = try panes.File.History.create(p.gpa), + }; + layout.insert(p, 0, 1, id); + layout.compute(p); + for ([_]bool{ false, true }) |range| { + p.active = 0; + try seed(source, if (range) "/look-destination.txt:2:2-4" else "/look-destination.txt:3:2"); + try seed(destination, "previous destination"); + p.lookAt(0, source.pointer_selections[0].?.raw_text.?); + try std.testing.expectEqual(id, p.active); + try cleared(source); + try cleared(destination); + try std.testing.expect(!source.vsel.active); + if (range) { + try std.testing.expectEqual(@as(i32, 1), destination.cur_row); + try std.testing.expectEqualStrings("rav", selected(destination)); + } else { + try std.testing.expectEqual(@as(i32, 2), destination.cur_row); + try std.testing.expectEqual(@as(i32, 1), destination.cur_col); + try std.testing.expect(!destination.vsel.active); + } + } + } +}; + +test { + _ = LookResetTests; +} diff --git a/test/pdf.zig b/test/pdf.zig index 113ed8b9..7a05447e 100644 --- a/test/pdf.zig +++ b/test/pdf.zig @@ -120,8 +120,12 @@ const PdfLinkTests = struct { defer frame.deinit(); _ = try p.render(frame.allocator()); while (p.nextEffect()) |_| {} - click(p, try textCell(p, "target.txt")); + const target_cell = try textCell(p, "target.txt"); + try std.testing.expect(panes.Pdf.beginSelection(p, p.panes[0].?, target_cell.col, target_cell.row)); + try std.testing.expect(p.panes[0].?.pdf.?.selection != null); + click(p, target_cell); try expectOpened(p, null); + try std.testing.expect(p.panes[0].?.pdf.?.selection == null); const choices = for (p.panes, 0..) |slot, id| { if (id == 0) continue; if (slot) |pane| if (pane.file) |file| if (file.output != null) break pane; @@ -146,7 +150,7 @@ const PdfLinkTests = struct { for (0..(config.look_preview_delay_frames orelse 0)) |_| p.update(.tick); } - test "PDF links hover clears on leave page and reload while right drag selects text" { + test "PDF links hover clears on leave page and reload while right drag chooses Look text" { if (!pdf_enabled or platform == .web) return; var tmp = std.testing.tmpDir(.{}); defer tmp.cleanup(); @@ -181,10 +185,13 @@ const PdfLinkTests = struct { const label = try textCell(p, "label"); p.update(.{ .mouse = .{ .button = config.look_button, .kind = .press, .col = label.col, .row = label.row } }); p.update(.{ .mouse = .{ .button = config.look_button, .kind = .drag, .col = label.col + 3, .row = label.row } }); - p.update(.{ .mouse = .{ .button = config.look_button, .kind = .release, .col = label.col + 3, .row = label.row } }); - try expectOpened(p, null); try std.testing.expect(pane.pdf.?.selection != null); try std.testing.expect(pane.pdf.?.selection_text.len > 0); + p.update(.{ .mouse = .{ .button = config.look_button, .kind = .release, .col = label.col + 3, .row = label.row } }); + try expectOpened(p, null); + try std.testing.expect(pane.pdf.?.selection == null); + try std.testing.expect(pane.pdf.?.selection_text.len == 0); + try std.testing.expect(pane.pdf.?.search_query.len > 0); } }; @@ -1844,8 +1851,8 @@ test "PDF native mouse selection, Look, and highlights share page geometry" { } // A native right-click resolves the same MuPDF-snapped word and feeds it - // to Look. Search highlights precede selection highlights so the live - // selection remains visually authoritative where they overlap. + // to Look. Resolving it clears the previous selection, leaving the new + // search highlights without carrying an old selection into the result. p.update(.{ .mouse = .{ .button = config.look_button, .kind = .press, .col = word_col, .row = selected_row } }); p.update(.{ .mouse = .{ .button = config.look_button, .kind = .release, .col = word_col, .row = selected_row } }); try std.testing.expect(std.ascii.indexOfIgnoreCase(pv.search_query, "Pardes") != null); @@ -1855,9 +1862,9 @@ test "PDF native mouse selection, Look, and highlights share page geometry" { p.scratch.allocator(), panes.Pdf.highlightInput(p, 0, pane), )).forPage(pv.page); - try std.testing.expect(highlights.len > 1); - try std.testing.expectEqual(pdf_impl.HighlightKind.search, highlights[0].kind); - try std.testing.expectEqual(pdf_impl.HighlightKind.selection, highlights[highlights.len - 1].kind); + try std.testing.expect(highlights.len > 0); + for (highlights) |highlight| try std.testing.expectEqual(pdf_impl.HighlightKind.search, highlight.kind); + try std.testing.expect(pv.selection == null and pv.selection_text.len == 0); const revision_before_reveal = raster.revision; const max_document_scroll = @as(f64, @floatFromInt( pv.document_height -| panes.Pdf.paneViewport(p, pane).?.pixel_h, @@ -1928,6 +1935,7 @@ test "PDF native mouse selection, Look, and highlights share page geometry" { // Unsupported text-selection actions are consumed by the PDF adapter: // they neither invent a range over placeholder cells nor disturb the // native MuPDF selection. The select-button's no-drag click still clears. + try std.testing.expect(panes.Pdf.beginSelection(p, pane, word_col, selected_row)); p.update(.{ .key = .{ .cp = 'v' } }); try std.testing.expect(pv.selection != null); try std.testing.expect(!pane.vsel.active); -- cgit v1.3 From ffa2fd2d4b40bc4ff2a05263cf82ee9638590edd Mon Sep 17 00:00:00 2001 From: Gabriel Schneider Date: Tue, 15 Sep 2026 20:15:48 -0300 Subject: Keep unavailable numeric Look targets harmless when clearing selection --- src/pardes.zig | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) (limited to 'src/pardes.zig') diff --git a/src/pardes.zig b/src/pardes.zig index 8bccfd89..2a8ae5cc 100644 --- a/src/pardes.zig +++ b/src/pardes.zig @@ -12388,7 +12388,9 @@ pub const Pardes = struct { } }, .pane => |t| { - p.clearLookSelection(p.panes[t.id].?); + if (t.id >= MAX_PANES) return; + const target = p.panes[t.id] orelse return; + p.clearLookSelection(target); p.focusPaneLine(t.id, t.at, .center); }, .url => |u| if (u.len <= 256) p.emit(.{ .open_link = .from(u) }), @@ -14985,6 +14987,19 @@ test "Look copies its operand before releasing pointer selection storage" { try std.testing.expectEqual(.none, p.drag); } +test "Look ignores missing and out of bounds pane addresses" { + const p = try Pardes.init(std.testing.allocator, .{ .cols = 60, .rows = 12 }); + defer p.deinit(); + const pane = try p.setTestFile("alpha\nbravo\n"); + for ([_][]const u8{ config.pane_addr ++ "15:2", config.pane_addr ++ "999999:2" }) |operand| { + pane.setRange(pane.file.?.content, 0, .{ .anchor = 0, .head = 3 }, true); + p.lookAt(0, operand); + try std.testing.expectEqual(@as(usize, 0), p.active); + try std.testing.expectEqual(@as(i32, 0), pane.cur_row); + try std.testing.expect(!pane.vsel.active); + } +} + test "jump history preserves modal and mouse selections" { const p = try Pardes.init(std.testing.allocator, .{ .cols = 60, .rows = 12 }); defer p.deinit(); -- cgit v1.3 From 179863c0a7b011d5a4bd5e064f7d021d239aa96e Mon Sep 17 00:00:00 2001 From: Gabriel Schneider Date: Tue, 15 Sep 2026 20:17:50 -0300 Subject: Clear selections when navigating Back and Forward --- docs/helix-keys.md | 2 +- src/panes.zig | 4 +-- src/pardes.zig | 104 +++++++++++++++++++++++------------------------------ test/panes.zig | 62 +++++++++++++++++++++++++++++--- test/pdf.zig | 27 ++++++++++++++ 5 files changed, 132 insertions(+), 67 deletions(-) (limited to 'src/pardes.zig') diff --git a/docs/helix-keys.md b/docs/helix-keys.md index 9dc86ee2..6907473a 100644 --- a/docs/helix-keys.md +++ b/docs/helix-keys.md @@ -134,7 +134,7 @@ language-backend queries, and the shell pipe. | `gd` `gD` `gy` `gi` `gr` | LSP definition / declaration / type-definition / implementation / references. ONE answer jumps straight there; several fill `+Search`, where n/N walk and Enter opens | in-process ZLS (`src/lsp/lsp_zls.zig`), `.zig` only — on a file the backend does not speak these do nothing at all, with no error row. Ctrl+left-click is the mouse spelling of `gd` | out of corpus | | `]d` `[d` / `]D` `[D` | step the diagnostics list / go to its last or first; if no list is up, asking the backend for one is part of the press | | out of corpus | | `=` | `format_selections` — writes a `- old` / `+ new` diff into `+Lsp` | deliberate divergence: the seam returns ROWS, not edits, so this SHOWS the formatting instead of applying it. Not in the corpus, so there is no waiver to name — the query leaves the core as an effect the headless harness has no shell to perform | out of corpus | -| `Ctrl-o` / `Ctrl-i` | jumplist back / forward (also Mouse4 / Mouse5 in SDL, macOS and web); selections remain unchanged (a selected cursor stays at its selection while the view visits the saved location); raw tty forwards both to the child — the `Back` / `Forward` builtins, also on `SPC j o` / `SPC j i`, with `SPC j l` rendering the stack as a buffer | helix binds both keys (`jump_backward` / `jump_forward`) but to a POSITION jumplist; pardes' stack is over panes and focus, so the keys agree and the semantics do not. `Ctrl-i` and Tab are the same byte under the legacy encoding; there Tab keeps meaning execute, and the pair only separates where the host speaks the kitty keyboard protocol | pardes-specific | +| `Ctrl-o` / `Ctrl-i` | jumplist back / forward (also Mouse4 / Mouse5 in SDL, macOS and web); successful navigation clears selections in both panes and places the cursor at the saved location; raw tty forwards both to the child — the `Back` / `Forward` builtins, also on `SPC j o` / `SPC j i`, with `SPC j l` rendering the stack as a buffer | helix binds both keys (`jump_backward` / `jump_forward`) but to a POSITION jumplist; pardes' stack is over panes and focus, so the keys agree and the semantics do not. `Ctrl-i` and Tab are the same byte under the legacy encoding; there Tab keeps meaning execute, and the pair only separates where the host speaks the kitty keyboard protocol | pardes-specific | | `\|` | pipe every selection through `/bin/sh -c`: its bytes in on stdin, its stdout replacing them, one undo across all cursors | helix's own key and meaning; the command is typed into the pane's tag after a bare `\|` marker rather than into a popup | out of corpus | | `A-\|` | the same, and the output is DISCARDED — the text is not touched at all | helix `shell_pipe_to`. For a command run for its effect. Marker `\|-` | out of corpus | | `!` | run with NO stdin, insert the output BEFORE each selection | helix `shell_insert_output`. Runs ONCE and every cursor gets that one answer, as helix does — ten cursors and `date` give ten identical stamps. Marker `!` | out of corpus | diff --git a/src/panes.zig b/src/panes.zig index c3fa732e..88e6a8ea 100644 --- a/src/panes.zig +++ b/src/panes.zig @@ -3604,7 +3604,7 @@ pub const Pdf = struct { return result; } - test "PDF selections retain their owning page across history navigation" { + test "PDF selections retain their owning page across page focus" { if (comptime !enabled) return; const gpa = std.testing.allocator; var state = try State.open(gpa, "docs/design.pdf", 1); @@ -5372,7 +5372,7 @@ pub const Pdf = struct { const destination = owner.state.sectionDestination(core.pdf_gpa, at.col - 1) orelse return true; switch (destination) { .internal => |internal| { - core.clearLookSelection(owner.pane); + core.clearNavigationSelection(owner.pane); revealOutlineDestination(core, owner.pane, internal); }, .external => |uri| if (uri.len <= 256) core.emit(.{ .open_link = .from(uri) }), diff --git a/src/pardes.zig b/src/pardes.zig index 2a8ae5cc..16343972 100644 --- a/src/pardes.zig +++ b/src/pardes.zig @@ -5961,7 +5961,6 @@ pub const Pardes = struct { jumps: [MAX_JUMPS]Loc = undefined, njumps: usize = 0, jcur: usize = 0, - jump_selection_cursor: ?struct { pane: usize, serial: u32, row: i32, col: i32 } = null, look_src: [MAX_PANES]u32 = undefined, n_look_src: usize = 0, look_walk_owner: ?u32 = null, @@ -12220,13 +12219,13 @@ pub const Pardes = struct { fn focusPaneByPath(p: *Pardes, path: []const u8, at: look.Spot) bool { const target = p.openPaneTarget(path, at) orelse return false; - p.clearLookSelection(p.panes[target.pane.id].?); + p.clearNavigationSelection(p.panes[target.pane.id].?); p.focusPaneLine(target.pane.id, target.pane.at, .center); return true; } - /// Look starts a new selection; history navigation keeps the old one. - pub fn clearLookSelection(p: *Pardes, pane: *Pane) void { + /// Navigation starts a new selection at the destination. + pub fn clearNavigationSelection(p: *Pardes, pane: *Pane) void { pane.vsel = .{}; pane.msel = .{}; pane.nsel = 0; @@ -12241,9 +12240,6 @@ pub const Pardes = struct { state.clearSelection(p.pdf_gpa); }; if (p.drag == .select and p.panes[p.drag.select.id] == pane) p.drag = .none; - if (p.jump_selection_cursor) |saved| if (saved.serial == pane.serial) { - p.jump_selection_cursor = null; - }; } /// Resolve without changing focus or falling back to search. PDF links use @@ -12333,7 +12329,7 @@ pub const Pardes = struct { const pane = p.panes[id] orelse return; const link = probe.link orelse return; const target = p.pdfLinkLocation(pane, link) orelse return; - p.clearLookSelection(pane); + p.clearNavigationSelection(pane); if (p.canonicalLookLocation(id, probe.text)) |visible| { if (!std.mem.eql(u8, visible, target)) { const content = std.fmt.allocPrint(p.gpa, "{s}\n{s}\n", .{ visible, target }) catch |err| @@ -12367,7 +12363,7 @@ pub const Pardes = struct { // The operand may borrow selected terminal/PDF text released below. const txt = p.scratch.allocator().dupe(u8, operand) catch return; const trimmed = std.mem.trim(u8, txt, " \t\r\n"); - p.clearLookSelection(pane); + p.clearNavigationSelection(pane); const pl = look.parsePathLine(trimmed); if (comptime pdf_enabled) if (panes.Pdf.lookSection(p, id, pl.path, pl.at)) return; var realbuf: [4096]u8 = undefined; @@ -12390,14 +12386,14 @@ pub const Pardes = struct { .pane => |t| { if (t.id >= MAX_PANES) return; const target = p.panes[t.id] orelse return; - p.clearLookSelection(target); + p.clearNavigationSelection(target); p.focusPaneLine(t.id, t.at, .center); }, .url => |u| if (u.len <= 256) p.emit(.{ .open_link = .from(u) }), .dir => |dir| { for (p.panes, 0..) |slot, i| { if (slot) |tt| if (std.mem.eql(u8, tt.cwdSlice(), dir) and p.takesCommandLine(i)) { - p.clearLookSelection(tt); + p.clearNavigationSelection(tt); p.active = i; p.emitWrite(i, "ls\r"); return; @@ -12973,14 +12969,6 @@ pub const Pardes = struct { p.jcur = @min(cur, w -| 1); const pane = p.panes[p.active] orelse return; - // After a history arrival, an unchanged selection head still belongs - // to the selection, not to the location we just showed. - if (p.jump_selection_cursor) |saved| { - if (saved.pane == p.active and saved.serial == pane.serial and - saved.row == pane.cur_row and saved.col == pane.cur_col and - (pane.vsel.active or pane.msel.active or pane.nsel > 0)) return; - p.jump_selection_cursor = null; - } const now: Loc = .{ .pane = @intCast(p.active), .serial = pane.serial, @@ -13012,25 +13000,14 @@ pub const Pardes = struct { pub fn jumpBy(p: *Pardes, delta: i32) void { const next = @as(i64, @intCast(p.jcur)) + delta; if (p.njumps == 0 or next < 0 or next >= p.njumps) return; - p.jcur = @intCast(next); - const j = p.jumps[p.jcur]; + const j = p.jumps[@intCast(next)]; + if (j.pane >= MAX_PANES) return; const pane = p.panes[j.pane] orelse return; if (pane.serial != j.serial) return; - // A modal selection stores its head in the cursor. History changes - // the viewed location, but must not stretch that selection to it. - for (0..pane.sel.len) |slot| p.capturePointerSelection(pane, slot) catch return; - const preserve_cursor = pane.vsel.active or pane.msel.active or pane.nsel > 0; - const row = pane.cur_row; - const col = pane.cur_col; - const pinned = pane.cur_pinned; + if (p.panes[p.active]) |source| p.clearNavigationSelection(source); + if (p.active != j.pane) p.clearNavigationSelection(pane); + p.jcur = @intCast(next); p.focusPaneLine(j.pane, .{ .line = j.line, .col = j.col }, .center); - p.jump_selection_cursor = null; - if (preserve_cursor) { - p.jump_selection_cursor = .{ .pane = j.pane, .serial = pane.serial, .row = row, .col = col }; - pane.cur_row = row; - pane.cur_col = col; - pane.cur_pinned = pinned; - } } /// Recompute geometry, push grid-size changes to each emulator + pty, fire @@ -15000,32 +14977,43 @@ test "Look ignores missing and out of bounds pane addresses" { } } -test "jump history preserves modal and mouse selections" { +test "jump history clears selections and lands at the recorded cursor" { const p = try Pardes.init(std.testing.allocator, .{ .cols = 60, .rows = 12 }); defer p.deinit(); const pane = try p.setTestFile("alpha beta\ngamma delta\nepsilon zeta\n"); - pane.setRange(pane.file.?.content, 0, .{ .anchor = 1, .head = 5 }, true); - pane.sel[0] = .{ .state = .done, .c0 = 2, .c1 = 5, .r0 = 1, .r1 = 1 }; - const selection = pane.primaryRange(pane.file.?.content, 0); - try p.capturePointerSelection(pane, 0); - const mouse = pane.sel; p.njumps = 2; p.jcur = 1; p.jumps[0] = .{ .pane = 0, .serial = pane.serial, .line = 3, .col = 8 }; p.jumps[1] = .{ .pane = 0, .serial = pane.serial, .line = 1, .col = 1 }; - p.update(.{ .key = .{ .cp = 'o', .ctrl = true } }); - try std.testing.expectEqual(@as(usize, 0), p.jcur); - try std.testing.expectEqual(@as(u32, 3), p.jumps[0].line); - try std.testing.expectEqualDeep(selection, pane.primaryRange(pane.file.?.content, 0)); - try std.testing.expectEqualDeep(mouse, pane.sel); - p.update(.{ .key = .{ .cp = 'i', .ctrl = true } }); - try std.testing.expectEqual(@as(usize, 1), p.jcur); - try std.testing.expectEqualDeep(selection, pane.primaryRange(pane.file.?.content, 0)); - try std.testing.expectEqualDeep(mouse, pane.sel); - pane.vsel.active = false; - p.jumpBy(-1); - try std.testing.expectEqual(@as(i32, 2), pane.cur_row); - try std.testing.expectEqual(@as(i32, 7), pane.cur_col); + for ([_]u21{ 'o', 'i' }, 0..) |key, index| { + pane.setRange(pane.file.?.content, 0, .{ .anchor = 1, .head = 5 }, true); + pane.sel[0] = .{ .state = .done, .c0 = 2, .c1 = 5, .r0 = 1, .r1 = 1 }; + try p.capturePointerSelection(pane, 0); + pane.select = true; + p.update(.{ .key = .{ .cp = key, .ctrl = true } }); + try std.testing.expectEqual(index, p.jcur); + try std.testing.expectEqual(@as(usize, 2), p.njumps); + try std.testing.expectEqual(@as(u32, 3), p.jumps[0].line); + try std.testing.expect(!pane.vsel.active and !pane.msel.active and !pane.select); + try std.testing.expectEqual(@as(u8, 0), pane.nsel); + try std.testing.expectEqual(.none, pane.sel[0].state); + try std.testing.expect(pane.pointer_selections[0] == null); + try std.testing.expectEqual(@as(i32, if (index == 0) 2 else 0), pane.cur_row); + try std.testing.expectEqual(@as(i32, if (index == 0) 7 else 0), pane.cur_col); + } + pane.setRange(pane.file.?.content, 0, .{ .anchor = 1, .head = 5 }, true); + const selected = pane.primaryRange(pane.file.?.content, 0); + p.jumpBy(1); // No forward entry: selection stays untouched. + try std.testing.expectEqualDeep(selected, pane.primaryRange(pane.file.?.content, 0)); + for ([_]Loc{ + .{ .pane = 15, .serial = pane.serial, .line = 1, .col = 1 }, + .{ .pane = 0, .serial = pane.serial + 1, .line = 1, .col = 1 }, + }) |missing| { + p.jumps[0] = missing; + p.jumpBy(-1); + try std.testing.expectEqual(@as(usize, 1), p.jcur); + try std.testing.expectEqualDeep(selected, pane.primaryRange(pane.file.?.content, 0)); + } } test "jump history terminal rectangle follows output and clears on reflow" { @@ -15044,17 +15032,15 @@ test "jump history terminal rectangle follows output and clears on reflow" { try std.testing.expectEqual(.none, pane.sel[0].state); } -test "mouse thumb buttons navigate once without disturbing selection gestures" { +test "mouse thumb buttons navigate once and clear selection gestures" { const p = try Pardes.init(std.testing.allocator, .{ .cols = 60, .rows = 12 }); defer p.deinit(); const pane = try p.setTestFile("alpha beta\ngamma delta\nepsilon zeta\n"); pane.setRange(pane.file.?.content, 0, .{ .anchor = 1, .head = 5 }, true); - const selection = pane.primaryRange(pane.file.?.content, 0); p.njumps = 3; p.jcur = 2; for (0..3) |i| p.jumps[i] = .{ .pane = 0, .serial = pane.serial, .line = @intCast(i + 1), .col = 1 }; p.drag = .{ .select = .{ .id = 0, .button = config.select_button } }; - const drag = p.drag; p.update(.{ .mouse = .{ .button = .back, .kind = .press, .col = 0, .row = 0 } }); try std.testing.expectEqual(@as(usize, 1), p.jcur); for ([_]Mouse.Kind{ .drag, .release, .motion }) |kind| @@ -15063,6 +15049,6 @@ test "mouse thumb buttons navigate once without disturbing selection gestures" { p.update(.{ .mouse = .{ .button = .forward, .kind = .press, .col = 0, .row = 0 } }); p.update(.{ .mouse = .{ .button = .forward, .kind = .release, .col = 0, .row = 0 } }); try std.testing.expectEqual(@as(usize, 2), p.jcur); - try std.testing.expectEqualDeep(selection, pane.primaryRange(pane.file.?.content, 0)); - try std.testing.expectEqualDeep(drag, p.drag); + try std.testing.expect(!pane.vsel.active); + try std.testing.expectEqual(.none, p.drag); } diff --git a/test/panes.zig b/test/panes.zig index cb2e8169..81015356 100644 --- a/test/panes.zig +++ b/test/panes.zig @@ -899,7 +899,7 @@ const JumpSelectionTests = struct { if (wrap) try std.testing.expect(std.mem.indexOf(u8, selected, "界") != null); // Seed two actual locations after the drag, so both history directions - // must scroll while retaining the rectangle's original source text. + // must scroll and discard the previous selection. p.njumps = 2; p.jcur = 1; p.jumps[0] = .{ .pane = 0, .serial = pane.serial, .line = 60, .col = 1 }; @@ -909,25 +909,77 @@ const JumpSelectionTests = struct { _ = try p.render(frame.allocator()); try std.testing.expectEqual(@as(usize, 0), p.jcur); try std.testing.expect(pane.file.?.scroll > 20); - try std.testing.expectEqualStrings(selected, pardes.test_api.heldSelection(p, 0) orelse return error.LostMouseSelection); + try LookResetTests.cleared(pane); + try std.testing.expect(!pane.vsel.active); + try std.testing.expect(pardes.test_api.heldSelection(p, 0) == null); + try std.testing.expectEqual(@as(i32, 59), pane.cur_row); + try std.testing.expectEqual(@as(i32, 0), pane.cur_col); + // A selection created after Back must also disappear on Forward. + drag(p, x + 1, y, x + 3, y + 1); + try std.testing.expect(pardes.test_api.heldSelection(p, 0) != null); p.update(.{ .key = .{ .cp = 'i', .ctrl = true } }); _ = frame.reset(.retain_capacity); _ = try p.render(frame.allocator()); try std.testing.expectEqual(@as(usize, 1), p.jcur); try std.testing.expectEqual(@as(usize, 0), pane.file.?.scroll); - try std.testing.expectEqualStrings(selected, pardes.test_api.heldSelection(p, 0) orelse return error.LostMouseSelection); + try LookResetTests.cleared(pane); + try std.testing.expect(!pane.vsel.active); + try std.testing.expect(pardes.test_api.heldSelection(p, 0) == null); + try std.testing.expectEqual(@as(i32, 0), pane.cur_row); + try std.testing.expectEqual(@as(i32, 0), pane.cur_col); } - test "jump selection retains copied rectangle text after scrolling away and back" { + test "jump selection clears copied rectangles in both history directions" { for ([_]bool{ false, true }) |reverse| try exercise("alpha\nbravo\n", false, reverse, 1, 3, "lph\nrav"); } - test "jump selection retains wrapped Unicode and tab rectangle text" { + test "jump selection clears wrapped Unicode and tab rectangles" { for ([_]bool{ false, true }) |reverse| try exercise("界\tabcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789\n", true, reverse, 0, 8, null); } + + test "jump selection clears source and destination state across panes" { + const p = try Pardes.init(std.testing.allocator, .{ .tty_only = true, .cols = 100, .rows = 30 }); + defer p.deinit(); + const source = try p.setTestFile("alpha\nbravo\ncharlie\n"); + const id = p.freeSlot().?; + const destination = try p.newDocPane(id); + destination.file = .{ + .path = try p.gpa.dupe(u8, "/jump-destination.txt"), + .content = try p.gpa.dupe(u8, "first\nsecond\nthird\n"), + .history = try panes.File.History.create(p.gpa), + }; + layout.insert(p, 0, 1, id); + layout.compute(p); + try LookResetTests.seed(source, "source held text"); + try LookResetTests.seed(destination, "destination held text"); + p.active = 0; + p.njumps = 2; + p.jcur = 1; + p.jumps[0] = .{ .pane = @intCast(id), .serial = destination.serial, .line = 3, .col = 2 }; + p.jumps[1] = .{ .pane = 0, .serial = source.serial, .line = 2, .col = 1 }; + p.update(.{ .key = .{ .cp = 'o', .ctrl = true } }); + try std.testing.expectEqual(id, p.active); + try std.testing.expectEqual(@as(usize, 0), p.jcur); + try LookResetTests.cleared(source); + try LookResetTests.cleared(destination); + try std.testing.expect(!source.vsel.active and !destination.vsel.active); + try std.testing.expectEqual(@as(i32, 2), destination.cur_row); + try std.testing.expectEqual(@as(i32, 1), destination.cur_col); + + try LookResetTests.seed(source, "new source held text"); + try LookResetTests.seed(destination, "new destination held text"); + p.update(.{ .key = .{ .cp = 'i', .ctrl = true } }); + try std.testing.expectEqual(@as(usize, 0), p.active); + try std.testing.expectEqual(@as(usize, 1), p.jcur); + try LookResetTests.cleared(source); + try LookResetTests.cleared(destination); + try std.testing.expect(!source.vsel.active and !destination.vsel.active); + try std.testing.expectEqual(@as(i32, 1), source.cur_row); + try std.testing.expectEqual(@as(i32, 0), source.cur_col); + } }; const TagNameTintTests = struct { diff --git a/test/pdf.zig b/test/pdf.zig index 7a05447e..beeb0b40 100644 --- a/test/pdf.zig +++ b/test/pdf.zig @@ -2055,3 +2055,30 @@ test "Esc back into a PDF keeps the offset within its page" { // snap, so a test that watched the offset alone would not see it coming. try std.testing.expect(!pv.scroll_to_page_pending); } + +test "PDF Back and Forward clear selections and land on recorded pages" { + if (!pdf_enabled or platform == .web) return error.SkipZigTest; + const p = try Pardes.init(std.testing.allocator, .{ .file = "docs/design.pdf", .cols = 80, .rows = 28 }); + defer p.deinit(); + p.native_images = true; + p.presentation.enabled = false; + const pane = p.panes[0].?; + const state = &pane.pdf.?; + try std.testing.expect(state.page_count > 1); + try std.testing.expect(state.focusLocation(p.pdf_gpa, 2, 0)); + p.njumps = 2; + p.jcur = 1; + p.jumps[0] = .{ .pane = 0, .serial = pane.serial, .line = 1, .col = 0 }; + p.jumps[1] = .{ .pane = 0, .serial = pane.serial, .line = 2, .col = 0 }; + for ([_]u21{ 'o', 'i' }, 0..) |key, destination| { + try std.testing.expectEqual(panes.Pdf.SelectionUpdate.changed, state.setSelection(p.pdf_gpa, .{ .x = 0, .y = 0 }, .{ .x = 1, .y = 1 }, true)); + try std.testing.expect(state.selection != null and state.selection_text.len > 0); + p.update(.{ .key = .{ .cp = key, .ctrl = true } }); + try std.testing.expectEqual(destination, p.jcur); + try std.testing.expectEqual(destination, state.page); + try std.testing.expect(state.selection == null); + try std.testing.expect(state.selection_page == null); + try std.testing.expectEqual(@as(usize, 0), state.selection_text.len); + try std.testing.expect(state.drag_anchor == null and state.drag_head == null); + } +} -- cgit v1.3 From 2109098400fa37d7b448f232c848a0411c318591 Mon Sep 17 00:00:00 2001 From: Gabriel Schneider Date: Wed, 16 Sep 2026 12:18:01 -0300 Subject: Give macOS scrolling momentum MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit A swipe that was still moving when the fingers lifted stopped dead. The dial next to it has thrown properly since pardes_rotate_end, and this is that same curve on the scroll accumulator: velocity sampled between events off the monotonic clock, weighted toward the newest sample because a flick is decided by how the hand was moving when it left, and a fling that ramps up from zero at the floor rather than switching on at it. A coast stops at the end of a document rather than spinning its remaining velocity against the edge, which is why spendScroll now reports whether the pane moved and why paneAt is public. Only a step that delivered a press can report an edge — the many steps between two rows cross nothing. Nothing suppresses AppKit's own momentum, and nothing needs to: its momentum events are ordinary pardes_scroll calls, every one of which cancels the coast before spending its travel, so on a real trackpad the system takes the gesture over about a frame after the lift and the tail it ends on is below the floor. This is the path for devices AppKit does not fling for — and the only one a script can reach, since NSEvent phases have no public constructor. momentum.snap asserts both halves, which is why it needs the long scrollback: a flick with no document left proves nothing. A slow swipe is byte-identical after the release; a hard one coasts twenty-four rows further on its own, and a finger back on the pad stops it there. Co-Authored-By: Claude Opus 5 (1M context) --- src/macos.zig | 194 +++++++++++++++++++++++++++++++---- src/macos/Sources/PardesView.swift | 34 ++++++ src/macos/pardes.h | 18 ++++ src/pardes.zig | 2 +- test/macos-snapshots/momentum.golden | 186 +++++++++++++++++++++++++++++++++ test/macos-snapshots/momentum.snap | 73 +++++++++++++ test/macos_e2e.swift | 25 +++++ 7 files changed, 509 insertions(+), 23 deletions(-) create mode 100644 test/macos-snapshots/momentum.golden create mode 100644 test/macos-snapshots/momentum.snap (limited to 'src/pardes.zig') diff --git a/src/macos.zig b/src/macos.zig index 67a5ec5b..4b37255e 100644 --- a/src/macos.zig +++ b/src/macos.zig @@ -658,6 +658,15 @@ const State = struct { gens: [pardes.MAX_PANES]u32 = @splat(0), scroll_lag: f32 = 0, scroll_lag_x: f32 = 0, + scroll_velocity: f32 = 0, + scroll_velocity_x: f32 = 0, + scroll_last_ns: i128 = 0, + /// Where the gesture turned. A coast keeps delivering THERE rather than + /// wherever the pointer has drifted to since — the same rule the SDL + /// shell keeps in scroll_col/scroll_row. + scroll_col: u16 = 0, + scroll_row: u16 = 0, + scroll_coasting: bool = false, rotate_lag: f32 = 0, rotate_velocity: f32 = 0, rotate_last_ns: i128 = 0, @@ -866,7 +875,7 @@ test "the animation clock spends real time, not callbacks" { export fn pardes_animating() bool { const st = &(state orelse return false); - return st.core.animationActive() or st.rotate_coasting; + return st.core.animationActive() or st.rotate_coasting or st.scroll_coasting; } export fn pardes_theme_bg() u32 { @@ -1282,6 +1291,10 @@ fn restoreCore(st: *State) bool { st.cwd_stale = @splat(false); st.scroll_lag = 0; st.scroll_lag_x = 0; + st.scroll_velocity = 0; + st.scroll_velocity_x = 0; + st.scroll_last_ns = 0; + st.scroll_coasting = false; st.rotate_lag = 0; st.rotate_velocity = 0; st.rotate_last_ns = 0; @@ -1464,6 +1477,30 @@ export fn pardes_animation_tick() bool { st.core.update(.tick); changed = true; } + if (st.scroll_coasting) { + const spent_now = spendScroll( + st, + st.scroll_velocity * scroll_fling_step, + st.scroll_velocity_x * scroll_fling_step, + st.scroll_col, + st.scroll_row, + ); + st.scroll_velocity *= scroll_fling_decay; + st.scroll_velocity_x *= scroll_fling_decay; + const decayed = @abs(st.scroll_velocity) < scroll_fling_stop and + @abs(st.scroll_velocity_x) < scroll_fling_stop; + // Only a step that actually delivered a press can report an edge; + // the many steps between two rows cross nothing and say nothing. + const at_edge = spent_now.ticks != 0 and !spent_now.moved; + if (decayed or at_edge) { + st.scroll_velocity = 0; + st.scroll_velocity_x = 0; + st.scroll_coasting = false; + st.scroll_lag = 0; + st.scroll_lag_x = 0; + } + changed = true; + } if (st.rotate_coasting) { spendRotation(st, st.rotate_velocity * rotation_fling_step); st.rotate_velocity *= rotation_fling_decay; @@ -1563,28 +1600,48 @@ export fn pardes_pointer_leave() void { export fn pardes_scroll(delta_rows: f32, delta_cols: f32, col: u16, row: u16) void { const st = &(state orelse return); - var down_left = takeScrollTicks(&st.scroll_lag, delta_rows); - while (down_left != 0) { - const down = down_left > 0; - down_left += if (down) -1 else 1; - st.core.update(.{ .mouse = .{ - .button = if (down) .wheel_down else .wheel_up, - .kind = .press, - .col = col, - .row = row, - } }); - } - var right_left = takeScrollTicks(&st.scroll_lag_x, delta_cols); - while (right_left != 0) { - const right = right_left > 0; - right_left += if (right) -1 else 1; - st.core.update(.{ .mouse = .{ - .button = if (right) .wheel_right else .wheel_left, - .kind = .press, - .col = col, - .row = row, - } }); + st.scroll_col = col; + st.scroll_row = row; + noteScrollVelocity(st, delta_rows, delta_cols); + _ = spendScroll(st, delta_rows, delta_cols, col, row); +} + +/// A finger back on the pad, which catches a coast the way a hand catches a +/// spinning dial. Also drops whatever the last gesture left banked, so the +/// first millimetre of a new swipe cannot inherit a nearly-complete row. +export fn pardes_scroll_begin() void { + const st = &(state orelse return); + st.scroll_lag = 0; + st.scroll_lag_x = 0; + st.scroll_velocity = 0; + st.scroll_velocity_x = 0; + st.scroll_coasting = false; + st.scroll_last_ns = monotonicNs(); +} + +/// Fingers lifted. A swipe that was still moving when it ended becomes a +/// fling, measured from the speed of the last events rather than from any one +/// of them, exactly as pardes_rotate_end measures the dial. +/// +/// A host whose windowing system flings for it need do nothing to suppress +/// this: its first momentum event is an ordinary pardes_scroll, and every +/// pardes_scroll cancels the coast before spending its own travel. The system's +/// momentum simply takes the gesture over, and the tail of that momentum is +/// below the fling floor, so its end arms nothing. +export fn pardes_scroll_end() void { + const st = &(state orelse return); + const last = st.scroll_last_ns; + st.scroll_last_ns = 0; + st.scroll_coasting = false; + // A hand that came to rest before lifting is not throwing anything. + if (last == 0 or monotonicNs() - last > 90 * std.time.ns_per_ms) { + st.scroll_velocity = 0; + st.scroll_velocity_x = 0; + return; } + st.scroll_velocity = scrollFling(st.scroll_velocity); + st.scroll_velocity_x = scrollFling(st.scroll_velocity_x); + st.scroll_coasting = st.scroll_velocity != 0 or st.scroll_velocity_x != 0; } export fn pardes_rotate(degrees: f32) void { @@ -2351,6 +2408,97 @@ fn encodeCellFlags(default: bool, role: pardes.FontRole) u8 { @as(u8, @intFromBool(role == .tagline)) * cell_flag_tagline; } +fn noteScrollVelocity(st: *State, delta_rows: f32, delta_cols: f32) void { + const now = monotonicNs(); + const last = st.scroll_last_ns; + st.scroll_last_ns = now; + // Any real travel ends a coast: that is what lets a host with momentum of + // its own take the gesture over without either side knowing about it. + st.scroll_coasting = false; + if (last == 0 or now == 0) return; + const dt_ns = now - last; + // A gap this long is a new gesture, not a fast one. Without the guard the + // pause between two separate swipes would read as enormous speed. + if (dt_ns <= 0 or dt_ns > 200 * std.time.ns_per_ms) return; + const seconds: f32 = @floatCast(@as(f64, @floatFromInt(dt_ns)) / @as(f64, std.time.ns_per_s)); + const rows = delta_rows / seconds; + const cols = delta_cols / seconds; + if (!std.math.isFinite(rows) or !std.math.isFinite(cols)) return; + // Weighted toward the newest sample: a flick is decided by how the hand was + // moving when it left, not by how the swipe started. + st.scroll_velocity = st.scroll_velocity * 0.35 + rows * 0.65; + st.scroll_velocity_x = st.scroll_velocity_x * 0.35 + cols * 0.65; +} + +/// Spend accumulated travel as wheel presses, and report whether the pane under +/// the gesture actually moved. +/// +/// A coast has to stop at the end of a document instead of spinning the rest of +/// its velocity against the edge — the SDL shell stops for the same reason in +/// stepScroll. Only the vertical axis can be measured that way (a pane's +/// horizontal position is not Pane.scroll()), so sideways travel counts as +/// movement; a purely horizontal fling therefore rides its decay out, which is +/// what it would do anyway once the drift guard has swallowed it. +const Spent = struct { + /// Whole wheel presses delivered. Most coast steps cross no row at all, + /// which is why "did not move" cannot be read off `moved` alone. + ticks: u32 = 0, + moved: bool = false, +}; + +fn spendScroll(st: *State, delta_rows: f32, delta_cols: f32, col: u16, row: u16) Spent { + const pane = if (st.core.paneAt(col, row)) |id| st.core.panes[id] else null; + var out: Spent = .{}; + var down_left = takeScrollTicks(&st.scroll_lag, delta_rows); + while (down_left != 0) { + const down = down_left > 0; + down_left += if (down) -1 else 1; + out.ticks += 1; + const was = if (pane) |p| p.scroll() else 0; + st.core.update(.{ .mouse = .{ + .button = if (down) .wheel_down else .wheel_up, + .kind = .press, + .col = col, + .row = row, + } }); + if (pane) |p| { + if (p.scroll() != was) out.moved = true; + } else out.moved = true; + } + var right_left = takeScrollTicks(&st.scroll_lag_x, delta_cols); + while (right_left != 0) { + const right = right_left > 0; + right_left += if (right) -1 else 1; + st.core.update(.{ .mouse = .{ + .button = if (right) .wheel_right else .wheel_left, + .kind = .press, + .col = col, + .row = row, + } }); + out.ticks += 1; + out.moved = true; + } + return out; +} + +// Rows per second. The floor is what separates a flick from a swipe that +// merely ended while still in contact; the ceiling stops a jab from launching +// the page past anything the eye can follow. Step and decay are stated at +// 60 Hz and spent by the same measured display clock the rotation fling uses, +// so a 120 Hz screen coasts the same distance in the same time. +const scroll_fling_floor: f32 = 8; +const scroll_fling_max: f32 = 90; +const scroll_fling_step: f32 = 1.0 / 60.0; +const scroll_fling_decay: f32 = 0.94; +const scroll_fling_stop: f32 = 2; + +fn scrollFling(speed: f32) f32 { + if (!std.math.isFinite(speed)) return 0; + const excess = @min(@abs(speed) - scroll_fling_floor, scroll_fling_max); + if (excess < scroll_fling_stop) return 0; + return std.math.copysign(excess, speed); +} + fn takeScrollTicks(lag: *f32, delta_rows: f32) i32 { if (!std.math.isFinite(delta_rows)) return 0; const next = std.math.clamp(lag.* + delta_rows, -256, 256); @@ -2419,6 +2567,8 @@ test "pardes.h declares every export the way it is defined" { try expectSameAbi(@TypeOf(c.pardes_pointer_leave), @TypeOf(pardes_pointer_leave)); try expectSameAbi(@TypeOf(c.pardes_watch_changed), @TypeOf(pardes_watch_changed)); try expectSameAbi(@TypeOf(c.pardes_scroll), @TypeOf(pardes_scroll)); + try expectSameAbi(@TypeOf(c.pardes_scroll_begin), @TypeOf(pardes_scroll_begin)); + try expectSameAbi(@TypeOf(c.pardes_scroll_end), @TypeOf(pardes_scroll_end)); try expectSameAbi(@TypeOf(c.pardes_rotate), @TypeOf(pardes_rotate)); try expectSameAbi(@TypeOf(c.pardes_rotate_end), @TypeOf(pardes_rotate_end)); try expectSameAbi(@TypeOf(c.pardes_command), @TypeOf(pardes_command)); diff --git a/src/macos/Sources/PardesView.swift b/src/macos/Sources/PardesView.swift index 5df1fd73..ba3677e7 100644 --- a/src/macos/Sources/PardesView.swift +++ b/src/macos/Sources/PardesView.swift @@ -1842,6 +1842,20 @@ final class PardesView: NSView { fed() } + /// Fingers down and fingers up on a precise scroll. Entry points of their + /// own for the same reason rotateEnd is one: NSEvent phases have no public + /// constructor, and a fling nothing can synthesize is a fling nothing can + /// assert. + func scrollBegin() { + pardes_scroll_begin() + fed() + } + + func scrollEnd() { + pardes_scroll_end() + fed() + } + func rotate(degrees: CGFloat) { guard degrees != 0 else { return } pardes_rotate(Float(degrees)) @@ -2086,12 +2100,32 @@ final class PardesView: NSView { return } if event.hasPreciseScrollingDeltas { + // Phases first: a finger back on the pad has to catch a coast before + // its own travel is spent, or the first millimetre of the new swipe + // would be added to the old fling instead of replacing it. + // + // Momentum events carry `phase == .none` and a momentumPhase + // instead, so neither branch here fires for them — they are just + // more travel, and libpardes lets them take the gesture over. That + // is deliberate: AppKit's fling is the one the rest of the system + // uses, and a second fling of our own underneath it would scroll + // everything at double speed. `pardes_scroll_end` exists for the + // devices AppKit does NOT fling for. + if event.phase == .began { scrollBegin() } // The core scrolls a cell at a time, so libpardes accumulates the // sub-cell travel and spends it as wheel presses — which is why the // cell has to travel with the delta. scroll(rows: -event.scrollingDeltaY / cellHeight, cols: -event.scrollingDeltaX / cellWidth, at: at) + switch event.phase { + case .ended: scrollEnd() + // A gesture the system took away should not be thrown. scrollBegin + // is the catching half of the pair — coast stopped, bank and + // velocity cleared — which is exactly what a cancellation means. + case .cancelled: scrollBegin() + default: break + } } else { // AppKit's sign is the opposite of the DOM's: positive deltaY means the // content moved down, which is a scroll back through history. diff --git a/src/macos/pardes.h b/src/macos/pardes.h index 5f1ccf77..a2d13b1f 100644 --- a/src/macos/pardes.h +++ b/src/macos/pardes.h @@ -377,6 +377,24 @@ void pardes_watch_changed(uint8_t pane, uint32_t generation); void pardes_scroll(float delta_rows, float delta_cols, uint16_t col, uint16_t row); +// The gesture boundaries around pardes_scroll, and the whole of scroll +// momentum. `begin` is fingers down: it catches a coast the way a hand catches +// a spinning dial, and drops whatever the last gesture left banked. `end` is +// fingers up: a swipe still moving when it ended becomes a fling, in +// proportion to how hard it was thrown, on the same curve pardes_rotate_end +// uses — momentum ramps up from zero rather than switching on at a threshold. +// +// A coast makes pardes_animating true and is spent by pardes_animation_tick, +// and it stops at the end of a document instead of spinning against the edge. +// +// A host whose windowing system already flings for it needs no suppression: +// the system's momentum arrives as ordinary pardes_scroll calls, every one of +// which cancels the coast before spending its own travel, so that momentum +// simply takes the gesture over. A host that calls neither — a discrete wheel +// has no phases — scrolls with no momentum at all. +void pardes_scroll_begin(void); +void pardes_scroll_end(void); + // A two-finger trackpad rotation, in degrees since the last call, positive // counterclockwise (AppKit's sign, unchanged). The core has no rotation: this // is spent as the search-step keys, clockwise `n` and counterclockwise `N`, a diff --git a/src/pardes.zig b/src/pardes.zig index 16343972..c1a6b038 100644 --- a/src/pardes.zig +++ b/src/pardes.zig @@ -11047,7 +11047,7 @@ pub const Pardes = struct { return null; } - fn paneAt(p: *const Pardes, col: u16, row: u16) ?usize { + pub fn paneAt(p: *const Pardes, col: u16, row: u16) ?usize { for (p.panes, 0..) |slot, id| { if (slot == null) continue; const r = p.rects[id]; diff --git a/test/macos-snapshots/momentum.golden b/test/macos-snapshots/momentum.golden new file mode 100644 index 00000000..b4471061 --- /dev/null +++ b/test/macos-snapshots/momentum.golden @@ -0,0 +1,186 @@ +== snap home grid=100x30 cursor=4,29 +|Newcol Joincol Find Grep Help Changelog Tutor Dump NextColor Debug Kill +| New Tty Find Grep Joincol +|$ /private/tmp/pardes-macos-e2e/momentum/cwd Tty Save Del Mode Filter Collapse +| LINE 175 +| LINE 176 +| LINE 177 +| LINE 178 +| LINE 179 +| LINE 180 +| LINE 181 +| LINE 182 +| LINE 183 +| LINE 184 +| LINE 185 +| LINE 186 +| LINE 187 +| LINE 188 +| LINE 189 +| LINE 190 +| LINE 191 +| LINE 192 +| LINE 193 +| LINE 194 +| LINE 195 +| LINE 196 +| LINE 197 +| LINE 198 +| LINE 199 +| LINE 200 +| $ +== snap placed grid=100x30 cursor=0,0 +|Newcol Joincol Find Grep Help Changelog Tutor Dump NextColor Debug Kill +| New Tty Find Grep Joincol +|$ /private/tmp/pardes-macos-e2e/momentum/cwd Tty Save Del Mode Filter Collapse +| LINE 174 +| LINE 175 +| LINE 176 +| LINE 177 +| LINE 178 +| LINE 179 +| LINE 180 +| LINE 181 +| LINE 182 +| LINE 183 +| LINE 184 +| LINE 185 +| LINE 186 +| LINE 187 +| LINE 188 +| LINE 189 +| LINE 190 +| LINE 191 +| LINE 192 +| LINE 193 +| LINE 194 +| LINE 195 +| LINE 196 +| LINE 197 +| LINE 198 +| LINE 199 +| LINE 200 +== snap placed_released grid=100x30 cursor=0,0 +|Newcol Joincol Find Grep Help Changelog Tutor Dump NextColor Debug Kill +| New Tty Find Grep Joincol +|$ /private/tmp/pardes-macos-e2e/momentum/cwd Tty Save Del Mode Filter Collapse +| LINE 174 +| LINE 175 +| LINE 176 +| LINE 177 +| LINE 178 +| LINE 179 +| LINE 180 +| LINE 181 +| LINE 182 +| LINE 183 +| LINE 184 +| LINE 185 +| LINE 186 +| LINE 187 +| LINE 188 +| LINE 189 +| LINE 190 +| LINE 191 +| LINE 192 +| LINE 193 +| LINE 194 +| LINE 195 +| LINE 196 +| LINE 197 +| LINE 198 +| LINE 199 +| LINE 200 +== snap thrown grid=100x30 cursor=0,0 +|Newcol Joincol Find Grep Help Changelog Tutor Dump NextColor Debug Kill +| New Tty Find Grep Joincol +|$ /private/tmp/pardes-macos-e2e/momentum/cwd Tty Save Del Mode Filter Collapse +| LINE 165 +| LINE 166 +| LINE 167 +| LINE 168 +| LINE 169 +| LINE 170 +| LINE 171 +| LINE 172 +| LINE 173 +| LINE 174 +| LINE 175 +| LINE 176 +| LINE 177 +| LINE 178 +| LINE 179 +| LINE 180 +| LINE 181 +| LINE 182 +| LINE 183 +| LINE 184 +| LINE 185 +| LINE 186 +| LINE 187 +| LINE 188 +| LINE 189 +| LINE 190 +| LINE 191 +== snap coasted grid=100x30 cursor=0,0 +|Newcol Joincol Find Grep Help Changelog Tutor Dump NextColor Debug Kill +| New Tty Find Grep Joincol +|$ /private/tmp/pardes-macos-e2e/momentum/cwd Tty Save Del Mode Filter Collapse +| LINE 141 +| LINE 142 +| LINE 143 +| LINE 144 +| LINE 145 +| LINE 146 +| LINE 147 +| LINE 148 +| LINE 149 +| LINE 150 +| LINE 151 +| LINE 152 +| LINE 153 +| LINE 154 +| LINE 155 +| LINE 156 +| LINE 157 +| LINE 158 +| LINE 159 +| LINE 160 +| LINE 161 +| LINE 162 +| LINE 163 +| LINE 164 +| LINE 165 +| LINE 166 +| LINE 167 +== snap caught grid=100x30 cursor=0,0 +|Newcol Joincol Find Grep Help Changelog Tutor Dump NextColor Debug Kill +| New Tty Find Grep Joincol +|$ /private/tmp/pardes-macos-e2e/momentum/cwd Tty Save Del Mode Filter Collapse +| LINE 141 +| LINE 142 +| LINE 143 +| LINE 144 +| LINE 145 +| LINE 146 +| LINE 147 +| LINE 148 +| LINE 149 +| LINE 150 +| LINE 151 +| LINE 152 +| LINE 153 +| LINE 154 +| LINE 155 +| LINE 156 +| LINE 157 +| LINE 158 +| LINE 159 +| LINE 160 +| LINE 161 +| LINE 162 +| LINE 163 +| LINE 164 +| LINE 165 +| LINE 166 +| LINE 167 diff --git a/test/macos-snapshots/momentum.snap b/test/macos-snapshots/momentum.snap new file mode 100644 index 00000000..1c578e68 --- /dev/null +++ b/test/macos-snapshots/momentum.snap @@ -0,0 +1,73 @@ +# Scroll momentum: a swipe still moving when the fingers lift keeps scrolling, +# in proportion to how hard it was thrown. +# +# The same shape as the dial's fling in rotate.snap, and asserted the same way, +# because the contract is the same one: momentum ramps up from zero at the +# floor (scroll_fling_floor in src/macos.zig, 8 rows/second) rather than +# switching on at it. The `gap_ms` argument is what makes the two cases +# different — it is a real sleep before the event, so libpardes measures a real +# speed off its monotonic clock rather than reading back-to-back script lines +# as an impossibly fast hand. +# +# Momentum on a real Apple trackpad comes from AppKit, not from here: its +# momentum events are ordinary pardes_scroll calls and every one of them +# cancels the coast. This is the path for the devices AppKit does not fling +# for, and it is the only one a script can reach at all, since NSEvent phases +# have no public constructor. +start 30 100 +wait 8000 Newcol Joincol +wait 8000 $ +stable 700 20000 +# Something long enough to coast ALONG. A flick that runs out of document has +# nothing left to prove: at the top of a short scrollback the hardest possible +# throw and no throw at all leave the same screen. Brace expansion rather than +# seq, so the hermetic world needs nothing on PATH. +text printf 'LINE %s\n' {1..200} +key enter +wait 10000 LINE 200 +stable 700 10000 +snap home + +# ---- PLACED ---- +# +# Half a row every 100 ms is 5 rows/second, under the floor, so lifting the +# fingers changes nothing: the swipe itself has moved what it moved and that is +# where it stops. This is the case that has to hold — a slow deliberate scroll +# that kept sliding afterwards would be unusable. +scroll_begin +scroll -0.5 10 10 0 100 +scroll -0.5 10 10 0 100 +scroll -0.5 10 10 0 100 +stable 700 15000 +snap placed +scroll_end +stable 700 15000 +# Byte-identical to `placed`, which is the whole assertion. +snap placed_released + +# ---- THROWN ---- +# +# The same hand moving six times as far in a twentieth of the time is hundreds +# of rows a second, so the release keeps the view travelling after the fingers +# are gone. +# +# `snap` and then `scroll_end` with NO `stable` between them, which is not +# impatience: a release is only a throw if it arrives while the hand is still +# moving, and a 700 ms wait here would be a hand that stopped — which is +# exactly what PLACED above already proves. +scroll_begin +scroll -3 10 10 0 5 +scroll -3 10 10 0 5 +scroll -3 10 10 0 5 +snap thrown +scroll_end +stable 700 15000 +# Further back through the scrollback than `thrown`, and that distance is the +# coast: nothing but the fling moved the view between these two captures. +snap coasted + +# A finger back on the pad catches it. Begin re-zeros the velocity and the +# bank, so a second throw cannot inherit the first one's speed. +scroll_begin +stable 700 15000 +snap caught diff --git a/test/macos_e2e.swift b/test/macos_e2e.swift index fbfa0e3e..43627a7e 100644 --- a/test/macos_e2e.swift +++ b/test/macos_e2e.swift @@ -790,6 +790,12 @@ private final class Driver: PardesViewDelegate { view.drop([path], at: cell) pump() + // `scroll [cols] [gap_ms]`. The optional gap is a + // real sleep BEFORE the event and means what it does for `rotate`: + // libpardes measures the release speed off the monotonic clock between + // calls, so back-to-back script lines read as an impossibly fast swipe. + // Pacing them is the only way a script can say a swipe was SLOW, which + // is the half of the momentum contract a fling test cannot show. case "scroll": let view = try live() let rows = try double(args, 0, "scroll rows") @@ -799,9 +805,28 @@ private final class Driver: PardesViewDelegate { // other suites' scroll commands do. var cols = 0.0 if args.count > 3 { cols = try double(args, 3, "scroll cols") } + if args.count > 4 { + Thread.sleep(forTimeInterval: try double(args, 4, "scroll gap_ms") / 1000) + } view.scroll(rows: CGFloat(rows), cols: CGFloat(cols), at: cell) pump() + // Fingers down and fingers up. Their own commands for the reason + // rotate_end is one: the fling is decided by the RELEASE SPEED, and + // NSEvent phases have no public constructor, so these entry points are + // the only way the momentum path is reachable from a script at all. + // The coast is then spent by idle's display clock, one step per + // animation frame; ordinary pumps do not move it. + case "scroll_begin": + let view = try live() + view.scrollBegin() + pump() + + case "scroll_end": + let view = try live() + view.scrollEnd() + pump() + case "wheel": let view = try live() let button = try mouseButton(try token(args, 0, "wheel button")) -- cgit v1.3 From 3042f33df2b16b61c08d6535fba268103728dd1e Mon Sep 17 00:00:00 2001 From: Gabriel Schneider Date: Wed, 16 Sep 2026 12:26:38 -0300 Subject: Follow the tag gap in the Look hover preview test MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The tag's first character moved to TAG_TEXT_INSET when the grip's hit area was separated from the text by a gap; the assertion kept reading GUTTER, which is now the gap itself and carries the plain tag background. The test's own point — that a preview on the tag's first character is paintable at tag column zero, PREFIX_W being a body concern — is unchanged; only where column zero is moved. Co-Authored-By: Claude Opus 5 (1M context) --- src/pardes.zig | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'src/pardes.zig') diff --git a/src/pardes.zig b/src/pardes.zig index c1a6b038..94f67ced 100644 --- a/src/pardes.zig +++ b/src/pardes.zig @@ -4280,10 +4280,12 @@ test "Look hover waits without mutating the pane and input cancels it" { try std.testing.expect(!p.animationActive()); // File PREFIX_W belongs only to body line numbers. A preview on the tag's - // first character must be paintable all the way at tag column zero. + // first character must be paintable all the way at tag column zero — which + // is TAG_TEXT_INSET, not GUTTER: the grip keeps the gutter and the gap + // beside it separates the grip's hit area from the text. const tag_y = if (p.settings.tag_bottom) rect.y + rect.h - BOX_H else rect.y; p.look_hover_preview = .{ - .col = rect.x + config.GUTTER, + .col = rect.x + TAG_TEXT_INSET, .row = tag_y, .pane = p.active, .serial = pane.serial, @@ -4291,7 +4293,7 @@ test "Look hover waits without mutating the pane and input cancels it" { }; _ = frame.reset(.retain_capacity); const tag_surface = try p.render(frame.allocator()); - try std.testing.expectEqual(Color{ .rgb = expected_bg }, tag_surface.at(rect.x + config.GUTTER, tag_y).style.bg); + try std.testing.expectEqual(Color{ .rgb = expected_bg }, tag_surface.at(rect.x + TAG_TEXT_INSET, tag_y).style.bg); p.look_hover_preview = null; p.update(motion); -- cgit v1.3 From 717afaf3177a2e0925b18ae3445119efe808b129 Mon Sep 17 00:00:00 2001 From: Gabriel Schneider Date: Wed, 16 Sep 2026 14:46:16 -0300 Subject: Add macOS backdrop blur and preserve PDF ink opacity --- docs/macos.md | 42 +++++++++++++++++++++--- docs/rendering-parity-design.md | 6 ++-- src/builtins.zig | 1 + src/config.zig | 49 +++++++++++++++++++++++++--- src/macos.zig | 29 ++++++++++++++++ src/macos/Sources/AppDelegate.swift | 24 +++++++------- src/macos/Sources/PardesView.swift | 16 ++++++++- src/macos/pardes.h | 4 +++ src/panes.zig | 7 +++- src/pardes.zig | 2 ++ src/pdf.zig | 48 +++++++++++++++++++++++++++ src/pdf_bridge.c | 21 ++++++++++-- src/pdf_bridge.h | 6 ++-- test/macos-snapshots/rendering-parity.golden | 14 ++++---- test/macos_e2e.swift | 21 ++++++++---- 15 files changed, 249 insertions(+), 41 deletions(-) (limited to 'src/pardes.zig') diff --git a/docs/macos.md b/docs/macos.md index 3fdf399f..9190ca67 100644 --- a/docs/macos.md +++ b/docs/macos.md @@ -696,7 +696,7 @@ A theme with `bg = null` — the curated `dark`, and every vendored `pardes_theme_bg` answers `PARDES_COLOR_DEFAULT` and the host goes see-through: `window.isOpaque = false`, a clear background colour, and an `NSVisualEffectView` (`.underWindowBackground`, `.behindWindow`, `.active`) -behind the grid. `PardesView` stops painting the ground at all — it *clears*, +behind the grid when `WindowBlur` is enabled. `PardesView` stops painting the ground at all — it *clears*, because AppKit does not blank a non-opaque view — and any cell whose background is still the default resolves to `bgClear` and is skipped by the run loop. Reversed cells are not: a reverse puts the text colour in the background, and @@ -710,10 +710,42 @@ blank window for every opaque theme the moment it was hidden. Background fills replace existing coverage, so overlapping ground, cell, tag and context layers cannot increase the requested opacity. The window itself stays clear below 100%; a second tinted window backdrop would compound it. -Text and cursor ink stay opaque. PDF and image pixels follow the SDL image -pipeline: remove the destination by source coverage, then add the image at the -requested opacity. This also preserves the background under transparent image -pixels. Theme colours and attachment rasters are interpreted as sRGB. +Text and cursor ink stay opaque. PDFs render onto a transparent MuPDF pixmap, +which preserves the coverage of text, paths, photos, and highlights. The host +paints paper at `WindowOpacity`, then composites PDF content at its original +opacity. Blank paper therefore reveals the blurred backdrop while lettering +stays readable even at `WindowOpacity 0`. Paper is white with `PdfTint` disabled +and uses the theme background otherwise. Explicit PDF background rectangles +and scanned page images remain content: this does not guess paper from pixel +brightness or remove white objects from a document. Scrolling and transitions +retain both the content raster and its paper color. + +Ordinary image attachments still follow the SDL image pipeline: remove the +destination by source coverage, then add the image at the requested opacity. +Theme colours and attachment rasters are interpreted as sRGB. The PDF paper +separation is currently macOS-specific; other hosts keep the opaque raster path. + +`WindowBlur <0..100>` controls the strength of that native backdrop independently +of `WindowOpacity`. It is a macOS-only builtin, also accepted in the startup +config and reported by `Config`. It defaults to 0 (off); 100 shows the full +AppKit material and intermediate values blend the material with the unblurred +backdrop using the effect view's alpha. An opaque themed background hides the +effect; lowering `WindowOpacity` makes the remembered strength visible again. +For example: + +```text +WindowOpacity 71 +WindowBlur 60 +``` + +This is material strength, not a Gaussian radius in pixels. AppKit's public +`NSVisualEffectView` API chooses its own blur and tint for the material. It +samples behind the window; text and cursors are drawn in a separate sibling +above the effect and remain sharp. macOS accessibility settings such as Reduce +Transparency can override the material's appearance. `WindowBlur 0` also turns +off the formerly implicit blur for background-less themes; set it to 100 to +restore that appearance. The compositor must be checked in a live window: +offscreen grid captures cannot verify behind-window blur. `test/macos-snapshots/rendering-parity.snap` checks background colour and alpha, regular and bottom tags, compact context separators, and PDF fit, tint and diff --git a/docs/rendering-parity-design.md b/docs/rendering-parity-design.md index b6036543..14a5bc62 100644 --- a/docs/rendering-parity-design.md +++ b/docs/rendering-parity-design.md @@ -76,8 +76,10 @@ out.rgb = p * a * c + (1 - a) * dst.rgb out.a = p * a + (1 - a) * dst.a ``` -Thus PDF text is part of a raster page and fades with the page; native text does -not. Transparent image pixels preserve the destination. Ordinary source-over +This describes ordinary image attachments and the existing SDL PDF path. +macOS PDFs now separate unpainted paper from content: paper uses p and content +uses its own coverage, without multiplying that coverage by p. A future shared +scene must carry this paper/content distinction explicitly. Transparent image pixels preserve the destination. Ordinary source-over with source alpha p*a is not equivalent. Any future operation API needs to express this distinction directly and specify sampling and premultiplication. diff --git a/src/builtins.zig b/src/builtins.zig index 1cd10a99..39d70e5d 100644 --- a/src/builtins.zig +++ b/src/builtins.zig @@ -18,6 +18,7 @@ pub const capabilities: config.Runtime.Capabilities = .{ // whatever terminal is on the other end of the serial line. .tagline_font_size = pardes.platform != .tty and pardes.platform != .esp32p4, .window_opacity = pardes.platform == .gui or pardes.platform == .macos, + .window_blur = pardes.platform == .macos, }; pub const Ctx = struct { diff --git a/src/config.zig b/src/config.zig index f91d95c6..440549b3 100644 --- a/src/config.zig +++ b/src/config.zig @@ -102,6 +102,7 @@ pub const leader_path = paths: { } if (pardes.platform == .gui) table.set(.Pet, null); if (builtins.capabilities.window_opacity) table.set(.WindowOpacity, null); + if (builtins.capabilities.window_blur) table.set(.WindowBlur, null); if (builtins.capabilities.panel_transitions) { table.set(.PanelSlide, "as"); table.set(.PanelZoom, "az"); @@ -540,6 +541,7 @@ pub const Runtime = struct { column_tags: bool = true, syntax_bold: bool = false, window_opacity: u8 = 100, + window_blur: u8 = 0, window_opacity_pending: bool = true, pet: enum { off, cat, frog } = .off, @@ -630,6 +632,7 @@ pub const Runtime = struct { scene_shaders: bool, tagline_font_size: bool, window_opacity: bool = false, + window_blur: bool = false, }; pub const Capability = std.meta.FieldEnum(Capabilities); @@ -644,6 +647,7 @@ pub const Runtime = struct { font, tagline_size, window_opacity, + window_blur, transition: layout.Transition, scene: Scene, }; @@ -655,7 +659,7 @@ pub const Runtime = struct { pub fn takesArg(setting: Setting) bool { return switch (setting.action) { - .shell, .theme, .font, .tagline_size, .window_opacity => true, + .shell, .theme, .font, .tagline_size, .window_opacity, .window_blur => true, else => false, }; } @@ -683,6 +687,7 @@ pub const Runtime = struct { .{ .word = "Font", .action = .font, .availability = .font_picker }, .{ .word = "TaglineSize", .action = .tagline_size, .availability = .font_picker }, .{ .word = "WindowOpacity", .action = .window_opacity, .availability = .window_opacity }, + .{ .word = "WindowBlur", .action = .window_blur, .availability = .window_blur }, .{ .word = "PanelSlide", .action = .{ .transition = .slide }, .availability = .panel_transitions }, .{ .word = "PanelZoom", .action = .{ .transition = .zoom }, .availability = .panel_transitions }, .{ .word = "PanelDissolve", .action = .{ .transition = .dissolve }, .availability = .panel_transitions }, @@ -726,6 +731,8 @@ pub const Runtime = struct { @compileError("native font settings must use the font-picker capability"), .window_opacity => if (setting.availability != .window_opacity) @compileError("window opacity must use the window-opacity capability"), + .window_blur => if (setting.availability != .window_blur) + @compileError("window blur must use the window-blur capability"), .transition => if (setting.availability != .panel_transitions) @compileError("panel effects must use the panel-transition capability"), .scene => if (setting.availability != .scene_shaders) @@ -737,8 +744,8 @@ pub const Runtime = struct { for (std.enums.values(Toggle)) |field| if (actionCount(.{ .toggle = field }) != 1) @compileError("runtime toggle must occur exactly once: " ++ @tagName(field)); if (actionCount(.shell) != 1 or actionCount(.theme) != 1 or actionCount(.font) != 1 or - actionCount(.tagline_size) != 1 or actionCount(.window_opacity) != 1) - @compileError("Shell, Theme, Font, TaglineSize, and WindowOpacity actions must each occur exactly once"); + actionCount(.tagline_size) != 1 or actionCount(.window_opacity) != 1 or actionCount(.window_blur) != 1) + @compileError("Shell, Theme, Font, TaglineSize, WindowOpacity, and WindowBlur actions must each occur exactly once"); for (std.enums.values(layout.Transition)) |effect| { const expected: comptime_int = @intFromBool(effect != .off); if (actionCount(.{ .transition = effect }) != expected) @@ -783,6 +790,13 @@ pub const Runtime = struct { state.window_opacity = percent; state.window_opacity_pending = true; }, + .window_blur => { + const text = std.mem.trim(u8, argument orelse return false, " \t\r\n"); + for (text) |byte| if (!std.ascii.isDigit(byte)) return false; + const percent = std.fmt.parseInt(u8, text, 10) catch return false; + if (percent > 100) return false; + state.window_blur = percent; + }, .transition => |effect| state.toggleTransition(effect), .scene => |effect| switch (effect) { inline else => |field| { @@ -849,6 +863,12 @@ pub const Runtime = struct { else try out.print("{s}: unsupported\n", .{setting.word}); }, + .window_blur => { + if (setting.enabled(context.capabilities)) + try out.print("{s}: {d}%\n", .{ setting.word, state.window_blur }) + else + try out.print("{s}: unsupported\n", .{setting.word}); + }, .shell => { const chosen = state.shell.requested.get(); try out.print( @@ -947,7 +967,7 @@ pub const Runtime = struct { for (settings[i + 1 ..]) |later| try std.testing.expect(!std.mem.eql(u8, setting.word, later.word)); try std.testing.expectEqual(switch (setting.action) { - .shell, .theme, .font, .tagline_size, .window_opacity => true, + .shell, .theme, .font, .tagline_size, .window_opacity, .window_blur => true, else => false, }, setting.takesArg()); } @@ -1011,6 +1031,22 @@ pub const Runtime = struct { try std.testing.expect(state.window_opacity_pending); } + test "window blur defaults off and validates without changing opacity" { + const setting = find("WindowBlur").?; + var state: Runtime = .{}; + try std.testing.expectEqual(@as(u8, 0), state.window_blur); + try std.testing.expectEqual(Capability.window_blur, setting.availability.?); + for ([_][]const u8{ "0", " 40\n", "100" }, [_]u8{ 0, 40, 100 }) |argument, expected| { + try std.testing.expect(apply(&state, setting, argument)); + try std.testing.expectEqual(expected, state.window_blur); + try std.testing.expectEqual(@as(u8, 100), state.window_opacity); + } + for ([_]?[]const u8{ null, "", " \t\n", "101", "-1", "+40", "40%", "0.5", "40 20", "4_0", "0x28", "999999999999999" }) |argument| { + try std.testing.expect(!apply(&state, setting, argument)); + try std.testing.expectEqual(@as(u8, 100), state.window_blur); + } + } + test "font request tuple rejects atomically" { var state: Runtime = .{}; try std.testing.expect(requestFont(&state, "/fonts/old.ttf", "Old", 1200)); @@ -1052,6 +1088,7 @@ pub const Runtime = struct { .scene_shaders = true, .tagline_font_size = true, .window_opacity = true, + .window_blur = true, }, .state = &state, }; @@ -1065,6 +1102,7 @@ pub const Runtime = struct { .shell => "fish", .tagline_size => "73", .window_opacity => "85", + .window_blur => "40", else => null, }; try std.testing.expect(apply(&state, setting, argument)); @@ -1086,6 +1124,7 @@ pub const Runtime = struct { .shell => "Shell requested (new panes): fish\n", .tagline_size => "TaglineSize: 73%\n", .window_opacity => "WindowOpacity: 85% (pending)\n", + .window_blur => "WindowBlur: 40%\n", .transition => |transition| switch (transition) { .off => unreachable, .slide => "Panel transition: PanelSlide\n", @@ -1160,6 +1199,8 @@ pub const Runtime = struct { const defaults_report = storage[0..out.end]; try std.testing.expect(std.mem.indexOf(u8, defaults_report, "WindowOpacity: unsupported\n") != null); try std.testing.expect(!find("WindowOpacity").?.enabled(defaults_context.capabilities)); + try std.testing.expect(std.mem.indexOf(u8, defaults_report, "WindowBlur: unsupported\n") != null); + try std.testing.expect(!find("WindowBlur").?.enabled(defaults_context.capabilities)); try std.testing.expect(find("WindowOpacity").?.enabled(context.capabilities)); try std.testing.expect(std.mem.indexOf(u8, defaults_report, "Shell requested (new panes): /bin/sh (default)\n") != null); try std.testing.expect(std.mem.indexOf(u8, defaults_report, "Shell effective (last spawn): (none)\n") != null); diff --git a/src/macos.zig b/src/macos.zig index bbfb8c08..d0d379de 100644 --- a/src/macos.zig +++ b/src/macos.zig @@ -92,6 +92,7 @@ pub const Image = extern struct { iw: u32, ih: u32, rgba: [*]const u8, + paper_bg: u32, }; pub const Runtime = extern struct { @@ -902,6 +903,11 @@ export fn pardes_window_opacity() u8 { return st.core.settings.window_opacity; } +/// Public AppKit backdrop strength, independent of background paint opacity. +export fn pardes_window_blur() u8 { + return if (state) |st| st.core.settings.window_blur else 0; +} + fn taglineFontPercent(core: ?*const pardes.Pardes) u8 { return if (core) |p| p.settings.font.tagline_percent else pardes.config.gui_tagline_font_percent; } @@ -1879,6 +1885,10 @@ fn collectImages(st: *State, surface: *const pardes.Surface) void { .iw = @intCast(place.iw), .ih = @intCast(place.ih), .rgba = place.rgba.ptr, + .paper_bg = if (place.native.paper_bg) |bg| + @as(u32, bg[0]) << 16 | @as(u32, bg[1]) << 8 | bg[2] + else + color_default, }; st.images_len += 1; } @@ -2611,6 +2621,7 @@ test "pardes.h declares every export the way it is defined" { try expectSameAbi(@TypeOf(c.pardes_active_dirty), @TypeOf(pardes_active_dirty)); try expectSameAbi(@TypeOf(c.pardes_theme_bg), @TypeOf(pardes_theme_bg)); try expectSameAbi(@TypeOf(c.pardes_window_opacity), @TypeOf(pardes_window_opacity)); + try expectSameAbi(@TypeOf(c.pardes_window_blur), @TypeOf(pardes_window_blur)); } test "pardes.h matches the Zig boundary" { @@ -2941,3 +2952,21 @@ test "mac tag layer ABI preserves logical capacity and physical grip" { try std.testing.expectEqual(@as(u8, 'G'), canonical[18].text[0]); try std.testing.expectEqual(encodeCell(.{}).len, canonical[10].len); } + +test "mac window blur builtin reaches the ABI without changing opacity" { + try std.testing.expectEqual(@as(u8, 0), pardes_window_blur()); + const gpa = std.testing.allocator; + const core = try pardes.Pardes.init(gpa, .{ .tty_only = true, .cols = 8, .rows = 3 }); + defer core.deinit(); + state = .{ .gpa = gpa, .threaded = undefined, .io = std.testing.io, .core = core, .runtime = .{}, .config_arena = .init(gpa), .prompt_rcs = .{} }; + defer { + state.?.config_arena.deinit(); + state = null; + } + try std.testing.expect(core.executeBuiltinLine(0, "WindowOpacity 71")); + for ([_][]const u8{ "WindowBlur 0", "WindowBlur 40", "WindowBlur 100", "WindowBlur 101", "WindowBlur 0" }, [_]u8{ 0, 40, 100, 100, 0 }) |command, expected| { + try std.testing.expect(core.executeBuiltinLine(0, command)); + try std.testing.expectEqual(expected, pardes_window_blur()); + try std.testing.expectEqual(@as(u8, 71), pardes_window_opacity()); + } +} diff --git a/src/macos/Sources/AppDelegate.swift b/src/macos/Sources/AppDelegate.swift index 4e91e407..cbe9cdc9 100644 --- a/src/macos/Sources/AppDelegate.swift +++ b/src/macos/Sources/AppDelegate.swift @@ -81,8 +81,8 @@ final class AppDelegate: NSObject, NSApplicationDelegate, PardesViewDelegate { // The grid and the blur are SIBLINGS in a plain container, not parent // and child. A transparent theme has to show something through the // grid, and AppKit will not blur what is behind a window unless an - // NSVisualEffectView asks it to — but the backdrop is hidden for every - // theme that brings its own background, and hiding a superview hides + // NSVisualEffectView asks it to. The backdrop can be hidden independently + // when blur is disabled or the ground is opaque; hiding a superview hides // its subviews with it. Nested, an opaque theme drew a blank window. let container = NSView(frame: NSRect(origin: .zero, size: want)) container.autoresizesSubviews = true @@ -460,6 +460,7 @@ final class AppDelegate: NSObject, NSApplicationDelegate, PardesViewDelegate { /// theme whose background happened to equal the view's starting guess /// would otherwise leave the window in AppKit's default clothes forever. private var dressed = false + private var appliedBlur: UInt8 = 0 private func applyTheme() { // Both reads happen every pump, and neither may be short-circuited by @@ -468,15 +469,17 @@ final class AppDelegate: NSObject, NSApplicationDelegate, PardesViewDelegate { // tick would leave one of them unworn. let themeChanged = view.adoptThemeBG(pardes_theme_bg()) let opacityChanged = view.adoptWindowOpacity(pardes_window_opacity()) - guard themeChanged || opacityChanged || !dressed else { return } + let blur = pardes_window_blur() + let blurChanged = blur != appliedBlur + guard themeChanged || opacityChanged || blurChanged || !dressed else { return } + appliedBlur = blur + backdrop.alphaValue = CGFloat(blur) / 100 + backdrop.isHidden = blur == 0 || (view.themeBG != nil && view.backgroundAlpha >= 1) dressed = true - // A ground short of solid needs the same non-opaque window a - // background-less theme does — but not the blur behind it. The backdrop - // answers "this theme brings no background"; WindowOpacity says how - // much of the one it brings to paint, and what shows through the rest - // is the desktop, which is what asking for a translucent window means. + // Opacity paints the theme ground; blur controls the native material + // behind it. An opaque ground hides the backdrop without losing the + // requested strength, so lowering opacity restores the effect. if let rgb = view.themeBG { - backdrop.isHidden = true window.isOpaque = view.backgroundAlpha >= 1 window.backgroundColor = view.backgroundAlpha < 1 ? .clear : NSColor( srgbRed: CGFloat((rgb >> 16) & 0xFF) / 255, @@ -493,10 +496,9 @@ final class AppDelegate: NSObject, NSApplicationDelegate, PardesViewDelegate { window.appearance = NSAppearance(named: luma > 0.5 ? .aqua : .darkAqua) } else { // Transparent: the window stops painting anything of its own and - // the blur takes over. isOpaque false is what lets the desktop + // the optional blur sits behind it. isOpaque false lets the desktop // reach the backdrop at all — a titled window is opaque by default // and would composite over it. - backdrop.isHidden = false window.isOpaque = false window.backgroundColor = .clear window.appearance = NSAppearance(named: .darkAqua) diff --git a/src/macos/Sources/PardesView.swift b/src/macos/Sources/PardesView.swift index 7c537055..7981cf46 100644 --- a/src/macos/Sources/PardesView.swift +++ b/src/macos/Sources/PardesView.swift @@ -1446,6 +1446,7 @@ final class PardesView: NSView { let source: CGRect let body: CGRect let destination: CGRect + let paperBG: UInt32 } /// Rasterized attachments, decoded once each. The bytes the core lends are @@ -1496,7 +1497,7 @@ final class PardesView: NSView { height: CGFloat(place.dst_h) / scale) let frozen = FrozenImage( key: key, image: crop, source: source, - body: body, destination: dst) + body: body, destination: dst, paperBG: place.paper_bg) frameImages.append(frozen) drawFrozenImage(ctx, frozen) } @@ -1545,11 +1546,24 @@ final class PardesView: NSView { ctx.clip(to: placed.body) // isFlipped gives us a y-down CTM and CGImage draws +y up, so flip // about this destination rather than changing the grid arithmetic. + let isPDF = placed.paperBG != UInt32(PARDES_COLOR_DEFAULT) + if isPDF { + fillBackground(ctx, placed.destination, placed.paperBG, backgroundAlpha) + } ctx.translateBy(x: placed.destination.minX, y: placed.destination.maxY) ctx.scaleBy(x: 1, y: -1) ctx.interpolationQuality = .high let rect = CGRect(x: 0, y: 0, width: placed.destination.width, height: placed.destination.height) + if isPDF { + // Paper was painted at WindowOpacity. Content keeps the PDF's own + // coverage, so glyphs, photos and paths stay legible at zero opacity. + ctx.setAlpha(1) + ctx.setBlendMode(.normal) + ctx.draw(placed.image, in: rect) + ctx.restoreGState() + return + } // Match image.frag.glsl/backgroundLayerBlend: source coverage removes // the destination independently of WindowOpacity, then the source is // added at that opacity. Ordinary source-over would compound alpha; diff --git a/src/macos/pardes.h b/src/macos/pardes.h index a2e34f53..df3ba04f 100644 --- a/src/macos/pardes.h +++ b/src/macos/pardes.h @@ -262,6 +262,8 @@ uint32_t pardes_theme_bg(void); // Read it once per pump beside pardes_theme_bg(): reading also acknowledges // whatever `WindowOpacity` asked for. 100 is opaque and is the default. uint8_t pardes_window_opacity(void); +// Backdrop material strength, 0..100; zero disables blur. Not a pixel radius. +uint8_t pardes_window_blur(void); // Pane taglines use this percentage of the current body font size. It is the // embedded default before init and the live core setting afterwards; the host @@ -475,6 +477,8 @@ typedef struct { uint32_t ih; // iw * ih * 4 bytes, RGBA8, borrowed until the next pardes_frame const uint8_t *rgba; + // PDF paper RGB; PARDES_COLOR_DEFAULT means an ordinary image. + uint32_t paper_bg; } pardes_image_s; // This frame's attachments, in paint order. Ask after pardes_frame; both are diff --git a/src/panes.zig b/src/panes.zig index 93abae30..49e5d624 100644 --- a/src/panes.zig +++ b/src/panes.zig @@ -4577,13 +4577,14 @@ pub const Pdf = struct { { const tz_render = tracy.zone(@src(), "pdf.render_into"); defer tz_render.end(); - state.document.renderIntoAt( + state.document.renderIntoAtWithPaper( page, request, shape, want, page_highlights, fresh, + pardes.platform == .macos, ) catch break :filled false; } const tz_tint = tracy.zone(@src(), "pdf.tint"); @@ -5852,6 +5853,10 @@ pub const Pdf = struct { .pan_x = placed.pan_x, .geometry = placed.geometry, .pixel_offset_y = placed.pixel_offset_y, + .paper_bg = if (pardes.platform == .macos) + (if (key.mode == .disabled) .{ 255, 255, 255 } else key.colors.background) + else + null, }, .x = text_x, .y = if (core.settings.tag_bottom) rect.y else rect.y + pardes.BOX_H, diff --git a/src/pardes.zig b/src/pardes.zig index 94f67ced..5c0ac263 100644 --- a/src/pardes.zig +++ b/src/pardes.zig @@ -3593,6 +3593,8 @@ pub const NativePlacement = if (pdf_enabled) struct { geometry: ?image.NativeGeometry = null, /// Subpixel vertical displacement retained from proportional SDL wheel dy. pixel_offset_y: f32 = 0, + /// Separate paper behind straight-alpha PDF content; null for other images. + paper_bg: ?[3]u8 = null, } else struct {}; pub const ImagePlace = struct { diff --git a/src/pdf.zig b/src/pdf.zig index 052d34db..712750dc 100644 --- a/src/pdf.zig +++ b/src/pdf.zig @@ -975,6 +975,20 @@ pub const Document = struct { band: Raster.Band, highlights: []const Highlight, rgba: []u8, + ) !void { + return document.renderIntoAtWithPaper(page, request, raster, band, highlights, rgba, false); + } + + /// Preserve the PDF's content coverage when the host paints paper separately. + pub fn renderIntoAtWithPaper( + document: *Document, + page: usize, + request: RenderRequest, + raster: Raster, + band: Raster.Band, + highlights: []const Highlight, + rgba: []u8, + transparent_paper: bool, ) !void { if (rgba.len != band.len) return error.BadPixmap; if (band.height == 0 or band.y + band.height > raster.height) @@ -999,6 +1013,7 @@ pub const Document = struct { @intCast(raster.stride), @intCast(band.y), @intCast(band.height), + @intFromBool(transparent_paper), ) != c.PARDES_PDF_OK) return error.RenderFailed; } @@ -1832,6 +1847,7 @@ test "RGBA allocation and buffer-validation failures leave the document renderab raw_layout.stride, 0, raw_layout.height, + 0, )); for (scratch) |byte| try std.testing.expectEqual(@as(u8, 0xa5), byte); @@ -2074,3 +2090,35 @@ test "offset crop and rotation keep normalized highlights pixel-aligned" { marked.rgba[left + 1] < 10 and marked.rgba[left + 2] > 240); try std.testing.expectEqualSlices(u8, plain.rgba[right .. right + 4], marked.rgba[right .. right + 4]); } + +test "transparent PDF paper preserves ink and band coverage" { + var document = try Document.open("docs/9p.pdf"); + defer document.deinit(); + const request: RenderRequest = .{ .dpi = 96, .max_dimension = 1200 }; + const raster = try document.measureRenderAt(0, request); + const flattened = try std.testing.allocator.alloc(u8, raster.len); + defer std.testing.allocator.free(flattened); + const content = try std.testing.allocator.alloc(u8, raster.len); + defer std.testing.allocator.free(content); + try document.renderIntoAt(0, request, raster, raster.wholePage(), &.{}, flattened); + try document.renderIntoAtWithPaper(0, request, raster, raster.wholePage(), &.{}, content, true); + var paper: usize = 0; + var ink: usize = 0; + var edges: usize = 0; + for (std.mem.bytesAsSlice([4]u8, content), std.mem.bytesAsSlice([4]u8, flattened)) |pixel, reference| { + const a: u32 = pixel[3]; + paper += @intFromBool(a == 0); + ink += @intFromBool(a == 255); + edges += @intFromBool(a > 0 and a < 255); + for (0..3) |channel| { + const over_white = (a * pixel[channel] + (255 - a) * 255 + 127) / 255; + try std.testing.expect(@abs(@as(i32, @intCast(over_white)) - @as(i32, reference[channel])) <= 2); + } + } + try std.testing.expect(paper > 100 and ink > 100 and edges > 100); + const band = raster.band(raster.height / 3, raster.height / 4); + const rows = try std.testing.allocator.alloc(u8, band.len); + defer std.testing.allocator.free(rows); + try document.renderIntoAtWithPaper(0, request, raster, band, &.{}, rows, true); + try std.testing.expectEqualSlices(u8, content[band.y * raster.stride ..][0..band.len], rows); +} diff --git a/src/pdf_bridge.c b/src/pdf_bridge.c index bdc7b891..976ed838 100644 --- a/src/pdf_bridge.c +++ b/src/pdf_bridge.c @@ -588,7 +588,8 @@ pardes_pdf_render_into( int height, int stride, int band_y, - int band_height) + int band_height, + int transparent_paper) { fz_context *ctx; fz_pixmap *pixmap = NULL; @@ -654,7 +655,8 @@ pardes_pdf_render_into( * paid either way by the glyph spans and the tint pass that walk the * same buffer immediately afterwards. Leave it alone. */ - fz_clear_pixmap_with_value(ctx, pixmap, 0xFF); + if (transparent_paper) fz_clear_pixmap(ctx, pixmap); + else fz_clear_pixmap_with_value(ctx, pixmap, 0xFF); if (document->cached_display_list != NULL || document->display_list_candidate_page_number == page_number) { @@ -719,6 +721,21 @@ pardes_pdf_render_into( return PARDES_PDF_ERROR; } + /* MuPDF draws premultiplied samples. The public RGBA contract and tint + * pass use straight alpha; preserve coverage and undo premultiplication. */ + if (transparent_paper) { + size_t pixel; + for (pixel = 0; pixel < samples_len; pixel += 4) { + unsigned int a = samples[pixel + 3]; + int channel; + if (a == 0 || a == 255) continue; + for (channel = 0; channel < 3; ++channel) { + unsigned int straight = (samples[pixel + channel] * 255u + a / 2) / a; + samples[pixel + channel] = (unsigned char)(straight > 255 ? 255 : straight); + } + } + } + if (document->cached_display_list == NULL) document->display_list_candidate_page_number = page_number; diff --git a/src/pdf_bridge.h b/src/pdf_bridge.h index 8c73f688..cda426aa 100644 --- a/src/pdf_bridge.h +++ b/src/pdf_bridge.h @@ -220,7 +220,8 @@ int pardes_pdf_measure_render( * A full page is the band `(0, height)`. * * MuPDF wraps but never owns or frees samples. Every successful pixel is - * opaque, including the caller-supplied highlights composited onto the page. + * opaque unless transparent_paper is nonzero. That mode preserves content + * coverage and returns straight-alpha RGBA over an unpainted page. * The CTM does not depend on the band, so a band's rows are bit-identical to * the same rows of the whole page: it is a clip, not a different rendering. */ @@ -239,7 +240,8 @@ int pardes_pdf_render_into( int height, int stride, int band_y, - int band_height + int band_height, + int transparent_paper ); int pardes_pdf_page_text( diff --git a/test/macos-snapshots/rendering-parity.golden b/test/macos-snapshots/rendering-parity.golden index 536f6800..cbb56ab2 100644 --- a/test/macos-snapshots/rendering-parity.golden +++ b/test/macos-snapshots/rendering-parity.golden @@ -5,10 +5,10 @@ == backgrounds invalid-stays-0 uniform == context context-100 compact separators verified == context context-71 compact separators verified -== pdf pdf-100 native page opacity verified -== pdf pdf-0 native page opacity verified -== pdf pdf-71 native page opacity verified -== pdf pdf-fit-height native page opacity verified -== pdf pdf-full-tint native page opacity verified -== pdf pdf-original-colors native page opacity verified -== pdf pdf-scrolled native page opacity verified +== pdf pdf-100 paper opacity and opaque ink verified +== pdf pdf-0 paper opacity and opaque ink verified +== pdf pdf-71 paper opacity and opaque ink verified +== pdf pdf-fit-height paper opacity and opaque ink verified +== pdf pdf-full-tint paper opacity and opaque ink verified +== pdf pdf-original-colors paper opacity and opaque ink verified +== pdf pdf-scrolled paper opacity and opaque ink verified diff --git a/test/macos_e2e.swift b/test/macos_e2e.swift index 5427c3ad..5efc366c 100644 --- a/test/macos_e2e.swift +++ b/test/macos_e2e.swift @@ -687,13 +687,22 @@ private final class Driver: PardesViewDelegate { throw ScriptError(message: "PDF: placement is outside its physical-pixel viewport") } let backing = CGFloat(rep.pixelsWide) / view.bounds.width - var matched = 0 - for fraction in [CGFloat(0.2), 0.4, 0.6, 0.8] { - if let c = rep.colorAt(x: Int((x + width * fraction) * backing), - y: Int((y + height * fraction) * backing)), abs(c.alphaComponent - view.backgroundAlpha) < 2.0 / 255 { matched += 1 } + guard image.paper_bg != UInt32(PARDES_COLOR_DEFAULT) else { + throw ScriptError(message: "PDF: missing separate paper background") } - guard matched == 4 else { throw ScriptError(message: "PDF: raster opacity does not match WindowOpacity") } - output += "== pdf \(label) native page opacity verified\n" + var lowest: CGFloat = 1, highest: CGFloat = 0 + for py in stride(from: Int(y * backing) + 2, to: Int((y + height) * backing) - 2, by: 2) { + for px in stride(from: Int(x * backing) + 2, to: Int((x + width) * backing) - 2, by: 2) { + if let c = rep.colorAt(x: px, y: py) { + lowest = min(lowest, c.alphaComponent) + highest = max(highest, c.alphaComponent) + } + } + } + guard abs(lowest - view.backgroundAlpha) < 2.0 / 255, highest > 0.98 else { + throw ScriptError(message: "PDF: expected translucent paper and opaque ink, got alpha \(lowest)...\(highest)") + } + output += "== pdf \(label) paper opacity and opaque ink verified\n" } // MARK: - the script -- cgit v1.3 From c1990b3e6e196ad41379aa432bf3ccca8a65d9f0 Mon Sep 17 00:00:00 2001 From: Gabriel Schneider Date: Sun, 20 Sep 2026 00:36:50 -0300 Subject: Flatten the 9P control tree and move it out of fs.zig The served tree loses the self/ level: /index /ctl /new /log /screen /listeners /pane//... /os, with /src only in -Dembed-sources=true builds (default off, on for esp32p4). ctl speaks the editor's own language with two lowercase verbs, look TEXT and exec TEXT, plus acme's addr verbs; the new/ factory directory becomes one clone file; cons is gone (exec Msg); name and sel are files; stats report real lengths, modes and mtimes; /log streams pane new/del/rename/save events. The tree code lives in src/ninep/ (tree, pane, ctl, addr, pty, events, screen, sources); fs.zig keeps host access, mounts, resolution and find/grep. Same engine and transports. README (fs-help.txt) and docs rewritten; tests updated and extended. Co-Authored-By: Claude Fable 5.1 --- build.zig | 6 +- docs/config.md | 3 +- docs/fs.md | 126 +- docs/v9fs.md | 12 +- src/9p.zig | 2 +- src/9p_io.zig | 39 +- src/CHANGELOG.md | 10 + src/effect_sources.zig | 1 + src/fs-help.txt | 103 +- src/fs.zig | 3594 +------------------------------------------- src/main.zig | 4 +- src/memory.zig | 5 +- src/ninep/addr.zig | 276 ++++ src/ninep/ctl.zig | 503 +++++++ src/ninep/events.zig | 558 +++++++ src/ninep/pane.zig | 840 +++++++++++ src/ninep/pty.zig | 388 +++++ src/ninep/screen.zig | 351 +++++ src/ninep/sources.zig | 152 ++ src/ninep/testing.zig | 135 ++ src/ninep/tree.zig | 850 +++++++++++ src/panes.zig | 7 +- src/pardes.zig | 34 +- src/tutor.txt | 25 +- test/agent_session.py | 14 +- test/appearance_gallery.py | 26 +- test/collapse_layout.py | 8 +- test/column_tags.py | 32 +- test/font_size.py | 2 +- test/fs.py | 367 +++-- test/fs_bench.zig | 43 +- test/fs_namespace.zig | 12 +- test/fs_soak.py | 29 +- test/look_placement.py | 8 +- test/ninep.py | 39 +- test/output.zig | 12 +- test/panes.zig | 8 +- test/pdf_scroll_bench.zig | 18 +- test/snapshot.zig | 2 +- test/tag_cleanup.py | 10 +- test/ui_review.py | 50 +- test/v9fs.py | 33 +- test/v9fs_terminal.py | 6 +- test/window_opacity.py | 12 +- 44 files changed, 4779 insertions(+), 3976 deletions(-) create mode 100644 src/ninep/addr.zig create mode 100644 src/ninep/ctl.zig create mode 100644 src/ninep/events.zig create mode 100644 src/ninep/pane.zig create mode 100644 src/ninep/pty.zig create mode 100644 src/ninep/screen.zig create mode 100644 src/ninep/sources.zig create mode 100644 src/ninep/testing.zig create mode 100644 src/ninep/tree.zig (limited to 'src/pardes.zig') diff --git a/build.zig b/build.zig index aeae7443..6734d9b0 100644 --- a/build.zig +++ b/build.zig @@ -104,6 +104,7 @@ pub fn build(b: *std.Build) void { ninep_options.addOption(bool, "quic", enable_quic); const enable_mupdf = b.option(bool, "mupdf", "native PDF rendering with MuPDF (AGPL/commercial; native default on, web/esp32p4 off; -Dmupdf=false disables)") orelse !freestanding_core; const enable_jpx = b.option(bool, "jpx", "JPEG 2000 in PDFs, for scanned documents (default on; -Djpx=false drops openjpeg)") orelse true; + const embed_sources = b.option(bool, "embed-sources", "serve the editor's own sources under /src of its 9P tree (default off; on for -Dplatform=esp32p4, whose only source is the device)") orelse is_esp32p4; const is_web_target = target.result.cpu.arch == .wasm32 and target.result.os.tag == .freestanding; const is_esp32p4_target = target.result.cpu.arch == .riscv32 and target.result.os.tag == .freestanding; const optimize = if (is_web) @@ -309,6 +310,7 @@ pub fn build(b: *std.Build) void { .esp32p4_rows = esp32p4_rows, .theme_animation = theme_animation, .prebuilt_shaders = prebuilt_shaders, + .embed_sources = embed_sources, .zig_lib_dir = b.graph.zig_lib_directory.path orelse "", .commit = gitCommit(b), }; @@ -600,8 +602,6 @@ pub fn build(b: *std.Build) void { if (shell == .macos) mod.addAnonymousImport("effect-source-crt.ci.metal", .{ .root_source_file = b.path("shaders/crt.ci.metal"), }); - mod.addAnonymousImport("root-build.zig", .{ .root_source_file = b.path("build.zig") }); - mod.addAnonymousImport("root-build.zig.zon", .{ .root_source_file = b.path("build.zig.zon") }); } const gui_shell_mod: ?*std.Build.Module = gui_mod orelse @@ -1435,6 +1435,7 @@ const ShellConfig = struct { /// the default is off for the board and on everywhere else. theme_animation: ?bool, prebuilt_shaders: bool, + embed_sources: bool, zig_lib_dir: []const u8, commit: ?[]const u8, }; @@ -1456,6 +1457,7 @@ fn shellOptions(b: *std.Build, cfg: ShellConfig, platform: Platform) *std.Build. // prevents Config/EffectCode from describing tty/macOS/web as "prebuilt". o.addOption(bool, "gui_shader_sources_prebuilt", platform == .gui and cfg.prebuilt_shaders); o.addOption([]const u8, "zls_version", if (cfg.zls_backend) zls_version else "none"); + o.addOption(bool, "embed_sources", cfg.embed_sources); o.addOption([]const u8, "version", zon.version); // ...and the commit it was built from, when there is one. See `gitCommit` // for why this is optional and why it is read at configure time. diff --git a/docs/config.md b/docs/config.md index 972f9403..a55aef1c 100644 --- a/docs/config.md +++ b/docs/config.md @@ -496,7 +496,8 @@ palette; Ripple and Glitch primarily perturb sample coordinates. `EffectCode PanelAscii` or `EffectCode Crt` lists the current backend's build-embedded source paths under `/virtual`. Look opens each full file; -no checkout is needed. TTY exposes grid transitions, native GUI builds also +no checkout is needed, but the build must carry them (`-Dembed-sources=true`, +the default only for esp32p4); otherwise the command reports them unavailable. TTY exposes grid transitions, native GUI builds also expose scene shaders, and web has neither. Shared implementations share paths. SDL reports whether GLSL was compiled during this build or came from the `-Dprebuilt-shaders` snapshot paired with the committed SPIR-V. diff --git a/docs/fs.md b/docs/fs.md index 942a26a3..c16f810b 100644 --- a/docs/fs.md +++ b/docs/fs.md @@ -16,9 +16,13 @@ Explicit paths bypass that search: | Editor path | Meaning | 9P server path | |---|---|---| | `/n/os/proc/self` | OS filesystem | `/os/proc/self` | -| `/n/self/pane/2/body` | pane 2's text | `/self/pane/2/body` | -| `/virtual/src/pardes.zig` | source embedded in this build | `/self/src/pardes.zig` | -| `/n/peer/self/pane/2/body` | another session's text | peer's `/self/pane/2/body` | +| `/n/self/pane/2/body` | pane 2's text | `/pane/2/body` | +| `/virtual/pane/2/body` | the same, in the editor's own spelling | `/pane/2/body` | +| `/virtual/src/pardes.zig` | source embedded in this build | `/src/pardes.zig` | +| `/n/peer/pane/2/body` | another session's text | peer's `/pane/2/body` | + +The mount name `self` is reserved and maps to the server root, so `/n/self/X` +and `/virtual/X` both name the served `/X`. `--mount=peer=work` mounts the named session `work`; the dial can also be an absolute socket path, `unix!/path`, `tcp!IP!port`, or `quic!IP!port`. @@ -31,7 +35,7 @@ pending Save. Mounts are saved in dumps. Save uses the file's original mount. socket. Build with `-Dquic=true` and system OpenSSL 3.6+ to enable QUIC; `--9p-quic='quic!127.0.0.1!5641'` adds its listener. Both accept numeric IPv4/IPv6 addresses, not DNS names. Listener port zero chooses a free port; -`/self/listeners` reports all active dial addresses. +`/listeners` reports all active dial addresses. All connections have session access, including `os`. TCP is unencrypted. QUIC uses an ephemeral TLS identity without peer verification or login. @@ -40,56 +44,108 @@ The four application connection slots are shared across transports; OpenSSL's internal buffers are separate, dynamically allocated memory. [Plan9port's client](https://9fans.github.io/plan9port/man/man1/9p.html) can -drive Unix or TCP without a kernel mount: +drive Unix or TCP without a kernel mount, and `9ns` mounts the tree in a +private namespace: ```sh -9p -n -a "unix!$PARDES_9P" read self/index -9p -n -a 'tcp!127.0.0.1!5640' read self/index +9p -n -a "unix!$PARDES_9P" read index +9p -n -a 'tcp!127.0.0.1!5640' ls pane/1 +9ns --unix "$PARDES_9P" -- sh -c 'cat "$NINE_MOUNT/index"' ``` For [Linux v9fs](https://www.kernel.org/doc/html/latest/filesystems/9p.html), use `version=9p2000,cache=none,access=any` and `trans=unix`, or `trans=tcp` with `port=5640`. Set `uname`, `dfltuid`, and `dfltgid` for the local user. -Leave `aname` empty: the mount root contains `os` and `self`. The opt-in +Leave `aname` empty. The opt-in [Linux v9fs experiment](v9fs.md) tests a kernel mount in a separate subprocess namespace (`zig build v9fs-test`, requiring explicit mount authorization). Neither 9P2000.u nor 9P2000.L is implemented. Existing Plan9port/v9fs clients need a userspace bridge for QUIC. -The server root contains `os` and `self`. Under `self`, `index` lists panes, -`README` explains the interface. `new/` lists its creation endpoints and another -`README`; listing, walking and statting entries do not create panes. Opening -`new/ctl` creates a pane and returns its serial, and `pane/` contains -`body`, `tag`, `ctl`, `addr`, `data`, `event`, and selection files. Terminal -panes additionally have `pty/{ctl,status,data}`. - -`EffectCode ` lists the current backend's embedded implementation -files under `/virtual`; Look opens their full source. - -`self/screen` returns JSON with `cols`, `rows`, `cursor`, a `styles` table, -and row-major `cells` of `[grapheme, style_index]`. Each open freezes one -frame until close, including across multiple reads. The independent client -can inspect it directly with `Client(socket_path).screen()`. - -A terminal `body` freezes its history on the first read of each open handle; -later reads use the same bytes while output continues. Close and reopen for -newer history, or read `pty/data` for the live stream. Screen and terminal-body -snapshots share 32 handle slots, released on close or disconnect. - -Writing `body` appends; opening it with truncation replaces its contents. -`addr` selects a range and `data` replaces that range. `ctl` accepts `name`, -`look `, `get`, `put`, `del`, and `delete`. Look resolves from that pane -without editing its body or tag. Holding `event` open redirects the pane's Look +## The served tree + +``` +/README this guide, also src/fs-help.txt +/index one line per pane: serial, kind (text|term|pdf|image), dirty flag, name +/ctl write: one command per line; read: the serials the last command made or touched +/new reading it creates one empty pane and answers "\n" (the /net/tcp/clone idiom) +/log one line per editor event: new|del|rename|save ; reads park +/screen rendered screen JSON; frozen per open handle +/listeners the session's dial addresses +/pane// name body tag ctl addr data xdata sel errors event, plus pty/{ctl,status,data} +/os/ the host filesystem +/src/ the editor's embedded sources, only when built with -Dembed-sources=true +``` + +Nothing in the tree is created by list, stat, walk or read, except that +reading `/new` makes a pane; that is its whole purpose, so a recursive read +of the tree makes one pane per open of it. + +`/ctl` and `/pane//ctl` take the editor's own command language, two verbs: + +- `look TEXT` is a right click on `TEXT`: a path opens a file, `file:12` jumps + to a line, a directory opens a shell there, a URL opens in the browser. From + `/ctl` the look happens at the active pane; from a pane's `ctl` at that pane. +- `exec TEXT` is a middle click: a command word from `src/builtins.zig` + (`Save`, `Del`, `New`, `Newcol`, `Mount NAME DIAL`, `Unmount NAME`, `Dump`, + `Restore`, `Msg TEXT`, `Find`, `Grep`, `Tty`, ...), or anything else, which + runs in the pane's terminal. + +Both verbs are lowercase; the words after `exec` are the editor's capitalized +commands. A pane's `ctl` also keeps acme's addr verbs (`addr=dot`, `dot=addr`, +`limit=addr`, `clean`, `dirty`, `cleartag`, `get`, `mark`, `nomark`, +`noscroll`, `scroll`, `show`). Every line of a write is checked before any +line runs; a malformed line fails the write with EINVAL. A command that fails +inside the editor is reported on the message row, not as a write error. + +After a write to either `ctl`, reading `/ctl` answers the serials of the panes +the command created, or, when it created none, the pane a look focused or the +pane an exec acted on (even one it closed), one per line. Before any command it answers `pid`, `version` and `panes` lines. + +`/pane//name` reads the pane's file name (a terminal's directory) and +writing it renames the buffer; a relative name resolves against the pane's +directory. `sel` reads the editor selection and writing it replaces the +selection. `body` appends on write and replaces on truncating open. `addr` +selects a range and `data` or `xdata` read or replace it. `errors` appends to +the directory's `+Errors` pane. Holding `event` open redirects the pane's Look and Exec clicks to that client; writing a record back performs the action. +Stats report real lengths for `index`, `ctl`, `name`, `body`, `tag` and `sel`, +modes 0644/0666 (0444 for read-only files, 0222 for write-only), the pane's +last edit time or the process start as mtime, and stable qids. Directory +entries carry no sizes; stat the entry. + +`/log` records `new`, `del`, `rename` and `save` while at least one client +holds it open; a read parks until a record arrives. `/screen` returns JSON with +`cols`, `rows`, `cursor`, a `styles` table, and row-major `cells` of +`[grapheme, style_index]`. Each open freezes one frame until close. A +terminal `body` freezes its history on the first read of each open handle; +`pty/data` streams live output. Screen and terminal-body snapshots share 32 +handle slots, released on close or disconnect. + +`-Dembed-sources=true` embeds the editor's sources and serves them under +`/src` (and `/shaders` on GUI builds). `EffectCode ` lists the current +backend's implementation files under `/virtual`, which Look opens; without the +option the command reports the sources as unavailable. The esp32p4 build +enables the option by default, so the device can serve its own source. + This is a control filesystem, not a complete POSIX export. Native filenames may contain up to 255 bytes. Existing regular OS files support read, write, and truncation to zero; protocol create, remove, rename, and other metadata -changes are refused. Ownership, permissions, and timestamps are synthetic. +changes are refused. Ownership and permissions under `/os` are synthetic. Zero-length truncation accepts the accompanying `mtime` hint sent by Linux v9fs; the hint is not stored. Standalone timestamp changes remain refused. +The tree lives in `src/ninep/`: `tree.zig` (nodes, lookup, readdir, dispatch, +the backend contract), `pane.zig` (pane files), `ctl.zig`, `addr.zig`, +`pty.zig`, `events.zig` (event and log streams), `screen.zig` and +`sources.zig`. The protocol engine is `src/9p.zig`, the transports +`src/9p_io.zig`; `src/fs.zig` keeps host access, mounts, resolution, find and +grep. + `zig build fs-test` drives real sessions using the independent Python client -in `test/ninep.py`. `zig build 9p-test` checks the freestanding wire protocol; -`zig build fs-bench` measures filesystem transactions in the core. +in `test/ninep.py`; `zig build fs-discovery-test` checks that browsing creates +nothing and that `new`, `ctl`, `name`, `sel` and `log` behave. `zig build +9p-test` checks the freestanding wire protocol; `zig build fs-bench` measures +filesystem transactions in the core. `zig build fs-test quic-test -Dquic=true` also exercises QUIC mounts and I/O. diff --git a/docs/v9fs.md b/docs/v9fs.md index 51b35a46..6cb4e998 100644 --- a/docs/v9fs.md +++ b/docs/v9fs.md @@ -8,11 +8,11 @@ your configured shell as your normal user, with your account's supplementary groups. The shell receives `PARDES_MOUNT`, the absolute mountpoint: ```sh -ls "$PARDES_MOUNT/self/pane" -cat "$PARDES_MOUNT/self/index" -cat "$PARDES_MOUNT/self/README" -ls -l "$PARDES_MOUNT/self/new" -cat "$PARDES_MOUNT/self/pane/$PARDES_PANE/body" +ls "$PARDES_MOUNT/pane" +cat "$PARDES_MOUNT/index" +cat "$PARDES_MOUNT/README" +cat "$PARDES_MOUNT/pane/$PARDES_PANE/body" +echo 'exec Msg hello' > "$PARDES_MOUNT/ctl" ``` The mount belongs to that pane's subprocess tree. Other panes and the editor @@ -96,7 +96,7 @@ unprivileged and uses `sudo -n`, retaining the calling terminal's authorization. Missing authorization or kernel support fails the test instead of skipping it. It checks mount isolation, privilege dropping, inherited access, directory refresh, body reads and truncation, independent wire updates, addressed edits, -shell redirection to ctl, Exec dispatch, rendered screen JSON, and OS-file reads. +shell redirection to name, Exec dispatch, rendered screen JSON, and OS-file reads. Linux follows `O_TRUNC` with a `Twstat` carrying zero length and an `mtime` hint. Pardes accepts this truncation without storing caller-selected timestamps; diff --git a/src/9p.zig b/src/9p.zig index 2948b9ed..3cffbffc 100644 --- a/src/9p.zig +++ b/src/9p.zig @@ -894,7 +894,7 @@ pub fn Server(comptime fs: type, comptime fid_capacity: usize) type { .qid = qidOf(if (a.node != 0) a.node else f.node, a.dir), .mode = (if (a.dir) dmdir else 0) | @as(u32, a.mode), .atime = 0, - .mtime = 0, + .mtime = if (@hasField(@TypeOf(a), "mtime")) a.mtime else 0, .length = a.size, .name = f.name[0..f.name_len], .uid = who, diff --git a/src/9p_io.zig b/src/9p_io.zig index 943561eb..d0db1c86 100644 --- a/src/9p_io.zig +++ b/src/9p_io.zig @@ -138,7 +138,7 @@ fn localIp(address: std.Io.net.IpAddress) bool { return false; } -const Srv = ninep.Server(pardes.filesystem, ninep.max_fids); +const Srv = ninep.Server(pardes.ctlfs, ninep.max_fids); const Conn = struct { fd: c_int = -1, @@ -149,7 +149,7 @@ const Conn = struct { in: [msize]u8 = undefined, out: [2 * msize]u8 = undefined, - fn step(c: *Conn, core: *pardes.Pardes, req: pardes.filesystem.Req) void { + fn step(c: *Conn, core: *pardes.Pardes, req: pardes.ctlfs.Req) void { core.update(.{ .fs_req = req }); var answered = false; while (core.nextEffect()) |effect| { @@ -160,7 +160,7 @@ const Conn = struct { } else core.perform(effect); } if (!answered) { - const reply = pardes.filesystem.Reply.fail(req.tag, pardes.filesystem.E.IO); + const reply = pardes.ctlfs.Reply.fail(req.tag, pardes.ctlfs.E.IO); c.srv.reply(&reply, ""); } } @@ -226,7 +226,7 @@ pub const Listener = struct { c.srv = .init(.{ .in = &c.in, .out = &c.out, - .root = pardes.filesystem.namespace_root, + .root = pardes.ctlfs.root, }); } } @@ -246,7 +246,7 @@ pub const Listener = struct { c.quic = connection; c.draining = false; c.accepted_ms = nowMs(); - c.srv = .init(.{ .in = &c.in, .out = &c.out, .root = pardes.filesystem.namespace_root }); + c.srv = .init(.{ .in = &c.in, .out = &c.out, .root = pardes.ctlfs.root }); }; } } @@ -748,17 +748,17 @@ test "Unix TCP and QUIC share one listener through reads writes reconnects and r defer testing.allocator.free(before); try testing.expectEqualStrings(w.expected, before); try testing.expectError(error.FileTooLarge, Client.readLimit(testing.allocator, w.dial, w.body_path, w.body_path, w.expected.len - 1)); - const listing = try Client.readLimit(testing.allocator, w.dial, "/self/pane", "/self/pane", 128); + const listing = try Client.readLimit(testing.allocator, w.dial, "/pane", "/pane", 128); defer testing.allocator.free(listing); - const exact_listing = try Client.readLimit(testing.allocator, w.dial, "/self/pane", "/self/pane", listing.len); + const exact_listing = try Client.readLimit(testing.allocator, w.dial, "/pane", "/pane", listing.len); defer testing.allocator.free(exact_listing); try testing.expectEqualStrings(listing, exact_listing); - try testing.expectError(error.FileTooLarge, Client.readLimit(testing.allocator, w.dial, "/self/pane", "/self/pane", listing.len - 1)); + try testing.expectError(error.FileTooLarge, Client.readLimit(testing.allocator, w.dial, "/pane", "/pane", listing.len - 1)); try Client.write(testing.allocator, w.dial, w.body_path, w.replacement); const after = try Client.read(testing.allocator, w.dial, w.body_path, w.body_path); defer testing.allocator.free(after); try testing.expectEqualStrings(w.replacement, after); - const screen = try Client.read(testing.allocator, w.dial, "/self/screen", "/self/screen"); + const screen = try Client.read(testing.allocator, w.dial, "/screen", "/screen"); defer testing.allocator.free(screen); const parsed = try std.json.parseFromSlice(struct { cols: u16, rows: u16 }, testing.allocator, screen, .{ .ignore_unknown_fields = true }); defer parsed.deinit(); @@ -790,7 +790,7 @@ test "Unix TCP and QUIC share one listener through reads writes reconnects and r var dial_buf: [64]u8 = undefined; const network_dial = try std.fmt.bufPrint(&dial_buf, "{s}!{s}!{d}", .{ protocol, host, port }); var body_buf: [64]u8 = undefined; - const body = try std.fmt.bufPrint(&body_buf, "/self/pane/{d}/body", .{pane.serial}); + const body = try std.fmt.bufPrint(&body_buf, "/pane/{d}/body", .{pane.serial}); for ([_][]const u8{ network_dial, l.path(), network_dial }, 0..) |dial, attempt| { var worker: Worker = .{ .dial = dial, .body_path = body, .expected = if (attempt == 0) "initial\n" else replacement, .replacement = replacement }; const thread = try std.Thread.spawn(.{}, Worker.run, .{&worker}); @@ -1245,15 +1245,14 @@ pub const Client = struct { test "a path becomes walk elements, normalised the way a shell would" { var out: [max_depth][]const u8 = undefined; - try testing.expectEqual(@as(usize, 4), try elements("/self/pane/1/body", &out)); - try testing.expectEqualStrings("self", out[0]); - try testing.expectEqualStrings("pane", out[1]); - try testing.expectEqualStrings("1", out[2]); - try testing.expectEqualStrings("body", out[3]); + try testing.expectEqual(@as(usize, 3), try elements("/pane/1/body", &out)); + try testing.expectEqualStrings("pane", out[0]); + try testing.expectEqualStrings("1", out[1]); + try testing.expectEqualStrings("body", out[2]); - try testing.expectEqual(@as(usize, 4), try elements("self/pane/1/body", &out)); - try testing.expectEqual(@as(usize, 4), try elements("//self//pane//1//body//", &out)); - try testing.expectEqual(@as(usize, 2), try elements("/self/index", &out)); + try testing.expectEqual(@as(usize, 3), try elements("pane/1/body", &out)); + try testing.expectEqual(@as(usize, 3), try elements("//pane//1//body//", &out)); + try testing.expectEqual(@as(usize, 1), try elements("/index", &out)); try testing.expectEqual(@as(usize, 0), try elements("/", &out)); @@ -1284,12 +1283,12 @@ pub const Client = struct { test "a dial with nothing listening is one error and not a wait" { if (comptime !supported) return error.SkipZigTest; var names: [max_depth][]const u8 = undefined; - const n = try elements("/self/pane/1/body", &names); + const n = try elements("/pane/1/body", &names); var remote: RemoteError = .{}; const before = nowMs(); try testing.expectError( Error.Dial, - fetchBytes(testing.allocator, .{ .unix = "/tmp/pardes-9p-no-such-socket.sock" }, names[0..n], &remote, null, "/self/pane/1/body", limits.max_file_bytes), + fetchBytes(testing.allocator, .{ .unix = "/tmp/pardes-9p-no-such-socket.sock" }, names[0..n], &remote, null, "/pane/1/body", limits.max_file_bytes), ); try testing.expect(nowMs() - before < budget_ms); } diff --git a/src/CHANGELOG.md b/src/CHANGELOG.md index 015f726b..18bcceb9 100644 --- a/src/CHANGELOG.md +++ b/src/CHANGELOG.md @@ -2,6 +2,16 @@ ## 0.0.3 +- Flatten the 9P control tree: `self/` is gone, so `/index`, `/pane//`, + `/screen` and `/os` sit at the root. `/new` is one clone file (reading it + makes a pane and answers its serial), `/ctl` takes `look TEXT` and + `exec TEXT` in the editor's own command language and answers the serials a + command touched, `/log` streams pane events, and each pane gains `name` and + `sel` (replacing `rdsel`/`wrsel`); `cons`, `new/` and the `name`, `put`, + `del` and `delete` ctl verbs are gone in favour of `name` and `exec`. Stats + carry real lengths, modes and mtimes. Sources are served under `/src` only + with `-Dembed-sources=true`. The tree code moved from `src/fs.zig` to + `src/ninep/`. - Add pinned tree-sitter declaration context, with optional compact tagline styling and separators between discontinuous source lines. - Configure search and LSP result context with `LocationsConfig`. Results use diff --git a/src/effect_sources.zig b/src/effect_sources.zig index 3ca15c3f..08680860 100644 --- a/src/effect_sources.zig +++ b/src/effect_sources.zig @@ -79,6 +79,7 @@ pub fn forSetting(setting: config.Runtime.Setting) ?[]const []const u8 { } test "EffectCode paths resolve uniquely to this backend's archived inputs" { + if (!@import("memory.zig").limits.embedded_sources) return error.SkipZigTest; for (config.Runtime.settings) |setting| { const available = switch (setting.action) { .transition => backend == .tty or backend == .gui or backend == .macos, diff --git a/src/fs-help.txt b/src/fs-help.txt index eeb000cc..a0a84b28 100644 --- a/src/fs-help.txt +++ b/src/fs-help.txt @@ -1,65 +1,42 @@ Pardes control filesystem ========================= -The mount root contains self/ (this editor) and os/ (host files). -This guide is available as self/README and self/new/README. -Examples below run inside a Tty9p shell, where PARDES_MOUNT is set. - -Explore -------- - ls "$PARDES_MOUNT/self" - cat "$PARDES_MOUNT/self/index" - ls -l "$PARDES_MOUNT/self/new" - ls "$PARDES_MOUNT/self/pane" - -index lists panes: serial, tag length, body length, reserved zero, -modified flag, then tag text. Use the serial in self/pane//. -screen is rendered screen JSON; listeners lists the session addresses. -cons accepts text to display in the editor. - -Create a pane -------------- -new/ lists the same files as a scratch pane, plus this README. -Listing, walking and statting these paths do not create anything. -OPENING any file except README creates one scratch pane below the active pane. -Each open creates a separate pane, even if you open the same path again. - - cat "$PARDES_MOUNT/self/new/ctl" - -This creates a pane and prints its control information, beginning with its -serial. Use self/pane// for all subsequent operations on that pane. -To create a pane and write its initial text in one operation: - - printf 'Hello from the shell\n' > "$PARDES_MOUNT/self/new/body" - -Reading all files recursively would open factories and create panes. -Use ls or stat to inspect them; read README for this guide. - -Work with an existing pane --------------------------- -Replace with a number from index or new/ctl: - - cat "$PARDES_MOUNT/self/pane//body" - printf 'Replacement text\n' > "$PARDES_MOUNT/self/pane//body" - printf 'More text\n' >> "$PARDES_MOUNT/self/pane//body" - printf 'name notes.txt\n' > "$PARDES_MOUNT/self/pane//ctl" - -body buffer text; for terminals, reads history and writes child input - tag editable pane tag - ctl control information on read; newline-separated commands on write - addr address range; write #0,#5 to select the first five bytes - data read from addr onward, or replace the range selected by addr - xdata read only the range selected by addr; writes replace that range - rdsel read the editor selection - wrsel replace the editor selection - errors write diagnostics - event pane interaction events; opening intercepts Look/Exec events - -Common ctl commands: name PATH, put (save), get (reload), dot=addr, -addr=dot, look PATH, del (close, refusing dirty text), delete (force close). -Reload and force close can discard unsaved changes. - -Terminal panes also expose pty/ctl, pty/status and pty/data. -Writing pty/data sends terminal input; use carriage return to submit a command. -Reading pty/data streams new output; read body for a history snapshot. - -Embedded source files under self/src/ document the complete interface. +README this guide +index one line per pane: serial, kind (text|term|pdf|image), dirty flag, name +ctl write commands; read the serials the last command made or touched +new reading it creates one empty pane and answers its serial +log one line per editor event (new/del/rename/save ); reads wait +screen rendered screen as JSON, frozen from open to close +listeners the session's dial addresses +pane// name body tag ctl addr data xdata sel errors event, and pty/ for terminals +os/ the host filesystem +src/ the editor's own sources, only in a -Dembed-sources=true build + +Commands, on /ctl (applied at the active pane) or on pane//ctl (at that pane): + look TEXT a right click: open a file, a file:12 location, a directory, a URL + exec TEXT a middle click: an editor command word (Save Del New Newcol Mount Unmount + Dump Restore Msg Find Grep Tty ...), or a shell command for the pane's terminal +Below, $m is the mount point (PARDES_MOUNT in a Tty9p shell; 9ns and 9p work too): + + cat $m/index which panes exist + n=$(cat $m/new) make a pane, remember its serial + echo 'look /etc/hosts:3' > $m/ctl; cat $m/ctl open a file, see the pane it went to + printf 'text\n' > $m/pane/$n/body append to a pane (>| truncates first) + cat $m/pane/$n/name; echo notes.txt > $m/pane/$n/name read, then rename + echo 'exec Save' > $m/pane/$n/ctl save it (exec Del closes it) + echo 'exec Msg hello' > $m/ctl show text in the editor + echo '#0,#5' > $m/pane/$n/addr; echo NEW > $m/pane/$n/data replace bytes 0..5 + echo 'dot=addr' > $m/pane/$n/ctl; cat $m/pane/$n/sel select the range, read it + cat $m/log block until a pane is made, renamed, saved or closed + cat $m/pane/$n/event hold it open to own that pane's clicks + echo 'exec' > $m/pane/$n/pty/ctl restart a shell; also winsize C R, sig INT + +Pitfalls, one each: + Every open of new makes another pane, so `cat $m/new` twice makes two. + ls, stat and find create nothing; reading log, event or pty/data blocks until something happens. + exec Del closes a pane even when it is dirty; index shows the dirty flag first. + look and exec are lowercase verbs; the words after exec are the editor's capitalized commands. + ctl also takes acme's addr verbs (addr=dot dot=addr limit=addr clean dirty get show ...), one per line. + Writing body appends; open it with truncation to replace; writes are whole UTF-8 sequences. + A terminal's body is a history snapshot frozen per open; pty/data is the live stream. + screen is frozen per open handle as well; reopen it for a fresh frame. + A command that fails is reported in the editor, not as a write error; a malformed line fails the write. diff --git a/src/fs.zig b/src/fs.zig index 4fe32347..7f416440 100644 --- a/src/fs.zig +++ b/src/fs.zig @@ -9,6 +9,22 @@ const panes = @import("panes.zig"); const mvzr = @import("mvzr"); const modal = @import("modal.zig"); const look = @import("look.zig"); +pub const tree = @import("ninep/tree.zig"); +const sources_fs = @import("ninep/sources.zig"); +const th = @import("ninep/testing.zig"); + +const Pardes = pardes.Pardes; +const MAX_PANES = pardes.MAX_PANES; +const Req = tree.Req; +const Reply = tree.Reply; +const E = tree.E; + +/// The served README; tree.zig answers it. +pub const help = @embedFile("fs-help.txt"); + +/// Host filesystem nodes: the root, and one hashed node per path a client walked to. +pub const os_root: u64 = (1 << 63) + 2; +pub const os_node: u64 = 1 << 62; pub const name_capacity: usize = 255; @@ -18,8 +34,6 @@ pub const sources: []const Source = if (limits.embedded_sources) else &.{}; const source_files = [_]Source{ - .{ .path = "build.zig", .contents = @embedFile("root-build.zig") }, - .{ .path = "build.zig.zon", .contents = @embedFile("root-build.zig.zon") }, .{ .path = "src/pardes.zig", .contents = @embedFile("pardes.zig") }, .{ .path = "src/panes.zig", .contents = @embedFile("panes.zig") }, .{ .path = "src/layout.zig", .contents = @embedFile("layout.zig") }, @@ -86,101 +100,6 @@ pub const Mount = struct { name: []const u8, dial: []const u8 }; pub const max_mounts = 8; pub const Resolved = struct { path: []const u8, dir: bool = false }; pub const OsPath = struct { node: u64, path: []const u8 }; -pub const archive_node: u64 = 1 << 61; - -pub fn archiveNode(path: []const u8) ?u64 { - if (path.len == 0) return archive_node; - if (path.len >= 4096) return null; - for (sources, 0..) |source, i| { - if (std.mem.eql(u8, source.path, path) or - (source.path.len > path.len and source.path[path.len] == '/' and std.mem.startsWith(u8, source.path, path))) - return archive_node | (@as(u64, i) << 12) | path.len; - } - return null; -} - -fn archiveInfo(node: u64) ?struct { path: []const u8, contents: []const u8, dir: bool } { - if (node == archive_node) return .{ .path = "", .contents = "", .dir = true }; - const index = (node & ~archive_node) >> 12; - if (index >= sources.len) return null; - const source = sources[@intCast(index)]; - const len: usize = @intCast(node & 4095); - if (len > source.path.len) return null; - return .{ .path = source.path[0..len], .contents = source.contents, .dir = len < source.path.len }; -} - -pub fn stageArchive(p: *pardes.Pardes, out: *std.ArrayList(u8), path: []const u8, skip: *u64) void { - var seen: [sources.len][]const u8 = undefined; - var count: usize = 0; - for (sources, 0..) |source, i| { - if (path.len != 0 and - (source.path.len <= path.len or source.path[path.len] != '/' or !std.mem.startsWith(u8, source.path, path))) continue; - const start = if (path.len == 0) 0 else path.len + 1; - const rest = source.path[start..]; - const len = std.mem.indexOfScalar(u8, rest, '/') orelse rest.len; - const name = rest[0..len]; - var duplicate = false; - for (seen[0..count]) |previous| if (std.mem.eql(u8, name, previous)) { - duplicate = true; - break; - }; - if (duplicate) continue; - seen[count] = name; - count += 1; - if (skip.* > 0) { - skip.* -= 1; - continue; - } - const node = archive_node | (@as(u64, i) << 12) | (start + len); - stageDirent(out, p.gpa, node, len < rest.len, name); - } -} - -pub fn archiveHandle(p: *pardes.Pardes, req: Req) Reply { - const info = archiveInfo(req.node) orelse return Reply.fail(req.tag, E.NOENT); - const attr: Reply.Attr = .{ - .node = req.node, - .name = std.fs.path.basename(info.path), - .dir = info.dir, - .size = if (info.dir) 0 else info.contents.len, - .mode = if (info.dir) 0o500 else 0o400, - }; - switch (req.op) { - .getattr => return .{ .tag = req.tag, .attr = attr }, - .open => return .{ .tag = req.tag, .handle = 1 }, - .release => return .{ .tag = req.tag }, - .lookup => { - if (!info.dir) return Reply.fail(req.tag, E.NOTDIR); - if (std.mem.eql(u8, req.data, "..")) { - const parent = std.fs.path.dirname(info.path) orelse ""; - if (parent.len == 0) return handle(p, .{ .tag = req.tag, .op = .getattr, .node = @intFromEnum(SelfFile.root) }); - const node = archiveNode(parent) orelse return Reply.fail(req.tag, E.NOENT); - return archiveHandle(p, .{ .tag = req.tag, .op = .getattr, .node = node }); - } - if (req.data.len == 0 or std.mem.indexOfAny(u8, req.data, "/\x00") != null) return Reply.fail(req.tag, E.NOENT); - var buf: [4096]u8 = undefined; - const path = if (info.path.len == 0) req.data else std.fmt.bufPrint(&buf, "{s}/{s}", .{ info.path, req.data }) catch return Reply.fail(req.tag, E.NOENT); - const node = archiveNode(path) orelse return Reply.fail(req.tag, E.NOENT); - return archiveHandle(p, .{ .tag = req.tag, .op = .getattr, .node = node }); - }, - .readdir => { - if (!info.dir) return Reply.fail(req.tag, E.NOTDIR); - const out = p.fs.stage(p.gpa); - var skip = req.off; - stageArchive(p, out, info.path, &skip); - return .{ .tag = req.tag, .payload = .{ .staged = @intCast(out.items.len) } }; - }, - .read => { - if (info.dir) return Reply.fail(req.tag, E.PERM); - const off: usize = @intCast(@min(req.off, info.contents.len)); - const bytes = info.contents[off..][0..@min(req.size, info.contents.len - off)]; - const out = p.fs.stage(p.gpa); - out.appendSlice(p.gpa, bytes) catch return Reply.fail(req.tag, E.NOMEM); - return .{ .tag = req.tag, .payload = .{ .staged = @intCast(bytes.len) } }; - }, - else => return Reply.fail(req.tag, E.PERM), - } -} fn osPath(p: *pardes.Pardes, node: u64) ?[]const u8 { if (node == os_root) return "/"; @@ -208,7 +127,7 @@ pub fn osHandle(p: *pardes.Pardes, req: Req) Reply { if (req.op == .release) return .{ .tag = req.tag }; const io = std.Io.Threaded.global_single_threaded.io(); const stat = std.Io.Dir.cwd().statFile(io, path, .{}) catch return Reply.fail(req.tag, E.NOENT); - const attr: Reply.Attr = .{ .name = if (req.node == os_root) "os" else std.fs.path.basename(path), .node = req.node, .dir = stat.kind == .directory, .size = stat.size, .mode = if (stat.kind == .directory) 0o500 else 0o600 }; + const attr: Reply.Attr = .{ .name = if (req.node == os_root) "os" else std.fs.path.basename(path), .node = req.node, .dir = stat.kind == .directory, .size = stat.size, .mode = if (stat.kind == .directory) 0o755 else 0o644, .mtime = std.math.cast(u32, stat.mtime.toSeconds()) orelse 0 }; switch (req.op) { .getattr => return .{ .tag = req.tag, .attr = attr }, .open => { @@ -218,7 +137,7 @@ pub fn osHandle(p: *pardes.Pardes, req: Req) Reply { .lookup => { if (stat.kind != .directory) return Reply.fail(req.tag, E.NOTDIR); if (req.node == os_root and std.mem.eql(u8, req.data, "..")) - return handle(p, .{ .tag = req.tag, .op = .getattr, .node = namespace_root }); + return tree.handle(p, .{ .tag = req.tag, .op = .getattr, .node = tree.root }); if (req.data.len == 0 or std.mem.indexOfAny(u8, req.data, "/\x00") != null) return Reply.fail(req.tag, E.NOENT); var buf: [4096]u8 = undefined; const joined = std.fmt.bufPrint(&buf, "{s}/{s}", .{ std.mem.trimEnd(u8, path, "/"), req.data }) catch return Reply.fail(req.tag, E.NOENT); @@ -244,7 +163,7 @@ pub fn osHandle(p: *pardes.Pardes, req: Req) Reply { continue; } const node = if (std.mem.eql(u8, normalized.path, "/")) os_root else os_node | (std.hash.Wyhash.hash(0, normalized.path) & (os_node - 1)); - stageDirent(out, p.gpa, node, child.kind == .directory, entry.name); + tree.stageDirent(out, p.gpa, node, child.kind == .directory, entry.name); if (out.items.len >= @max(req.size, 512)) break; } return .{ .tag = req.tag, .payload = .{ .staged = @intCast(out.items.len) } }; @@ -362,10 +281,16 @@ test "virtual writes enforce permissions even when contents are empty" { const p = try pardes.Pardes.init(std.testing.allocator, .{ .tty_only = true }); defer p.deinit(); for ([_][]const u8{ "", "bytes" }) |bytes| { - for ([_][]const u8{ "/virtual/index", "/virtual/screen", "/virtual/src/fs.zig", "/n/self/src/fs.zig" }) |path| + for ([_][]const u8{ "/virtual/index", "/virtual/screen", "/virtual/README", "/n/self/log" }) |path| try std.testing.expectError(error.ReadOnlyFilesystem, write(p, path, bytes)); - try std.testing.expectError(error.IsDirectory, write(p, "/virtual/src", bytes)); + try std.testing.expectError(error.IsDirectory, write(p, "/virtual/pane", bytes)); try std.testing.expectError(error.FileNotFound, write(p, "/virtual/missing", bytes)); + try std.testing.expectError(error.FileNotFound, write(p, "/virtual/cons", bytes)); + if (limits.embedded_sources) { + for ([_][]const u8{ "/virtual/src/fs.zig", "/n/self/src/fs.zig" }) |path| + try std.testing.expectError(error.ReadOnlyFilesystem, write(p, path, bytes)); + try std.testing.expectError(error.IsDirectory, write(p, "/virtual/src", bytes)); + } else try std.testing.expectError(error.FileNotFound, write(p, "/virtual/src/fs.zig", bytes)); } for (p.fs.snapshots) |snapshot| try std.testing.expect(snapshot.node == 0); } @@ -385,8 +310,8 @@ test "direct self reads and writes use the same dot paths as Look" { try std.testing.expectEqualStrings(pane.file.?.content, bytes); var resolved: [4096]u8 = undefined; const canonical = resolve(p, path, "/", &resolved).?; - try std.testing.expectEqual(resolveSelf(p, canonical.path[9..]), resolveSelf(p, path[root.len..])); - try std.testing.expectEqual(@as(?u64, @intFromEnum(SelfFile.root)), resolveSelf(p, "./pane/../../")); + try std.testing.expectEqual(tree.resolveSelf(p, canonical.path[9..]), tree.resolveSelf(p, path[root.len..])); + try std.testing.expectEqual(@as(?u64, tree.root), tree.resolveSelf(p, "./pane/../../")); const index_path = try std.fmt.bufPrint(&path_buf, "{s}/./pane/../index", .{root}); try std.testing.expectError(error.ReadOnlyFilesystem, write(p, index_path, "")); const index = try read(p, index_path); @@ -397,7 +322,7 @@ test "direct self reads and writes use the same dot paths as Look" { @memcpy(overlong[0..9], "/virtual/"); var resolved: [4096]u8 = undefined; try std.testing.expect(resolve(p, &overlong, "/", &resolved) == null); - try std.testing.expect(resolveSelf(p, overlong[9..]) == null); + try std.testing.expect(tree.resolveSelf(p, overlong[9..]) == null); try std.testing.expectError(error.FileNotFound, write(p, &overlong, "")); } @@ -462,8 +387,8 @@ test "bounded reads apply the same limits to self bodies and embedded sources" { contents[contents.len - 1] = '\n'; for ([_][]const u8{ &contents, "" }) |expected| { const pane = try p.setTestFile(expected); - for ([_][]const u8{ "/virtual", "/n/self", "/n/own/self" }) |prefix| { - if (!platform_has_fs and std.mem.eql(u8, prefix, "/n/own/self")) continue; + for ([_][]const u8{ "/virtual", "/n/self", "/n/own" }) |prefix| { + if (!platform_has_fs and std.mem.eql(u8, prefix, "/n/own")) continue; var path_buf: [128]u8 = undefined; const path = try std.fmt.bufPrint(&path_buf, "{s}/pane/{d}/body", .{ prefix, pane.serial }); const bytes = try readLimit(p, path, expected.len); @@ -478,7 +403,7 @@ test "bounded reads apply the same limits to self bodies and embedded sources" { } if (limits.embedded_sources) { const source = findEmbeddedSource("src/look.zig", false).?; - for ([_][]const u8{ "/virtual/src/look.zig", "/n/self/src/look.zig", "/n/own/self/src/look.zig" }) |path| { + for ([_][]const u8{ "/virtual/src/look.zig", "/n/self/src/look.zig", "/n/own/src/look.zig" }) |path| { if (!platform_has_fs and std.mem.startsWith(u8, path, "/n/own/")) continue; const bytes = try readLimit(p, path, source.contents.len); defer gpa.free(bytes); @@ -498,7 +423,7 @@ test "bounded reads count rendered directory paths and unknown self lengths" { defer p.deinit(); p.fs.socket_path = "/tmp/pardes-limited-in-process.sock"; try p.fs.mount(gpa, "own", p.fs.socket_path); - for ([_][]const u8{ "/n", "/virtual", "/n/self", "/n/own", "/n/own/self", "/virtual/listeners" }) |path| { + for ([_][]const u8{ "/n", "/virtual", "/n/self", "/n/own", "/n/own/pane", "/virtual/listeners", "/virtual/README" }) |path| { if (!platform_has_fs and std.mem.startsWith(u8, path, "/n/own")) continue; const expected = try read(p, path); defer gpa.free(expected); @@ -515,10 +440,10 @@ test "bounded reads count rendered directory paths and unknown self lengths" { test "bounded reads release terminal snapshots after success and size refusal" { if (!pardes.terminal_panes) return error.SkipZigTest; const gpa = std.testing.allocator; - const p = try withTerm(gpa); + const p = try th.withTerm(gpa); defer p.deinit(); var path_buf: [128]u8 = undefined; - const path = try std.fmt.bufPrint(&path_buf, "/virtual/pane/{d}/body", .{serialOf(p)}); + const path = try std.fmt.bufPrint(&path_buf, "/virtual/pane/{d}/body", .{th.serialOf(p)}); const empty = try readLimit(p, path, 0); defer gpa.free(empty); try std.testing.expectEqual(@as(usize, 0), empty.len); @@ -626,9 +551,9 @@ test "virtual body writes can read their input from the same pane" { const p = try pardes.Pardes.init(std.testing.allocator, .{ .tty_only = true }); defer p.deinit(); const pane = try p.setTestFile("same pane contents\n"); - const event_node = Node.of(pane.serial, .event); - _ = handle(p, .{ .tag = 0, .op = .open, .node = event_node }); - defer _ = handle(p, .{ .tag = 0, .op = .release, .node = event_node }); + const event_node = tree.Node.of(pane.serial, .event); + _ = tree.handle(p, .{ .tag = 0, .op = .open, .node = event_node }); + defer _ = tree.handle(p, .{ .tag = 0, .op = .release, .node = event_node }); var path_buffer: [64]u8 = undefined; const path = try std.fmt.bufPrint(&path_buffer, "/virtual/pane/{d}/body", .{pane.serial}); try write(p, path, pane.file.?.content); @@ -654,11 +579,10 @@ test "same-core mount directories preserve their mount prefix across reads" { try p.fs.mount(gpa, "own", socket_path); const roots = try read(p, "/n/own"); defer gpa.free(roots); - try std.testing.expectEqualStrings("/n/own/os/\n/n/own/self/\n", roots); - const self = try read(p, "/n/own/self"); - defer gpa.free(self); - try std.testing.expect(std.mem.indexOf(u8, self, "/n/own/self/index\n") != null); - try std.testing.expectError(error.NotADirectory, read(p, "/n/own/self/index/..")); + try std.testing.expect(std.mem.startsWith(u8, roots, "/n/own/README\n/n/own/index\n")); + try std.testing.expect(std.mem.indexOf(u8, roots, "/n/own/pane/\n/n/own/os/\n") != null); + try std.testing.expectError(error.NotADirectory, read(p, "/n/own/index/..")); + try std.testing.expectError(error.FileNotFound, read(p, "/n/own/self/index")); var tmp = std.testing.tmpDir(.{}); defer tmp.cleanup(); @@ -767,11 +691,11 @@ pub fn resolveOs(path: []const u8, out: *[4096]u8) ?Resolved { fn resolveVirtual(p: ?*pardes.Pardes, path: []const u8, out: *[4096]u8) ?Resolved { var normalized_buf: [4096]u8 = undefined; const normalized = normalizeVirtualPath(path, &normalized_buf) orelse return null; - if (p) |core| if (resolveSelf(core, normalized) != null) + if (p) |core| if (tree.resolveSelf(core, normalized) != null) return .{ .path = std.fmt.bufPrint(out, "/virtual/{s}", .{normalized}) catch return null }; if (findEmbeddedSource(normalized, false)) |source| return .{ .path = std.fmt.bufPrint(out, "/virtual/{s}", .{source.path}) catch return null }; - if (archiveNode(normalized) != null) + if (sources_fs.node(normalized) != null) return .{ .path = std.fmt.bufPrint(out, "/virtual/{s}", .{normalized}) catch return null }; return null; } @@ -793,7 +717,7 @@ pub fn readLimit(p: *pardes.Pardes, path: []const u8, max_bytes: usize) ![]u8 { } return out.toOwnedSlice(); } - if (std.mem.eql(u8, path, "/virtual")) return readNode(p, @intFromEnum(SelfFile.root), path, limit); + if (std.mem.eql(u8, path, "/virtual")) return readNode(p, tree.root, path, limit); if (std.mem.startsWith(u8, path, "/n/")) { const explicit = path[3..]; const cut = std.mem.indexOfScalar(u8, explicit, '/') orelse explicit.len; @@ -812,7 +736,7 @@ pub fn readLimit(p: *pardes.Pardes, path: []const u8, max_bytes: usize) ![]u8 { return readNode(p, node, path, limit); } if (std.mem.eql(u8, name, "self")) { - const node = resolveSelf(p, remote_path) orelse return error.FileNotFound; + const node = tree.resolveSelf(p, remote_path) orelse return error.FileNotFound; return readNode(p, node, path, limit); } for (p.fs.mounts.items) |mount| { @@ -823,13 +747,13 @@ pub fn readLimit(p: *pardes.Pardes, path: []const u8, max_bytes: usize) ![]u8 { for (p.fs.os_paths.items[saved_paths..]) |temporary| p.gpa.free(temporary.path); p.fs.os_paths.shrinkRetainingCapacity(saved_paths); } - var node = namespace_root; + var node = tree.root; var directory = true; var parts = std.mem.tokenizeScalar(u8, remote_path, '/'); while (parts.next()) |part| { if (!directory) return error.NotADirectory; if (std.mem.eql(u8, part, ".")) continue; - const reply = handle(p, .{ .tag = 0, .op = .lookup, .node = node, .data = part }); + const reply = tree.handle(p, .{ .tag = 0, .op = .lookup, .node = node, .data = part }); if (reply.status != .ok) return error.FileNotFound; node = reply.attr.node; directory = reply.attr.dir; @@ -842,14 +766,14 @@ pub fn readLimit(p: *pardes.Pardes, path: []const u8, max_bytes: usize) ![]u8 { } if (std.mem.startsWith(u8, path, "/virtual/")) { const name = path[9..]; - if (resolveSelf(p, name)) |node| return readNode(p, node, path, limit); + if (tree.resolveSelf(p, name)) |node| return readNode(p, node, path, limit); } return readFileLimit(p.gpa, path, limit); } fn readNode(p: *pardes.Pardes, initial_node: u64, path: []const u8, limit: usize) ![]u8 { var node = initial_node; - const attr = handle(p, .{ .tag = 0, .op = .getattr, .node = node }); + const attr = tree.handle(p, .{ .tag = 0, .op = .getattr, .node = node }); if (attr.status != .ok) return error.FileNotFound; if (attr.attr.dir) { var out: std.Io.Writer.Allocating = .init(p.gpa); @@ -858,7 +782,7 @@ fn readNode(p: *pardes.Pardes, initial_node: u64, path: []const u8, limit: usize const max_bytes = @min(limit, limits.max_stream_bytes); const prefix = std.mem.trimEnd(u8, path, "/"); while (true) { - const reply = handle(p, .{ .tag = 0, .op = .readdir, .node = node, .off = index, .size = 8192 }); + const reply = tree.handle(p, .{ .tag = 0, .op = .readdir, .node = node, .off = index, .size = 8192 }); if (reply.status != .ok) return error.ReadFailed; const entries = p.fsPayload(reply); if (entries.len == 0) return out.toOwnedSlice(); @@ -878,15 +802,15 @@ fn readNode(p: *pardes.Pardes, initial_node: u64, path: []const u8, limit: usize } } if (attr.attr.size > limit) return error.FileTooLarge; - const opened = handle(p, .{ .tag = 0, .op = .open, .node = node }); + const opened = tree.handle(p, .{ .tag = 0, .op = .open, .node = node }); if (opened.status != .ok) return error.OpenFailed; if (opened.attr.node != 0) node = opened.attr.node; - defer _ = handle(p, .{ .tag = 0, .op = .release, .node = node, .handle = opened.handle }); + defer _ = tree.handle(p, .{ .tag = 0, .op = .release, .node = node, .handle = opened.handle }); var out: std.Io.Writer.Allocating = .init(p.gpa); errdefer out.deinit(); while (true) { const want: u32 = @intCast(@min(8192, limit + 1 - out.written().len)); - const reply = handle(p, .{ .tag = 0, .op = .read, .node = node, .handle = opened.handle, .off = out.written().len, .size = want }); + const reply = tree.handle(p, .{ .tag = 0, .op = .read, .node = node, .handle = opened.handle, .off = out.written().len, .size = want }); if (reply.status == .again) return error.NotAFile; if (reply.status != .ok) return error.ReadFailed; const bytes = p.fsPayload(reply); @@ -923,27 +847,27 @@ pub fn write(p: *pardes.Pardes, path: []const u8, bytes: []const u8) !void { } } if (self_path) |name| { - var node = resolveSelf(p, name) orelse return error.FileNotFound; - const attributes = handle(p, .{ .tag = 0, .op = .getattr, .node = node }); + var node = tree.resolveSelf(p, name) orelse return error.FileNotFound; + const attributes = tree.handle(p, .{ .tag = 0, .op = .getattr, .node = node }); if (attributes.status != .ok) return error.FileNotFound; if (attributes.attr.dir) return error.IsDirectory; if (attributes.attr.mode & 0o200 == 0) return error.ReadOnlyFilesystem; - const opened = handle(p, .{ .tag = 0, .op = .open, .node = node }); + const opened = tree.handle(p, .{ .tag = 0, .op = .open, .node = node }); if (opened.status != .ok) return error.OpenFailed; if (opened.attr.node != 0) node = opened.attr.node; - defer _ = handle(p, .{ .tag = 0, .op = .release, .node = node, .handle = opened.handle }); + defer _ = tree.handle(p, .{ .tag = 0, .op = .release, .node = node, .handle = opened.handle }); var preserved: ?[]u8 = null; defer if (preserved) |copy| p.gpa.free(copy); - const target = Node.target(node); + const target = tree.Node.target(node); if (target != null and target.? == .pane and target.?.pane.file == .body) { preserved = try p.gpa.dupe(u8, bytes); - const trunc = handle(p, .{ .tag = 0, .op = .setattr, .node = node, .truncate = true }); + const trunc = tree.handle(p, .{ .tag = 0, .op = .setattr, .node = node, .truncate = true }); if (trunc.status != .ok) return error.WriteFailed; } const contents = preserved orelse bytes; var off: usize = 0; while (off < contents.len) { - const reply = handle(p, .{ .tag = 0, .op = .write, .node = node, .off = off, .data = contents[off..] }); + const reply = tree.handle(p, .{ .tag = 0, .op = .write, .node = node, .off = off, .data = contents[off..] }); if (reply.status != .ok or reply.written == 0) return error.WriteFailed; off += reply.written; } @@ -964,7 +888,7 @@ fn resolveEmbedded(word: []const u8, cwd: []const u8, scratch: *[4096]u8) ?Sourc return findEmbeddedSource(normalized_word, false); } -fn normalizeVirtualPath(path: []const u8, out: *[4096]u8) ?[]const u8 { +pub fn normalizeVirtualPath(path: []const u8, out: *[4096]u8) ?[]const u8 { if (std.mem.indexOfScalar(u8, path, 0) != null) return null; var len: usize = 0; var parts = std.mem.tokenizeAny(u8, path, "/\\"); @@ -1322,361 +1246,6 @@ fn readFileLimit(gpa: std.mem.Allocator, path: []const u8, limit: usize) ![]u8 { return buf; } -const Pardes = pardes.Pardes; -const Pane = pardes.Pane; -const MAX_PANES = pardes.MAX_PANES; - -pub const namespace_root: u64 = 1 << 63; -pub const namespace_panes: u64 = namespace_root + 1; -pub const os_root: u64 = namespace_root + 2; -pub const os_node: u64 = 1 << 62; -const factory_base: u64 = namespace_root + 256; -const fs_help = @embedFile("fs-help.txt"); - -pub fn resolveSelf(p: *Pardes, path: []const u8) ?u64 { - var path_buf: [4096]u8 = undefined; - const normalized = normalizeVirtualPath(path, &path_buf) orelse return null; - var parts = std.mem.tokenizeScalar(u8, normalized, '/'); - const first = parts.next() orelse return @intFromEnum(SelfFile.root); - if (!std.mem.eql(u8, first, "pane")) { - const top = topFileNamed(first) orelse return archiveNode(normalized); - if (parts.next()) |name| { - if (top != .new or parts.next() != null) return null; - if (std.mem.eql(u8, name, "README")) return @intFromEnum(SelfFile.README); - const file = paneFileNamed(name) orelse return null; - if (file.inPty()) return null; - return factory_base + @intFromEnum(file); - } - return @intFromEnum(top); - } - const serial = serialNamed(parts.next() orelse return namespace_panes) orelse return null; - const id = p.paneBySerial(serial) orelse return null; - const file = paneFileNamed(parts.next() orelse return Node.of(serial, .dir)) orelse return null; - if (file.inPty() and !p.panes[id].?.isTerminal()) return null; - if (parts.next()) |name| { - if (file != .pty) return null; - const child = ptyFileNamed(name) orelse return null; - if (parts.next() != null) return null; - return Node.of(serial, child); - } - return Node.of(serial, file); -} - -fn namespace(p: *Pardes, req: Req) Reply { - switch (req.op) { - .getattr => return .{ .tag = req.tag, .attr = .{ .node = req.node, .dir = true, .mode = 0o500 } }, - .open => return .{ .tag = req.tag, .handle = 1 }, - .release => return .{ .tag = req.tag }, - .lookup => { - if (std.mem.eql(u8, req.data, "..")) return handle(p, .{ - .tag = req.tag, - .op = .getattr, - .node = if (req.node == namespace_root) namespace_root else @intFromEnum(SelfFile.root), - }); - if (req.node == namespace_root) { - if (std.mem.eql(u8, req.data, "self")) return handle(p, .{ .tag = req.tag, .op = .getattr, .node = @intFromEnum(SelfFile.root) }); - if (std.mem.eql(u8, req.data, "os")) return handle(p, .{ .tag = req.tag, .op = .getattr, .node = os_root }); - } else { - const serial = serialNamed(req.data) orelse return Reply.fail(req.tag, E.NOENT); - if (serial == 0) return Reply.fail(req.tag, E.NOENT); - return handle(p, .{ .tag = req.tag, .op = .getattr, .node = Node.of(serial, .dir) }); - } - return Reply.fail(req.tag, E.NOENT); - }, - .readdir => { - const out = p.fs.stage(p.gpa); - var skip = req.off; - if (req.node == namespace_root) { - if (skip == 0) stageDirent(out, p.gpa, os_root, true, "os") else skip -= 1; - if (skip == 0) stageDirent(out, p.gpa, @intFromEnum(SelfFile.root), true, "self"); - } else { - var last: u32 = 0; - while (nextSerialAfter(p, last)) |serial| { - last = serial; - if (skip > 0) { - skip -= 1; - continue; - } - var buf: [16]u8 = undefined; - const name = std.fmt.bufPrint(&buf, "{d}", .{serial}) catch unreachable; - stageDirent(out, p.gpa, Node.of(serial, .dir), true, name); - } - } - return .{ .tag = req.tag, .payload = .{ .staged = @intCast(out.items.len) } }; - }, - else => return Reply.fail(req.tag, E.PERM), - } -} - -pub const Op = enum(u8) { - lookup, - getattr, - setattr, - open, - read, - write, - release, - readdir, -}; - -pub const Status = enum(u8) { - ok, - again, - err, -}; - -pub const Req = struct { - tag: u64, - op: Op, - node: u64, - handle: u32 = 0, - off: u64 = 0, - size: u32 = 0, - data: []const u8 = &.{}, - truncate: bool = false, - - pub fn changesPane(req: Req) bool { - return switch (req.op) { - .write, .setattr => true, - .lookup => false, - .open => req.node >= factory_base and req.node < factory_base + 16, - .getattr, .read, .release, .readdir => false, - }; - } -}; - -pub const Reply = struct { - tag: u64, - status: Status = .ok, - errno: u16 = 0, - attr: Attr = .{}, - handle: u32 = 0, - payload: Payload = .none, - written: u32 = 0, - - pub const Attr = struct { - name: []const u8 = "", - node: u64 = 0, - dir: bool = false, - size: u64 = 0, - mode: u16 = 0o600, - }; - - pub const Payload = union(enum) { - none, - staged: u32, - region: struct { pane: u8, serial: u32, off: u32, len: u32 }, - }; - - pub fn fail(tag: u64, e: u16) Reply { - return .{ .tag = tag, .status = .err, .errno = e }; - } -}; - -pub const E = struct { - pub const PERM: u16 = 1; - pub const NOENT: u16 = 2; - pub const IO: u16 = 5; - pub const NOMEM: u16 = 12; - pub const NOTDIR: u16 = 20; - pub const INVAL: u16 = 22; - pub const NFILE: u16 = 23; - pub const NOSPC: u16 = 28; - pub const NOSYS: u16 = 38; -}; - -pub const PaneFile = enum(u4) { - dir = 0, - addr, - body, - ctl, - data, - errors, - event, - tag, - xdata, - rdsel, - wrsel, - pty, - pty_ctl, - pty_status, - pty_data, - - pub fn name(f: PaneFile) []const u8 { - return switch (f) { - .dir => ".", - .pty_ctl => "ctl", - .pty_status => "status", - .pty_data => "data", - else => @tagName(f), - }; - } - - pub fn mode(f: PaneFile) u16 { - return switch (f) { - .dir, .pty => 0o500, - .errors, .wrsel, .pty_ctl => 0o200, - .rdsel, .pty_status => 0o400, - else => 0o600, - }; - } - - pub fn isDir(f: PaneFile) bool { - return f == .dir or f == .pty; - } - - pub fn inPty(f: PaneFile) bool { - return switch (f) { - .pty, .pty_ctl, .pty_status, .pty_data => true, - else => false, - }; - } -}; - -pub const SelfFile = enum(u4) { - root = 1, - index = 2, - cons = 3, - new = 4, - screen = 5, - listeners = 6, - README = 7, - - pub fn name(f: SelfFile) []const u8 { - return if (f == .root) "." else @tagName(f); - } - - pub fn mode(f: SelfFile) u16 { - return switch (f) { - .root, .new => 0o500, - .index, .screen, .listeners, .README => 0o400, - .cons => 0o200, - }; - } - - pub fn dir(f: SelfFile) bool { - return f == .root or f == .new; - } -}; - -pub const Node = packed struct(u64) { - file: u4 = 0, - serial: u60 = 0, - - pub fn of(serial: u32, file: PaneFile) u64 { - std.debug.assert(serial != 0); - return @bitCast(Node{ .file = @intFromEnum(file), .serial = serial }); - } - - pub fn target(node: u64) ?Target { - const n: Node = @bitCast(node); - if (n.serial == 0) { - return .{ .top = std.enums.fromInt(SelfFile, n.file) orelse return null }; - } - return .{ .pane = .{ - .serial = std.math.cast(u32, n.serial) orelse return null, - .file = std.enums.fromInt(PaneFile, n.file) orelse return null, - } }; - } -}; - -pub const Target = union(enum) { - top: SelfFile, - pane: struct { serial: u32, file: PaneFile }, -}; - -pub const out_reserve = 4 * 1024; - -pub const queue_cap = 64 * 1024; - -pub const Queue = struct { - buf: std.ArrayList(u8) = .empty, - head: usize = 0, - - pub fn deinit(q: *Queue, gpa: std.mem.Allocator) void { - q.buf.deinit(gpa); - q.head = 0; - } - - pub fn push(q: *Queue, gpa: std.mem.Allocator, record: []const u8) void { - if (record.len > std.math.maxInt(u32)) return; - while (q.buf.items.len - q.head + record.len + 4 > queue_cap) { - if (q.peek() == null) return; - q.pop(); - } - q.compact(); - var head: [4]u8 = undefined; - std.mem.writeInt(u32, &head, @intCast(record.len), .little); - q.buf.appendSlice(gpa, &head) catch return; - q.buf.appendSlice(gpa, record) catch { - q.buf.shrinkRetainingCapacity(q.buf.items.len - 4); - return; - }; - } - - pub fn peek(q: *const Queue) ?[]const u8 { - const rest = q.buf.items[@min(q.head, q.buf.items.len)..]; - if (rest.len < 4) return null; - const len = std.mem.readInt(u32, rest[0..4], .little); - if (rest.len < 4 + len) return null; - return rest[4 .. 4 + len]; - } - - pub fn pop(q: *Queue) void { - const record = q.peek() orelse return; - q.head += 4 + record.len; - if (q.head == q.buf.items.len) { - q.buf.clearRetainingCapacity(); - q.head = 0; - } - } - - pub fn popFront(q: *Queue, n: usize) void { - const record = q.peek() orelse return; - if (n >= record.len) return q.pop(); - q.head += n; - std.mem.writeInt(u32, q.buf.items[q.head..][0..4], @intCast(record.len - n), .little); - } - - fn compact(q: *Queue) void { - if (q.head == 0 or q.head * 2 < q.buf.items.len) return; - const rest = q.buf.items.len - q.head; - std.mem.copyForwards(u8, q.buf.items[0..rest], q.buf.items[q.head..]); - q.buf.shrinkRetainingCapacity(rest); - q.head = 0; - } - - pub fn empty(q: *const Queue) bool { - return q.peek() == null; - } - - pub fn clearAndFree(q: *Queue, gpa: std.mem.Allocator) void { - q.buf.clearAndFree(gpa); - q.head = 0; - } -}; - -pub const PaneState = struct { - addr: Range = .{}, - limit: ?Range = null, - readers: u16 = 0, - events: Queue = .{}, - nomark: bool = false, - noscroll: bool = false, - tag_snap: std.ArrayList(u8) = .empty, - pty_readers: u16 = 0, - pty_out: Queue = .{}, - - pub const Range = struct { q0: u32 = 0, q1: u32 = 0 }; - - fn deinit(pf: *PaneState, gpa: std.mem.Allocator) void { - pf.events.deinit(gpa); - pf.pty_out.deinit(gpa); - pf.tag_snap.deinit(gpa); - pf.* = .{}; - } -}; - pub const Namespace = struct { socket_path: []const u8 = "", tcp_address: ?std.Io.net.IpAddress = null, @@ -1684,11 +1253,20 @@ pub const Namespace = struct { mounts: std.ArrayList(Mount) = .empty, node_name: [16]u8 = undefined, os_paths: std.ArrayList(OsPath) = .empty, - snapshots: [32]struct { node: u64 = 0, bytes: ?[]const u8 = null } = @splat(.{}), + snapshots: [tree.screen.snapshot_slots]tree.screen.Snapshot = @splat(.{}), out: std.ArrayList(u8) = .empty, - panes: [MAX_PANES]PaneState = @splat(.{}), + panes: [MAX_PANES]tree.pane.State = @splat(.{}), listeners: u16 = 0, origin: u8 = 'K', + /// The editor-wide event stream, recorded only while /log is held open. + log: tree.events.Queue = .{}, + log_readers: u16 = 0, + /// What the last ctl command created or touched, answered by reading /ctl. + results: [MAX_PANES]u32 = undefined, + results_len: u8 = 0, + results_valid: bool = false, + /// Process start, the mtime of everything that has no edit time of its own. + started: u32 = 0, pub fn deinit(st: *Namespace, gpa: std.mem.Allocator) void { for (st.mounts.items) |entry| { @@ -1700,6 +1278,7 @@ pub const Namespace = struct { st.os_paths.deinit(gpa); for (st.snapshots) |snapshot| if (snapshot.bytes) |bytes| gpa.free(bytes); for (&st.panes) |*pf| pf.deinit(gpa); + st.log.deinit(gpa); st.out.deinit(gpa); } @@ -1718,7 +1297,7 @@ pub const Namespace = struct { pub fn stage(st: *Namespace, gpa: std.mem.Allocator) *std.ArrayList(u8) { st.out.clearRetainingCapacity(); - st.out.ensureTotalCapacity(gpa, out_reserve) catch {}; + st.out.ensureTotalCapacity(gpa, tree.out_reserve) catch {}; return &st.out; } @@ -1764,3023 +1343,6 @@ pub fn unmount(p: *Pardes, name: []const u8) !void { return error.NotMounted; } -pub const max_record_text = 256; - -pub const Action = enum(u8) { - body_delete = 'D', - tag_delete = 'd', - body_insert = 'I', - tag_insert = 'i', - body_look = 'L', - tag_look = 'l', - body_exec = 'X', - tag_exec = 'x', - - pub fn char(a: Action) u8 { - return @intFromEnum(a); - } - - pub fn fromChar(c: u8) ?Action { - return std.enums.fromInt(Action, c); - } - - pub fn onTag(a: Action) bool { - return @intFromEnum(a) >= 'a'; - } -}; - -pub const flag_builtin: u32 = 1; -pub const flag_expansion: u32 = 2; -pub const flag_filename: u32 = 4; -pub const flag_chorded: u32 = 8; - -pub fn formatRecord( - buf: []u8, - origin: u8, - action: Action, - q0: u32, - q1: u32, - flag: u32, - text: []const u8, -) []const u8 { - const sent = if (text.len >= max_record_text) text[0..0] else text; - return std.fmt.bufPrint(buf, "{c}{c}{d} {d} {d} {d} {s}\n", .{ - origin, - action.char(), - q0, - q1, - flag, - sent.len, - sent, - }) catch buf[0..0]; -} - -pub const Span = struct { at: u32, removed: u32, inserted: u32 }; - -pub fn diffSpan(old: []const u8, new: []const u8) Span { - const both = @min(old.len, new.len); - const stride = 64; - var head: usize = 0; - while (head + stride <= both and - std.mem.eql(u8, old[head..][0..stride], new[head..][0..stride])) head += stride; - while (head < both and old[head] == new[head]) head += 1; - var tail: usize = 0; - const rest = both - head; - while (tail + stride <= rest and std.mem.eql( - u8, - old[old.len - tail - stride ..][0..stride], - new[new.len - tail - stride ..][0..stride], - )) tail += stride; - while (tail < rest and old[old.len - 1 - tail] == new[new.len - 1 - tail]) tail += 1; - return .{ - .at = @intCast(head), - .removed = @intCast(old.len - tail - head), - .inserted = @intCast(new.len - tail - head), - }; -} - -pub fn noteReplace(p: *Pardes, id: usize, on_tag: bool, old: []const u8, new: []const u8) void { - if (!p.fs.scripted(id)) return; - const span = diffSpan(old, new); - if (span.removed == 0 and span.inserted == 0) return; - if (span.removed > 0) _ = noteAction( - p, - id, - if (on_tag) .tag_delete else .body_delete, - span.at, - span.at + span.removed, - 0, - "", - ); - if (span.inserted > 0) _ = noteAction( - p, - id, - if (on_tag) .tag_insert else .body_insert, - span.at, - span.at + span.inserted, - 0, - new[span.at..][0..span.inserted], - ); -} - -pub fn noteAction( - p: *Pardes, - id: usize, - action: Action, - q0: u32, - q1: u32, - flag: u32, - text: []const u8, -) bool { - if (!p.fs.scripted(id)) return false; - var buf: [max_record_text + 64]u8 = undefined; - const record = formatRecord(&buf, p.fs.origin, action, q0, q1, flag, text); - p.fs.panes[id].events.push(p.gpa, record); - return true; -} - -pub fn notePtyOutput(p: *Pardes, id: usize, bytes: []const u8) void { - if (id >= MAX_PANES or bytes.len == 0) return; - const pf = &p.fs.panes[id]; - if (pf.pty_readers == 0) return; - var off: usize = 0; - while (off < bytes.len) { - const n = @min(bytes.len - off, queue_cap / 2); - pf.pty_out.push(p.gpa, bytes[off..][0..n]); - off += n; - } -} - -pub fn handle(p: *Pardes, req: Req) Reply { - if (req.node >= factory_base and req.node < factory_base + 16) { - const file = std.enums.fromInt(PaneFile, req.node - factory_base) orelse return Reply.fail(req.tag, E.NOENT); - if (file == .dir or file.inPty()) return Reply.fail(req.tag, E.NOENT); - // Truncating a factory is harmless: its next open creates an empty pane. - if (req.op == .getattr or (req.op == .setattr and req.truncate)) - return .{ .tag = req.tag, .attr = .{ .node = req.node, .name = file.name(), .mode = file.mode() } }; - if (req.op != .open) return Reply.fail(req.tag, E.PERM); - const serial = newPane(p) orelse return Reply.fail(req.tag, E.NFILE); - const node = Node.of(serial, file); - var reply = handle(p, .{ .tag = req.tag, .op = .open, .node = node }); - reply.attr.node = node; - return reply; - } - if (req.node == namespace_root or req.node == namespace_panes) return namespace(p, req); - if (req.node == os_root or req.node & os_node != 0) return osHandle(p, req); - if (req.node & archive_node != 0) return archiveHandle(p, req); - const target = Node.target(req.node) orelse return Reply.fail(req.tag, E.NOENT); - if (req.op == .write or req.op == .setattr) p.fs.origin = switch (target) { - .pane => |t| @as(u8, if (t.file == .body or t.file == .tag) 'E' else 'F'), - .top => 'F', - }; - return switch (req.op) { - .lookup => lookup(p, req, target), - .getattr => switch (attrOf(p, target)) { - .ok => |a| .{ .tag = req.tag, .attr = a }, - .missing => Reply.fail(req.tag, E.NOENT), - }, - .setattr => setattr(p, req, target), - .open => open(p, req, target), - .release => release(p, req), - .readdir => readdir(p, req, target), - .read => handleRead(p, req, target), - .write => handleWrite(p, req, target), - }; -} - -const AttrResult = union(enum) { ok: Reply.Attr, missing }; - -fn attrOf(p: *Pardes, target: Target) AttrResult { - switch (target) { - .top => |f| return .{ .ok = .{ - .name = if (f == .root) "self" else f.name(), - .node = @intFromEnum(f), - .dir = f.dir(), - .mode = f.mode(), - .size = topSize(p, f), - } }, - .pane => |t| { - const id = p.paneBySerial(t.serial) orelse return .missing; - if (t.file.inPty() and !p.panes[id].?.isTerminal()) return .missing; - return .{ .ok = .{ - .name = if (t.file == .dir) (std.fmt.bufPrint(&p.fs.node_name, "{d}", .{t.serial}) catch unreachable) else t.file.name(), - .node = Node.of(t.serial, t.file), - .dir = t.file.isDir(), - .mode = t.file.mode(), - .size = paneFileSize(p, id, t.file), - } }; - }, - } -} - -fn topSize(p: *Pardes, f: SelfFile) u64 { - return switch (f) { - .root, .new, .cons, .screen, .listeners => 0, - .index => indexLen(p), - .README => fs_help.len, - }; -} - -fn paneFileSize(p: *Pardes, id: usize, f: PaneFile) u64 { - const pane = p.panes[id] orelse return 0; - return switch (f) { - .body, .data, .xdata => bodyLen(p, pane), - .tag => tagLen(p, pane), - .dir, .addr, .ctl, .errors, .event, .rdsel, .wrsel => 0, - .pty, .pty_ctl, .pty_status, .pty_data => 0, - }; -} - -fn bodyOf(pane: *const Pane) []const u8 { - if (pane.file) |*f| return f.content; - return ""; -} - -fn fileOf(pane: *Pane) ?*panes.File.State { - return if (pane.file) |*f| f else null; -} - -fn tagOf(p: *Pardes, pane: *Pane) []const u8 { - return p.tagText(p.scratch.allocator(), pane) catch ""; -} - -fn dirOf(pane: *Pane) []const u8 { - if (pane.file) |*f| return std.fs.path.dirname(f.path) orelse "/"; - const cwd = pane.cwdSlice(); - return if (cwd.len > 0) cwd else "/"; -} - -fn dirtyOf(pane: *const Pane) bool { - const f = if (pane.file) |*x| x else return false; - if (!panes.Output.fileTraits(f.output).saves) return false; - return f.revision != f.saved_revision; -} - -fn clip(n: usize) u32 { - return std.math.cast(u32, n) orelse std.math.maxInt(u32); -} - -fn cellOf(row: i32, col: i32) modal.Cursor { - return .{ .row = @intCast(@max(0, row)), .col = @intCast(@max(0, col)) }; -} - -fn firstLine(s: []const u8) []const u8 { - return s[0 .. std.mem.indexOfScalar(u8, s, '\n') orelse s.len]; -} - -fn dotOf(pane: *Pane) PaneState.Range { - const text = bodyOf(pane); - const head = modal.offsetAt(text, cellOf(pane.cur_row, pane.cur_col)); - if (!pane.vsel.active) return .{ .q0 = clip(head), .q1 = clip(head) }; - const anchor = modal.offsetAt(text, cellOf(pane.vsel.row, pane.vsel.col)); - var hi = @max(head, anchor); - if (hi < text.len) hi = modal.nextGrapheme(text, hi); - return .{ .q0 = clip(@min(head, anchor)), .q1 = clip(hi) }; -} - -fn setDot(pane: *Pane, r: PaneState.Range) void { - const text = bodyOf(pane); - const q0 = @min(@as(usize, r.q0), text.len); - const q1 = @max(q0, @min(@as(usize, r.q1), text.len)); - const a = modal.positionAt(text, q0); - pane.vsel = .{ .active = q1 > q0, .row = @intCast(a.row), .col = @intCast(a.col), .explicit = true }; - const h = modal.positionAt(text, if (q1 > q0) modal.prevGrapheme(text, q1) else q0); - pane.cur_row = @intCast(h.row); - pane.cur_col = @intCast(h.col); - pane.cur_pinned = true; - pane.sticky_col = -1; - pane.msel.active = false; - pane.ensureCursorVisible(); -} - -fn showOffset(pane: *Pane, off: usize) void { - const text = bodyOf(pane); - const c = modal.positionAt(text, @min(off, text.len)); - pane.cur_row = @intCast(c.row); - pane.cur_col = @intCast(c.col); - pane.cur_pinned = true; - pane.sticky_col = -1; - pane.ensureCursorVisible(); -} - -fn clampAddr(pf: *PaneState, len: usize) void { - const n = clip(len); - pf.addr.q0 = @min(pf.addr.q0, n); - pf.addr.q1 = @min(pf.addr.q1, n); - if (pf.limit) |*l| { - l.q0 = @min(l.q0, n); - l.q1 = @min(l.q1, n); - } -} - -fn shiftBy(r: PaneState.Range, at: u32, removed: u32, inserted: u32) PaneState.Range { - return .{ .q0 = shiftOne(r.q0, at, removed, inserted), .q1 = shiftOne(r.q1, at, removed, inserted) }; -} - -fn shiftOne(v: u32, at: u32, removed: u32, inserted: u32) u32 { - if (v <= at) return v; - if (v <= at +| removed) return at +| inserted; - return v - removed +| inserted; -} - -fn wholeUtf8(data: []const u8) usize { - var i = data.len; - var back: usize = 0; - while (i > 0 and back < 4) : (back += 1) { - i -= 1; - const c = data[i]; - if (c < 0x80) return data.len; - if (c & 0xC0 == 0xC0) { - const need = std.unicode.utf8ByteSequenceLength(c) catch return data.len; - if (i + need <= data.len or i == 0) return data.len; - return i; - } - } - return data.len; -} - -fn paneFileNamed(name: []const u8) ?PaneFile { - const f = std.meta.stringToEnum(PaneFile, name) orelse return null; - if (f == .dir) return null; - return if (f.inPty() and f != .pty) null else f; -} - -fn ptyFileNamed(name: []const u8) ?PaneFile { - if (std.mem.eql(u8, name, "ctl")) return .pty_ctl; - if (std.mem.eql(u8, name, "status")) return .pty_status; - if (std.mem.eql(u8, name, "data")) return .pty_data; - return null; -} - -fn topFileNamed(name: []const u8) ?SelfFile { - const f = std.meta.stringToEnum(SelfFile, name) orelse return null; - return if (f == .root) null else f; -} - -fn serialNamed(name: []const u8) ?u32 { - if (name.len == 0 or name.len > 10) return null; - for (name) |c| if (c < '0' or c > '9') return null; - return std.fmt.parseInt(u32, name, 10) catch null; -} - -fn nextSerialAfter(p: *Pardes, after: u32) ?u32 { - var best: ?u32 = null; - for (p.panes) |slot| { - const pane = slot orelse continue; - if (pane.serial <= after) continue; - if (best == null or pane.serial < best.?) best = pane.serial; - } - return best; -} - -fn newPane(p: *Pardes) ?u32 { - const slot = p.freeSlot() orelse return null; - p.newScratchBelow(p.active); - const pane = p.panes[slot] orelse return null; - return pane.serial; -} - -fn lookup(p: *Pardes, req: Req, target: Target) Reply { - const name = req.data; - if (std.mem.eql(u8, name, "..")) { - const parent: u64 = switch (target) { - .top => |top| if (top == .root) namespace_root else @intFromEnum(SelfFile.root), - .pane => |t| if (t.file == .pty) Node.of(t.serial, .dir) else namespace_panes, - }; - return handle(p, .{ .tag = req.tag, .op = .getattr, .node = parent }); - } - if (name.len == 0 or std.mem.indexOfScalar(u8, name, '/') != null) return Reply.fail(req.tag, E.NOENT); - const node: u64 = switch (target) { - .top => |f| switch (f) { - .root => root: { - if (std.mem.eql(u8, name, "pane")) return .{ .tag = req.tag, .attr = .{ .node = namespace_panes, .dir = true, .mode = 0o500 } }; - if (topFileNamed(name)) |t| break :root @intFromEnum(t); - if (archiveNode(name)) |node| return archiveHandle(p, .{ .tag = req.tag, .op = .getattr, .node = node }); - return Reply.fail(req.tag, E.NOENT); - }, - .new => new: { - if (std.mem.eql(u8, name, "README")) break :new @intFromEnum(SelfFile.README); - const want = paneFileNamed(name) orelse return Reply.fail(req.tag, E.NOENT); - if (want.inPty()) return Reply.fail(req.tag, E.NOENT); - return handle(p, .{ .tag = req.tag, .op = .getattr, .node = factory_base + @intFromEnum(want) }); - }, - else => return Reply.fail(req.tag, E.NOTDIR), - }, - .pane => |t| pane: { - _ = p.paneBySerial(t.serial) orelse return Reply.fail(req.tag, E.NOENT); - const f = switch (t.file) { - .dir => paneFileNamed(name), - .pty => ptyFileNamed(name), - else => return Reply.fail(req.tag, E.NOTDIR), - } orelse return Reply.fail(req.tag, E.NOENT); - break :pane Node.of(t.serial, f); - }, - }; - return switch (attrOf(p, Node.target(node) orelse return Reply.fail(req.tag, E.NOENT))) { - .ok => |a| .{ .tag = req.tag, .attr = a }, - .missing => Reply.fail(req.tag, E.NOENT), - }; -} - -pub fn stageDirent(out: *std.ArrayList(u8), gpa: std.mem.Allocator, node: u64, dir: bool, name: []const u8) void { - if (name.len == 0 or name.len > 255) return; - var head: [10]u8 = undefined; - std.mem.writeInt(u64, head[0..8], node, .little); - head[8] = @intFromBool(dir); - head[9] = @intCast(name.len); - out.appendSlice(gpa, &head) catch return; - out.appendSlice(gpa, name) catch return; -} - -fn stagePaneFiles(p: *Pardes, out: *std.ArrayList(u8), serial: u32, terminal: bool, skip: *u64) void { - inline for (comptime std.enums.values(PaneFile)) |f| { - if (comptime f == .dir or (f.inPty() and f != .pty)) continue; - const present = f != .pty or terminal; - if (present) { - if (skip.* > 0) skip.* -= 1 else stageDirent(out, p.gpa, Node.of(serial, f), f.isDir(), f.name()); - } - } -} - -fn stagePtyFiles(p: *Pardes, out: *std.ArrayList(u8), serial: u32, skip: *u64) void { - inline for (comptime std.enums.values(PaneFile)) |f| { - if (comptime !f.inPty() or f == .pty) continue; - if (skip.* > 0) skip.* -= 1 else stageDirent(out, p.gpa, Node.of(serial, f), false, f.name()); - } -} - -fn readdir(p: *Pardes, req: Req, target: Target) Reply { - const out = p.fs.stage(p.gpa); - var skip = req.off; - switch (target) { - .top => |f| switch (f) { - .root => { - inline for (.{ SelfFile.index, SelfFile.cons, SelfFile.new }) |t| { - if (skip > 0) skip -= 1 else stageDirent(out, p.gpa, @intFromEnum(t), t.dir(), t.name()); - } - if (skip > 0) skip -= 1 else stageDirent(out, p.gpa, namespace_panes, true, "pane"); - if (skip > 0) skip -= 1 else stageDirent(out, p.gpa, @intFromEnum(SelfFile.screen), false, "screen"); - if (skip > 0) skip -= 1 else stageDirent(out, p.gpa, @intFromEnum(SelfFile.listeners), false, "listeners"); - if (skip > 0) skip -= 1 else stageDirent(out, p.gpa, @intFromEnum(SelfFile.README), false, "README"); - stageArchive(p, out, "", &skip); - }, - .new => { - if (skip > 0) skip -= 1 else stageDirent(out, p.gpa, @intFromEnum(SelfFile.README), false, "README"); - inline for (comptime std.enums.values(PaneFile)) |file| { - if (comptime file == .dir or file.inPty()) continue; - if (skip > 0) skip -= 1 else stageDirent(out, p.gpa, factory_base + @intFromEnum(file), false, file.name()); - } - }, - else => return Reply.fail(req.tag, E.NOTDIR), - }, - .pane => |t| { - const id = p.paneBySerial(t.serial) orelse return Reply.fail(req.tag, E.NOENT); - const terminal = p.panes[id].?.isTerminal(); - switch (t.file) { - .dir => stagePaneFiles(p, out, t.serial, terminal, &skip), - .pty => { - if (!terminal) return Reply.fail(req.tag, E.NOENT); - stagePtyFiles(p, out, t.serial, &skip); - }, - else => return Reply.fail(req.tag, E.NOTDIR), - } - }, - } - return .{ .tag = req.tag, .payload = .{ .staged = @intCast(out.items.len) } }; -} - -fn open(p: *Pardes, req: Req, target: Target) Reply { - const snapshot = switch (target) { - .top => |f| f == .screen, - .pane => |t| t.file == .body and if (p.paneBySerial(t.serial)) |id| p.panes[id].?.isTerminal() else false, - }; - if (snapshot) { - for (&p.fs.snapshots, 0..) |*slot, i| { - if (slot.node != 0) continue; - const bytes = if (target == .top) screenSnapshot(p) catch return Reply.fail(req.tag, E.NOMEM) else null; - slot.* = .{ .node = req.node, .bytes = bytes }; - return .{ .tag = req.tag, .handle = @intCast(i + 1) }; - } - return Reply.fail(req.tag, E.NFILE); - } - switch (target) { - .top => {}, - .pane => |t| { - const id = p.paneBySerial(t.serial) orelse return Reply.fail(req.tag, E.NOENT); - const pf = &p.fs.panes[id]; - if (t.file.inPty() and !p.panes[id].?.isTerminal()) return Reply.fail(req.tag, E.NOENT); - switch (t.file) { - .ctl => pf.limit = null, - .addr => { - pf.addr = .{}; - pf.limit = null; - }, - .event => { - pf.readers +|= 1; - p.fs.listeners +|= 1; - }, - .pty_data => pf.pty_readers +|= 1, - else => {}, - } - }, - } - return .{ .tag = req.tag, .handle = 1 }; -} - -fn release(p: *Pardes, req: Req) Reply { - if (req.handle > 0 and req.handle <= p.fs.snapshots.len) { - const snapshot = &p.fs.snapshots[req.handle - 1]; - if (snapshot.node == req.node) { - if (snapshot.bytes) |bytes| p.gpa.free(bytes); - snapshot.* = .{}; - return .{ .tag = req.tag }; - } - } - const target = Node.target(req.node) orelse return .{ .tag = req.tag }; - switch (target) { - .top => {}, - .pane => |t| { - if (t.file != .event and t.file != .pty_data) return .{ .tag = req.tag }; - const id = p.paneBySerial(t.serial) orelse return .{ .tag = req.tag }; - const pf = &p.fs.panes[id]; - if (t.file == .pty_data) { - if (pf.pty_readers == 0) return .{ .tag = req.tag }; - pf.pty_readers -= 1; - if (pf.pty_readers == 0) pf.pty_out.clearAndFree(p.gpa); - return .{ .tag = req.tag }; - } - if (pf.readers == 0) return .{ .tag = req.tag }; - pf.readers -= 1; - p.fs.listeners -|= 1; - if (pf.readers == 0) pf.tag_snap.clearAndFree(p.gpa); - }, - } - return .{ .tag = req.tag }; -} - -fn setattr(p: *Pardes, req: Req, target: Target) Reply { - if (req.truncate) switch (target) { - .pane => |t| switch (t.file) { - .body, .data, .xdata => { - const id = p.paneBySerial(t.serial) orelse return Reply.fail(req.tag, E.NOENT); - const pane = p.panes[id].?; - if (fileOf(pane) != null) { - _ = spliceBody(p, id, pane, 0, bodyOf(pane).len, "") orelse - return Reply.fail(req.tag, E.NOMEM); - p.fs.panes[id].addr = .{}; - setDot(pane, .{}); - } - }, - else => {}, - }, - else => {}, - }; - return switch (attrOf(p, target)) { - .ok => |a| .{ .tag = req.tag, .attr = a }, - .missing => Reply.fail(req.tag, E.NOENT), - }; -} - -fn staged(p: *Pardes, req: Req) Reply { - const out = &p.fs.out; - const off = @min(req.off, out.items.len); - const n = @min(out.items.len - off, req.size); - if (off > 0) std.mem.copyForwards(u8, out.items[0..n], out.items[off..][0..n]); - out.shrinkRetainingCapacity(n); - return .{ .tag = req.tag, .payload = .{ .staged = @intCast(n) } }; -} - -fn handleRead(p: *Pardes, req: Req, target: Target) Reply { - switch (target) { - .top => |f| return switch (f) { - .index => readIndex(p, req), - .README => help: { - const off = @min(req.off, fs_help.len); - const bytes = fs_help[off..][0..@min(req.size, fs_help.len - off)]; - p.fs.stage(p.gpa).appendSlice(p.gpa, bytes) catch break :help Reply.fail(req.tag, E.NOMEM); - break :help .{ .tag = req.tag, .payload = .{ .staged = @intCast(bytes.len) } }; - }, - .listeners => listeners: { - var buf: [512]u8 = undefined; - var text = std.Io.Writer.fixed(&buf); - if (p.fs.socket_path.len != 0) - text.print("unix!{s}\n", .{p.fs.socket_path}) catch break :listeners Reply.fail(req.tag, E.IO); - for ([_]?std.Io.net.IpAddress{ p.fs.tcp_address, p.fs.quic_address }, [_][]const u8{ "tcp", "quic" }) |maybe, transport| { - const address = maybe orelse continue; - switch (address) { - .ip4 => |ip| text.print("{s}!{d}.{d}.{d}.{d}!{d}\n", .{ transport, ip.bytes[0], ip.bytes[1], ip.bytes[2], ip.bytes[3], ip.port }) catch - break :listeners Reply.fail(req.tag, E.IO), - .ip6 => |ip| text.print("{s}!{f}!{d}\n", .{ transport, std.Io.net.Ip6Address.Unresolved{ .bytes = ip.bytes, .interface_name = null }, ip.port }) catch - break :listeners Reply.fail(req.tag, E.IO), - } - } - const bytes = text.buffered(); - const off = @min(req.off, bytes.len); - const len = @min(bytes.len - off, req.size); - p.fs.stage(p.gpa).appendSlice(p.gpa, bytes[off..][0..len]) catch break :listeners Reply.fail(req.tag, E.NOMEM); - break :listeners .{ .tag = req.tag, .payload = .{ .staged = @intCast(len) } }; - }, - .screen => readSnapshot(p, req, null), - .cons, .root, .new => Reply.fail(req.tag, E.PERM), - }, - .pane => |t| { - const id = p.paneBySerial(t.serial) orelse return Reply.fail(req.tag, E.NOENT); - const pane = p.panes[id].?; - const pf = &p.fs.panes[id]; - if (t.file.inPty() and !pane.isTerminal()) return Reply.fail(req.tag, E.NOENT); - return switch (t.file) { - .addr => readAddr(p, req, pf, pane), - .body => readBody(p, req, id, pane), - .ctl => readCtl(p, req, pane), - .data => readData(req, id, pane, pf, false), - .xdata => readData(req, id, pane, pf, true), - .tag => readTag(p, req, pane), - .event => readQueue(p, req, &pf.events), - .rdsel => readRdsel(req, id, pane), - .pty_status => readPtyStatus(p, req, id, pane), - .pty_data => readPtyData(p, req, pf), - .dir, .errors, .wrsel, .pty, .pty_ctl => Reply.fail(req.tag, E.PERM), - }; - }, - } -} - -fn screenSnapshot(p: *Pardes) ![]u8 { - var arena: std.heap.ArenaAllocator = .init(p.gpa); - defer arena.deinit(); - const surface = try p.render(arena.allocator()); - var styles: std.ArrayList(pardes.CellStyle) = .empty; - var indices: std.ArrayList(usize) = .empty; - for (surface.cells) |cell| { - const style: pardes.CellStyle = if (cell.default) .{} else cell.style; - const index = for (styles.items, 0..) |previous, i| { - if (std.meta.eql(style, previous)) break i; - } else new: { - try styles.append(arena.allocator(), style); - break :new styles.items.len - 1; - }; - try indices.append(arena.allocator(), index); - } - var out: std.Io.Writer.Allocating = .init(p.gpa); - errdefer out.deinit(); - const writer = &out.writer; - try writer.print("{{\"cols\":{d},\"rows\":{d},\"cursor\":", .{ surface.cols, surface.rows }); - try std.json.Stringify.value(surface.cursor, .{}, writer); - try writer.writeAll(",\"styles\":"); - try std.json.Stringify.value(styles.items, .{ .emit_strings_as_arrays = true }, writer); - try writer.writeAll(",\"cells\":["); - for (surface.cells, indices.items, 0..) |cell, index, i| { - if (i != 0) try writer.writeByte(','); - try std.json.Stringify.value(.{ if (cell.default) " " else cell.grapheme(), index }, .{}, writer); - } - try writer.writeAll("]}\n"); - return out.toOwnedSlice(); -} - -const ctl_fields = 5 * 12; - -fn stageCtlNumbers(p: *Pardes, out: *std.ArrayList(u8), pane: *Pane) void { - out.print(p.gpa, "{d:>11} {d:>11} {d:>11} {d:>11} {d:>11} ", .{ - pane.serial, - tagOf(p, pane).len, - bodyOf(pane).len, - @as(u32, 0), - @intFromBool(dirtyOf(pane)), - }) catch {}; -} - -fn readIndex(p: *Pardes, req: Req) Reply { - const out = p.fs.stage(p.gpa); - var last: u32 = 0; - while (nextSerialAfter(p, last)) |s| { - last = s; - const pane = p.panes[p.paneBySerial(s).?].?; - stageCtlNumbers(p, out, pane); - out.appendSlice(p.gpa, firstLine(tagOf(p, pane))) catch {}; - out.append(p.gpa, '\n') catch {}; - } - return staged(p, req); -} - -fn readAddr(p: *Pardes, req: Req, pf: *PaneState, pane: *Pane) Reply { - clampAddr(pf, bodyOf(pane).len); - const out = p.fs.stage(p.gpa); - out.print(p.gpa, "{d:>11} {d:>11} ", .{ pf.addr.q0, pf.addr.q1 }) catch {}; - return staged(p, req); -} - -fn readBody(p: *Pardes, req: Req, id: usize, pane: *Pane) Reply { - if (pane.file != null) { - const text = bodyOf(pane); - const off = @min(req.off, text.len); - const n = @min(text.len - off, req.size); - return .{ .tag = req.tag, .payload = .{ .region = .{ - .pane = @intCast(id), - .serial = pane.serial, - .off = clip(off), - .len = clip(n), - } } }; - } - if (req.handle != 0 and pane.isTerminal()) return readSnapshot(p, req, pane); - const text = panes.Terminal.screenTextAlloc(pane, p.gpa) catch - return Reply.fail(req.tag, E.NOMEM); - defer p.gpa.free(text); - const out = p.fs.stage(p.gpa); - out.appendSlice(p.gpa, text) catch return Reply.fail(req.tag, E.NOMEM); - return staged(p, req); -} - -fn readSnapshot(p: *Pardes, req: Req, pane: ?*Pane) Reply { - if (req.handle == 0 or req.handle > p.fs.snapshots.len) return Reply.fail(req.tag, E.INVAL); - const snapshot = &p.fs.snapshots[req.handle - 1]; - if (snapshot.node == 0 or snapshot.node != req.node) return Reply.fail(req.tag, E.INVAL); - if (snapshot.bytes == null) { - const terminal = pane orelse return Reply.fail(req.tag, E.INVAL); - snapshot.bytes = panes.Terminal.screenTextAlloc(terminal, p.gpa) catch return Reply.fail(req.tag, E.NOMEM); - } - const bytes = snapshot.bytes.?; - const off = @min(req.off, bytes.len); - const len = @min(bytes.len - off, req.size); - const out = p.fs.stage(p.gpa); - out.appendSlice(p.gpa, bytes[off..][0..len]) catch return Reply.fail(req.tag, E.NOMEM); - return .{ .tag = req.tag, .payload = .{ .staged = @intCast(len) } }; -} - -fn fontName(p: *Pardes) []const u8 { - const name = p.settings.font.effective_name.get(); - return if (name.len == 0) "default" else name; -} - -fn stageQuoted(out: *std.ArrayList(u8), gpa: std.mem.Allocator, s: []const u8) void { - const plain = s.len > 0 and for (s) |c| { - if (c <= ' ' or c == '\'') break false; - } else true; - if (plain) { - out.appendSlice(gpa, s) catch {}; - return; - } - out.append(gpa, '\'') catch {}; - for (s) |c| { - if (c == '\'') out.append(gpa, '\'') catch {}; - out.append(gpa, c) catch {}; - } - out.append(gpa, '\'') catch {}; -} - -fn readCtl(p: *Pardes, req: Req, pane: *Pane) Reply { - const out = p.fs.stage(p.gpa); - stageCtlNumbers(p, out, pane); - out.print(p.gpa, "{d:>11} ", .{pane.cols}) catch {}; - stageQuoted(out, p.gpa, fontName(p)); - out.print(p.gpa, " {d:>11} ", .{config.tab_width}) catch {}; - return staged(p, req); -} - -fn readTag(p: *Pardes, req: Req, pane: *Pane) Reply { - const out = p.fs.stage(p.gpa); - out.appendSlice(p.gpa, tagOf(p, pane)) catch {}; - return staged(p, req); -} - -fn readData(req: Req, id: usize, pane: *Pane, pf: *PaneState, stop_at_end: bool) Reply { - const text = bodyOf(pane); - clampAddr(pf, text.len); - const q0: usize = pf.addr.q0; - const hi: usize = if (stop_at_end) @max(q0, @as(usize, pf.addr.q1)) else text.len; - var end = @min(hi, q0 +| req.size); - end = @max(q0, modal.graphemeStart(text, end)); - pf.addr.q0 = clip(end); - if (!stop_at_end) pf.addr.q1 = clip(end); - if (pane.file == null) return .{ .tag = req.tag }; - return .{ .tag = req.tag, .payload = .{ .region = .{ - .pane = @intCast(id), - .serial = pane.serial, - .off = clip(q0), - .len = clip(end - q0), - } } }; -} - -fn readRdsel(req: Req, id: usize, pane: *Pane) Reply { - if (pane.file == null) return .{ .tag = req.tag }; - const text = bodyOf(pane); - const d = dotOf(pane); - const lo = @min(@as(usize, d.q0), text.len); - const hi = @max(lo, @min(@as(usize, d.q1), text.len)); - const off = @min(req.off, hi - lo); - const n = @min(hi - lo - off, req.size); - return .{ .tag = req.tag, .payload = .{ .region = .{ - .pane = @intCast(id), - .serial = pane.serial, - .off = clip(lo + off), - .len = clip(n), - } } }; -} - -fn readQueue(p: *Pardes, req: Req, q: *Queue) Reply { - const record = q.peek() orelse return .{ .tag = req.tag, .status = .again }; - if (req.size < record.len) return Reply.fail(req.tag, E.INVAL); - const out = p.fs.stage(p.gpa); - out.appendSlice(p.gpa, record) catch return Reply.fail(req.tag, E.NOMEM); - q.pop(); - return .{ .tag = req.tag, .payload = .{ .staged = @intCast(out.items.len) } }; -} - -fn readPtyStatus(p: *Pardes, req: Req, id: usize, pane: *Pane) Reply { - const out = p.fs.stage(p.gpa); - out.print(p.gpa, "{d:>11} {d:>11} {d:>11} ", .{ - pane.cols, - pane.rows, - @intFromBool(p.hostTtyTaken(id)), - }) catch {}; - return staged(p, req); -} - -fn readPtyData(p: *Pardes, req: Req, pf: *PaneState) Reply { - if (pf.pty_out.empty()) return .{ .tag = req.tag, .status = .again }; - const out = p.fs.stage(p.gpa); - while (out.items.len < req.size) { - const chunk = pf.pty_out.peek() orelse break; - const n = @min(chunk.len, req.size - out.items.len); - out.appendSlice(p.gpa, chunk[0..n]) catch break; - pf.pty_out.popFront(n); - } - return .{ .tag = req.tag, .payload = .{ .staged = @intCast(out.items.len) } }; -} - -fn handleWrite(p: *Pardes, req: Req, target: Target) Reply { - switch (target) { - .top => |f| return switch (f) { - .cons => if (appendErrors(p, p.active, req.data)) |took| - .{ .tag = req.tag, .written = @intCast(took) } - else - Reply.fail(req.tag, E.IO), - else => Reply.fail(req.tag, E.PERM), - }, - .pane => |t| { - const id = p.paneBySerial(t.serial) orelse return Reply.fail(req.tag, E.NOENT); - const pane = p.panes[id].?; - if (t.file.inPty() and !pane.isTerminal()) return Reply.fail(req.tag, E.NOENT); - return switch (t.file) { - .addr => writeAddr(p, req, id, pane), - .body => writeBody(p, req, id, pane), - .ctl => writeCtl(p, req, t.serial), - .data, .xdata => writeData(p, req, id, pane), - .tag => writeTag(p, req, pane), - .event => writeEvent(p, req, id), - .wrsel => writeWrsel(p, req, id, pane), - .errors => if (appendErrors(p, id, req.data)) |took| - .{ .tag = req.tag, .written = @intCast(took) } - else - Reply.fail(req.tag, E.IO), - .pty_ctl => writePtyCtl(p, req, id), - .pty_data => writePtyData(p, req, id), - .dir, .rdsel, .pty, .pty_status => Reply.fail(req.tag, E.PERM), - }; - }, - } -} - -fn spliceBody(p: *Pardes, id: usize, pane: *Pane, q0: usize, q1: usize, bytes: []const u8) ?usize { - const f = fileOf(pane) orelse return null; - const take = if (bytes.len == 0) 0 else wholeUtf8(bytes); - const lo = @min(q0, f.content.len); - const hi = @max(lo, @min(q1, f.content.len)); - const new = p.gpa.alloc(u8, f.content.len - (hi - lo) + take) catch return null; - @memcpy(new[0..lo], f.content[0..lo]); - @memcpy(new[lo..][0..take], bytes[0..take]); - @memcpy(new[lo + take ..], f.content[hi..]); - if (!p.fs.panes[id].nomark) panes.File.pushUndo(p, pane); - panes.File.setContent(p, f, new); - return take; -} - -fn writeBody(p: *Pardes, req: Req, id: usize, pane: *Pane) Reply { - if (req.data.len == 0) return .{ .tag = req.tag, .written = 0 }; - if (pane.file == null) { - const take = wholeUtf8(req.data); - p.emitWrite(id, req.data[0..take]); - return .{ .tag = req.tag, .written = @intCast(take) }; - } - const at = bodyOf(pane).len; - const take = spliceBody(p, id, pane, at, at, req.data) orelse - return Reply.fail(req.tag, E.NOMEM); - if (!p.fs.panes[id].noscroll) showOffset(pane, at + take); - return .{ .tag = req.tag, .written = @intCast(take) }; -} - -fn writeTag(p: *Pardes, req: Req, pane: *Pane) Reply { - if (req.data.len == 0) return .{ .tag = req.tag, .written = 0 }; - p.seedTail(pane); - const room = pane.tag_tail.len - pane.tag_tail_len; - if (room == 0) return Reply.fail(req.tag, E.NOSPC); - const take = wholeUtf8(req.data[0..@min(req.data.len, room)]); - @memcpy(pane.tag_tail[pane.tag_tail_len..][0..take], req.data[0..take]); - pane.tag_tail_len += take; - pane.tag_init = true; - return .{ .tag = req.tag, .written = @intCast(take) }; -} - -fn writeData(p: *Pardes, req: Req, id: usize, pane: *Pane) Reply { - if (fileOf(pane) == null) return Reply.fail(req.tag, E.INVAL); - const pf = &p.fs.panes[id]; - clampAddr(pf, bodyOf(pane).len); - const q0: usize = pf.addr.q0; - const q1: usize = @max(q0, @as(usize, pf.addr.q1)); - const before = dotOf(pane); - const take = spliceBody(p, id, pane, q0, q1, req.data) orelse - return Reply.fail(req.tag, E.NOMEM); - setDot(pane, shiftBy(before, clip(q0), clip(q1 - q0), clip(take))); - pf.addr = .{ .q0 = clip(q0 + take), .q1 = clip(q0 + take) }; - if (!pf.noscroll) showOffset(pane, q0 + take); - return .{ .tag = req.tag, .written = @intCast(take) }; -} - -fn writeWrsel(p: *Pardes, req: Req, id: usize, pane: *Pane) Reply { - if (fileOf(pane) == null) return Reply.fail(req.tag, E.INVAL); - const d = dotOf(pane); - const q0: usize = d.q0; - const q1: usize = @max(q0, @as(usize, d.q1)); - const take = spliceBody(p, id, pane, q0, q1, req.data) orelse - return Reply.fail(req.tag, E.NOMEM); - setDot(pane, .{ .q0 = clip(q0 + take), .q1 = clip(q0 + take) }); - return .{ .tag = req.tag, .written = @intCast(take) }; -} - -fn writeAddr(p: *Pardes, req: Req, id: usize, pane: *Pane) Reply { - const pf = &p.fs.panes[id]; - const text = bodyOf(pane); - clampAddr(pf, text.len); - const expr = std.mem.trimEnd(u8, req.data, "\n"); - var a: Addr = .{ .text = text, .lim = pf.limit, .expr = expr }; - const r = a.address(pf.addr) orelse return Reply.fail(req.tag, E.INVAL); - if (a.i < expr.len) return Reply.fail(req.tag, E.INVAL); - pf.addr = r; - return .{ .tag = req.tag, .written = @intCast(req.data.len) }; -} - -fn safePattern(pat: []const u8) bool { - var i: usize = 0; - while (i < pat.len) : (i += 1) { - if (pat[i] != '\\') continue; - if (i + 1 >= pat.len) return false; - i += 1; - } - return true; -} - -const Addr = struct { - text: []const u8, - lim: ?PaneState.Range, - expr: []const u8, - i: usize = 0, - depth: u8 = 0, - - const max_depth = 32; - const Size = enum { char, line }; - - fn address(a: *Addr, ar_in: PaneState.Range) ?PaneState.Range { - const start = a.i; - var ar = ar_in; - var r = ar_in; - var dir: u8 = 0; - var size: Size = .line; - var c: u8 = 0; - while (a.i < a.expr.len) { - const prevc = c; - c = a.expr[a.i]; - a.i += 1; - switch (c) { - ',', ';' => { - if (c == ';') ar = r; - if (prevc == 0) r.q0 = 0; // lhs defaults to 0 - if (a.i >= a.expr.len) { - r.q1 = clip(a.text.len); // rhs defaults to $ - } else { - if (a.depth >= max_depth) return null; - a.depth += 1; - const nr = a.address(ar) orelse return null; - a.depth -= 1; - r.q1 = nr.q1; - } - return r; - }, - '+', '-' => { - if (prevc == '+' or prevc == '-') { - const nc = if (a.i < a.expr.len) a.expr[a.i] else 0; - if (nc != '#' and nc != '/' and nc != '?') - r = a.number(r, 1, prevc, .line) orelse return null; - } - dir = c; - }, - '.', '$' => { - if (a.i != start + 1) { - a.i -= 1; - return r; - } - r = if (c == '.') ar else .{ .q0 = clip(a.text.len), .q1 = clip(a.text.len) }; - dir = if (a.i < a.expr.len) '+' else 0; - }, - '#', '0'...'9' => { - var digit = c; - if (c == '#') { - if (a.i >= a.expr.len or a.expr[a.i] < '0' or a.expr[a.i] > '9') { - a.i -= 1; - return r; - } - digit = a.expr[a.i]; - a.i += 1; - size = .char; - } - var n: u64 = digit - '0'; - while (a.i < a.expr.len) : (a.i += 1) { - const d = a.expr[a.i]; - if (d < '0' or d > '9') break; - n = @min(n * 10 + (d - '0'), std.math.maxInt(u32)); - } - r = a.number(r, @intCast(n), dir, size) orelse return null; - dir = 0; - size = .line; - }, - '/', '?' => { - const back = c == '?'; - r = a.regexp(r, a.pattern(c), back) orelse return null; - dir = 0; - size = .line; - }, - else => { - a.i -= 1; - return r; - }, - } - } - if (dir != 0) r = a.number(r, 1, dir, .line) orelse return null; - return r; - } - - fn pattern(a: *Addr, delim: u8) []const u8 { - const s = a.i; - while (a.i < a.expr.len) { - const c = a.expr[a.i]; - if (c == '\n') break; - a.i += 1; - if (c == '\\') { - if (a.i < a.expr.len) a.i += 1; - continue; - } - if (c == delim) return a.expr[s .. a.i - 1]; - } - return a.expr[s..a.i]; - } - - fn number(a: *Addr, r_in: PaneState.Range, n: u32, dir: u8, size: Size) ?PaneState.Range { - var r = r_in; - if (size == .char) { - var off: i64 = n; - if (dir == '+') { - off = @as(i64, r.q1) + n; - } else if (dir == '-') { - if (r.q0 == 0 and n > 0) r.q0 = clip(a.text.len); - off = @as(i64, r.q0) - n; - } - if (off < 0 or off > @as(i64, @intCast(a.text.len))) return null; - const g = clip(modal.graphemeStart(a.text, @intCast(off))); - return .{ .q0 = g, .q1 = g }; - } - var line: i64 = n; - var q0: usize = r.q0; - var q1: usize = r.q1; - switch (dir) { - '-' => { - if (q0 < a.text.len) while (q0 > 0 and a.text[q0 - 1] != '\n') { - q0 -= 1; - }; - q1 = q0; - while (line > 0 and q0 > 0) { - if (a.text[q0 - 1] == '\n') { - line -= 1; - q1 = q0; - } - q0 -= 1; - } - if (line > 1) return null; - while (q0 > 0 and a.text[q0 - 1] != '\n') q0 -= 1; - return .{ .q0 = clip(q0), .q1 = clip(q1) }; - }, - '+' => { - if (q1 > 0) while (q1 < a.text.len and a.text[q1 - 1] != '\n') { - q1 += 1; - }; - q0 = q1; - }, - else => { - q0 = 0; - q1 = 0; - }, - } - while (line > 0 and q1 < a.text.len) { - const ch = a.text[q1]; - q1 += 1; - if (ch == '\n' or q1 == a.text.len) { - line -= 1; - if (line > 0) q0 = q1; - } - } - if (line > 0) return null; - return .{ .q0 = clip(q0), .q1 = clip(q1) }; - } - - fn regexp(a: *Addr, r: PaneState.Range, pat: []const u8, back: bool) ?PaneState.Range { - if (pat.len == 0 or !safePattern(pat)) return null; - const re = mvzr.compile(pat) orelse return null; - if (back) { - const hi = @min(@as(usize, r.q0), a.text.len); - var best: ?mvzr.Match = null; - var at: usize = 0; - while (at < hi) { - const m = re.matchPos(at, a.text[0..hi]) orelse break; - best = m; - at = if (m.end > m.start) m.end else m.end + 1; - } - const m = best orelse return null; - return .{ .q0 = clip(m.start), .q1 = clip(m.end) }; - } - const hi = if (a.lim) |l| @min(@as(usize, l.q1), a.text.len) else a.text.len; - const from = @min(@as(usize, r.q1), hi); - const m = re.match(a.text[from..hi]) orelse return null; - return .{ .q0 = clip(from + m.start), .q1 = clip(from + m.end) }; - } -}; - -const Verb = enum { - @"addr=dot", - clean, - cleartag, - del, - delete, - dirty, - @"dot=addr", - get, - @"limit=addr", - mark, - nomark, - noscroll, - put, - scroll, - show, -}; - -const refused_verbs = [_][]const u8{ "dump", "dumpdir", "font", "lock", "menu", "nomenu", "unlock" }; - -fn verbIs(line: []const u8, word: []const u8) bool { - if (!std.mem.startsWith(u8, line, word)) return false; - return line.len == word.len or line[word.len] == ' '; -} - -fn writeCtl(p: *Pardes, req: Req, serial: u32) Reply { - for ([2]bool{ false, true }) |apply| { - var dirty = if (p.paneBySerial(serial)) |id| dirtyOf(p.panes[id].?) else false; - var it = std.mem.splitScalar(u8, req.data, '\n'); - while (it.next()) |raw| { - const line = std.mem.trim(u8, raw, " \t\r"); - if (line.len == 0) continue; - const live = p.paneBySerial(serial) orelse if (apply) break else return Reply.fail(req.tag, E.NOENT); - const errno = ctlVerb(p, live, line, apply, &dirty); - if (errno != 0) return Reply.fail(req.tag, errno); - } - } - return .{ .tag = req.tag, .written = @intCast(req.data.len) }; -} - -/// Change a buffer's absolute name without writing or renaming a disk file. -/// Tag editing preserves user commands; the 9P name operation resets its tail. -pub fn nameBuffer(p: *Pardes, id: usize, full: []const u8, preserve_tag: bool) !void { - const pane = p.panes[id] orelse return error.NoPane; - const f = fileOf(pane) orelse return error.NotFile; - if (!std.fs.path.isAbsolute(full) or full.len == 0 or full.len >= 4096) - return error.InvalidName; - for (full) |c| if (c < ' ') return error.InvalidName; - if (std.mem.eql(u8, f.path, full)) return; - const copy = try p.gpa.dupe(u8, full); - p.gpa.free(f.path); - f.path = copy; - if (panes.Output.fileTraits(f.output).saves) { - f.output = null; - pane.clearCwd(); - if (!preserve_tag) { - pane.tag_init = false; - pane.tag_tail_len = 0; - } - f.saved_revision = f.revision -% 1; - f.watch_after_save = localPath(full) != null; - } - if (f.highlights.len > 0) p.tree_sitter_gpa.free(f.highlights); - f.highlights = &.{}; - f.highlight_start = 0; - f.syntax_dirty = true; - f.context_revision = null; - pane.context_rows = 0; - pane.wrap_n = 0; - p.invalidateLookHover(id); - p.emit(.{ .watch = .{ .pane = @intCast(id), .on = false } }); -} - -fn ctlVerb(p: *Pardes, id: usize, line: []const u8, apply: bool, dirty: *bool) u16 { - const pane = p.panes[id] orelse return E.INVAL; - const pf = &p.fs.panes[id]; - - if (verbIs(line, "look")) { - if (line.len <= 5) return E.INVAL; - const word = std.mem.trim(u8, line[5..], " \t"); - if (word.len == 0) return E.INVAL; - for (word) |c| if (c < ' ') return E.INVAL; - if (apply) p.lookAt(id, word); - return 0; - } - if (verbIs(line, "name")) { - if (line.len <= 5) return E.INVAL; - const name = std.mem.trim(u8, line[5..], " \t"); - if (name.len == 0) return E.INVAL; - for (name) |c| if (c <= ' ') return E.INVAL; - const f = fileOf(pane) orelse return 0; - const full = std.fs.path.resolvePosix(p.gpa, &.{ Pardes.paneDir(pane), name }) catch return E.NOMEM; - defer p.gpa.free(full); - if (!std.fs.path.isAbsolute(full) or full.len >= 4096) return E.INVAL; - if (std.mem.eql(u8, f.path, full)) return 0; - if (panes.Output.fileTraits(f.output).saves) dirty.* = true; - if (!apply) return 0; - nameBuffer(p, id, full, false) catch return E.NOMEM; - return 0; - } - for (refused_verbs) |w| if (verbIs(line, w)) return E.INVAL; - - const v = std.meta.stringToEnum(Verb, line) orelse return E.INVAL; - if (v == .del and dirty.*) return E.INVAL; - switch (v) { - .dirty => dirty.* = true, - .clean, .get, .put => dirty.* = false, - else => {}, - } - if (!apply) return 0; - - switch (v) { - .@"addr=dot" => pf.addr = dotOf(pane), - .@"dot=addr" => { - clampAddr(pf, bodyOf(pane).len); - setDot(pane, pf.addr); - }, - .@"limit=addr" => { - clampAddr(pf, bodyOf(pane).len); - pf.limit = pf.addr; - }, - .clean => if (fileOf(pane)) |f| { - f.saved_revision = f.revision; - }, - .dirty => if (fileOf(pane)) |f| { - f.saved_revision = f.revision -% 1; - }, - .cleartag => { - pane.tag_tail_len = 0; - pane.tag_init = true; - }, - .del, .delete => p.removePane(id) catch return E.NOMEM, - .put => { - const serial = pane.serial; - if (fileOf(pane)) |f| { - if (f.output == null) { - p.perform(.{ .save_file = .{ .pane = @intCast(id) } }); - const current = p.paneBySerial(serial) orelse return E.NOENT; - if (dirtyOf(p.panes[current].?)) return E.IO; - } else _ = p.executeBuiltinLine(id, "Save"); - } else _ = p.executeBuiltinLine(id, "Save"); - }, - .get => if (fileOf(pane)) |f| { - if (panes.Output.fileTraits(f.output).saves) { - if (read(p, f.path)) |bytes| { - panes.File.pushUndo(p, pane); - panes.File.setContent(p, f, bytes); - f.saved_revision = f.revision; - } else |err| return switch (err) { - error.FileNotFound => E.NOENT, - else => E.IO, - }; - } - }, - .mark => { - pf.nomark = false; - panes.File.pushUndo(p, pane); - }, - .nomark => pf.nomark = true, - .noscroll => pf.noscroll = true, - .scroll => pf.noscroll = false, - .show => showOffset(pane, dotOf(pane).q0), - } - return 0; -} - -const PtyVerb = enum { winsize, sig, exec }; - -fn ptyDimension(word: []const u8) ?u16 { - if (word.len == 0 or word.len > 5) return null; - for (word) |c| if (c < '0' or c > '9') return null; - const n = std.fmt.parseInt(u16, word, 10) catch return null; - return if (n == 0) null else n; -} - -fn ptySignalNamed(word: []const u8) ?pardes.PtySignal { - if (std.mem.eql(u8, word, "INT")) return .int; - if (std.mem.eql(u8, word, "TERM")) return .term; - if (std.mem.eql(u8, word, "HUP")) return .hup; - if (std.mem.eql(u8, word, "QUIT")) return .quit; - if (std.mem.eql(u8, word, "KILL")) return .kill; - return null; -} - -fn writePtyCtl(p: *Pardes, req: Req, id: usize) Reply { - for ([2]bool{ false, true }) |apply| { - var it = std.mem.splitScalar(u8, req.data, '\n'); - while (it.next()) |raw| { - const line = std.mem.trim(u8, raw, " \t\r"); - if (line.len == 0) continue; - if (!ptyVerb(p, id, line, apply)) return Reply.fail(req.tag, E.INVAL); - } - } - return .{ .tag = req.tag, .written = @intCast(req.data.len) }; -} - -fn ptyVerb(p: *Pardes, id: usize, line: []const u8, apply: bool) bool { - const pane = p.panes[id] orelse return false; - var words = std.mem.tokenizeAny(u8, line, " \t"); - const v = std.meta.stringToEnum(PtyVerb, words.next() orelse return false) orelse return false; - switch (v) { - .winsize => { - const cols = ptyDimension(words.next() orelse return false) orelse return false; - const rows = ptyDimension(words.next() orelse return false) orelse return false; - if (words.next() != null) return false; - if (!apply) return true; - p.emit(.{ .resize_pty = .{ .pane = @intCast(id), .cols = cols, .rows = rows } }); - }, - .sig => { - const which = ptySignalNamed(words.next() orelse return false) orelse return false; - if (words.next() != null) return false; - if (!apply) return true; - p.emit(.{ .signal_pty = .{ .pane = @intCast(id), .sig = which } }); - }, - .exec => { - if (words.next() != null) return false; - if (pane.cwdSlice().len > pardes.effect_path_cap) return false; - if (!apply) return true; - p.emit(.{ .spawn = .{ .pane = @intCast(id), .cwd = .from(pane.cwdSlice()) } }); - }, - } - return true; -} - -fn writePtyData(p: *Pardes, req: Req, id: usize) Reply { - if (req.data.len == 0) return .{ .tag = req.tag, .written = 0 }; - const take = wholeUtf8(req.data); - p.emitWrite(id, req.data[0..take]); - return .{ .tag = req.tag, .written = @intCast(take) }; -} - -const EventRecord = struct { action: Action, q0: u32, q1: u32 }; - -const EventReader = struct { - data: []const u8, - i: usize = 0, - - fn next(er: *EventReader) ?EventRecord { - if (er.i >= er.data.len) return null; - var i = er.i; - if (i + 2 > er.data.len) return null; - i += 1; - const action = Action.fromChar(er.data[i]) orelse return null; - i += 1; - const q0 = scanNumber(er.data, &i) orelse return null; - const q1 = scanNumber(er.data, &i) orelse return null; - while (i < er.data.len and er.data[i] == ' ') i += 1; - if (i >= er.data.len or er.data[i] != '\n') return null; - er.i = i + 1; - return .{ .action = action, .q0 = q0, .q1 = q1 }; - } -}; - -fn scanNumber(data: []const u8, i: *usize) ?u32 { - while (i.* < data.len and data[i.*] == ' ') i.* += 1; - const s = i.*; - var n: u64 = 0; - while (i.* < data.len and data[i.*] >= '0' and data[i.*] <= '9') : (i.* += 1) - n = @min(n * 10 + (data[i.*] - '0'), std.math.maxInt(u32)); - if (i.* == s) return null; - return @intCast(n); -} - -fn writeEvent(p: *Pardes, req: Req, id: usize) Reply { - const pane0 = p.panes[id] orelse return Reply.fail(req.tag, E.NOENT); - const serial = pane0.serial; - { - const body = bodyOf(pane0); - const tag = tagOf(p, pane0); - var check: EventReader = .{ .data = req.data }; - while (check.next()) |r| { - switch (r.action) { - .body_look, .tag_look, .body_exec, .tag_exec => {}, - else => return Reply.fail(req.tag, E.INVAL), - } - const n = if (r.action.onTag()) tag.len else body.len; - if (r.q0 > r.q1 or r.q1 > n) return Reply.fail(req.tag, E.INVAL); - } - if (check.i != req.data.len) return Reply.fail(req.tag, E.INVAL); - } - var run: EventReader = .{ .data = req.data }; - while (run.next()) |r| { - const now = p.paneBySerial(serial) orelse break; - const pane = p.panes[now].?; - const whole = if (r.action.onTag()) tagOf(p, pane) else bodyOf(pane); - const lo = @min(@as(usize, r.q0), whole.len); - const hi = @max(lo, @min(@as(usize, r.q1), whole.len)); - const text = p.scratch.allocator().dupe(u8, whole[lo..hi]) catch continue; - switch (r.action) { - .body_exec, .tag_exec => _ = p.execute(now, text), - .body_look, .tag_look => p.lookAt(now, text), - else => unreachable, - } - } - return .{ .tag = req.tag, .written = @intCast(req.data.len) }; -} - -fn appendErrors(p: *Pardes, id: usize, text: []const u8) ?usize { - if (text.len == 0) return 0; - const pane = p.panes[id] orelse return null; - const dir = dirOf(pane); - for (p.panes, 0..) |slot, i| { - const q = slot orelse continue; - const qf = fileOf(q) orelse continue; - const o = qf.output orelse continue; - if (std.meta.activeTag(o.from) != .errors) continue; - if (!std.mem.eql(u8, std.fs.path.dirname(qf.path) orelse "", dir)) continue; - return spliceBody(p, i, q, qf.content.len, qf.content.len, text); - } - const free = p.freeSlot() orelse return null; - const content = p.gpa.dupe(u8, text) catch return null; - const np = panes.Output.open(p, free, dir, .errors, "", content) catch { - p.gpa.free(content); - return null; - }; - p.placeDoc(id, free, np); - return text.len; -} - -fn indexLen(p: *Pardes) u64 { - var n: u64 = 0; - for (p.panes) |slot| { - const pane = slot orelse continue; - n += ctl_fields + firstLine(tagOf(p, pane)).len + 1; - } - return n; -} - -fn bodyLen(p: *Pardes, pane: *Pane) u64 { - _ = p; - return bodyOf(pane).len; -} - -fn tagLen(p: *Pardes, pane: *Pane) u64 { - return tagOf(p, pane).len; -} - -test "filesystem inspection preserves pending and displayed Look hover" { - const delay = config.look_preview_delay_frames orelse return; - const gpa = std.testing.allocator; - const p = try withFile(gpa, "alpha beta gamma\n"); - defer p.deinit(); - var frame: std.heap.ArenaAllocator = .init(gpa); - defer frame.deinit(); - _ = try p.render(frame.allocator()); - const rect = p.rects[0]; - p.update(.{ .mouse = .{ - .button = .none, - .kind = .motion, - .col = rect.x + config.GUTTER + config.PREFIX_W + 7, - .row = if (p.settings.tag_bottom) rect.y else rect.y + pardes.BOX_H, - } }); - try testing.expect(p.look_hover_wait != null); - const body = Node.of(serialOf(p), .body); - const screen = @intFromEnum(SelfFile.screen); - for (0..2) |phase| { - if (phase == 1) { - for (0..delay) |_| p.update(.tick); - try testing.expect(p.look_hover_preview != null); - } - const waiting = p.look_hover_wait; - const preview = p.look_hover_preview; - const requests = [_]Req{ - .{ .tag = 1, .op = .lookup, .node = @intFromEnum(SelfFile.root), .data = "screen" }, - .{ .tag = 1, .op = .lookup, .node = @intFromEnum(SelfFile.new), .data = ".." }, - .{ .tag = 1, .op = .lookup, .node = @intFromEnum(SelfFile.new), .data = "body" }, - .{ .tag = 2, .op = .getattr, .node = body }, - .{ .tag = 3, .op = .open, .node = body }, - .{ .tag = 4, .op = .read, .node = body, .size = 5 }, - .{ .tag = 5, .op = .release, .node = body, .handle = 1 }, - .{ .tag = 6, .op = .readdir, .node = @intFromEnum(SelfFile.root), .size = 4096 }, - .{ .tag = 7, .op = .open, .node = screen }, - .{ .tag = 8, .op = .read, .node = screen, .handle = 1, .size = 32 }, - .{ .tag = 9, .op = .release, .node = screen, .handle = 1 }, - }; - for (requests) |req| { - const answer = call(p, req); - try testing.expectEqual(Status.ok, answer.reply.status); - try testing.expect(std.meta.eql(waiting, p.look_hover_wait)); - try testing.expect(std.meta.eql(preview, p.look_hover_preview)); - try testing.expect(p.raw_hover_intent); - } - } - try testing.expectEqual(Status.ok, wr(p, body, "changed").reply.status); - try testing.expect(p.look_hover_wait == null); - try testing.expect(p.look_hover_preview == null); - try testing.expect(!p.raw_hover_intent); -} - -test "filesystem pane creation and truncation cancel Look hover" { - const requests = [_]Req{ - .{ .tag = 2, .op = .open, .node = factory_base + @intFromEnum(PaneFile.body) }, - .{ .tag = 3, .op = .setattr, .node = 0, .truncate = true }, - }; - for (requests) |request| { - const p = try withFile(testing.allocator, "word\n"); - defer p.deinit(); - p.look_hover_wait = .{ .col = 1, .row = 1, .pane = 0, .serial = serialOf(p) }; - p.raw_hover_intent = true; - var req = request; - if (req.op == .setattr) req.node = Node.of(serialOf(p), .body); - try testing.expectEqual(Status.ok, call(p, req).reply.status); - try testing.expect(p.look_hover_wait == null); - try testing.expect(p.look_hover_preview == null); - try testing.expect(!p.raw_hover_intent); - } -} - -test "terminal body handles keep one history snapshot across fragmented reads" { - const gpa = std.testing.allocator; - const p = try withTerm(gpa); - defer p.deinit(); - const node = Node.of(serialOf(p), .body); - p.update(.{ .output = .{ .pane = 0, .bytes = "old caf\xc3\xa9\r\nold tail" } }); - while (p.nextEffect()) |_| {} - const original = try panes.Terminal.screenTextAlloc(p.panes[0].?, gpa); - defer gpa.free(original); - const opened = call(p, .{ .tag = 1, .op = .open, .node = node }); - try testing.expectEqual(Status.ok, opened.reply.status); - const first = call(p, .{ .tag = 2, .op = .read, .node = node, .handle = opened.reply.handle, .size = 3 }); - try testing.expectEqualStrings(original[0..3], first.bytes); - p.update(.{ .output = .{ .pane = 0, .bytes = "\x1b[3J\x1b[2J\x1b[Hnew output" } }); - while (p.nextEffect()) |_| {} - var offset: usize = 3; - while (offset < original.len) { - const part = call(p, .{ .tag = 3, .op = .read, .node = node, .handle = opened.reply.handle, .off = offset, .size = 3 }); - try testing.expectEqualStrings(original[offset..][0..@min(3, original.len - offset)], part.bytes); - offset += part.bytes.len; - } - try testing.expectEqualStrings("", call(p, .{ .tag = 4, .op = .read, .node = node, .handle = opened.reply.handle, .off = original.len, .size = 3 }).bytes); - _ = call(p, .{ .tag = 5, .op = .release, .node = node, .handle = opened.reply.handle }); - const newer = call(p, .{ .tag = 6, .op = .open, .node = node }); - try testing.expectEqualStrings("new output", call(p, .{ .tag = 7, .op = .read, .node = node, .handle = newer.reply.handle, .size = 32 }).bytes); - _ = call(p, .{ .tag = 8, .op = .release, .node = node, .handle = newer.reply.handle }); -} - -test "an empty terminal body snapshot stays empty while output continues" { - const p = try withTerm(std.testing.allocator); - defer p.deinit(); - const node = Node.of(serialOf(p), .body); - const opened = call(p, .{ .tag = 1, .op = .open, .node = node }); - try testing.expectEqualStrings("", call(p, .{ .tag = 2, .op = .read, .node = node, .handle = opened.reply.handle, .size = 32 }).bytes); - try testing.expect(p.fs.snapshots[opened.reply.handle - 1].bytes != null); - p.update(.{ .output = .{ .pane = 0, .bytes = "new output" } }); - while (p.nextEffect()) |_| {} - try testing.expectEqualStrings("", call(p, .{ .tag = 3, .op = .read, .node = node, .handle = opened.reply.handle, .size = 32 }).bytes); - _ = call(p, .{ .tag = 4, .op = .release, .node = node, .handle = opened.reply.handle }); - const newer = call(p, .{ .tag = 5, .op = .open, .node = node }); - try testing.expectEqualStrings("new output", call(p, .{ .tag = 6, .op = .read, .node = node, .handle = newer.reply.handle, .size = 32 }).bytes); - _ = call(p, .{ .tag = 7, .op = .release, .node = node, .handle = newer.reply.handle }); -} - -test "terminal body snapshots are lazy bounded and released after the pane closes" { - const gpa = std.testing.allocator; - const p = try withTerm(gpa); - defer p.deinit(); - const node = Node.of(serialOf(p), .body); - var handles: [32]u32 = undefined; - for (&handles) |*opened_handle| { - const opened = call(p, .{ .tag = 1, .op = .open, .node = node }); - try testing.expectEqual(Status.ok, opened.reply.status); - opened_handle.* = opened.reply.handle; - } - for (p.fs.snapshots) |snapshot| { - try testing.expectEqual(node, snapshot.node); - try testing.expect(snapshot.bytes == null); - } - try testing.expectEqual(E.NFILE, call(p, .{ .tag = 2, .op = .open, .node = node }).errno()); - const scratch = call(p, .{ .tag = 2, .op = .open, .node = factory_base + @intFromEnum(PaneFile.body) }); - try testing.expectEqual(Status.ok, scratch.reply.status); - const scratch_id = p.paneBySerial(Node.target(scratch.reply.attr.node).?.pane.serial).?; - try testing.expect(p.panes[scratch_id].?.file != null); - _ = call(p, .{ .tag = 2, .op = .release, .node = scratch.reply.attr.node, .handle = scratch.reply.handle }); - p.update(.{ .output = .{ .pane = 0, .bytes = "latest output" } }); - while (p.nextEffect()) |_| {} - var failing = std.testing.FailingAllocator.init(gpa, .{ .fail_index = 0 }); - p.gpa = failing.allocator(); - const failed = call(p, .{ .tag = 3, .op = .read, .node = node, .handle = handles[0], .size = 32 }); - p.gpa = gpa; - try testing.expectEqual(E.NOMEM, failed.errno()); - try testing.expect(p.fs.snapshots[handles[0] - 1].bytes == null); - const first = call(p, .{ .tag = 4, .op = .read, .node = node, .handle = handles[0], .size = 32 }); - try testing.expectEqualStrings("latest output", first.bytes); - const saved = p.fs.snapshots[handles[0] - 1].bytes.?; - failing = std.testing.FailingAllocator.init(gpa, .{ .fail_index = 0 }); - p.gpa = failing.allocator(); - const second = call(p, .{ .tag = 5, .op = .read, .node = node, .handle = handles[0], .off = 7, .size = 32 }); - p.gpa = gpa; - try testing.expectEqualStrings("output", second.bytes); - try testing.expect(!failing.has_induced_failure); - try testing.expectEqual(saved.ptr, p.fs.snapshots[handles[0] - 1].bytes.?.ptr); - const screen = @intFromEnum(SelfFile.screen); - try testing.expectEqual(E.INVAL, call(p, .{ .tag = 6, .op = .read, .node = screen, .handle = handles[0], .size = 32 }).errno()); - _ = call(p, .{ .tag = 7, .op = .release, .node = screen, .handle = handles[0] }); - try testing.expectEqual(node, p.fs.snapshots[handles[0] - 1].node); - try p.removePane(0); - for (handles) |opened_handle| _ = call(p, .{ .tag = 8, .op = .release, .node = node, .handle = opened_handle }); - for (p.fs.snapshots) |snapshot| { - try testing.expectEqual(@as(u64, 0), snapshot.node); - try testing.expect(snapshot.bytes == null); - } -} - -test "screen snapshots preserve rendered cells and styles until their handle is released" { - const gpa = std.testing.allocator; - const p = try withFile(gpa, "const value = 1;\n"); - defer p.deinit(); - const node = @intFromEnum(SelfFile.screen); - const opened = call(p, .{ .tag = 1, .op = .open, .node = node }); - try testing.expectEqual(Status.ok, opened.reply.status); - const snapshot = p.fs.snapshots[opened.reply.handle - 1].bytes.?; - const original = try gpa.dupe(u8, snapshot); - defer gpa.free(original); - const parsed = try std.json.parseFromSlice(std.json.Value, gpa, original, .{}); - defer parsed.deinit(); - const data = parsed.value.object; - try testing.expectEqual(@as(i64, p.screen_w), data.get("cols").?.integer); - try testing.expectEqual(@as(i64, p.screen_h), data.get("rows").?.integer); - try testing.expectEqual(@as(usize, p.screen_w) * p.screen_h, data.get("cells").?.array.items.len); - try testing.expect(data.get("styles").?.array.items.len > 0); - _ = wr(p, Node.of(serialOf(p), .body), "changed\n"); - const newer = call(p, .{ .tag = 2, .op = .open, .node = node }); - try testing.expectEqual(Status.ok, newer.reply.status); - try testing.expect(!std.mem.eql(u8, original, p.fs.snapshots[newer.reply.handle - 1].bytes.?)); - var off: usize = 0; - while (off < original.len) { - const result = call(p, .{ .tag = 3, .op = .read, .node = node, .handle = opened.reply.handle, .off = off, .size = 13 }); - try testing.expectEqual(Status.ok, result.reply.status); - try testing.expectEqualSlices(u8, original[off..][0..@min(13, original.len - off)], result.bytes); - off += result.bytes.len; - } - _ = call(p, .{ .tag = 4, .op = .release, .node = node, .handle = opened.reply.handle }); - _ = call(p, .{ .tag = 5, .op = .release, .node = node, .handle = newer.reply.handle }); - for (p.fs.snapshots) |slot| try testing.expect(slot.node == 0); -} - -test "screen inspection preserves acknowledged presentation and the next real frame" { - const gpa = testing.allocator; - for (std.enums.values(pardes.layout.Transition)) |transition| { - errdefer std.debug.print("screen inspection during {s}\n", .{@tagName(transition)}); - const control = try withFile(gpa, "const value = 1;\n"); - defer control.deinit(); - const inspected = try withFile(gpa, "const value = 1;\n"); - defer inspected.deinit(); - var arena: std.heap.ArenaAllocator = .init(gpa); - defer arena.deinit(); - for ([_]*Pardes{ control, inspected }) |p| { - p.settings.panel_transition = .off; - p.update(.tick); - p.acknowledgePanelPresentation((try p.render(arena.allocator())).panelTracks()); - p.settings.panel_transition = transition; - } - for (0..4) |phase| { - for ([_]*Pardes{ control, inspected }) |p| switch (phase) { - 0 => {}, - 1 => p.update(.{ .command = "New" }), - 2 => { - p.update(.tick); - try testing.expectEqual(Status.ok, wr(p, Node.of(p.panes[p.active].?.serial, .body), "changed cells\n").reply.status); - }, - 3 => { - for (0..transition.frames() + 1) |_| p.update(.tick); - p.acknowledgePanelPresentation((try p.render(arena.allocator())).panelTracks()); - p.update(.{ .command = "Del" }); - }, - else => unreachable, - }; - const screen = @intFromEnum(SelfFile.screen); - for (0..2) |_| { - const opened = call(inspected, .{ .tag = 1, .op = .open, .node = screen }); - try testing.expectEqual(Status.ok, opened.reply.status); - const captured = call(inspected, .{ .tag = 2, .op = .read, .node = screen, .handle = opened.reply.handle, .size = 32 }); - try testing.expectEqual(Status.ok, captured.reply.status); - try testing.expect(captured.bytes.len > 0); - try testing.expectEqual(Status.ok, call(inspected, .{ - .tag = 3, - .op = .release, - .node = screen, - .handle = opened.reply.handle, - }).reply.status); - } - const a = &control.presentation; - const b = &inspected.presentation; - try testing.expectEqualDeep(a.shown, b.shown); - try testing.expectEqualDeep(a.shown_tracks, b.shown_tracks); - try testing.expectEqualDeep(a.shown_closing[0..a.shown_closing_len], b.shown_closing[0..b.shown_closing_len]); - try testing.expectEqual(a.pending, b.pending); - try testing.expectEqual(a.acknowledged, b.acknowledged); - try testing.expectEqual(a.previous_valid, b.previous_valid); - try testing.expectEqual(a.previous_cols, b.previous_cols); - try testing.expectEqual(a.previous_rows, b.previous_rows); - try testing.expectEqualDeep(a.previous_layout, b.previous_layout); - try testing.expectEqual(a.previous_cells.len, b.previous_cells.len); - for (a.previous_cells, b.previous_cells) |*expected, *actual| - try testing.expect(expected.visuallyEqual(actual)); - - const expected = try control.render(arena.allocator()); - const actual = try inspected.render(arena.allocator()); - try testing.expectEqual(expected.cols, actual.cols); - try testing.expectEqual(expected.rows, actual.rows); - try testing.expectEqualDeep(expected.cursor, actual.cursor); - try testing.expectEqualDeep(expected.panelTracks(), actual.panelTracks()); - try testing.expectEqualDeep(expected.cell_diffs, actual.cell_diffs); - try testing.expectEqual(expected.previous_cells.len, actual.previous_cells.len); - try testing.expectEqual(expected.cells.len, actual.cells.len); - try testing.expectEqual(@as(usize, 0), expected.nimages); - try testing.expectEqual(@as(usize, 0), actual.nimages); - for (expected.cells, actual.cells) |*left, *right| try testing.expect(left.visuallyEqual(right)); - for (expected.previous_cells, actual.previous_cells) |*left, *right| try testing.expect(left.visuallyEqual(right)); - if (phase == 1 and transition != .off) try testing.expect(expected.panelTracks().len > 0); - if (phase == 1 and transition.needsPreviousGrid()) try testing.expect(expected.hasPanelDiff()); - if (phase == 3 and transition == .vertical) try testing.expect(a.closing_len > 0); - control.acknowledgePanelPresentation(expected.panelTracks()); - inspected.acknowledgePanelPresentation(actual.panelTracks()); - try testing.expectEqualDeep(a.shown, b.shown); - try testing.expectEqualDeep(a.previous_layout, b.previous_layout); - _ = arena.reset(.retain_capacity); - } - } -} - -const testing = std.testing; - -const Answer = struct { - reply: Reply = .{ .tag = 0, .status = .err, .errno = E.IO }, - bytes: []const u8 = "", - saved: bool = false, - watch: ?bool = null, - pty_buf: [256]u8 = undefined, - pty_len: usize = 0, - winsize: ?struct { cols: u16, rows: u16 } = null, - signal: ?pardes.PtySignal = null, - spawned: bool = false, - - fn pty(a: *const Answer) []const u8 { - return a.pty_buf[0..a.pty_len]; - } - - fn errno(a: Answer) u16 { - return if (a.reply.status == .err) a.reply.errno else 0; - } -}; - -fn call(p: *Pardes, req: Req) Answer { - p.update(.{ .fs_req = req }); - var ans: Answer = .{}; - while (p.nextEffect()) |e| switch (e) { - .fs_reply => |r| { - ans.reply = r; - ans.bytes = p.fsPayload(r); - }, - .save_file, .save_text => ans.saved = true, - .watch => |w| ans.watch = w.on, - .write => |w| { - const b = w.bytes.slice(); - const n = @min(b.len, ans.pty_buf.len - ans.pty_len); - @memcpy(ans.pty_buf[ans.pty_len..][0..n], b[0..n]); - ans.pty_len += n; - }, - .resize_pty => |r| ans.winsize = .{ .cols = r.cols, .rows = r.rows }, - .signal_pty => |s| ans.signal = s.sig, - .spawn => ans.spawned = true, - else => {}, - }; - return ans; -} - -fn rd(p: *Pardes, node: u64, off: u64, size: u32) Answer { - return call(p, .{ .tag = 1, .op = .read, .node = node, .off = off, .size = size }); -} - -fn wr(p: *Pardes, node: u64, data: []const u8) Answer { - return call(p, .{ .tag = 2, .op = .write, .node = node, .data = data }); -} - -fn rdir(p: *Pardes, node: u64, skip: u64) Answer { - return call(p, .{ .tag = 4, .op = .readdir, .node = node, .off = skip, .size = 4096 }); -} - -fn look_up(p: *Pardes, dir: u64, name: []const u8) Answer { - return call(p, .{ .tag = 3, .op = .lookup, .node = dir, .data = name }); -} - -fn withFile(gpa: std.mem.Allocator, text: []const u8) !*Pardes { - const p = try Pardes.init(gpa, .{ .tty_only = true, .cols = 80, .rows = 24 }); - errdefer p.deinit(); - while (p.nextEffect()) |_| {} - _ = try p.setTestFile(text); - while (p.nextEffect()) |_| {} - return p; -} - -fn withTerm(gpa: std.mem.Allocator) !*Pardes { - const p = try Pardes.init(gpa, .{ .tty_only = true, .cols = 80, .rows = 24 }); - errdefer p.deinit(); - while (p.nextEffect()) |_| {} - std.debug.assert(p.panes[0].?.isTerminal()); - return p; -} - -fn serialOf(p: *Pardes) u32 { - return p.panes[0].?.serial; -} - -const Dirent = struct { node: u64, dir: bool, name: []const u8 }; - -fn dirents(bytes: []const u8, out: []Dirent) []Dirent { - var n: usize = 0; - var i: usize = 0; - while (i + 10 <= bytes.len and n < out.len) { - const node = std.mem.readInt(u64, bytes[i..][0..8], .little); - const kind = bytes[i + 8]; - const len = bytes[i + 9]; - i += 10; - if (i + len > bytes.len) break; - out[n] = .{ .node = node, .dir = kind == 1, .name = bytes[i .. i + len] }; - i += len; - n += 1; - } - return out[0..n]; -} - -fn nameAt(list: []const Dirent, want: []const u8) ?Dirent { - for (list) |d| if (std.mem.eql(u8, d.name, want)) return d; - return null; -} - -test "listener addresses are readable canonical dials with bounded partial reads" { - const gpa = testing.allocator; - const p = try Pardes.init(gpa, .{ .tty_only = true }); - defer p.deinit(); - p.fs.socket_path = "/tmp/a socket.sock"; - p.fs.tcp_address = .{ .ip4 = .loopback(5640) }; - p.fs.quic_address = .{ .ip6 = .loopback(5641) }; - const expected = "unix!/tmp/a socket.sock\ntcp!127.0.0.1!5640\nquic!::1!5641\n"; - for ([_][]const u8{ "/virtual/listeners", "/n/self/listeners" }) |path| { - const bytes = try read(p, path); - defer gpa.free(bytes); - try testing.expectEqualStrings(expected, bytes); - try testing.expectError(error.ReadOnlyFilesystem, write(p, path, "")); - } - const node = @intFromEnum(SelfFile.listeners); - var off: usize = 0; - while (off < expected.len) { - const part = rd(p, node, off, 3); - try testing.expectEqual(Status.ok, part.reply.status); - try testing.expectEqualStrings(expected[off..][0..@min(3, expected.len - off)], part.bytes); - off += part.bytes.len; - } - try testing.expectEqual(@as(usize, 0), rd(p, node, off, 3).bytes.len); -} - -test "readdir lists the root, a pane directory, and new/ without creating anything" { - const gpa = testing.allocator; - const p = try withFile(gpa, "hello\n"); - defer p.deinit(); - const serial = serialOf(p); - var buf: [32]Dirent = undefined; - - const root = rdir(p, @intFromEnum(SelfFile.root), 0); - try testing.expectEqual(Status.ok, root.reply.status); - const top = dirents(root.bytes, &buf); - try testing.expect(top.len >= 5); - try testing.expectEqualStrings("index", top[0].name); - try testing.expectEqualStrings("cons", top[1].name); - try testing.expectEqualStrings("new", top[2].name); - try testing.expect(top[2].dir and !top[0].dir); - try testing.expectEqualStrings("pane", top[3].name); - try testing.expect(top[3].dir); - try testing.expectEqual(namespace_panes, top[3].node); - var idbuf: [16]u8 = undefined; - try testing.expect(nameAt(top, try std.fmt.bufPrint(&idbuf, "{d}", .{serial})) == null); - try testing.expect(nameAt(top, "src") != null); - - const rest = rdir(p, @intFromEnum(SelfFile.root), 3); - try testing.expectEqual(top.len - 3, dirents(rest.bytes, &buf).len); - const eof = rdir(p, @intFromEnum(SelfFile.root), 99); - try testing.expectEqual(Status.ok, eof.reply.status); - try testing.expectEqual(@as(usize, 0), eof.bytes.len); - - const dir = rdir(p, Node.of(serial, .dir), 0); - const files = dirents(dir.bytes, &buf); - try testing.expectEqual(@as(usize, 10), files.len); - try testing.expect(nameAt(files, "addr") != null); - try testing.expect(nameAt(files, "xdata") != null); - try testing.expect(nameAt(files, ".") == null); - try testing.expectEqual(Node.of(serial, .body), nameAt(files, "body").?.node); - - const before = p.next_serial; - const new = rdir(p, @intFromEnum(SelfFile.new), 0); - try testing.expectEqual(Status.ok, new.reply.status); - const factories = dirents(new.bytes, &buf); - try testing.expectEqual(@as(usize, 11), factories.len); - try testing.expect(nameAt(factories, "README") != null); - for (factories) |entry| { - const inspected = look_up(p, @intFromEnum(SelfFile.new), entry.name); - try testing.expectEqual(Status.ok, inspected.reply.status); - try testing.expectEqual(entry.node, inspected.reply.attr.node); - try testing.expectEqual(Status.ok, call(p, .{ .tag = 1, .op = .getattr, .node = entry.node }).reply.status); - } - try testing.expectEqual(before, p.next_serial); - - try testing.expectEqual(E.NOTDIR, rdir(p, Node.of(serial, .body), 0).errno()); -} - -test "lookup resolves top files, pane serials and pane files" { - const gpa = testing.allocator; - const p = try withFile(gpa, "hello\n"); - defer p.deinit(); - const serial = serialOf(p); - const root = @intFromEnum(SelfFile.root); - - try testing.expectEqual(@as(u64, @intFromEnum(SelfFile.index)), look_up(p, root, "index").reply.attr.node); - try testing.expect(look_up(p, root, "new").reply.attr.dir); - try testing.expectEqual(E.NOENT, look_up(p, root, "nosuchthing").errno()); - - var idbuf: [16]u8 = undefined; - const serial_name = try std.fmt.bufPrint(&idbuf, "{d}", .{serial}); - try testing.expectEqual(E.NOENT, look_up(p, root, serial_name).errno()); - const dir = look_up(p, namespace_panes, serial_name); - try testing.expectEqual(Node.of(serial, .dir), dir.reply.attr.node); - try testing.expect(dir.reply.attr.dir); - try testing.expectEqual(E.NOENT, look_up(p, namespace_panes, "99999").errno()); - - const body = look_up(p, Node.of(serial, .dir), "body"); - try testing.expectEqual(Node.of(serial, .body), body.reply.attr.node); - const stat = call(p, .{ .tag = 4, .op = .getattr, .node = Node.of(serial, .body) }); - try testing.expectEqual(body.reply.attr.size, stat.reply.attr.size); - try testing.expectEqual(@as(u64, "hello\n".len), stat.reply.attr.size); - try testing.expectEqual(E.NOENT, look_up(p, Node.of(serial, .dir), "editout").errno()); - try testing.expectEqual(E.NOTDIR, look_up(p, Node.of(serial, .body), "x").errno()); -} - -test "new/ lookup is inert and each open creates a distinct pane" { - const gpa = testing.allocator; - const p = try withFile(gpa, "first\n"); - defer p.deinit(); - const before = serialOf(p); - - try testing.expectEqual(E.NOENT, look_up(p, @intFromEnum(SelfFile.new), "bogus").errno()); - try testing.expectEqual(before, p.next_serial); - - const a = look_up(p, @intFromEnum(SelfFile.new), "body"); - try testing.expectEqual(Status.ok, a.reply.status); - try testing.expectEqual(before, p.next_serial); - const opened = call(p, .{ .tag = 1, .op = .open, .node = a.reply.attr.node }); - try testing.expectEqual(Status.ok, opened.reply.status); - const made: Node = @bitCast(opened.reply.attr.node); - try testing.expect(made.serial != before); - try testing.expectEqual(@intFromEnum(PaneFile.body), made.file); - - _ = wr(p, opened.reply.attr.node, "hi"); - const second = call(p, .{ .tag = 2, .op = .open, .node = a.reply.attr.node }); - try testing.expectEqual(Status.ok, second.reply.status); - try testing.expect(second.reply.attr.node != opened.reply.attr.node); - const id = p.paneBySerial(@intCast(made.serial)).?; - try testing.expectEqualStrings("hi", p.panes[id].?.file.?.content); -} - -test "index prints winctlprint's five fields then the tag" { - const gpa = testing.allocator; - const p = try withFile(gpa, "hello\nthere\n"); - defer p.deinit(); - const pane = p.panes[0].?; - - const a = rd(p, @intFromEnum(SelfFile.index), 0, 4096); - try testing.expectEqual(Status.ok, a.reply.status); - var got: [512]u8 = undefined; - @memcpy(got[0..a.bytes.len], a.bytes); - const line = got[0..a.bytes.len]; - - const tag = try gpa.dupe(u8, tagOf(p, pane)); - defer gpa.free(tag); - var want: std.ArrayList(u8) = .empty; - defer want.deinit(gpa); - try want.print(gpa, "{d:>11} {d:>11} {d:>11} {d:>11} {d:>11} {s}\n", .{ - pane.serial, tag.len, @as(usize, "hello\nthere\n".len), 0, 0, firstLine(tag), - }); - try testing.expectEqualStrings(want.items, line); - try testing.expectEqual(@as(usize, 60), std.mem.indexOf(u8, line, firstLine(tag)).?); - - const mid = rd(p, @intFromEnum(SelfFile.index), 60, 5); - try testing.expectEqualStrings(firstLine(tag)[0..5], mid.bytes); - - pane.file.?.saved_revision = pane.file.?.revision -% 1; - const dirty = rd(p, @intFromEnum(SelfFile.index), 48, 12); - try testing.expectEqualStrings(" 1 ", dirty.bytes); -} - -test "ctl read is index's five fields plus width in cells, font and tab width" { - const gpa = testing.allocator; - const p = try withFile(gpa, "x\n"); - defer p.deinit(); - const pane = p.panes[0].?; - - const a = rd(p, Node.of(pane.serial, .ctl), 0, 4096); - try testing.expectEqual(Status.ok, a.reply.status); - var want: std.ArrayList(u8) = .empty; - defer want.deinit(gpa); - try want.print(gpa, "{d:>11} {d:>11} {d:>11} {d:>11} {d:>11} {d:>11} {s} {d:>11} ", .{ - pane.serial, tagOf(p, pane).len, @as(usize, 2), 0, 0, pane.cols, "default", config.tab_width, - }); - try testing.expectEqualStrings(want.items, a.bytes); - - var quoted: std.ArrayList(u8) = .empty; - defer quoted.deinit(gpa); - stageQuoted("ed, gpa, "DejaVu Sans Mono"); - try testing.expectEqualStrings("'DejaVu Sans Mono'", quoted.items); - quoted.clearRetainingCapacity(); - stageQuoted("ed, gpa, "it's"); - try testing.expectEqualStrings("'it''s'", quoted.items); -} - -test "body reads at any offset and writes append" { - const gpa = testing.allocator; - const p = try withFile(gpa, "one\ntwo\n"); - defer p.deinit(); - const serial = serialOf(p); - const body = Node.of(serial, .body); - - try testing.expectEqualStrings("one\ntwo\n", rd(p, body, 0, 100).bytes); - try testing.expectEqualStrings("two\n", rd(p, body, 4, 100).bytes); - try testing.expectEqualStrings("wo", rd(p, body, 5, 2).bytes); - try testing.expectEqualStrings("", rd(p, body, 999, 2).bytes); - try testing.expect(rd(p, body, 0, 100).bytes.ptr == p.panes[0].?.file.?.content.ptr); - - const w = call(p, .{ .tag = 5, .op = .write, .node = body, .off = 0, .data = "three\n" }); - try testing.expectEqual(@as(u32, 6), w.reply.written); - try testing.expectEqualStrings("one\ntwo\nthree\n", p.panes[0].?.file.?.content); - - const short = wr(p, body, "a\xC3"); - try testing.expectEqual(@as(u32, 1), short.reply.written); - try testing.expectEqualStrings("one\ntwo\nthree\na", p.panes[0].?.file.?.content); -} - -test "a body write to a terminal pane types at its shell" { - const gpa = testing.allocator; - const p = try Pardes.init(gpa, .{ .tty_only = true, .cols = 40, .rows = 10 }); - defer p.deinit(); - while (p.nextEffect()) |_| {} - const pane = p.panes[0].?; - try testing.expect(pane.isTerminal()); - - const a = wr(p, Node.of(pane.serial, .body), "ls -l\r"); - try testing.expectEqual(@as(u32, 6), a.reply.written); - try testing.expectEqualStrings("ls -l\r", a.pty()); - - const r = rd(p, Node.of(pane.serial, .body), 0, 64); - try testing.expectEqual(Status.ok, r.reply.status); -} - -test "tag reads the whole tag and writes append to the editable tail" { - const gpa = testing.allocator; - const p = try withFile(gpa, "x\n"); - defer p.deinit(); - const pane = p.panes[0].?; - const node = Node.of(pane.serial, .tag); - - const whole = rd(p, node, 0, 4096); - try testing.expect(std.mem.startsWith(u8, whole.bytes, "/test.txt")); - try testing.expect(std.mem.indexOf(u8, whole.bytes, "Del") != null); - - const before = rd(p, node, 0, 4096).bytes.len; - const w = wr(p, node, " Mine"); - try testing.expectEqual(@as(u32, 5), w.reply.written); - try testing.expect(std.mem.endsWith(u8, pane.tag_tail[0..pane.tag_tail_len], " Mine")); - const after = rd(p, node, 0, 4096); - try testing.expectEqual(before + 5, after.bytes.len); - try testing.expect(std.mem.endsWith(u8, after.bytes, " Mine")); - - pane.tag_tail_len = pane.tag_tail.len; - try testing.expectEqual(E.NOSPC, wr(p, node, "x").errno()); -} - -test "the address language, form by form" { - const gpa = testing.allocator; - const p = try withFile(gpa, "one\ntwo\nthree\n"); - defer p.deinit(); - const serial = serialOf(p); - const addr = Node.of(serial, .addr); - - const Case = struct { expr: []const u8, q0: u32, q1: u32 }; - for ([_]Case{ - .{ .expr = "#0", .q0 = 0, .q1 = 0 }, - .{ .expr = "#5", .q0 = 5, .q1 = 5 }, - .{ .expr = "0", .q0 = 0, .q1 = 0 }, - .{ .expr = "1", .q0 = 0, .q1 = 4 }, - .{ .expr = "2", .q0 = 4, .q1 = 8 }, - .{ .expr = "$", .q0 = 14, .q1 = 14 }, - .{ .expr = ",", .q0 = 0, .q1 = 14 }, - .{ .expr = "1,2", .q0 = 0, .q1 = 8 }, - .{ .expr = "#1,#4", .q0 = 1, .q1 = 4 }, - .{ .expr = "2+1", .q0 = 8, .q1 = 14 }, - .{ .expr = "$-1", .q0 = 8, .q1 = 14 }, - .{ .expr = "/two/", .q0 = 4, .q1 = 7 }, - .{ .expr = "/t.o/", .q0 = 4, .q1 = 7 }, - .{ .expr = "1\n", .q0 = 0, .q1 = 4 }, - }) |c| { - _ = wr(p, addr, "#0"); - const w = wr(p, addr, c.expr); - try testing.expectEqual(Status.ok, w.reply.status); - const got = rd(p, addr, 0, 64); - var want: [32]u8 = undefined; - try testing.expectEqualStrings( - try std.fmt.bufPrint(&want, "{d:>11} {d:>11} ", .{ c.q0, c.q1 }), - got.bytes, - ); - } - - _ = wr(p, addr, "1"); - _ = wr(p, addr, "."); - try testing.expectEqual(@as(u32, 0), p.fs.panes[0].addr.q0); - try testing.expectEqual(@as(u32, 4), p.fs.panes[0].addr.q1); - - _ = wr(p, addr, "$"); - _ = wr(p, addr, "?o?"); - try testing.expectEqual(@as(u32, 6), p.fs.panes[0].addr.q0); // the `o` in "two" - try testing.expectEqual(@as(u32, 7), p.fs.panes[0].addr.q1); - - _ = wr(p, addr, "1"); - _ = wr(p, Node.of(serial, .ctl), "limit=addr\n"); - _ = wr(p, addr, "#0"); - try testing.expectEqual(E.INVAL, wr(p, addr, "/three/").errno()); - _ = wr(p, Node.of(serial, .ctl), "clean\n"); - _ = call(p, .{ .tag = 6, .op = .open, .node = Node.of(serial, .ctl) }); - try testing.expect(p.fs.panes[0].limit == null); - _ = wr(p, addr, "#0"); - try testing.expectEqual(Status.ok, wr(p, addr, "/three/").reply.status); - - for ([_][]const u8{ "zzz", "#", "//", "/nomatch/", "1 2", "99", "/a\\" }) |bad| { - _ = wr(p, addr, "#0"); - try testing.expectEqual(E.INVAL, wr(p, addr, bad).errno()); - } - - const nested = "," ** 4096; - _ = wr(p, addr, "#0"); - try testing.expectEqual(E.INVAL, wr(p, addr, nested).errno()); -} - -test "data and xdata read from addr, move it, and write through it" { - const gpa = testing.allocator; - const p = try withFile(gpa, "one\ntwo\n"); - defer p.deinit(); - const serial = serialOf(p); - const addr = Node.of(serial, .addr); - const data = Node.of(serial, .data); - const xdata = Node.of(serial, .xdata); - - _ = wr(p, addr, "#0"); - try testing.expectEqualStrings("one", rd(p, data, 0, 3).bytes); - try testing.expectEqual(@as(u32, 3), p.fs.panes[0].addr.q0); - try testing.expectEqual(@as(u32, 3), p.fs.panes[0].addr.q1); - - _ = wr(p, addr, "1"); - try testing.expectEqualStrings("one\n", rd(p, xdata, 0, 100).bytes); - _ = wr(p, addr, "1"); - try testing.expectEqualStrings("one\ntwo\n", rd(p, data, 0, 100).bytes); - - _ = wr(p, addr, "1"); - const w = wr(p, data, "ONE\n"); - try testing.expectEqual(@as(u32, 4), w.reply.written); - try testing.expectEqualStrings("ONE\ntwo\n", p.panes[0].?.file.?.content); - try testing.expectEqual(@as(u32, 4), p.fs.panes[0].addr.q0); -} - -test "data never splits a grapheme, in either direction" { - const gpa = testing.allocator; - const p = try withFile(gpa, "\u{00e9}x\n"); - defer p.deinit(); - const serial = serialOf(p); - _ = wr(p, Node.of(serial, .addr), "#0"); - try testing.expectEqualStrings("", rd(p, Node.of(serial, .data), 0, 1).bytes); - _ = wr(p, Node.of(serial, .addr), "#0"); - try testing.expectEqualStrings("\u{00e9}", rd(p, Node.of(serial, .data), 0, 2).bytes); - - _ = wr(p, Node.of(serial, .addr), "#0"); - try testing.expectEqual(@as(u32, 1), wr(p, Node.of(serial, .data), "a\xC3").reply.written); -} - -test "rdsel reads the selection and wrsel replaces it" { - const gpa = testing.allocator; - const p = try withFile(gpa, "one\ntwo\n"); - defer p.deinit(); - const serial = serialOf(p); - const ctl = Node.of(serial, .ctl); - - _ = wr(p, Node.of(serial, .addr), "#0,#3"); - try testing.expectEqual(Status.ok, wr(p, ctl, "dot=addr\n").reply.status); - try testing.expectEqualStrings("one", rd(p, Node.of(serial, .rdsel), 0, 100).bytes); - - _ = wr(p, ctl, "addr=dot\n"); - try testing.expectEqual(@as(u32, 0), p.fs.panes[0].addr.q0); - try testing.expectEqual(@as(u32, 3), p.fs.panes[0].addr.q1); - - try testing.expectEqual(Status.ok, wr(p, Node.of(serial, .wrsel), "ONE").reply.status); - try testing.expectEqualStrings("ONE\ntwo\n", p.panes[0].?.file.?.content); - _ = wr(p, Node.of(serial, .wrsel), "!"); - try testing.expectEqualStrings("ONE!\ntwo\n", p.panes[0].?.file.?.content); -} - -test "every ctl verb, and every refusal" { - const gpa = testing.allocator; - const p = try withFile(gpa, "one\ntwo\n"); - defer p.deinit(); - const serial = serialOf(p); - const ctl = Node.of(serial, .ctl); - const pane = p.panes[0].?; - const pf = &p.fs.panes[0]; - - try testing.expectEqual(Status.ok, wr(p, ctl, "nomark\nnoscroll\ndirty\n").reply.status); - try testing.expect(pf.nomark and pf.noscroll and dirtyOf(pane)); - try testing.expectEqual(Status.ok, wr(p, ctl, "mark\nscroll\nclean\n").reply.status); - try testing.expect(!pf.nomark and !pf.noscroll and !dirtyOf(pane)); - - _ = wr(p, ctl, "cleartag\n"); - try testing.expectEqual(@as(usize, 0), pane.tag_tail_len); - - _ = wr(p, Node.of(serial, .addr), "2"); - _ = wr(p, ctl, "limit=addr\n"); - try testing.expectEqual(@as(u32, 4), pf.limit.?.q0); - _ = wr(p, ctl, "dot=addr\nshow\n"); - try testing.expectEqual(@as(i32, 1), pane.cur_row); - - try testing.expectEqual(Status.ok, wr(p, ctl, "name /tmp/renamed.txt\n").reply.status); - try testing.expectEqualStrings("/tmp/renamed.txt", pane.file.?.path); - try testing.expectEqual(E.INVAL, wr(p, ctl, "name two words\n").errno()); - try testing.expectEqual(E.INVAL, wr(p, ctl, "name\n").errno()); - try testing.expectEqualStrings("/tmp/renamed.txt", pane.file.?.path); - - try testing.expectEqual(Status.ok, wr(p, ctl, "put\n").reply.status); - try testing.expectEqualStrings(pane.file.?.content, p.fallback.get("/tmp/renamed.txt").?); - - for ([_][]const u8{ - "menu", "nomenu", "dump echo hi", "dumpdir /tmp", "font Go Mono", "lock", "unlock", "bogus", "DEL", - }) |bad| try testing.expectEqual(E.INVAL, wr(p, ctl, bad).errno()); - - try testing.expect(!dirtyOf(pane)); - try testing.expectEqual(E.INVAL, wr(p, ctl, "dirty\nbogus\n").errno()); - try testing.expect(!dirtyOf(pane)); -} - -test "ctl look opens spaced paths and locations without editing the source pane" { - if (!platform_has_fs) return error.SkipZigTest; - const gpa = testing.allocator; - var tmp = testing.tmpDir(.{}); - defer tmp.cleanup(); - try tmp.dir.writeFile(testing.io, .{ .sub_path = "two words.zig", .data = "first\nsecond\nthird\n" }); - var path_buf: [4096]u8 = undefined; - const path = path_buf[0..try tmp.dir.realPathFile(testing.io, "two words.zig", &path_buf)]; - const p = try withFile(gpa, "source stays intact\n"); - defer p.deinit(); - const source = p.panes[0].?; - const ctl = Node.of(source.serial, .ctl); - const revision = source.file.?.revision; - const undo_len = source.file.?.history.undo_len; - source.cur_col = 3; - var command: [4200]u8 = undefined; - try testing.expectEqual(Status.ok, wr(p, ctl, try std.fmt.bufPrint(&command, "look {s}:2:3\n", .{path})).reply.status); - const opened = p.panes[p.active].?; - try testing.expect(opened != source); - try testing.expectEqualStrings(path, opened.file.?.path); - try testing.expectEqualStrings("first\nsecond\nthird\n", opened.file.?.content); - try testing.expectEqual(@as(i32, 1), opened.cur_row); - try testing.expectEqual(@as(i32, 2), opened.cur_col); - try testing.expectEqualStrings("source stays intact\n", source.file.?.content); - try testing.expectEqual(revision, source.file.?.revision); - try testing.expectEqual(undo_len, source.file.?.history.undo_len); - try testing.expectEqual(@as(i32, 3), source.cur_col); - - try testing.expectEqual(Status.ok, wr(p, ctl, try std.fmt.bufPrint(&command, "look {s}:3:2\n", .{path})).reply.status); - try testing.expect(p.panes[p.active].? == opened); - try testing.expectEqual(@as(i32, 2), opened.cur_row); - try testing.expectEqual(@as(i32, 1), opened.cur_col); -} - -test "ctl look validates the whole batch before opening virtual files" { - const gpa = testing.allocator; - const p = try withFile(gpa, "source\n"); - defer p.deinit(); - const source = p.panes[0].?; - const ctl = Node.of(source.serial, .ctl); - const serial = p.next_serial; - for ([_][]const u8{ - "look", "look \t", "look /virtual/index\x00ignored", "look /virtual/index\nbogus\n", - }) |invalid| { - try testing.expectEqual(E.INVAL, wr(p, ctl, invalid).errno()); - try testing.expectEqual(serial, p.next_serial); - try testing.expectEqual(@as(usize, 0), p.active); - try testing.expectEqualStrings("source\n", source.file.?.content); - } - try testing.expectEqual(Status.ok, wr(p, ctl, "look /n/self/index\n").reply.status); - const opened = p.panes[p.active].?; - try testing.expectEqualStrings("/virtual/index", opened.file.?.path); - try testing.expect(std.mem.indexOf(u8, opened.file.?.content, "/test.txt") != null); - try testing.expectEqualStrings("source\n", source.file.?.content); -} - -test "ctl name promotes a scratch without changing its body or undo history" { - const gpa = testing.allocator; - const p = try withFile(gpa, "opener\n"); - defer p.deinit(); - _ = call(p, .{ .tag = 1, .op = .open, .node = factory_base + @intFromEnum(PaneFile.ctl) }); - const pane = p.panes[p.active].?; - const ctl = Node.of(pane.serial, .ctl); - const body = Node.of(pane.serial, .body); - _ = wr(p, body, "scratch "); - _ = wr(p, body, "work\n"); - const undo_len = pane.file.?.history.undo_len; - var tmp = testing.tmpDir(.{}); - defer tmp.cleanup(); - try tmp.dir.writeFile(testing.io, .{ .sub_path = "renamed.zig", .data = "existing target\n" }); - var directory_buf: [4096]u8 = undefined; - const directory = directory_buf[0..try tmp.dir.realPath(testing.io, &directory_buf)]; - var path_buffer: [4096]u8 = undefined; - const path = try std.fmt.bufPrint(&path_buffer, "{s}/renamed.zig", .{directory}); - var command: [4104]u8 = undefined; - const renamed = wr(p, ctl, try std.fmt.bufPrint(&command, "name {s}\n", .{path})); - try testing.expectEqual(Status.ok, renamed.reply.status); - try testing.expectEqual(false, renamed.watch.?); - try testing.expectEqualStrings("scratch work\n", pane.file.?.content); - try testing.expectEqual(undo_len, pane.file.?.history.undo_len); - try testing.expect(pane.file.?.output == null and dirtyOf(pane)); - try testing.expect(pane.file.?.watch_after_save); - const target = try readFile(gpa, path); - defer gpa.free(target); - try testing.expectEqualStrings("existing target\n", target); - const saved = wr(p, ctl, "put\n"); - try testing.expectEqual(Status.ok, saved.reply.status); - try testing.expectEqual(true, saved.watch.?); - try testing.expect(!dirtyOf(pane) and !pane.file.?.watch_after_save); - try testing.expectEqualStrings("scratch work\n", p.fallback.get(path).?); -} - -test "ctl name refreshes cached syntax for unchanged contents" { - if (!pardes.syntax.enabled) return error.SkipZigTest; - pardes.syntax.start(testing.allocator); - defer pardes.syntax.stop(); - const p = try withFile(testing.allocator, "fn check() void {}\n"); - defer p.deinit(); - const pane = p.panes[0].?; - panes.File.refreshHighlights(p); - try testing.expectEqual(@as(usize, 0), pane.file.?.highlights.len); - try testing.expectEqual(Status.ok, wr(p, Node.of(pane.serial, .ctl), "name renamed.zig\n").reply.status); - panes.File.refreshHighlights(p); - try testing.expect(pane.file.?.highlights.len >= 2); - try testing.expectEqual(@intFromEnum(pardes.syntax.Syn.keyword), pane.file.?.highlights[0]); - try testing.expectEqual(@intFromEnum(pardes.syntax.Syn.keyword), pane.file.?.highlights[1]); - try testing.expectEqualStrings("fn check() void {}\n", pane.file.?.content); -} - -test "ctl relative names use the file directory and can name a new target" { - const gpa = testing.allocator; - const p = try withFile(gpa, "retained body\n"); - defer p.deinit(); - var tmp = testing.tmpDir(.{}); - defer tmp.cleanup(); - try tmp.dir.writeFile(testing.io, .{ .sub_path = "note.txt", .data = "from pane directory\n" }); - var directory_buf: [4096]u8 = undefined; - const directory = directory_buf[0..try tmp.dir.realPath(testing.io, &directory_buf)]; - const pane = p.panes[0].?; - const ctl = Node.of(pane.serial, .ctl); - var command: [4140]u8 = undefined; - try testing.expectEqual(Status.ok, wr(p, ctl, try std.fmt.bufPrint(&command, "name {s}/old.txt\n", .{directory})).reply.status); - try testing.expectEqual(Status.ok, wr(p, ctl, "name child/../note.txt\nget\n").reply.status); - try testing.expectEqualStrings("from pane directory\n", pane.file.?.content); - try testing.expectEqualStrings(directory, Pardes.paneDir(pane)); - try testing.expectEqual(Status.ok, wr(p, ctl, "name ./created.txt\nput\n").reply.status); - try testing.expect(!dirtyOf(pane)); - var expected_buf: [4096]u8 = undefined; - const expected = try std.fmt.bufPrint(&expected_buf, "{s}/created.txt", .{directory}); - try testing.expectEqualStrings(expected, pane.file.?.path); - try testing.expectEqualStrings(pane.file.?.content, p.fallback.get(expected).?); -} - -test "ctl relative names follow inherited scratch and virtual directories" { - const p = try withFile(testing.allocator, "source body\n"); - defer p.deinit(); - const source = p.panes[0].?; - try testing.expectEqual(Status.ok, wr(p, Node.of(source.serial, .ctl), "name /project/src/source.zig\n").reply.status); - _ = call(p, .{ .tag = 1, .op = .open, .node = factory_base + @intFromEnum(PaneFile.ctl) }); - const scratch = p.panes[p.active].?; - const ctl = Node.of(scratch.serial, .ctl); - try testing.expectEqualStrings("/project/src", Pardes.paneDir(scratch)); - try testing.expectEqual(Status.ok, wr(p, ctl, "name ../out/./notes.txt\n").reply.status); - try testing.expectEqualStrings("/project/out/notes.txt", scratch.file.?.path); - try testing.expectEqualStrings("/project/out", Pardes.paneDir(scratch)); - var command: [256]u8 = undefined; - try testing.expectEqual(Status.ok, wr(p, ctl, try std.fmt.bufPrint(&command, "name /virtual/pane/{d}/./body\nget\n", .{source.serial})).reply.status); - try testing.expectEqualStrings(source.file.?.content, scratch.file.?.content); - const unchanged = wr(p, ctl, "name ./body\n"); - try testing.expectEqual(Status.ok, unchanged.reply.status); - try testing.expect(unchanged.watch == null); - try testing.expect(!dirtyOf(scratch)); - try testing.expect(!scratch.file.?.watch_after_save); -} - -test "ctl get reloads the pane from disk and del honours a dirty body" { - const gpa = testing.allocator; - var tmp = testing.tmpDir(.{}); - defer tmp.cleanup(); - try tmp.dir.writeFile(testing.io, .{ .sub_path = "note.txt", .data = "from disk\n" }); - var directory_buf: [4096]u8 = undefined; - const directory = directory_buf[0..try tmp.dir.realPath(testing.io, &directory_buf)]; - var path_buf: [4096]u8 = undefined; - const path = try std.fmt.bufPrint(&path_buf, "{s}/note.txt", .{directory}); - - const p = try withFile(gpa, "in memory\n"); - defer p.deinit(); - const serial = serialOf(p); - const ctl = Node.of(serial, .ctl); - const pane = p.panes[0].?; - - var name: [std.fs.max_path_bytes + 8]u8 = undefined; - _ = wr(p, ctl, try std.fmt.bufPrint(&name, "name {s}\n", .{path})); - try testing.expectEqual(Status.ok, wr(p, ctl, "get\n").reply.status); - try testing.expectEqualStrings("from disk\n", pane.file.?.content); - try testing.expect(!dirtyOf(pane)); - try testing.expect(pane.file.?.history.undo_len > 0); - - _ = wr(p, ctl, "dirty\n"); - try testing.expectEqual(E.INVAL, wr(p, ctl, "del\n").errno()); - try testing.expect(p.paneBySerial(serial) != null); - _ = call(p, .{ .tag = 1, .op = .open, .node = factory_base + @intFromEnum(PaneFile.body) }); - try testing.expectEqual(Status.ok, wr(p, ctl, "delete\n").reply.status); - try testing.expect(p.paneBySerial(serial) == null); -} - -test "ctl get reports missing files without losing dirty contents or applying del" { - const p = try withFile(testing.allocator, "unsaved contents\n"); - defer p.deinit(); - var tmp = testing.tmpDir(.{}); - defer tmp.cleanup(); - var directory_buf: [4096]u8 = undefined; - const directory = directory_buf[0..try tmp.dir.realPath(testing.io, &directory_buf)]; - var name: [4140]u8 = undefined; - const ctl = Node.of(serialOf(p), .ctl); - try testing.expectEqual(Status.ok, wr(p, ctl, try std.fmt.bufPrint(&name, "name {s}/missing.txt\ndirty\n", .{directory})).reply.status); - try testing.expectEqual(E.NOENT, wr(p, ctl, "get\ndel\n").errno()); - const pane = p.panes[0].?; - try testing.expectEqualStrings("unsaved contents\n", pane.file.?.content); - try testing.expect(dirtyOf(pane)); -} - -test "ctl put waits for one host write and stops before del when saving fails" { - const Refusing = struct { - p: *Pardes, - calls: usize = 0, - - fn writeFile(ctx: ?*anyopaque, id: u8, _: []const u8, _: []const u8) void { - const self: *@This() = @ptrCast(@alignCast(ctx.?)); - self.calls += 1; - self.p.saveFailed(id, "save", error.PermissionDenied); - } - }; - const p = try withFile(testing.allocator, "retained contents\n"); - defer p.deinit(); - var refusing: Refusing = .{ .p = p }; - p.host = .{ .ctx = &refusing, .vtable = &.{ .write_file = Refusing.writeFile } }; - const serial = serialOf(p); - const ctl = Node.of(serial, .ctl); - for ([_][]const u8{ "clean\n", "dirty\n" }, 0..) |initial, i| { - _ = wr(p, ctl, initial); - const result = wr(p, ctl, "put\ndel\n"); - try testing.expectEqual(E.IO, result.errno()); - try testing.expect(!result.saved); - try testing.expectEqual(i + 1, refusing.calls); - const pane = p.panes[p.paneBySerial(serial).?].?; - try testing.expect(dirtyOf(pane)); - try testing.expectEqualStrings("retained contents\n", pane.file.?.content); - } -} - -test "self directories walk to their namespace parents" { - const p = try withFile(testing.allocator, "contents\n"); - defer p.deinit(); - const root = @intFromEnum(SelfFile.root); - for ([_]struct { node: u64, parent: u64 }{ - .{ .node = root, .parent = namespace_root }, - .{ .node = @intFromEnum(SelfFile.new), .parent = root }, - .{ .node = namespace_panes, .parent = root }, - .{ .node = Node.of(serialOf(p), .dir), .parent = namespace_panes }, - }) |case| { - const result = look_up(p, case.node, ".."); - try testing.expectEqual(Status.ok, result.reply.status); - try testing.expectEqual(case.parent, result.reply.attr.node); - } -} - -test "errors and cons append to one +Errors buffer per directory" { - const gpa = testing.allocator; - const p = try withFile(gpa, "x\n"); - defer p.deinit(); - const serial = serialOf(p); - - const live = for (p.panes) |slot| { - if (slot) |q| if (q.file) |f| if (f.output) |o| if (std.meta.activeTag(o.from) == .errors) break q; - } else null; - try testing.expect(live == null); - - try testing.expectEqual(Status.ok, wr(p, Node.of(serial, .errors), "boom\n").reply.status); - _ = wr(p, @intFromEnum(SelfFile.cons), "again\n"); - - var found: usize = 0; - for (p.panes) |slot| { - const q = slot orelse continue; - const f = q.file orelse continue; - const o = f.output orelse continue; - if (std.meta.activeTag(o.from) != .errors) continue; - found += 1; - try testing.expectEqualStrings("boom\nagain\n", f.content); - try testing.expectEqualStrings("/+Errors", f.path); - } - try testing.expectEqual(@as(usize, 1), found); -} - -test "setattr truncation empties the body and answers fresh attributes" { - const gpa = testing.allocator; - const p = try withFile(gpa, "one\ntwo\n"); - defer p.deinit(); - const serial = serialOf(p); - - const a = call(p, .{ .tag = 7, .op = .setattr, .node = Node.of(serial, .body), .truncate = true }); - try testing.expectEqual(Status.ok, a.reply.status); - try testing.expectEqual(@as(u64, 0), a.reply.attr.size); - try testing.expectEqualStrings("", p.panes[0].?.file.?.content); - - _ = wr(p, Node.of(serial, .body), "new text\n"); - try testing.expectEqualStrings("new text\n", p.panes[0].?.file.?.content); - - const noop = call(p, .{ .tag = 8, .op = .setattr, .node = Node.of(serial, .body) }); - try testing.expectEqual(@as(u64, 9), noop.reply.attr.size); -} - -test "event records are acme's bytes, one per read, and .again when empty" { - const gpa = testing.allocator; - const p = try withFile(gpa, "Msg fs-ran\n"); - defer p.deinit(); - const serial = serialOf(p); - const event = Node.of(serial, .event); - - _ = noteAction(p, 0, .body_exec, 1, 4, flag_builtin, "sg "); - try testing.expect(p.fs.panes[0].events.empty()); - - const h = call(p, .{ .tag = 10, .op = .open, .node = event }); - try testing.expect(h.reply.handle != 0); - try testing.expectEqual(@as(u16, 1), p.fs.listeners); - - try testing.expectEqual(Status.again, rd(p, event, 0, 4096).reply.status); - - p.fs.origin = 'M'; - _ = noteAction(p, 0, .body_exec, 1, 4, flag_builtin, "ell"); - _ = noteAction(p, 0, .body_delete, 0, 3, 0, ""); - try testing.expectEqualStrings("MX1 4 1 3 ell\n", rd(p, event, 0, 4096).bytes); - try testing.expectEqualStrings("MD0 3 0 0 \n", rd(p, event, 0, 4096).bytes); - try testing.expectEqual(Status.again, rd(p, event, 0, 4096).reply.status); - - _ = noteAction(p, 0, .body_look, 0, 3, flag_filename, "one"); - try testing.expectEqual(E.INVAL, rd(p, event, 0, 4).errno()); - try testing.expectEqualStrings("ML0 3 4 3 one\n", rd(p, event, 0, 4096).bytes); - - const big = "z" ** max_record_text; - _ = noteAction(p, 0, .body_exec, 0, max_record_text, 0, big); - try testing.expectEqualStrings("MX0 256 0 0 \n", rd(p, event, 0, 4096).bytes); - - _ = call(p, .{ .tag = 11, .op = .release, .node = event, .handle = h.reply.handle }); - try testing.expectEqual(@as(u16, 0), p.fs.listeners); -} - -fn drainEvents(p: *Pardes, node: u64, store: []u8, out: [][]const u8) [][]const u8 { - var used: usize = 0; - var n: usize = 0; - while (n < out.len) { - const a = rd(p, node, 0, 4096); - if (a.reply.status != .ok) break; - @memcpy(store[used..][0..a.bytes.len], a.bytes); - out[n] = store[used..][0..a.bytes.len]; - used += a.bytes.len; - n += 1; - } - return out[0..n]; -} - -test "a write through the filesystem is reported once, attributed to the file it came through" { - const gpa = testing.allocator; - const p = try withFile(gpa, "one\ntwo\n"); - defer p.deinit(); - const serial = serialOf(p); - const event = Node.of(serial, .event); - _ = call(p, .{ .tag = 40, .op = .open, .node = event }); - var store: [4096]u8 = undefined; - var slots: [16][]const u8 = undefined; - _ = drainEvents(p, event, &store, &slots); - - _ = wr(p, Node.of(serial, .body), "three\n"); - const body_recs = drainEvents(p, event, &store, &slots); - try testing.expect(body_recs.len >= 1); - try testing.expectEqualStrings("EI8 14 0 6 three\n\n", body_recs[0]); - for (body_recs[1..]) |r| { - try testing.expectEqual(@as(u8, 'E'), r[0]); - try testing.expect(Action.fromChar(r[1]).?.onTag()); - } - - _ = wr(p, Node.of(serial, .addr), "1"); - _ = wr(p, Node.of(serial, .data), "ONE\n"); - const data_recs = drainEvents(p, event, &store, &slots); - try testing.expectEqual(@as(usize, 2), data_recs.len); - try testing.expectEqualStrings("FD0 3 0 0 \n", data_recs[0]); - try testing.expectEqualStrings("FI0 3 0 3 ONE\n", data_recs[1]); - try testing.expectEqual(Status.again, rd(p, event, 0, 4096).reply.status); -} - -test "two event readers each count once, and the second closing leaves the first" { - const gpa = testing.allocator; - const p = try withFile(gpa, "x\n"); - defer p.deinit(); - const event = Node.of(serialOf(p), .event); - - _ = call(p, .{ .tag = 12, .op = .open, .node = event }); - _ = call(p, .{ .tag = 13, .op = .open, .node = event }); - try testing.expectEqual(@as(u16, 2), p.fs.panes[0].readers); - try testing.expectEqual(@as(u16, 2), p.fs.listeners); - - _ = call(p, .{ .tag = 14, .op = .release, .node = event }); - try testing.expectEqual(@as(u16, 1), p.fs.panes[0].readers); - try testing.expect(p.fs.scripted(0)); - - _ = call(p, .{ .tag = 15, .op = .release, .node = Node.of(serialOf(p), .body) }); - try testing.expectEqual(@as(u16, 1), p.fs.listeners); - - _ = call(p, .{ .tag = 16, .op = .release, .node = event }); - try testing.expectEqual(@as(u16, 0), p.fs.listeners); - try testing.expect(!p.fs.scripted(0)); - _ = call(p, .{ .tag = 17, .op = .release, .node = event }); - try testing.expectEqual(@as(u16, 0), p.fs.listeners); -} - -test "a pane deleted while its event file is open leaves no suppression behind" { - const gpa = testing.allocator; - const p = try withFile(gpa, "x\n"); - defer p.deinit(); - const serial = serialOf(p); - const event = Node.of(serial, .event); - _ = call(p, .{ .tag = 1, .op = .open, .node = factory_base + @intFromEnum(PaneFile.body) }); - - const a = call(p, .{ .tag = 18, .op = .open, .node = event }); - const b = call(p, .{ .tag = 19, .op = .open, .node = event }); - try testing.expectEqual(@as(u16, 2), p.fs.listeners); - - _ = wr(p, Node.of(serial, .ctl), "delete\n"); - try testing.expect(p.paneBySerial(serial) == null); - try testing.expectEqual(@as(u16, 0), p.fs.listeners); - - _ = call(p, .{ .tag = 20, .op = .release, .node = event, .handle = a.reply.handle }); - _ = call(p, .{ .tag = 21, .op = .release, .node = event, .handle = b.reply.handle }); - try testing.expectEqual(@as(u16, 0), p.fs.listeners); - - try testing.expectEqual(E.NOENT, rd(p, event, 0, 64).errno()); - try testing.expectEqual(E.NOENT, rd(p, Node.of(serial, .body), 0, 64).errno()); - try testing.expectEqual(E.NOENT, wr(p, Node.of(serial, .ctl), "clean\n").errno()); - try testing.expectEqual(E.NOENT, call(p, .{ .tag = 22, .op = .open, .node = event }).errno()); -} - -test "writing an event record back performs the action it names" { - const gpa = testing.allocator; - const p = try withFile(gpa, "Msg fs-ran\n"); - defer p.deinit(); - const serial = serialOf(p); - const event = Node.of(serial, .event); - const pane = p.panes[0].?; - - const w = wr(p, event, "FX0 10\n"); - try testing.expectEqual(Status.ok, w.reply.status); - try testing.expectEqualStrings("fs-ran", pane.msg[0..pane.msg_len]); - - pane.msg_len = 0; - try testing.expectEqual(Status.ok, wr(p, event, "FX0 10\nFX0 10\n").reply.status); - try testing.expectEqualStrings("fs-ran", pane.msg[0..pane.msg_len]); - - pane.msg_len = 0; - for ([_][]const u8{ - "FX0 10\nFQ0 1\n", // unknown type character - "FX0 999\n", // out of range - "FX0 10", // no newline - "FX5 1\n", // q0 > q1 - "FD0 3\n", // a report, not a request - "F\n", - }) |bad| { - try testing.expectEqual(E.INVAL, wr(p, event, bad).errno()); - try testing.expectEqual(@as(usize, 0), pane.msg_len); - } - - _ = call(p, .{ .tag = 23, .op = .open, .node = event }); - p.fs.origin = 'K'; - _ = wr(p, event, "KX0 10\n"); - try testing.expectEqual(@as(u8, 'F'), p.fs.origin); -} - -test "a pane that is not a terminal has no pty/ at all" { - const gpa = testing.allocator; - const p = try withFile(gpa, "hello\n"); - defer p.deinit(); - const serial = serialOf(p); - const dir = Node.of(serial, .dir); - - try testing.expectEqual(E.NOENT, look_up(p, dir, "pty").errno()); - try testing.expectEqual(E.NOENT, call(p, .{ - .tag = 1, - .op = .getattr, - .node = Node.of(serial, .pty), - }).errno()); - try testing.expectEqual(E.NOENT, rd(p, Node.of(serial, .pty_status), 0, 256).errno()); - try testing.expectEqual(E.NOENT, wr(p, Node.of(serial, .pty_ctl), "winsize 80 24\n").errno()); - try testing.expectEqual(E.NOENT, rdir(p, Node.of(serial, .pty), 0).errno()); - try testing.expectEqual(E.NOENT, call(p, .{ - .tag = 2, - .op = .open, - .node = Node.of(serial, .pty_data), - }).errno()); - try testing.expectEqual(@as(u16, 0), p.fs.panes[0].pty_readers); - - var buf: [32]Dirent = undefined; - const files = dirents(rdir(p, dir, 0).bytes, &buf); - try testing.expectEqual(@as(usize, 10), files.len); - try testing.expect(nameAt(files, "pty") == null); - - try testing.expectEqual(E.NOENT, look_up(p, dir, "pty_ctl").errno()); - try testing.expectEqual(E.NOENT, look_up(p, dir, "status").errno()); - - const before = p.next_serial; - try testing.expectEqual(E.NOENT, look_up(p, @intFromEnum(SelfFile.new), "pty").errno()); - try testing.expectEqual(before, p.next_serial); -} - -test "a terminal pane's pty/ holds exactly ctl, status and data" { - const gpa = testing.allocator; - const p = try withTerm(gpa); - defer p.deinit(); - const serial = serialOf(p); - const dir = Node.of(serial, .dir); - - const pty = look_up(p, dir, "pty"); - try testing.expectEqual(Node.of(serial, .pty), pty.reply.attr.node); - try testing.expect(pty.reply.attr.dir); - try testing.expectEqual(@as(u16, 0o500), pty.reply.attr.mode); - - var buf: [32]Dirent = undefined; - const files = dirents(rdir(p, dir, 0).bytes, &buf); - try testing.expectEqual(@as(usize, 11), files.len); - try testing.expect(nameAt(files, "pty").?.dir); - - const inside = dirents(rdir(p, Node.of(serial, .pty), 0).bytes, &buf); - try testing.expectEqual(@as(usize, 3), inside.len); - try testing.expectEqualStrings("ctl", inside[0].name); - try testing.expectEqualStrings("status", inside[1].name); - try testing.expectEqualStrings("data", inside[2].name); - for (inside) |d| try testing.expect(!d.dir); - try testing.expectEqual(Node.of(serial, .pty_data), inside[2].node); - - const ctl = look_up(p, Node.of(serial, .pty), "ctl"); - try testing.expectEqual(Node.of(serial, .pty_ctl), ctl.reply.attr.node); - try testing.expectEqual(@as(u16, 0o200), ctl.reply.attr.mode); - try testing.expectEqual(@as(u16, 0o400), look_up(p, Node.of(serial, .pty), "status").reply.attr.mode); - try testing.expectEqual(E.NOENT, look_up(p, Node.of(serial, .pty), "body").errno()); - try testing.expectEqual(E.NOENT, look_up(p, Node.of(serial, .pty), "pty").errno()); - - try testing.expectEqual(E.NOTDIR, look_up(p, Node.of(serial, .pty_ctl), "x").errno()); - try testing.expectEqual(E.NOTDIR, rdir(p, Node.of(serial, .pty_ctl), 0).errno()); - try testing.expectEqual(E.PERM, rd(p, Node.of(serial, .pty), 0, 16).errno()); - try testing.expectEqual(E.PERM, rd(p, Node.of(serial, .pty_ctl), 0, 16).errno()); - try testing.expectEqual(E.PERM, wr(p, Node.of(serial, .pty_status), "x").errno()); -} - -test "every pty/ctl verb, and every refusal" { - const gpa = testing.allocator; - const p = try withTerm(gpa); - defer p.deinit(); - const ctl = Node.of(serialOf(p), .pty_ctl); - - const pane = p.panes[0].?; - const cols = pane.cols; - const rows = pane.rows; - const ws = wr(p, ctl, "winsize 132 44\n"); - try testing.expectEqual(@as(u32, "winsize 132 44\n".len), ws.reply.written); - try testing.expectEqual(@as(u16, 132), ws.winsize.?.cols); - try testing.expectEqual(@as(u16, 44), ws.winsize.?.rows); - try testing.expectEqual(cols, pane.cols); - try testing.expectEqual(rows, pane.rows); - - for ([_]struct { line: []const u8, want: pardes.PtySignal }{ - .{ .line = "sig INT", .want = .int }, - .{ .line = "sig TERM", .want = .term }, - .{ .line = "sig HUP", .want = .hup }, - .{ .line = "sig QUIT", .want = .quit }, - .{ .line = "sig KILL", .want = .kill }, - }) |c| { - const a = wr(p, ctl, c.line); - try testing.expectEqual(Status.ok, a.reply.status); - try testing.expectEqual(c.want, a.signal.?); - } - - const ex = wr(p, ctl, "exec\n"); - try testing.expectEqual(Status.ok, ex.reply.status); - try testing.expect(ex.spawned); - - const both = wr(p, ctl, "winsize 100 30\nsig TERM"); - try testing.expectEqual(@as(u16, 100), both.winsize.?.cols); - try testing.expectEqual(pardes.PtySignal.term, both.signal.?); - - for ([_][]const u8{ - "winsize", // no arguments - "winsize 80", // one argument - "winsize 80 24 extra", // three - "winsize 0 24", // zero is "unknown", never a width - "winsize 80 0", - "winsize -1 24", // not a decimal - "winsize 999999 24", // wider than a u16 - "sig", // no name - "sig INT TERM", // two - "sig SIGINT", - "sig int", // lower case - "sig 9", // a number is one platform's number - "sig USR1", // a real signal, deliberately not offered - "exec /bin/sh", // the effect carries no argv; refused, never ignored - "raw", - "cooked", - "winsize 80 24\nbogus", // a good verb beside a bad one - "bogus\nwinsize 80 24", - "name x", // a `ctl` verb; the two files share no vocabulary - "del", - }) |bad| { - const a = wr(p, ctl, bad); - try testing.expectEqual(E.INVAL, a.errno()); - try testing.expect(a.winsize == null); - try testing.expect(a.signal == null); - try testing.expect(!a.spawned); - } - - const spaced = wr(p, ctl, "\n winsize 90 20 \n\n"); - try testing.expectEqual(Status.ok, spaced.reply.status); - try testing.expectEqual(@as(u16, 90), spaced.winsize.?.cols); - try testing.expectEqual(Status.ok, wr(p, ctl, "").reply.status); -} - -const FakeTty = struct { - taken: bool, - - const vtable: pardes.Host.VTable = .{ .tty_taken = answer }; - - fn answer(ctx: ?*anyopaque, pane: u8) bool { - _ = pane; - const f: *FakeTty = @ptrCast(@alignCast(ctx.?)); - return f.taken; - } -}; - -test "owned cwd pty exec rejects long paths before applying its batch" { - const p = try withTerm(testing.allocator); - defer p.deinit(); - const pane = p.panes[0].?; - const ctl = Node.of(pane.serial, .pty_ctl); - var path: [1025]u8 = @splat('d'); - path[0] = '/'; - p.setCwd(0, &path); - for ([_][]const u8{ "exec\n", "winsize 100 30\nexec\n", "sig TERM\nexec\n" }) |command| { - const result = wr(p, ctl, command); - try testing.expectEqual(E.INVAL, result.errno()); - try testing.expect(!result.spawned); - try testing.expect(result.signal == null and result.winsize == null); - } - try testing.expectEqualStrings(&path, pane.cwdSlice()); - p.setCwd(0, path[0..pardes.effect_path_cap]); - const accepted = wr(p, ctl, "exec\n"); - try testing.expectEqual(Status.ok, accepted.reply.status); - try testing.expect(accepted.spawned); -} - -test "owned cwd name promotion releases the former directory" { - const p = try withTerm(testing.allocator); - defer p.deinit(); - p.newScratchBelow(0); - const id = p.active; - const pane = p.panes[id].?; - try pane.setOwnedCwd("/old/directory"); - const result = wr(p, Node.of(pane.serial, .ctl), "name saved.txt\n"); - try testing.expectEqual(Status.ok, result.reply.status); - try testing.expect(pane.cwd == .none); - try testing.expect(pane.file.?.output == null); - try testing.expectEqualStrings("/old/directory/saved.txt", pane.file.?.path); - try testing.expectEqualStrings("/old/directory", Pardes.paneDir(pane)); -} - -test "pty/status reports the grid and who holds the tty" { - const gpa = testing.allocator; - const p = try withTerm(gpa); - defer p.deinit(); - const pane = p.panes[0].?; - const status = Node.of(pane.serial, .pty_status); - - const a = rd(p, status, 0, 256); - try testing.expectEqual(Status.ok, a.reply.status); - var want: [64]u8 = undefined; - const whole = try std.fmt.bufPrint(&want, "{d:>11} {d:>11} {d:>11} ", .{ pane.cols, pane.rows, 0 }); - try testing.expectEqualStrings(whole, a.bytes); - try testing.expectEqual(@as(usize, 3 * 12), a.bytes.len); - try testing.expectEqualStrings(whole[12..], rd(p, status, 12, 256).bytes); - - var probe: FakeTty = .{ .taken = true }; - p.host = .{ .ctx = &probe, .vtable = &FakeTty.vtable }; - const held = rd(p, status, 0, 256); - try testing.expectEqualStrings( - try std.fmt.bufPrint(&want, "{d:>11} {d:>11} {d:>11} ", .{ pane.cols, pane.rows, 1 }), - held.bytes, - ); -} - -test "pty/data writes at the shell and reads the raw stream" { - const gpa = testing.allocator; - const p = try withTerm(gpa); - defer p.deinit(); - const serial = serialOf(p); - const data = Node.of(serial, .pty_data); - - const w = call(p, .{ .tag = 2, .op = .write, .node = data, .off = 999, .data = "ls -l\r" }); - try testing.expectEqual(@as(u32, 6), w.reply.written); - try testing.expectEqualStrings("ls -l\r", w.pty()); - try testing.expectEqual(@as(u32, 1), wr(p, data, "a\xC3").reply.written); - try testing.expectEqual(@as(u32, 0), wr(p, data, "").reply.written); - - try testing.expectEqual(Status.again, rd(p, data, 0, 64).reply.status); - - p.update(.{ .output = .{ .pane = 0, .bytes = "unwatched" } }); - while (p.nextEffect()) |_| {} - try testing.expectEqual(@as(usize, 0), p.fs.panes[0].pty_out.buf.items.len); - try testing.expectEqual(Status.again, rd(p, data, 0, 64).reply.status); - - _ = call(p, .{ .tag = 5, .op = .open, .node = data }); - try testing.expectEqual(@as(u16, 1), p.fs.panes[0].pty_readers); - try testing.expectEqual(@as(u16, 0), p.fs.listeners); - try testing.expect(!p.fs.scripted(0)); - - p.update(.{ .output = .{ .pane = 0, .bytes = "hello" } }); - while (p.nextEffect()) |_| {} - try testing.expectEqualStrings("hello", rd(p, data, 0, 64).bytes); - try testing.expectEqual(Status.again, rd(p, data, 0, 64).reply.status); - - p.update(.{ .output = .{ .pane = 0, .bytes = "abcdef" } }); - while (p.nextEffect()) |_| {} - try testing.expectEqualStrings("ab", rd(p, data, 0, 2).bytes); - try testing.expectEqualStrings("cd", rd(p, data, 0, 2).bytes); - p.update(.{ .output = .{ .pane = 0, .bytes = "ghi" } }); - while (p.nextEffect()) |_| {} - try testing.expectEqualStrings("efghi", rd(p, data, 0, 64).bytes); - - p.update(.{ .output = .{ .pane = 0, .bytes = "orphan" } }); - while (p.nextEffect()) |_| {} - _ = call(p, .{ .tag = 6, .op = .release, .node = data }); - try testing.expectEqual(@as(u16, 0), p.fs.panes[0].pty_readers); - try testing.expectEqual(@as(usize, 0), p.fs.panes[0].pty_out.buf.capacity); - try testing.expectEqual(Status.again, rd(p, data, 0, 64).reply.status); - - _ = call(p, .{ .tag = 7, .op = .open, .node = data }); - _ = call(p, .{ .tag = 8, .op = .open, .node = data }); - _ = call(p, .{ .tag = 9, .op = .release, .node = data }); - try testing.expectEqual(@as(u16, 1), p.fs.panes[0].pty_readers); - p.update(.{ .output = .{ .pane = 0, .bytes = "still" } }); - while (p.nextEffect()) |_| {} - try testing.expectEqualStrings("still", rd(p, data, 0, 64).bytes); -} - -test "the pty queue drops the oldest at its cap" { - const gpa = testing.allocator; - const p = try withTerm(gpa); - defer p.deinit(); - const data = Node.of(serialOf(p), .pty_data); - _ = call(p, .{ .tag = 5, .op = .open, .node = data }); - - const oldest: [4096]u8 = @splat('A'); - const rest: [4096]u8 = @splat('B'); - notePtyOutput(p, 0, &oldest); - for (0..queue_cap / rest.len + 4) |_| notePtyOutput(p, 0, &rest); - const q = &p.fs.panes[0].pty_out; - try testing.expect(q.buf.items.len - q.head <= queue_cap); - - var seen: usize = 0; - while (true) { - const a = rd(p, data, 0, 1 << 16); - if (a.reply.status == .again) break; - try testing.expect(std.mem.indexOfScalar(u8, a.bytes, 'A') == null); - if (a.bytes.len == 0) break; - seen += a.bytes.len; - } - try testing.expect(seen > 0 and seen <= queue_cap); +test { + _ = tree; } diff --git a/src/main.zig b/src/main.zig index 40ec8667..4b1910bd 100644 --- a/src/main.zig +++ b/src/main.zig @@ -281,10 +281,10 @@ fn nativeMain(init: std.process.Init) !void { const serial = std.fmt.parseInt(u32, pane_text, 10) catch break :forwarding; if (serial == 0) break :forwarding; var ctl_buf: [64]u8 = undefined; - const ctl = try std.fmt.bufPrint(&ctl_buf, "/self/pane/{d}/ctl", .{serial}); + const ctl = try std.fmt.bufPrint(&ctl_buf, "/pane/{d}/ctl", .{serial}); const word = positional orelse { var tag_buf: [64]u8 = undefined; - const tag = try std.fmt.bufPrint(&tag_buf, "/self/pane/{d}/tag", .{serial}); + const tag = try std.fmt.bufPrint(&tag_buf, "/pane/{d}/tag", .{serial}); const contents = ninep_io.Client.read(arena, dial, tag, tag) catch break :forwarding; arena.free(contents); try std.Io.File.stderr().writeStreamingAll(init.io, nested_text); diff --git a/src/memory.zig b/src/memory.zig index 60ec1bb6..f30e4392 100644 --- a/src/memory.zig +++ b/src/memory.zig @@ -19,7 +19,8 @@ pub const limits = struct { pub const message_log = if (board) 16 else 128; pub const max_tag_tail: usize = if (board) 512 else 4096; pub const host_path_cap: usize = if (board) 0 else 4095; - pub const embedded_sources = !board; + /// -Dembed-sources: the editor serves its own sources under /src. + pub const embedded_sources = config.embed_sources; pub const hexdump_row_bytes: u32 = if (board) 8 else 16; pub const arena = struct { @@ -138,7 +139,7 @@ test "memory limits preserve desktop capacities" { try std.testing.expectEqual(128, limits.message_log); try std.testing.expectEqual(@as(usize, 4096), limits.max_tag_tail); try std.testing.expectEqual(@as(usize, 4095), limits.host_path_cap); - try std.testing.expect(limits.embedded_sources); + try std.testing.expectEqual(config.embed_sources, limits.embedded_sources); try std.testing.expectEqual(@as(u32, 16), limits.hexdump_row_bytes); try std.testing.expectEqual(32 * MiB, limits.arena.pardes); try std.testing.expectEqual(16 * MiB, limits.arena.frame); diff --git a/src/ninep/addr.zig b/src/ninep/addr.zig new file mode 100644 index 00000000..f7642b9e --- /dev/null +++ b/src/ninep/addr.zig @@ -0,0 +1,276 @@ +//! The address language of a pane's `addr` file: acme's, with mvzr regexps. +const std = @import("std"); +const mvzr = @import("mvzr"); +const modal = @import("../modal.zig"); +const pane_files = @import("pane.zig"); + +pub const Range = pane_files.State.Range; + +fn clip(n: usize) u32 { + return std.math.cast(u32, n) orelse std.math.maxInt(u32); +} + +fn safePattern(pat: []const u8) bool { + var i: usize = 0; + while (i < pat.len) : (i += 1) { + if (pat[i] != '\\') continue; + if (i + 1 >= pat.len) return false; + i += 1; + } + return true; +} + +pub const Addr = struct { + text: []const u8, + lim: ?Range, + expr: []const u8, + i: usize = 0, + depth: u8 = 0, + + const max_depth = 32; + const Size = enum { char, line }; + + pub fn address(a: *Addr, ar_in: Range) ?Range { + const start = a.i; + var ar = ar_in; + var r = ar_in; + var dir: u8 = 0; + var size: Size = .line; + var c: u8 = 0; + while (a.i < a.expr.len) { + const prevc = c; + c = a.expr[a.i]; + a.i += 1; + switch (c) { + ',', ';' => { + if (c == ';') ar = r; + if (prevc == 0) r.q0 = 0; // lhs defaults to 0 + if (a.i >= a.expr.len) { + r.q1 = clip(a.text.len); // rhs defaults to $ + } else { + if (a.depth >= max_depth) return null; + a.depth += 1; + const nr = a.address(ar) orelse return null; + a.depth -= 1; + r.q1 = nr.q1; + } + return r; + }, + '+', '-' => { + if (prevc == '+' or prevc == '-') { + const nc = if (a.i < a.expr.len) a.expr[a.i] else 0; + if (nc != '#' and nc != '/' and nc != '?') + r = a.number(r, 1, prevc, .line) orelse return null; + } + dir = c; + }, + '.', '$' => { + if (a.i != start + 1) { + a.i -= 1; + return r; + } + r = if (c == '.') ar else .{ .q0 = clip(a.text.len), .q1 = clip(a.text.len) }; + dir = if (a.i < a.expr.len) '+' else 0; + }, + '#', '0'...'9' => { + var digit = c; + if (c == '#') { + if (a.i >= a.expr.len or a.expr[a.i] < '0' or a.expr[a.i] > '9') { + a.i -= 1; + return r; + } + digit = a.expr[a.i]; + a.i += 1; + size = .char; + } + var n: u64 = digit - '0'; + while (a.i < a.expr.len) : (a.i += 1) { + const d = a.expr[a.i]; + if (d < '0' or d > '9') break; + n = @min(n * 10 + (d - '0'), std.math.maxInt(u32)); + } + r = a.number(r, @intCast(n), dir, size) orelse return null; + dir = 0; + size = .line; + }, + '/', '?' => { + const back = c == '?'; + r = a.regexp(r, a.pattern(c), back) orelse return null; + dir = 0; + size = .line; + }, + else => { + a.i -= 1; + return r; + }, + } + } + if (dir != 0) r = a.number(r, 1, dir, .line) orelse return null; + return r; + } + + fn pattern(a: *Addr, delim: u8) []const u8 { + const s = a.i; + while (a.i < a.expr.len) { + const c = a.expr[a.i]; + if (c == '\n') break; + a.i += 1; + if (c == '\\') { + if (a.i < a.expr.len) a.i += 1; + continue; + } + if (c == delim) return a.expr[s .. a.i - 1]; + } + return a.expr[s..a.i]; + } + + fn number(a: *Addr, r_in: Range, n: u32, dir: u8, size: Size) ?Range { + var r = r_in; + if (size == .char) { + var off: i64 = n; + if (dir == '+') { + off = @as(i64, r.q1) + n; + } else if (dir == '-') { + if (r.q0 == 0 and n > 0) r.q0 = clip(a.text.len); + off = @as(i64, r.q0) - n; + } + if (off < 0 or off > @as(i64, @intCast(a.text.len))) return null; + const g = clip(modal.graphemeStart(a.text, @intCast(off))); + return .{ .q0 = g, .q1 = g }; + } + var line: i64 = n; + var q0: usize = r.q0; + var q1: usize = r.q1; + switch (dir) { + '-' => { + if (q0 < a.text.len) while (q0 > 0 and a.text[q0 - 1] != '\n') { + q0 -= 1; + }; + q1 = q0; + while (line > 0 and q0 > 0) { + if (a.text[q0 - 1] == '\n') { + line -= 1; + q1 = q0; + } + q0 -= 1; + } + if (line > 1) return null; + while (q0 > 0 and a.text[q0 - 1] != '\n') q0 -= 1; + return .{ .q0 = clip(q0), .q1 = clip(q1) }; + }, + '+' => { + if (q1 > 0) while (q1 < a.text.len and a.text[q1 - 1] != '\n') { + q1 += 1; + }; + q0 = q1; + }, + else => { + q0 = 0; + q1 = 0; + }, + } + while (line > 0 and q1 < a.text.len) { + const ch = a.text[q1]; + q1 += 1; + if (ch == '\n' or q1 == a.text.len) { + line -= 1; + if (line > 0) q0 = q1; + } + } + if (line > 0) return null; + return .{ .q0 = clip(q0), .q1 = clip(q1) }; + } + + fn regexp(a: *Addr, r: Range, pat: []const u8, back: bool) ?Range { + if (pat.len == 0 or !safePattern(pat)) return null; + const re = mvzr.compile(pat) orelse return null; + if (back) { + const hi = @min(@as(usize, r.q0), a.text.len); + var best: ?mvzr.Match = null; + var at: usize = 0; + while (at < hi) { + const m = re.matchPos(at, a.text[0..hi]) orelse break; + best = m; + at = if (m.end > m.start) m.end else m.end + 1; + } + const m = best orelse return null; + return .{ .q0 = clip(m.start), .q1 = clip(m.end) }; + } + const hi = if (a.lim) |l| @min(@as(usize, l.q1), a.text.len) else a.text.len; + const from = @min(@as(usize, r.q1), hi); + const m = re.match(a.text[from..hi]) orelse return null; + return .{ .q0 = clip(from + m.start), .q1 = clip(from + m.end) }; + } +}; + +const testing = std.testing; +const th = @import("testing.zig"); +const tree = @import("tree.zig"); +const Node = tree.Node; +const E = tree.E; +const Status = tree.Status; + +test "the address language, form by form" { + const gpa = testing.allocator; + const p = try th.withFile(gpa, "one\ntwo\nthree\n"); + defer p.deinit(); + const serial = th.serialOf(p); + const addr = Node.of(serial, .addr); + + const Case = struct { expr: []const u8, q0: u32, q1: u32 }; + for ([_]Case{ + .{ .expr = "#0", .q0 = 0, .q1 = 0 }, + .{ .expr = "#5", .q0 = 5, .q1 = 5 }, + .{ .expr = "0", .q0 = 0, .q1 = 0 }, + .{ .expr = "1", .q0 = 0, .q1 = 4 }, + .{ .expr = "2", .q0 = 4, .q1 = 8 }, + .{ .expr = "$", .q0 = 14, .q1 = 14 }, + .{ .expr = ",", .q0 = 0, .q1 = 14 }, + .{ .expr = "1,2", .q0 = 0, .q1 = 8 }, + .{ .expr = "#1,#4", .q0 = 1, .q1 = 4 }, + .{ .expr = "2+1", .q0 = 8, .q1 = 14 }, + .{ .expr = "$-1", .q0 = 8, .q1 = 14 }, + .{ .expr = "/two/", .q0 = 4, .q1 = 7 }, + .{ .expr = "/t.o/", .q0 = 4, .q1 = 7 }, + .{ .expr = "1\n", .q0 = 0, .q1 = 4 }, + }) |c| { + _ = th.wr(p, addr, "#0"); + const w = th.wr(p, addr, c.expr); + try testing.expectEqual(Status.ok, w.reply.status); + const got = th.rd(p, addr, 0, 64); + var want: [32]u8 = undefined; + try testing.expectEqualStrings( + try std.fmt.bufPrint(&want, "{d:>11} {d:>11} ", .{ c.q0, c.q1 }), + got.bytes, + ); + } + + _ = th.wr(p, addr, "1"); + _ = th.wr(p, addr, "."); + try testing.expectEqual(@as(u32, 0), p.fs.panes[0].addr.q0); + try testing.expectEqual(@as(u32, 4), p.fs.panes[0].addr.q1); + + _ = th.wr(p, addr, "$"); + _ = th.wr(p, addr, "?o?"); + try testing.expectEqual(@as(u32, 6), p.fs.panes[0].addr.q0); // the `o` in "two" + try testing.expectEqual(@as(u32, 7), p.fs.panes[0].addr.q1); + + _ = th.wr(p, addr, "1"); + _ = th.wr(p, Node.of(serial, .ctl), "limit=addr\n"); + _ = th.wr(p, addr, "#0"); + try testing.expectEqual(E.INVAL, th.wr(p, addr, "/three/").errno()); + _ = th.wr(p, Node.of(serial, .ctl), "clean\n"); + _ = th.call(p, .{ .tag = 6, .op = .open, .node = Node.of(serial, .ctl) }); + try testing.expect(p.fs.panes[0].limit == null); + _ = th.wr(p, addr, "#0"); + try testing.expectEqual(Status.ok, th.wr(p, addr, "/three/").reply.status); + + for ([_][]const u8{ "zzz", "#", "//", "/nomatch/", "1 2", "99", "/a\\" }) |bad| { + _ = th.wr(p, addr, "#0"); + try testing.expectEqual(E.INVAL, th.wr(p, addr, bad).errno()); + } + + const nested = "," ** 4096; + _ = th.wr(p, addr, "#0"); + try testing.expectEqual(E.INVAL, th.wr(p, addr, nested).errno()); +} diff --git a/src/ninep/ctl.zig b/src/ninep/ctl.zig new file mode 100644 index 00000000..d61ebf75 --- /dev/null +++ b/src/ninep/ctl.zig @@ -0,0 +1,503 @@ +//! The two ctl files. `look TEXT` is a right click and `exec TEXT` a middle +//! click in the editor's own command language; a pane's ctl adds the addr +//! verbs. Reading /ctl answers the serials the last command made or touched. +const std = @import("std"); +const pardes = @import("../pardes.zig"); +const panes = @import("../panes.zig"); +const config = @import("../config.zig"); +const fs = @import("../fs.zig"); +const tree = @import("tree.zig"); +const pane_files = @import("pane.zig"); + +const Pardes = pardes.Pardes; +const Pane = pardes.Pane; +const MAX_PANES = pardes.MAX_PANES; +const Req = tree.Req; +const Reply = tree.Reply; +const E = tree.E; + +const Verb = enum { + @"addr=dot", + clean, + cleartag, + dirty, + @"dot=addr", + get, + @"limit=addr", + mark, + nomark, + noscroll, + scroll, + show, +}; + +fn verbIs(line: []const u8, word: []const u8) bool { + if (!std.mem.startsWith(u8, line, word)) return false; + return line.len == word.len or line[word.len] == ' ' or line[word.len] == '\t'; +} + +/// The text after `look` or `exec`, or null when the line is not that verb. +/// Control characters other than tab are refused. +fn textAfter(line: []const u8, verb: []const u8) ?[]const u8 { + if (!verbIs(line, verb)) return null; + const text = std.mem.trim(u8, line[verb.len..], " \t"); + if (text.len == 0) return ""; + for (text) |c| if (c < ' ' and c != '\t') return ""; + return text; +} + +// ---- which panes a command made or touched ---- + +const Serials = struct { + list: [MAX_PANES]u32 = undefined, + len: usize = 0, + + fn snapshot(p: *Pardes) Serials { + var s: Serials = .{}; + for (p.panes) |slot| if (slot) |pane| { + s.list[s.len] = pane.serial; + s.len += 1; + }; + return s; + } + + fn has(s: *const Serials, serial: u32) bool { + for (s.list[0..s.len]) |known| if (known == serial) return true; + return false; + } +}; + +fn noteResult(p: *Pardes, serial: u32) void { + for (p.fs.results[0..p.fs.results_len]) |known| if (known == serial) return; + if (p.fs.results_len == p.fs.results.len) return; + p.fs.results[p.fs.results_len] = serial; + p.fs.results_len += 1; +} + +fn activeSerial(p: *Pardes) ?u32 { + const pane = p.panes[p.active] orelse return null; + return pane.serial; +} + +/// Runs one look or exec from the pane `id`, then records the panes it +/// created; failing that, a look records the pane it focused and an exec +/// the pane it acted on (even one it closed). +fn run(p: *Pardes, id: usize, exec: bool, text: []const u8) void { + const context = p.panes[id].?.serial; + const before = Serials.snapshot(p); + if (exec) _ = p.execute(id, text) else p.lookAt(id, text); + const after = Serials.snapshot(p); + var created = false; + for (after.list[0..after.len]) |serial| if (!before.has(serial)) { + noteResult(p, serial); + created = true; + }; + if (created) return; + noteResult(p, if (exec) context else activeSerial(p) orelse return); +} + +fn beginResults(p: *Pardes) void { + p.fs.results_len = 0; + p.fs.results_valid = true; +} + +// ---- /ctl ---- + +pub fn writeRoot(p: *Pardes, req: Req) Reply { + for ([2]bool{ false, true }) |apply| { + if (apply) beginResults(p); + var it = std.mem.splitScalar(u8, req.data, '\n'); + while (it.next()) |raw| { + const line = std.mem.trim(u8, raw, " \t\r"); + if (line.len == 0) continue; + const exec = verbIs(line, "exec"); + const text = textAfter(line, if (exec) "exec" else "look") orelse return Reply.fail(req.tag, E.INVAL); + if (text.len == 0) return Reply.fail(req.tag, E.INVAL); + if (!apply) continue; + if (p.panes[p.active] == null) return Reply.fail(req.tag, E.NOENT); + run(p, p.active, exec, text); + } + } + return .{ .tag = req.tag, .written = @intCast(req.data.len) }; +} + +pub fn rootText(p: *Pardes, buf: []u8) []const u8 { + var w = std.Io.Writer.fixed(buf); + if (p.fs.results_valid) { + for (p.fs.results[0..p.fs.results_len]) |serial| w.print("{d}\n", .{serial}) catch break; + return w.buffered(); + } + var count: usize = 0; + for (p.panes) |slot| count += @intFromBool(slot != null); + const pid: u32 = if (comptime pardes.hosted) @intCast(std.c.getpid()) else 0; + w.print("pid {d}\nversion {s}\npanes {d}\n", .{ pid, pardes.version, count }) catch {}; + return w.buffered(); +} + +pub const root_text_cap = @max(MAX_PANES * 11, 64 + pardes.version.len); + +pub fn readRoot(p: *Pardes, req: Req) Reply { + var buf: [root_text_cap]u8 = undefined; + const text = rootText(p, &buf); + const out = p.fs.stage(p.gpa); + out.appendSlice(p.gpa, text) catch return Reply.fail(req.tag, E.NOMEM); + return tree.stagedReply(p, req); +} + +// ---- /pane//ctl ---- + +fn fontName(p: *Pardes) []const u8 { + const name = p.settings.font.effective_name.get(); + return if (name.len == 0) "default" else name; +} + +fn writeQuoted(w: *std.Io.Writer, s: []const u8) !void { + const plain = s.len > 0 and for (s) |c| { + if (c <= ' ' or c == '\'') break false; + } else true; + if (plain) return w.writeAll(s); + try w.writeByte('\''); + for (s) |c| { + if (c == '\'') try w.writeByte('\''); + try w.writeByte(c); + } + try w.writeByte('\''); +} + +pub const pane_text_cap = 7 * 12 + 2 * 256 + 4; + +/// acme's winctlprint: serial, tag length, body length, a reserved zero, the +/// dirty flag, then the width in cells, the font and the tab width. +pub fn paneText(p: *Pardes, pane: *Pane, buf: []u8) []const u8 { + var w = std.Io.Writer.fixed(buf); + w.print("{d:>11} {d:>11} {d:>11} {d:>11} {d:>11} {d:>11} ", .{ + pane.serial, + pane_files.tagOf(p, pane).len, + pane_files.bodyOf(pane).len, + @as(u32, 0), + @intFromBool(pane_files.dirtyOf(pane)), + pane.cols, + }) catch return w.buffered(); + writeQuoted(&w, fontName(p)) catch return w.buffered(); + w.print(" {d:>11} ", .{config.tab_width}) catch {}; + return w.buffered(); +} + +pub fn readPane(p: *Pardes, req: Req, pane: *Pane) Reply { + var buf: [pane_text_cap]u8 = undefined; + const out = p.fs.stage(p.gpa); + out.appendSlice(p.gpa, paneText(p, pane, &buf)) catch return Reply.fail(req.tag, E.NOMEM); + return tree.stagedReply(p, req); +} + +pub fn writePane(p: *Pardes, req: Req, serial: u32) Reply { + for ([2]bool{ false, true }) |apply| { + if (apply) beginResults(p); + var it = std.mem.splitScalar(u8, req.data, '\n'); + while (it.next()) |raw| { + const line = std.mem.trim(u8, raw, " \t\r"); + if (line.len == 0) continue; + const live = p.paneBySerial(serial) orelse if (apply) break else return Reply.fail(req.tag, E.NOENT); + const errno = paneVerb(p, live, line, apply); + if (errno != 0) return Reply.fail(req.tag, errno); + } + } + return .{ .tag = req.tag, .written = @intCast(req.data.len) }; +} + +fn paneVerb(p: *Pardes, id: usize, line: []const u8, apply: bool) u16 { + const pane = p.panes[id] orelse return E.INVAL; + const pf = &p.fs.panes[id]; + + for ([_]bool{ false, true }) |exec| if (textAfter(line, if (exec) "exec" else "look")) |text| { + if (text.len == 0) return E.INVAL; + if (apply) run(p, id, exec, text); + return 0; + }; + const v = std.meta.stringToEnum(Verb, line) orelse return E.INVAL; + if (!apply) return 0; + + switch (v) { + .@"addr=dot" => pf.addr = pane_files.dotOf(pane), + .@"dot=addr" => { + pane_files.clampAddr(pf, pane_files.bodyOf(pane).len); + pane_files.setDot(pane, pf.addr); + }, + .@"limit=addr" => { + pane_files.clampAddr(pf, pane_files.bodyOf(pane).len); + pf.limit = pf.addr; + }, + .clean => if (pane_files.fileOf(pane)) |f| { + f.saved_revision = f.revision; + }, + .dirty => if (pane_files.fileOf(pane)) |f| { + f.saved_revision = f.revision -% 1; + }, + .cleartag => { + pane.tag_tail_len = 0; + pane.tag_init = true; + }, + .get => if (pane_files.fileOf(pane)) |f| { + if (panes.Output.fileTraits(f.output).saves) { + if (fs.read(p, f.path)) |bytes| { + panes.File.pushUndo(p, pane); + panes.File.setContent(p, f, bytes); + f.saved_revision = f.revision; + } else |err| return switch (err) { + error.FileNotFound => E.NOENT, + else => E.IO, + }; + } + }, + .mark => { + pf.nomark = false; + panes.File.pushUndo(p, pane); + }, + .nomark => pf.nomark = true, + .noscroll => pf.noscroll = true, + .scroll => pf.noscroll = false, + .show => pane_files.showOffset(pane, pane_files.dotOf(pane).q0), + } + return 0; +} + +// ---- tests ---- + +const testing = std.testing; +const th = @import("testing.zig"); +const call = th.call; +const rd = th.rd; +const wr = th.wr; +const withFile = th.withFile; +const serialOf = th.serialOf; +const Node = tree.Node; +const Status = tree.Status; +const root_ctl = @intFromEnum(tree.TopFile.ctl); + +test "pane ctl read is index's five fields plus width in cells, font and tab width" { + const gpa = testing.allocator; + const p = try withFile(gpa, "x\n"); + defer p.deinit(); + const pane = p.panes[0].?; + + const a = rd(p, Node.of(pane.serial, .ctl), 0, 4096); + try testing.expectEqual(Status.ok, a.reply.status); + var want: std.ArrayList(u8) = .empty; + defer want.deinit(gpa); + try want.print(gpa, "{d:>11} {d:>11} {d:>11} {d:>11} {d:>11} {d:>11} {s} {d:>11} ", .{ + pane.serial, pane_files.tagOf(p, pane).len, @as(usize, 2), 0, 0, pane.cols, "default", config.tab_width, + }); + try testing.expectEqualStrings(want.items, a.bytes); + try testing.expectEqual(@as(u64, a.bytes.len), call(p, .{ .tag = 1, .op = .getattr, .node = Node.of(pane.serial, .ctl) }).reply.attr.size); + + var quoted: [64]u8 = undefined; + var w = std.Io.Writer.fixed("ed); + try writeQuoted(&w, "DejaVu Sans Mono"); + try testing.expectEqualStrings("'DejaVu Sans Mono'", w.buffered()); + w = std.Io.Writer.fixed("ed); + try writeQuoted(&w, "it's"); + try testing.expectEqualStrings("'it''s'", w.buffered()); +} + +test "every pane ctl verb, and every refusal" { + const gpa = testing.allocator; + const p = try withFile(gpa, "one\ntwo\n"); + defer p.deinit(); + const serial = serialOf(p); + const ctl_node = Node.of(serial, .ctl); + const pane = p.panes[0].?; + const pf = &p.fs.panes[0]; + + try testing.expectEqual(Status.ok, wr(p, ctl_node, "nomark\nnoscroll\ndirty\n").reply.status); + try testing.expect(pf.nomark and pf.noscroll and pane_files.dirtyOf(pane)); + try testing.expectEqual(Status.ok, wr(p, ctl_node, "mark\nscroll\nclean\n").reply.status); + try testing.expect(!pf.nomark and !pf.noscroll and !pane_files.dirtyOf(pane)); + + _ = wr(p, ctl_node, "cleartag\n"); + try testing.expectEqual(@as(usize, 0), pane.tag_tail_len); + + _ = wr(p, Node.of(serial, .addr), "2"); + _ = wr(p, ctl_node, "limit=addr\n"); + try testing.expectEqual(@as(u32, 4), pf.limit.?.q0); + _ = wr(p, ctl_node, "dot=addr\nshow\n"); + try testing.expectEqual(@as(i32, 1), pane.cur_row); + + for ([_][]const u8{ + "menu", "nomenu", "dump echo hi", "dumpdir /tmp", "font Go Mono", "lock", "unlock", "bogus", "DEL", + "name x.txt", "put", "del", "delete", "Look x", "Exec Save", + }) |bad| try testing.expectEqual(E.INVAL, wr(p, ctl_node, bad).errno()); + + try testing.expect(!pane_files.dirtyOf(pane)); + try testing.expectEqual(E.INVAL, wr(p, ctl_node, "dirty\nbogus\n").errno()); + try testing.expect(!pane_files.dirtyOf(pane)); +} + +test "exec runs a builtin at the pane and records the pane it acted on" { + const gpa = testing.allocator; + const p = try withFile(gpa, "Msg fs-ran\n"); + defer p.deinit(); + const serial = serialOf(p); + const pane = p.panes[0].?; + try testing.expectEqual(Status.ok, wr(p, Node.of(serial, .ctl), "exec Msg from ctl\n").reply.status); + try testing.expectEqualStrings("from ctl", pane.msg[0..pane.msg_len]); + var expected: [16]u8 = undefined; + try testing.expectEqualStrings(try std.fmt.bufPrint(&expected, "{d}\n", .{serial}), rd(p, root_ctl, 0, 4096).bytes); + + try testing.expectEqual(Status.ok, wr(p, Node.of(serial, .ctl), "exec New\n").reply.status); + const made = p.panes[p.active].?; + try testing.expect(made.serial != serial); + try testing.expectEqualStrings(try std.fmt.bufPrint(&expected, "{d}\n", .{made.serial}), rd(p, root_ctl, 0, 4096).bytes); + + try testing.expectEqual(Status.ok, wr(p, Node.of(made.serial, .ctl), "exec Del\n").reply.status); + try testing.expect(p.paneBySerial(made.serial) == null); + try testing.expectEqualStrings(try std.fmt.bufPrint(&expected, "{d}\n", .{made.serial}), rd(p, root_ctl, 0, 4096).bytes); +} + +test "the root ctl reads editor status until a command runs and validates whole batches" { + const gpa = testing.allocator; + const p = try withFile(gpa, "Msg root\n"); + defer p.deinit(); + const status = rd(p, root_ctl, 0, 4096); + try testing.expectEqual(Status.ok, status.reply.status); + var lines = std.mem.tokenizeScalar(u8, status.bytes, '\n'); + try testing.expect(std.mem.startsWith(u8, lines.next().?, "pid ")); + var expected: [64]u8 = undefined; + try testing.expectEqualStrings(try std.fmt.bufPrint(&expected, "version {s}", .{pardes.version}), lines.next().?); + try testing.expectEqualStrings("panes 1", lines.next().?); + try testing.expect(lines.next() == null); + const stat = call(p, .{ .tag = 1, .op = .getattr, .node = root_ctl }); + try testing.expectEqual(@as(u64, status.bytes.len), stat.reply.attr.size); + try testing.expectEqual(@as(u16, 0o666), stat.reply.attr.mode); + + const serial = p.next_serial; + for ([_][]const u8{ "look", "exec", "look \t", "Look /virtual/index", "exec Msg a\x00b", "exec Msg x\nbogus\n", "name x", "put" }) |invalid| { + try testing.expectEqual(E.INVAL, wr(p, root_ctl, invalid).errno()); + try testing.expectEqual(serial, p.next_serial); + } + try testing.expectEqualStrings(status.bytes, rd(p, root_ctl, 0, 4096).bytes); + + const pane = p.panes[0].?; + try testing.expectEqual(Status.ok, wr(p, root_ctl, "exec Msg hello there\n").reply.status); + try testing.expectEqualStrings("hello there", pane.msg[0..pane.msg_len]); + try testing.expectEqualStrings(try std.fmt.bufPrint(&expected, "{d}\n", .{pane.serial}), rd(p, root_ctl, 0, 4096).bytes); + + try testing.expectEqual(Status.ok, wr(p, root_ctl, "look /virtual/index\nexec New\n").reply.status); + var made: [MAX_PANES]u32 = undefined; + var n: usize = 0; + for (p.panes) |slot| if (slot) |q| if (q.serial != pane.serial) { + made[n] = q.serial; + n += 1; + }; + try testing.expectEqual(@as(usize, 2), n); + const listed = rd(p, root_ctl, 0, 4096); + try testing.expectEqualStrings(try std.fmt.bufPrint(&expected, "{d}\n{d}\n", .{ @min(made[0], made[1]), @max(made[0], made[1]) }), listed.bytes); + const opened = p.panes[p.paneBySerial(@min(made[0], made[1])).?].?; + try testing.expectEqualStrings("/virtual/index", opened.file.?.path); +} + +test "look opens spaced paths and locations without editing the source pane" { + if (!fs.platform_has_fs) return error.SkipZigTest; + const gpa = testing.allocator; + var tmp = testing.tmpDir(.{}); + defer tmp.cleanup(); + try tmp.dir.writeFile(testing.io, .{ .sub_path = "two words.zig", .data = "first\nsecond\nthird\n" }); + var path_buf: [4096]u8 = undefined; + const path = path_buf[0..try tmp.dir.realPathFile(testing.io, "two words.zig", &path_buf)]; + const p = try withFile(gpa, "source stays intact\n"); + defer p.deinit(); + const source = p.panes[0].?; + const ctl_node = Node.of(source.serial, .ctl); + const revision = source.file.?.revision; + const undo_len = source.file.?.history.undo_len; + source.cur_col = 3; + var command: [4200]u8 = undefined; + try testing.expectEqual(Status.ok, wr(p, ctl_node, try std.fmt.bufPrint(&command, "look {s}:2:3\n", .{path})).reply.status); + const opened = p.panes[p.active].?; + try testing.expect(opened != source); + try testing.expectEqualStrings(path, opened.file.?.path); + try testing.expectEqualStrings("first\nsecond\nthird\n", opened.file.?.content); + try testing.expectEqual(@as(i32, 1), opened.cur_row); + try testing.expectEqual(@as(i32, 2), opened.cur_col); + try testing.expectEqualStrings("source stays intact\n", source.file.?.content); + try testing.expectEqual(revision, source.file.?.revision); + try testing.expectEqual(undo_len, source.file.?.history.undo_len); + try testing.expectEqual(@as(i32, 3), source.cur_col); + var expected: [16]u8 = undefined; + try testing.expectEqualStrings(try std.fmt.bufPrint(&expected, "{d}\n", .{opened.serial}), rd(p, root_ctl, 0, 4096).bytes); + + p.active = 0; + try testing.expectEqual(Status.ok, wr(p, root_ctl, try std.fmt.bufPrint(&command, "look {s}:3:2\n", .{path})).reply.status); + try testing.expect(p.panes[p.active].? == opened); + try testing.expectEqual(@as(i32, 2), opened.cur_row); + try testing.expectEqual(@as(i32, 1), opened.cur_col); + try testing.expectEqualStrings(try std.fmt.bufPrint(&expected, "{d}\n", .{opened.serial}), rd(p, root_ctl, 0, 4096).bytes); +} + +test "look validates the whole batch before opening virtual files" { + const gpa = testing.allocator; + const p = try withFile(gpa, "source\n"); + defer p.deinit(); + const source = p.panes[0].?; + const ctl_node = Node.of(source.serial, .ctl); + const serial = p.next_serial; + for ([_][]const u8{ + "look", "look \t", "look /virtual/index\x00ignored", "look /virtual/index\nbogus\n", + }) |invalid| { + try testing.expectEqual(E.INVAL, wr(p, ctl_node, invalid).errno()); + try testing.expectEqual(serial, p.next_serial); + try testing.expectEqual(@as(usize, 0), p.active); + try testing.expectEqualStrings("source\n", source.file.?.content); + } + try testing.expectEqual(Status.ok, wr(p, ctl_node, "look /n/self/index\n").reply.status); + const opened = p.panes[p.active].?; + try testing.expectEqualStrings("/virtual/index", opened.file.?.path); + try testing.expect(std.mem.indexOf(u8, opened.file.?.content, "/test.txt") != null); + try testing.expectEqualStrings("source\n", source.file.?.content); +} + +test "get reloads the pane from disk and reports a missing file without losing dirty contents" { + const gpa = testing.allocator; + var tmp = testing.tmpDir(.{}); + defer tmp.cleanup(); + try tmp.dir.writeFile(testing.io, .{ .sub_path = "note.txt", .data = "from disk\n" }); + var directory_buf: [4096]u8 = undefined; + const directory = directory_buf[0..try tmp.dir.realPath(testing.io, &directory_buf)]; + var path_buf: [4096]u8 = undefined; + const path = try std.fmt.bufPrint(&path_buf, "{s}/note.txt", .{directory}); + + const p = try withFile(gpa, "in memory\n"); + defer p.deinit(); + const serial = serialOf(p); + const ctl_node = Node.of(serial, .ctl); + const pane = p.panes[0].?; + + var name: [std.fs.max_path_bytes + 8]u8 = undefined; + _ = wr(p, Node.of(serial, .name), try std.fmt.bufPrint(&name, "{s}\n", .{path})); + try testing.expectEqual(Status.ok, wr(p, ctl_node, "get\n").reply.status); + try testing.expectEqualStrings("from disk\n", pane.file.?.content); + try testing.expect(!pane_files.dirtyOf(pane)); + try testing.expect(pane.file.?.history.undo_len > 0); + + _ = wr(p, Node.of(serial, .name), try std.fmt.bufPrint(&name, "{s}/missing.txt\n", .{directory})); + _ = wr(p, Node.of(serial, .body), "unsaved\n"); + try testing.expectEqual(E.NOENT, wr(p, ctl_node, "get\nexec Del\n").errno()); + try testing.expect(p.paneBySerial(serial) != null); + try testing.expectEqualStrings("from disk\nunsaved\n", pane.file.?.content); + try testing.expect(pane_files.dirtyOf(pane)); +} + +test "exec Save writes the named file through the host" { + const gpa = testing.allocator; + const p = try withFile(gpa, "one\ntwo\n"); + defer p.deinit(); + const serial = serialOf(p); + const pane = p.panes[0].?; + try testing.expectEqual(Status.ok, wr(p, Node.of(serial, .name), "/tmp/renamed.txt\n").reply.status); + try testing.expect(pane_files.dirtyOf(pane)); + const saved = wr(p, Node.of(serial, .ctl), "exec Save\n"); + try testing.expectEqual(Status.ok, saved.reply.status); + try testing.expect(saved.saved); + p.perform(.{ .save_file = .{ .pane = 0 } }); + try testing.expect(!pane_files.dirtyOf(pane)); + try testing.expectEqualStrings(pane.file.?.content, p.fallback.get("/tmp/renamed.txt").?); +} diff --git a/src/ninep/events.zig b/src/ninep/events.zig new file mode 100644 index 00000000..fb49e41b --- /dev/null +++ b/src/ninep/events.zig @@ -0,0 +1,558 @@ +//! Event streams: per-pane `event` records, the editor-wide `log`, and the +//! bounded queues that park a read until something happens. +const std = @import("std"); +const pardes = @import("../pardes.zig"); +const tree = @import("tree.zig"); +const pane_files = @import("pane.zig"); + +const Pardes = pardes.Pardes; +const Pane = pardes.Pane; +const MAX_PANES = pardes.MAX_PANES; +const Req = tree.Req; +const Reply = tree.Reply; +const E = tree.E; + +pub const queue_cap = 64 * 1024; + +/// Wall-clock seconds, or zero where the platform has no clock. +pub fn now() u32 { + if (comptime !pardes.hosted) return 0; + var ts: std.c.timespec = undefined; + if (std.c.clock_gettime(.REALTIME, &ts) != 0) return 0; + return std.math.cast(u32, ts.sec) orelse 0; +} + +pub const Queue = struct { + buf: std.ArrayList(u8) = .empty, + head: usize = 0, + + pub fn deinit(q: *Queue, gpa: std.mem.Allocator) void { + q.buf.deinit(gpa); + q.head = 0; + } + + pub fn push(q: *Queue, gpa: std.mem.Allocator, record: []const u8) void { + if (record.len > std.math.maxInt(u32)) return; + while (q.buf.items.len - q.head + record.len + 4 > queue_cap) { + if (q.peek() == null) return; + q.pop(); + } + q.compact(); + var head: [4]u8 = undefined; + std.mem.writeInt(u32, &head, @intCast(record.len), .little); + q.buf.appendSlice(gpa, &head) catch return; + q.buf.appendSlice(gpa, record) catch { + q.buf.shrinkRetainingCapacity(q.buf.items.len - 4); + return; + }; + } + + pub fn peek(q: *const Queue) ?[]const u8 { + const rest = q.buf.items[@min(q.head, q.buf.items.len)..]; + if (rest.len < 4) return null; + const len = std.mem.readInt(u32, rest[0..4], .little); + if (rest.len < 4 + len) return null; + return rest[4 .. 4 + len]; + } + + pub fn pop(q: *Queue) void { + const record = q.peek() orelse return; + q.head += 4 + record.len; + if (q.head == q.buf.items.len) { + q.buf.clearRetainingCapacity(); + q.head = 0; + } + } + + pub fn popFront(q: *Queue, n: usize) void { + const record = q.peek() orelse return; + if (n >= record.len) return q.pop(); + q.head += n; + std.mem.writeInt(u32, q.buf.items[q.head..][0..4], @intCast(record.len - n), .little); + } + + fn compact(q: *Queue) void { + if (q.head == 0 or q.head * 2 < q.buf.items.len) return; + const rest = q.buf.items.len - q.head; + std.mem.copyForwards(u8, q.buf.items[0..rest], q.buf.items[q.head..]); + q.buf.shrinkRetainingCapacity(rest); + q.head = 0; + } + + pub fn empty(q: *const Queue) bool { + return q.peek() == null; + } + + pub fn clearAndFree(q: *Queue, gpa: std.mem.Allocator) void { + q.buf.clearAndFree(gpa); + q.head = 0; + } +}; + +/// One record per read; `.again` parks the read until a record arrives. +pub fn readQueue(p: *Pardes, req: Req, q: *Queue) Reply { + const record = q.peek() orelse return .{ .tag = req.tag, .status = .again }; + if (req.size < record.len) return Reply.fail(req.tag, E.INVAL); + const out = p.fs.stage(p.gpa); + out.appendSlice(p.gpa, record) catch return Reply.fail(req.tag, E.NOMEM); + q.pop(); + return .{ .tag = req.tag, .payload = .{ .staged = @intCast(out.items.len) } }; +} + +// ---- the editor-wide log ---- + +pub const LogKind = enum { new, del, rename, save }; + +/// A pane installed now is announced by `announce` once the update that made +/// it has finished, when its name is known. +pub fn noteInstall(p: *Pardes, id: usize) void { + if (id < MAX_PANES) p.fs.panes[id].unannounced = true; +} + +/// A pane leaving; one never announced leaves silently. +pub fn noteRetire(p: *Pardes, id: usize, pane: *Pane) void { + if (id >= MAX_PANES) return; + if (p.fs.panes[id].unannounced) { + p.fs.panes[id].unannounced = false; + return; + } + noteLog(p, .del, pane); +} + +/// Called at the end of every update: reports the panes installed by it. +pub fn announce(p: *Pardes) void { + for (p.panes, 0..) |slot, id| { + const pf = &p.fs.panes[id]; + if (!pf.unannounced) continue; + pf.unannounced = false; + if (slot) |pane| noteLog(p, .new, pane); + } +} + +/// Records ` ` while a reader holds /log open. +pub fn noteLog(p: *Pardes, kind: LogKind, pane: *Pane) void { + if (p.fs.log_readers == 0) return; + var buf: [4096 + 64]u8 = undefined; + const name = pane_files.nameOf(pane); + const record = std.fmt.bufPrint(&buf, "{s} {d} {s}\n", .{ @tagName(kind), pane.serial, name[0..@min(name.len, 4096)] }) catch return; + p.fs.log.push(p.gpa, record); +} + +// ---- per-pane event records ---- + +pub const max_record_text = 256; + +pub const Action = enum(u8) { + body_delete = 'D', + tag_delete = 'd', + body_insert = 'I', + tag_insert = 'i', + body_look = 'L', + tag_look = 'l', + body_exec = 'X', + tag_exec = 'x', + + pub fn char(a: Action) u8 { + return @intFromEnum(a); + } + + pub fn fromChar(c: u8) ?Action { + return std.enums.fromInt(Action, c); + } + + pub fn onTag(a: Action) bool { + return @intFromEnum(a) >= 'a'; + } +}; + +pub const flag_builtin: u32 = 1; +pub const flag_expansion: u32 = 2; +pub const flag_filename: u32 = 4; +pub const flag_chorded: u32 = 8; + +pub fn formatRecord( + buf: []u8, + origin: u8, + action: Action, + q0: u32, + q1: u32, + flag: u32, + text: []const u8, +) []const u8 { + const sent = if (text.len >= max_record_text) text[0..0] else text; + return std.fmt.bufPrint(buf, "{c}{c}{d} {d} {d} {d} {s}\n", .{ + origin, + action.char(), + q0, + q1, + flag, + sent.len, + sent, + }) catch buf[0..0]; +} + +pub const Span = struct { at: u32, removed: u32, inserted: u32 }; + +pub fn diffSpan(old: []const u8, new: []const u8) Span { + const both = @min(old.len, new.len); + const stride = 64; + var head: usize = 0; + while (head + stride <= both and + std.mem.eql(u8, old[head..][0..stride], new[head..][0..stride])) head += stride; + while (head < both and old[head] == new[head]) head += 1; + var tail: usize = 0; + const rest = both - head; + while (tail + stride <= rest and std.mem.eql( + u8, + old[old.len - tail - stride ..][0..stride], + new[new.len - tail - stride ..][0..stride], + )) tail += stride; + while (tail < rest and old[old.len - 1 - tail] == new[new.len - 1 - tail]) tail += 1; + return .{ + .at = @intCast(head), + .removed = @intCast(old.len - tail - head), + .inserted = @intCast(new.len - tail - head), + }; +} + +pub fn noteReplace(p: *Pardes, id: usize, on_tag: bool, old: []const u8, new: []const u8) void { + if (!p.fs.scripted(id)) return; + const span = diffSpan(old, new); + if (span.removed == 0 and span.inserted == 0) return; + if (span.removed > 0) _ = noteAction( + p, + id, + if (on_tag) .tag_delete else .body_delete, + span.at, + span.at + span.removed, + 0, + "", + ); + if (span.inserted > 0) _ = noteAction( + p, + id, + if (on_tag) .tag_insert else .body_insert, + span.at, + span.at + span.inserted, + 0, + new[span.at..][0..span.inserted], + ); +} + +pub fn noteAction( + p: *Pardes, + id: usize, + action: Action, + q0: u32, + q1: u32, + flag: u32, + text: []const u8, +) bool { + if (!p.fs.scripted(id)) return false; + var buf: [max_record_text + 64]u8 = undefined; + const record = formatRecord(&buf, p.fs.origin, action, q0, q1, flag, text); + p.fs.panes[id].events.push(p.gpa, record); + return true; +} + +pub fn notePtyOutput(p: *Pardes, id: usize, bytes: []const u8) void { + if (id >= MAX_PANES or bytes.len == 0) return; + const pf = &p.fs.panes[id]; + if (pf.pty_readers == 0) return; + var off: usize = 0; + while (off < bytes.len) { + const n = @min(bytes.len - off, queue_cap / 2); + pf.pty_out.push(p.gpa, bytes[off..][0..n]); + off += n; + } +} + +const EventRecord = struct { action: Action, q0: u32, q1: u32 }; + +const EventReader = struct { + data: []const u8, + i: usize = 0, + + fn next(er: *EventReader) ?EventRecord { + if (er.i >= er.data.len) return null; + var i = er.i; + if (i + 2 > er.data.len) return null; + i += 1; + const action = Action.fromChar(er.data[i]) orelse return null; + i += 1; + const q0 = scanNumber(er.data, &i) orelse return null; + const q1 = scanNumber(er.data, &i) orelse return null; + while (i < er.data.len and er.data[i] == ' ') i += 1; + if (i >= er.data.len or er.data[i] != '\n') return null; + er.i = i + 1; + return .{ .action = action, .q0 = q0, .q1 = q1 }; + } +}; + +fn scanNumber(data: []const u8, i: *usize) ?u32 { + while (i.* < data.len and data[i.*] == ' ') i.* += 1; + const s = i.*; + var n: u64 = 0; + while (i.* < data.len and data[i.*] >= '0' and data[i.*] <= '9') : (i.* += 1) + n = @min(n * 10 + (data[i.*] - '0'), std.math.maxInt(u32)); + if (i.* == s) return null; + return @intCast(n); +} + +/// Writing a Look or Exec record back performs the action it names. +pub fn writeEvent(p: *Pardes, req: Req, id: usize) Reply { + const pane0 = p.panes[id] orelse return Reply.fail(req.tag, E.NOENT); + const serial = pane0.serial; + { + const body = pane_files.bodyOf(pane0); + const tag = pane_files.tagOf(p, pane0); + var check: EventReader = .{ .data = req.data }; + while (check.next()) |r| { + switch (r.action) { + .body_look, .tag_look, .body_exec, .tag_exec => {}, + else => return Reply.fail(req.tag, E.INVAL), + } + const n = if (r.action.onTag()) tag.len else body.len; + if (r.q0 > r.q1 or r.q1 > n) return Reply.fail(req.tag, E.INVAL); + } + if (check.i != req.data.len) return Reply.fail(req.tag, E.INVAL); + } + var run: EventReader = .{ .data = req.data }; + while (run.next()) |r| { + const live = p.paneBySerial(serial) orelse break; + const pane = p.panes[live].?; + const whole = if (r.action.onTag()) pane_files.tagOf(p, pane) else pane_files.bodyOf(pane); + const lo = @min(@as(usize, r.q0), whole.len); + const hi = @max(lo, @min(@as(usize, r.q1), whole.len)); + const text = p.scratch.allocator().dupe(u8, whole[lo..hi]) catch continue; + switch (r.action) { + .body_exec, .tag_exec => _ = p.execute(live, text), + .body_look, .tag_look => p.lookAt(live, text), + else => unreachable, + } + } + return .{ .tag = req.tag, .written = @intCast(req.data.len) }; +} + +// ---- tests ---- + +const testing = std.testing; +const th = @import("testing.zig"); +const call = th.call; +const rd = th.rd; +const wr = th.wr; +const withFile = th.withFile; +const serialOf = th.serialOf; +const Node = tree.Node; +const Status = tree.Status; + +test "event records are acme's bytes, one per read, and .again when empty" { + const gpa = testing.allocator; + const p = try withFile(gpa, "Msg fs-ran\n"); + defer p.deinit(); + const serial = serialOf(p); + const event = Node.of(serial, .event); + + _ = noteAction(p, 0, .body_exec, 1, 4, flag_builtin, "sg "); + try testing.expect(p.fs.panes[0].events.empty()); + + const h = call(p, .{ .tag = 10, .op = .open, .node = event }); + try testing.expect(h.reply.handle != 0); + try testing.expectEqual(@as(u16, 1), p.fs.listeners); + + try testing.expectEqual(Status.again, rd(p, event, 0, 4096).reply.status); + + p.fs.origin = 'M'; + _ = noteAction(p, 0, .body_exec, 1, 4, flag_builtin, "ell"); + _ = noteAction(p, 0, .body_delete, 0, 3, 0, ""); + try testing.expectEqualStrings("MX1 4 1 3 ell\n", rd(p, event, 0, 4096).bytes); + try testing.expectEqualStrings("MD0 3 0 0 \n", rd(p, event, 0, 4096).bytes); + try testing.expectEqual(Status.again, rd(p, event, 0, 4096).reply.status); + + _ = noteAction(p, 0, .body_look, 0, 3, flag_filename, "one"); + try testing.expectEqual(E.INVAL, rd(p, event, 0, 4).errno()); + try testing.expectEqualStrings("ML0 3 4 3 one\n", rd(p, event, 0, 4096).bytes); + + const big = "z" ** max_record_text; + _ = noteAction(p, 0, .body_exec, 0, max_record_text, 0, big); + try testing.expectEqualStrings("MX0 256 0 0 \n", rd(p, event, 0, 4096).bytes); + + _ = call(p, .{ .tag = 11, .op = .release, .node = event, .handle = h.reply.handle }); + try testing.expectEqual(@as(u16, 0), p.fs.listeners); +} + +fn drainEvents(p: *Pardes, node: u64, store: []u8, out: [][]const u8) [][]const u8 { + var used: usize = 0; + var n: usize = 0; + while (n < out.len) { + const a = rd(p, node, 0, 4096); + if (a.reply.status != .ok) break; + @memcpy(store[used..][0..a.bytes.len], a.bytes); + out[n] = store[used..][0..a.bytes.len]; + used += a.bytes.len; + n += 1; + } + return out[0..n]; +} + +test "a write through the filesystem is reported once, attributed to the file it came through" { + const gpa = testing.allocator; + const p = try withFile(gpa, "one\ntwo\n"); + defer p.deinit(); + const serial = serialOf(p); + const event = Node.of(serial, .event); + _ = call(p, .{ .tag = 40, .op = .open, .node = event }); + var store: [4096]u8 = undefined; + var slots: [16][]const u8 = undefined; + _ = drainEvents(p, event, &store, &slots); + + _ = wr(p, Node.of(serial, .body), "three\n"); + const body_recs = drainEvents(p, event, &store, &slots); + try testing.expect(body_recs.len >= 1); + try testing.expectEqualStrings("EI8 14 0 6 three\n\n", body_recs[0]); + for (body_recs[1..]) |r| { + try testing.expectEqual(@as(u8, 'E'), r[0]); + try testing.expect(Action.fromChar(r[1]).?.onTag()); + } + + _ = wr(p, Node.of(serial, .addr), "1"); + _ = wr(p, Node.of(serial, .data), "ONE\n"); + const data_recs = drainEvents(p, event, &store, &slots); + try testing.expectEqual(@as(usize, 2), data_recs.len); + try testing.expectEqualStrings("FD0 3 0 0 \n", data_recs[0]); + try testing.expectEqualStrings("FI0 3 0 3 ONE\n", data_recs[1]); + try testing.expectEqual(Status.again, rd(p, event, 0, 4096).reply.status); +} + +test "two event readers each count once, and the second closing leaves the first" { + const gpa = testing.allocator; + const p = try withFile(gpa, "x\n"); + defer p.deinit(); + const event = Node.of(serialOf(p), .event); + + _ = call(p, .{ .tag = 12, .op = .open, .node = event }); + _ = call(p, .{ .tag = 13, .op = .open, .node = event }); + try testing.expectEqual(@as(u16, 2), p.fs.panes[0].readers); + try testing.expectEqual(@as(u16, 2), p.fs.listeners); + + _ = call(p, .{ .tag = 14, .op = .release, .node = event }); + try testing.expectEqual(@as(u16, 1), p.fs.panes[0].readers); + try testing.expect(p.fs.scripted(0)); + + _ = call(p, .{ .tag = 15, .op = .release, .node = Node.of(serialOf(p), .body) }); + try testing.expectEqual(@as(u16, 1), p.fs.listeners); + + _ = call(p, .{ .tag = 16, .op = .release, .node = event }); + try testing.expectEqual(@as(u16, 0), p.fs.listeners); + try testing.expect(!p.fs.scripted(0)); + _ = call(p, .{ .tag = 17, .op = .release, .node = event }); + try testing.expectEqual(@as(u16, 0), p.fs.listeners); +} + +test "a pane deleted while its event file is open leaves no suppression behind" { + const gpa = testing.allocator; + const p = try withFile(gpa, "x\n"); + defer p.deinit(); + const serial = serialOf(p); + const event = Node.of(serial, .event); + _ = try th.newPane(p); + + const a = call(p, .{ .tag = 18, .op = .open, .node = event }); + const b = call(p, .{ .tag = 19, .op = .open, .node = event }); + try testing.expectEqual(@as(u16, 2), p.fs.listeners); + + _ = wr(p, Node.of(serial, .ctl), "exec Del\n"); + try testing.expect(p.paneBySerial(serial) == null); + try testing.expectEqual(@as(u16, 0), p.fs.listeners); + + _ = call(p, .{ .tag = 20, .op = .release, .node = event, .handle = a.reply.handle }); + _ = call(p, .{ .tag = 21, .op = .release, .node = event, .handle = b.reply.handle }); + try testing.expectEqual(@as(u16, 0), p.fs.listeners); + + try testing.expectEqual(E.NOENT, rd(p, event, 0, 64).errno()); + try testing.expectEqual(E.NOENT, rd(p, Node.of(serial, .body), 0, 64).errno()); + try testing.expectEqual(E.NOENT, wr(p, Node.of(serial, .ctl), "clean\n").errno()); + try testing.expectEqual(E.NOENT, call(p, .{ .tag = 22, .op = .open, .node = event }).errno()); +} + +test "writing an event record back performs the action it names" { + const gpa = testing.allocator; + const p = try withFile(gpa, "Msg fs-ran\n"); + defer p.deinit(); + const serial = serialOf(p); + const event = Node.of(serial, .event); + const pane = p.panes[0].?; + + const w = wr(p, event, "FX0 10\n"); + try testing.expectEqual(Status.ok, w.reply.status); + try testing.expectEqualStrings("fs-ran", pane.msg[0..pane.msg_len]); + + pane.msg_len = 0; + try testing.expectEqual(Status.ok, wr(p, event, "FX0 10\nFX0 10\n").reply.status); + try testing.expectEqualStrings("fs-ran", pane.msg[0..pane.msg_len]); + + pane.msg_len = 0; + for ([_][]const u8{ + "FX0 10\nFQ0 1\n", // unknown type character + "FX0 999\n", // out of range + "FX0 10", // no newline + "FX5 1\n", // q0 > q1 + "FD0 3\n", // a report, not a request + "F\n", + }) |bad| { + try testing.expectEqual(E.INVAL, wr(p, event, bad).errno()); + try testing.expectEqual(@as(usize, 0), pane.msg_len); + } + + _ = call(p, .{ .tag = 23, .op = .open, .node = event }); + p.fs.origin = 'K'; + _ = wr(p, event, "KX0 10\n"); + try testing.expectEqual(@as(u8, 'F'), p.fs.origin); +} + +test "the log parks until a pane is created, renamed, saved or deleted" { + const gpa = testing.allocator; + const p = try withFile(gpa, "logged\n"); + defer p.deinit(); + const log = @intFromEnum(tree.TopFile.log); + _ = try th.newPane(p); + try testing.expect(p.fs.log.empty()); + + const opened = call(p, .{ .tag = 1, .op = .open, .node = log }); + try testing.expectEqual(Status.ok, opened.reply.status); + try testing.expectEqual(@as(u16, 1), p.fs.log_readers); + try testing.expectEqual(Status.again, rd(p, log, 0, 4096).reply.status); + + const serial = try th.newPane(p); + const id = p.paneBySerial(serial).?; + var expected: [4200]u8 = undefined; + try testing.expectEqualStrings( + try std.fmt.bufPrint(&expected, "new {d} {s}\n", .{ serial, pane_files.nameOf(p.panes[id].?) }), + rd(p, log, 0, 4096).bytes, + ); + try testing.expectEqual(Status.ok, wr(p, Node.of(serial, .name), "/tmp/logged.txt\n").reply.status); + try testing.expectEqualStrings( + try std.fmt.bufPrint(&expected, "rename {d} /tmp/logged.txt\n", .{serial}), + rd(p, log, 0, 4096).bytes, + ); + const saving = wr(p, Node.of(serial, .ctl), "exec Save\n"); + try testing.expectEqual(Status.ok, saving.reply.status); + try testing.expect(saving.saved); + p.perform(.{ .save_file = .{ .pane = @intCast(id) } }); + try testing.expectEqualStrings( + try std.fmt.bufPrint(&expected, "save {d} /tmp/logged.txt\n", .{serial}), + rd(p, log, 0, 4096).bytes, + ); + try testing.expectEqual(Status.ok, wr(p, Node.of(serial, .ctl), "exec Del\n").reply.status); + try testing.expectEqualStrings( + try std.fmt.bufPrint(&expected, "del {d} /tmp/logged.txt\n", .{serial}), + rd(p, log, 0, 4096).bytes, + ); + try testing.expectEqual(Status.again, rd(p, log, 0, 4096).reply.status); + + _ = call(p, .{ .tag = 2, .op = .release, .node = log, .handle = opened.reply.handle }); + try testing.expectEqual(@as(u16, 0), p.fs.log_readers); + _ = try th.newPane(p); + try testing.expect(p.fs.log.empty()); + try testing.expectEqual(@as(usize, 0), p.fs.log.buf.capacity); +} diff --git a/src/ninep/pane.zig b/src/ninep/pane.zig new file mode 100644 index 00000000..b37ae645 --- /dev/null +++ b/src/ninep/pane.zig @@ -0,0 +1,840 @@ +//! The files under /pane//: name, body, tag, ctl, addr, data, xdata, +//! sel, errors and event. Terminal panes add pty/ (pty.zig). +const std = @import("std"); +const pardes = @import("../pardes.zig"); +const panes = @import("../panes.zig"); +const modal = @import("../modal.zig"); +const config = @import("../config.zig"); +const fs = @import("../fs.zig"); +const tree = @import("tree.zig"); +const events = @import("events.zig"); +const addressing = @import("addr.zig"); +const ctl = @import("ctl.zig"); +const pty = @import("pty.zig"); +const screen = @import("screen.zig"); + +const Pardes = pardes.Pardes; +const Pane = pardes.Pane; +const Req = tree.Req; +const Reply = tree.Reply; +const E = tree.E; +const PaneFile = tree.PaneFile; +const Node = tree.Node; + +/// Filesystem state a pane carries beside its editor state. +pub const State = struct { + addr: Range = .{}, + limit: ?Range = null, + readers: u16 = 0, + events: events.Queue = .{}, + nomark: bool = false, + noscroll: bool = false, + tag_snap: std.ArrayList(u8) = .empty, + pty_readers: u16 = 0, + pty_out: events.Queue = .{}, + /// Installed during this update; /log hears about it once the update ends + /// and the pane has its file, name and place. + unannounced: bool = false, + + pub const Range = struct { q0: u32 = 0, q1: u32 = 0 }; + + pub fn deinit(pf: *State, gpa: std.mem.Allocator) void { + pf.events.deinit(gpa); + pf.pty_out.deinit(gpa); + pf.tag_snap.deinit(gpa); + pf.* = .{}; + } +}; + +// ---- what a pane is ---- + +pub fn bodyOf(pane: *const Pane) []const u8 { + if (pane.file) |*f| return f.content; + return ""; +} + +pub fn fileOf(pane: *Pane) ?*panes.File.State { + return if (pane.file) |*f| f else null; +} + +pub fn tagOf(p: *Pardes, pane: *Pane) []const u8 { + return p.tagText(p.scratch.allocator(), pane) catch ""; +} + +pub fn dirOf(pane: *Pane) []const u8 { + if (pane.file) |*f| return std.fs.path.dirname(f.path) orelse "/"; + const cwd = pane.cwdSlice(); + return if (cwd.len > 0) cwd else "/"; +} + +pub fn dirtyOf(pane: *const Pane) bool { + const f = if (pane.file) |*x| x else return false; + if (!panes.Output.fileTraits(f.output).saves) return false; + return f.revision != f.saved_revision; +} + +/// The pane's name: its file, its document, or a terminal's directory. +pub fn nameOf(pane: *const Pane) []const u8 { + if (pane.file) |*f| return f.path; + if (pane.pdfPath()) |path| return path; + if (pane.image) |state| return state.path; + const cwd = pane.cwdSlice(); + return if (cwd.len > 0) cwd else "/"; +} + +pub fn kindOf(pane: *const Pane) []const u8 { + if (pane.file != null) return "text"; + if (pane.pdfPath() != null) return "pdf"; + if (pane.image != null) return "image"; + return "term"; +} + +pub fn mtimeOf(p: *Pardes, pane: *const Pane) u32 { + if (pane.file) |*f| if (f.mtime != 0) return f.mtime; + return p.fs.started; +} + +pub fn clip(n: usize) u32 { + return std.math.cast(u32, n) orelse std.math.maxInt(u32); +} + +fn cellOf(row: i32, col: i32) modal.Cursor { + return .{ .row = @intCast(@max(0, row)), .col = @intCast(@max(0, col)) }; +} + +pub fn dotOf(pane: *Pane) State.Range { + const text = bodyOf(pane); + const head = modal.offsetAt(text, cellOf(pane.cur_row, pane.cur_col)); + if (!pane.vsel.active) return .{ .q0 = clip(head), .q1 = clip(head) }; + const anchor = modal.offsetAt(text, cellOf(pane.vsel.row, pane.vsel.col)); + var hi = @max(head, anchor); + if (hi < text.len) hi = modal.nextGrapheme(text, hi); + return .{ .q0 = clip(@min(head, anchor)), .q1 = clip(hi) }; +} + +pub fn setDot(pane: *Pane, r: State.Range) void { + const text = bodyOf(pane); + const q0 = @min(@as(usize, r.q0), text.len); + const q1 = @max(q0, @min(@as(usize, r.q1), text.len)); + const a = modal.positionAt(text, q0); + pane.vsel = .{ .active = q1 > q0, .row = @intCast(a.row), .col = @intCast(a.col), .explicit = true }; + const h = modal.positionAt(text, if (q1 > q0) modal.prevGrapheme(text, q1) else q0); + pane.cur_row = @intCast(h.row); + pane.cur_col = @intCast(h.col); + pane.cur_pinned = true; + pane.sticky_col = -1; + pane.msel.active = false; + pane.ensureCursorVisible(); +} + +pub fn showOffset(pane: *Pane, off: usize) void { + const text = bodyOf(pane); + const c = modal.positionAt(text, @min(off, text.len)); + pane.cur_row = @intCast(c.row); + pane.cur_col = @intCast(c.col); + pane.cur_pinned = true; + pane.sticky_col = -1; + pane.ensureCursorVisible(); +} + +pub fn clampAddr(pf: *State, len: usize) void { + const n = clip(len); + pf.addr.q0 = @min(pf.addr.q0, n); + pf.addr.q1 = @min(pf.addr.q1, n); + if (pf.limit) |*l| { + l.q0 = @min(l.q0, n); + l.q1 = @min(l.q1, n); + } +} + +fn shiftBy(r: State.Range, at: u32, removed: u32, inserted: u32) State.Range { + return .{ .q0 = shiftOne(r.q0, at, removed, inserted), .q1 = shiftOne(r.q1, at, removed, inserted) }; +} + +fn shiftOne(v: u32, at: u32, removed: u32, inserted: u32) u32 { + if (v <= at) return v; + if (v <= at +| removed) return at +| inserted; + return v - removed +| inserted; +} + +pub fn wholeUtf8(data: []const u8) usize { + var i = data.len; + var back: usize = 0; + while (i > 0 and back < 4) : (back += 1) { + i -= 1; + const c = data[i]; + if (c < 0x80) return data.len; + if (c & 0xC0 == 0xC0) { + const need = std.unicode.utf8ByteSequenceLength(c) catch return data.len; + if (i + need <= data.len or i == 0) return data.len; + return i; + } + } + return data.len; +} + +pub fn spliceBody(p: *Pardes, id: usize, pane: *Pane, q0: usize, q1: usize, bytes: []const u8) ?usize { + const f = fileOf(pane) orelse return null; + const take = if (bytes.len == 0) 0 else wholeUtf8(bytes); + const lo = @min(q0, f.content.len); + const hi = @max(lo, @min(q1, f.content.len)); + const new = p.gpa.alloc(u8, f.content.len - (hi - lo) + take) catch return null; + @memcpy(new[0..lo], f.content[0..lo]); + @memcpy(new[lo..][0..take], bytes[0..take]); + @memcpy(new[lo + take ..], f.content[hi..]); + if (!p.fs.panes[id].nomark) panes.File.pushUndo(p, pane); + panes.File.setContent(p, f, new); + return take; +} + +// ---- sizes reported by stat ---- + +pub fn fileSize(p: *Pardes, id: usize, f: PaneFile) u64 { + const pane = p.panes[id] orelse return 0; + return switch (f) { + .body, .data, .xdata => bodyOf(pane).len, + .tag => tagOf(p, pane).len, + .name => nameOf(pane).len + 1, + .ctl => ctl: { + var buf: [ctl.pane_text_cap]u8 = undefined; + break :ctl ctl.paneText(p, pane, &buf).len; + }, + .sel => sel: { + const d = dotOf(pane); + break :sel @max(d.q0, d.q1) - d.q0; + }, + .dir, .addr, .errors, .event, .pty, .pty_ctl, .pty_status, .pty_data => 0, + }; +} + +// ---- the index ---- + +pub fn stageIndexLine(p: *Pardes, out: *std.ArrayList(u8), pane: *Pane) void { + out.print(p.gpa, "{d} {s} {d} {s}\n", .{ pane.serial, kindOf(pane), @intFromBool(dirtyOf(pane)), nameOf(pane) }) catch {}; +} + +pub fn indexLen(p: *Pardes) u64 { + var n: u64 = 0; + var last: u32 = 0; + while (tree.nextSerialAfter(p, last)) |serial| { + last = serial; + const pane = p.panes[p.paneBySerial(serial).?].?; + var digits: [16]u8 = undefined; + n += (std.fmt.bufPrint(&digits, "{d}", .{serial}) catch unreachable).len; + n += 1 + kindOf(pane).len + 3 + nameOf(pane).len + 1; + } + return n; +} + +// ---- reads ---- + +pub fn read(p: *Pardes, req: Req, id: usize, pane: *Pane, file: PaneFile) Reply { + const pf = &p.fs.panes[id]; + return switch (file) { + .name => name: { + const out = p.fs.stage(p.gpa); + out.appendSlice(p.gpa, nameOf(pane)) catch {}; + out.append(p.gpa, '\n') catch {}; + break :name tree.stagedReply(p, req); + }, + .body => readBody(p, req, id, pane), + .tag => tag: { + const out = p.fs.stage(p.gpa); + out.appendSlice(p.gpa, tagOf(p, pane)) catch {}; + break :tag tree.stagedReply(p, req); + }, + .ctl => ctl.readPane(p, req, pane), + .addr => addr: { + clampAddr(pf, bodyOf(pane).len); + const out = p.fs.stage(p.gpa); + out.print(p.gpa, "{d:>11} {d:>11} ", .{ pf.addr.q0, pf.addr.q1 }) catch {}; + break :addr tree.stagedReply(p, req); + }, + .data => readData(req, id, pane, pf, false), + .xdata => readData(req, id, pane, pf, true), + .sel => readSel(req, id, pane), + .event => events.readQueue(p, req, &pf.events), + .pty_status => pty.readStatus(p, req, id, pane), + .pty_data => pty.readData(p, req, pf), + .dir, .errors, .pty, .pty_ctl => Reply.fail(req.tag, E.PERM), + }; +} + +fn readBody(p: *Pardes, req: Req, id: usize, pane: *Pane) Reply { + if (pane.file != null) { + const text = bodyOf(pane); + const off = @min(req.off, text.len); + const n = @min(text.len - off, req.size); + return .{ .tag = req.tag, .payload = .{ .region = .{ + .pane = @intCast(id), + .serial = pane.serial, + .off = clip(off), + .len = clip(n), + } } }; + } + if (req.handle != 0 and pane.isTerminal()) return screen.readSnapshot(p, req, pane); + const text = panes.Terminal.screenTextAlloc(pane, p.gpa) catch + return Reply.fail(req.tag, E.NOMEM); + defer p.gpa.free(text); + const out = p.fs.stage(p.gpa); + out.appendSlice(p.gpa, text) catch return Reply.fail(req.tag, E.NOMEM); + return tree.stagedReply(p, req); +} + +fn readData(req: Req, id: usize, pane: *Pane, pf: *State, stop_at_end: bool) Reply { + const text = bodyOf(pane); + clampAddr(pf, text.len); + const q0: usize = pf.addr.q0; + const hi: usize = if (stop_at_end) @max(q0, @as(usize, pf.addr.q1)) else text.len; + var end = @min(hi, q0 +| req.size); + end = @max(q0, modal.graphemeStart(text, end)); + pf.addr.q0 = clip(end); + if (!stop_at_end) pf.addr.q1 = clip(end); + if (pane.file == null) return .{ .tag = req.tag }; + return .{ .tag = req.tag, .payload = .{ .region = .{ + .pane = @intCast(id), + .serial = pane.serial, + .off = clip(q0), + .len = clip(end - q0), + } } }; +} + +fn readSel(req: Req, id: usize, pane: *Pane) Reply { + if (pane.file == null) return .{ .tag = req.tag }; + const text = bodyOf(pane); + const d = dotOf(pane); + const lo = @min(@as(usize, d.q0), text.len); + const hi = @max(lo, @min(@as(usize, d.q1), text.len)); + const off = @min(req.off, hi - lo); + const n = @min(hi - lo - off, req.size); + return .{ .tag = req.tag, .payload = .{ .region = .{ + .pane = @intCast(id), + .serial = pane.serial, + .off = clip(lo + off), + .len = clip(n), + } } }; +} + +// ---- writes ---- + +pub fn write(p: *Pardes, req: Req, id: usize, pane: *Pane, file: PaneFile) Reply { + return switch (file) { + .name => writeName(p, req, id, pane), + .body => writeBody(p, req, id, pane), + .tag => writeTag(p, req, pane), + .ctl => ctl.writePane(p, req, pane.serial), + .addr => writeAddr(p, req, id, pane), + .data, .xdata => writeData(p, req, id, pane), + .sel => writeSel(p, req, id, pane), + .event => events.writeEvent(p, req, id), + .errors => if (appendErrors(p, id, req.data)) |took| + .{ .tag = req.tag, .written = @intCast(took) } + else + Reply.fail(req.tag, E.IO), + .pty_ctl => pty.writeCtl(p, req, id), + .pty_data => pty.writeData(p, req, id), + .dir, .pty, .pty_status => Reply.fail(req.tag, E.PERM), + }; +} + +fn writeBody(p: *Pardes, req: Req, id: usize, pane: *Pane) Reply { + if (req.data.len == 0) return .{ .tag = req.tag, .written = 0 }; + if (pane.file == null) { + const take = wholeUtf8(req.data); + p.emitWrite(id, req.data[0..take]); + return .{ .tag = req.tag, .written = @intCast(take) }; + } + const at = bodyOf(pane).len; + const take = spliceBody(p, id, pane, at, at, req.data) orelse + return Reply.fail(req.tag, E.NOMEM); + if (!p.fs.panes[id].noscroll) showOffset(pane, at + take); + return .{ .tag = req.tag, .written = @intCast(take) }; +} + +fn writeTag(p: *Pardes, req: Req, pane: *Pane) Reply { + if (req.data.len == 0) return .{ .tag = req.tag, .written = 0 }; + p.seedTail(pane); + const room = pane.tag_tail.len - pane.tag_tail_len; + if (room == 0) return Reply.fail(req.tag, E.NOSPC); + const take = wholeUtf8(req.data[0..@min(req.data.len, room)]); + @memcpy(pane.tag_tail[pane.tag_tail_len..][0..take], req.data[0..take]); + pane.tag_tail_len += take; + pane.tag_init = true; + return .{ .tag = req.tag, .written = @intCast(take) }; +} + +fn writeData(p: *Pardes, req: Req, id: usize, pane: *Pane) Reply { + if (fileOf(pane) == null) return Reply.fail(req.tag, E.INVAL); + const pf = &p.fs.panes[id]; + clampAddr(pf, bodyOf(pane).len); + const q0: usize = pf.addr.q0; + const q1: usize = @max(q0, @as(usize, pf.addr.q1)); + const before = dotOf(pane); + const take = spliceBody(p, id, pane, q0, q1, req.data) orelse + return Reply.fail(req.tag, E.NOMEM); + setDot(pane, shiftBy(before, clip(q0), clip(q1 - q0), clip(take))); + pf.addr = .{ .q0 = clip(q0 + take), .q1 = clip(q0 + take) }; + if (!pf.noscroll) showOffset(pane, q0 + take); + return .{ .tag = req.tag, .written = @intCast(take) }; +} + +fn writeSel(p: *Pardes, req: Req, id: usize, pane: *Pane) Reply { + if (fileOf(pane) == null) return Reply.fail(req.tag, E.INVAL); + const d = dotOf(pane); + const q0: usize = d.q0; + const q1: usize = @max(q0, @as(usize, d.q1)); + const take = spliceBody(p, id, pane, q0, q1, req.data) orelse + return Reply.fail(req.tag, E.NOMEM); + setDot(pane, .{ .q0 = clip(q0 + take), .q1 = clip(q0 + take) }); + return .{ .tag = req.tag, .written = @intCast(take) }; +} + +fn writeAddr(p: *Pardes, req: Req, id: usize, pane: *Pane) Reply { + const pf = &p.fs.panes[id]; + const text = bodyOf(pane); + clampAddr(pf, text.len); + const expr = std.mem.trimEnd(u8, req.data, "\n"); + var a: addressing.Addr = .{ .text = text, .lim = pf.limit, .expr = expr }; + const r = a.address(pf.addr) orelse return Reply.fail(req.tag, E.INVAL); + if (a.i < expr.len) return Reply.fail(req.tag, E.INVAL); + pf.addr = r; + return .{ .tag = req.tag, .written = @intCast(req.data.len) }; +} + +/// Writing `name` renames the buffer: a relative name resolves against the +/// pane's directory, as the tag's name field does. +fn writeName(p: *Pardes, req: Req, id: usize, pane: *Pane) Reply { + const name = std.mem.trim(u8, req.data, " \t\r\n"); + if (name.len == 0) return Reply.fail(req.tag, E.INVAL); + for (name) |c| if (c < ' ') return Reply.fail(req.tag, E.INVAL); + if (fileOf(pane) == null) return Reply.fail(req.tag, E.PERM); + const full = std.fs.path.resolvePosix(p.scratch.allocator(), &.{ pardes.Pardes.paneDir(pane), name }) catch + return Reply.fail(req.tag, E.NOMEM); + if (!std.fs.path.isAbsolute(full) or full.len >= 4096) return Reply.fail(req.tag, E.INVAL); + nameBuffer(p, id, full, false) catch |err| return Reply.fail(req.tag, switch (err) { + error.OutOfMemory => E.NOMEM, + else => E.INVAL, + }); + return .{ .tag = req.tag, .written = @intCast(req.data.len) }; +} + +/// Change a buffer's absolute name without writing or renaming a disk file. +/// Tag editing preserves user commands; the filesystem's rename resets its tail. +pub fn nameBuffer(p: *Pardes, id: usize, full: []const u8, preserve_tag: bool) !void { + const pane = p.panes[id] orelse return error.NoPane; + const f = fileOf(pane) orelse return error.NotFile; + if (!std.fs.path.isAbsolute(full) or full.len == 0 or full.len >= 4096) + return error.InvalidName; + for (full) |c| if (c < ' ') return error.InvalidName; + if (std.mem.eql(u8, f.path, full)) return; + const copy = try p.gpa.dupe(u8, full); + p.gpa.free(f.path); + f.path = copy; + if (panes.Output.fileTraits(f.output).saves) { + f.output = null; + pane.clearCwd(); + if (!preserve_tag) { + pane.tag_init = false; + pane.tag_tail_len = 0; + } + f.saved_revision = f.revision -% 1; + f.watch_after_save = fs.localPath(full) != null; + } + if (f.highlights.len > 0) p.tree_sitter_gpa.free(f.highlights); + f.highlights = &.{}; + f.highlight_start = 0; + f.syntax_dirty = true; + f.context_revision = null; + pane.context_rows = 0; + pane.wrap_n = 0; + p.invalidateLookHover(id); + p.emit(.{ .watch = .{ .pane = @intCast(id), .on = false } }); + events.noteLog(p, .rename, pane); +} + +/// Diagnostics go to the +Errors buffer of the pane's directory. +pub fn appendErrors(p: *Pardes, id: usize, text: []const u8) ?usize { + if (text.len == 0) return 0; + const pane = p.panes[id] orelse return null; + const dir = dirOf(pane); + for (p.panes, 0..) |slot, i| { + const q = slot orelse continue; + const qf = fileOf(q) orelse continue; + const o = qf.output orelse continue; + if (std.meta.activeTag(o.from) != .errors) continue; + if (!std.mem.eql(u8, std.fs.path.dirname(qf.path) orelse "", dir)) continue; + return spliceBody(p, i, q, qf.content.len, qf.content.len, text); + } + const free = p.freeSlot() orelse return null; + const content = p.gpa.dupe(u8, text) catch return null; + const np = panes.Output.open(p, free, dir, .errors, "", content) catch { + p.gpa.free(content); + return null; + }; + p.placeDoc(id, free, np); + return text.len; +} + +/// Truncation empties a body; every other setattr just answers fresh attributes. +pub fn truncate(p: *Pardes, id: usize, pane: *Pane, file: PaneFile) tree.Status { + switch (file) { + .body, .data, .xdata => if (fileOf(pane) != null) { + _ = spliceBody(p, id, pane, 0, bodyOf(pane).len, "") orelse return .err; + p.fs.panes[id].addr = .{}; + setDot(pane, .{}); + }, + else => {}, + } + return .ok; +} + +// ---- tests ---- + +const testing = std.testing; +const th = @import("testing.zig"); +const call = th.call; +const rd = th.rd; +const wr = th.wr; +const withFile = th.withFile; +const serialOf = th.serialOf; +const Status = tree.Status; + +test "index lists serial kind dirty flag and name and stat reports its length" { + const gpa = testing.allocator; + const p = try withFile(gpa, "hello\nthere\n"); + defer p.deinit(); + const pane = p.panes[0].?; + const index = @intFromEnum(tree.TopFile.index); + + const a = rd(p, index, 0, 4096); + try testing.expectEqual(Status.ok, a.reply.status); + var want: [64]u8 = undefined; + try testing.expectEqualStrings(try std.fmt.bufPrint(&want, "{d} text 0 /test.txt\n", .{pane.serial}), a.bytes); + const stat = call(p, .{ .tag = 1, .op = .getattr, .node = index }); + try testing.expectEqual(@as(u64, a.bytes.len), stat.reply.attr.size); + try testing.expectEqual(@as(u16, 0o444), stat.reply.attr.mode); + + pane.file.?.saved_revision = pane.file.?.revision -% 1; + try testing.expectEqualStrings(try std.fmt.bufPrint(&want, "{d} text 1 /test.txt\n", .{pane.serial}), rd(p, index, 0, 4096).bytes); + const mid = rd(p, index, 2, 4); + try testing.expectEqualStrings("text", mid.bytes); + + const serial = try th.newPane(p); + const both = rd(p, index, 0, 4096); + try testing.expectEqual(@as(u64, both.bytes.len), indexLen(p)); + var expected: [4200]u8 = undefined; + const made = p.panes[p.paneBySerial(serial).?].?; + try testing.expect(std.mem.endsWith(u8, both.bytes, try std.fmt.bufPrint(&expected, "\n{d} text 0 {s}\n", .{ serial, nameOf(made) }))); +} + +test "a terminal is listed as term with its directory as name" { + const p = try th.withTerm(testing.allocator); + defer p.deinit(); + const pane = p.panes[0].?; + p.setCwd(0, "/work/dir"); + var want: [64]u8 = undefined; + try testing.expectEqualStrings( + try std.fmt.bufPrint(&want, "{d} term 0 /work/dir\n", .{pane.serial}), + rd(p, @intFromEnum(tree.TopFile.index), 0, 4096).bytes, + ); + try testing.expectEqualStrings("/work/dir\n", rd(p, Node.of(pane.serial, .name), 0, 4096).bytes); + try testing.expectEqual(E.PERM, wr(p, Node.of(pane.serial, .name), "/elsewhere\n").errno()); +} + +test "body reads at any offset and writes append" { + const gpa = testing.allocator; + const p = try withFile(gpa, "one\ntwo\n"); + defer p.deinit(); + const serial = serialOf(p); + const body = Node.of(serial, .body); + + try testing.expectEqualStrings("one\ntwo\n", rd(p, body, 0, 100).bytes); + try testing.expectEqualStrings("two\n", rd(p, body, 4, 100).bytes); + try testing.expectEqualStrings("wo", rd(p, body, 5, 2).bytes); + try testing.expectEqualStrings("", rd(p, body, 999, 2).bytes); + try testing.expect(rd(p, body, 0, 100).bytes.ptr == p.panes[0].?.file.?.content.ptr); + + const w = call(p, .{ .tag = 5, .op = .write, .node = body, .off = 0, .data = "three\n" }); + try testing.expectEqual(@as(u32, 6), w.reply.written); + try testing.expectEqualStrings("one\ntwo\nthree\n", p.panes[0].?.file.?.content); + + const short = wr(p, body, "a\xC3"); + try testing.expectEqual(@as(u32, 1), short.reply.written); + try testing.expectEqualStrings("one\ntwo\nthree\na", p.panes[0].?.file.?.content); + + const stat = call(p, .{ .tag = 6, .op = .getattr, .node = body }); + try testing.expectEqual(@as(u64, "one\ntwo\nthree\na".len), stat.reply.attr.size); + try testing.expectEqual(@as(u16, 0o666), stat.reply.attr.mode); + try testing.expect(stat.reply.attr.mtime >= p.fs.started); +} + +test "a body write to a terminal pane types at its shell" { + const gpa = testing.allocator; + const p = try Pardes.init(gpa, .{ .tty_only = true, .cols = 40, .rows = 10 }); + defer p.deinit(); + while (p.nextEffect()) |_| {} + const pane = p.panes[0].?; + try testing.expect(pane.isTerminal()); + + const a = wr(p, Node.of(pane.serial, .body), "ls -l\r"); + try testing.expectEqual(@as(u32, 6), a.reply.written); + try testing.expectEqualStrings("ls -l\r", a.pty()); + + const r = rd(p, Node.of(pane.serial, .body), 0, 64); + try testing.expectEqual(Status.ok, r.reply.status); +} + +test "tag reads the whole tag and writes append to the editable tail" { + const gpa = testing.allocator; + const p = try withFile(gpa, "x\n"); + defer p.deinit(); + const pane = p.panes[0].?; + const node = Node.of(pane.serial, .tag); + + const whole = rd(p, node, 0, 4096); + try testing.expect(std.mem.startsWith(u8, whole.bytes, "/test.txt")); + try testing.expect(std.mem.indexOf(u8, whole.bytes, "Del") != null); + try testing.expectEqual(@as(u64, whole.bytes.len), call(p, .{ .tag = 1, .op = .getattr, .node = node }).reply.attr.size); + + const before = rd(p, node, 0, 4096).bytes.len; + const w = wr(p, node, " Mine"); + try testing.expectEqual(@as(u32, 5), w.reply.written); + try testing.expect(std.mem.endsWith(u8, pane.tag_tail[0..pane.tag_tail_len], " Mine")); + const after = rd(p, node, 0, 4096); + try testing.expectEqual(before + 5, after.bytes.len); + try testing.expect(std.mem.endsWith(u8, after.bytes, " Mine")); + + pane.tag_tail_len = pane.tag_tail.len; + try testing.expectEqual(E.NOSPC, wr(p, node, "x").errno()); +} + +test "data and xdata read from addr, move it, and write through it" { + const gpa = testing.allocator; + const p = try withFile(gpa, "one\ntwo\n"); + defer p.deinit(); + const serial = serialOf(p); + const addr = Node.of(serial, .addr); + const data = Node.of(serial, .data); + const xdata = Node.of(serial, .xdata); + + _ = wr(p, addr, "#0"); + try testing.expectEqualStrings("one", rd(p, data, 0, 3).bytes); + try testing.expectEqual(@as(u32, 3), p.fs.panes[0].addr.q0); + try testing.expectEqual(@as(u32, 3), p.fs.panes[0].addr.q1); + + _ = wr(p, addr, "1"); + try testing.expectEqualStrings("one\n", rd(p, xdata, 0, 100).bytes); + _ = wr(p, addr, "1"); + try testing.expectEqualStrings("one\ntwo\n", rd(p, data, 0, 100).bytes); + + _ = wr(p, addr, "1"); + const w = wr(p, data, "ONE\n"); + try testing.expectEqual(@as(u32, 4), w.reply.written); + try testing.expectEqualStrings("ONE\ntwo\n", p.panes[0].?.file.?.content); + try testing.expectEqual(@as(u32, 4), p.fs.panes[0].addr.q0); +} + +test "data never splits a grapheme, in either direction" { + const gpa = testing.allocator; + const p = try withFile(gpa, "\u{00e9}x\n"); + defer p.deinit(); + const serial = serialOf(p); + _ = wr(p, Node.of(serial, .addr), "#0"); + try testing.expectEqualStrings("", rd(p, Node.of(serial, .data), 0, 1).bytes); + _ = wr(p, Node.of(serial, .addr), "#0"); + try testing.expectEqualStrings("\u{00e9}", rd(p, Node.of(serial, .data), 0, 2).bytes); + + _ = wr(p, Node.of(serial, .addr), "#0"); + try testing.expectEqual(@as(u32, 1), wr(p, Node.of(serial, .data), "a\xC3").reply.written); +} + +test "sel reads the selection and writing sel replaces it" { + const gpa = testing.allocator; + const p = try withFile(gpa, "one\ntwo\n"); + defer p.deinit(); + const serial = serialOf(p); + const ctl_node = Node.of(serial, .ctl); + const sel = Node.of(serial, .sel); + + _ = wr(p, Node.of(serial, .addr), "#0,#3"); + try testing.expectEqual(Status.ok, wr(p, ctl_node, "dot=addr\n").reply.status); + try testing.expectEqualStrings("one", rd(p, sel, 0, 100).bytes); + try testing.expectEqual(@as(u64, 3), call(p, .{ .tag = 1, .op = .getattr, .node = sel }).reply.attr.size); + + _ = wr(p, ctl_node, "addr=dot\n"); + try testing.expectEqual(@as(u32, 0), p.fs.panes[0].addr.q0); + try testing.expectEqual(@as(u32, 3), p.fs.panes[0].addr.q1); + + try testing.expectEqual(Status.ok, wr(p, sel, "ONE").reply.status); + try testing.expectEqualStrings("ONE\ntwo\n", p.panes[0].?.file.?.content); + _ = wr(p, sel, "!"); + try testing.expectEqualStrings("ONE!\ntwo\n", p.panes[0].?.file.?.content); + try testing.expectEqual(@as(u64, 0), call(p, .{ .tag = 2, .op = .getattr, .node = sel }).reply.attr.size); +} + +test "name reads the file name and writing it promotes a scratch without touching its body" { + const gpa = testing.allocator; + const p = try withFile(gpa, "opener\n"); + defer p.deinit(); + const serial = try th.newPane(p); + const pane = p.panes[p.paneBySerial(serial).?].?; + const name = Node.of(serial, .name); + const body = Node.of(serial, .body); + var scratch_name: [4200]u8 = undefined; + const scratch_line = try std.fmt.bufPrint(&scratch_name, "{s}\n", .{nameOf(pane)}); + try testing.expectEqualStrings(scratch_line, rd(p, name, 0, 4096).bytes); + try testing.expectEqual(@as(u64, scratch_line.len), call(p, .{ .tag = 1, .op = .getattr, .node = name }).reply.attr.size); + _ = wr(p, body, "scratch "); + _ = wr(p, body, "work\n"); + const undo_len = pane.file.?.history.undo_len; + var tmp = testing.tmpDir(.{}); + defer tmp.cleanup(); + try tmp.dir.writeFile(testing.io, .{ .sub_path = "renamed.zig", .data = "existing target\n" }); + var directory_buf: [4096]u8 = undefined; + const directory = directory_buf[0..try tmp.dir.realPath(testing.io, &directory_buf)]; + var path_buffer: [4096]u8 = undefined; + const path = try std.fmt.bufPrint(&path_buffer, "{s}/renamed.zig", .{directory}); + var line: [4104]u8 = undefined; + const renamed = wr(p, name, try std.fmt.bufPrint(&line, "{s}\n", .{path})); + try testing.expectEqual(Status.ok, renamed.reply.status); + try testing.expectEqual(false, renamed.watch.?); + try testing.expectEqualStrings("scratch work\n", pane.file.?.content); + try testing.expectEqual(undo_len, pane.file.?.history.undo_len); + try testing.expect(pane.file.?.output == null and dirtyOf(pane)); + try testing.expect(pane.file.?.watch_after_save); + try testing.expectEqualStrings(path, std.mem.trimEnd(u8, rd(p, name, 0, 4096).bytes, "\n")); + const target = try fs.readFile(gpa, path); + defer gpa.free(target); + try testing.expectEqualStrings("existing target\n", target); + for ([_][]const u8{ "", "\n", "bad\x01name\n" }) |bad| + try testing.expectEqual(E.INVAL, wr(p, name, bad).errno()); + try testing.expectEqualStrings(path, pane.file.?.path); + try testing.expectEqual(Status.ok, wr(p, name, "two words.zig\n").reply.status); + const spaced = try std.fmt.bufPrint(&path_buffer, "{s}/two words.zig", .{directory}); + try testing.expectEqualStrings(spaced, pane.file.?.path); +} + +test "name refreshes cached syntax for unchanged contents" { + if (!pardes.syntax.enabled) return error.SkipZigTest; + pardes.syntax.start(testing.allocator); + defer pardes.syntax.stop(); + const p = try withFile(testing.allocator, "fn check() void {}\n"); + defer p.deinit(); + const pane = p.panes[0].?; + panes.File.refreshHighlights(p); + try testing.expectEqual(@as(usize, 0), pane.file.?.highlights.len); + try testing.expectEqual(Status.ok, wr(p, Node.of(pane.serial, .name), "renamed.zig\n").reply.status); + panes.File.refreshHighlights(p); + try testing.expect(pane.file.?.highlights.len >= 2); + try testing.expectEqual(@intFromEnum(pardes.syntax.Syn.keyword), pane.file.?.highlights[0]); + try testing.expectEqual(@intFromEnum(pardes.syntax.Syn.keyword), pane.file.?.highlights[1]); + try testing.expectEqualStrings("fn check() void {}\n", pane.file.?.content); +} + +test "relative names use the file directory and can name a new target" { + const gpa = testing.allocator; + const p = try withFile(gpa, "retained body\n"); + defer p.deinit(); + var tmp = testing.tmpDir(.{}); + defer tmp.cleanup(); + try tmp.dir.writeFile(testing.io, .{ .sub_path = "note.txt", .data = "from pane directory\n" }); + var directory_buf: [4096]u8 = undefined; + const directory = directory_buf[0..try tmp.dir.realPath(testing.io, &directory_buf)]; + const pane = p.panes[0].?; + const name = Node.of(pane.serial, .name); + const ctl_node = Node.of(pane.serial, .ctl); + var line: [4140]u8 = undefined; + try testing.expectEqual(Status.ok, wr(p, name, try std.fmt.bufPrint(&line, "{s}/old.txt\n", .{directory})).reply.status); + try testing.expectEqual(Status.ok, wr(p, name, "child/../note.txt\n").reply.status); + try testing.expectEqual(Status.ok, wr(p, ctl_node, "get\n").reply.status); + try testing.expectEqualStrings("from pane directory\n", pane.file.?.content); + try testing.expectEqualStrings(directory, Pardes.paneDir(pane)); + try testing.expectEqual(Status.ok, wr(p, name, "./created.txt\n").reply.status); + var expected_buf: [4096]u8 = undefined; + const expected = try std.fmt.bufPrint(&expected_buf, "{s}/created.txt", .{directory}); + try testing.expectEqualStrings(expected, pane.file.?.path); + try testing.expect(dirtyOf(pane)); +} + +test "relative names follow inherited scratch and virtual directories" { + const p = try withFile(testing.allocator, "source body\n"); + defer p.deinit(); + const source = p.panes[0].?; + try testing.expectEqual(Status.ok, wr(p, Node.of(source.serial, .name), "/project/src/source.zig\n").reply.status); + const serial = try th.newPane(p); + const scratch = p.panes[p.paneBySerial(serial).?].?; + const name = Node.of(serial, .name); + try testing.expectEqualStrings("/project/src", Pardes.paneDir(scratch)); + try testing.expectEqual(Status.ok, wr(p, name, "../out/./notes.txt\n").reply.status); + try testing.expectEqualStrings("/project/out/notes.txt", scratch.file.?.path); + try testing.expectEqualStrings("/project/out", Pardes.paneDir(scratch)); + var line: [256]u8 = undefined; + try testing.expectEqual(Status.ok, wr(p, name, try std.fmt.bufPrint(&line, "/virtual/pane/{d}/./body\n", .{source.serial})).reply.status); + try testing.expectEqual(Status.ok, wr(p, Node.of(serial, .ctl), "get\n").reply.status); + try testing.expectEqualStrings(source.file.?.content, scratch.file.?.content); + const unchanged = wr(p, name, "./body\n"); + try testing.expectEqual(Status.ok, unchanged.reply.status); + try testing.expect(unchanged.watch == null); + try testing.expect(!dirtyOf(scratch)); + try testing.expect(!scratch.file.?.watch_after_save); +} + +test "owned cwd name promotion releases the former directory" { + const p = try th.withTerm(testing.allocator); + defer p.deinit(); + p.newScratchBelow(0); + const id = p.active; + const pane = p.panes[id].?; + try pane.setOwnedCwd("/old/directory"); + const result = wr(p, Node.of(pane.serial, .name), "saved.txt\n"); + try testing.expectEqual(Status.ok, result.reply.status); + try testing.expect(pane.cwd == .none); + try testing.expect(pane.file.?.output == null); + try testing.expectEqualStrings("/old/directory/saved.txt", pane.file.?.path); + try testing.expectEqualStrings("/old/directory", Pardes.paneDir(pane)); +} + +test "errors append to one +Errors buffer per directory" { + const gpa = testing.allocator; + const p = try withFile(gpa, "x\n"); + defer p.deinit(); + const serial = serialOf(p); + + const live = for (p.panes) |slot| { + if (slot) |q| if (q.file) |f| if (f.output) |o| if (std.meta.activeTag(o.from) == .errors) break q; + } else null; + try testing.expect(live == null); + + try testing.expectEqual(Status.ok, wr(p, Node.of(serial, .errors), "boom\n").reply.status); + try testing.expectEqual(Status.ok, wr(p, Node.of(serial, .errors), "again\n").reply.status); + + var found: usize = 0; + for (p.panes) |slot| { + const q = slot orelse continue; + const f = q.file orelse continue; + const o = f.output orelse continue; + if (std.meta.activeTag(o.from) != .errors) continue; + found += 1; + try testing.expectEqualStrings("boom\nagain\n", f.content); + try testing.expectEqualStrings("/+Errors", f.path); + } + try testing.expectEqual(@as(usize, 1), found); +} + +test "setattr truncation empties the body and answers fresh attributes" { + const gpa = testing.allocator; + const p = try withFile(gpa, "one\ntwo\n"); + defer p.deinit(); + const serial = serialOf(p); + + const a = call(p, .{ .tag = 7, .op = .setattr, .node = Node.of(serial, .body), .truncate = true }); + try testing.expectEqual(Status.ok, a.reply.status); + try testing.expectEqual(@as(u64, 0), a.reply.attr.size); + try testing.expectEqualStrings("", p.panes[0].?.file.?.content); + + _ = wr(p, Node.of(serial, .body), "new text\n"); + try testing.expectEqualStrings("new text\n", p.panes[0].?.file.?.content); + + const noop = call(p, .{ .tag = 8, .op = .setattr, .node = Node.of(serial, .body) }); + try testing.expectEqual(@as(u64, 9), noop.reply.attr.size); +} diff --git a/src/ninep/pty.zig b/src/ninep/pty.zig new file mode 100644 index 00000000..e6696b85 --- /dev/null +++ b/src/ninep/pty.zig @@ -0,0 +1,388 @@ +//! A terminal pane's pty/: ctl (winsize, sig, exec), status and the raw data stream. +const std = @import("std"); +const pardes = @import("../pardes.zig"); +const tree = @import("tree.zig"); +const pane_files = @import("pane.zig"); + +const Pardes = pardes.Pardes; +const Pane = pardes.Pane; +const Req = tree.Req; +const Reply = tree.Reply; +const E = tree.E; +const PaneFile = tree.PaneFile; + +pub fn fileNamed(name: []const u8) ?PaneFile { + if (std.mem.eql(u8, name, "ctl")) return .pty_ctl; + if (std.mem.eql(u8, name, "status")) return .pty_status; + if (std.mem.eql(u8, name, "data")) return .pty_data; + return null; +} + +const Verb = enum { winsize, sig, exec }; + +fn dimension(word: []const u8) ?u16 { + if (word.len == 0 or word.len > 5) return null; + for (word) |c| if (c < '0' or c > '9') return null; + const n = std.fmt.parseInt(u16, word, 10) catch return null; + return if (n == 0) null else n; +} + +fn signalNamed(word: []const u8) ?pardes.PtySignal { + if (std.mem.eql(u8, word, "INT")) return .int; + if (std.mem.eql(u8, word, "TERM")) return .term; + if (std.mem.eql(u8, word, "HUP")) return .hup; + if (std.mem.eql(u8, word, "QUIT")) return .quit; + if (std.mem.eql(u8, word, "KILL")) return .kill; + return null; +} + +pub fn writeCtl(p: *Pardes, req: Req, id: usize) Reply { + for ([2]bool{ false, true }) |apply| { + var it = std.mem.splitScalar(u8, req.data, '\n'); + while (it.next()) |raw| { + const line = std.mem.trim(u8, raw, " \t\r"); + if (line.len == 0) continue; + if (!verb(p, id, line, apply)) return Reply.fail(req.tag, E.INVAL); + } + } + return .{ .tag = req.tag, .written = @intCast(req.data.len) }; +} + +fn verb(p: *Pardes, id: usize, line: []const u8, apply: bool) bool { + const pane = p.panes[id] orelse return false; + var words = std.mem.tokenizeAny(u8, line, " \t"); + const v = std.meta.stringToEnum(Verb, words.next() orelse return false) orelse return false; + switch (v) { + .winsize => { + const cols = dimension(words.next() orelse return false) orelse return false; + const rows = dimension(words.next() orelse return false) orelse return false; + if (words.next() != null) return false; + if (!apply) return true; + p.emit(.{ .resize_pty = .{ .pane = @intCast(id), .cols = cols, .rows = rows } }); + }, + .sig => { + const which = signalNamed(words.next() orelse return false) orelse return false; + if (words.next() != null) return false; + if (!apply) return true; + p.emit(.{ .signal_pty = .{ .pane = @intCast(id), .sig = which } }); + }, + .exec => { + if (words.next() != null) return false; + if (pane.cwdSlice().len > pardes.effect_path_cap) return false; + if (!apply) return true; + p.emit(.{ .spawn = .{ .pane = @intCast(id), .cwd = .from(pane.cwdSlice()) } }); + }, + } + return true; +} + +pub fn readStatus(p: *Pardes, req: Req, id: usize, pane: *Pane) Reply { + const out = p.fs.stage(p.gpa); + out.print(p.gpa, "{d:>11} {d:>11} {d:>11} ", .{ + pane.cols, + pane.rows, + @intFromBool(p.hostTtyTaken(id)), + }) catch {}; + return tree.stagedReply(p, req); +} + +pub fn readData(p: *Pardes, req: Req, pf: *pane_files.State) Reply { + if (pf.pty_out.empty()) return .{ .tag = req.tag, .status = .again }; + const out = p.fs.stage(p.gpa); + while (out.items.len < req.size) { + const chunk = pf.pty_out.peek() orelse break; + const n = @min(chunk.len, req.size - out.items.len); + out.appendSlice(p.gpa, chunk[0..n]) catch break; + pf.pty_out.popFront(n); + } + return .{ .tag = req.tag, .payload = .{ .staged = @intCast(out.items.len) } }; +} + +pub fn writeData(p: *Pardes, req: Req, id: usize) Reply { + if (req.data.len == 0) return .{ .tag = req.tag, .written = 0 }; + const take = pane_files.wholeUtf8(req.data); + p.emitWrite(id, req.data[0..take]); + return .{ .tag = req.tag, .written = @intCast(take) }; +} + +// ---- tests ---- + +const testing = std.testing; +const th = @import("testing.zig"); +const events = @import("events.zig"); +const call = th.call; +const rd = th.rd; +const wr = th.wr; +const rdir = th.rdir; +const look_up = th.look_up; +const withFile = th.withFile; +const withTerm = th.withTerm; +const serialOf = th.serialOf; +const Node = tree.Node; +const Status = tree.Status; + +test "a pane that is not a terminal has no pty/ at all" { + const gpa = testing.allocator; + const p = try withFile(gpa, "hello\n"); + defer p.deinit(); + const serial = serialOf(p); + const dir = Node.of(serial, .dir); + + try testing.expectEqual(E.NOENT, look_up(p, dir, "pty").errno()); + try testing.expectEqual(E.NOENT, call(p, .{ + .tag = 1, + .op = .getattr, + .node = Node.of(serial, .pty), + }).errno()); + try testing.expectEqual(E.NOENT, rd(p, Node.of(serial, .pty_status), 0, 256).errno()); + try testing.expectEqual(E.NOENT, wr(p, Node.of(serial, .pty_ctl), "winsize 80 24\n").errno()); + try testing.expectEqual(E.NOENT, rdir(p, Node.of(serial, .pty), 0).errno()); + try testing.expectEqual(E.NOENT, call(p, .{ + .tag = 2, + .op = .open, + .node = Node.of(serial, .pty_data), + }).errno()); + try testing.expectEqual(@as(u16, 0), p.fs.panes[0].pty_readers); + + var buf: [32]th.Dirent = undefined; + const files = th.dirents(rdir(p, dir, 0).bytes, &buf); + try testing.expectEqual(@as(usize, 10), files.len); + try testing.expect(th.nameAt(files, "pty") == null); + + try testing.expectEqual(E.NOENT, look_up(p, dir, "pty_ctl").errno()); + try testing.expectEqual(E.NOENT, look_up(p, dir, "status").errno()); +} + +test "a terminal pane's pty/ holds exactly ctl, status and data" { + const gpa = testing.allocator; + const p = try withTerm(gpa); + defer p.deinit(); + const serial = serialOf(p); + const dir = Node.of(serial, .dir); + + const pty = look_up(p, dir, "pty"); + try testing.expectEqual(Node.of(serial, .pty), pty.reply.attr.node); + try testing.expect(pty.reply.attr.dir); + try testing.expectEqual(@as(u16, 0o755), pty.reply.attr.mode); + + var buf: [32]th.Dirent = undefined; + const files = th.dirents(rdir(p, dir, 0).bytes, &buf); + try testing.expectEqual(@as(usize, 11), files.len); + try testing.expect(th.nameAt(files, "pty").?.dir); + + const inside = th.dirents(rdir(p, Node.of(serial, .pty), 0).bytes, &buf); + try testing.expectEqual(@as(usize, 3), inside.len); + try testing.expectEqualStrings("ctl", inside[0].name); + try testing.expectEqualStrings("status", inside[1].name); + try testing.expectEqualStrings("data", inside[2].name); + for (inside) |d| try testing.expect(!d.dir); + try testing.expectEqual(Node.of(serial, .pty_data), inside[2].node); + + const ctl = look_up(p, Node.of(serial, .pty), "ctl"); + try testing.expectEqual(Node.of(serial, .pty_ctl), ctl.reply.attr.node); + try testing.expectEqual(@as(u16, 0o222), ctl.reply.attr.mode); + try testing.expectEqual(@as(u16, 0o444), look_up(p, Node.of(serial, .pty), "status").reply.attr.mode); + try testing.expectEqual(E.NOENT, look_up(p, Node.of(serial, .pty), "body").errno()); + try testing.expectEqual(E.NOENT, look_up(p, Node.of(serial, .pty), "pty").errno()); + + try testing.expectEqual(E.NOTDIR, look_up(p, Node.of(serial, .pty_ctl), "x").errno()); + try testing.expectEqual(E.NOTDIR, rdir(p, Node.of(serial, .pty_ctl), 0).errno()); + try testing.expectEqual(E.PERM, rd(p, Node.of(serial, .pty), 0, 16).errno()); + try testing.expectEqual(E.PERM, rd(p, Node.of(serial, .pty_ctl), 0, 16).errno()); + try testing.expectEqual(E.PERM, wr(p, Node.of(serial, .pty_status), "x").errno()); +} + +test "every pty/ctl verb, and every refusal" { + const gpa = testing.allocator; + const p = try withTerm(gpa); + defer p.deinit(); + const ctl = Node.of(serialOf(p), .pty_ctl); + + const pane = p.panes[0].?; + const cols = pane.cols; + const rows = pane.rows; + const ws = wr(p, ctl, "winsize 132 44\n"); + try testing.expectEqual(@as(u32, "winsize 132 44\n".len), ws.reply.written); + try testing.expectEqual(@as(u16, 132), ws.winsize.?.cols); + try testing.expectEqual(@as(u16, 44), ws.winsize.?.rows); + try testing.expectEqual(cols, pane.cols); + try testing.expectEqual(rows, pane.rows); + + for ([_]struct { line: []const u8, want: pardes.PtySignal }{ + .{ .line = "sig INT", .want = .int }, + .{ .line = "sig TERM", .want = .term }, + .{ .line = "sig HUP", .want = .hup }, + .{ .line = "sig QUIT", .want = .quit }, + .{ .line = "sig KILL", .want = .kill }, + }) |c| { + const a = wr(p, ctl, c.line); + try testing.expectEqual(Status.ok, a.reply.status); + try testing.expectEqual(c.want, a.signal.?); + } + + const ex = wr(p, ctl, "exec\n"); + try testing.expectEqual(Status.ok, ex.reply.status); + try testing.expect(ex.spawned); + + const both = wr(p, ctl, "winsize 100 30\nsig TERM"); + try testing.expectEqual(@as(u16, 100), both.winsize.?.cols); + try testing.expectEqual(pardes.PtySignal.term, both.signal.?); + + for ([_][]const u8{ + "winsize", // no arguments + "winsize 80", // one argument + "winsize 80 24 extra", // three + "winsize 0 24", // zero is "unknown", never a width + "winsize 80 0", + "winsize -1 24", // not a decimal + "winsize 999999 24", // wider than a u16 + "sig", // no name + "sig INT TERM", // two + "sig SIGINT", + "sig int", // lower case + "sig 9", // a number is one platform's number + "sig USR1", // a real signal, deliberately not offered + "exec /bin/sh", // the effect carries no argv; refused, never ignored + "raw", + "cooked", + "winsize 80 24\nbogus", // a good verb beside a bad one + "bogus\nwinsize 80 24", + "look x", // a `ctl` verb; the two files share no vocabulary + "exec Del", + }) |bad| { + const a = wr(p, ctl, bad); + try testing.expectEqual(E.INVAL, a.errno()); + try testing.expect(a.winsize == null); + try testing.expect(a.signal == null); + try testing.expect(!a.spawned); + } + + const spaced = wr(p, ctl, "\n winsize 90 20 \n\n"); + try testing.expectEqual(Status.ok, spaced.reply.status); + try testing.expectEqual(@as(u16, 90), spaced.winsize.?.cols); + try testing.expectEqual(Status.ok, wr(p, ctl, "").reply.status); +} + +test "owned cwd pty exec rejects long paths before applying its batch" { + const p = try withTerm(testing.allocator); + defer p.deinit(); + const pane = p.panes[0].?; + const ctl = Node.of(pane.serial, .pty_ctl); + var path: [1025]u8 = @splat('d'); + path[0] = '/'; + p.setCwd(0, &path); + for ([_][]const u8{ "exec\n", "winsize 100 30\nexec\n", "sig TERM\nexec\n" }) |command| { + const result = wr(p, ctl, command); + try testing.expectEqual(E.INVAL, result.errno()); + try testing.expect(!result.spawned); + try testing.expect(result.signal == null and result.winsize == null); + } + try testing.expectEqualStrings(&path, pane.cwdSlice()); + p.setCwd(0, path[0..pardes.effect_path_cap]); + const accepted = wr(p, ctl, "exec\n"); + try testing.expectEqual(Status.ok, accepted.reply.status); + try testing.expect(accepted.spawned); +} + +test "pty/status reports the grid and who holds the tty" { + const gpa = testing.allocator; + const p = try withTerm(gpa); + defer p.deinit(); + const pane = p.panes[0].?; + const status = Node.of(pane.serial, .pty_status); + + const a = rd(p, status, 0, 256); + try testing.expectEqual(Status.ok, a.reply.status); + var want: [64]u8 = undefined; + const whole = try std.fmt.bufPrint(&want, "{d:>11} {d:>11} {d:>11} ", .{ pane.cols, pane.rows, 0 }); + try testing.expectEqualStrings(whole, a.bytes); + try testing.expectEqual(@as(usize, 3 * 12), a.bytes.len); + try testing.expectEqualStrings(whole[12..], rd(p, status, 12, 256).bytes); + + var probe: th.FakeTty = .{ .taken = true }; + p.host = .{ .ctx = &probe, .vtable = &th.FakeTty.vtable }; + const held = rd(p, status, 0, 256); + try testing.expectEqualStrings( + try std.fmt.bufPrint(&want, "{d:>11} {d:>11} {d:>11} ", .{ pane.cols, pane.rows, 1 }), + held.bytes, + ); +} + +test "pty/data writes at the shell and reads the raw stream" { + const gpa = testing.allocator; + const p = try withTerm(gpa); + defer p.deinit(); + const serial = serialOf(p); + const data = Node.of(serial, .pty_data); + + const w = call(p, .{ .tag = 2, .op = .write, .node = data, .off = 999, .data = "ls -l\r" }); + try testing.expectEqual(@as(u32, 6), w.reply.written); + try testing.expectEqualStrings("ls -l\r", w.pty()); + try testing.expectEqual(@as(u32, 1), wr(p, data, "a\xC3").reply.written); + try testing.expectEqual(@as(u32, 0), wr(p, data, "").reply.written); + + try testing.expectEqual(Status.again, rd(p, data, 0, 64).reply.status); + + p.update(.{ .output = .{ .pane = 0, .bytes = "unwatched" } }); + while (p.nextEffect()) |_| {} + try testing.expectEqual(@as(usize, 0), p.fs.panes[0].pty_out.buf.items.len); + try testing.expectEqual(Status.again, rd(p, data, 0, 64).reply.status); + + _ = call(p, .{ .tag = 5, .op = .open, .node = data }); + try testing.expectEqual(@as(u16, 1), p.fs.panes[0].pty_readers); + try testing.expectEqual(@as(u16, 0), p.fs.listeners); + try testing.expect(!p.fs.scripted(0)); + + p.update(.{ .output = .{ .pane = 0, .bytes = "hello" } }); + while (p.nextEffect()) |_| {} + try testing.expectEqualStrings("hello", rd(p, data, 0, 64).bytes); + try testing.expectEqual(Status.again, rd(p, data, 0, 64).reply.status); + + p.update(.{ .output = .{ .pane = 0, .bytes = "abcdef" } }); + while (p.nextEffect()) |_| {} + try testing.expectEqualStrings("ab", rd(p, data, 0, 2).bytes); + try testing.expectEqualStrings("cd", rd(p, data, 0, 2).bytes); + p.update(.{ .output = .{ .pane = 0, .bytes = "ghi" } }); + while (p.nextEffect()) |_| {} + try testing.expectEqualStrings("efghi", rd(p, data, 0, 64).bytes); + + p.update(.{ .output = .{ .pane = 0, .bytes = "orphan" } }); + while (p.nextEffect()) |_| {} + _ = call(p, .{ .tag = 6, .op = .release, .node = data }); + try testing.expectEqual(@as(u16, 0), p.fs.panes[0].pty_readers); + try testing.expectEqual(@as(usize, 0), p.fs.panes[0].pty_out.buf.capacity); + try testing.expectEqual(Status.again, rd(p, data, 0, 64).reply.status); + + _ = call(p, .{ .tag = 7, .op = .open, .node = data }); + _ = call(p, .{ .tag = 8, .op = .open, .node = data }); + _ = call(p, .{ .tag = 9, .op = .release, .node = data }); + try testing.expectEqual(@as(u16, 1), p.fs.panes[0].pty_readers); + p.update(.{ .output = .{ .pane = 0, .bytes = "still" } }); + while (p.nextEffect()) |_| {} + try testing.expectEqualStrings("still", rd(p, data, 0, 64).bytes); +} + +test "the pty queue drops the oldest at its cap" { + const gpa = testing.allocator; + const p = try withTerm(gpa); + defer p.deinit(); + const data = Node.of(serialOf(p), .pty_data); + _ = call(p, .{ .tag = 5, .op = .open, .node = data }); + + const oldest: [4096]u8 = @splat('A'); + const rest: [4096]u8 = @splat('B'); + events.notePtyOutput(p, 0, &oldest); + for (0..events.queue_cap / rest.len + 4) |_| events.notePtyOutput(p, 0, &rest); + const q = &p.fs.panes[0].pty_out; + try testing.expect(q.buf.items.len - q.head <= events.queue_cap); + + var seen: usize = 0; + while (true) { + const a = rd(p, data, 0, 1 << 16); + if (a.reply.status == .again) break; + try testing.expect(std.mem.indexOfScalar(u8, a.bytes, 'A') == null); + if (a.bytes.len == 0) break; + seen += a.bytes.len; + } + try testing.expect(seen > 0 and seen <= events.queue_cap); +} diff --git a/src/ninep/screen.zig b/src/ninep/screen.zig new file mode 100644 index 00000000..5b68b34c --- /dev/null +++ b/src/ninep/screen.zig @@ -0,0 +1,351 @@ +//! /screen, /listeners and the snapshot handles that freeze a screen or a +//! terminal history between open and close. +const std = @import("std"); +const pardes = @import("../pardes.zig"); +const panes = @import("../panes.zig"); +const tree = @import("tree.zig"); + +const Pardes = pardes.Pardes; +const Pane = pardes.Pane; +const Req = tree.Req; +const Reply = tree.Reply; +const E = tree.E; + +pub const Snapshot = struct { node: u64 = 0, bytes: ?[]const u8 = null }; +pub const snapshot_slots = 32; + +pub fn render(p: *Pardes) ![]u8 { + var arena: std.heap.ArenaAllocator = .init(p.gpa); + defer arena.deinit(); + const surface = try p.render(arena.allocator()); + var styles: std.ArrayList(pardes.CellStyle) = .empty; + var indices: std.ArrayList(usize) = .empty; + for (surface.cells) |cell| { + const style: pardes.CellStyle = if (cell.default) .{} else cell.style; + const index = for (styles.items, 0..) |previous, i| { + if (std.meta.eql(style, previous)) break i; + } else new: { + try styles.append(arena.allocator(), style); + break :new styles.items.len - 1; + }; + try indices.append(arena.allocator(), index); + } + var out: std.Io.Writer.Allocating = .init(p.gpa); + errdefer out.deinit(); + const writer = &out.writer; + try writer.print("{{\"cols\":{d},\"rows\":{d},\"cursor\":", .{ surface.cols, surface.rows }); + try std.json.Stringify.value(surface.cursor, .{}, writer); + try writer.writeAll(",\"styles\":"); + try std.json.Stringify.value(styles.items, .{ .emit_strings_as_arrays = true }, writer); + try writer.writeAll(",\"cells\":["); + for (surface.cells, indices.items, 0..) |cell, index, i| { + if (i != 0) try writer.writeByte(','); + try std.json.Stringify.value(.{ if (cell.default) " " else cell.grapheme(), index }, .{}, writer); + } + try writer.writeAll("]}\n"); + return out.toOwnedSlice(); +} + +/// A screen freezes at open; a terminal body freezes at its first read. +pub fn openSnapshot(p: *Pardes, req: Req, of_screen: bool) Reply { + for (&p.fs.snapshots, 0..) |*slot, i| { + if (slot.node != 0) continue; + const bytes = if (of_screen) render(p) catch return Reply.fail(req.tag, E.NOMEM) else null; + slot.* = .{ .node = req.node, .bytes = bytes }; + return .{ .tag = req.tag, .handle = @intCast(i + 1) }; + } + return Reply.fail(req.tag, E.NFILE); +} + +pub fn readSnapshot(p: *Pardes, req: Req, pane: ?*Pane) Reply { + if (req.handle == 0 or req.handle > p.fs.snapshots.len) return Reply.fail(req.tag, E.INVAL); + const snapshot = &p.fs.snapshots[req.handle - 1]; + if (snapshot.node == 0 or snapshot.node != req.node) return Reply.fail(req.tag, E.INVAL); + if (snapshot.bytes == null) { + const terminal = pane orelse return Reply.fail(req.tag, E.INVAL); + snapshot.bytes = panes.Terminal.screenTextAlloc(terminal, p.gpa) catch return Reply.fail(req.tag, E.NOMEM); + } + const bytes = snapshot.bytes.?; + const off = @min(req.off, bytes.len); + const len = @min(bytes.len - off, req.size); + const out = p.fs.stage(p.gpa); + out.appendSlice(p.gpa, bytes[off..][0..len]) catch return Reply.fail(req.tag, E.NOMEM); + return .{ .tag = req.tag, .payload = .{ .staged = @intCast(len) } }; +} + +/// True when the handle named a snapshot, which is now released. +pub fn releaseSnapshot(p: *Pardes, req: Req) bool { + if (req.handle == 0 or req.handle > p.fs.snapshots.len) return false; + const snapshot = &p.fs.snapshots[req.handle - 1]; + if (snapshot.node != req.node) return false; + if (snapshot.bytes) |bytes| p.gpa.free(bytes); + snapshot.* = .{}; + return true; +} + +pub fn readListeners(p: *Pardes, req: Req) Reply { + var buf: [512]u8 = undefined; + var text = std.Io.Writer.fixed(&buf); + if (p.fs.socket_path.len != 0) + text.print("unix!{s}\n", .{p.fs.socket_path}) catch return Reply.fail(req.tag, E.IO); + for ([_]?std.Io.net.IpAddress{ p.fs.tcp_address, p.fs.quic_address }, [_][]const u8{ "tcp", "quic" }) |maybe, transport| { + const address = maybe orelse continue; + switch (address) { + .ip4 => |ip| text.print("{s}!{d}.{d}.{d}.{d}!{d}\n", .{ transport, ip.bytes[0], ip.bytes[1], ip.bytes[2], ip.bytes[3], ip.port }) catch + return Reply.fail(req.tag, E.IO), + .ip6 => |ip| text.print("{s}!{f}!{d}\n", .{ transport, std.Io.net.Ip6Address.Unresolved{ .bytes = ip.bytes, .interface_name = null }, ip.port }) catch + return Reply.fail(req.tag, E.IO), + } + } + const out = p.fs.stage(p.gpa); + out.appendSlice(p.gpa, text.buffered()) catch return Reply.fail(req.tag, E.NOMEM); + return tree.stagedReply(p, req); +} + +// ---- tests ---- + +const testing = std.testing; +const th = @import("testing.zig"); +const fs = @import("../fs.zig"); +const call = th.call; +const rd = th.rd; +const wr = th.wr; +const withFile = th.withFile; +const withTerm = th.withTerm; +const serialOf = th.serialOf; +const Node = tree.Node; +const Status = tree.Status; +const screen_node = @intFromEnum(tree.TopFile.screen); + +test "listener addresses are readable canonical dials with bounded partial reads" { + const gpa = testing.allocator; + const p = try Pardes.init(gpa, .{ .tty_only = true }); + defer p.deinit(); + p.fs.socket_path = "/tmp/a socket.sock"; + p.fs.tcp_address = .{ .ip4 = .loopback(5640) }; + p.fs.quic_address = .{ .ip6 = .loopback(5641) }; + const expected = "unix!/tmp/a socket.sock\ntcp!127.0.0.1!5640\nquic!::1!5641\n"; + for ([_][]const u8{ "/virtual/listeners", "/n/self/listeners" }) |path| { + const bytes = try fs.read(p, path); + defer gpa.free(bytes); + try testing.expectEqualStrings(expected, bytes); + try testing.expectError(error.ReadOnlyFilesystem, fs.write(p, path, "")); + } + const node = @intFromEnum(tree.TopFile.listeners); + var off: usize = 0; + while (off < expected.len) { + const part = rd(p, node, off, 3); + try testing.expectEqual(Status.ok, part.reply.status); + try testing.expectEqualStrings(expected[off..][0..@min(3, expected.len - off)], part.bytes); + off += part.bytes.len; + } + try testing.expectEqual(@as(usize, 0), rd(p, node, off, 3).bytes.len); +} + +test "terminal body handles keep one history snapshot across fragmented reads" { + const gpa = testing.allocator; + const p = try withTerm(gpa); + defer p.deinit(); + const node = Node.of(serialOf(p), .body); + p.update(.{ .output = .{ .pane = 0, .bytes = "old caf\xc3\xa9\r\nold tail" } }); + while (p.nextEffect()) |_| {} + const original = try panes.Terminal.screenTextAlloc(p.panes[0].?, gpa); + defer gpa.free(original); + const opened = call(p, .{ .tag = 1, .op = .open, .node = node }); + try testing.expectEqual(Status.ok, opened.reply.status); + const first = call(p, .{ .tag = 2, .op = .read, .node = node, .handle = opened.reply.handle, .size = 3 }); + try testing.expectEqualStrings(original[0..3], first.bytes); + p.update(.{ .output = .{ .pane = 0, .bytes = "\x1b[3J\x1b[2J\x1b[Hnew output" } }); + while (p.nextEffect()) |_| {} + var offset: usize = 3; + while (offset < original.len) { + const part = call(p, .{ .tag = 3, .op = .read, .node = node, .handle = opened.reply.handle, .off = offset, .size = 3 }); + try testing.expectEqualStrings(original[offset..][0..@min(3, original.len - offset)], part.bytes); + offset += part.bytes.len; + } + try testing.expectEqualStrings("", call(p, .{ .tag = 4, .op = .read, .node = node, .handle = opened.reply.handle, .off = original.len, .size = 3 }).bytes); + _ = call(p, .{ .tag = 5, .op = .release, .node = node, .handle = opened.reply.handle }); + const newer = call(p, .{ .tag = 6, .op = .open, .node = node }); + try testing.expectEqualStrings("new output", call(p, .{ .tag = 7, .op = .read, .node = node, .handle = newer.reply.handle, .size = 32 }).bytes); + _ = call(p, .{ .tag = 8, .op = .release, .node = node, .handle = newer.reply.handle }); +} + +test "an empty terminal body snapshot stays empty while output continues" { + const p = try withTerm(std.testing.allocator); + defer p.deinit(); + const node = Node.of(serialOf(p), .body); + const opened = call(p, .{ .tag = 1, .op = .open, .node = node }); + try testing.expectEqualStrings("", call(p, .{ .tag = 2, .op = .read, .node = node, .handle = opened.reply.handle, .size = 32 }).bytes); + try testing.expect(p.fs.snapshots[opened.reply.handle - 1].bytes != null); + p.update(.{ .output = .{ .pane = 0, .bytes = "new output" } }); + while (p.nextEffect()) |_| {} + try testing.expectEqualStrings("", call(p, .{ .tag = 3, .op = .read, .node = node, .handle = opened.reply.handle, .size = 32 }).bytes); + _ = call(p, .{ .tag = 4, .op = .release, .node = node, .handle = opened.reply.handle }); + const newer = call(p, .{ .tag = 5, .op = .open, .node = node }); + try testing.expectEqualStrings("new output", call(p, .{ .tag = 6, .op = .read, .node = node, .handle = newer.reply.handle, .size = 32 }).bytes); + _ = call(p, .{ .tag = 7, .op = .release, .node = node, .handle = newer.reply.handle }); +} + +test "terminal body snapshots are lazy bounded and released after the pane closes" { + const gpa = testing.allocator; + const p = try withTerm(gpa); + defer p.deinit(); + const node = Node.of(serialOf(p), .body); + var handles: [snapshot_slots]u32 = undefined; + for (&handles) |*opened_handle| { + const opened = call(p, .{ .tag = 1, .op = .open, .node = node }); + try testing.expectEqual(Status.ok, opened.reply.status); + opened_handle.* = opened.reply.handle; + } + for (p.fs.snapshots) |snapshot| { + try testing.expectEqual(node, snapshot.node); + try testing.expect(snapshot.bytes == null); + } + try testing.expectEqual(E.NFILE, call(p, .{ .tag = 2, .op = .open, .node = node }).errno()); + const scratch = try th.newPane(p); + const scratch_id = p.paneBySerial(scratch).?; + try testing.expect(p.panes[scratch_id].?.file != null); + p.update(.{ .output = .{ .pane = 0, .bytes = "latest output" } }); + while (p.nextEffect()) |_| {} + var failing = std.testing.FailingAllocator.init(gpa, .{ .fail_index = 0 }); + p.gpa = failing.allocator(); + const failed = call(p, .{ .tag = 3, .op = .read, .node = node, .handle = handles[0], .size = 32 }); + p.gpa = gpa; + try testing.expectEqual(E.NOMEM, failed.errno()); + try testing.expect(p.fs.snapshots[handles[0] - 1].bytes == null); + const first = call(p, .{ .tag = 4, .op = .read, .node = node, .handle = handles[0], .size = 32 }); + try testing.expectEqualStrings("latest output", first.bytes); + const saved = p.fs.snapshots[handles[0] - 1].bytes.?; + failing = std.testing.FailingAllocator.init(gpa, .{ .fail_index = 0 }); + p.gpa = failing.allocator(); + const second = call(p, .{ .tag = 5, .op = .read, .node = node, .handle = handles[0], .off = 7, .size = 32 }); + p.gpa = gpa; + try testing.expectEqualStrings("output", second.bytes); + try testing.expect(!failing.has_induced_failure); + try testing.expectEqual(saved.ptr, p.fs.snapshots[handles[0] - 1].bytes.?.ptr); + try testing.expectEqual(E.INVAL, call(p, .{ .tag = 6, .op = .read, .node = screen_node, .handle = handles[0], .size = 32 }).errno()); + _ = call(p, .{ .tag = 7, .op = .release, .node = screen_node, .handle = handles[0] }); + try testing.expectEqual(node, p.fs.snapshots[handles[0] - 1].node); + try p.removePane(0); + for (handles) |opened_handle| _ = call(p, .{ .tag = 8, .op = .release, .node = node, .handle = opened_handle }); + for (p.fs.snapshots) |snapshot| { + try testing.expectEqual(@as(u64, 0), snapshot.node); + try testing.expect(snapshot.bytes == null); + } +} + +test "screen snapshots preserve rendered cells and styles until their handle is released" { + const gpa = testing.allocator; + const p = try withFile(gpa, "const value = 1;\n"); + defer p.deinit(); + const opened = call(p, .{ .tag = 1, .op = .open, .node = screen_node }); + try testing.expectEqual(Status.ok, opened.reply.status); + const snapshot = p.fs.snapshots[opened.reply.handle - 1].bytes.?; + const original = try gpa.dupe(u8, snapshot); + defer gpa.free(original); + const parsed = try std.json.parseFromSlice(std.json.Value, gpa, original, .{}); + defer parsed.deinit(); + const data = parsed.value.object; + try testing.expectEqual(@as(i64, p.screen_w), data.get("cols").?.integer); + try testing.expectEqual(@as(i64, p.screen_h), data.get("rows").?.integer); + try testing.expectEqual(@as(usize, p.screen_w) * p.screen_h, data.get("cells").?.array.items.len); + try testing.expect(data.get("styles").?.array.items.len > 0); + _ = wr(p, Node.of(serialOf(p), .body), "changed\n"); + const newer = call(p, .{ .tag = 2, .op = .open, .node = screen_node }); + try testing.expectEqual(Status.ok, newer.reply.status); + try testing.expect(!std.mem.eql(u8, original, p.fs.snapshots[newer.reply.handle - 1].bytes.?)); + var off: usize = 0; + while (off < original.len) { + const result = call(p, .{ .tag = 3, .op = .read, .node = screen_node, .handle = opened.reply.handle, .off = off, .size = 13 }); + try testing.expectEqual(Status.ok, result.reply.status); + try testing.expectEqualSlices(u8, original[off..][0..@min(13, original.len - off)], result.bytes); + off += result.bytes.len; + } + _ = call(p, .{ .tag = 4, .op = .release, .node = screen_node, .handle = opened.reply.handle }); + _ = call(p, .{ .tag = 5, .op = .release, .node = screen_node, .handle = newer.reply.handle }); + for (p.fs.snapshots) |slot| try testing.expect(slot.node == 0); +} + +test "screen inspection preserves acknowledged presentation and the next real frame" { + const gpa = testing.allocator; + for (std.enums.values(pardes.layout.Transition)) |transition| { + errdefer std.debug.print("screen inspection during {s}\n", .{@tagName(transition)}); + const control = try withFile(gpa, "const value = 1;\n"); + defer control.deinit(); + const inspected = try withFile(gpa, "const value = 1;\n"); + defer inspected.deinit(); + var arena: std.heap.ArenaAllocator = .init(gpa); + defer arena.deinit(); + for ([_]*Pardes{ control, inspected }) |p| { + p.settings.panel_transition = .off; + p.update(.tick); + p.acknowledgePanelPresentation((try p.render(arena.allocator())).panelTracks()); + p.settings.panel_transition = transition; + } + for (0..4) |phase| { + for ([_]*Pardes{ control, inspected }) |p| switch (phase) { + 0 => {}, + 1 => p.update(.{ .command = "New" }), + 2 => { + p.update(.tick); + try testing.expectEqual(Status.ok, wr(p, Node.of(p.panes[p.active].?.serial, .body), "changed cells\n").reply.status); + }, + 3 => { + for (0..transition.frames() + 1) |_| p.update(.tick); + p.acknowledgePanelPresentation((try p.render(arena.allocator())).panelTracks()); + p.update(.{ .command = "Del" }); + }, + else => unreachable, + }; + for (0..2) |_| { + const opened = call(inspected, .{ .tag = 1, .op = .open, .node = screen_node }); + try testing.expectEqual(Status.ok, opened.reply.status); + const captured = call(inspected, .{ .tag = 2, .op = .read, .node = screen_node, .handle = opened.reply.handle, .size = 32 }); + try testing.expectEqual(Status.ok, captured.reply.status); + try testing.expect(captured.bytes.len > 0); + try testing.expectEqual(Status.ok, call(inspected, .{ + .tag = 3, + .op = .release, + .node = screen_node, + .handle = opened.reply.handle, + }).reply.status); + } + const a = &control.presentation; + const b = &inspected.presentation; + try testing.expectEqualDeep(a.shown, b.shown); + try testing.expectEqualDeep(a.shown_tracks, b.shown_tracks); + try testing.expectEqualDeep(a.shown_closing[0..a.shown_closing_len], b.shown_closing[0..b.shown_closing_len]); + try testing.expectEqual(a.pending, b.pending); + try testing.expectEqual(a.acknowledged, b.acknowledged); + try testing.expectEqual(a.previous_valid, b.previous_valid); + try testing.expectEqual(a.previous_cols, b.previous_cols); + try testing.expectEqual(a.previous_rows, b.previous_rows); + try testing.expectEqualDeep(a.previous_layout, b.previous_layout); + try testing.expectEqual(a.previous_cells.len, b.previous_cells.len); + for (a.previous_cells, b.previous_cells) |*expected, *actual| + try testing.expect(expected.visuallyEqual(actual)); + + const expected = try control.render(arena.allocator()); + const actual = try inspected.render(arena.allocator()); + try testing.expectEqual(expected.cols, actual.cols); + try testing.expectEqual(expected.rows, actual.rows); + try testing.expectEqualDeep(expected.cursor, actual.cursor); + try testing.expectEqualDeep(expected.panelTracks(), actual.panelTracks()); + try testing.expectEqualDeep(expected.cell_diffs, actual.cell_diffs); + try testing.expectEqual(expected.previous_cells.len, actual.previous_cells.len); + try testing.expectEqual(expected.cells.len, actual.cells.len); + try testing.expectEqual(@as(usize, 0), expected.nimages); + try testing.expectEqual(@as(usize, 0), actual.nimages); + for (expected.cells, actual.cells) |*left, *right| try testing.expect(left.visuallyEqual(right)); + for (expected.previous_cells, actual.previous_cells) |*left, *right| try testing.expect(left.visuallyEqual(right)); + if (phase == 1 and transition != .off) try testing.expect(expected.panelTracks().len > 0); + if (phase == 1 and transition.needsPreviousGrid()) try testing.expect(expected.hasPanelDiff()); + if (phase == 3 and transition == .vertical) try testing.expect(a.closing_len > 0); + control.acknowledgePanelPresentation(expected.panelTracks()); + inspected.acknowledgePanelPresentation(actual.panelTracks()); + try testing.expectEqualDeep(a.shown, b.shown); + try testing.expectEqualDeep(a.previous_layout, b.previous_layout); + _ = arena.reset(.retain_capacity); + } + } +} diff --git a/src/ninep/sources.zig b/src/ninep/sources.zig new file mode 100644 index 00000000..b0408594 --- /dev/null +++ b/src/ninep/sources.zig @@ -0,0 +1,152 @@ +//! The editor's embedded sources, served read-only from the root when the +//! build carries them (-Dembed-sources=true). +const std = @import("std"); +const pardes = @import("../pardes.zig"); +const fs = @import("../fs.zig"); +const tree = @import("tree.zig"); + +const Pardes = pardes.Pardes; +const Req = tree.Req; +const Reply = tree.Reply; +const E = tree.E; +const sources = fs.sources; + +pub const archive_node: u64 = 1 << 61; + +/// The node of an archive path, or null when nothing embedded lives there. +/// The empty path is the archive root, which is never listed by itself. +pub fn node(path: []const u8) ?u64 { + if (path.len == 0) return archive_node; + if (path.len >= 4096) return null; + for (sources, 0..) |source, i| { + if (std.mem.eql(u8, source.path, path) or + (source.path.len > path.len and source.path[path.len] == '/' and std.mem.startsWith(u8, source.path, path))) + return archive_node | (@as(u64, i) << 12) | path.len; + } + return null; +} + +fn info(n: u64) ?struct { path: []const u8, contents: []const u8, dir: bool } { + if (n == archive_node) return .{ .path = "", .contents = "", .dir = true }; + const index = (n & ~archive_node) >> 12; + if (index >= sources.len) return null; + const source = sources[@intCast(index)]; + const len: usize = @intCast(n & 4095); + if (len > source.path.len) return null; + return .{ .path = source.path[0..len], .contents = source.contents, .dir = len < source.path.len }; +} + +/// Stages the children of one archive directory; "" lists the top-level +/// directories the served root shows. +pub fn stage(p: *Pardes, out: *std.ArrayList(u8), path: []const u8, skip: *u64) void { + var seen: [sources.len][]const u8 = undefined; + var count: usize = 0; + for (sources, 0..) |source, i| { + if (path.len != 0 and + (source.path.len <= path.len or source.path[path.len] != '/' or !std.mem.startsWith(u8, source.path, path))) continue; + const start = if (path.len == 0) 0 else path.len + 1; + const rest = source.path[start..]; + const len = std.mem.indexOfScalar(u8, rest, '/') orelse rest.len; + const name = rest[0..len]; + var duplicate = false; + for (seen[0..count]) |previous| if (std.mem.eql(u8, name, previous)) { + duplicate = true; + break; + }; + if (duplicate) continue; + seen[count] = name; + count += 1; + if (skip.* > 0) { + skip.* -= 1; + continue; + } + const child = archive_node | (@as(u64, i) << 12) | (start + len); + tree.stageDirent(out, p.gpa, child, len < rest.len, name); + } +} + +pub fn handle(p: *Pardes, req: Req) Reply { + const found = info(req.node) orelse return Reply.fail(req.tag, E.NOENT); + const attr: Reply.Attr = .{ + .node = req.node, + .name = std.fs.path.basename(found.path), + .dir = found.dir, + .size = if (found.dir) 0 else found.contents.len, + .mode = if (found.dir) 0o555 else 0o444, + .mtime = p.fs.started, + }; + switch (req.op) { + .getattr => return .{ .tag = req.tag, .attr = attr }, + .open => return .{ .tag = req.tag, .handle = 1 }, + .release => return .{ .tag = req.tag }, + .lookup => { + if (!found.dir) return Reply.fail(req.tag, E.NOTDIR); + if (std.mem.eql(u8, req.data, "..")) { + const parent = std.fs.path.dirname(found.path) orelse ""; + if (parent.len == 0) return tree.handle(p, .{ .tag = req.tag, .op = .getattr, .node = tree.root }); + const parent_node = node(parent) orelse return Reply.fail(req.tag, E.NOENT); + return handle(p, .{ .tag = req.tag, .op = .getattr, .node = parent_node }); + } + if (req.data.len == 0 or std.mem.indexOfAny(u8, req.data, "/\x00") != null) return Reply.fail(req.tag, E.NOENT); + var buf: [4096]u8 = undefined; + const path = if (found.path.len == 0) req.data else std.fmt.bufPrint(&buf, "{s}/{s}", .{ found.path, req.data }) catch return Reply.fail(req.tag, E.NOENT); + const child = node(path) orelse return Reply.fail(req.tag, E.NOENT); + return handle(p, .{ .tag = req.tag, .op = .getattr, .node = child }); + }, + .readdir => { + if (!found.dir) return Reply.fail(req.tag, E.NOTDIR); + const out = p.fs.stage(p.gpa); + var skip = req.off; + stage(p, out, found.path, &skip); + return .{ .tag = req.tag, .payload = .{ .staged = @intCast(out.items.len) } }; + }, + .read => { + if (found.dir) return Reply.fail(req.tag, E.PERM); + const off: usize = @intCast(@min(req.off, found.contents.len)); + const bytes = found.contents[off..][0..@min(req.size, found.contents.len - off)]; + const out = p.fs.stage(p.gpa); + out.appendSlice(p.gpa, bytes) catch return Reply.fail(req.tag, E.NOMEM); + return .{ .tag = req.tag, .payload = .{ .staged = @intCast(bytes.len) } }; + }, + else => return Reply.fail(req.tag, E.PERM), + } +} + +const testing = std.testing; +const th = @import("testing.zig"); +const limits = @import("../memory.zig").limits; + +test "embedded sources appear under the root only when the build carries them" { + const p = try th.withFile(testing.allocator, "x\n"); + defer p.deinit(); + var buf: [64]th.Dirent = undefined; + const top = th.dirents(th.rdir(p, tree.root, 0).bytes, &buf); + const listed = th.nameAt(top, "src"); + try testing.expectEqual(limits.embedded_sources, listed != null); + const looked = th.look_up(p, tree.root, "src"); + try testing.expectEqual(limits.embedded_sources, looked.reply.status == .ok); + try testing.expect(tree.resolveSelf(p, "shaders/../src/../") == tree.root); + if (!limits.embedded_sources) { + try testing.expect(tree.resolveSelf(p, "src/pardes.zig") == null); + try testing.expect(tree.resolveSelf(p, "src") == null); + try testing.expect(th.nameAt(top, "build.zig") == null); + return; + } + try testing.expect(looked.reply.attr.dir); + try testing.expectEqual(@as(u16, 0o555), looked.reply.attr.mode); + try testing.expectEqual(listed.?.node, looked.reply.attr.node); + try testing.expect(th.nameAt(top, "build.zig") == null); + try testing.expect(th.nameAt(top, "build.zig.zon") == null); + const file = th.look_up(p, looked.reply.attr.node, "pardes.zig"); + try testing.expectEqual(tree.Status.ok, file.reply.status); + try testing.expectEqual(@as(u16, 0o444), file.reply.attr.mode); + try testing.expectEqual(@as(u64, fs.sourceBytes("src/pardes.zig").?.len), file.reply.attr.size); + try testing.expectEqual(file.reply.attr.node, tree.resolveSelf(p, "src/pardes.zig").?); + const opened = th.call(p, .{ .tag = 1, .op = .open, .node = file.reply.attr.node }); + const head = th.call(p, .{ .tag = 2, .op = .read, .node = file.reply.attr.node, .handle = opened.reply.handle, .size = 16 }); + try testing.expectEqualStrings(fs.sourceBytes("src/pardes.zig").?[0..16], head.bytes); + const parent = th.look_up(p, looked.reply.attr.node, ".."); + try testing.expectEqual(tree.root, parent.reply.attr.node); + try testing.expectEqual(E.NOENT, th.look_up(p, tree.root, "build.zig").errno()); + try testing.expectEqual(E.NOENT, th.look_up(p, looked.reply.attr.node, "missing.zig").errno()); +} diff --git a/src/ninep/testing.zig b/src/ninep/testing.zig new file mode 100644 index 00000000..ba26cb38 --- /dev/null +++ b/src/ninep/testing.zig @@ -0,0 +1,135 @@ +//! Test helpers shared by the control-tree modules: drive one request +//! through the core and collect the reply and the effects it raised. +const std = @import("std"); +const pardes = @import("../pardes.zig"); +const tree = @import("tree.zig"); + +const Pardes = pardes.Pardes; +pub const Req = tree.Req; +pub const Reply = tree.Reply; +pub const E = tree.E; + +pub const Answer = struct { + reply: Reply = .{ .tag = 0, .status = .err, .errno = E.IO }, + bytes: []const u8 = "", + saved: bool = false, + watch: ?bool = null, + pty_buf: [256]u8 = undefined, + pty_len: usize = 0, + winsize: ?struct { cols: u16, rows: u16 } = null, + signal: ?pardes.PtySignal = null, + spawned: bool = false, + + pub fn pty(a: *const Answer) []const u8 { + return a.pty_buf[0..a.pty_len]; + } + + pub fn errno(a: Answer) u16 { + return if (a.reply.status == .err) a.reply.errno else 0; + } +}; + +pub fn call(p: *Pardes, req: Req) Answer { + p.update(.{ .fs_req = req }); + var ans: Answer = .{}; + while (p.nextEffect()) |e| switch (e) { + .fs_reply => |r| { + ans.reply = r; + ans.bytes = p.fsPayload(r); + }, + .save_file, .save_text => ans.saved = true, + .watch => |w| ans.watch = w.on, + .write => |w| { + const b = w.bytes.slice(); + const n = @min(b.len, ans.pty_buf.len - ans.pty_len); + @memcpy(ans.pty_buf[ans.pty_len..][0..n], b[0..n]); + ans.pty_len += n; + }, + .resize_pty => |r| ans.winsize = .{ .cols = r.cols, .rows = r.rows }, + .signal_pty => |s| ans.signal = s.sig, + .spawn => ans.spawned = true, + else => {}, + }; + return ans; +} + +pub fn rd(p: *Pardes, node: u64, off: u64, size: u32) Answer { + return call(p, .{ .tag = 1, .op = .read, .node = node, .off = off, .size = size }); +} + +pub fn wr(p: *Pardes, node: u64, data: []const u8) Answer { + return call(p, .{ .tag = 2, .op = .write, .node = node, .data = data }); +} + +pub fn rdir(p: *Pardes, node: u64, skip: u64) Answer { + return call(p, .{ .tag = 4, .op = .readdir, .node = node, .off = skip, .size = 4096 }); +} + +pub fn look_up(p: *Pardes, dir: u64, name: []const u8) Answer { + return call(p, .{ .tag = 3, .op = .lookup, .node = dir, .data = name }); +} + +/// Opens /new once, as a client would, and returns the pane it made. +pub fn newPane(p: *Pardes) !u32 { + const new = @intFromEnum(tree.TopFile.new); + const opened = call(p, .{ .tag = 9, .op = .open, .node = new }); + if (opened.reply.status != .ok or opened.reply.handle == 0) return error.NoPane; + _ = call(p, .{ .tag = 9, .op = .release, .node = new, .handle = opened.reply.handle }); + return opened.reply.handle; +} + +pub fn withFile(gpa: std.mem.Allocator, text: []const u8) !*Pardes { + const p = try Pardes.init(gpa, .{ .tty_only = true, .cols = 80, .rows = 24 }); + errdefer p.deinit(); + while (p.nextEffect()) |_| {} + _ = try p.setTestFile(text); + while (p.nextEffect()) |_| {} + return p; +} + +pub fn withTerm(gpa: std.mem.Allocator) !*Pardes { + const p = try Pardes.init(gpa, .{ .tty_only = true, .cols = 80, .rows = 24 }); + errdefer p.deinit(); + while (p.nextEffect()) |_| {} + std.debug.assert(p.panes[0].?.isTerminal()); + return p; +} + +pub fn serialOf(p: *Pardes) u32 { + return p.panes[0].?.serial; +} + +pub const Dirent = struct { node: u64, dir: bool, name: []const u8 }; + +pub fn dirents(bytes: []const u8, out: []Dirent) []Dirent { + var n: usize = 0; + var i: usize = 0; + while (i + 10 <= bytes.len and n < out.len) { + const node = std.mem.readInt(u64, bytes[i..][0..8], .little); + const kind = bytes[i + 8]; + const len = bytes[i + 9]; + i += 10; + if (i + len > bytes.len) break; + out[n] = .{ .node = node, .dir = kind == 1, .name = bytes[i .. i + len] }; + i += len; + n += 1; + } + return out[0..n]; +} + +pub fn nameAt(list: []const Dirent, want: []const u8) ?Dirent { + for (list) |d| if (std.mem.eql(u8, d.name, want)) return d; + return null; +} + +pub const FakeTty = struct { + taken: bool, + + pub const vtable: pardes.Host.VTable = .{ .tty_taken = answer }; + + fn answer(ctx: ?*anyopaque, pane: u8) bool { + _ = pane; + const f: *FakeTty = @ptrCast(@alignCast(ctx.?)); + return f.taken; + } +}; diff --git a/src/ninep/tree.zig b/src/ninep/tree.zig new file mode 100644 index 00000000..f716bf5f --- /dev/null +++ b/src/ninep/tree.zig @@ -0,0 +1,850 @@ +//! The control tree served over 9P: its nodes, lookup, readdir and the +//! dispatch that answers the engine in src/9p.zig. The backend contract +//! (Req, Reply, Op, Status, E) lives here; fs.zig keeps host access and mounts. +//! +//! /README /index /ctl /new /log /screen /listeners +//! /pane//{name,body,tag,ctl,addr,data,xdata,sel,errors,event,pty/} +//! /os/... the host filesystem /src/... embedded sources (opt-in) +const std = @import("std"); +const pardes = @import("../pardes.zig"); +const fs = @import("../fs.zig"); +pub const events = @import("events.zig"); +pub const pane = @import("pane.zig"); +pub const addr = @import("addr.zig"); +pub const ctl = @import("ctl.zig"); +pub const pty = @import("pty.zig"); +pub const sources = @import("sources.zig"); +pub const screen = @import("screen.zig"); + +const Pardes = pardes.Pardes; +const Pane = pardes.Pane; +const MAX_PANES = pardes.MAX_PANES; + +pub const name_capacity: usize = 255; + +// ---- the backend contract ---- + +pub const Op = enum(u8) { + lookup, + getattr, + setattr, + open, + read, + write, + release, + readdir, +}; + +pub const Status = enum(u8) { + ok, + again, + err, +}; + +pub const Req = struct { + tag: u64, + op: Op, + node: u64, + handle: u32 = 0, + off: u64 = 0, + size: u32 = 0, + data: []const u8 = &.{}, + truncate: bool = false, + + pub fn changesPane(req: Req) bool { + return switch (req.op) { + .write, .setattr => true, + .open => req.node == @intFromEnum(TopFile.new), + .lookup, .getattr, .read, .release, .readdir => false, + }; + } +}; + +pub const Reply = struct { + tag: u64, + status: Status = .ok, + errno: u16 = 0, + attr: Attr = .{}, + handle: u32 = 0, + payload: Payload = .none, + written: u32 = 0, + + pub const Attr = struct { + name: []const u8 = "", + node: u64 = 0, + dir: bool = false, + size: u64 = 0, + mode: u16 = 0o644, + mtime: u32 = 0, + }; + + pub const Payload = union(enum) { + none, + staged: u32, + region: struct { pane: u8, serial: u32, off: u32, len: u32 }, + }; + + pub fn fail(tag: u64, e: u16) Reply { + return .{ .tag = tag, .status = .err, .errno = e }; + } +}; + +pub const E = struct { + pub const PERM: u16 = 1; + pub const NOENT: u16 = 2; + pub const IO: u16 = 5; + pub const NOMEM: u16 = 12; + pub const NOTDIR: u16 = 20; + pub const INVAL: u16 = 22; + pub const NFILE: u16 = 23; + pub const NOSPC: u16 = 28; + pub const NOSYS: u16 = 38; +}; + +pub const out_reserve = 4 * 1024; + +// ---- nodes ---- + +pub const TopFile = enum(u4) { + root = 1, + README, + index, + ctl, + new, + log, + screen, + listeners, + pane, + + pub fn fileName(f: TopFile) []const u8 { + return if (f == .root) "/" else @tagName(f); + } + + pub fn mode(f: TopFile) u16 { + return switch (f) { + .root, .pane => 0o755, + .ctl => 0o666, + .README, .index, .new, .log, .screen, .listeners => 0o444, + }; + } + + pub fn dir(f: TopFile) bool { + return f == .root or f == .pane; + } +}; + +pub const root: u64 = @intFromEnum(TopFile.root); + +pub const PaneFile = enum(u4) { + dir = 0, + name, + body, + tag, + ctl, + addr, + data, + xdata, + sel, + errors, + event, + pty, + pty_ctl, + pty_status, + pty_data, + + pub fn fileName(f: PaneFile) []const u8 { + return switch (f) { + .dir => ".", + .pty_ctl => "ctl", + .pty_status => "status", + .pty_data => "data", + else => @tagName(f), + }; + } + + pub fn mode(f: PaneFile) u16 { + return switch (f) { + .dir, .pty => 0o755, + .errors, .pty_ctl => 0o222, + .pty_status => 0o444, + else => 0o666, + }; + } + + pub fn isDir(f: PaneFile) bool { + return f == .dir or f == .pty; + } + + pub fn inPty(f: PaneFile) bool { + return switch (f) { + .pty, .pty_ctl, .pty_status, .pty_data => true, + else => false, + }; + } +}; + +pub const Node = packed struct(u64) { + file: u4 = 0, + serial: u60 = 0, + + pub fn of(serial: u32, file: PaneFile) u64 { + std.debug.assert(serial != 0); + return @bitCast(Node{ .file = @intFromEnum(file), .serial = serial }); + } + + pub fn target(node: u64) ?Target { + const n: Node = @bitCast(node); + if (n.serial == 0) { + return .{ .top = std.enums.fromInt(TopFile, n.file) orelse return null }; + } + return .{ .pane = .{ + .serial = std.math.cast(u32, n.serial) orelse return null, + .file = std.enums.fromInt(PaneFile, n.file) orelse return null, + } }; + } +}; + +pub const Target = union(enum) { + top: TopFile, + pane: struct { serial: u32, file: PaneFile }, +}; + +fn paneFileNamed(name: []const u8) ?PaneFile { + const f = std.meta.stringToEnum(PaneFile, name) orelse return null; + if (f == .dir) return null; + return if (f.inPty() and f != .pty) null else f; +} + +fn topFileNamed(name: []const u8) ?TopFile { + const f = std.meta.stringToEnum(TopFile, name) orelse return null; + return if (f == .root) null else f; +} + +fn serialNamed(name: []const u8) ?u32 { + if (name.len == 0 or name.len > 10) return null; + for (name) |c| if (c < '0' or c > '9') return null; + const serial = std.fmt.parseInt(u32, name, 10) catch return null; + return if (serial == 0) null else serial; +} + +pub fn nextSerialAfter(p: *Pardes, after: u32) ?u32 { + var best: ?u32 = null; + for (p.panes) |slot| { + const pn = slot orelse continue; + if (pn.serial <= after) continue; + if (best == null or pn.serial < best.?) best = pn.serial; + } + return best; +} + +/// An editor path below the root (`pane/3/body`, `index`, `src/...`) to its node. +pub fn resolveSelf(p: *Pardes, path: []const u8) ?u64 { + var path_buf: [4096]u8 = undefined; + const normalized = fs.normalizeVirtualPath(path, &path_buf) orelse return null; + var parts = std.mem.tokenizeScalar(u8, normalized, '/'); + const first = parts.next() orelse return root; + if (!std.mem.eql(u8, first, "pane")) { + const top = topFileNamed(first) orelse return sources.node(normalized); + if (top == .pane or parts.next() != null) return null; + return @intFromEnum(top); + } + const serial = serialNamed(parts.next() orelse return @intFromEnum(TopFile.pane)) orelse return null; + const id = p.paneBySerial(serial) orelse return null; + const file = paneFileNamed(parts.next() orelse return Node.of(serial, .dir)) orelse return null; + if (file.inPty() and !p.panes[id].?.isTerminal()) return null; + if (parts.next()) |name| { + if (file != .pty) return null; + const child = pty.fileNamed(name) orelse return null; + if (parts.next() != null) return null; + return Node.of(serial, child); + } + return Node.of(serial, file); +} + +// ---- staging ---- + +pub fn stageDirent(out: *std.ArrayList(u8), gpa: std.mem.Allocator, node: u64, dir: bool, name: []const u8) void { + if (name.len == 0 or name.len > 255) return; + var head: [10]u8 = undefined; + std.mem.writeInt(u64, head[0..8], node, .little); + head[8] = @intFromBool(dir); + head[9] = @intCast(name.len); + out.appendSlice(gpa, &head) catch return; + out.appendSlice(gpa, name) catch return; +} + +/// Answers a read from whatever the handler staged, windowed by offset and size. +pub fn stagedReply(p: *Pardes, req: Req) Reply { + const out = &p.fs.out; + const off = @min(req.off, out.items.len); + const n = @min(out.items.len - off, req.size); + if (off > 0) std.mem.copyForwards(u8, out.items[0..n], out.items[off..][0..n]); + out.shrinkRetainingCapacity(n); + return .{ .tag = req.tag, .payload = .{ .staged = @intCast(n) } }; +} + +// ---- dispatch ---- + +pub fn handle(p: *Pardes, req: Req) Reply { + if (req.node == fs.os_root or req.node & fs.os_node != 0) return fs.osHandle(p, req); + if (req.node & sources.archive_node != 0) return sources.handle(p, req); + const target = Node.target(req.node) orelse return Reply.fail(req.tag, E.NOENT); + if (req.op == .write or req.op == .setattr) p.fs.origin = switch (target) { + .pane => |t| @as(u8, if (t.file == .body or t.file == .tag) 'E' else 'F'), + .top => 'F', + }; + return switch (req.op) { + .lookup => lookup(p, req, target), + .getattr => attrReply(p, req.tag, target), + .setattr => setattr(p, req, target), + .open => open(p, req, target), + .release => release(p, req), + .readdir => readdir(p, req, target), + .read => read(p, req, target), + .write => write(p, req, target), + }; +} + +fn attrOf(p: *Pardes, target: Target) ?Reply.Attr { + switch (target) { + .top => |f| return .{ + .name = f.fileName(), + .node = @intFromEnum(f), + .dir = f.dir(), + .mode = f.mode(), + .size = topSize(p, f), + .mtime = p.fs.started, + }, + .pane => |t| { + const id = p.paneBySerial(t.serial) orelse return null; + const pn = p.panes[id].?; + if (t.file.inPty() and !pn.isTerminal()) return null; + return .{ + .name = if (t.file == .dir) (std.fmt.bufPrint(&p.fs.node_name, "{d}", .{t.serial}) catch unreachable) else t.file.fileName(), + .node = Node.of(t.serial, t.file), + .dir = t.file.isDir(), + .mode = t.file.mode(), + .size = pane.fileSize(p, id, t.file), + .mtime = pane.mtimeOf(p, pn), + }; + }, + } +} + +fn attrReply(p: *Pardes, tag: u64, target: Target) Reply { + const a = attrOf(p, target) orelse return Reply.fail(tag, E.NOENT); + return .{ .tag = tag, .attr = a }; +} + +fn topSize(p: *Pardes, f: TopFile) u64 { + return switch (f) { + .root, .pane, .new, .log, .screen, .listeners => 0, + .index => pane.indexLen(p), + .README => fs.help.len, + .ctl => ctl: { + var buf: [ctl.root_text_cap]u8 = undefined; + break :ctl ctl.rootText(p, &buf).len; + }, + }; +} + +fn lookup(p: *Pardes, req: Req, target: Target) Reply { + const name = req.data; + if (std.mem.eql(u8, name, "..")) { + const parent: u64 = switch (target) { + .top => |top| if (top.dir()) root else return Reply.fail(req.tag, E.NOTDIR), + .pane => |t| switch (t.file) { + .dir => @intFromEnum(TopFile.pane), + .pty => Node.of(t.serial, .dir), + else => return Reply.fail(req.tag, E.NOTDIR), + }, + }; + return handle(p, .{ .tag = req.tag, .op = .getattr, .node = parent }); + } + if (name.len == 0 or std.mem.indexOfAny(u8, name, "/\x00") != null) return Reply.fail(req.tag, E.NOENT); + const node: u64 = switch (target) { + .top => |f| switch (f) { + .root => root: { + if (std.mem.eql(u8, name, "os")) return fs.osHandle(p, .{ .tag = req.tag, .op = .getattr, .node = fs.os_root }); + if (topFileNamed(name)) |t| break :root @intFromEnum(t); + if (sources.node(name)) |n| return sources.handle(p, .{ .tag = req.tag, .op = .getattr, .node = n }); + return Reply.fail(req.tag, E.NOENT); + }, + .pane => pane: { + const serial = serialNamed(name) orelse return Reply.fail(req.tag, E.NOENT); + break :pane Node.of(serial, .dir); + }, + else => return Reply.fail(req.tag, E.NOTDIR), + }, + .pane => |t| pane: { + _ = p.paneBySerial(t.serial) orelse return Reply.fail(req.tag, E.NOENT); + const f = switch (t.file) { + .dir => paneFileNamed(name), + .pty => pty.fileNamed(name), + else => return Reply.fail(req.tag, E.NOTDIR), + } orelse return Reply.fail(req.tag, E.NOENT); + break :pane Node.of(t.serial, f); + }, + }; + return attrReply(p, req.tag, Node.target(node) orelse return Reply.fail(req.tag, E.NOENT)); +} + +fn stagePaneFiles(p: *Pardes, out: *std.ArrayList(u8), serial: u32, terminal: bool, skip: *u64) void { + inline for (comptime std.enums.values(PaneFile)) |f| { + if (comptime f == .dir or (f.inPty() and f != .pty)) continue; + const present = f != .pty or terminal; + if (present) { + if (skip.* > 0) skip.* -= 1 else stageDirent(out, p.gpa, Node.of(serial, f), f.isDir(), f.fileName()); + } + } +} + +fn stagePtyFiles(p: *Pardes, out: *std.ArrayList(u8), serial: u32, skip: *u64) void { + inline for (comptime std.enums.values(PaneFile)) |f| { + if (comptime !f.inPty() or f == .pty) continue; + if (skip.* > 0) skip.* -= 1 else stageDirent(out, p.gpa, Node.of(serial, f), false, f.fileName()); + } +} + +fn readdir(p: *Pardes, req: Req, target: Target) Reply { + const out = p.fs.stage(p.gpa); + var skip = req.off; + switch (target) { + .top => |f| switch (f) { + .root => { + inline for (.{ TopFile.README, TopFile.index, TopFile.ctl, TopFile.new, TopFile.log, TopFile.screen, TopFile.listeners, TopFile.pane }) |t| { + if (skip > 0) skip -= 1 else stageDirent(out, p.gpa, @intFromEnum(t), t.dir(), t.fileName()); + } + if (skip > 0) skip -= 1 else stageDirent(out, p.gpa, fs.os_root, true, "os"); + sources.stage(p, out, "", &skip); + }, + .pane => { + var last: u32 = 0; + while (nextSerialAfter(p, last)) |serial| { + last = serial; + if (skip > 0) { + skip -= 1; + continue; + } + var buf: [16]u8 = undefined; + const name = std.fmt.bufPrint(&buf, "{d}", .{serial}) catch unreachable; + stageDirent(out, p.gpa, Node.of(serial, .dir), true, name); + } + }, + else => return Reply.fail(req.tag, E.NOTDIR), + }, + .pane => |t| { + const id = p.paneBySerial(t.serial) orelse return Reply.fail(req.tag, E.NOENT); + const terminal = p.panes[id].?.isTerminal(); + switch (t.file) { + .dir => stagePaneFiles(p, out, t.serial, terminal, &skip), + .pty => { + if (!terminal) return Reply.fail(req.tag, E.NOENT); + stagePtyFiles(p, out, t.serial, &skip); + }, + else => return Reply.fail(req.tag, E.NOTDIR), + } + }, + } + return .{ .tag = req.tag, .payload = .{ .staged = @intCast(out.items.len) } }; +} + +fn newPane(p: *Pardes) ?u32 { + const slot = p.freeSlot() orelse return null; + p.newScratchBelow(p.active); + const pn = p.panes[slot] orelse return null; + return pn.serial; +} + +fn open(p: *Pardes, req: Req, target: Target) Reply { + switch (target) { + .top => |f| switch (f) { + // The clone idiom: each open makes one empty pane; reads answer its serial. + .new => { + const serial = newPane(p) orelse return Reply.fail(req.tag, E.NFILE); + return .{ .tag = req.tag, .handle = serial }; + }, + .screen => return screen.openSnapshot(p, req, true), + .log => p.fs.log_readers +|= 1, + else => {}, + }, + .pane => |t| { + const id = p.paneBySerial(t.serial) orelse return Reply.fail(req.tag, E.NOENT); + const pn = p.panes[id].?; + const pf = &p.fs.panes[id]; + if (t.file.inPty() and !pn.isTerminal()) return Reply.fail(req.tag, E.NOENT); + switch (t.file) { + .body => if (pn.isTerminal()) return screen.openSnapshot(p, req, false), + .ctl => pf.limit = null, + .addr => { + pf.addr = .{}; + pf.limit = null; + }, + .event => { + pf.readers +|= 1; + p.fs.listeners +|= 1; + }, + .pty_data => pf.pty_readers +|= 1, + else => {}, + } + }, + } + return .{ .tag = req.tag, .handle = 1 }; +} + +fn release(p: *Pardes, req: Req) Reply { + if (screen.releaseSnapshot(p, req)) return .{ .tag = req.tag }; + const target = Node.target(req.node) orelse return .{ .tag = req.tag }; + switch (target) { + .top => |f| if (f == .log and p.fs.log_readers > 0) { + p.fs.log_readers -= 1; + if (p.fs.log_readers == 0) p.fs.log.clearAndFree(p.gpa); + }, + .pane => |t| { + if (t.file != .event and t.file != .pty_data) return .{ .tag = req.tag }; + const id = p.paneBySerial(t.serial) orelse return .{ .tag = req.tag }; + const pf = &p.fs.panes[id]; + if (t.file == .pty_data) { + if (pf.pty_readers == 0) return .{ .tag = req.tag }; + pf.pty_readers -= 1; + if (pf.pty_readers == 0) pf.pty_out.clearAndFree(p.gpa); + return .{ .tag = req.tag }; + } + if (pf.readers == 0) return .{ .tag = req.tag }; + pf.readers -= 1; + p.fs.listeners -|= 1; + if (pf.readers == 0) pf.tag_snap.clearAndFree(p.gpa); + }, + } + return .{ .tag = req.tag }; +} + +fn setattr(p: *Pardes, req: Req, target: Target) Reply { + if (req.truncate) switch (target) { + .pane => |t| { + const id = p.paneBySerial(t.serial) orelse return Reply.fail(req.tag, E.NOENT); + if (pane.truncate(p, id, p.panes[id].?, t.file) != .ok) return Reply.fail(req.tag, E.NOMEM); + }, + .top => {}, + }; + return attrReply(p, req.tag, target); +} + +fn read(p: *Pardes, req: Req, target: Target) Reply { + switch (target) { + .top => |f| return switch (f) { + .README => help: { + const off = @min(req.off, fs.help.len); + const bytes = fs.help[off..][0..@min(req.size, fs.help.len - off)]; + p.fs.stage(p.gpa).appendSlice(p.gpa, bytes) catch break :help Reply.fail(req.tag, E.NOMEM); + break :help .{ .tag = req.tag, .payload = .{ .staged = @intCast(bytes.len) } }; + }, + .index => index: { + const out = p.fs.stage(p.gpa); + var last: u32 = 0; + while (nextSerialAfter(p, last)) |serial| { + last = serial; + pane.stageIndexLine(p, out, p.panes[p.paneBySerial(serial).?].?); + } + break :index stagedReply(p, req); + }, + .ctl => ctl.readRoot(p, req), + .new => new: { + if (req.handle == 0) break :new Reply.fail(req.tag, E.INVAL); + p.fs.stage(p.gpa).print(p.gpa, "{d}\n", .{req.handle}) catch break :new Reply.fail(req.tag, E.NOMEM); + break :new stagedReply(p, req); + }, + .log => events.readQueue(p, req, &p.fs.log), + .screen => screen.readSnapshot(p, req, null), + .listeners => screen.readListeners(p, req), + .root, .pane => Reply.fail(req.tag, E.PERM), + }, + .pane => |t| { + const id = p.paneBySerial(t.serial) orelse return Reply.fail(req.tag, E.NOENT); + const pn = p.panes[id].?; + if (t.file.inPty() and !pn.isTerminal()) return Reply.fail(req.tag, E.NOENT); + return pane.read(p, req, id, pn, t.file); + }, + } +} + +fn write(p: *Pardes, req: Req, target: Target) Reply { + switch (target) { + .top => |f| return switch (f) { + .ctl => ctl.writeRoot(p, req), + else => Reply.fail(req.tag, E.PERM), + }, + .pane => |t| { + const id = p.paneBySerial(t.serial) orelse return Reply.fail(req.tag, E.NOENT); + const pn = p.panes[id].?; + if (t.file.inPty() and !pn.isTerminal()) return Reply.fail(req.tag, E.NOENT); + return pane.write(p, req, id, pn, t.file); + }, + } +} + +// ---- tests ---- + +test { + _ = events; + _ = pane; + _ = addr; + _ = ctl; + _ = pty; + _ = sources; + _ = screen; +} + +const testing = std.testing; +const th = @import("testing.zig"); +const config = @import("../config.zig"); +const call = th.call; +const rd = th.rd; +const wr = th.wr; +const rdir = th.rdir; +const look_up = th.look_up; +const withFile = th.withFile; +const serialOf = th.serialOf; + +test "filesystem inspection preserves pending and displayed Look hover" { + const delay = config.look_preview_delay_frames orelse return; + const gpa = testing.allocator; + const p = try withFile(gpa, "alpha beta gamma\n"); + defer p.deinit(); + var frame: std.heap.ArenaAllocator = .init(gpa); + defer frame.deinit(); + _ = try p.render(frame.allocator()); + const rect = p.rects[0]; + p.update(.{ .mouse = .{ + .button = .none, + .kind = .motion, + .col = rect.x + config.GUTTER + config.PREFIX_W + 7, + .row = if (p.settings.tag_bottom) rect.y else rect.y + pardes.BOX_H, + } }); + try testing.expect(p.look_hover_wait != null); + const body = Node.of(serialOf(p), .body); + const screen_node = @intFromEnum(TopFile.screen); + for (0..2) |phase| { + if (phase == 1) { + for (0..delay) |_| p.update(.tick); + try testing.expect(p.look_hover_preview != null); + } + const waiting = p.look_hover_wait; + const preview = p.look_hover_preview; + const requests = [_]Req{ + .{ .tag = 1, .op = .lookup, .node = root, .data = "screen" }, + .{ .tag = 1, .op = .lookup, .node = root, .data = "new" }, + .{ .tag = 1, .op = .getattr, .node = @intFromEnum(TopFile.new) }, + .{ .tag = 2, .op = .getattr, .node = body }, + .{ .tag = 3, .op = .open, .node = body }, + .{ .tag = 4, .op = .read, .node = body, .size = 5 }, + .{ .tag = 5, .op = .release, .node = body, .handle = 1 }, + .{ .tag = 6, .op = .readdir, .node = root, .size = 4096 }, + .{ .tag = 7, .op = .open, .node = screen_node }, + .{ .tag = 8, .op = .read, .node = screen_node, .handle = 1, .size = 32 }, + .{ .tag = 9, .op = .release, .node = screen_node, .handle = 1 }, + }; + for (requests) |req| { + const answer = call(p, req); + try testing.expectEqual(Status.ok, answer.reply.status); + try testing.expect(std.meta.eql(waiting, p.look_hover_wait)); + try testing.expect(std.meta.eql(preview, p.look_hover_preview)); + try testing.expect(p.raw_hover_intent); + } + } + try testing.expectEqual(Status.ok, wr(p, body, "changed").reply.status); + try testing.expect(p.look_hover_wait == null); + try testing.expect(p.look_hover_preview == null); + try testing.expect(!p.raw_hover_intent); +} + +test "filesystem pane creation and truncation cancel Look hover" { + const requests = [_]Req{ + .{ .tag = 2, .op = .open, .node = @intFromEnum(TopFile.new) }, + .{ .tag = 3, .op = .setattr, .node = 0, .truncate = true }, + }; + for (requests) |request| { + const p = try withFile(testing.allocator, "word\n"); + defer p.deinit(); + p.look_hover_wait = .{ .col = 1, .row = 1, .pane = 0, .serial = serialOf(p) }; + p.raw_hover_intent = true; + var req = request; + if (req.op == .setattr) req.node = Node.of(serialOf(p), .body); + try testing.expectEqual(Status.ok, call(p, req).reply.status); + try testing.expect(p.look_hover_wait == null); + try testing.expect(p.look_hover_preview == null); + try testing.expect(!p.raw_hover_intent); + } +} + +test "readdir lists the root and a pane directory without creating anything" { + const gpa = testing.allocator; + const p = try withFile(gpa, "hello\n"); + defer p.deinit(); + const serial = serialOf(p); + var buf: [32]th.Dirent = undefined; + + const before = p.next_serial; + const top_reply = rdir(p, root, 0); + try testing.expectEqual(Status.ok, top_reply.reply.status); + var top_bytes: [4096]u8 = undefined; + @memcpy(top_bytes[0..top_reply.bytes.len], top_reply.bytes); + const top = th.dirents(top_bytes[0..top_reply.bytes.len], &buf); + try testing.expect(top.len >= 9); + for ([_][]const u8{ "README", "index", "ctl", "new", "log", "screen", "listeners", "pane", "os" }, 0..) |name, i| { + try testing.expectEqualStrings(name, top[i].name); + try testing.expectEqual(i >= 7, top[i].dir); + } + try testing.expectEqual(@intFromEnum(TopFile.pane), top[7].node); + try testing.expectEqual(fs.os_root, top[8].node); + var idbuf: [16]u8 = undefined; + try testing.expect(th.nameAt(top, try std.fmt.bufPrint(&idbuf, "{d}", .{serial})) == null); + try testing.expect(th.nameAt(top, "self") == null); + try testing.expect(th.nameAt(top, "cons") == null); + + var rest_buf: [32]th.Dirent = undefined; + const rest = rdir(p, root, 3); + try testing.expectEqual(top.len - 3, th.dirents(rest.bytes, &rest_buf).len); + const eof = rdir(p, root, 99); + try testing.expectEqual(Status.ok, eof.reply.status); + try testing.expectEqual(@as(usize, 0), eof.bytes.len); + + // Walk, stat and open-for-read every top entry a browser would, then every pane file. + for (top) |entry| { + if (std.mem.eql(u8, entry.name, "os")) continue; + const inspected = look_up(p, root, entry.name); + try testing.expectEqual(Status.ok, inspected.reply.status); + try testing.expectEqual(entry.node, inspected.reply.attr.node); + try testing.expectEqual(Status.ok, call(p, .{ .tag = 1, .op = .getattr, .node = entry.node }).reply.status); + try testing.expectEqual(before, p.next_serial); + } + const panes_dir = rdir(p, @intFromEnum(TopFile.pane), 0); + const listed = th.dirents(panes_dir.bytes, &buf); + try testing.expectEqual(@as(usize, 1), listed.len); + try testing.expectEqual(Node.of(serial, .dir), listed[0].node); + + const dir = rdir(p, Node.of(serial, .dir), 0); + const files = th.dirents(dir.bytes, &buf); + try testing.expectEqual(@as(usize, 10), files.len); + for ([_][]const u8{ "name", "body", "tag", "ctl", "addr", "data", "xdata", "sel", "errors", "event" }, 0..) |name, i| + try testing.expectEqualStrings(name, files[i].name); + try testing.expect(th.nameAt(files, ".") == null); + try testing.expect(th.nameAt(files, "rdsel") == null); + try testing.expectEqual(Node.of(serial, .body), th.nameAt(files, "body").?.node); + for (files) |entry| { + const stat = call(p, .{ .tag = 1, .op = .getattr, .node = entry.node }); + try testing.expectEqual(Status.ok, stat.reply.status); + try testing.expectEqual(p.fs.started, stat.reply.attr.mtime); + } + try testing.expectEqual(before, p.next_serial); + + try testing.expectEqual(E.NOTDIR, rdir(p, Node.of(serial, .body), 0).errno()); + try testing.expectEqual(E.NOTDIR, rdir(p, @intFromEnum(TopFile.index), 0).errno()); +} + +test "lookup resolves top files, pane serials and pane files" { + const gpa = testing.allocator; + const p = try withFile(gpa, "hello\n"); + defer p.deinit(); + const serial = serialOf(p); + + try testing.expectEqual(@as(u64, @intFromEnum(TopFile.index)), look_up(p, root, "index").reply.attr.node); + try testing.expect(!look_up(p, root, "new").reply.attr.dir); + try testing.expectEqual(@as(u16, 0o444), look_up(p, root, "new").reply.attr.mode); + try testing.expect(look_up(p, root, "pane").reply.attr.dir); + try testing.expect(look_up(p, root, "os").reply.attr.dir); + try testing.expectEqual(E.NOENT, look_up(p, root, "nosuchthing").errno()); + try testing.expectEqual(E.NOENT, look_up(p, root, "self").errno()); + try testing.expectEqual(E.NOENT, look_up(p, root, "cons").errno()); + try testing.expectEqual(E.NOTDIR, look_up(p, @intFromEnum(TopFile.index), "x").errno()); + + var idbuf: [16]u8 = undefined; + const serial_name = try std.fmt.bufPrint(&idbuf, "{d}", .{serial}); + try testing.expectEqual(E.NOENT, look_up(p, root, serial_name).errno()); + const dir = look_up(p, @intFromEnum(TopFile.pane), serial_name); + try testing.expectEqual(Node.of(serial, .dir), dir.reply.attr.node); + try testing.expect(dir.reply.attr.dir); + try testing.expectEqualStrings(serial_name, dir.reply.attr.name); + try testing.expectEqual(E.NOENT, look_up(p, @intFromEnum(TopFile.pane), "99999").errno()); + try testing.expectEqual(E.NOENT, look_up(p, @intFromEnum(TopFile.pane), "0").errno()); + + const body = look_up(p, Node.of(serial, .dir), "body"); + try testing.expectEqual(Node.of(serial, .body), body.reply.attr.node); + const stat = call(p, .{ .tag = 4, .op = .getattr, .node = Node.of(serial, .body) }); + try testing.expectEqual(body.reply.attr.size, stat.reply.attr.size); + try testing.expectEqual(@as(u64, "hello\n".len), stat.reply.attr.size); + try testing.expectEqual(E.NOENT, look_up(p, Node.of(serial, .dir), "editout").errno()); + try testing.expectEqual(E.NOENT, look_up(p, Node.of(serial, .dir), "rdsel").errno()); + try testing.expectEqual(E.NOTDIR, look_up(p, Node.of(serial, .body), "x").errno()); +} + +test "each open of new creates exactly one pane whose serial the read answers" { + const gpa = testing.allocator; + const p = try withFile(gpa, "first\n"); + defer p.deinit(); + const before = p.next_serial; + const new = @intFromEnum(TopFile.new); + + try testing.expectEqual(Status.ok, look_up(p, root, "new").reply.status); + try testing.expectEqual(Status.ok, call(p, .{ .tag = 1, .op = .getattr, .node = new }).reply.status); + try testing.expectEqual(before, p.next_serial); + + const opened = call(p, .{ .tag = 1, .op = .open, .node = new }); + try testing.expectEqual(Status.ok, opened.reply.status); + try testing.expectEqual(before + 1, p.next_serial); + try testing.expectEqual(before + 1, opened.reply.handle); + try testing.expectEqual(@as(u64, 0), opened.reply.attr.node); + var expected: [16]u8 = undefined; + const line = try std.fmt.bufPrint(&expected, "{d}\n", .{opened.reply.handle}); + try testing.expectEqualStrings(line, call(p, .{ .tag = 2, .op = .read, .node = new, .handle = opened.reply.handle, .size = 64 }).bytes); + try testing.expectEqualStrings(line[1..], call(p, .{ .tag = 2, .op = .read, .node = new, .handle = opened.reply.handle, .off = 1, .size = 64 }).bytes); + try testing.expectEqualStrings("", call(p, .{ .tag = 2, .op = .read, .node = new, .handle = opened.reply.handle, .off = line.len, .size = 64 }).bytes); + try testing.expectEqual(before + 1, p.next_serial); + _ = call(p, .{ .tag = 3, .op = .release, .node = new, .handle = opened.reply.handle }); + + const id = p.paneBySerial(opened.reply.handle).?; + try testing.expectEqualStrings("", p.panes[id].?.file.?.content); + _ = wr(p, Node.of(opened.reply.handle, .body), "hi"); + const second = call(p, .{ .tag = 4, .op = .open, .node = new }); + try testing.expectEqual(Status.ok, second.reply.status); + try testing.expect(second.reply.handle != opened.reply.handle); + try testing.expectEqualStrings("hi", p.panes[id].?.file.?.content); + try testing.expectEqual(E.INVAL, call(p, .{ .tag = 5, .op = .read, .node = new, .size = 64 }).errno()); +} + +test "directories walk to their parents" { + const p = try withFile(testing.allocator, "contents\n"); + defer p.deinit(); + for ([_]struct { node: u64, parent: u64 }{ + .{ .node = root, .parent = root }, + .{ .node = @intFromEnum(TopFile.pane), .parent = root }, + .{ .node = Node.of(serialOf(p), .dir), .parent = @intFromEnum(TopFile.pane) }, + .{ .node = fs.os_root, .parent = root }, + }) |case| { + const result = look_up(p, case.node, ".."); + try testing.expectEqual(Status.ok, result.reply.status); + try testing.expectEqual(case.parent, result.reply.attr.node); + } + try testing.expectEqual(E.NOTDIR, look_up(p, @intFromEnum(TopFile.index), "..").errno()); + try testing.expectEqual(E.NOTDIR, look_up(p, Node.of(serialOf(p), .body), "..").errno()); +} + +test "editor paths resolve to the same nodes the wire serves" { + const p = try withFile(testing.allocator, "contents\n"); + defer p.deinit(); + const serial = serialOf(p); + var path: [64]u8 = undefined; + try testing.expectEqual(root, resolveSelf(p, "").?); + try testing.expectEqual(root, resolveSelf(p, "/./pane/../").?); + try testing.expectEqual(@intFromEnum(TopFile.index), resolveSelf(p, "index").?); + try testing.expectEqual(@intFromEnum(TopFile.new), resolveSelf(p, "new").?); + try testing.expectEqual(@intFromEnum(TopFile.pane), resolveSelf(p, "pane").?); + try testing.expectEqual(Node.of(serial, .dir), resolveSelf(p, try std.fmt.bufPrint(&path, "pane/{d}", .{serial})).?); + try testing.expectEqual(Node.of(serial, .sel), resolveSelf(p, try std.fmt.bufPrint(&path, "pane/{d}/sel", .{serial})).?); + try testing.expect(resolveSelf(p, try std.fmt.bufPrint(&path, "pane/{d}/pty/ctl", .{serial})) == null); + try testing.expect(resolveSelf(p, try std.fmt.bufPrint(&path, "pane/{d}/rdsel", .{serial})) == null); + try testing.expect(resolveSelf(p, "self/index") == null); + try testing.expect(resolveSelf(p, "new/ctl") == null); + try testing.expect(resolveSelf(p, "cons") == null); + try testing.expect(resolveSelf(p, "pane/0") == null); +} diff --git a/src/panes.zig b/src/panes.zig index 49e5d624..edd7038f 100644 --- a/src/panes.zig +++ b/src/panes.zig @@ -1014,6 +1014,8 @@ pub const File = struct { /// Equal means the screen matches disk. saved_revision: u32 = 0, watch_after_save: bool = false, + /// Seconds of the last content change, for the filesystem's stat; zero until edited. + mtime: u32 = 0, /// Non-null for a generated output buffer rather than an on-disk file. output: ?Output.State = null, mini: ?Mini.State = null, @@ -1702,7 +1704,7 @@ pub const File = struct { const pane = slot orelse continue; if (pane.file) |*state| if (state == f) break i; } else return; - pardes.filesystem.noteReplace(p, id, false, f.content, new); + pardes.ctlfs.events.noteReplace(p, id, false, f.content, new); } pub fn setContent(p: *Pardes, f: *State, new: []u8) void { @@ -1722,6 +1724,7 @@ pub const File = struct { p.gpa.free(f.content); f.content = new; f.revision +%= 1; + f.mtime = pardes.ctlfs.events.now(); if (f.line_starts.len > 0) p.gpa.free(f.line_starts); f.line_starts = &.{}; if (f.highlights.len > 0) p.tree_sitter_gpa.free(f.highlights); @@ -2876,6 +2879,8 @@ pub const Output = struct { else => return error.NotAnEffect, } if (!setting.enabled(builtins.capabilities)) 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 return error.EffectUnavailable; diff --git a/src/pardes.zig b/src/pardes.zig index 5c0ac263..88442542 100644 --- a/src/pardes.zig +++ b/src/pardes.zig @@ -6,6 +6,7 @@ const mvzr = @import("mvzr"); pub const modal = @import("modal.zig"); pub const look = @import("look.zig"); pub const filesystem = @import("fs.zig"); +pub const ctlfs = @import("ninep/tree.zig"); pub const syntax = @import("syntax.zig"); pub const locations_config = @import("locations_config.zig"); const tracy = @import("tracy.zig"); @@ -4711,7 +4712,7 @@ pub const Event = union(enum) { /// this must not clamp onto and preview the final grid cell. pointer_leave, tick, - fs_req: filesystem.Req, + fs_req: ctlfs.Req, }; pub const attach_name_max = 256; @@ -4749,7 +4750,7 @@ pub const Effect = union(enum) { /// Write the build-time theme ring below the per-user config directory. /// The pane receives the completion/error message from the native host. dump_themes: struct { pane: u8 }, - fs_reply: filesystem.Reply, + fs_reply: ctlfs.Reply, attach: struct { pane: u8, name: Buf(attach_name_max) }, detach: struct { pane: u8 }, quit, @@ -6109,6 +6110,7 @@ pub const Pardes = struct { .fallback = .{ .gpa = gpa }, }; errdefer p.deinit(); + p.fs.started = ctlfs.events.now(); for (opts.mounts) |mount| try p.fs.mount(gpa, mount.name, mount.dial); p.opts.mounts = &.{}; p.opts.ninep_identity = .{}; @@ -6335,6 +6337,7 @@ pub const Pardes = struct { const watched = (if (pane.file) |f| f.output == null else false) or pane.hasPdf(); for (p.panes, 0..) |slot, id| if (slot == pane) { if (watched) p.emit(.{ .watch = .{ .pane = @intCast(id), .on = false } }); + ctlfs.events.noteRetire(p, id, pane); p.fs.forget(p.gpa, id); // ...and so do bytes still queued for the pty it no longer has. p.dropPendingWrite(id); @@ -6380,6 +6383,7 @@ pub const Pardes = struct { pane.serial = p.next_serial; p.rects[id] = .{}; p.panes[id] = pane; + ctlfs.events.noteInstall(p, id); } pub fn newShell(p: *Pardes, id: usize, cwd: []const u8) !*Pane { @@ -6924,7 +6928,7 @@ pub const Pardes = struct { return pane.pdfPath(); } - pub fn fsPayload(p: *const Pardes, r: filesystem.Reply) []const u8 { + pub fn fsPayload(p: *const Pardes, r: ctlfs.Reply) []const u8 { return switch (r.payload) { .none => &.{}, .staged => |n| p.fs.out.items[0..@min(n, p.fs.out.items.len)], @@ -6961,6 +6965,7 @@ pub const Pardes = struct { p.hostWriteFile(sf.pane, f.path, f.content); const saved_pane = p.panes[sf.pane] orelse return; if (saved_pane.serial != serial) return; + ctlfs.events.noteLog(p, .save, saved_pane); const saved = if (saved_pane.file) |*file| file else return; if (saved.saved_revision != saved.revision or !saved.watch_after_save) return; saved.watch_after_save = false; @@ -7116,7 +7121,7 @@ pub const Pardes = struct { }, .output => |o| { const pane = p.panes[o.pane] orelse return; - filesystem.notePtyOutput(p, o.pane, o.bytes); + ctlfs.events.notePtyOutput(p, o.pane, o.bytes); panes.Terminal.feedOutput(p, pane, o.bytes); }, .eof => |e| p.removePane(e.pane) catch |err| { @@ -7146,7 +7151,7 @@ pub const Pardes = struct { }, .paste => |bytes| p.applyPaste(bytes), .command => |line| _ = p.executeBuiltinLine(p.active, line), - .fs_req => |r| p.emit(.{ .fs_reply = filesystem.handle(p, r) }), + .fs_req => |r| p.emit(.{ .fs_reply = ctlfs.handle(p, r) }), .pinch => |scale| p.ov_pinch_scale = scale, .touch_scroll => |delta| p.ov_touch_scroll_delta = delta, .pointer_leave => { @@ -7163,6 +7168,7 @@ pub const Pardes = struct { _ = p.scratch.reset(.retain_capacity); p.sync(); p.fsReport(); + ctlfs.events.announce(p); } fn fsReport(p: *Pardes) void { @@ -7174,7 +7180,7 @@ pub const Pardes = struct { const snap = &p.fs.panes[id].tag_snap; if (std.mem.eql(u8, snap.items, tag)) continue; if (snap.capacity != 0 or snap.items.len != 0) - filesystem.noteReplace(p, id, true, snap.items, tag); + ctlfs.events.noteReplace(p, id, true, snap.items, tag); snap.clearRetainingCapacity(); snap.appendSlice(p.gpa, tag) catch {}; } @@ -7451,7 +7457,7 @@ pub const Pardes = struct { p.reportError(id, "name", err); return false; }; - filesystem.nameBuffer(p, id, full, true) catch |err| { + ctlfs.pane.nameBuffer(p, id, full, true) catch |err| { p.reportError(id, "name", err); return false; }; @@ -11673,21 +11679,21 @@ pub const Pardes = struct { ) bool { if (!p.fs.scripted(id)) return false; const is_look = cmd == config.look_cmd; - const action: filesystem.Action = if (is_look) + const action: ctlfs.events.Action = if (is_look) (if (on_tag) .tag_look else .body_look) else (if (on_tag) .tag_exec else .body_exec); const named = std.meta.stringToEnum(Builtin, commandText(text)) != null; const range = p.gestureRange(id, text, on_tag, operand); - var flag: u32 = if (named) filesystem.flag_builtin else 0; - if (range.q0 == range.q1 and text.len > 0) flag |= filesystem.flag_expansion; + var flag: u32 = if (named) ctlfs.events.flag_builtin else 0; + if (range.q0 == range.q1 and text.len > 0) flag |= ctlfs.events.flag_expansion; if (is_look) { - if (!named and std.mem.indexOfAny(u8, text, "/.:") != null) flag |= filesystem.flag_filename; - } else if (chorded) flag |= filesystem.flag_chorded; - return filesystem.noteAction(p, id, action, range.q0, range.q1, flag, text); + if (!named and std.mem.indexOfAny(u8, text, "/.:") != null) flag |= ctlfs.events.flag_filename; + } else if (chorded) flag |= ctlfs.events.flag_chorded; + return ctlfs.events.noteAction(p, id, action, range.q0, range.q1, flag, text); } - fn gestureRange(p: *Pardes, id: usize, text: []const u8, on_tag: bool, operand: PointerOperand) filesystem.PaneState.Range { + fn gestureRange(p: *Pardes, id: usize, text: []const u8, on_tag: bool, operand: PointerOperand) ctlfs.pane.State.Range { const pane = p.panes[id] orelse return .{}; if (on_tag) { const tag = p.tagText(p.scratch.allocator(), pane) catch return .{}; diff --git a/src/tutor.txt b/src/tutor.txt index ae22ede9..394a48a3 100644 --- a/src/tutor.txt +++ b/src/tutor.txt @@ -387,29 +387,30 @@ typed pardes the 9P socket opens by default - A directory per pane holding `body`, `tag`, `ctl`, `addr`, `data`, - `event`, `pty/` and the rest, plus `index`, `cons` and `new/` at the - top under /self. Every pane shell receives `$PARDES_9P` (the socket) - and `$PARDES_PANE` (its serial). Use a 9P client to read and write: + A directory per pane holding `name`, `body`, `tag`, `ctl`, `addr`, + `data`, `sel`, `event`, `pty/` and the rest, plus `index`, `ctl`, + `new` and `log` at the root. Every pane shell receives `$PARDES_9P` + (the socket) and `$PARDES_PANE` (its serial). Use a 9P client: - /self/pane//body - /self/index - /self/new/ctl + /pane//body + /index + /new reading it makes a pane, answers its serial + /ctl `look FILE:12` and `exec Save`, as the mouse does A terminal pane also has `pty/`: - /self/pane/3/pty/ctl winsize, sig - /self/pane/3/pty/data terminal input/output + /pane/3/pty/ctl winsize, sig + /pane/3/pty/data terminal input/output Over 9P the same tree answers plan9port, from anywhere: 9p -a $XDG_RUNTIME_DIR/pardes-9p-work.sock ls / - 9p -a $XDG_RUNTIME_DIR/pardes-9p-work.sock read /self/index + 9p -a $XDG_RUNTIME_DIR/pardes-9p-work.sock read index ...and pardes is a 9P CLIENT too, so one session can read another's: pardes --mount=peer=work - /n/peer/self/pane/1/body Look opens the other session's body + /n/peer/pane/1/body Look opens the other session's body TWO THINGS WORTH KNOWING. While a program holds a pane's `event` file open, MIDDLE AND RIGHT CLICKS IN THAT PANE BELONG TO IT: pardes reports @@ -467,7 +468,7 @@ typed SPC is the leader (SPC ? lists every path) SCRIPTING 9P is served by default on $PARDES_9P - /self/pane//{body,tag,ctl,addr,data,event,pty/} + /pane//{name,body,tag,ctl,addr,data,sel,event,pty/} a script holding `event` owns that pane's middle and right clicks; writing a record back runs it diff --git a/test/agent_session.py b/test/agent_session.py index b920b006..aa87c845 100644 --- a/test/agent_session.py +++ b/test/agent_session.py @@ -52,21 +52,21 @@ def run(args, command, status): client, _ = context.__enter__() try: try: - while not client.read('/self/pane/1/body').strip(): + while not client.read('/pane/1/body').strip(): time.sleep(.01) started = time.monotonic() - client.write('/self/pane/1/pty/data', shlex.join(['/bin/sh', str(script)]).encode() + b'\r') + client.write('/pane/1/pty/data', shlex.join(['/bin/sh', str(script)]).encode() + b'\r') status['phase'] = 'readiness' wait_ready(client, args.ready) if args.prepare_key is not None: status['phase'] = 'preparation' - client.write('/self/pane/1/pty/data', args.prepare_key) + client.write('/pane/1/pty/data', args.prepare_key) wait_ready(client, args.ready) ready_ms = (time.monotonic() - started) * 1000 status.update(phase='history', required_body_rows=args.min_rows) while True: started = time.monotonic() - body = client.read('/self/pane/1/body') + body = client.read('/pane/1/body') body_read_ms = (time.monotonic() - started) * 1000 rows = body.count(b'\n') + int(bool(body) and not body.endswith(b'\n')) status.update(body_bytes=len(body), body_rows=rows) @@ -81,13 +81,13 @@ def run(args, command, status): raise AssertionError('probe is already visible') status['phase'] = 'probe-visible' started = time.monotonic() - client.write('/self/pane/1/pty/data', probe.encode()) + client.write('/pane/1/pty/data', probe.encode()) while probe not in screen_text(client).replace('\n', ''): time.sleep(.01) write_ms = (time.monotonic() - started) * 1000 status['phase'] = 'probe-cleared' started = time.monotonic() - client.write('/self/pane/1/pty/data', b'\x15') + client.write('/pane/1/pty/data', b'\x15') while True: observed = screen_text(client) status['observed_visible_text_sha256'] = hashlib.sha256(observed.encode()).hexdigest() @@ -109,7 +109,7 @@ def run(args, command, status): client.socket.settimeout(.25) for _ in range(2): try: - client.write('/self/pane/1/pty/data', b'\x03') + client.write('/pane/1/pty/data', b'\x03') except (OSError, EOFError): pass time.sleep(.05) diff --git a/test/appearance_gallery.py b/test/appearance_gallery.py index 7779efa9..0fa12136 100644 --- a/test/appearance_gallery.py +++ b/test/appearance_gallery.py @@ -80,21 +80,21 @@ def run(args): before = set(panes(client)) command(client, source, 'Newcol') right = require(wait_for(lambda: next((s for s in panes(client) if s not in before), None)), 'right column missing') - client.write(f'/self/pane/{right}/ctl', f'name {root / "Review"}\n'.encode()) - client.write(f'/self/pane/{right}/body', PREFERENCE_NOTES if args.theme_selector else NOTES, truncate=True) - client.write(f'/self/pane/{right}/ctl', b'clean\n') + client.write(f'/pane/{right}/name', f'{root / "Review"}\n'.encode()) + client.write(f'/pane/{right}/body', PREFERENCE_NOTES if args.theme_selector else NOTES, truncate=True) + client.write(f'/pane/{right}/ctl', b'clean\n') before = set(panes(client)) command(client, right, 'Tty') terminal = require(wait_for(lambda: next((s for s in panes(client) if s not in before), None)), 'terminal missing') - client.write(f'/self/pane/{terminal}/pty/data', b"PS1='$ '; printf '\\033[2J\\033[H\\033[1;36mPardes workspace\\033[0m\\n\\n'; printf 'Agave source: read-only\\nTerminal: ready\\n\\n'; printf '\\033[32mSmall touches. Same workflow.\\033[0m\\n'\r") - require(wait_for(lambda: b'Small touches. Same workflow.' in client.read(f'/self/pane/{terminal}/body')), 'terminal output missing') + client.write(f'/pane/{terminal}/pty/data', b"PS1='$ '; printf '\\033[2J\\033[H\\033[1;36mPardes workspace\\033[0m\\n\\n'; printf 'Agave source: read-only\\nTerminal: ready\\n\\n'; printf '\\033[32mSmall touches. Same workflow.\\033[0m\\n'\r") + require(wait_for(lambda: b'Small touches. Same workflow.' in client.read(f'/pane/{terminal}/body')), 'terminal output missing') def config_report(): before = set(panes(client)) command(client, right, 'Config') pane = require(wait_for(lambda: next((s for s in panes(client) if s not in before), None)), 'Config output missing') - text = client.read(f'/self/pane/{pane}/body').decode() - client.write(f'/self/pane/{pane}/ctl', b'del\n') + text = client.read(f'/pane/{pane}/body').decode() + client.write(f'/pane/{pane}/ctl', b'exec Del\n') return text settings = config_report() @@ -135,7 +135,7 @@ def run(args): command(client, right, 'Theme ' + theme) if args.theme_selector: # Keep both quiet active gutter ink and vivid comments in view. - client.write(f'/self/pane/{source}/ctl', f'look {source_path}:117\n'.encode()) + client.write(f'/pane/{source}/ctl', f'look {source_path}:117\n'.encode()) take_frame('classic-' + theme) if args.theme_selector: frame = client.screen() @@ -162,7 +162,7 @@ def run(args): command(client, right, 'ThemeSel') selector = require(wait_for(lambda: next((s for s in panes(client) if s not in before), None)), 'ThemeSel missing') - body = client.read(f'/self/pane/{selector}/body').decode() + body = client.read(f'/pane/{selector}/body').decode() native, legacy = body.split('# Legacy and imported themes', 1) for theme in ('forge_black', 'forge_soft', 'orchard_black'): require('Theme ' + theme + '\n' in native, 'native contrast variant below legacy heading') @@ -171,14 +171,14 @@ def run(args): 'ThemeSel did not open at native first entry') take_frame('theme-selector') report['native_themes_first'] = True - client.write(f'/self/pane/{selector}/ctl', b'del\n') + client.write(f'/pane/{selector}/ctl', b'exec Del\n') command(client, terminal, 'Collapse') for pet in (() if args.skip_pets else ('cat', 'frog', 'off')): command(client, right, 'Pet ' + pet) settings = config_report() require('Pet: ' + pet + '\n' in settings, 'pet setting not applied') # Returning focus to the source closes all transient report state. - client.write(f'/self/pane/{source}/ctl', f'look {source_path}:1\n'.encode()) + client.write(f'/pane/{source}/ctl', f'look {source_path}:1\n'.encode()) take_frame('pet-' + pet) if pet != 'off': frame = client.screen() @@ -194,9 +194,9 @@ def run(args): require(band_digest('pet-' + pet) != band_digest('pet-' + pet + '-later'), 'pet did not animate in workspace tag') report['pets'].append(pet) - require(client.read(f'/self/pane/{source}/body') == original == source_path.read_bytes(), 'Agave source changed') + require(client.read(f'/pane/{source}/body') == original == source_path.read_bytes(), 'Agave source changed') report['source_unchanged'] = True - client.write(f'/self/pane/{terminal}/pty/data', b'exit\r') + client.write(f'/pane/{terminal}/pty/data', b'exit\r') (root / 'report.json').write_text(json.dumps(report, indent=2)) print(json.dumps(report, indent=2)) diff --git a/test/collapse_layout.py b/test/collapse_layout.py index e549bd37..244ee57a 100644 --- a/test/collapse_layout.py +++ b/test/collapse_layout.py @@ -29,7 +29,7 @@ def geometry(client, names): def toggle(client, serial): """Execute the default tag's Collapse word without changing any body or tag.""" - pane = f'/self/pane/{serial}' + pane = f'/pane/{serial}' tag = client.read(pane + '/tag') at = tag.rfind(b' Collapse') require(at >= 0, 'default pane tag lacks Collapse') @@ -57,8 +57,8 @@ def run(args): for index, label in enumerate(names): if index: serials.append(new_pane(client, b'')) - pane = f'/self/pane/{serials[index]}' - client.write(pane + '/ctl', ('name ' + label + '\n').encode()) + pane = f'/pane/{serials[index]}' + client.write(pane + '/name', (label + '\n').encode()) client.write(pane + '/body', contents, truncate=True) original = require(wait_for(lambda: geometry(client, names)), 'four pane tags not visible') require(all(height > 1 for _, height in original), f'fixture has no body room: {original}') @@ -82,7 +82,7 @@ def run(args): require(wait_for(lambda: geometry(client, names) == original), f'expansion did not restore original geometry: {geometry(client, names)}') for serial in serials: - require(client.read(f'/self/pane/{serial}/body') == contents, 'Collapse changed pane contents') + require(client.read(f'/pane/{serial}/body') == contents, 'Collapse changed pane contents') require((root / (name + '.txt')).read_bytes() == b'initial\n', 'fixture source file changed') print(f'{"TTY" if args.tty else "SDL"}: 7 local collapse/expand pairs, exact unrelated pane geometry, and content preservation passed') diff --git a/test/column_tags.py b/test/column_tags.py index 6173d38a..80b623bd 100644 --- a/test/column_tags.py +++ b/test/column_tags.py @@ -70,7 +70,7 @@ def await_text(client, row, text): def tag(client, serial): - return client.read(f'/self/pane/{serial}/tag').decode().rstrip('\n') + return client.read(f'/pane/{serial}/tag').decode().rstrip('\n') def new_serial(client, previous): @@ -79,10 +79,10 @@ def new_serial(client, previous): def exec_tag_without_cleanup(client, serial, text): """Restore can replace the whole core, so never touch the old pane after it.""" - client.write(f'/self/pane/{serial}/tag', (' ' + text).encode()) - whole = client.read(f'/self/pane/{serial}/tag') + client.write(f'/pane/{serial}/tag', (' ' + text).encode()) + whole = client.read(f'/pane/{serial}/tag') start = whole.rfind(text.encode()) - client.write(f'/self/pane/{serial}/event', f'Mx{start} {start + len(text.encode())}\n'.encode()) + client.write(f'/pane/{serial}/event', f'Mx{start} {start + len(text.encode())}\n'.encode()) def reconnect(address): @@ -140,10 +140,10 @@ def run(args): keys.click(*require(locate(client, 'Newcol', row=0), 'Newcol missing'), button=1) right = require(wait_for(lambda: new_serial(client, before)), 'Newcol did not create its pane') right_name = root / 'right.rs' - client.write(f'/self/pane/{right}/ctl', f'name {right_name}\n'.encode()) + client.write(f'/pane/{right}/name', f'{right_name}\n'.encode()) right_body = b'// Column-local scratch\nfn main() {\n let ready = true;\n}\n' - client.write(f'/self/pane/{right}/body', right_body) - client.write(f'/self/pane/{right}/ctl', b'clean\n') + client.write(f'/pane/{right}/body', right_body) + client.write(f'/pane/{right}/ctl', b'clean\n') require(wait_for(lambda: locate(client, 'New Tty', row=1, minimum_col=75)), 'right column tag missing') require(locate(client, 'New Tty', row=1, minimum_col=75) == (75, 1), 'right column tag retains an inset') @@ -171,9 +171,9 @@ def run(args): before = panes(client) keys.click(col_start, 1, button=1) extra = require(wait_for(lambda: new_serial(client, before)), 'right-column New did not create a pane') - client.write(f'/self/pane/{extra}/body', b'RIGHT-COLUMN-NEW\n') + client.write(f'/pane/{extra}/body', b'RIGHT-COLUMN-NEW\n') require(wait_for(lambda: locate(client, 'RIGHT-COLUMN-NEW', minimum_col=75)), 'right-column command targeted another column') - client.write(f'/self/pane/{extra}/ctl', b'delete\n') + client.write(f'/pane/{extra}/ctl', b'exec Del\n') checks.append('middle-click New targets the inactive right column') # An owned short-path file makes its complete tag visible. Pane-tag @@ -197,7 +197,7 @@ def run(args): keys.escape() require(wait_for(lambda: tag(client, right).startswith(str(right_name) + ' ')), 'Escape did not cancel filename draft') require(not (root / 'Xright.rs').exists(), 'editing a filename wrote a file') - require(client.read(f'/self/pane/{right}/body') == right_body, 'tag editing changed file body') + require(client.read(f'/pane/{right}/body') == right_body, 'tag editing changed file body') checks.append('filename draft cancels without disk writes or body changes') # Keep a real embedded shell in the right column for useful captures. @@ -205,9 +205,9 @@ def run(args): before = panes(client) keys.click(*require(locate(client, 'Tty', row=1, minimum_col=75), 'Tty missing'), button=1) terminal = require(wait_for(lambda: new_serial(client, before)), 'column Tty did not create a pane') - require('pty' in client.list(f'/self/pane/{terminal}'), 'Tty created a non-terminal pane') - client.write(f'/self/pane/{terminal}/pty/data', b"printf 'Column-local terminal ready\\n'; pwd\r") - require(wait_for(lambda: b'\nColumn-local terminal ready\n' in client.read(f'/self/pane/{terminal}/body').replace(b'\r', b'')), 'terminal command output missing') + require('pty' in client.list(f'/pane/{terminal}'), 'Tty created a non-terminal pane') + client.write(f'/pane/{terminal}/pty/data', b"printf 'Column-local terminal ready\\n'; pwd\r") + require(wait_for(lambda: b'\nColumn-local terminal ready\n' in client.read(f'/pane/{terminal}/body').replace(b'\r', b'')), 'terminal command output missing') checks.append('right-column embedded terminal executes harmless commands') # Persistence is checked through real Dump/Restore dispatch and the @@ -285,11 +285,11 @@ def run(args): capture(client, root, 'columns-tag-reveal', not args.tty) keys.escape() checks.append('long-path pane tag reveals its command tail when the caret moves to End') - require(client.read(f'/self/pane/{source_serial}/body') == original == source.read_bytes(), 'Agave source changed') + require(client.read(f'/pane/{source_serial}/body') == original == source.read_bytes(), 'Agave source changed') checks.append('Agave source bytes unchanged') for serial in panes(client): - if 'pty' in client.list(f'/self/pane/{serial}'): - client.write(f'/self/pane/{serial}/pty/data', b'exit\r') + if 'pty' in client.list(f'/pane/{serial}'): + client.write(f'/pane/{serial}/pty/data', b'exit\r') report = {'checks': checks, 'cols': 150, 'rows': 48, 'host': 'tty' if args.tty else 'sdl', 'input': 'keyboard and SGR mouse through the host PTY parser', 'source': str(source), 'artifacts': str(root)} diff --git a/test/font_size.py b/test/font_size.py index e40b7b3a..3a0a9a28 100644 --- a/test/font_size.py +++ b/test/font_size.py @@ -29,7 +29,7 @@ def run(args): def ready(): for serial, tag in panes(client).items(): if '/+Config ' in tag: - body = client.read(f'/self/pane/{serial}/body').decode() + body = client.read(f'/pane/{serial}/body').decode() if f'Font effective size: {size:.2f} pixels' in body: return body return None diff --git a/test/fs.py b/test/fs.py index 2ffd5098..819a78d6 100644 --- a/test/fs.py +++ b/test/fs.py @@ -72,7 +72,7 @@ def session(binary, root, name, *options, socket_name=None, file=None, tty=False time.sleep(.005) with Client(address) as client: if network is not None: - for dial in client.read('/self/listeners').decode().splitlines(): + for dial in client.read('/listeners').decode().splitlines(): parts = dial.split('!') if parts[0] in ['tcp', 'quic']: assert len(parts) == 3 and 0 < int(parts[2]) < 65536, dial @@ -101,60 +101,136 @@ def session(binary, root, name, *options, socket_name=None, file=None, tty=False def new_pane(client, contents): - serial = int(client.read('/self/new/ctl').split()[0]) - client.write(f'/self/pane/{serial}/body', contents) + serial = int(client.read('/new').split()[0]) + if contents: + client.write(f'/pane/{serial}/body', contents) return serial def look(client, path, source=None): + """A right click on `path` from a pane (a fresh scratch by default).""" serial = source if source is not None else new_pane(client, b'') - client.write(f'/self/pane/{serial}/body', path.encode(), truncate=True) - client.write(f'/self/pane/{serial}/event', f'ML0 {len(path.encode())}\n'.encode()) - rows = client.read('/self/index').splitlines() - opened = int(rows[-1].split()[0]) - assert opened != serial, f'Look did not open {path}' - return opened + client.write(f'/pane/{serial}/ctl', f'look {path}\n'.encode()) + results = [int(row) for row in client.read('/ctl').split()] + assert len(results) == 1 and results[0] != serial, (path, results) + return results[0] def execute(client, serial, command): - text = command.encode() - client.write(f'/self/pane/{serial}/body', text, truncate=True) - client.write(f'/self/pane/{serial}/event', f'MX0 {len(text)}\n'.encode()) + """A middle click on `command` from a pane.""" + client.write(f'/pane/{serial}/ctl', f'exec {command}\n'.encode()) -def discovery(binary): +def walk_tree(client, path='/', skip=('/new', '/log', '/os', '/screen')): + """Stat every entry below `path`, as `find` does, without opening anything.""" + seen = [] + for name in client.list(path): + child = (path.rstrip('/') + '/' + name) + info = client.stat(child) + seen.append((child, info)) + if info['dir'] and child not in skip: + seen.extend(walk_tree(client, child, skip)) + return seen + + +def discovery(binary, embedded=False): with tempfile.TemporaryDirectory(prefix='pardes-discovery-') as directory: - with session(binary, Path(directory), 'discovery') as (client, _): - before = client.read('/self/index') - entries = client.list('/self/new') - assert {'README', 'ctl', 'body', 'addr', 'data', 'event'} <= set(entries) - guide = client.read('/self/README') - assert guide == client.read('/self/new/README') - assert b'Each open creates a separate pane' in guide - # Walk and stat each entry, as a filesystem browser does, without open. - from ninep import string - for name in entries: - client.fid += 1 - fid = client.fid - client.rpc(110, struct.pack(' 0, (path, info) + assert client.read('/index') == before, 'browsing created a pane' + assert client.stat('/index')['length'] == len(before) > 0 + index = client.stat('/index') + assert index['mode'] == 0o444 and client.stat('/ctl')['mode'] == 0o666 + assert client.stat('/pane/1/body')['mode'] == 0o666 and client.stat('/pane')['mode'] == 0o755 + fixture = int(before.split()[0]) + assert before.split()[1:3] == [b'text', b'0'] and before.endswith(b'/discovery.txt\n'), before + # Before any command, /ctl reports the editor. + status = dict(line.split(maxsplit=1) for line in client.read('/ctl').decode().splitlines()) + assert int(status['pid']) > 0 and status['version'] and int(status['panes']) == 1, status + # /new: one pane per open, its serial is the file's content. + log = client.open('/log') + first = int(client.read('/new').split()[0]) + second = int(client.read('/new').split()[0]) + assert first != second and first != fixture, (first, second) + assert client.read_fid(log) == f'new {first} {root}/+New\n'.encode() + assert client.read_fid(log) == f'new {second} {root}/+New\n'.encode() + assert set(client.list('/pane')) == {str(fixture), str(first), str(second)} + client.write(f'/pane/{first}/body', b'first pane', truncate=True) + assert client.read(f'/pane/{first}/body') == b'first pane' + assert client.read(f'/pane/{second}/body') == b'' + assert client.stat(f'/pane/{first}/body')['length'] == len(b'first pane') + rows = {int(row.split()[0]): row.split() for row in client.read('/index').splitlines()} + assert rows[first][1:3] == [b'text', b'1'] and rows[second][1:3] == [b'text', b'0'], rows + # name: read the file name, write to rename; sel: the selection. + assert client.read(f'/pane/{first}/name') == f'{root}/+New\n'.encode() + client.write(f'/pane/{first}/name', b'notes.txt\n') + assert client.read(f'/pane/{first}/name') == f'{root}/notes.txt\n'.encode() + assert client.read_fid(log) == f'rename {first} {root}/notes.txt\n'.encode() + assert client.stat(f'/pane/{first}/name')['length'] == len(f'{root}/notes.txt\n') + client.write(f'/pane/{first}/addr', b'#0,#5') + client.write(f'/pane/{first}/ctl', b'dot=addr\n') + assert client.read(f'/pane/{first}/sel') == b'first' + assert client.stat(f'/pane/{first}/sel')['length'] == 5 + client.write(f'/pane/{first}/sel', b'FIRST') + assert client.read(f'/pane/{first}/body') == b'FIRST pane' + assert client.read(f'/pane/{first}/sel') == b'' + # exec Msg shows text; exec Save writes the named file; exec Del closes. + client.write(f'/pane/{first}/ctl', b'exec Msg hello from 9P\n') + assert 'hello from 9P' in ''.join(cell[0] for cell in client.screen()['cells']) + client.write(f'/pane/{first}/ctl', b'exec Save\n') + assert (root / 'notes.txt').read_bytes() == b'FIRST pane' + assert client.read_fid(log) == f'save {first} {root}/notes.txt\n'.encode() + assert client.read('/ctl') == f'{first}\n'.encode() + client.write('/ctl', b'exec Del\n') + assert client.read_fid(log) == f'del {second} {root}/+New\n'.encode() + assert str(second) not in client.list('/pane') + # look through /ctl opens a file; the serial reads back. + (root / 'opened.txt').write_bytes(b'one\ntwo\nthree\n') + client.write('/ctl', f'look {root}/opened.txt:2\n'.encode()) + opened = int(client.read('/ctl')) + assert opened not in (fixture, first, second), opened + assert client.read(f'/pane/{opened}/body') == b'one\ntwo\nthree\n' + assert client.read(f'/pane/{opened}/name') == f'{root}/opened.txt\n'.encode() + assert client.read_fid(log) == f'new {opened} {root}/opened.txt\n'.encode() + client.write(f'/pane/{first}/ctl', f'look {root}/opened.txt:3\n'.encode()) + assert client.read('/ctl') == f'{opened}\n'.encode(), 'a repeated look targets the open pane' + assert set(client.list('/pane')) == {str(fixture), str(first), str(opened)} + # Writing an event record back still performs the action it names. + client.write(f'/pane/{first}/body', b'Msg via event', truncate=True) + client.write(f'/pane/{first}/event', b'FX0 13\n') + assert 'via event' in ''.join(cell[0] for cell in client.screen()['cells']) + for bad in [b'Look x\n', b'Exec Msg x\n', b'put\n', b'name x\n', b'del\n']: try: - client.rpc(124, struct.pack(' [--quic | --discovery]') diff --git a/test/fs_bench.zig b/test/fs_bench.zig index 7fe49734..f9735ee2 100644 --- a/test/fs_bench.zig +++ b/test/fs_bench.zig @@ -1,6 +1,7 @@ const std = @import("std"); const pardes = @import("pardes"); const filesystem = pardes.filesystem; +const ctlfs = pardes.ctlfs; pub const std_options: std.Options = .{ .log_level = .err }; @@ -73,8 +74,8 @@ const Session = struct { s.core.deinit(); } - fn node(s: *const Session, file: filesystem.PaneFile) u64 { - return filesystem.Node.of(s.file_serial, file); + fn node(s: *const Session, file: ctlfs.PaneFile) u64 { + return ctlfs.Node.of(s.file_serial, file); } }; @@ -90,9 +91,9 @@ fn checkNumbers(bytes: []const u8, expected: []const usize) ![]const u8 { return std.mem.trimStart(u8, rest, " "); } -fn checkReply(s: *Session, req: filesystem.Req, reply: filesystem.Reply) !void { +fn checkReply(s: *Session, req: ctlfs.Req, reply: ctlfs.Reply) !void { const event_read = req.op == .read and req.node == s.node(.event); - const expected_status: filesystem.Status = if (event_read) .again else .ok; + const expected_status: ctlfs.Status = if (event_read) .again else .ok; if (reply.tag != req.tag or reply.errno != 0 or reply.status != expected_status) return error.IncorrectReply; const body = s.core.panes[s.file_id].?.file.?.content; @@ -112,16 +113,18 @@ fn checkReply(s: *Session, req: filesystem.Req, reply: filesystem.Reply) !void { if (reply.payload != .staged or reply.payload.staged != bytes.len or bytes.len > req.size) return error.IncorrectReply; const pane = s.core.panes[s.file_id].?; + if (req.node == @intFromEnum(ctlfs.TopFile.index)) { + var expected_buf: [4200]u8 = undefined; + const expected = try std.fmt.bufPrint(&expected_buf, "{d} text {d} {s}\n", .{ s.file_serial, @intFromBool(pane.file.?.revision != pane.file.?.saved_revision), pane.file.?.path }); + if (!std.mem.eql(u8, expected, bytes)) return error.IncorrectReply; + return; + } const rest = try checkNumbers(bytes, &.{ s.file_serial, s.tag.len, body.len, 0, @intFromBool(pane.file.?.revision != pane.file.?.saved_revision) }); if (req.node == s.node(.ctl)) { const tail = try checkNumbers(rest, &.{pane.cols}); if (!std.mem.startsWith(u8, tail, "default ")) return error.IncorrectReply; if ((try checkNumbers(tail[8..], &.{pardes.config.tab_width})).len != 0) return error.IncorrectReply; - } else if (req.node == @intFromEnum(filesystem.SelfFile.index)) { - const tag = s.tag[0 .. std.mem.indexOfScalar(u8, s.tag, '\n') orelse s.tag.len]; - if (rest.len != tag.len + 1 or rest[rest.len - 1] != '\n' or !std.mem.eql(u8, rest[0..tag.len], tag)) - return error.IncorrectReply; } else return error.UnmeasuredOperation; } }, @@ -129,8 +132,8 @@ fn checkReply(s: *Session, req: filesystem.Req, reply: filesystem.Reply) !void { const bytes = s.core.fs.out.items; if (reply.payload != .staged or reply.payload.staged != bytes.len or bytes.len > req.size) return error.IncorrectReply; - const names = [_][]const u8{ "index", "cons", "new", "pane", "screen", "listeners" }; - const nodes = [_]u64{ @intFromEnum(filesystem.SelfFile.index), @intFromEnum(filesystem.SelfFile.cons), @intFromEnum(filesystem.SelfFile.new), filesystem.namespace_panes, @intFromEnum(filesystem.SelfFile.screen), @intFromEnum(filesystem.SelfFile.listeners) }; + const names = [_][]const u8{ "README", "index", "ctl", "new", "log", "screen", "listeners", "pane", "os" }; + const nodes = [_]u64{ @intFromEnum(ctlfs.TopFile.README), @intFromEnum(ctlfs.TopFile.index), @intFromEnum(ctlfs.TopFile.ctl), @intFromEnum(ctlfs.TopFile.new), @intFromEnum(ctlfs.TopFile.log), @intFromEnum(ctlfs.TopFile.screen), @intFromEnum(ctlfs.TopFile.listeners), @intFromEnum(ctlfs.TopFile.pane), filesystem.os_root }; var off: usize = 0; var entry: usize = 0; while (off < bytes.len) : (entry += 1) { @@ -140,7 +143,7 @@ fn checkReply(s: *Session, req: filesystem.Req, reply: filesystem.Reply) !void { const size: usize = bytes[off + 9]; off += 10; if (dir > 1 or size == 0 or size > bytes.len - off) return error.IncorrectReply; - if (entry < names.len and (node != nodes[entry] or dir != @intFromBool(entry == 2 or entry == 3) or + if (entry < names.len and (node != nodes[entry] or dir != @intFromBool(entry >= 7) or !std.mem.eql(u8, names[entry], bytes[off..][0..size]))) return error.IncorrectReply; off += size; } @@ -151,21 +154,21 @@ fn checkReply(s: *Session, req: filesystem.Req, reply: filesystem.Reply) !void { } } -fn bench(s: *Session, name: []const u8, reps: usize, req: filesystem.Req, note: []const u8) !void { +fn bench(s: *Session, name: []const u8, reps: usize, req: ctlfs.Req, note: []const u8) !void { std.debug.assert(reps > 0); const initial_bytes = s.core.panes[s.file_id].?.file.?.content.len; const initial_hash = if (req.op == .write) std.hash.Wyhash.hash(0, s.core.panes[s.file_id].?.file.?.content) else 0; for (0..64) |_| { - try checkReply(s, req, filesystem.handle(s.core, req)); + try checkReply(s, req, ctlfs.handle(s.core, req)); _ = s.core.scratch.reset(.retain_capacity); } s.counting.allocations = 0; - const expected_status: filesystem.Status = if (req.op == .read and req.node == s.node(.event)) .again else .ok; + const expected_status: ctlfs.Status = if (req.op == .read and req.node == s.node(.event)) .again else .ok; var valid = true; - var reply: filesystem.Reply = undefined; + var reply: ctlfs.Reply = undefined; const start = nowNs(); for (0..reps) |_| { - reply = filesystem.handle(s.core, req); + reply = ctlfs.handle(s.core, req); valid = valid and reply.tag == req.tag and reply.status == expected_status and reply.errno == 0; std.mem.doNotOptimizeAway(reply); _ = s.core.scratch.reset(.retain_capacity); @@ -223,7 +226,7 @@ pub fn main(init: std.process.Init) !void { try bench(&s, "lookup ctl", reps, .{ .tag = 2, .op = .lookup, - .node = filesystem.Node.of(s.file_serial, .dir), + .node = ctlfs.Node.of(s.file_serial, .dir), .data = "ctl", }, "name -> node"); try bench(&s, "read body 4K", reps, .{ @@ -249,13 +252,13 @@ pub fn main(init: std.process.Init) !void { try bench(&s, "read index", reps, .{ .tag = 6, .op = .read, - .node = @intFromEnum(filesystem.SelfFile.index), + .node = @intFromEnum(ctlfs.TopFile.index), .size = 4096, }, "one line per pane"); - try bench(&s, "readdir self", reps, .{ + try bench(&s, "readdir root", reps, .{ .tag = 7, .op = .readdir, - .node = @intFromEnum(filesystem.SelfFile.root), + .node = ctlfs.root, .size = 4096, }, "staged dirents"); try bench(&s, "read event (empty)", reps, .{ diff --git a/test/fs_namespace.zig b/test/fs_namespace.zig index c856148d..8b6f245e 100644 --- a/test/fs_namespace.zig +++ b/test/fs_namespace.zig @@ -13,13 +13,13 @@ test "runtime Mount and Unmount copy command arguments and change Look resolutio try std.testing.expectEqualStrings("peer", p.fs.mounts.items[0].name); try std.testing.expectEqualStrings("/tmp/a socket.sock", p.fs.mounts.items[0].dial); var path: [4096]u8 = undefined; - try std.testing.expectEqualStrings("/n/peer/self/index", filesystem.resolve(p, "/n/peer/self/index", "/", &path).?.path); + try std.testing.expectEqualStrings("/n/peer/index", filesystem.resolve(p, "/n/peer/index", "/", &path).?.path); try std.testing.expect(p.executeBuiltinLine(0, "Mount peer /tmp/other.sock")); try std.testing.expectEqual(@as(usize, 1), p.fs.mounts.items.len); try std.testing.expectEqualStrings("/tmp/a socket.sock", p.fs.mounts.items[0].dial); try std.testing.expect(p.executeBuiltinLine(0, "Unmount peer")); try std.testing.expectEqual(@as(usize, 0), p.fs.mounts.items.len); - try std.testing.expect(filesystem.resolve(p, "/n/peer/self/index", "/", &path) == null); + try std.testing.expect(filesystem.resolve(p, "/n/peer/index", "/", &path) == null); for ([_][]const u8{ "Mount", "Mount name", "Mount os /tmp/peer.sock", "Mount peer tcp!127.0.0.1!0", "Unmount", "Unmount name extra" }) |invalid| { try std.testing.expect(p.executeBuiltinLine(0, invalid)); try std.testing.expectEqual(@as(usize, 0), p.fs.mounts.items.len); @@ -185,6 +185,7 @@ test "filesystem resolves OS first then virtual with explicit mounts and parent const fallback = filesystem.resolve(p, "index", directory, &resolved_buffer) orelse return error.MissingVirtualFallback; try std.testing.expectEqualStrings("/virtual/index", fallback.path); + if (!pardes.memory.limits.embedded_sources) return; for ([_][]const u8{ "src/pardes.zig", "/virtual/src/pardes.zig", "/virtual/src/../src/pardes.zig" }) |word| { const found = filesystem.resolve(p, word, directory, &resolved_buffer) orelse return error.MissingEmbeddedSource; const bytes = try filesystem.read(p, found.path); @@ -235,6 +236,7 @@ test "explicit OS file opens and restores keep their names and request watches" } test "virtual file opens do not request OS watches" { + if (!pardes.memory.limits.embedded_sources) return error.SkipZigTest; const p = try pardes.Pardes.init(std.testing.allocator, .{ .tty_only = true }); defer p.deinit(); while (p.nextEffect()) |_| {} @@ -243,16 +245,16 @@ test "virtual file opens do not request OS watches" { while (p.nextEffect()) |effect| if (effect == .watch) return error.VirtualFileWatch; } -test "Look at the self factory reserves its own pane and failed opens release it" { +test "Look at the clone file reserves its own pane and failed opens release it" { const p = try pardes.Pardes.init(std.testing.allocator, .{ .tty_only = true }); defer p.deinit(); - p.lookAt(0, "/virtual/new/ctl"); + p.lookAt(0, "/virtual/new"); var control_count: usize = 0; var scratch_count: usize = 0; for (p.panes) |slot| { const pane = slot orelse continue; const file = pane.file orelse continue; - if (std.mem.eql(u8, file.path, "/virtual/new/ctl")) control_count += 1; + if (std.mem.eql(u8, file.path, "/virtual/new")) control_count += 1; if (file.output) |output| if (output.from == .cmd and output.from.cmd == .New) { scratch_count += 1; }; diff --git a/test/fs_soak.py b/test/fs_soak.py index 1201fda2..5569a7c7 100644 --- a/test/fs_soak.py +++ b/test/fs_soak.py @@ -56,7 +56,7 @@ def read_fid(client, fid, limit, count): def check_body(client, pane, count=4096): - fid = client.open(f'/self/pane/{pane["serial"]}/body') + fid = client.open(f'/pane/{pane["serial"]}/body') try: actual = read_fid(client, fid, BODY_LIMIT, count) finally: @@ -127,7 +127,7 @@ def run(args): address = unix_address if args.transport == 'tcp': listeners = [line.split('!') for line in - control.read('/self/listeners').decode().splitlines() + control.read('/listeners').decode().splitlines() if line.startswith('tcp!')] assert len(listeners) == 1, listeners transport, host, port = listeners[0] @@ -140,11 +140,12 @@ def run(args): for slot in range(4): body = payload(rng) serial = 1 if slot == 0 else new_pane(client, body) - base = f'/self/pane/{serial}' + base = f'/pane/{serial}' if slot == 0: client.write(base + '/body', body, truncate=True) path = root / f'pane-{slot}-0.zig' - client.write(base + '/ctl', f'name {path}\nput\n'.encode()) + client.write(base + '/name', f'{path}\n'.encode()) + client.write(base + '/ctl', b'exec Save\n') panes.append({'serial': serial, 'body': body, 'path': path, 'variant': 0}) emit(kind='start', seed=args.seed, session_pid=pid, transport=args.transport, host='tty' if args.tty else 'detached', @@ -161,7 +162,7 @@ def run(args): for operation in operations: slot = rng.randrange(len(panes)) pane = panes[slot] - base = f'/self/pane/{pane["serial"]}' + base = f'/pane/{pane["serial"]}' if operation == 'append': addition = payload(rng, min(256, BODY_LIMIT - len(pane['body']))) client.write(base + '/body', addition) @@ -185,7 +186,8 @@ def run(args): elif operation == 'save': pane['variant'] ^= 1 pane['path'] = root / f'pane-{slot}-{pane["variant"]}.zig' - client.write(base + '/ctl', f'name {pane["path"]}\nput\n'.encode()) + client.write(base + '/name', f'{pane["path"]}\n'.encode()) + client.write(base + '/ctl', b'exec Save\n') check_bytes(pane['path'].read_bytes(), pane['body'], 'saved file') check_bytes(client.read('/os' + str(pane['path'])), pane['body'], 'OS mount') elif operation == 'reload': @@ -194,19 +196,20 @@ def run(args): client.write(base + '/ctl', b'get\n') elif operation == 'cycle': old_serial = pane['serial'] - client.write(base + '/ctl', b'delete\n') + client.write(base + '/ctl', b'exec Del\n') pane['body'] = payload(rng) pane['serial'] = new_pane(client, pane['body']) assert pane['serial'] != old_serial - base = f'/self/pane/{pane["serial"]}' - client.write(base + '/ctl', f'name {pane["path"]}\nput\n'.encode()) + base = f'/pane/{pane["serial"]}' + client.write(base + '/name', f'{pane["path"]}\n'.encode()) + client.write(base + '/ctl', b'exec Save\n') elif operation == 'reconnect': client.socket.close() client = Client(address) check_session(client, control, pid) check_body(control, pane) elif operation == 'screen': - frozen = client.open('/self/screen') + frozen = client.open('/screen') try: before = read_fid(client, frozen, SCREEN_LIMIT, 4096) check_screen(before) @@ -217,7 +220,7 @@ def run(args): check_bytes(after, before, 'frozen screen') finally: client.close(frozen) - fresh = client.open('/self/screen') + fresh = client.open('/screen') try: check_screen(read_fid(client, fresh, SCREEN_LIMIT, 4096)) finally: @@ -225,8 +228,8 @@ def run(args): operation_count += 1 check_body(client, pane) expected = {str(pane['serial']) for pane in panes} - assert set(client.list('/self/pane')) == expected - assert set(control.list('/self/pane')) == expected + assert set(client.list('/pane')) == expected + assert set(control.list('/pane')) == expected for pane in panes: check_body(client, pane) check_body(control, pane) diff --git a/test/look_placement.py b/test/look_placement.py index e9918c5d..1341e776 100644 --- a/test/look_placement.py +++ b/test/look_placement.py @@ -70,7 +70,7 @@ def run_case(args, root, source_index): require(len(serials) == 3, 'classic fixture did not boot three terminals') markers = {} for index, serial in enumerate(serials): - pane = f'/self/pane/{serial}' + pane = f'/pane/{serial}' require('pty' in client.list(pane), 'fixture contains an existing document') marker = f'LP_{index}' markers[serial] = marker @@ -89,7 +89,7 @@ def run_case(args, root, source_index): require(before[serials[0]][:2] == (0, 2) and before[serials[1]][0] == 0 and before[serials[1]][1] > 2 and before[serials[2]][:2] == (75, 2), f'unexpected initial classic layout: {before}') - client.write(f'/self/pane/{source}/ctl', f'look {target}\n'.encode()) + client.write(f'/pane/{source}/ctl', f'look {target}\n'.encode()) opened = require(wait_for(lambda: next((serial for serial in panes(client) if serial not in serials), None)), 'Look did not open the first document') @@ -111,9 +111,9 @@ def run_case(args, root, source_index): require(rectangle_text(before_frame, before[serial]) == rectangle_text(after_frame, after[serial]), f'Look changed unrelated terminal {serial} rendered text') - require(client.read(f'/self/pane/{opened}/body') == contents, + require(client.read(f'/pane/{opened}/body') == contents, 'opened document contents differ') - client.write(f'/self/pane/{source}/ctl', f'look {target}:2\n'.encode()) + client.write(f'/pane/{source}/ctl', f'look {target}:2\n'.encode()) require(list(panes(client)) == serials + [opened], 'repeated Look created a duplicate pane') require(wait_for(lambda: geometry(client, markers)[1] == after), 'repeated Look changed layout') diff --git a/test/ninep.py b/test/ninep.py index b128cc8a..6c625951 100644 --- a/test/ninep.py +++ b/test/ninep.py @@ -116,7 +116,44 @@ class Client: self.close(fid) def screen(self): - return json.loads(self.read('/self/screen')) + return json.loads(self.read('/screen')) + + def walk(self, path): + names = [part for part in os.fspath(path).split('/') if part] + self.fid += 1 + fid = self.fid + oldfid = 1 + try: + for start in range(0, max(1, len(names)), 16): + part = names[start:start + 16] + reply = self.rpc(110, struct.pack('16} transport={x:0>16}\n" ++ " got frames={d} images={d} visual={x:0>16} transport={x:0>16}\n", .{ - name, round, want.frames, want.images, - want.visual, want.transport, got.frames, got.images, - got.visual, got.transport, + name, round, want.frames, want.images, + want.visual, want.transport, got.frames, got.images, + got.visual, got.transport, }, ); return error.UnstableIdentity; @@ -569,8 +569,8 @@ fn reportText(config: Config, travel: Travel, results: []const Result) void { std.debug.print( "{s}: {d} pages, {d}px strip at {d}x{d} cells of {d}x{d}px\n", .{ - config.path, travel.pages, travel.strip_px, bench_cols, - bench_rows, bench_cell_pixels.w, bench_cell_pixels.h, + config.path, travel.pages, travel.strip_px, bench_cols, + bench_rows, bench_cell_pixels.w, bench_cell_pixels.h, }, ); std.debug.print( @@ -578,9 +578,9 @@ fn reportText(config: Config, travel: Travel, results: []const Result) void { .{ config.warmup, config.reps }, ); std.debug.print("{s:<16} {s:>6} {s:>7} {s:>10} {s:>10} {s:>10} {s:>10} {s:>10} {s:>11} {s:>7} {s:>5} {s:<16} {s}\n", .{ - "scenario", "frames", "notches", "min", - "median", "p90", "p99", "max", - "total_us", "rasters", "kept", "visual", + "scenario", "frames", "notches", "min", + "median", "p90", "p99", "max", + "total_us", "rasters", "kept", "visual", "transport", }); std.debug.print("{s}\n", .{"-" ** 160}); @@ -618,7 +618,7 @@ fn reportJson(io: std.Io, config: Config, travel: Travel, results: []const Resul "{{\"benchmark\":\"pardes-pdf-scroll\",\"build\":\"{s}\",\"path\":\"{s}\"," ++ "\"pages\":{d},\"strip_px\":{d},\"warmup\":{d},\"reps\":{d},\"results\":[", .{ - bench_config.core_optimize, config.path, travel.pages, + bench_config.core_optimize, config.path, travel.pages, travel.strip_px, config.warmup, config.reps, }, ) catch return; diff --git a/test/snapshot.zig b/test/snapshot.zig index a7a1ba48..7fa84a86 100644 --- a/test/snapshot.zig +++ b/test/snapshot.zig @@ -1151,7 +1151,7 @@ const Screen9p = struct { fn snap9p(arena: std.mem.Allocator, h: *eh.Harness, label: []const u8, prev: *Prev) ![]u8 { var dial_buf: [24]u8 = undefined; const dial = try std.fmt.bufPrint(&dial_buf, "{d}", .{h.pid}); - const bytes = try Client.read(gpa, dial, "/self/screen", "/self/screen"); + const bytes = try Client.read(gpa, dial, "/screen", "/screen"); defer gpa.free(bytes); const parsed = try std.json.parseFromSlice(Screen9p, gpa, bytes, .{}); defer parsed.deinit(); diff --git a/test/tag_cleanup.py b/test/tag_cleanup.py index 52ee8e9d..7b7d8bbf 100644 --- a/test/tag_cleanup.py +++ b/test/tag_cleanup.py @@ -28,7 +28,7 @@ def run(args): launch=launch, inherited=inherited, terminal=terminal) as (client, _): keys = HostInput(terminal['input_fd']) pdf = next(serial for serial, tag in panes(client).items() if str(source) in tag) - pdf_tag = client.read(f'/self/pane/{pdf}/tag').decode().strip() + pdf_tag = client.read(f'/pane/{pdf}/tag').decode().strip() require(pdf_tag.startswith(str(source) + ' [1/'), 'PDF name/page prefix missing') require(pdf_tag.endswith('] Tty Del PdfSections PdfTint Collapse'), 'PDF commands missing') require(all(word not in pdf_tag for word in ['PdfFit', 'filtered', 'full', 'disabled']), 'PDF tag contains fit or tint-state clutter') @@ -36,7 +36,7 @@ def run(args): before = set(panes(client)) execute(client, control, 'Tty') tty = require(wait_for(lambda: next((s for s in panes(client) if s not in before), None)), 'terminal missing') - client.write(f'/self/pane/{control}/ctl', b'delete\n') # owned command-only scratch + client.write(f'/pane/{control}/ctl', b'exec Del\n') # owned command-only scratch def tag_position(): frame = client.screen() @@ -64,11 +64,11 @@ def run(args): keys.send(b'\t') require(wait_for(lambda: (p := tag_position()) and p[2] == ' '), 'Mode from edited tag ignored parked raw mode') keys.send(b'\x02') - client.write(f'/self/pane/{tty}/pty/data', b"printf 'Mode toggle ready\\n'\r") - require(wait_for(lambda: b'Mode toggle ready' in client.read(f'/self/pane/{tty}/body')), 'terminal input failed') + client.write(f'/pane/{tty}/pty/data', b"printf 'Mode toggle ready\\n'\r") + require(wait_for(lambda: b'Mode toggle ready' in client.read(f'/pane/{tty}/body')), 'terminal input failed') capture(client, root, 'pdf-and-tty-tags', not args.tty) require(source.read_bytes() == original, 'PDF file changed') - client.write(f'/self/pane/{tty}/pty/data', b'exit\r') + client.write(f'/pane/{tty}/pty/data', b'exit\r') print('PDF tag, Mode click, Ctrl-B, edited-tag execution and source preservation passed') diff --git a/test/ui_review.py b/test/ui_review.py index df492eac..2b6faa29 100644 --- a/test/ui_review.py +++ b/test/ui_review.py @@ -21,7 +21,7 @@ from fs import session def panes(client): return {int(row.split(maxsplit=5)[0]): row.split(maxsplit=5)[5] - for row in client.read('/self/index').decode().splitlines()} + for row in client.read('/index').decode().splitlines()} def wait_for(fn, seconds=12): deadline = time.monotonic() + seconds @@ -34,7 +34,7 @@ def wait_for(fn, seconds=12): def command(client, serial, text): """Execute a temporary tag command without changing source contents.""" - tag = f'/self/pane/{serial}/tag' + tag = f'/pane/{serial}/tag' before = client.read(tag).rstrip(b'\n') tail_start = before.index(b'Save Tty Del') while tail_start and before[tail_start - 1:tail_start] == b' ': @@ -42,13 +42,13 @@ def command(client, serial, text): client.write(tag, b' ' + text.encode()) current = client.read(tag) start = current.rfind(text.encode()) - client.write(f'/self/pane/{serial}/event', f'Mx{start} {start + len(text.encode())}\n'.encode()) - client.write(f'/self/pane/{serial}/ctl', b'cleartag\n') + client.write(f'/pane/{serial}/event', f'Mx{start} {start + len(text.encode())}\n'.encode()) + client.write(f'/pane/{serial}/ctl', b'cleartag\n') client.write(tag, before[tail_start:]) def new_output(client, before): return next((serial for serial in panes(client) if serial not in before and - client.read(f'/self/pane/{serial}/body').strip()), None) + client.read(f'/pane/{serial}/body').strip()), None) def require(value, description): if not value: @@ -63,7 +63,7 @@ def capture(client, root, label, gui): text = '\n'.join(''.join(cell[0] for cell in screen['cells'][at:at+cols]) for at in range(0, len(screen['cells']), cols)) (root / (label + '.txt')).write_text(text) - (root / (label + '-index.txt')).write_text(client.read('/self/index').decode()) + (root / (label + '-index.txt')).write_text(client.read('/index').decode()) if gui: require(wait_for(lambda: (root / 'latest.ppm').exists(), 8), 'GPU capture missing') def convert_frame(): @@ -106,28 +106,28 @@ def run(args): before = panes(client) command(client, source, 'Find crds_value') find_pane = require(wait_for(lambda: new_output(client, before)), 'Find did not return results') - require(b'crds_value.rs' in client.read(f'/self/pane/{find_pane}/body'), 'Find result missing source') + require(b'crds_value.rs' in client.read(f'/pane/{find_pane}/body'), 'Find result missing source') report['find'] = True capture(client, root, '02-find', not args.tty) if find_pane: - (root / 'find-results.txt').write_bytes(client.read(f'/self/pane/{find_pane}/body')) - client.write(f'/self/pane/{find_pane}/ctl', b'del\n') + (root / 'find-results.txt').write_bytes(client.read(f'/pane/{find_pane}/body')) + client.write(f'/pane/{find_pane}/ctl', b'exec Del\n') before = panes(client) command(client, source, 'Grep CrdsValueLabel') grep_pane = require(wait_for(lambda: new_output(client, before)), 'Grep did not return results') - require(b'CrdsValueLabel' in client.read(f'/self/pane/{grep_pane}/body'), 'Grep result missing match') + require(b'CrdsValueLabel' in client.read(f'/pane/{grep_pane}/body'), 'Grep result missing match') report['grep'] = True if grep_pane: - (root / 'grep-results.txt').write_bytes(client.read(f'/self/pane/{grep_pane}/body')) + (root / 'grep-results.txt').write_bytes(client.read(f'/pane/{grep_pane}/body')) capture(client, root, '03-grep', not args.tty) command(client, source, 'Tty') terminal = require(wait_for(lambda: next((serial for serial in panes(client) - if 'pty' in client.list(f'/self/pane/{serial}')), None)), + if 'pty' in client.list(f'/pane/{serial}')), None)), 'Tty did not create a terminal') if terminal: - client.write(f'/self/pane/{terminal}/pty/data', b"printf '\\033[1;36mAgave workspace\\033[0m\\n'; pwd; printf '\\033[32mRead-only UI review ready\\033[0m\\n'\r") + client.write(f'/pane/{terminal}/pty/data', b"printf '\\033[1;36mAgave workspace\\033[0m\\n'; pwd; printf '\\033[32mRead-only UI review ready\\033[0m\\n'\r") require(wait_for(lambda: b'\nRead-only UI review ready\n' in - client.read(f'/self/pane/{terminal}/body').replace(b'\r', b'')), + client.read(f'/pane/{terminal}/body').replace(b'\r', b'')), 'Terminal command output was not observed') report['terminal'] = True capture(client, root, '04-terminal', not args.tty) @@ -137,46 +137,46 @@ def run(args): symbols = wait_for(lambda: new_output(client, before), args.lsp_wait) report['symbols'] = 'returned results' if symbols else 'no output before deadline' if symbols: - (root / 'symbols-results.txt').write_bytes(client.read(f'/self/pane/{symbols}/body')) + (root / 'symbols-results.txt').write_bytes(client.read(f'/pane/{symbols}/body')) capture(client, root, '05-symbols', not args.tty) if symbols: - client.write(f'/self/pane/{symbols}/ctl', b'del\n') + client.write(f'/pane/{symbols}/ctl', b'exec Del\n') offset = original.index(b'CrdsValue {') - client.write(f'/self/pane/{source}/addr', f'#{offset},#{offset}'.encode()) - client.write(f'/self/pane/{source}/ctl', b'dot=addr\nshow\n') + client.write(f'/pane/{source}/addr', f'#{offset},#{offset}'.encode()) + client.write(f'/pane/{source}/ctl', b'dot=addr\nshow\n') before = panes(client) command(client, source, 'Hover') hover = wait_for(lambda: new_output(client, before), args.lsp_wait) report['hover'] = 'returned results' if hover else 'no output before deadline' if hover: - (root / 'hover-results.txt').write_bytes(client.read(f'/self/pane/{hover}/body')) + (root / 'hover-results.txt').write_bytes(client.read(f'/pane/{hover}/body')) capture(client, root, '06-hover', not args.tty) # Look focuses the source without changing it; gd then travels through # the host's real input parser, unlike tag builtin dispatch above. line = original[:original.index(b'impl Sanitize for CrdsValue')].count(b'\n') + 1 - client.write(f'/self/pane/{source}/ctl', f'look {source_path}:{line}:19\n'.encode()) + client.write(f'/pane/{source}/ctl', f'look {source_path}:{line}:19\n'.encode()) os.write(terminal_handle['input_fd'], b'gd') time.sleep(1) capture(client, root, '07-definition', not args.tty) command(client, source, 'Lspinfo') lsp = wait_for(lambda: next((serial for serial, tag in panes(client).items() if '+Lsp' in tag), None)) if lsp: - info = client.read(f'/self/pane/{lsp}/body') + info = client.read(f'/pane/{lsp}/body') (root / 'lsp-info.txt').write_bytes(info) report['lsp'] = info.decode() capture(client, root, '08-lsp-info', not args.tty) if lsp: - client.write(f'/self/pane/{lsp}/ctl', b'del\n') + client.write(f'/pane/{lsp}/ctl', b'exec Del\n') for theme in args.themes: command(client, source, 'Theme ' + theme) capture(client, root, 'theme-' + theme, not args.tty) for serial, tag in panes(client).items(): if any(word in tag for word in ['+Hover', '+Search']): - (root / f'pane-{serial}.txt').write_bytes(client.read(f'/self/pane/{serial}/body')) - assert client.read(f'/self/pane/{source}/body') == original == source_path.read_bytes() + (root / f'pane-{serial}.txt').write_bytes(client.read(f'/pane/{serial}/body')) + assert client.read(f'/pane/{source}/body') == original == source_path.read_bytes() report['source_unchanged'] = True if terminal: - client.write(f'/self/pane/{terminal}/pty/data', b'exit\r') + client.write(f'/pane/{terminal}/pty/data', b'exit\r') (root / 'report.json').write_text(json.dumps(report, indent=2)) print('artifacts', root, flush=True) diff --git a/test/v9fs.py b/test/v9fs.py index 7dc88195..16916d0b 100644 --- a/test/v9fs.py +++ b/test/v9fs.py @@ -42,25 +42,26 @@ def worker(mountpoint, socket, uid, gid, original_namespace): assert len(mounted) == 1 and ' - 9p ' in mounted[0], mounted assert not any(field.startswith(('shared:', 'master:')) for field in mounted[0].split()[6:]) - assert set(os.listdir(mountpoint)) == {'os', 'self'} - tree = mountpoint / 'self' - assert {'index', 'pane', 'new', 'screen'} <= set(os.listdir(tree)) + tree = mountpoint + assert {'os', 'index', 'pane', 'new', 'ctl', 'log', 'screen', 'README'} <= set(os.listdir(tree)) + assert 'self' not in os.listdir(tree) # A direct connection provides independent evidence for VFS reads/writes. with Client(socket) as client: - assert (tree / 'index').read_bytes() == client.read('/self/index') + assert (tree / 'index').read_bytes() == client.read('/index') assert (tree / 'pane/1/body').read_bytes() == b'initial\n' - before = client.read('/self/index') - subprocess.run(['ls', '-l', str(tree / 'new')], check=True, capture_output=True, timeout=5) - assert {'README', 'ctl', 'body'} <= set(os.listdir(tree / 'new')) - assert (tree / 'new/README').read_bytes() == (tree / 'README').read_bytes() - assert client.read('/self/index') == before, 'browsing created panes' - serial = int((tree / 'new/ctl').read_bytes().split()[0]) - another = int((tree / 'new/ctl').read_bytes().split()[0]) + before = client.read('/index') + subprocess.run(['ls', '-l', str(tree), str(tree / 'pane' / '1')], check=True, capture_output=True, timeout=5) + subprocess.run(['find', str(tree / 'pane'), str(tree / 'new'), '-ls'], check=True, capture_output=True, timeout=5) + assert (tree / 'README').read_bytes() == client.read('/README') + assert (tree / 'new').stat().st_size == 0 + assert client.read('/index') == before, 'browsing created panes' + serial = int((tree / 'new').read_bytes().split()[0]) + another = int((tree / 'new').read_bytes().split()[0]) assert serial != another, 'cached factory reused a pane' - client.write(f'/self/pane/{another}/ctl', b'delete\n') + client.write(f'/pane/{another}/ctl', b'exec Del\n') pane = tree / 'pane' / str(serial) - wire = f'/self/pane/{serial}' + wire = f'/pane/{serial}' assert str(serial) in os.listdir(tree / 'pane') assert serial in [int(row.split()[0]) for row in (tree / 'index').read_bytes().splitlines()] @@ -76,7 +77,7 @@ def worker(mountpoint, socket, uid, gid, original_namespace): assert client.read(wire + '/body') == b'v9fs update\nappended\n' # Exercise an actual shell redirection, including its O_TRUNC open. - subprocess.run(['/bin/sh', '-c', 'printf "name kernel-probe\\n" > "$1/ctl"', + subprocess.run(['/bin/sh', '-c', 'printf "kernel-probe\\n" > "$1/name"', 'v9fs-probe', str(pane)], check=True, timeout=5) tag = client.read(wire + '/tag') assert tag.split(maxsplit=1)[0] == str(socket.parent / 'kernel-probe').encode(), tag @@ -100,7 +101,7 @@ def worker(mountpoint, socket, uid, gid, original_namespace): # Reading OS files through the exported tree does not recurse through # the mount: the core still lives in the supervisor's namespace. assert (mountpoint / 'os' / str(socket.parent).lstrip('/') / 'kernel.txt').read_bytes() == b'initial\n' - write_existing(pane / 'ctl', b'delete\n') + write_existing(pane / 'ctl', b'exec Del\n') assert serial not in [int(row.split()[0]) for row in (tree / 'index').read_bytes().splitlines()] print('v9fs: namespace isolation, privilege drop, inherited mount, directory refresh, ' @@ -154,7 +155,7 @@ def run(binary, helper): print(run_helper(command), end='') assert os.readlink('/proc/self/ns/mnt') == namespace assert list(target.iterdir()) == [], 'mount escaped its private namespace' - assert client.read('/self/pane/1/body') == b'initial\n', 'core stopped serving after probe exit' + assert client.read('/pane/1/body') == b'initial\n', 'core stopped serving after probe exit' print('v9fs: supervisor namespace unchanged and session cleanup passed') diff --git a/test/v9fs_terminal.py b/test/v9fs_terminal.py index cc273a40..b49246d1 100644 --- a/test/v9fs_terminal.py +++ b/test/v9fs_terminal.py @@ -74,7 +74,7 @@ sys.exit(1) execute(client, control, 'Tty9p') until(report_path.exists, 'Tty9p did not reach the sudo stand-in') report = json.loads(report_path.read_text()) - pane = f"/self/pane/{report['pane']}" + pane = f"/pane/{report['pane']}" until(lambda: b'V9FS_AUTH_READY' in client.read(pane + '/body'), 'prompt not visible') assert report['socket'] == str(address) assert report['argv'][:2] == ['-E', '--'], report @@ -85,7 +85,7 @@ sys.exit(1) assert report['path'] == path assert report['shell'] == str(Path(shell).resolve()), report # The detached core remains responsive during authentication. - assert client.read('/self/pane/1/body') == b'initial\n' + assert client.read('/pane/1/body') == b'initial\n' target = Path(report['mount']) assert target.is_dir() and list(target.iterdir()) == [] if interrupted: @@ -100,7 +100,7 @@ sys.exit(1) client.write(pane + '/pty/data', b'printf "OUTER_READY:%s\\n" "$PARDES_PANE"\r') expected = ('OUTER_READY:' + report['pane']).encode() until(lambda: expected in client.read(pane + '/body'), 'original shell did not remain usable') - assert client.read('/self/pane/1/body') == b'initial\n' + assert client.read('/pane/1/body') == b'initial\n' print('Tty9p: shell-first startup, quoted paths, hidden password input, failure recovery and cleanup passed') diff --git a/test/window_opacity.py b/test/window_opacity.py index 8abe8677..b9529373 100644 --- a/test/window_opacity.py +++ b/test/window_opacity.py @@ -49,9 +49,9 @@ def run(args): command(client, source, 'Tty') terminal = require(wait_for(lambda: next((serial for serial in panes(client) if serial not in before), None)), 'terminal missing') - client.write(f'/self/pane/{terminal}/pty/data', + client.write(f'/pane/{terminal}/pty/data', b"PS1='$ '; printf '\\033[2J\\033[H\\033[36mTerminal opacity sample\\033[0m\\n'\r") - require(wait_for(lambda: b'Terminal opacity sample' in client.read(f'/self/pane/{terminal}/body')), + require(wait_for(lambda: b'Terminal opacity sample' in client.read(f'/pane/{terminal}/body')), 'terminal output missing') def output(builtin): @@ -59,8 +59,8 @@ def run(args): command(client, source, builtin) pane = require(wait_for(lambda: next((serial for serial in panes(client) if serial not in before), None)), builtin + ' output missing') - text = client.read(f'/self/pane/{pane}/body').decode() - client.write(f'/self/pane/{pane}/ctl', b'del\n') + text = client.read(f'/pane/{pane}/body').decode() + client.write(f'/pane/{pane}/ctl', b'exec Del\n') return text help_text = output('Help') @@ -208,9 +208,9 @@ def run(args): require(all(int(value) == 0xffffffff for value in multipliers), 'whole-window alpha modifier would fade foreground text') require('WindowOpacity: 100%\n' in output('Config'), '100% opacity not restored') - require(source_path.read_bytes() == original == client.read(f'/self/pane/{source}/body'), + require(source_path.read_bytes() == original == client.read(f'/pane/{source}/body'), 'source contents changed') - client.write(f'/self/pane/{terminal}/pty/data', b'exit\r') + client.write(f'/pane/{terminal}/pty/data', b'exit\r') report.update(source_unchanged=True, core_rgb_and_text_unchanged=True, invalid_value_ignored=True, help_updated=True, restored_opaque=True) (root / 'report.json').write_text(json.dumps(report, indent=2) + '\n') -- cgit v1.3 From 2ce8956c8e9843eba7407ab12593871ee451b991 Mon Sep 17 00:00:00 2001 From: Gabriel Schneider Date: Sun, 20 Sep 2026 00:59:34 -0300 Subject: Use cloud9's file-server engine instead of the private copy src/9p.zig shrinks to an 88-line alias: the engine and the backend contract (Req, Reply/ReplyWith, Op, Status, Attr, E, error strings) now come from cloud9.fs. The editor's limits become cloud9.fs.Options values; the ESP32-P4 board backend drops its own copies of the contract types. No behaviour change; fs-bench still allocates nothing per request. cloud9 re-pinned to the commit that carries the engine. Co-Authored-By: Claude Fable 5.1 --- build.zig.zon | 4 +- docs/cloud9.md | 16 +- docs/fs.md | 14 +- src/9p.zig | 2311 +------------------------------------------------- src/9p_io.zig | 2 +- src/esp32p4_9p.zig | 2 +- src/esp32p4_gpio.zig | 54 +- src/ninep/tree.zig | 102 +-- src/pardes.zig | 2 +- 9 files changed, 91 insertions(+), 2416 deletions(-) (limited to 'src/pardes.zig') diff --git a/build.zig.zon b/build.zig.zon index 79c2a261..5bf0d5dc 100644 --- a/build.zig.zon +++ b/build.zig.zon @@ -9,8 +9,8 @@ // read-only HTTPS URL is what a manifest can carry. Re-pin with // `zig fetch --save=cloud9 git+https://git.sr.ht/~gbrls/cloud9#`. .cloud9 = .{ - .url = "git+https://git.sr.ht/~gbrls/cloud9#ae310a207534b33b7321dd2b9f423a73b1969159", - .hash = "cloud9-0.1.0-yt86qsv9AwAy7XqxowpkCFum_p_xfl4S74L8KIeVz4j9", + .url = "git+https://git.sr.ht/~gbrls/cloud9#65209217b5b68f56bc0bd5bc6c4dce33911ded59", + .hash = "cloud9-0.1.0-yt86qs3eEQDqC8duRUGBEWOLj82-iCpAb_afpu0KPjPB", }, // ZLS as a LIBRARY, not a language server: src/lsp_zls.zig imports the // `zls` module its build.zig publishes and calls the analyser in diff --git a/docs/cloud9.md b/docs/cloud9.md index e18130ef..d31d2cb3 100644 --- a/docs/cloud9.md +++ b/docs/cloud9.md @@ -7,14 +7,18 @@ other dependency; no sibling checkout is required. Re-pin with `zig fetch --save=cloud9 git+https://git.sr.ht/~gbrls/cloud9#`, and swap in `.cloud9 = .{ .path = "../cloud9" }` while editing both packages at once. -`src/9p.zig` remains the adapter between cloud9 requests and Pardes filesystem -operations. Mounting, Unix namespace discovery and permissions, the editor event -loop, connection limits, and exported tree policy remain here. `src/9p_quic.zig` +The file-server engine (fids, jobs, parking, flush, hangup) is cloud9's +`fs.Server`; the control tree in `src/ninep/` is its backend, using cloud9's +`fs.Req`, `fs.Op`, `fs.Status`, `fs.E` and `fs.ReplyWith` (extended with the +editor's reply payload locator). `src/9p.zig` names the editor's and the +board's `fs.Options` and re-exports the wire names the transports use. +Mounting, Unix namespace discovery and permissions, the editor event loop, +connection limits, and exported tree policy remain here. `src/9p_quic.zig` selects the existing `pardes-9p` ALPN for cloud9's optional OpenSSL transport. -The snapshot client and standalone protocol/GPIO tests import the same module. -The separate `05-zig-p4` build also supplies cloud9 for the GPIO firmware entry. +The standalone protocol/GPIO tests import the same module. The separate +`05-zig-p4` build also supplies cloud9 for the GPIO firmware entry. -Run `zig build 9p-test` for the filesystem adapter and +Run `zig build 9p-test` for the engine configurations and `zig build 9p-io-test -Dquic=true` for native transport/client integration. Run cloud9's `zig build test`, `transport-test`, `quic-test -Dquic=true`, `fuzz`, and `differential` steps for the shared implementation. See cloud9's `docs/validation.md` for recorded runs and diff --git a/docs/fs.md b/docs/fs.md index c16f810b..a9293393 100644 --- a/docs/fs.md +++ b/docs/fs.md @@ -137,15 +137,17 @@ Zero-length truncation accepts the accompanying `mtime` hint sent by Linux v9fs; the hint is not stored. Standalone timestamp changes remain refused. The tree lives in `src/ninep/`: `tree.zig` (nodes, lookup, readdir, dispatch, -the backend contract), `pane.zig` (pane files), `ctl.zig`, `addr.zig`, -`pty.zig`, `events.zig` (event and log streams), `screen.zig` and -`sources.zig`. The protocol engine is `src/9p.zig`, the transports -`src/9p_io.zig`; `src/fs.zig` keeps host access, mounts, resolution, find and -grep. +and the editor's reply payload over cloud9's backend contract), `pane.zig` +(pane files), `ctl.zig`, `addr.zig`, `pty.zig`, `events.zig` (event and log +streams), `screen.zig` and `sources.zig`. The protocol engine is cloud9's +`fs.Server`, configured in `src/9p.zig` (the editor's and the board's +capacities); the transports are `src/9p_io.zig`; `src/fs.zig` keeps host +access, mounts, resolution, find and grep. `zig build fs-test` drives real sessions using the independent Python client in `test/ninep.py`; `zig build fs-discovery-test` checks that browsing creates nothing and that `new`, `ctl`, `name`, `sel` and `log` behave. `zig build -9p-test` checks the freestanding wire protocol; `zig build fs-bench` measures +9p-test` checks the two engine configurations' budgets (the engine's own +tests are cloud9's `zig build test`); `zig build fs-bench` measures filesystem transactions in the core. `zig build fs-test quic-test -Dquic=true` also exercises QUIC mounts and I/O. diff --git a/src/9p.zig b/src/9p.zig index 3cffbffc..c0e7f61e 100644 --- a/src/9p.zig +++ b/src/9p.zig @@ -1,8 +1,10 @@ -//! Pardes filesystem adapter. The 9P protocol and transports live in cloud9. -const std = @import("std"); -const assert = std.debug.assert; -const testing = std.testing; +//! The editor's 9P surface. The wire protocol, the client, the transports +//! and the file-server engine (`cloud9.fs.Server`) live in cloud9; this +//! module names the two engine configurations Pardes builds, the editor's +//! and the board's, and re-exports what the transports and firmware use. const cloud9 = @import("cloud9"); +pub const fs = cloud9.fs; +pub const Server = cloud9.fs.Server; pub const Error = cloud9.Error; pub const Type = cloud9.Type; pub const isT = cloud9.isT; @@ -37,2299 +39,50 @@ pub const dmperm = cloud9.dmperm; pub const Client = cloud9.Client; pub const ClientError = cloud9.ClientError; pub const max_tags = cloud9.max_tags; -const totalLen = cloud9.encodedLen; -pub const errmax: usize = 128; +pub const oread = cloud9.oread; +pub const owrite = cloud9.owrite; +pub const ordwr = cloud9.ordwr; +pub const oexec = cloud9.oexec; +pub const otrunc = cloud9.otrunc; +pub const ocexec = cloud9.ocexec; +pub const orclose = cloud9.orclose; +pub const errmax = cloud9.fs.errmax; +pub const errString = cloud9.fs.errString; +pub const msize_min = cloud9.fs.msize_min; + +/// The smallest msize a native listener offers (src/9p_io.zig). pub const min_msize: u32 = 4096; -const sample_qid: Qid = .{ .type = qtdir, .version = 3, .path = 0x0102_0304_0506_0708 }; -const sample_stat: Stat = .{ - .type = 0, - .dev = 0, - .qid = sample_qid, - .mode = dmdir | 0o755, - .atime = 1, - .mtime = 2, - .length = 0, - .name = "body", - .uid = "goblin", - .gid = "goblin", - .muid = "goblin", -}; - -pub const e_unknown_fid = "fid unknown or out of range"; -pub const e_fid_in_use = "fid already in use"; -pub const e_bad_use = "bad use of fid"; -pub const e_bad_offset = "bad offset in directory read"; -pub const e_perm = "permission denied"; -pub const e_not_dir = "not a directory"; -pub const e_already_open = "file already open for I/O"; -pub const e_illegal_name = "illegal name"; -pub const e_too_many_fids = "Too many open files in system"; -pub const e_botch = "protocol botch"; -pub const e_interrupted = "Interrupted system call"; -pub const e_trunc_only = "only support truncation to zero length"; -pub const e_wstat = "wstat prohibited"; -pub const e_again = "Resource temporarily unavailable"; -pub const e_count_small = "Invalid argument"; -pub const e_no_tree = "No such file or directory"; -pub const e_no_auth = "authentication not required"; -pub const e_small_msize = "Invalid argument"; - -pub fn errString(errno: u16) []const u8 { - return switch (errno) { - 1 => "Operation not permitted", // E.PERM, EPERM - 2 => "No such file or directory", // E.NOENT, ENOENT - 5 => "Input/output error", // E.IO, EIO - 12 => "Cannot allocate memory", // E.NOMEM, ENOMEM - 20 => "Not a directory", // E.NOTDIR, ENOTDIR - 22 => "Invalid argument", // E.INVAL, EINVAL - 23 => "Too many open files in system", // E.NFILE, ENFILE - 28 => "No space left on device", // E.NOSPC, ENOSPC - 38 => "Function not implemented", // E.NOSYS, ENOSYS - else => "Input/output error", - }; -} - -pub const oread: u8 = 0; -pub const owrite: u8 = 1; -pub const ordwr: u8 = 2; -pub const oexec: u8 = 3; -pub const otrunc: u8 = 16; -pub const ocexec: u8 = 32; -pub const orclose: u8 = 64; +/// The editor's engine: native fid count, native file names. +pub const editor: cloud9.fs.Options = .{ .fid_capacity = max_fids, .name_capacity = 255 }; +/// The board's engine: the GPIO firmware's budget (src/esp32p4_9p.zig). +pub const board: cloud9.fs.Options = .{ .fid_capacity = board_fids, .name_capacity = board_name_capacity }; pub const max_fids: usize = 256; - pub const board_fids: usize = 32; - -pub const max_slots: usize = 32; - -pub const park_data_max: usize = 128; - pub const board_name_capacity: usize = 28; -const username_capacity: usize = 28; - -pub const msize_min: u32 = header_len + 2 + max_welem * qid_len; - -comptime { - assert(msize_min == 217); - assert(header_len + 2 + stat_fixed + board_name_capacity + 3 * username_capacity <= msize_min); - assert(header_len + 4 + stat_fixed + board_name_capacity + 3 * username_capacity <= msize_min); - assert(username_capacity >= 20); - assert(oread | owrite | ordwr | oexec == 3); - assert(otrunc | ocexec | orclose == 112); -} - -fn qidOf(node: u64, dir: bool) Qid { - return .{ .type = if (dir) qtdir else qtfile, .version = 0, .path = node }; -} - -pub const dirent_dir_perm: u16 = 0o500; -pub const dirent_file_perm: u16 = 0o600; - -pub fn Server(comptime fs: type, comptime fid_capacity: usize) type { - if (fid_capacity == 0) @compileError("9P server needs at least one fid"); - const name_capacity = if (@hasDecl(fs, "name_capacity")) fs.name_capacity else board_name_capacity; - if (name_capacity == 0 or name_capacity > 255) @compileError("9P backend name capacity must fit a directory entry"); - return struct { - const Self = @This(); - - protocol: cloud9.Server, - root: u64, - - uname: [username_capacity]u8 = @splat(0), - uname_len: u8 = 0, - - fids: [fid_capacity]Fid = @splat(.{}), - slots: [max_slots]Slot = @splat(.{}), - job: Job = .{}, - seq: u64 = 0, - - const Kind = enum { none, attach, walk, open, read, readdir, write, clunk, remove, stat, wstat }; - - const Fid = struct { - used: bool = false, - fid: u32 = 0, - node: u64 = 0, - dir: bool = false, - perm: u16 = 0, - open: bool = false, - omode: u8 = 0, - handle: u32 = 0, - diroff: u64 = 0, - dirindex: u32 = 0, - orphan: bool = false, - name: [name_capacity]u8 = @splat(0), - name_len: u8 = 0, - }; - - const Slot = struct { - used: bool = false, - parked: bool = false, - retried: bool = false, - copied: bool = false, - seq: u64 = 0, - tag: u16 = 0, - kind: Kind = .none, - fid: u32 = 0, - count: u32 = 0, - req: fs.Req = undefined, - data: [park_data_max]u8 = undefined, - }; - - const Job = struct { - kind: Kind = .none, - tag: u16 = 0, - req_tag: u64 = 0, - req: fs.Req = undefined, - step: u8 = 0, - fid: u32 = 0, - newfid: u32 = 0, - count: u32 = 0, - offset: u64 = 0, - omode: u8 = 0, - node: u64 = 0, - dir: bool = false, - perm: u16 = 0, - name: [name_capacity]u8 = @splat(0), - name_len: u8 = 0, - nwname: u8 = 0, - nwqid: u8 = 0, - wqid: [max_welem]Qid = @splat(.{ .type = 0, .version = 0, .path = 0 }), - msg: Msg = .rflush, - }; - - pub const Options = struct { - in: []u8, - out: []u8, - root: u64, - }; - - pub fn init(opts: Options) Self { - assert(opts.in.len >= msize_min); - assert(opts.out.len >= 2 * msize_min); - assert(opts.root != 0); - return .{ .protocol = .init(.{ .in = opts.in, .out = opts.out }), .root = opts.root }; - } - - pub fn references(s: *const Self, node: u64) bool { - for (s.fids) |fid| if (fid.used and fid.node == node) return true; - if (s.job.kind != .none and s.job.node == node) return true; - for (s.slots) |slot| if (slot.used and slot.req.node == node) return true; - return false; - } - - pub fn hangup(s: *Self) void { - s.reset(); - s.protocol.hangup(); - } - - fn reset(s: *Self) void { - for (&s.fids) |*f| { - if (!f.used) continue; - if (f.open) f.orphan = true else f.* = .{}; - } - for (&s.slots) |*sl| sl.* = .{}; - s.job = .{}; - } - - pub fn push(s: *Self, bytes: []const u8) usize { - return s.protocol.push(bytes); - } - - pub fn output(s: *const Self) []const u8 { - return s.protocol.output(); - } - - pub fn wrote(s: *Self, n: usize) void { - s.protocol.wrote(n); - } - - fn hasRoom(s: *Self) bool { - return s.protocol.hasRoom(); - } - - fn emit(s: *Self, tag: u16, msg: Msg) void { - s.protocol.reply(tag, msg) catch { - s.protocol.dead = true; - }; - } - - fn fail(s: *Self, tag: u16, ename: []const u8) void { - assert(ename.len <= errmax); - s.emit(tag, .{ .rerror = .{ .ename = ename } }); - } - - fn tick(s: *Self) u64 { - s.seq += 1; - return s.seq; - } - - fn findFid(s: *Self, fid: u32) ?usize { - for (&s.fids, 0..) |*f, i| if (f.used and !f.orphan and f.fid == fid) return i; - return null; - } - - fn freeFid(s: *Self) ?usize { - for (&s.fids, 0..) |*f, i| if (!f.used) return i; - return null; - } - - fn dropFid(s: *Self, fid: u32) void { - if (s.findFid(fid)) |i| s.fids[i] = .{}; - } - - fn findSlot(s: *Self, req_tag: u64) ?usize { - for (&s.slots, 0..) |*sl, i| if (sl.used and sl.req.tag == req_tag) return i; - return null; - } - - fn freeSlot(s: *Self) ?usize { - for (&s.slots, 0..) |*sl, i| if (!sl.used) return i; - return null; - } - - fn findTag(s: *Self, tag: u16) ?usize { - for (&s.slots, 0..) |*sl, i| if (sl.used and sl.tag == tag) return i; - return null; - } - - fn setUname(s: *Self, uname: []const u8) void { - const n = @min(uname.len, username_capacity); - @memcpy(s.uname[0..n], uname[0..n]); - s.uname_len = @intCast(n); - } - - pub fn retry(s: *Self) ?fs.Req { - var best: ?usize = null; - for (&s.slots, 0..) |*sl, i| { - if (!sl.used or !sl.parked or sl.retried) continue; - if (best == null or sl.seq < s.slots[best.?].seq) best = i; - } - const i = best orelse { - for (&s.slots) |*sl| sl.retried = false; - return null; - }; - if (!s.hasRoom()) { - for (&s.slots) |*sl| sl.retried = false; - return null; - } - s.slots[i].retried = true; - s.slots[i].parked = false; - return s.slots[i].req; - } - - pub fn next(s: *Self) ?fs.Req { - while (true) { - if (s.job.kind != .none) { - if (s.job.req_tag != 0) return null; - if (s.stepJob()) |req| return req; - assert(s.job.kind == .none); - continue; - } - if (s.orphan()) |req| return req; - if (!s.hasRoom()) return null; - if (!s.startFrame()) return null; - } - } - - pub fn reply(s: *Self, r: *const fs.Reply, bytes: []const u8) void { - if (s.job.kind != .none and s.job.req_tag == r.tag) return s.jobReply(r, bytes); - if (s.findSlot(r.tag)) |i| return s.slotReply(i, r, bytes); - } - - fn orphan(s: *Self) ?fs.Req { - for (&s.fids) |*f| { - if (!f.used or !f.orphan) continue; - assert(f.open); - const req: fs.Req = .{ - .tag = s.tick(), - .op = .release, - .node = f.node, - .handle = f.handle, - }; - f.* = .{}; - return req; - } - return null; - } - - fn startFrame(s: *Self) bool { - assert(s.job.kind == .none); - const got = (s.protocol.receive() catch return false) orelse return false; - defer if (s.job.kind == .none) s.dropFrame(); - s.dispatch(got); - return true; - } - - fn dropFrame(s: *Self) void { - s.protocol.release(); - } - - fn dispatch(s: *Self, got: Decoded) void { - switch (got.msg) { - .tversion => |m| s.version(got.tag, m.msize, m.version), - .tauth => s.fail(got.tag, e_no_auth), - .tcreate => s.fail(got.tag, e_perm), - .tattach => |m| s.attach(got.tag, m.fid, m.uname, m.aname), - .tflush => |m| s.flush(got.tag, m.oldtag), - .twalk => |m| s.walk(got, m.fid, m.newfid, @intCast(m.nwname)), - .topen => |m| s.open(got.tag, m.fid, m.mode), - .tread => |m| s.read(got.tag, m.fid, m.offset, m.count), - .twrite => |m| s.write(got, m.fid, m.offset, m.data.len), - .tclunk => |m| s.clunk(got.tag, m.fid, .clunk), - .tremove => |m| s.clunk(got.tag, m.fid, .remove), - .tstat => |m| s.stat(got.tag, m.fid), - .twstat => |m| s.wstat(got.tag, m.fid, m.stat), - else => s.fail(got.tag, e_botch), - } - } - - fn version(s: *Self, tag: u16, want: u32, ver: []const u8) void { - assert(tag == notag); - s.reset(); - // The adapter's fixed directory staging requires this capacity. - if (want < msize_min) { - s.protocol.dead = true; - return; - } - s.protocol.negotiate(want, ver) catch { - s.protocol.dead = true; - }; - } - - fn attach(s: *Self, tag: u16, fid: u32, uname: []const u8, aname: []const u8) void { - if (aname.len != 0) return s.fail(tag, e_no_tree); - if (fid == nofid) return s.fail(tag, e_unknown_fid); - if (s.findFid(fid) != null) return s.fail(tag, e_fid_in_use); - if (s.freeFid() == null) return s.fail(tag, e_too_many_fids); - s.setUname(uname); - s.job = .{ .kind = .attach, .tag = tag, .fid = fid, .node = s.root }; - } - - fn walk(s: *Self, got: Decoded, fid: u32, newfid: u32, nwname: u8) void { - const tag = got.tag; - const i = s.findFid(fid) orelse return s.fail(tag, e_unknown_fid); - if (s.fids[i].open) return s.fail(tag, e_bad_use); - if (newfid == nofid) return s.fail(tag, e_unknown_fid); - if (newfid != fid) { - if (s.findFid(newfid) != null) return s.fail(tag, e_fid_in_use); - if (s.freeFid() == null) return s.fail(tag, e_too_many_fids); - } - if (nwname == 0) { - if (newfid != fid) { - const j = s.freeFid().?; - s.fids[j] = s.fids[i]; - s.fids[j].fid = newfid; - s.fids[j].diroff = 0; - s.fids[j].dirindex = 0; - } - s.emit(tag, .{ .rwalk = .{ .nwqid = 0 } }); - return; - } - if (!s.fids[i].dir) return s.fail(tag, e_not_dir); - s.job = .{ - .kind = .walk, - .tag = tag, - .fid = fid, - .newfid = newfid, - .nwname = nwname, - .node = s.fids[i].node, - .dir = s.fids[i].dir, - .perm = s.fids[i].perm, - .name = s.fids[i].name, - .name_len = s.fids[i].name_len, - .msg = got.msg, - }; - } - - fn open(s: *Self, tag: u16, fid: u32, mode: u8) void { - const i = s.findFid(fid) orelse return s.fail(tag, e_unknown_fid); - const f = &s.fids[i]; - if (f.open) return s.fail(tag, e_already_open); - if (mode & orclose != 0) return s.fail(tag, e_perm); - const rw = mode & 3; - if (rw == oexec) return s.fail(tag, e_perm); - if (f.dir and (rw != oread or mode & otrunc != 0)) return s.fail(tag, e_perm); - var need: u16 = 0; - if (rw == oread or rw == ordwr) need |= 0o400; - if (rw == owrite or rw == ordwr or mode & otrunc != 0) need |= 0o200; - if (f.perm & need != need) return s.fail(tag, e_perm); - s.job = .{ .kind = .open, .tag = tag, .fid = fid, .omode = mode }; - } - - fn read(s: *Self, tag: u16, fid: u32, offset: u64, count: u32) void { - const i = s.findFid(fid) orelse return s.fail(tag, e_unknown_fid); - const f = &s.fids[i]; - if (!f.open or (f.omode & 3) == owrite) return s.fail(tag, e_bad_use); - const want = @min(count, s.protocol.msize - header_len - 4); - if (!f.dir) { - s.job = .{ .kind = .read, .tag = tag, .fid = fid, .offset = offset, .count = want }; - return; - } - if (offset != f.diroff) { - if (offset != 0) return s.fail(tag, e_bad_offset); - f.diroff = 0; - f.dirindex = 0; - } - s.job = .{ .kind = .readdir, .tag = tag, .fid = fid, .offset = offset, .count = want }; - } - - fn write(s: *Self, got: Decoded, fid: u32, offset: u64, len: usize) void { - const tag = got.tag; - const i = s.findFid(fid) orelse return s.fail(tag, e_unknown_fid); - const f = &s.fids[i]; - if (!f.open or (f.omode & 3) == oread) return s.fail(tag, e_bad_use); - s.job = .{ - .kind = .write, - .tag = tag, - .fid = fid, - .offset = offset, - .count = @intCast(len), - .msg = got.msg, - }; - } - - fn clunk(s: *Self, tag: u16, fid: u32, kind: Kind) void { - assert(kind == .clunk or kind == .remove); - const i = s.findFid(fid) orelse return s.fail(tag, e_unknown_fid); - if (s.fids[i].open) { - s.job = .{ .kind = kind, .tag = tag, .fid = fid }; - return; - } - s.fids[i] = .{}; - if (kind == .remove) s.fail(tag, e_perm) else s.emit(tag, .rclunk); - } - - fn stat(s: *Self, tag: u16, fid: u32) void { - if (s.findFid(fid) == null) return s.fail(tag, e_unknown_fid); - s.job = .{ .kind = .stat, .tag = tag, .fid = fid }; - } - - fn wstat(s: *Self, tag: u16, fid: u32, st: Stat) void { - if (s.findFid(fid) == null) return s.fail(tag, e_unknown_fid); - if (st.type != std.math.maxInt(u16) or st.dev != std.math.maxInt(u32) or - st.qid.type != std.math.maxInt(u8) or st.qid.version != std.math.maxInt(u32) or - st.qid.path != std.math.maxInt(u64) or st.mode != std.math.maxInt(u32) or - st.atime != std.math.maxInt(u32) or - // Linux v9fs follows O_TRUNC with Twstat(length=0, mtime=now). - // Accept that timestamp hint with truncation; this control - // filesystem does not persist caller-selected timestamps. - (st.mtime != std.math.maxInt(u32) and st.length != 0) or - st.name.len != 0 or st.uid.len != 0 or st.gid.len != 0 or st.muid.len != 0) - return s.fail(tag, e_wstat); - if (st.length == std.math.maxInt(u64)) { - s.emit(tag, .rwstat); - return; - } - if (st.length != 0) return s.fail(tag, e_trunc_only); - s.job = .{ .kind = .wstat, .tag = tag, .fid = fid }; - } - - fn flush(s: *Self, tag: u16, oldtag: u16) void { - if (s.findTag(oldtag)) |i| { - s.fail(s.slots[i].tag, e_interrupted); - s.slots[i] = .{}; - } - s.emit(tag, .rflush); - } - - fn ask(s: *Self, req: fs.Req) fs.Req { - assert(req.tag != 0); - s.job.req = req; - s.job.req_tag = req.tag; - return req; - } - - fn jobFid(s: *Self) ?*Fid { - const i = s.findFid(s.job.fid) orelse { - s.fail(s.job.tag, e_unknown_fid); - s.finishJob(); - return null; - }; - return &s.fids[i]; - } - - fn stepJob(s: *Self) ?fs.Req { - const j = &s.job; - assert(j.kind != .none); - assert(j.req_tag == 0); - switch (j.kind) { - .none => unreachable, - .attach => return s.ask(.{ .tag = s.tick(), .op = .getattr, .node = s.root }), - .walk => return s.stepWalk(), - .open => { - const f = s.jobFid() orelse return null; - if (j.step == 0 and j.omode & otrunc != 0) return s.ask(.{ - .tag = s.tick(), - .op = .setattr, - .node = f.node, - .truncate = true, - }); - return s.ask(.{ .tag = s.tick(), .op = .open, .node = f.node }); - }, - .read => { - const f = s.jobFid() orelse return null; - return s.ask(.{ - .tag = s.tick(), - .op = .read, - .node = f.node, - .handle = f.handle, - .off = j.offset, - .size = j.count, - }); - }, - .readdir => { - const f = s.jobFid() orelse return null; - return s.ask(.{ - .tag = s.tick(), - .op = .readdir, - .node = f.node, - .handle = f.handle, - .off = f.dirindex, - .size = j.count, - }); - }, - .write => { - const f = s.jobFid() orelse return null; - return s.ask(.{ - .tag = s.tick(), - .op = .write, - .node = f.node, - .handle = f.handle, - .off = j.offset, - .size = j.count, - .data = j.msg.twrite.data, - }); - }, - .clunk, .remove => { - const f = s.jobFid() orelse return null; - return s.ask(.{ - .tag = s.tick(), - .op = .release, - .node = f.node, - .handle = f.handle, - }); - }, - .stat => { - const f = s.jobFid() orelse return null; - return s.ask(.{ .tag = s.tick(), .op = .getattr, .node = f.node }); - }, - .wstat => { - const f = s.jobFid() orelse return null; - return s.ask(.{ .tag = s.tick(), .op = .setattr, .node = f.node, .truncate = true }); - }, - } - } - - fn stepWalk(s: *Self) ?fs.Req { - const j = &s.job; - while (j.step < j.nwname) { - const name = j.msg.twalk.wname[j.step]; - if (name.len > name_capacity) { - s.stopWalk(e_illegal_name); - return null; - } - if (std.mem.eql(u8, name, ".")) { - j.wqid[j.nwqid] = qidOf(j.node, j.dir); - j.nwqid += 1; - j.step += 1; - continue; - } - @memcpy(j.name[0..name.len], name); - j.name_len = @intCast(name.len); - return s.ask(.{ .tag = s.tick(), .op = .lookup, .node = j.node, .data = name }); - } - const dst = pick: { - if (j.newfid == j.fid) break :pick s.findFid(j.fid) orelse { - s.fail(j.tag, e_unknown_fid); - s.finishJob(); - return null; - }; - break :pick s.freeFid() orelse { - s.fail(j.tag, e_too_many_fids); - s.finishJob(); - return null; - }; - }; - s.fids[dst] = .{ - .used = true, - .fid = j.newfid, - .node = j.node, - .dir = j.dir, - .perm = j.perm, - .name = j.name, - .name_len = j.name_len, - }; - s.emit(j.tag, .{ .rwalk = .{ .nwqid = j.nwqid, .wqid = j.wqid } }); - s.finishJob(); - return null; - } - - fn stopWalk(s: *Self, ename: []const u8) void { - const j = &s.job; - if (j.nwqid == 0) - s.fail(j.tag, ename) - else - s.emit(j.tag, .{ .rwalk = .{ .nwqid = j.nwqid, .wqid = j.wqid } }); - s.finishJob(); - } - - fn finishJob(s: *Self) void { - s.job = .{}; - if (s.protocol.frame != 0) s.dropFrame(); - } - - fn jobReply(s: *Self, r: *const fs.Reply, bytes: []const u8) void { - const j = &s.job; - assert(j.kind != .none); - assert(j.req_tag == r.tag); - j.req_tag = 0; - - if (j.kind == .clunk or j.kind == .remove) { - s.dropFid(j.fid); - if (j.kind == .remove) s.fail(j.tag, e_perm) else s.emit(j.tag, .rclunk); - s.finishJob(); - return; - } - if (r.status == .again) return s.parkJob(); - if (r.status == .err) { - const ename = errString(r.errno); - if (j.kind == .walk) return s.stopWalk(ename); - s.fail(j.tag, ename); - s.finishJob(); - return; - } - - switch (j.kind) { - .none, .clunk, .remove => unreachable, - .attach => { - const i = s.freeFid() orelse { - s.fail(j.tag, e_too_many_fids); - s.finishJob(); - return; - }; - const node = if (r.attr.node != 0) r.attr.node else s.root; - s.fids[i] = .{ - .used = true, - .fid = j.fid, - .node = node, - .dir = r.attr.dir, - .perm = r.attr.mode, - }; - s.fids[i].name[0] = '/'; - s.fids[i].name_len = 1; - s.emit(j.tag, .{ .rattach = .{ .qid = qidOf(node, r.attr.dir) } }); - s.finishJob(); - }, - .walk => { - if (r.attr.node != 0) j.node = r.attr.node; - if (comptime @hasField(@TypeOf(r.attr), "name")) { - if (r.attr.name.len != 0) { - j.name_len = @intCast(@min(r.attr.name.len, j.name.len)); - @memcpy(j.name[0..j.name_len], r.attr.name[0..j.name_len]); - } - } - j.dir = r.attr.dir; - j.perm = r.attr.mode; - j.wqid[j.nwqid] = qidOf(j.node, j.dir); - j.nwqid += 1; - j.step += 1; - }, - .open => { - if (j.step == 0 and j.omode & otrunc != 0) { - j.step = 1; - return; - } - const f = s.jobFid() orelse return; - if (r.attr.node != 0) f.node = r.attr.node; - f.open = true; - f.omode = j.omode; - f.handle = r.handle; - f.diroff = 0; - f.dirindex = 0; - s.emit(j.tag, .{ .ropen = .{ - .qid = qidOf(f.node, f.dir), - .iounit = s.protocol.msize - iohdrsz, - } }); - s.finishJob(); - }, - .read => { - s.emit(j.tag, .{ .rread = .{ .data = bytes[0..@min(bytes.len, j.count)] } }); - s.finishJob(); - }, - .readdir => { - s.emitDirRead(j.tag, j.fid, bytes, j.count); - s.finishJob(); - }, - .write => { - s.emit(j.tag, .{ .rwrite = .{ .count = @min(r.written, j.count) } }); - s.finishJob(); - }, - .stat => { - const f = s.jobFid() orelse return; - f.perm = r.attr.mode; - f.dir = r.attr.dir; - const response: Msg = .{ .rstat = .{ .stat = s.statOf(f, r.attr) } }; - if ((totalLen(response) catch unreachable) > s.protocol.msize) - s.fail(j.tag, e_small_msize) - else - s.emit(j.tag, response); - s.finishJob(); - }, - .wstat => { - s.emit(j.tag, .rwstat); - s.finishJob(); - }, - } - } - fn parkJob(s: *Self) void { - const j = &s.job; - switch (j.kind) { - .read, .readdir, .write => {}, - else => { - s.fail(j.tag, e_again); - s.finishJob(); - return; - }, - } - const i = s.freeSlot() orelse { - s.fail(j.tag, e_again); - s.finishJob(); - return; - }; - const sl = &s.slots[i]; - sl.* = .{ - .used = true, - .parked = true, - .seq = s.tick(), - .tag = j.tag, - .kind = j.kind, - .fid = j.fid, - .count = j.count, - .req = j.req, - }; - if (j.req.data.len != 0) { - if (j.req.data.len > park_data_max) { - sl.* = .{}; - s.fail(j.tag, e_again); - s.finishJob(); - return; - } - @memcpy(sl.data[0..j.req.data.len], j.req.data); - sl.copied = true; - sl.req.data = sl.data[0..j.req.data.len]; - } - s.finishJob(); - } - - fn slotReply(s: *Self, i: usize, r: *const fs.Reply, bytes: []const u8) void { - const sl = &s.slots[i]; - if (r.status == .again) { - sl.parked = true; - return; - } - if (r.status == .err) { - s.fail(sl.tag, errString(r.errno)); - sl.* = .{}; - return; - } - switch (sl.kind) { - .read => s.emit(sl.tag, .{ .rread = .{ .data = bytes[0..@min(bytes.len, sl.count)] } }), - .readdir => s.emitDirRead(sl.tag, sl.fid, bytes, sl.count), - .write => s.emit(sl.tag, .{ .rwrite = .{ .count = @min(r.written, sl.count) } }), - else => s.fail(sl.tag, e_botch), - } - sl.* = .{}; - } - - fn emitDirRead(s: *Self, tag: u16, fid: u32, staging: []const u8, count: u32) void { - const buf = s.protocol.out[s.protocol.out_len..]; - assert(buf.len > header_len + 4); - const cap = @min(@as(usize, count), buf.len - header_len - 4); - const who = s.uname[0..s.uname_len]; - var n: usize = header_len + 4; - var entries: u32 = 0; - var i: usize = 0; - while (i + 10 <= staging.len) { - const nlen: usize = staging[i + 9]; - if (i + 10 + nlen > staging.len) break; - const dir = staging[i + 8] != 0; - const rec: Stat = .{ - .type = 0, - .dev = 0, - .qid = qidOf(std.mem.readInt(u64, staging[i..][0..8], .little), dir), - .mode = (if (dir) dmdir else 0) | @as(u32, if (dir) dirent_dir_perm else dirent_file_perm), - .atime = 0, - .mtime = 0, - .length = 0, - .name = staging[i + 10 ..][0..nlen], - .uid = who, - .gid = who, - .muid = who, - }; - const size = @as(usize, rec.size() catch break) + 2; - if (n - header_len - 4 + size > cap) break; - _ = rec.encode(buf[n..]) catch break; - n += size; - entries += 1; - i += 10 + nlen; - } - if (entries == 0 and staging.len != 0) return s.fail(tag, e_count_small); - const payload: u32 = @intCast(n - header_len - 4); - comptime assert(header_len == 7); - s.emit(tag, .{ .rread = .{ .data = buf[header_len + 4 .. n] } }); - if (s.findFid(fid)) |k| { - s.fids[k].diroff += payload; - s.fids[k].dirindex += entries; - } - } - - fn statOf(s: *const Self, f: *const Fid, a: fs.Reply.Attr) Stat { - const who = s.uname[0..s.uname_len]; - return .{ - .type = 0, - .dev = 0, - .qid = qidOf(if (a.node != 0) a.node else f.node, a.dir), - .mode = (if (a.dir) dmdir else 0) | @as(u32, a.mode), - .atime = 0, - .mtime = if (@hasField(@TypeOf(a), "mtime")) a.mtime else 0, - .length = a.size, - .name = f.name[0..f.name_len], - .uid = who, - .gid = who, - .muid = who, - }; - } - }; -} - -const StubFs = struct { - pub const Op = enum(u8) { lookup, getattr, setattr, open, read, write, release, readdir }; - pub const Status = enum(u8) { ok, again, err }; - - pub const Req = struct { - tag: u64, - op: Op, - node: u64, - handle: u32 = 0, - off: u64 = 0, - size: u32 = 0, - data: []const u8 = &.{}, - truncate: bool = false, - }; - - pub const Reply = struct { - tag: u64, - status: Status = .ok, - errno: u16 = 0, - attr: Attr = .{}, - handle: u32 = 0, - written: u32 = 0, - - pub const Attr = struct { - name: []const u8 = "", - node: u64 = 0, - dir: bool = false, - size: u64 = 0, - mode: u16 = 0o600, - }; - }; - - const Entry = struct { node: u64, parent: u64, name: []const u8, dir: bool, mode: u16 }; - - const tree = [_]Entry{ - .{ .node = 1, .parent = 1, .name = "/", .dir = true, .mode = 0o500 }, - .{ .node = 2, .parent = 1, .name = "index", .dir = false, .mode = 0o400 }, - .{ .node = 3, .parent = 1, .name = "cons", .dir = false, .mode = 0o200 }, - .{ .node = 4, .parent = 1, .name = "new", .dir = true, .mode = 0o500 }, - .{ .node = 16, .parent = 1, .name = "1", .dir = true, .mode = 0o500 }, - .{ .node = 32, .parent = 1, .name = "2", .dir = true, .mode = 0o500 }, - .{ .node = 17, .parent = 16, .name = "addr", .dir = false, .mode = 0o600 }, - .{ .node = 18, .parent = 16, .name = "body", .dir = false, .mode = 0o600 }, - .{ .node = 19, .parent = 16, .name = "ctl", .dir = false, .mode = 0o600 }, - .{ .node = 21, .parent = 16, .name = "errors", .dir = false, .mode = 0o200 }, - .{ .node = 22, .parent = 16, .name = "event", .dir = false, .mode = 0o600 }, - .{ .node = 23, .parent = 16, .name = "tag", .dir = false, .mode = 0o600 }, - }; - - const body_node = 18; - const index_node = 2; - const event_node = 22; - - body: []const u8 = "hello, body\n", - filler: [1024]u8 = @splat('x'), - event: ?[]const u8 = null, - park_writes: bool = false, - releases: u32 = 0, - calls: u32 = 0, - writes: [128]u8 = undefined, - writes_len: usize = 0, - stage: [1024]u8 = undefined, - - const Answer = struct { reply: Reply, bytes: []const u8 = "" }; - - fn find(node: u64) ?usize { - for (tree, 0..) |e, i| if (e.node == node) return i; - return null; - } - - fn sizeOf(st: *const StubFs, node: u64) u64 { - return switch (node) { - body_node => st.body.len, - index_node => st.filler.len, - else => 0, - }; - } - - fn contentOf(st: *const StubFs, node: u64) []const u8 { - return switch (node) { - body_node => st.body, - index_node => &st.filler, - else => "", - }; - } - - fn attrOf(st: *const StubFs, e: Entry) Reply.Attr { - return .{ .name = e.name, .node = e.node, .dir = e.dir, .mode = e.mode, .size = st.sizeOf(e.node) }; - } - - fn stageDir(st: *StubFs, node: u64, skip: u64) []const u8 { - var n: usize = 0; - var seen: u64 = 0; - for (tree) |e| { - if (e.parent != node or e.node == node) continue; - if (seen < skip) { - seen += 1; - continue; - } - std.mem.writeInt(u64, st.stage[n..][0..8], e.node, .little); - st.stage[n + 8] = @intFromBool(e.dir); - st.stage[n + 9] = @intCast(e.name.len); - @memcpy(st.stage[n + 10 ..][0..e.name.len], e.name); - n += 10 + e.name.len; - } - return st.stage[0..n]; - } - - fn handle(st: *StubFs, req: Req) Answer { - st.calls += 1; - const fail: Answer = .{ .reply = .{ .tag = req.tag, .status = .err, .errno = 2 } }; - const i = find(req.node) orelse return fail; - switch (req.op) { - .lookup => { - if (std.mem.eql(u8, req.data, "..")) - return .{ .reply = .{ .tag = req.tag, .attr = st.attrOf(tree[find(tree[i].parent).?]) } }; - for (tree) |e| { - if (e.parent != req.node or e.node == req.node) continue; - if (!std.mem.eql(u8, e.name, req.data)) continue; - return .{ .reply = .{ .tag = req.tag, .attr = st.attrOf(e) } }; - } - return fail; - }, - .getattr => return .{ .reply = .{ .tag = req.tag, .attr = st.attrOf(tree[i]) } }, - .setattr => { - if (req.truncate and req.node == body_node) st.body = ""; - return .{ .reply = .{ .tag = req.tag, .attr = st.attrOf(tree[i]) } }; - }, - .open => return .{ .reply = .{ .tag = req.tag, .handle = 7 } }, - .release => { - st.releases += 1; - return .{ .reply = .{ .tag = req.tag } }; - }, - .readdir => { - if (!tree[i].dir) return .{ .reply = .{ .tag = req.tag, .status = .err, .errno = 20 } }; - return .{ .reply = .{ .tag = req.tag }, .bytes = st.stageDir(req.node, req.off) }; - }, - .read => { - if (req.node == event_node) { - const rec = st.event orelse return .{ .reply = .{ .tag = req.tag, .status = .again } }; - st.event = null; - return .{ .reply = .{ .tag = req.tag }, .bytes = rec }; - } - const all = st.contentOf(req.node); - if (req.off >= all.len) return .{ .reply = .{ .tag = req.tag } }; - const from = all[@intCast(req.off)..]; - return .{ .reply = .{ .tag = req.tag }, .bytes = from[0..@min(from.len, req.size)] }; - }, - .write => { - if (st.park_writes) return .{ .reply = .{ .tag = req.tag, .status = .again } }; - const n = @min(req.data.len, st.writes.len - st.writes_len); - @memcpy(st.writes[st.writes_len..][0..n], req.data[0..n]); - st.writes_len += n; - return .{ .reply = .{ .tag = req.tag, .written = @intCast(n) } }; - }, - } - } -}; - -const Srv = Server(StubFs, max_fids); - -const Harness = struct { - in: [4096]u8 = undefined, - out: [8192]u8 = undefined, - fsys: StubFs = .{}, - srv: Srv = undefined, - - fn start(h: *Harness) void { - h.srv = Srv.init(.{ .in = &h.in, .out = &h.out, .root = 1 }); - } - - fn answer(h: *Harness, req: StubFs.Req) void { - const a = h.fsys.handle(req); - h.srv.reply(&a.reply, a.bytes); - } - - fn pump(h: *Harness) void { - while (h.srv.retry()) |req| h.answer(req); - while (h.srv.next()) |req| h.answer(req); - } - - fn send(h: *Harness, tag: u16, msg: Msg) !void { - var buf: [1024]u8 = undefined; - const bytes = try encode(msg, tag, &buf); - try testing.expectEqual(bytes.len, h.srv.push(bytes)); - h.pump(); - } - - fn reap(h: *Harness) !Decoded { - const out = h.srv.output(); - const len = frameLen(out) orelse return error.NoReply; - if (len > out.len) return error.ShortReply; - const got = try decode(out[0..len]); - h.srv.wrote(len); - return got; - } - - fn quiet(h: *Harness) !void { - try testing.expectEqual(@as(usize, 0), h.srv.output().len); - } - - fn handshake(h: *Harness, msize: u32) !void { - h.start(); - try h.send(notag, .{ .tversion = .{ .msize = msize, .version = "9P2000" } }); - const v = try h.reap(); - try testing.expectEqualStrings("9P2000", v.msg.rversion.version); - try h.send(0, .{ .tattach = .{ .fid = 0, .afid = nofid, .uname = "goblin", .aname = "" } }); - const a = try h.reap(); - try testing.expectEqual(@as(u64, 1), a.msg.rattach.qid.path); - } +const std = @import("std"); +const testing = std.testing; - fn walkTo(h: *Harness, tag: u16, newfid: u32, list: []const []const u8) !Decoded { - try h.send(tag, .{ .twalk = .{ - .fid = 0, - .newfid = newfid, - .nwname = @intCast(list.len), - .wname = wnames(list), - } }); - return h.reap(); - } +const Stub = struct { + pub const Req = cloud9.fs.Req; + pub const Reply = cloud9.fs.Reply; }; -fn wnames(list: []const []const u8) [max_welem][]const u8 { - var out: [max_welem][]const u8 = @splat(""); - for (list, 0..) |n, i| out[i] = n; - return out; -} - -fn dirNames(data: []const u8, out: [][]const u8) !usize { - var n: usize = 0; - var i: usize = 0; - while (i < data.len) { - const size = std.mem.readInt(u16, data[i..][0..2], .little); - const st = try Stat.decode(data[i..][0 .. @as(usize, size) + 2]); - out[n] = st.name; - n += 1; - i += @as(usize, size) + 2; - } - return n; -} - -test "9p server: the version handshake clamps, falls back, and refuses" { - var h: Harness = .{}; - h.start(); - - try h.send(notag, .{ .tversion = .{ .msize = 1 << 20, .version = "9P2000" } }); - var got = try h.reap(); - try testing.expectEqual(notag, got.tag); - try testing.expectEqual(@as(u32, 4096), got.msg.rversion.msize); - try testing.expectEqualStrings("9P2000", got.msg.rversion.version); - - try h.send(notag, .{ .tversion = .{ .msize = 512, .version = "9P2000" } }); - got = try h.reap(); - try testing.expectEqual(@as(u32, 512), got.msg.rversion.msize); - - try h.send(notag, .{ .tversion = .{ .msize = 4096, .version = "9P2000.u" } }); - got = try h.reap(); - try testing.expectEqualStrings("9P2000", got.msg.rversion.version); - - try h.send(notag, .{ .tversion = .{ .msize = 4096, .version = "TCP/IP" } }); - got = try h.reap(); - try testing.expectEqualStrings("unknown", got.msg.rversion.version); - try h.send(1, .{ .tattach = .{ .fid = 0, .afid = nofid, .uname = "goblin", .aname = "" } }); - try testing.expect(h.srv.protocol.dead); - h.start(); - try h.send(notag, .{ .tversion = .{ .msize = 64, .version = "9P2000" } }); - try testing.expect(h.srv.protocol.dead); - try testing.expectEqual(@as(u32, 216), msize_min - 1); -} - -test "9p server: attach names the root, and the only tree there is" { - var h: Harness = .{}; - h.start(); - try h.send(notag, .{ .tversion = .{ .msize = 4096, .version = "9P2000" } }); - _ = try h.reap(); - - try h.send(1, .{ .tattach = .{ .fid = 0, .afid = nofid, .uname = "goblin", .aname = "work" } }); - var got = try h.reap(); - try testing.expectEqualStrings(e_no_tree, got.msg.rerror.ename); - - try h.send(2, .{ .tattach = .{ .fid = 0, .afid = nofid, .uname = "goblin", .aname = "" } }); - got = try h.reap(); - try testing.expectEqual(@as(u64, 1), got.msg.rattach.qid.path); - try testing.expectEqual(qtdir, got.msg.rattach.qid.type); - try testing.expectEqual(@as(u32, 0), got.msg.rattach.qid.version); - - try h.send(3, .{ .tattach = .{ .fid = 0, .afid = nofid, .uname = "goblin", .aname = "" } }); - got = try h.reap(); - try testing.expectEqualStrings(e_fid_in_use, got.msg.rerror.ename); - - try h.send(4, .{ .tauth = .{ .afid = 1, .uname = "goblin", .aname = "" } }); - got = try h.reap(); - try testing.expectEqualStrings(e_no_auth, got.msg.rerror.ename); - - try h.send(5, .{ .tstat = .{ .fid = 0 } }); - got = try h.reap(); - try testing.expectEqualStrings("/", got.msg.rstat.stat.name); - try testing.expectEqualStrings("goblin", got.msg.rstat.stat.uid); - try testing.expectEqualStrings("goblin", got.msg.rstat.stat.muid); - try testing.expect(got.msg.rstat.stat.mode & dmdir != 0); -} - -test "9p server: a three-element walk, and `..` with no kernel to resolve it" { - var h: Harness = .{}; - try h.handshake(4096); - - var got = try h.walkTo(5, 1, &.{ "..", "1", "body" }); - try testing.expectEqual(@as(u16, 3), got.msg.rwalk.nwqid); - try testing.expectEqual(@as(u64, 1), got.msg.rwalk.wqid[0].path); - try testing.expectEqual(@as(u64, 16), got.msg.rwalk.wqid[1].path); - try testing.expectEqual(@as(u64, 18), got.msg.rwalk.wqid[2].path); - try testing.expectEqual(qtdir, got.msg.rwalk.wqid[1].type); - try testing.expectEqual(qtfile, got.msg.rwalk.wqid[2].type); - for (got.msg.rwalk.wqid[0..3]) |q| try testing.expectEqual(@as(u32, 0), q.version); - - got = try h.walkTo(6, 2, &.{ "..", "1", "..", "1", "body" }); - try testing.expectEqual(@as(u16, 5), got.msg.rwalk.nwqid); - try testing.expectEqual(@as(u64, 1), got.msg.rwalk.wqid[2].path); - try testing.expectEqual(@as(u64, 18), got.msg.rwalk.wqid[4].path); - try h.send(7, .{ .tstat = .{ .fid = 2 } }); - got = try h.reap(); - try testing.expectEqualStrings("body", got.msg.rstat.stat.name); - try testing.expectEqual(@as(u64, 12), got.msg.rstat.stat.length); - - got = try h.walkTo(8, 3, &.{ "1", "body", ".." }); - try testing.expectEqual(@as(u16, 3), got.msg.rwalk.nwqid); - try testing.expectEqual(@as(u64, 16), got.msg.rwalk.wqid[2].path); - try testing.expectEqual(qtdir, got.msg.rwalk.wqid[2].type); - try h.send(9, .{ .tstat = .{ .fid = 3 } }); - got = try h.reap(); - try testing.expectEqualStrings("1", got.msg.rstat.stat.name); - - const before = h.fsys.calls; - got = try h.walkTo(10, 4, &.{ ".", "." }); - try testing.expectEqual(@as(u16, 2), got.msg.rwalk.nwqid); - try testing.expectEqual(@as(u64, 1), got.msg.rwalk.wqid[1].path); - try testing.expectEqual(before, h.fsys.calls); -} - -test "9p server: a walk failing on the first element is Rerror, on the second a short Rwalk" { - var h: Harness = .{}; - try h.handshake(4096); - - var got = try h.walkTo(5, 1, &.{ "nope", "body" }); - try testing.expectEqualStrings("No such file or directory", got.msg.rerror.ename); - - got = try h.walkTo(6, 1, &.{ "1", "nope" }); - try testing.expectEqual(@as(u16, 1), got.msg.rwalk.nwqid); - try testing.expectEqual(@as(u64, 16), got.msg.rwalk.wqid[0].path); - - try h.send(7, .{ .tstat = .{ .fid = 1 } }); - got = try h.reap(); - try testing.expectEqualStrings(e_unknown_fid, got.msg.rerror.ename); - - try h.send(8, .{ .twalk = .{ .fid = 0, .newfid = 1, .nwname = 0 } }); - got = try h.reap(); - try testing.expectEqual(@as(u16, 0), got.msg.rwalk.nwqid); - try h.send(9, .{ .tstat = .{ .fid = 1 } }); - got = try h.reap(); - try testing.expectEqualStrings("/", got.msg.rstat.stat.name); - - got = try h.walkTo(10, 2, &.{"index"}); - try testing.expectEqual(@as(u16, 1), got.msg.rwalk.nwqid); - try h.send(11, .{ .twalk = .{ .fid = 2, .newfid = 3, .nwname = 1, .wname = wnames(&.{"body"}) } }); - got = try h.reap(); - try testing.expectEqualStrings(e_not_dir, got.msg.rerror.ename); - - got = try h.walkTo(12, 4, &.{"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"}); - try testing.expectEqualStrings(e_illegal_name, got.msg.rerror.ename); - - try h.send(13, .{ .twalk = .{ .fid = 0, .newfid = 1, .nwname = 1, .wname = wnames(&.{"1"}) } }); - got = try h.reap(); - try testing.expectEqualStrings(e_fid_in_use, got.msg.rerror.ename); -} - -test "9p server: backend-sized filenames survive walk and stat within negotiated msize" { - const NativeFs = struct { - pub const Req = StubFs.Req; - pub const Reply = StubFs.Reply; - pub const name_capacity: usize = 255; - }; - const Native = Server(NativeFs, 2); - try testing.expectEqual(@as(usize, 28), @sizeOf(@FieldType(Srv.Fid, "name"))); - try testing.expectEqual(@as(usize, 255), @sizeOf(@FieldType(Native.Fid, "name"))); - - const filename: [255]u8 = @splat('f'); - for ([_]struct { length: usize, msize: u32 }{ - .{ .length = 29, .msize = 512 }, - .{ .length = 128, .msize = 512 }, - .{ .length = 255, .msize = 512 }, - .{ .length = 200, .msize = 256 }, - }) |case| { - var in: [1024]u8 = undefined; - var out: [2048]u8 = undefined; - var encoded: [1024]u8 = undefined; - var server = Native.init(.{ .in = &in, .out = &out, .root = 1 }); - server.protocol.msize = case.msize; - server.setUname("u" ** username_capacity); - server.fids[0] = .{ .used = true, .fid = 0, .node = 1, .dir = true, .perm = 0o500 }; - const name = filename[0..case.length]; - const walk = try encode(.{ .twalk = .{ - .fid = 0, - .newfid = 1, - .nwname = 1, - .wname = wnames(&.{name}), - } }, 1, &encoded); - try testing.expectEqual(walk.len, server.push(walk)); - const lookup = server.next() orelse return error.MissingLookup; - try testing.expectEqual(.lookup, lookup.op); - try testing.expectEqualStrings(name, lookup.data); - server.reply(&.{ .tag = lookup.tag, .attr = .{ .node = 2, .name = name, .size = 12 } }, ""); - try testing.expectEqual(null, server.next()); - var response = try decode(server.output()); - try testing.expectEqual(@as(u16, 1), response.msg.rwalk.nwqid); - server.wrote(server.output().len); - - const stat = try encode(.{ .tstat = .{ .fid = 1 } }, 2, &encoded); - try testing.expectEqual(stat.len, server.push(stat)); - const getattr = server.next() orelse return error.MissingGetattr; - try testing.expectEqual(.getattr, getattr.op); - server.reply(&.{ .tag = getattr.tag, .attr = .{ .node = 2, .name = name, .size = 12 } }, ""); - try testing.expect(server.output().len <= case.msize); - response = try decode(server.output()); - if (case.msize == 256) { - try testing.expectEqualStrings(e_small_msize, response.msg.rerror.ename); - } else { - try testing.expectEqualStrings(name, response.msg.rstat.stat.name); - try testing.expectEqual(@as(u64, 12), response.msg.rstat.stat.length); - } - server.wrote(server.output().len); - const clunk = try encode(.{ .tclunk = .{ .fid = 1 } }, 3, &encoded); - try testing.expectEqual(clunk.len, server.push(clunk)); - try testing.expectEqual(null, server.next()); - response = try decode(server.output()); - try testing.expect(response.msg == .rclunk); - try testing.expect(!server.protocol.dead); - } -} - -test "9p server: open then read then clunk, and the release a clunk owes the core" { - var h: Harness = .{}; - try h.handshake(4096); - _ = try h.walkTo(5, 1, &.{ "1", "body" }); - - try h.send(6, .{ .topen = .{ .fid = 1, .mode = oread } }); - var got = try h.reap(); - try testing.expectEqual(@as(u64, 18), got.msg.ropen.qid.path); - try testing.expectEqual(@as(u32, 4096 - iohdrsz), got.msg.ropen.iounit); - - try h.send(7, .{ .topen = .{ .fid = 1, .mode = oread } }); - got = try h.reap(); - try testing.expectEqualStrings(e_already_open, got.msg.rerror.ename); - - try h.send(8, .{ .tread = .{ .fid = 1, .offset = 0, .count = 4096 } }); - got = try h.reap(); - try testing.expectEqualStrings("hello, body\n", got.msg.rread.data); - - try h.send(9, .{ .tread = .{ .fid = 1, .offset = 7, .count = 4096 } }); - got = try h.reap(); - try testing.expectEqualStrings("body\n", got.msg.rread.data); - - try h.send(10, .{ .tread = .{ .fid = 1, .offset = 99, .count = 16 } }); - got = try h.reap(); - try testing.expectEqual(@as(usize, 0), got.msg.rread.data.len); - - try testing.expectEqual(@as(u32, 0), h.fsys.releases); - try h.send(11, .{ .tclunk = .{ .fid = 1 } }); - got = try h.reap(); - try testing.expect(got.msg == .rclunk); - try testing.expectEqual(@as(u32, 1), h.fsys.releases); - - try h.send(12, .{ .tread = .{ .fid = 1, .offset = 0, .count = 16 } }); - got = try h.reap(); - try testing.expectEqualStrings(e_unknown_fid, got.msg.rerror.ename); - try h.send(13, .{ .tclunk = .{ .fid = 1 } }); - got = try h.reap(); - try testing.expectEqualStrings(e_unknown_fid, got.msg.rerror.ename); - - _ = try h.walkTo(14, 2, &.{"index"}); - try h.send(15, .{ .tclunk = .{ .fid = 2 } }); - got = try h.reap(); - try testing.expect(got.msg == .rclunk); - try testing.expectEqual(@as(u32, 1), h.fsys.releases); -} - -test "9p server: every Rread is clamped to the client's count and to the msize" { - var h: Harness = .{}; - try h.handshake(512); - _ = try h.walkTo(5, 1, &.{"index"}); - try h.send(6, .{ .topen = .{ .fid = 1, .mode = oread } }); - _ = try h.reap(); - - try h.send(7, .{ .tread = .{ .fid = 1, .offset = 0, .count = 5 } }); - var got = try h.reap(); - try testing.expectEqual(@as(usize, 5), got.msg.rread.data.len); - - try h.send(8, .{ .tread = .{ .fid = 1, .offset = 0, .count = 1 << 20 } }); - const out = h.srv.output(); - try testing.expectEqual(@as(?u32, 512), frameLen(out)); - got = try h.reap(); - try testing.expectEqual(@as(usize, 512 - header_len - 4), got.msg.rread.data.len); - - try h.send(9, .{ .tread = .{ .fid = 1, .offset = 0, .count = 1 << 20 } }); - got = try h.reap(); - try testing.expectEqual(@as(usize, 501), got.msg.rread.data.len); -} - -test "9p server: a directory read is whole stat records at a cursor the client cannot invent" { - var h: Harness = .{}; - try h.handshake(4096); - _ = try h.walkTo(4, 1, &.{"index"}); - try h.send(5, .{ .topen = .{ .fid = 0, .mode = oread } }); - _ = try h.reap(); - - var found: [8][]const u8 = undefined; - - try h.send(6, .{ .tread = .{ .fid = 0, .offset = 0, .count = 150 } }); - var got = try h.reap(); - const first = got.msg.rread.data.len; - try testing.expectEqual(@as(usize, 2), try dirNames(got.msg.rread.data, &found)); - try testing.expectEqualStrings("index", found[0]); - try testing.expectEqualStrings("cons", found[1]); - try testing.expect(first <= 150); - - try h.send(7, .{ .tread = .{ .fid = 0, .offset = first, .count = 150 } }); - got = try h.reap(); - const second = got.msg.rread.data.len; - try testing.expectEqual(@as(usize, 2), try dirNames(got.msg.rread.data, &found)); - try testing.expectEqualStrings("new", found[0]); - try testing.expectEqualStrings("1", found[1]); - - try h.send(8, .{ .tread = .{ .fid = 0, .offset = first + second + 1, .count = 150 } }); - got = try h.reap(); - try testing.expectEqualStrings(e_bad_offset, got.msg.rerror.ename); - try h.send(9, .{ .tread = .{ .fid = 0, .offset = 3, .count = 150 } }); - got = try h.reap(); - try testing.expectEqualStrings(e_bad_offset, got.msg.rerror.ename); - - try h.send(10, .{ .tread = .{ .fid = 0, .offset = first + second, .count = 150 } }); - got = try h.reap(); - try testing.expectEqual(@as(usize, 1), try dirNames(got.msg.rread.data, &found)); - try testing.expectEqualStrings("2", found[0]); - - try h.send(11, .{ .tread = .{ .fid = 0, .offset = first + second + got.msg.rread.data.len, .count = 150 } }); - got = try h.reap(); - try testing.expectEqual(@as(usize, 0), got.msg.rread.data.len); - - try h.send(12, .{ .tread = .{ .fid = 0, .offset = 0, .count = 150 } }); - got = try h.reap(); - try testing.expectEqual(@as(usize, 2), try dirNames(got.msg.rread.data, &found)); - try testing.expectEqualStrings("index", found[0]); - - try h.send(13, .{ .tread = .{ .fid = 0, .offset = 0, .count = 40 } }); - got = try h.reap(); - try testing.expectEqualStrings(e_count_small, got.msg.rerror.ename); - - try h.send(14, .{ .tread = .{ .fid = 0, .offset = 0, .count = 150 } }); - got = try h.reap(); - const one = try Stat.decode(got.msg.rread.data[0 .. std.mem.readInt(u16, got.msg.rread.data[0..2], .little) + 2]); - try testing.expectEqualStrings("index", one.name); - try testing.expectEqual(@as(u32, dirent_file_perm), one.mode); - try testing.expectEqual(@as(u64, 0), one.length); - try testing.expectEqual(@as(u32, 0), one.qid.version); - - try h.send(16, .{ .tstat = .{ .fid = 1 } }); - got = try h.reap(); - try testing.expectEqual(@as(u32, 0o400), got.msg.rstat.stat.mode); - try testing.expectEqual(@as(u64, 1024), got.msg.rstat.stat.length); -} - -test "9p server: long directory names remain whole across pages" { - var h: Harness = .{}; - try h.handshake(4096); - var entries: [10 + 255 + 10 + 4]u8 = @splat(0); - std.mem.writeInt(u64, entries[0..8], 41, .little); - entries[9] = 255; - @memset(entries[10..265], 'f'); - std.mem.writeInt(u64, entries[265..273], 42, .little); - entries[274] = 4; - @memcpy(entries[275..], "next"); - var found: [2][]const u8 = undefined; - - { - var request: [64]u8 = undefined; - const bytes = try encode(.{ .tread = .{ .fid = 0, .offset = 0, .count = 330 } }, 5, &request); - _ = h.srv.protocol.push(bytes); - _ = (try h.srv.protocol.receive()).?; - h.srv.protocol.release(); - } - h.srv.emitDirRead(5, 0, &entries, 330); - var got = try h.reap(); - const first = got.msg.rread.data.len; - try testing.expectEqual(@as(usize, 1), try dirNames(got.msg.rread.data, &found)); - try testing.expectEqualStrings(entries[10..265], found[0]); - try testing.expectEqual(@as(u64, 1), h.srv.fids[0].dirindex); - - { - var request: [64]u8 = undefined; - const bytes = try encode(.{ .tread = .{ .fid = 0, .offset = 0, .count = 330 } }, 6, &request); - _ = h.srv.protocol.push(bytes); - _ = (try h.srv.protocol.receive()).?; - h.srv.protocol.release(); - } - h.srv.emitDirRead(6, 0, entries[265..], 330); - got = try h.reap(); - try testing.expectEqual(@as(usize, 1), try dirNames(got.msg.rread.data, &found)); - try testing.expectEqualStrings("next", found[0]); - try testing.expectEqual(@as(u64, 2), h.srv.fids[0].dirindex); - try testing.expectEqual(first + got.msg.rread.data.len, h.srv.fids[0].diroff); - - { - var request: [64]u8 = undefined; - const bytes = try encode(.{ .tread = .{ .fid = 0, .offset = 0, .count = 4096 } }, 7, &request); - _ = h.srv.protocol.push(bytes); - _ = (try h.srv.protocol.receive()).?; - h.srv.protocol.release(); - } - h.srv.emitDirRead(7, 0, &entries, 4096); - got = try h.reap(); - try testing.expectEqual(@as(usize, 2), try dirNames(got.msg.rread.data, &found)); - try testing.expectEqualStrings(entries[10..265], found[0]); - try testing.expectEqualStrings("next", found[1]); -} - -test "9p server: a blocked read parks, and the connection keeps working" { - var h: Harness = .{}; - try h.handshake(4096); - _ = try h.walkTo(5, 1, &.{ "1", "event" }); - try h.send(6, .{ .topen = .{ .fid = 1, .mode = oread } }); - _ = try h.reap(); - - try h.send(7, .{ .tread = .{ .fid = 1, .offset = 0, .count = 4096 } }); - try h.quiet(); - - h.pump(); - h.pump(); - try h.quiet(); - - _ = try h.walkTo(8, 2, &.{ "1", "body" }); - try h.send(9, .{ .tstat = .{ .fid = 2 } }); - var got = try h.reap(); - try testing.expectEqualStrings("body", got.msg.rstat.stat.name); - - h.fsys.event = "Kli7 7 0 0 hello\n"; - h.pump(); - got = try h.reap(); - try testing.expectEqual(@as(u16, 7), got.tag); - try testing.expectEqualStrings("Kli7 7 0 0 hello\n", got.msg.rread.data); - try h.quiet(); - - _ = try h.walkTo(10, 3, &.{ "1", "ctl" }); - try h.send(11, .{ .topen = .{ .fid = 3, .mode = owrite } }); - _ = try h.reap(); - h.fsys.park_writes = true; - try h.send(12, .{ .twrite = .{ .fid = 3, .offset = 0, .data = "clean\n" } }); - try h.quiet(); - try h.send(13, .{ .tstat = .{ .fid = 2 } }); - _ = try h.reap(); - h.fsys.park_writes = false; - h.pump(); - got = try h.reap(); - try testing.expectEqual(@as(u16, 12), got.tag); - try testing.expectEqual(@as(u32, 6), got.msg.rwrite.count); - try testing.expectEqualStrings("clean\n", h.fsys.writes[0..h.fsys.writes_len]); - for (0..max_slots) |k| { - try h.send(@intCast(100 + k), .{ .tread = .{ .fid = 1, .offset = 0, .count = 4096 } }); - try h.quiet(); - } - try h.send(200, .{ .tread = .{ .fid = 1, .offset = 0, .count = 4096 } }); - got = try h.reap(); - try testing.expectEqualStrings(e_again, got.msg.rerror.ename); -} - -test "9p server: the reply queue is a FIFO that survives a partial write" { - var h: Harness = .{}; - try h.handshake(4096); - - try h.send(5, .{ .tstat = .{ .fid = 0 } }); - var saved: [256]u8 = undefined; - const one = h.srv.output(); - const n = one.len; - @memcpy(saved[0..n], one); - h.srv.wrote(3); - try testing.expectEqual(n - 3, h.srv.output().len); - - try h.send(6, .{ .tstat = .{ .fid = 0 } }); - const rest = h.srv.output(); - try testing.expectEqualSlices(u8, saved[3..n], rest[0 .. n - 3]); - const tail = rest[n - 3 ..]; - const second = try decode(tail[0..frameLen(tail).?]); - try testing.expectEqual(@as(u16, 6), second.tag); - - var flood: [8192]u8 = @splat(0); - try testing.expectEqual(@as(usize, 4096), h.srv.push(&flood)); - h.pump(); - try testing.expect(h.srv.protocol.dead); - try testing.expectEqual(@as(usize, 0), h.srv.push(&flood)); -} - -test "9p server: Tflush answers the original first and the Rflush second" { - var h: Harness = .{}; - try h.handshake(4096); - _ = try h.walkTo(5, 1, &.{ "1", "event" }); - try h.send(6, .{ .topen = .{ .fid = 1, .mode = oread } }); - _ = try h.reap(); - try h.send(7, .{ .tread = .{ .fid = 1, .offset = 0, .count = 4096 } }); - try h.quiet(); - - try h.send(8, .{ .tflush = .{ .oldtag = 7 } }); - var got = try h.reap(); - try testing.expectEqual(@as(u16, 7), got.tag); - try testing.expectEqualStrings(e_interrupted, got.msg.rerror.ename); - got = try h.reap(); - try testing.expectEqual(@as(u16, 8), got.tag); - try testing.expect(got.msg == .rflush); - try h.quiet(); - - h.fsys.event = "Kli7 7 0 0 hello\n"; - h.pump(); - try h.quiet(); - - try h.send(9, .{ .tflush = .{ .oldtag = 99 } }); - got = try h.reap(); - try testing.expectEqual(@as(u16, 9), got.tag); - try testing.expect(got.msg == .rflush); - try h.quiet(); -} - -test "9p server: the fid and permission refusals, each in a string Linux knows" { - var h: Harness = .{}; - try h.handshake(4096); - - for ([_]Msg{ - .{ .tread = .{ .fid = 99, .offset = 0, .count = 16 } }, - .{ .tstat = .{ .fid = 99 } }, - .{ .tclunk = .{ .fid = 99 } }, - .{ .topen = .{ .fid = 99, .mode = oread } }, - .{ .twalk = .{ .fid = 99, .newfid = 98, .nwname = 0 } }, - }, 20..) |msg, tag| { - try h.send(@intCast(tag), msg); - const got = try h.reap(); - try testing.expectEqualStrings(e_unknown_fid, got.msg.rerror.ename); - } - - _ = try h.walkTo(5, 1, &.{ "1", "body" }); - try h.send(6, .{ .tread = .{ .fid = 1, .offset = 0, .count = 16 } }); - var got = try h.reap(); - try testing.expectEqualStrings(e_bad_use, got.msg.rerror.ename); - try h.send(7, .{ .topen = .{ .fid = 1, .mode = oread } }); - _ = try h.reap(); - try h.send(8, .{ .twrite = .{ .fid = 1, .offset = 0, .data = "x" } }); - got = try h.reap(); - try testing.expectEqualStrings(e_bad_use, got.msg.rerror.ename); - - try h.send(9, .{ .twalk = .{ .fid = 1, .newfid = 2, .nwname = 0 } }); - got = try h.reap(); - try testing.expectEqualStrings(e_bad_use, got.msg.rerror.ename); - - _ = try h.walkTo(10, 3, &.{ "1", "errors" }); - try h.send(11, .{ .topen = .{ .fid = 3, .mode = oread } }); - got = try h.reap(); - try testing.expectEqualStrings(e_perm, got.msg.rerror.ename); - try h.send(12, .{ .topen = .{ .fid = 3, .mode = owrite } }); - got = try h.reap(); - try testing.expect(got.msg == .ropen); - - try h.send(13, .{ .topen = .{ .fid = 0, .mode = ordwr } }); - got = try h.reap(); - try testing.expectEqualStrings(e_perm, got.msg.rerror.ename); - _ = try h.walkTo(14, 4, &.{ "1", "tag" }); - for ([_]u8{ orclose, oexec, oread | orclose }, 30..) |mode, tag| { - try h.send(@intCast(tag), .{ .topen = .{ .fid = 4, .mode = mode } }); - got = try h.reap(); - try testing.expectEqualStrings(e_perm, got.msg.rerror.ename); - } -} - -test "9p server: Twstat with a zero length is the truncate, and so is OTRUNC" { - var h: Harness = .{}; - try h.handshake(4096); - _ = try h.walkTo(5, 1, &.{ "1", "body" }); - - const sentinel: Stat = .{ - .type = std.math.maxInt(u16), - .dev = std.math.maxInt(u32), - .qid = .{ .type = 0xFF, .version = std.math.maxInt(u32), .path = std.math.maxInt(u64) }, - .mode = std.math.maxInt(u32), - .atime = std.math.maxInt(u32), - .mtime = std.math.maxInt(u32), - .length = std.math.maxInt(u64), - .name = "", - .uid = "", - .gid = "", - .muid = "", - }; - - try h.send(6, .{ .twstat = .{ .fid = 1, .stat = sentinel } }); - var got = try h.reap(); - try testing.expect(got.msg == .rwstat); - try testing.expectEqualStrings("hello, body\n", h.fsys.body); - - var five = sentinel; - five.length = 5; - try h.send(7, .{ .twstat = .{ .fid = 1, .stat = five } }); - got = try h.reap(); - try testing.expectEqualStrings(e_trunc_only, got.msg.rerror.ename); - - var renamed = sentinel; - renamed.name = "other"; - try h.send(8, .{ .twstat = .{ .fid = 1, .stat = renamed } }); - got = try h.reap(); - try testing.expectEqualStrings(e_wstat, got.msg.rerror.ename); - try testing.expectEqualStrings("hello, body\n", h.fsys.body); - - var changes: [12]Stat = @splat(sentinel); - changes[0].type = 0; - changes[1].dev = 0; - changes[2].qid.type = 0; - changes[3].qid.version = 0; - changes[4].qid.path = 0; - changes[5].mode = 0o644; - changes[6].atime = 0; - changes[7].mtime = 0; - changes[8].name = "renamed"; - changes[9].uid = "owner"; - changes[10].gid = "group"; - changes[11].muid = "writer"; - for (changes) |change| { - for ([_]u64{ std.math.maxInt(u64), 0 }) |length| { - if (change.mtime != std.math.maxInt(u32) and length == 0) continue; - var attributes = change; - attributes.length = length; - const calls = h.fsys.calls; - try h.send(20, .{ .twstat = .{ .fid = 1, .stat = attributes } }); - got = try h.reap(); - try testing.expect(got.msg == .rerror); - try testing.expectEqualStrings(e_wstat, got.msg.rerror.ename); - try testing.expectEqual(calls, h.fsys.calls); - try testing.expectEqualStrings("hello, body\n", h.fsys.body); - } - } - - // Captured Linux v9fs O_TRUNC follow-up: length=0 plus current mtime. - var linux_truncate = sentinel; - linux_truncate.length = 0; - linux_truncate.mtime = 1789432552; - try h.send(21, .{ .twstat = .{ .fid = 1, .stat = linux_truncate } }); - got = try h.reap(); - try testing.expect(got.msg == .rwstat); - try testing.expectEqualStrings("", h.fsys.body); - h.fsys.body = "hello, body\n"; - - var zero = sentinel; - zero.length = 0; - try h.send(9, .{ .twstat = .{ .fid = 1, .stat = zero } }); - got = try h.reap(); - try testing.expect(got.msg == .rwstat); - try testing.expectEqualStrings("", h.fsys.body); - - h.fsys.body = "hello, body\n"; - _ = try h.walkTo(10, 2, &.{"index"}); - try h.send(11, .{ .topen = .{ .fid = 2, .mode = oread | otrunc } }); - got = try h.reap(); - try testing.expectEqualStrings(e_perm, got.msg.rerror.ename); - try h.send(12, .{ .topen = .{ .fid = 1, .mode = owrite | otrunc } }); - got = try h.reap(); - try testing.expectEqual(@as(u64, 18), got.msg.ropen.qid.path); - try testing.expectEqualStrings("", h.fsys.body); -} - -test "9p server: create and remove are refused, and a remove clunks the fid anyway" { - var h: Harness = .{}; - try h.handshake(4096); - - try h.send(5, .{ .tcreate = .{ .fid = 0, .name = "thing", .perm = 0o600, .mode = owrite } }); - var got = try h.reap(); - try testing.expectEqualStrings(e_perm, got.msg.rerror.ename); - - _ = try h.walkTo(6, 1, &.{ "1", "body" }); - try h.send(7, .{ .topen = .{ .fid = 1, .mode = ordwr } }); - _ = try h.reap(); - try h.send(8, .{ .tremove = .{ .fid = 1 } }); - got = try h.reap(); - try testing.expectEqualStrings(e_perm, got.msg.rerror.ename); - try testing.expectEqual(@as(u32, 1), h.fsys.releases); - try h.send(9, .{ .tstat = .{ .fid = 1 } }); - got = try h.reap(); - try testing.expectEqualStrings(e_unknown_fid, got.msg.rerror.ename); -} - -test "9p server: a message arriving a byte at a time is served when its last byte lands" { - var h: Harness = .{}; - try h.handshake(4096); - - var buf: [64]u8 = undefined; - const bytes = try encode(.{ .tstat = .{ .fid = 0 } }, 5, &buf); - for (bytes[0 .. bytes.len - 1]) |b| { - try testing.expectEqual(@as(usize, 1), h.srv.push(&.{b})); - h.pump(); - try h.quiet(); - } - try testing.expectEqual(@as(usize, 1), h.srv.push(bytes[bytes.len - 1 ..])); - h.pump(); - const got = try h.reap(); - try testing.expectEqualStrings("/", got.msg.rstat.stat.name); - - var pair: [128]u8 = undefined; - const a = try encode(.{ .tstat = .{ .fid = 0 } }, 6, &pair); - const b = try encode(.{ .tstat = .{ .fid = 0 } }, 7, pair[a.len..]); - try testing.expectEqual(a.len + b.len, h.srv.push(pair[0 .. a.len + b.len])); - h.pump(); - try testing.expectEqual(@as(u16, 6), (try h.reap()).tag); - try testing.expectEqual(@as(u16, 7), (try h.reap()).tag); - try h.quiet(); -} - -test "9p server: invalid framing and reply types terminate the connection" { - for ([_]u8{ @intFromEnum(Type.rstat), 8, 0 }) |kind| { - var h: Harness = .{}; - try h.handshake(4096); - var buf: [64]u8 = undefined; - const raw = try encode(.{ .tstat = .{ .fid = 0 } }, 5, &buf); - if (kind == 0) std.mem.writeInt(u32, raw[0..4], 3, .little) else raw[4] = kind; - _ = h.srv.push(raw); - h.pump(); - try h.quiet(); - try testing.expect(h.srv.protocol.dead); - } -} - -test "9p server: a connection that drops still pays the core its releases" { - var h: Harness = .{}; - try h.handshake(4096); - _ = try h.walkTo(5, 1, &.{ "1", "event" }); - _ = try h.walkTo(6, 2, &.{ "1", "body" }); - for ([_]u32{ 1, 2 }, 7..) |fid, tag| { - try h.send(@intCast(tag), .{ .topen = .{ .fid = fid, .mode = oread } }); - _ = try h.reap(); - } - try h.send(9, .{ .tread = .{ .fid = 1, .offset = 0, .count = 4096 } }); - try h.quiet(); - - h.srv.hangup(); - h.pump(); - try testing.expectEqual(@as(u32, 2), h.fsys.releases); - try h.quiet(); - - var g: Harness = .{}; - try g.handshake(4096); - _ = try g.walkTo(5, 1, &.{ "1", "event" }); - try g.send(6, .{ .topen = .{ .fid = 1, .mode = oread } }); - _ = try g.reap(); - try g.send(7, .{ .tread = .{ .fid = 1, .offset = 0, .count = 4096 } }); - try g.quiet(); - try g.send(notag, .{ .tversion = .{ .msize = 4096, .version = "9P2000" } }); - const v = try g.reap(); - try testing.expectEqualStrings("9P2000", v.msg.rversion.version); - try testing.expectEqual(@as(u32, 1), g.fsys.releases); - g.fsys.event = "Kli7 7 0 0 hello\n"; - g.pump(); - try g.quiet(); - try g.send(8, .{ .tstat = .{ .fid = 1 } }); - const got = try g.reap(); - try testing.expectEqualStrings(e_unknown_fid, got.msg.rerror.ename); -} - -test "9p server: every errno the core can answer is a string Linux knows" { - try testing.expectEqualStrings("Operation not permitted", errString(1)); - try testing.expectEqualStrings("No such file or directory", errString(2)); - try testing.expectEqualStrings("Input/output error", errString(5)); - try testing.expectEqualStrings("Cannot allocate memory", errString(12)); - try testing.expectEqualStrings("Not a directory", errString(20)); - try testing.expectEqualStrings("Invalid argument", errString(22)); - try testing.expectEqualStrings("Too many open files in system", errString(23)); - try testing.expectEqualStrings("No space left on device", errString(28)); - try testing.expectEqualStrings("Function not implemented", errString(38)); - try testing.expectEqualStrings("Input/output error", errString(0)); - try testing.expectEqualStrings("Input/output error", errString(999)); - - try testing.expectEqualStrings("fid unknown or out of range", e_unknown_fid); - try testing.expectEqualStrings("fid already in use", e_fid_in_use); - try testing.expectEqualStrings("bad use of fid", e_bad_use); - try testing.expectEqualStrings("bad offset in directory read", e_bad_offset); - try testing.expectEqualStrings("permission denied", e_perm); - try testing.expectEqualStrings("not a directory", e_not_dir); - try testing.expectEqualStrings("file already open for I/O", e_already_open); - try testing.expectEqualStrings("illegal name", e_illegal_name); - try testing.expectEqualStrings("Too many open files in system", e_too_many_fids); - try testing.expectEqualStrings("protocol botch", e_botch); - try testing.expectEqualStrings("Interrupted system call", e_interrupted); - try testing.expectEqualStrings("only support truncation to zero length", e_trunc_only); - try testing.expectEqualStrings("wstat prohibited", e_wstat); - try testing.expectEqualStrings("Resource temporarily unavailable", e_again); - for ([_][]const u8{ - e_unknown_fid, e_fid_in_use, e_bad_use, e_bad_offset, e_perm, - e_not_dir, e_already_open, e_botch, e_interrupted, e_trunc_only, - e_wstat, e_again, e_no_tree, e_no_auth, e_count_small, - e_illegal_name, e_too_many_fids, e_small_msize, - }) |s| try testing.expect(s.len <= errmax); -} - test "9p server: board and native capacities size the actual fid storage" { - const Board = Server(StubFs, board_fids); - const Native = Server(StubFs, max_fids); + const Board = Server(Stub, board); + const Native = Server(Stub, editor); const BoardFids = @FieldType(Board, "fids"); const NativeFids = @FieldType(Native, "fids"); try testing.expectEqual(32, @typeInfo(BoardFids).array.len); try testing.expectEqual(256, @typeInfo(NativeFids).array.len); + try testing.expectEqual(28, @sizeOf(@FieldType(Board.Fid, "name"))); + try testing.expectEqual(255, @sizeOf(@FieldType(Native.Fid, "name"))); try testing.expectEqual(32 * @sizeOf(Board.Fid), @sizeOf(BoardFids)); try testing.expectEqual(256 * @sizeOf(Native.Fid), @sizeOf(NativeFids)); - try testing.expectEqual( - @sizeOf(NativeFids) - @sizeOf(BoardFids), - @sizeOf(Native) - @sizeOf(Board), - ); try testing.expect(@sizeOf(BoardFids) <= 3 * 1024); - try testing.expect(@sizeOf(NativeFids) <= 24 * 1024); try testing.expect(@sizeOf(@FieldType(Board, "slots")) <= 8 * 1024); try testing.expect(3 * 4096 + @sizeOf(Board) <= 24 * 1024); -} - -const Pair = struct { - srv_in: [4096]u8 = undefined, - srv_out: [8192]u8 = undefined, - cli_in: [4096]u8 = undefined, - cli_out: [4096]u8 = undefined, - fsys: StubFs = .{}, - srv: Srv = undefined, - cli: Client = undefined, - - fn start(p: *Pair) void { - p.srv = Srv.init(.{ .in = &p.srv_in, .out = &p.srv_out, .root = 1 }); - p.cli = Client.init(.{ .in = &p.cli_in, .out = &p.cli_out }); - } - - fn answer(p: *Pair, req: StubFs.Req) void { - const a = p.fsys.handle(req); - p.srv.reply(&a.reply, a.bytes); - } - - fn wire(p: *Pair) void { - var moved = true; - while (moved) { - moved = false; - while (p.cli.output().len != 0) { - const n = p.srv.push(p.cli.output()); - if (n == 0) break; - p.cli.wrote(n); - moved = true; - } - while (p.srv.retry()) |req| { - p.answer(req); - moved = true; - } - while (p.srv.next()) |req| { - p.answer(req); - moved = true; - } - while (p.srv.output().len != 0) { - const n = p.cli.push(p.srv.output()); - if (n == 0) break; - p.srv.wrote(n); - moved = true; - } - } - } - - fn one(p: *Pair, req: Client.Request) !Client.Done { - const tag = try p.cli.submit(req); - p.wire(); - const done = p.cli.take() orelse return error.NoReply; - try testing.expectEqual(tag, done.tag); - try testing.expectEqual(std.meta.activeTag(req), done.op); - try testing.expectEqual(@as(usize, 0), p.cli.pending()); - return done; - } - - fn handshake(p: *Pair) !void { - p.start(); - const v = try p.one(.{ .version = .{} }); - try testing.expectEqualStrings("9P2000", v.result.version.version); - try testing.expectEqual(@as(u16, notag), v.tag); - const a = try p.one(.{ .attach = .{ .fid = 0, .uname = "goblin" } }); - try testing.expectEqual(@as(u64, 1), a.result.attach.path); - try testing.expectEqual(qtdir, a.result.attach.type); - } -}; - -test "9p client: a whole session against the server in this file" { - var p: Pair = .{}; - try p.handshake(); - try testing.expectEqual(@as(u32, 4096), p.cli.msize); - try testing.expectEqual(@as(u32, 4096 - 11), p.cli.maxRead()); - try testing.expectEqual(@as(u32, 4096 - 23), p.cli.maxWrite()); - - const w = try p.one(.{ .walk = .{ .fid = 0, .newfid = 1, .names = &.{ "1", "body" } } }); - try testing.expectEqual(@as(u16, 2), w.result.walk.nwqid); - try testing.expectEqual(@as(u64, 16), w.result.walk.wqid[0].path); - try testing.expectEqual(@as(u64, 18), w.result.walk.wqid[1].path); - try testing.expectEqual(qtfile, w.result.walk.wqid[1].type); - - const o = try p.one(.{ .open = .{ .fid = 1, .mode = ordwr } }); - try testing.expectEqual(@as(u64, 18), o.result.open.qid.path); - try testing.expectEqual(@as(u32, 4096 - iohdrsz), o.result.open.iounit); - - const r = try p.one(.{ .read = .{ .fid = 1, .offset = 0, .count = 64 } }); - try testing.expectEqualStrings("hello, body\n", r.result.read); - const eof = try p.one(.{ .read = .{ .fid = 1, .offset = 12, .count = 64 } }); - try testing.expectEqual(@as(usize, 0), eof.result.read.len); - - const wr = try p.one(.{ .write = .{ .fid = 1, .offset = 0, .data = "abc" } }); - try testing.expectEqual(@as(u32, 3), wr.result.write); - try testing.expectEqualStrings("abc", p.fsys.writes[0..p.fsys.writes_len]); - - const st = try p.one(.{ .stat = .{ .fid = 1 } }); - try testing.expectEqualStrings("body", st.result.stat.name); - try testing.expectEqual(@as(u64, 12), st.result.stat.length); - try testing.expectEqualStrings("goblin", st.result.stat.uid); - - _ = try p.one(.{ .clunk = .{ .fid = 1 } }); - try testing.expectEqual(@as(u32, 1), p.fsys.releases); - try testing.expectEqual(@as(usize, 0), p.cli.pending()); - try testing.expectEqual(@as(usize, 0), p.cli.output().len); - try testing.expect(p.cli.take() == null); - try testing.expect(!p.cli.dead); -} - -fn deliverReversed(p: *Pair) !void { - var scratch: [4096]u8 = undefined; - const out = p.srv.output(); - try testing.expect(out.len <= scratch.len); - @memcpy(scratch[0..out.len], out); - const total = out.len; - p.srv.wrote(total); - - var at: [max_tags]usize = undefined; - var lens: [max_tags]u32 = undefined; - var count: usize = 0; - var i: usize = 0; - while (i < total) { - const len = frameLen(scratch[i..total]) orelse return error.ShortReply; - at[count] = i; - lens[count] = len; - count += 1; - i += len; - } - try testing.expect(count >= 2); - var k = count; - while (k > 0) { - k -= 1; - const f = scratch[at[k]..][0..lens[k]]; - try testing.expectEqual(f.len, p.cli.push(f)); - } -} - -test "9p client: replies out of order are matched by tag and not by arrival" { - var p: Pair = .{}; - try p.handshake(); - const w = try p.one(.{ .walk = .{ .fid = 0, .newfid = 1, .names = &.{"index"} } }); - try testing.expectEqual(@as(u16, 1), w.result.walk.nwqid); - - const root_tag = try p.cli.submit(.{ .stat = .{ .fid = 0 } }); - const index_tag = try p.cli.submit(.{ .stat = .{ .fid = 1 } }); - try testing.expectEqual(@as(u16, 0), root_tag); - try testing.expectEqual(@as(u16, 1), index_tag); - try testing.expectEqual(@as(usize, 2), p.cli.pending()); - - while (p.cli.output().len != 0) { - const n = p.srv.push(p.cli.output()); - p.cli.wrote(n); - } - while (p.srv.next()) |req| p.answer(req); - try deliverReversed(&p); - - const first = p.cli.take() orelse return error.NoReply; - try testing.expectEqual(index_tag, first.tag); - try testing.expectEqualStrings("index", first.result.stat.name); - const second = p.cli.take() orelse return error.NoReply; - try testing.expectEqual(root_tag, second.tag); - try testing.expectEqualStrings("/", second.result.stat.name); - try testing.expectEqual(@as(usize, 0), p.cli.pending()); - try testing.expect(!p.cli.dead); -} - -test "9p client: an Rerror answers one operation and the session carries on" { - var p: Pair = .{}; - try p.handshake(); - - const bad = try p.one(.{ .walk = .{ .fid = 0, .newfid = 1, .names = &.{"nope"} } }); - try testing.expectEqual(Client.Op.walk, bad.op); - try testing.expectEqualStrings(errString(2), bad.result.fail); - - try testing.expectEqual(@as(usize, 0), p.cli.pending()); - try testing.expect(!p.cli.dead); - const st = try p.one(.{ .stat = .{ .fid = 0 } }); - try testing.expectEqualStrings("/", st.result.stat.name); - - const stale = try p.one(.{ .stat = .{ .fid = 9 } }); - try testing.expectEqualStrings(e_unknown_fid, stale.result.fail); - try testing.expect(!p.cli.dead); -} - -test "9p client: a reply arriving a byte at a time is taken when its last byte lands" { - var p: Pair = .{}; - try p.handshake(); - const tag = try p.cli.submit(.{ .stat = .{ .fid = 0 } }); - - while (p.cli.output().len != 0) { - const n = p.srv.push(p.cli.output()); - p.cli.wrote(n); - } - while (p.srv.next()) |req| p.answer(req); - var scratch: [512]u8 = undefined; - const out = p.srv.output(); - try testing.expect(out.len > 4 and out.len <= scratch.len); - @memcpy(scratch[0..out.len], out); - const reply = scratch[0..out.len]; - p.srv.wrote(reply.len); - - for (reply[0 .. reply.len - 1]) |b| { - try testing.expectEqual(@as(usize, 1), p.cli.push(&.{b})); - try testing.expect(p.cli.take() == null); - try testing.expect(!p.cli.dead); - } - try testing.expectEqual(@as(usize, 1), p.cli.push(reply[reply.len - 1 ..])); - const done = p.cli.take() orelse return error.NoReply; - try testing.expectEqual(tag, done.tag); - try testing.expectEqualStrings("/", done.result.stat.name); -} - -test "9p client: sixteen tags outstanding, and the seventeenth is refused" { - var p: Pair = .{}; - try p.handshake(); - - var tags: [max_tags]u16 = undefined; - for (&tags, 0..) |*t, i| { - t.* = try p.cli.submit(.{ .stat = .{ .fid = 0 } }); - try testing.expectEqual(@as(u16, @intCast(i)), t.*); - } - try testing.expectEqual(max_tags, p.cli.pending()); - try testing.expectError(error.NoTags, p.cli.submit(.{ .stat = .{ .fid = 0 } })); - const owed = p.cli.output().len; - try testing.expectError(error.NoTags, p.cli.submit(.{ .clunk = .{ .fid = 0 } })); - try testing.expectEqual(owed, p.cli.output().len); - - p.wire(); - var seen: [max_tags]bool = @splat(false); - for (0..max_tags) |_| { - const done = p.cli.take() orelse return error.NoReply; - try testing.expectEqual(Client.Op.stat, done.op); - try testing.expect(!seen[done.tag]); - seen[done.tag] = true; - } - for (seen) |s| try testing.expect(s); - try testing.expectEqual(@as(usize, 0), p.cli.pending()); - _ = try p.one(.{ .stat = .{ .fid = 0 } }); -} - -test "9p client: what a caller may not ask for is refused before a tag is spent" { - var p: Pair = .{}; - p.start(); - - try testing.expectError(error.Handshake, p.cli.submit(.{ .stat = .{ .fid = 0 } })); - try p.handshake(); - - try testing.expectError(error.BadRequest, p.cli.submit(.{ .stat = .{ .fid = nofid } })); - try testing.expectError(error.BadRequest, p.cli.submit(.{ .clunk = .{ .fid = nofid } })); - try testing.expectError(error.BadRequest, p.cli.submit(.{ .walk = .{ .fid = 0, .newfid = nofid, .names = &.{} } })); - - try testing.expectError(error.BadRequest, p.cli.submit(.{ .walk = .{ .fid = 0, .newfid = 1, .names = &.{"1/body"} } })); - try testing.expectError(error.BadRequest, p.cli.submit(.{ .walk = .{ .fid = 0, .newfid = 1, .names = &.{""} } })); - const seventeen: [max_welem + 1][]const u8 = @splat("x"); - try testing.expectError(error.BadRequest, p.cli.submit(.{ .walk = .{ .fid = 0, .newfid = 1, .names = &seventeen } })); - - try testing.expectError(error.TooLarge, p.cli.submit(.{ .read = .{ - .fid = 0, - .offset = 0, - .count = p.cli.maxRead() + 1, - } })); - var big: [4096]u8 = @splat('x'); - try testing.expectError(error.TooLarge, p.cli.submit(.{ .write = .{ - .fid = 0, - .offset = 0, - .data = big[0 .. p.cli.maxWrite() + 1], - } })); - p.cli.wrote(p.cli.output().len); - _ = try p.cli.submit(.{ .read = .{ .fid = 0, .offset = 0, .count = p.cli.maxRead() } }); - p.cli.wrote(p.cli.output().len); - _ = try p.cli.submit(.{ .write = .{ .fid = 0, .offset = 0, .data = big[0..p.cli.maxWrite()] } }); - - try testing.expectError(error.Handshake, p.cli.submit(.{ .version = .{} })); - try testing.expectError(error.NoSpace, p.cli.submit(.{ .stat = .{ .fid = 0 } })); -} - -test "9p client: an msize below the floor, and one the server tried to raise" { - var in: [512]u8 = undefined; - var out: [512]u8 = undefined; - var buf: [64]u8 = undefined; - - var c = Client.init(.{ .in = &in, .out = &out }); - try testing.expectError(error.BadRequest, c.submit(.{ .version = .{ .msize = cloud9.Server.msize_min - 1 } })); - _ = try c.submit(.{ .version = .{} }); - try testing.expectEqual(@as(u32, 512), c.asked); - - _ = c.push(try encode(.{ .rversion = .{ .msize = 1024, .version = "9P2000" } }, notag, &buf)); - try testing.expect(c.take() == null); - try testing.expect(c.dead); - - var c2 = Client.init(.{ .in = &in, .out = &out }); - _ = try c2.submit(.{ .version = .{} }); - _ = c2.push(try encode(.{ .rversion = .{ .msize = 512, .version = "unknown" } }, notag, &buf)); - const done = c2.take() orelse return error.NoReply; - try testing.expectEqualStrings("unknown", done.result.version.version); - try testing.expect(!c2.dead); - try testing.expectEqual(@as(u32, 0), c2.msize); - try testing.expectError(error.Handshake, c2.submit(.{ .stat = .{ .fid = 0 } })); - - var c3 = Client.init(.{ .in = &in, .out = &out }); - _ = try c3.submit(.{ .version = .{} }); - _ = c3.push(try encode(.{ .rversion = .{ .msize = 512, .version = "9P2000.u" } }, notag, &buf)); - try testing.expect(c3.take() == null); - try testing.expect(c3.dead); -} - -test "9p client: what is not an answer to one of our requests ends the connection" { - var buf: [64]u8 = undefined; - const Case = struct { - fn armed(in: []u8, out: []u8, scratch: []u8) !Client { - var c = Client.init(.{ .in = in, .out = out }); - _ = try c.submit(.{ .version = .{} }); - c.wrote(c.output().len); - _ = c.push(try encode(.{ .rversion = .{ .msize = 512, .version = "9P2000" } }, notag, scratch)); - _ = c.take() orelse return error.NoReply; - _ = try c.submit(.{ .stat = .{ .fid = 0 } }); - c.wrote(c.output().len); - return c; - } - }; - var in: [512]u8 = undefined; - var out: [512]u8 = undefined; - - { - var c = try Case.armed(&in, &out, &buf); - _ = c.push(try encode(.{ .tstat = .{ .fid = 0 } }, 0, &buf)); - try testing.expect(c.take() == null); - try testing.expect(c.dead); - } - { - var c = try Case.armed(&in, &out, &buf); - _ = c.push(try encode(.rclunk, 3, &buf)); - try testing.expect(c.take() == null); - try testing.expect(c.dead); - } - { - var c = try Case.armed(&in, &out, &buf); - _ = c.push(try encode(.rclunk, 900, &buf)); - try testing.expect(c.take() == null); - try testing.expect(c.dead); - } - { - var c = try Case.armed(&in, &out, &buf); - _ = c.push(try encode(.rclunk, 0, &buf)); - try testing.expect(c.take() == null); - try testing.expect(c.dead); - } - { - var c = try Case.armed(&in, &out, &buf); - _ = c.push(try encode(.rwstat, 0, &buf)); - try testing.expect(c.take() == null); - try testing.expect(c.dead); - } - { - var c = try Case.armed(&in, &out, &buf); - _ = c.push(&.{ 3, 0, 0, 0 }); - try testing.expect(c.take() == null); - try testing.expect(c.dead); - } - { - var c = try Case.armed(&in, &out, &buf); - _ = c.push(&.{ 0, 4, 0, 0 }); - try testing.expect(c.take() == null); - try testing.expect(c.dead); - } - { - var c = try Case.armed(&in, &out, &buf); - _ = c.push(&.{ 8, 0, 0, 0, @intFromEnum(Type.rstat), 0, 0, 0 }); - try testing.expect(c.take() == null); - try testing.expect(c.dead); - } -} - -test "9p client: an Rread longer than the Tread asked for is refused" { - var p: Pair = .{}; - try p.handshake(); - _ = try p.one(.{ .walk = .{ .fid = 0, .newfid = 1, .names = &.{ "1", "body" } } }); - _ = try p.one(.{ .open = .{ .fid = 1, .mode = oread } }); - - const tag = try p.cli.submit(.{ .read = .{ .fid = 1, .offset = 0, .count = 4 } }); - p.cli.wrote(p.cli.output().len); - var buf: [64]u8 = undefined; - _ = p.cli.push(try encode(.{ .rread = .{ .data = "hello, body\n" } }, tag, &buf)); - try testing.expect(p.cli.take() == null); - try testing.expect(p.cli.dead); - - var q: Pair = .{}; - try q.handshake(); - _ = try q.one(.{ .walk = .{ .fid = 0, .newfid = 1, .names = &.{ "1", "body" } } }); - _ = try q.one(.{ .open = .{ .fid = 1, .mode = oread } }); - const short = try q.one(.{ .read = .{ .fid = 1, .offset = 0, .count = 4 } }); - try testing.expectEqualStrings("hell", short.result.read); -} - -test "9p client: hangup and a dead connection refuse everything after" { - var p: Pair = .{}; - try p.handshake(); - p.cli.hangup(); - try testing.expectEqual(@as(usize, 0), p.cli.pending()); - try testing.expectEqual(@as(usize, 0), p.cli.output().len); - try testing.expectEqual(@as(usize, 0), p.cli.push("anything")); - try testing.expect(p.cli.take() == null); - try testing.expectError(error.Dead, p.cli.submit(.{ .stat = .{ .fid = 0 } })); - try testing.expectError(error.Dead, p.cli.submit(.{ .version = .{} })); -} - -test "9p client: session memory is bounded independently of input" { - try testing.expect(@sizeOf(Client) <= 512); - try testing.expect(2 * 8192 + @sizeOf(Client) <= 17 * 1024); - try testing.expect(2 * cloud9.Server.msize_min + @sizeOf(Client) <= 700); + try testing.expect(min_msize >= msize_min); } diff --git a/src/9p_io.zig b/src/9p_io.zig index d0db1c86..57ce67b5 100644 --- a/src/9p_io.zig +++ b/src/9p_io.zig @@ -138,7 +138,7 @@ fn localIp(address: std.Io.net.IpAddress) bool { return false; } -const Srv = ninep.Server(pardes.ctlfs, ninep.max_fids); +const Srv = ninep.Server(pardes.ctlfs, ninep.editor); const Conn = struct { fd: c_int = -1, diff --git a/src/esp32p4_9p.zig b/src/esp32p4_9p.zig index f6f66c15..e23235a0 100644 --- a/src/esp32p4_9p.zig +++ b/src/esp32p4_9p.zig @@ -26,7 +26,7 @@ comptime { } const Fs = gpio.Fs(Pads); -const Server = ninep.Server(Fs, ninep.board_fids); +const Server = ninep.Server(Fs, ninep.board); comptime { std.debug.assert(@typeInfo(@FieldType(Server, "fids")).array.len == 32); diff --git a/src/esp32p4_gpio.zig b/src/esp32p4_gpio.zig index 92468581..d6c29a36 100644 --- a/src/esp32p4_gpio.zig +++ b/src/esp32p4_gpio.zig @@ -1,5 +1,6 @@ //! ESP32-P4 JP1 GPIO data and its freestanding filesystem. const std = @import("std"); +const ninep = @import("9p.zig"); // JP1: JC-ESP32P4-M3-DEV schematic, sheet 2 "Expand IO": // 01-esp32p4-m3/docs/schematics/2_EXPAND_IO&BAT.png @@ -107,11 +108,7 @@ pub const Header = struct { } }; -pub const E = struct { - pub const NOENT: u16 = 2; - pub const NOTDIR: u16 = 20; - pub const INVAL: u16 = 22; -}; +pub const E = ninep.fs.E; pub const root: u64 = 1; const gpio_node: u64 = 16; @@ -167,43 +164,10 @@ const out_capacity = size: { pub fn Fs(comptime Pads: type) type { return struct { const Self = @This(); - pub const name_capacity = 28; - - pub const Op = enum(u8) { lookup, getattr, setattr, open, read, write, release, readdir }; - - pub const Status = enum(u8) { ok, again, err }; - - pub const Req = struct { - tag: u64, - op: Op, - node: u64, - handle: u32 = 0, - off: u64 = 0, - size: u32 = 0, - data: []const u8 = &.{}, - truncate: bool = false, - }; - - pub const Reply = struct { - tag: u64, - status: Status = .ok, - errno: u16 = 0, - attr: Attr = .{}, - handle: u32 = 0, - written: u32 = 0, - - pub const Attr = struct { - name: []const u8 = "", - node: u64 = 0, - dir: bool = false, - size: u64 = 0, - mode: u16 = 0o600, - }; - - pub fn fail(tag: u64, e: u16) Reply { - return .{ .tag = tag, .status = .err, .errno = e }; - } - }; + pub const Op = ninep.fs.Op; + pub const Status = ninep.fs.Status; + pub const Req = ninep.fs.Req; + pub const Reply = ninep.fs.Reply; // Reply bytes are borrowed until the next handle call. pub const Answer = struct { reply: Reply, bytes: []const u8 = "" }; @@ -484,7 +448,7 @@ fn names(t: *Board, node: u64, skip: u64) ![][]const u8 { test "GPIO: the whole tree costs one buffer, and the table says how big" { try testing.expectEqual(@as(usize, 143), out_capacity); try testing.expectEqual(@as(usize, 143), @sizeOf(Board)); - try testing.expectEqual(@as(usize, 28), Board.name_capacity); + try testing.expectEqual(@as(usize, 28), ninep.board.name_capacity); try testing.expect(Header.text.len > out_capacity); } @@ -511,11 +475,9 @@ test "GPIO: stat and truncation preserve the register value and reads respect of try testing.expectEqualStrings(Header.text[10..22], text.bytes); } -const ninep = @import("9p.zig"); - test "GPIO: a real 9P client reads a pin's value off this tree" { StubPads.reset(); - const Server = ninep.Server(Board, ninep.board_fids); + const Server = ninep.Server(Board, ninep.board); var in: [1024]u8 = undefined; var out: [2048]u8 = undefined; var fsys: Board = .{}; diff --git a/src/ninep/tree.zig b/src/ninep/tree.zig index f716bf5f..56c3112d 100644 --- a/src/ninep/tree.zig +++ b/src/ninep/tree.zig @@ -1,11 +1,14 @@ //! The control tree served over 9P: its nodes, lookup, readdir and the -//! dispatch that answers the engine in src/9p.zig. The backend contract -//! (Req, Reply, Op, Status, E) lives here; fs.zig keeps host access and mounts. +//! dispatch that answers the engine (cloud9.fs.Server, configured in +//! src/9p.zig). The backend contract (Req, Reply, Op, Status, E) is cloud9's, +//! extended here with the editor's reply payload; fs.zig keeps host access +//! and mounts. //! //! /README /index /ctl /new /log /screen /listeners //! /pane//{name,body,tag,ctl,addr,data,xdata,sel,errors,event,pty/} //! /os/... the host filesystem /src/... embedded sources (opt-in) const std = @import("std"); +const cloud9 = @import("cloud9"); const pardes = @import("../pardes.zig"); const fs = @import("../fs.zig"); pub const events = @import("events.zig"); @@ -22,84 +25,35 @@ const MAX_PANES = pardes.MAX_PANES; pub const name_capacity: usize = 255; -// ---- the backend contract ---- - -pub const Op = enum(u8) { - lookup, - getattr, - setattr, - open, - read, - write, - release, - readdir, -}; +comptime { + // The editor's engine (src/9p.zig) remembers names this long. + std.debug.assert(@import("../9p.zig").editor.name_capacity == name_capacity); +} -pub const Status = enum(u8) { - ok, - again, - err, -}; +// ---- the backend contract: cloud9.fs, with the editor's payload locator ---- -pub const Req = struct { - tag: u64, - op: Op, - node: u64, - handle: u32 = 0, - off: u64 = 0, - size: u32 = 0, - data: []const u8 = &.{}, - truncate: bool = false, - - pub fn changesPane(req: Req) bool { - return switch (req.op) { - .write, .setattr => true, - .open => req.node == @intFromEnum(TopFile.new), - .lookup, .getattr, .read, .release, .readdir => false, - }; - } +pub const Op = cloud9.fs.Op; +pub const Status = cloud9.fs.Status; +pub const Req = cloud9.fs.Req; +pub const E = cloud9.fs.E; + +/// Where a reply's bytes live. The engine ignores it; `Pardes.fsPayload` +/// resolves it into the slice that travels beside the reply. +pub const Payload = union(enum) { + none, + staged: u32, + region: struct { pane: u8, serial: u32, off: u32, len: u32 }, }; -pub const Reply = struct { - tag: u64, - status: Status = .ok, - errno: u16 = 0, - attr: Attr = .{}, - handle: u32 = 0, - payload: Payload = .none, - written: u32 = 0, - - pub const Attr = struct { - name: []const u8 = "", - node: u64 = 0, - dir: bool = false, - size: u64 = 0, - mode: u16 = 0o644, - mtime: u32 = 0, - }; +pub const Reply = cloud9.fs.ReplyWith(Payload); - pub const Payload = union(enum) { - none, - staged: u32, - region: struct { pane: u8, serial: u32, off: u32, len: u32 }, +pub fn changesPane(req: Req) bool { + return switch (req.op) { + .write, .setattr => true, + .open => req.node == @intFromEnum(TopFile.new), + .lookup, .getattr, .read, .release, .readdir => false, }; - - pub fn fail(tag: u64, e: u16) Reply { - return .{ .tag = tag, .status = .err, .errno = e }; - } -}; - -pub const E = struct { - pub const PERM: u16 = 1; - pub const NOENT: u16 = 2; - pub const IO: u16 = 5; - pub const NOMEM: u16 = 12; - pub const NOTDIR: u16 = 20; - pub const INVAL: u16 = 22; - pub const NFILE: u16 = 23; - pub const NOSPC: u16 = 28; - pub const NOSYS: u16 = 38; -}; +} pub const out_reserve = 4 * 1024; diff --git a/src/pardes.zig b/src/pardes.zig index 88442542..ed71102e 100644 --- a/src/pardes.zig +++ b/src/pardes.zig @@ -7049,7 +7049,7 @@ pub const Pardes = struct { p.shell_rows.sweep(p.gpa); switch (ev) { .tick => {}, - .fs_req => |req| if (req.changesPane()) { + .fs_req => |req| if (ctlfs.changesPane(req)) { p.raw_hover_intent = false; p.cancelLookHover(); }, -- cgit v1.3 From 44ce573e15c773cf5bb0d42941a143b63e44d900 Mon Sep 17 00:00:00 2001 From: Gabriel Schneider Date: Mon, 21 Sep 2026 14:55:53 -0300 Subject: Make the macOS shell a first-class host MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Pty children are exec'd with their own TERM/COLORTERM/TERM_PROGRAM instead of inheriting a .app launch's empty environment, and ttyTaken finally answers on darwin — libproc walks the tty's foreground process group — so Escape reaches the child and Exec stops believing every pane sits at its prompt. The occupancy suite runs on both platforms now. The workspace tag row moves into the native menu bar as a Builtins menu. -Dworkspace-tag (default off for -Dplatform=macos, on everywhere else) drives it, and Pardes.topBarHeight replaces the TOPBAR_H constant so the core stops reserving the row. The view pins every variable-font axis to the file's own default (Maple Mono came up Thin otherwise), shapes ligatures, carries per-shape pointer cursors, and draws the look-hover affordance as refracted glass. Tag rows fill edge to edge, with the anchor box painted back on top of that fill and its mode glyph centred on the same square. Theme accents re-saturated across the set. Co-Authored-By: Claude Opus 5 (1M context) --- build.zig | 8 + docs/config.md | 1 + docs/macos.md | 38 +++- src/CHANGELOG.md | 12 ++ src/config.zig | 15 ++ src/gui/gui.zig | 22 +- src/host_io.zig | 320 +++++++++++++++++++++++++--- src/layout.zig | 8 +- src/macos.zig | 58 ++++-- src/macos/Sources/AppDelegate.swift | 18 +- src/macos/Sources/PardesView.swift | 406 +++++++++++++++++++++++++++++++++--- src/macos/pardes.h | 12 +- src/pardes.zig | 149 ++++++++----- src/themes/acme.zig | 8 +- src/themes/atelier.zig | 32 +-- src/themes/clay.zig | 32 +-- src/themes/dark.zig | 12 +- src/themes/daybreak.zig | 28 +-- src/themes/dusk.zig | 32 +-- src/themes/forge.zig | 28 +-- src/themes/forge_black.zig | 28 +-- src/themes/forge_soft.zig | 28 +-- src/themes/harvest.zig | 32 +-- src/themes/helix.zig | 6 +- src/themes/ink.zig | 18 +- src/themes/lagoon.zig | 24 +-- src/themes/orchard.zig | 32 +-- src/themes/orchard_black.zig | 32 +-- src/themes/paper.zig | 32 +-- src/themes/solarium.zig | 32 +-- src/themes/spectrum.zig | 22 +- src/web.zig | 2 +- test/macos_e2e.swift | 10 +- 33 files changed, 1160 insertions(+), 377 deletions(-) (limited to 'src/pardes.zig') diff --git a/build.zig b/build.zig index 6734d9b0..0cd7f312 100644 --- a/build.zig +++ b/build.zig @@ -301,6 +301,9 @@ pub fn build(b: *std.Build) void { const esp32p4_cols = b.option(u16, "esp32p4-cols", "the board's grid width in cells (-Dplatform=esp32p4 only)") orelse 56; const esp32p4_rows = b.option(u16, "esp32p4-rows", "the board's grid height in cells (-Dplatform=esp32p4 only)") orelse 14; const theme_animation = b.option(bool, "theme-animation", "animate chrome colors across a theme change (default: off for esp32p4)"); + // The macOS shell carries the workspace tag row's commands in its native + // menu bar; the row itself goes away. `-Dworkspace-tag=true` puts it back. + const workspace_tag = b.option(bool, "workspace-tag", "draw the workspace tag row (default: on except on macOS, whose menu bar carries its commands)"); const shell_cfg: ShellConfig = .{ .tree_sitter_grammars = tree_sitter_grammars, .tracy = tracy != null, @@ -309,6 +312,7 @@ pub fn build(b: *std.Build) void { .esp32p4_cols = esp32p4_cols, .esp32p4_rows = esp32p4_rows, .theme_animation = theme_animation, + .workspace_tag = workspace_tag, .prebuilt_shaders = prebuilt_shaders, .embed_sources = embed_sources, .zig_lib_dir = b.graph.zig_lib_directory.path orelse "", @@ -1434,6 +1438,9 @@ const ShellConfig = struct { /// null = "the platform's own default", resolved per shell below, because /// the default is off for the board and on everywhere else. theme_animation: ?bool, + /// null = "the platform's own default": the macOS shell hands the row to + /// its native menu bar, every other shell keeps the acme topbar. + workspace_tag: ?bool, prebuilt_shaders: bool, embed_sources: bool, zig_lib_dir: []const u8, @@ -1452,6 +1459,7 @@ fn shellOptions(b: *std.Build, cfg: ShellConfig, platform: Platform) *std.Build. o.addOption(bool, "mupdf", cfg.mupdf); o.addOption(u16, "esp32p4_cols", cfg.esp32p4_cols); o.addOption(u16, "esp32p4_rows", cfg.esp32p4_rows); + o.addOption(bool, "workspace_tag", cfg.workspace_tag orelse (platform != .macos)); o.addOption(bool, "theme_animation", cfg.theme_animation orelse (platform != .esp32p4)); // Meaningful only for the SDL shell. Keeping the platform condition here // prevents Config/EffectCode from describing tty/macOS/web as "prebuilt". diff --git a/docs/config.md b/docs/config.md index a55aef1c..a229830b 100644 --- a/docs/config.md +++ b/docs/config.md @@ -538,6 +538,7 @@ including the standard `-Dtarget` and `-Doptimize` options. | `-Djpx` | bool | `true` — JPEG 2000, and with it scanned PDFs | | `-Dtree-sitter` | `disabled`, `zig`, `minimal`, `full` | `full` natively, `zig` for web, `disabled` for esp32p4 | | `-Dtheme-animation` | bool | on everywhere except `-Dplatform=esp32p4` | +| `-Dworkspace-tag` | bool; draw the workspace tag row — the macOS shell hands its commands to the native menu bar instead | on except on `-Dplatform=macos` | | `-Dprebuilt-shaders` | bool | on for a bare `zig build`, off when `-Dplatform` names a shell | | `-Dtracy` | path to a Tracy source checkout | off | | `-Dmacos-identity` | codesigning identity for `pardes.app` | `-` (ad-hoc) | diff --git a/docs/macos.md b/docs/macos.md index 9190ca67..e104d3a6 100644 --- a/docs/macos.md +++ b/docs/macos.md @@ -369,6 +369,14 @@ second spelling of builtins — `AppDelegate` calls `run("New")`, `run("Save")`, `run("Help")`, `run("Tutor")` — and the items with no builtin behind them are left out rather than stubbed. +The workspace tag row — the topmost tagline, the one carrying `Newcol Joincol +Find Grep …` — is not drawn on this shell. `-Dworkspace-tag` (default off for +`-Dplatform=macos`, on everywhere else) hands the row to the menu bar: the +core stops reserving the row (`Pardes.topBarHeight`), the grid starts at the +column tags, and the row's commands live in a **Builtins** menu instead. The +items are the tag's own words, spelled exactly as a tag Exec would type them, +and nothing in that menu is editable — it is the tag's buttons, not the tag: + | menu | item | chord | what it does | |---|---|---|---| | pardes | About pardes | — | AppKit's panel | @@ -378,6 +386,7 @@ left out rather than stubbed. | | New | ⌘N | the `New` builtin | | | Save | ⌘S | the `Save` builtin | | | Close Window | ⌘W | AppKit; the app terminates after the last one | +| Builtins | Newcol / Joincol / Find / Grep / Changelog / Dump / NextColor / Debug / Kill | — | the workspace tag's own builtins, `run(word)` | | Edit | Paste | ⌘V | the view's own paste path, not a second one | | View | Zoom In / Zoom Out / Actual Size | ⌘= / ⌘- / ⌘0 | point size, host-side | | Window | Minimize / Zoom | ⌘M / — | AppKit | @@ -455,6 +464,32 @@ Nested launches use the same inherited 9P address and pane serial as other native hosts. They do not inspect ancestor processes or executable names. See [the control filesystem](fs.md) for paths and transports. +Two more things this host cannot inherit from its launcher, because a `.app` +has none: + +- **The terminal's identity.** `host_io.ChildEnv` writes `TERM`, `COLORTERM` + and `TERM_PROGRAM` over whatever the environment carried and the child is + `execve`'d with that array — built before the fork, because a `setenv` + between fork and exec can deadlock on the heap a pty reader thread was + holding. Every pane is emulated by the bundled VT, so the value describes + pardes and never the terminal pardes was started from; `-Dplatform=gui` and + the tty shell take the same path, where the difference is only that their + launcher usually happened to set something. The names come from + `config.child_term` / `child_colorterm` / `child_term_program`, and `TERM` + is deliberately `xterm-256color` rather than a name with no installed + terminfo entry — `clear`, colour and cursor addressing all resolve through + that lookup. +- **Whether a program has the terminal.** `host_io.ttyTaken` is what + `Pardes.takesCommandLine` asks before deciding that Escape is the `Last` + builtin rather than a keystroke for the child, and what `Exec` asks before + believing a pane is at its prompt. Linux descends `/proc//task// + children`; darwin has neither that nor a children list, so it enumerates the + tty's foreground process group with `proc_listpids(PROC_PGRP_ONLY)` and + compares each member's `proc_pidpath` against the shell's own. A nested + interactive shell is therefore still a prompt, and `bash -c 'sleep 30'` is + still taken — the wrapper wears the shell's binary, but `sleep` shares its + group. The occupancy suite in `src/host_io.zig` runs on both platforms. + ## Fonts and zoom The face is the shell's business and the size is the window's, so the two are @@ -1109,9 +1144,6 @@ used for the table and is not folded into the direct-path claim. says nothing either. Wiring it up means a unix-socket frontend loop beside the AppKit one, which is `src/detached/client.zig`'s job in the tty and SDL shells; see `docs/detached.md`. -- **`tty_taken` on darwin.** The pull is wired (`ttyTaken`, `src/macos.zig:1838`) - but `look.ttyTaken` has no libproc implementation and answers `false`, so an - `Exec` here always believes the pane is still at the prompt it forked. - **IME and marked text.** Only finished characters reach `pardes_key`, so a dead key composes nothing and Option is Alt rather than a compose modifier. Real composition means implementing `NSTextInputClient` *and* giving the core diff --git a/src/CHANGELOG.md b/src/CHANGELOG.md index 18bcceb9..e518f97a 100644 --- a/src/CHANGELOG.md +++ b/src/CHANGELOG.md @@ -2,6 +2,18 @@ ## 0.0.3 +- Give pty children their own terminal identity. `TERM`, `COLORTERM` and + `TERM_PROGRAM` are now written by pardes rather than inherited from whatever + launched it, and the child is exec'd with that environment. A macOS `.app` + launch supplies no `TERM` at all, so until now `clear` failed, nothing + painted a colour, and every cursor-addressing program fell back to printing + lines. +- Answer tty occupancy on macOS. `ttyTaken` had no darwin implementation and + said `false` for every pane, which made `Pardes.takesCommandLine` permanently + true: a bare Escape in a raw terminal ran the `Last` builtin instead of + reaching the child, and `Exec` always believed the pane sat at its prompt. + libproc answers it from the tty's foreground process group, and the + occupancy suite now runs on both platforms instead of only Linux. - Flatten the 9P control tree: `self/` is gone, so `/index`, `/pane//`, `/screen` and `/os` sit at the root. `/new` is one clone file (reading it makes a pane and answers its serial), `/ctl` takes `look TEXT` and diff --git a/src/config.zig b/src/config.zig index 440549b3..da23f51f 100644 --- a/src/config.zig +++ b/src/config.zig @@ -222,6 +222,17 @@ pub const tty_blank: enum { prompt, prompt_and_input } = .prompt; // Projected colors below this contrast use the theme's more legible anchor. pub const tty_filter_min_contrast: f64 = 1.5; +// What a pty child is told it is talking to. Every pane is emulated by the +// bundled VT, so this describes pardes and never the terminal pardes itself +// was launched from — the child inherits the launcher's TERM otherwise, which +// under a macOS .app launch is no TERM at all, and `clear`, colour and every +// cursor-addressing program fail at the terminfo lookup. There is no installed +// `xterm-ghostty` entry to name, and a name with no entry is worse than a +// conservative one that every system ships. +pub const child_term = "xterm-256color"; +pub const child_colorterm = "truecolor"; +pub const child_term_program = "pardes"; + pub const topbar_str = "Newcol Joincol Find Grep Help Changelog Tutor Dump NextColor Debug Kill"; pub const pane_builtins_str = "Tty Del Collapse"; @@ -538,6 +549,10 @@ pub const Runtime = struct { tree_context_tag_style: bool = true, debug: bool = false, focus_tint: bool = true, + /// The workspace tag row. Native shells with their own chrome (the macOS + /// menu bar) turn it off and carry its commands there instead; the core + /// keeps the row as the acme tradition everywhere else. + workspace_tag: bool = true, column_tags: bool = true, syntax_bold: bool = false, window_opacity: u8 = 100, diff --git a/src/gui/gui.zig b/src/gui/gui.zig index 27f3346c..d871e55e 100644 --- a/src/gui/gui.zig +++ b/src/gui/gui.zig @@ -5290,10 +5290,12 @@ test "tagline bands face the topbar rule and Tagbottom faces the window edge" { const canvas_h: f32 = 200; const border = topbarPaneBorderPixels(cell_h, tagline_h); try std.testing.expectEqual(@as(u32, 1), border); - try std.testing.expectEqual(@as(u32, 4), taglineBandOffset(0, canvas_h, cell_h, tagline_h)); - try std.testing.expectEqual(@as(u32, 1), taglineBandOffset(1, canvas_h, cell_h, tagline_h)); - try std.testing.expectEqual(@as(u32, 2), taglineBandOffset(5, canvas_h, cell_h, tagline_h)); - try std.testing.expectEqual(@as(u32, 4), taglineBandOffset(9, canvas_h, cell_h, tagline_h)); + try std.testing.expectEqual(@as(u32, 4), taglineBandOffset(0, canvas_h, cell_h, tagline_h, true)); + try std.testing.expectEqual(@as(u32, 2), taglineBandOffset(0, canvas_h, cell_h, tagline_h, false)); + try std.testing.expectEqual(@as(u32, 1), taglineBandOffset(1, canvas_h, cell_h, tagline_h, true)); + try std.testing.expectEqual(@as(u32, 2), taglineBandOffset(1, canvas_h, cell_h, tagline_h, false)); + try std.testing.expectEqual(@as(u32, 2), taglineBandOffset(5, canvas_h, cell_h, tagline_h, true)); + try std.testing.expectEqual(@as(u32, 4), taglineBandOffset(9, canvas_h, cell_h, tagline_h, true)); } fn resolveCell(g: *Gui, cell: *const pardes.Cell, role: pardes.FontRole, is_cursor: bool, page: Ground) ResolvedCell { @@ -5486,7 +5488,7 @@ fn emitBodyLayer(g: *Gui, instances: [*]CellInstance, next: *u32, layer: *const if (left + @as(f32, @floatFromInt(col)) * width >= right) break; const cell = &layer.cells[index * layer.cols + col]; const cursor = if (layer.cursor) |cu| show_cursor and !cu.bar and cu.x == col and cu.y == row else false; - const glyph_top = top - (if (header) @as(f32, @floatFromInt(taglineBandOffset(0, win_h, g.cell_h, g.tagline_height))) else 0); + const glyph_top = top - (if (header) @as(f32, @floatFromInt(taglineBandOffset(0, win_h, g.cell_h, g.tagline_height, true))) else 0); emitInstance(g, instances, next.*, 0, 0, .{ .w = width, .h = height, .x_off = left + @as(f32, @floatFromInt(col)) * width, .y_off = glyph_top }, win_w, win_h, track, role, cell, old_layer, cursor, page); clipBodyInstance(&instances[next.*], bottom, win_h); clipInstanceRight(&instances[next.*], right, win_w); @@ -5638,7 +5640,7 @@ fn emitInstance( else layout.h; const band_offset: f32 = if (resolved.role == .tagline) - @floatFromInt(taglineBandOffset(row, win_h, g.cell_h, g.tagline_height)) + @floatFromInt(taglineBandOffset(row, win_h, g.cell_h, g.tagline_height, true)) else 0; const py0 = layout.y_off + @as(f32, @floatFromInt(row)) * layout.h + band_offset; @@ -6448,7 +6450,7 @@ fn addCursorBar( const x0 = layout.x_off + @as(f32, @floatFromInt(x)) * layout.w; const height = std.math.clamp(visual_height, 1.0, layout.h); const y0 = layout.y_off + @as(f32, @floatFromInt(y)) * layout.h + - @as(f32, @floatFromInt(taglineBandOffset(y, builder.win_h, @intFromFloat(layout.h), @intFromFloat(height)))); + @as(f32, @floatFromInt(taglineBandOffset(y, builder.win_h, @intFromFloat(layout.h), @intFromFloat(height), true))); builder.addRect( x0, y0, @@ -6548,7 +6550,7 @@ fn buildOverlay( const right = left + @as(f32, @floatFromInt(layer.viewport.w)) * layout.w; const x = left + @as(f32, @floatFromInt(cursor.col)) * width; if (x >= right) continue; - const top = @as(f32, @floatFromInt(layer.viewport.y)) * layout.h + @as(f32, @floatFromInt(taglineBandOffset(layer.viewport.y, builder.win_h, g.cell_h, g.tagline_height))); + const top = @as(f32, @floatFromInt(layer.viewport.y)) * layout.h + @as(f32, @floatFromInt(taglineBandOffset(layer.viewport.y, builder.win_h, g.cell_h, g.tagline_height, true))); builder.addRect(x, top, @min(right, x + @max(1, width / 8)), top + @as(f32, @floatFromInt(g.tagline_height)), overlayRgb(cursorColor(core, &layer.cells[cursor.col], .tagline))); }; if (transient_on) appendTouchOverlay(g, &builder, debug_on); @@ -6569,7 +6571,7 @@ fn appendWorkspacePet(g: *Gui, core: ?*const pardes.Pardes, surface: *const pard if (cellCodepoint(cell) != ' ') occupied = i + 1; } const editing = p.topbar_col != null and p.header_column == null; - const band_top: f32 = @floatFromInt(taglineBandOffset(0, builder.win_h, g.cell_h, g.tagline_height)); + const band_top: f32 = @floatFromInt(taglineBandOffset(0, builder.win_h, g.cell_h, g.tagline_height, true)); const region = if (occupied >= surface.cols) null else pet.lane( occupied, @floatFromInt(g.tagline_width), @@ -6741,7 +6743,7 @@ fn appendTagGrips(g: *const Gui, surface: *const pardes.Surface, layout: CellLay else => continue, }; const center_x = (@as(f32, @floatFromInt(x)) + @as(f32, @floatFromInt(config.GUTTER)) / 2) * layout.w; - const center_y = @as(f32, @floatFromInt(y)) * layout.h + @as(f32, @floatFromInt(taglineBandOffset(y, builder.win_h, g.cell_h, g.tagline_height))) + @as(f32, @floatFromInt(g.tagline_height)) / 2; + const center_y = @as(f32, @floatFromInt(y)) * layout.h + @as(f32, @floatFromInt(taglineBandOffset(y, builder.win_h, g.cell_h, g.tagline_height, true))) + @as(f32, @floatFromInt(g.tagline_height)) / 2; const half_w = @max(1, @min(3, layout.w - 2)); builder.addRect(@floor(center_x - half_w), @floor(center_y - 2), @floor(center_x + half_w), @floor(center_y - 1), overlayRgb(rgb)); builder.addRect(@floor(center_x - half_w), @floor(center_y + 1), @floor(center_x + half_w), @floor(center_y + 2), overlayRgb(rgb)); diff --git a/src/host_io.zig b/src/host_io.zig index 212c23b4..55592957 100644 --- a/src/host_io.zig +++ b/src/host_io.zig @@ -837,6 +837,7 @@ pub const Shell = struct { extern "c" fn forkpty(amaster: *c_int, name: ?[*:0]u8, termp: ?*const anyopaque, winp: ?*const posix.winsize) c_int; extern "c" fn execv(path: [*:0]const u8, argv: [*:null]const ?[*:0]const u8) c_int; +extern "c" fn execve(path: [*:0]const u8, argv: [*:null]const ?[*:0]const u8, envp: [*:null]const ?[*:0]const u8) c_int; extern "c" fn chdir(path: [*:0]const u8) c_int; extern "c" fn _exit(status: c_int) noreturn; @@ -845,6 +846,100 @@ pub const Child = struct { pid: posix.pid_t, }; +/// The environment a pty child is handed: everything this process carries, +/// with the terminal's own identity written over whatever the launcher left +/// behind. The child is talking to the bundled VT, never to the terminal +/// pardes itself was started from, and a macOS `.app` launch supplies no +/// `TERM` at all — which is exactly why `clear` fails there, why nothing +/// paints a colour, and why every cursor-addressing program falls back to a +/// dumb line-at-a-time mode. +pub const ChildEnv = struct { + /// Entries pardes owns. The name of each is read back out of its own + /// spelling, so there is one place to edit and no second list to drift. + const own = [_][*:0]const u8{ + "TERM=" ++ pardes.config.child_term, + "COLORTERM=" ++ pardes.config.child_colorterm, + "TERM_PROGRAM=" ++ pardes.config.child_term_program, + }; + + /// Wide enough for any real environment; `build` answers null rather than + /// truncate, because a child missing half its variables is a worse bug + /// than one missing TERM, and the caller then execs with `environ` intact. + pub const Slots = [1024]?[*:0]const u8; + + fn name(entry: [*:0]const u8) []const u8 { + const line = std.mem.span(entry); + return line[0 .. std.mem.indexOfScalar(u8, line, '=') orelse line.len]; + } + + pub fn build(slots: *Slots) ?[*:null]const ?[*:0]const u8 { + var n: usize = 0; + var i: usize = 0; + while (libc.environ[i]) |entry| : (i += 1) { + const inherited = name(entry); + const shadowed = for (own) |mine| { + if (std.mem.eql(u8, inherited, name(mine))) break true; + } else false; + if (shadowed) continue; + if (n + own.len + 1 > slots.len) return null; + slots[n] = entry; + n += 1; + } + for (own) |mine| { + slots[n] = mine; + n += 1; + } + slots[n] = null; + return @ptrCast(slots); + } +}; + +test "the child environment replaces the launcher's terminal identity exactly once" { + const saved: ?[]const u8 = if (libc.getenv("TERM")) |t| std.mem.span(t) else null; + var saved_buf: [256]u8 = undefined; + const restore: ?[:0]const u8 = if (saved) |t| blk: { + if (t.len >= saved_buf.len) break :blk null; + @memcpy(saved_buf[0..t.len], t); + saved_buf[t.len] = 0; + break :blk saved_buf[0..t.len :0]; + } else null; + defer if (restore) |t| { + _ = Shell.setenv("TERM", t.ptr, 1); + } else { + _ = unsetenv("TERM"); + }; + + // A launcher TERM must be shadowed rather than duplicated, and the rest of + // the environment must arrive untouched. + try std.testing.expectEqual(@as(c_int, 0), Shell.setenv("TERM", "dumb", 1)); + try std.testing.expectEqual(@as(c_int, 0), Shell.setenv("PARDES_CHILD_ENV_PROBE", "1", 1)); + defer _ = unsetenv("PARDES_CHILD_ENV_PROBE"); + + var slots: ChildEnv.Slots = undefined; + const envp = ChildEnv.build(&slots) orelse return error.EnvironmentTooLarge; + var terms: usize = 0; + var colorterms: usize = 0; + var probes: usize = 0; + var dumb = false; + var i: usize = 0; + while (envp[i]) |entry| : (i += 1) { + const line = std.mem.span(entry); + if (std.mem.startsWith(u8, line, "TERM=")) terms += 1; + if (std.mem.startsWith(u8, line, "COLORTERM=")) colorterms += 1; + if (std.mem.eql(u8, line, "TERM=dumb")) dumb = true; + if (std.mem.eql(u8, line, "PARDES_CHILD_ENV_PROBE=1")) probes += 1; + } + try std.testing.expectEqual(@as(usize, 1), terms); + try std.testing.expectEqual(@as(usize, 1), colorterms); + try std.testing.expectEqual(@as(usize, 1), probes); + try std.testing.expect(!dumb); + // TERM_PROGRAM shares the prefix "TERM"; the match is on the name, so it + // is a separate entry and never a second TERM. + try std.testing.expectEqualStrings("TERM=" ++ pardes.config.child_term, std.mem.span(envp[i - ChildEnv.own.len].?)); +} + +extern "c" fn unsetenv(name: [*:0]const u8) c_int; + pub fn forkShell( core: ?*pardes.Pardes, pane: usize, @@ -888,6 +983,11 @@ pub fn forkShell( try @import("linux/v9fs.zig").writeLaunchCommand(&command.writer, path, std.mem.span(socket), &spawn.argv); if (!try pardes.panes.Terminal.queuePendingCommand(pn, command.written())) return error.ShellAlreadyStarted; } + // Built here and not after the fork: between fork and exec the child may + // not call setenv, whose malloc can deadlock against a pty reader thread + // that held the heap when the fork took its snapshot. + var env_slots: ChildEnv.Slots = undefined; + const envp = ChildEnv.build(&env_slots); const ws = posix.winsize{ .row = rows, .col = cols, .xpixel = 0, .ypixel = 0 }; const pid = forkpty(&master, null, null, &ws); if (pid < 0) return error.ForkFailed; @@ -896,6 +996,7 @@ pub fn forkShell( posix.sigaddset(&set, posix.SIG.WINCH); posix.sigprocmask(posix.SIG.UNBLOCK, &set, null); if (cwd_z) |path| if (chdir(path.ptr) != 0) _exit(126); + if (envp) |env| _ = execve(spawn.path, &spawn.argv, env); _ = execv(spawn.path, &spawn.argv); _exit(127); } @@ -925,6 +1026,42 @@ test "shell spawn rejects invalid directories before creating a child" { try std.testing.expectError(error.FileNotFound, forkShell(null, 0, &rcs, "/bin/sh", missing, 24, 80, null)); } +test "a forked shell is told which terminal it is talking to" { + if (!haveFile("/bin/sh")) return error.SkipZigTest; + // Whatever launched the test is the wrong answer, so make it a loud one. + const saved = libc.getenv("TERM"); + var saved_buf: [256]u8 = undefined; + const restore: ?[:0]const u8 = if (saved) |t| blk: { + const span = std.mem.span(t); + if (span.len >= saved_buf.len) break :blk null; + @memcpy(saved_buf[0..span.len], span); + saved_buf[span.len] = 0; + break :blk saved_buf[0..span.len :0]; + } else null; + defer if (restore) |t| { + _ = Shell.setenv("TERM", t.ptr, 1); + } else { + _ = unsetenv("TERM"); + }; + _ = Shell.setenv("TERM", "dumb", 1); + + const rcs: Shell.PromptFiles = .{}; + const child = try forkShell(null, 0, &rcs, "/bin/sh", "", 24, 80, null); + defer { + _ = libc.kill(child.pid, libc.SIG.KILL); + _ = libc.waitpid(child.pid, null, 0); + _ = libc.close(child.file.handle); + } + var sh: TestShell = .{ .master = child.file.handle, .pid = child.pid }; + // The echoed command carries the unexpanded `$TERM`, so only the shell's + // own expansion can match this. + try std.testing.expect(writeFd(child.file.handle, "printf '\nPARDES-TERM:%s:%s\n' \"$TERM\" \"$COLORTERM\"; exit\n")); + try std.testing.expect(sh.waitText( + "PARDES-TERM:" ++ pardes.config.child_term ++ ":" ++ pardes.config.child_colorterm, + 5_000, + )); +} + test "shell spawn uses an explicit OS directory longer than 256 bytes" { if (!haveFile("/bin/sh")) return error.SkipZigTest; var tmp = std.testing.tmpDir(.{}); @@ -1031,6 +1168,14 @@ extern "c" fn tcgetpgrp(fd: c_int) libc.pid_t; const occ_max_depth: u8 = 8; const occ_max_visited: usize = 32; +/// Where `ttyTaken` answers from evidence rather than from `false`. The two +/// implementations are different walks over the same question, so they share +/// one suite rather than each asserting half of it. +const tty_probe_platform = switch (builtin.os.tag) { + .linux, .macos => true, + else => false, +}; + const TtyProbe = struct { self_exe: [std.fs.max_path_bytes]u8 = undefined, exe: [std.fs.max_path_bytes]u8 = undefined, @@ -1085,10 +1230,94 @@ pub fn ttyTaken(shell_pid: libc.pid_t, master_fd: c_int) bool { } return !saw_fg; }, + .macos => { + const fg = tcgetpgrp(master_fd); + if (fg <= 0) return false; + if (fg == shell_pid) return false; + return darwin.taken(shell_pid, fg); + }, else => return false, } } +/// The same question the Linux walk asks, answered the way macOS can answer +/// it. There is no /proc to descend and no children list, but the tty's +/// foreground process group can be enumerated in one call — and "is anything +/// but the shell itself holding this terminal?" is exactly a statement about +/// the executables in that group. The test is the shell's own executable and +/// never its pid, which is what keeps a nested interactive shell a prompt, +/// and what still catches `bash -c 'sleep 30'`: the group holds `sleep` too. +/// +/// Until this existed, `ttyTaken` answered `false` on darwin for every pane, +/// so `Pardes.takesCommandLine` was permanently true and every bare Escape in +/// a raw terminal ran the `Last` builtin instead of reaching the child. +const darwin = struct { + const proc_pgrp_only: u32 = 2; + const proc_pidt_shortbsdinfo: c_int = 13; + const zombie_status: u32 = 5; // SZOMB + /// PROC_PIDPATHINFO_MAXSIZE. + const path_max = 4 * 1024; + /// A foreground group is a pipeline; anything larger is not a prompt. + const group_max = 64; + + const ShortBsdInfo = extern struct { + pid: u32, + ppid: u32, + pgid: u32, + status: u32, + comm: [16]u8, + flags: u32, + uid: u32, + gid: u32, + ruid: u32, + rgid: u32, + svuid: u32, + svgid: u32, + rfu: u32, + }; + + extern "c" fn proc_listpids(kind: u32, typeinfo: u32, buffer: ?*anyopaque, buffersize: c_int) c_int; + extern "c" fn proc_pidpath(pid: c_int, buffer: [*]u8, buffersize: u32) c_int; + + fn exe(pid: libc.pid_t, buf: *[path_max]u8) ?[]const u8 { + const got = proc_pidpath(pid, buf, buf.len); + if (got <= 0) return null; + return buf[0..@intCast(got)]; + } + + /// A pid with no readable path is either gone or not ours. Only a zombie + /// is provably harmless — it holds no tty — so everything else is taken. + fn zombie(pid: libc.pid_t) bool { + var info: ShortBsdInfo = undefined; + const got = proc_pidinfo(pid, proc_pidt_shortbsdinfo, 0, &info, @sizeOf(ShortBsdInfo)); + if (got != @sizeOf(ShortBsdInfo)) return false; + return info.status == zombie_status; + } + + fn taken(shell_pid: libc.pid_t, fg: libc.pid_t) bool { + var shell_buf: [path_max]u8 = undefined; + const shell_exe = exe(shell_pid, &shell_buf) orelse return false; + var group: [group_max]libc.pid_t = undefined; + const bytes = proc_listpids(proc_pgrp_only, @intCast(fg), &group, @sizeOf(@TypeOf(group))); + // An empty group is a group whose last member just exited: the shell + // is about to have its terminal back, and calling that taken would + // blink the prompt heuristic off for a frame every time a job ends. + if (bytes <= 0) return false; + const n = @as(usize, @intCast(bytes)) / @sizeOf(libc.pid_t); + if (n >= group.len) return true; + var exe_buf: [path_max]u8 = undefined; + for (group[0..n]) |pid| { + if (pid <= 0 or pid == shell_pid) continue; + const path = exe(pid, &exe_buf) orelse { + if (zombie(pid)) continue; + return true; + }; + if (!std.mem.eql(u8, path, shell_exe)) return true; + } + return false; + } +}; + pub fn signalTty(shell_pid: libc.pid_t, master_fd: c_int, which: pardes.PtySignal) void { const sig = switch (which) { .int => libc.SIG.INT, @@ -1329,23 +1558,33 @@ const TestShell = struct { } fn stop(sh: *TestShell) void { - var probe: TtyProbe = undefined; - var pending: usize = 0; - var doomed: [occ_max_visited]libc.pid_t = undefined; - var n: usize = 0; - _ = pushChildren(&probe, &pending, sh.pid, 1); - while (pending > 0) { - pending -= 1; - const node = probe.pending[pending]; - if (n == doomed.len) break; - doomed[n] = node.pid; - n += 1; - if (node.depth < occ_max_depth) _ = pushChildren(&probe, &pending, node.pid, node.depth + 1); - } - _ = libc.kill(sh.pid, libc.SIG.KILL); - for (doomed[0..n]) |kid| { - _ = libc.kill(kid, libc.SIG.KILL); - _ = libc.kill(-kid, libc.SIG.KILL); + if (comptime builtin.os.tag == .linux) { + var probe: TtyProbe = undefined; + var pending: usize = 0; + var doomed: [occ_max_visited]libc.pid_t = undefined; + var n: usize = 0; + _ = pushChildren(&probe, &pending, sh.pid, 1); + while (pending > 0) { + pending -= 1; + const node = probe.pending[pending]; + if (n == doomed.len) break; + doomed[n] = node.pid; + n += 1; + if (node.depth < occ_max_depth) _ = pushChildren(&probe, &pending, node.pid, node.depth + 1); + } + _ = libc.kill(sh.pid, libc.SIG.KILL); + for (doomed[0..n]) |kid| { + _ = libc.kill(kid, libc.SIG.KILL); + _ = libc.kill(-kid, libc.SIG.KILL); + } + } else { + // No children list to descend. forkpty made the shell a session + // leader, so its own group plus whichever group currently holds + // the tty covers the job the test left running. + const fg = tcgetpgrp(sh.master); + if (fg > 0 and fg != sh.pid) _ = libc.kill(-fg, libc.SIG.KILL); + _ = libc.kill(-sh.pid, libc.SIG.KILL); + _ = libc.kill(sh.pid, libc.SIG.KILL); } _ = libc.waitpid(sh.pid, null, 0); _ = libc.close(sh.master); @@ -1374,7 +1613,7 @@ fn sleepMs(ms: i64) void { } test "an idle prompt is free, a foreground job takes the tty, and Ctrl-C hands it back" { - if (comptime builtin.os.tag != .linux) return error.SkipZigTest; + if (comptime !tty_probe_platform) return error.SkipZigTest; var sh = TestShell.start() orelse return error.SkipZigTest; defer sh.stop(); @@ -1390,7 +1629,7 @@ test "an idle prompt is free, a foreground job takes the tty, and Ctrl-C hands i } test "a background job is not the tty's owner" { - if (comptime builtin.os.tag != .linux) return error.SkipZigTest; + if (comptime !tty_probe_platform) return error.SkipZigTest; var sh = TestShell.start() orelse return error.SkipZigTest; defer sh.stop(); @@ -1403,7 +1642,7 @@ test "a background job is not the tty's owner" { } test "a nested interactive shell is still a prompt" { - if (comptime builtin.os.tag != .linux) return error.SkipZigTest; + if (comptime !tty_probe_platform) return error.SkipZigTest; var sh = TestShell.start() orelse return error.SkipZigTest; defer sh.stop(); @@ -1424,7 +1663,7 @@ test "a nested interactive shell is still a prompt" { } test "the walk reaches the leaf: bash -c 'sleep 30' takes the tty" { - if (comptime builtin.os.tag != .linux) return error.SkipZigTest; + if (comptime !tty_probe_platform) return error.SkipZigTest; var sh = TestShell.start() orelse return error.SkipZigTest; defer sh.stop(); @@ -1436,23 +1675,40 @@ test "the walk reaches the leaf: bash -c 'sleep 30' takes the tty" { sh.send("bash --norc -c 'sleep 30; :'\n"); try std.testing.expect(sh.waitTaken(true, 10_000)); - var probe: TtyProbe = undefined; - var pending: usize = 0; - try std.testing.expectEqual(Pushed.pushed, pushChildren(&probe, &pending, sh.pid, 1)); - try std.testing.expectEqual(@as(usize, 1), pending); - var wrapper_buf: [std.fs.max_path_bytes]u8 = undefined; - var shell_buf: [std.fs.max_path_bytes]u8 = undefined; - try std.testing.expectEqualStrings( - procExe(sh.pid, &shell_buf).?, - procExe(probe.pending[0].pid, &wrapper_buf).?, - ); + // Why the shallow answer is the wrong one, in each walk's own evidence: + // the wrapper between the shell and `sleep` wears the shell's executable, + // so a probe that stopped at it would report a prompt. + if (comptime builtin.os.tag == .linux) { + var probe: TtyProbe = undefined; + var pending: usize = 0; + try std.testing.expectEqual(Pushed.pushed, pushChildren(&probe, &pending, sh.pid, 1)); + try std.testing.expectEqual(@as(usize, 1), pending); + var wrapper_buf: [std.fs.max_path_bytes]u8 = undefined; + var shell_buf: [std.fs.max_path_bytes]u8 = undefined; + try std.testing.expectEqualStrings( + procExe(sh.pid, &shell_buf).?, + procExe(probe.pending[0].pid, &wrapper_buf).?, + ); + } else { + const fg = tcgetpgrp(sh.master); + try std.testing.expect(fg > 0 and fg != sh.pid); + var leader_buf: [darwin.path_max]u8 = undefined; + var shell_buf: [darwin.path_max]u8 = undefined; + // The group's leader IS that wrapper, and it is the shell's binary. + try std.testing.expectEqualStrings( + darwin.exe(sh.pid, &shell_buf).?, + darwin.exe(fg, &leader_buf).?, + ); + // Taken all the same, because the rest of the group is not. + try std.testing.expect(darwin.taken(sh.pid, fg)); + } sh.send("\x03"); try std.testing.expect(sh.waitTaken(false, 10_000)); } test "a full-screen program takes the tty until it quits" { - if (comptime builtin.os.tag != .linux) return error.SkipZigTest; + if (comptime !tty_probe_platform) return error.SkipZigTest; const cases = [_]struct { bin: [*:0]const u8, run: []const u8, quit: []const u8 }{ .{ .bin = "/usr/bin/vim", .run = "vim -u NONE -i NONE\n", .quit = "\x1b:q!\r" }, .{ .bin = "/usr/bin/less", .run = "env LESS= less /etc/hosts\n", .quit = "q" }, diff --git a/src/layout.zig b/src/layout.zig index 47b2c1a4..c6cb7503 100644 --- a/src/layout.zig +++ b/src/layout.zig @@ -8,7 +8,7 @@ pub const Rect = struct { x: u16 = 0, y: u16 = 0, w: u16 = 0, h: u16 = 0 }; pub const Snapshot = struct { serial: u32, box: Box }; const MAX_COLS = pardes.MAX_COLS; const MAX_PANES = pardes.MAX_PANES; -const TOPBAR_H = pardes.TOPBAR_H; + const BOX_H = pardes.BOX_H; pub const Presentation = struct { @@ -795,7 +795,7 @@ pub fn movePlacement(p: *Pardes, id: usize, cur_x: u16, cur_y: u16) ?MovePlaceme const sib = if (src.idx > 0) p.col_panes[src.col][src.idx - 1] else p.col_panes[src.col][src.idx + 1]; heights[sib] +|= p.rects[id].h; } - var y: u16 = TOPBAR_H + p.columnBarHeight(); + var y: u16 = p.topBarHeight() + p.columnBarHeight(); var last: ?MovePlacement = null; for (0..p.col_n[tc]) |k| { const pid = p.col_panes[tc][k]; @@ -1123,7 +1123,7 @@ fn collapseNeighbor(p: *Pardes, col: usize, index: usize) ?usize { } fn computeCollapsedColumn(p: *Pardes, c: usize, x: u16, width: u16, folded: usize) void { - var y: u16 = TOPBAR_H + p.columnBarHeight(); + var y: u16 = p.topBarHeight() + p.columnBarHeight(); const available = p.screen_h -| y; var expanded_left: usize = 0; var weight: f32 = 0; @@ -1196,7 +1196,7 @@ pub fn compute(p: *Pardes) void { } if (vsum <= 0) vsum = 1; - var y: u16 = TOPBAR_H + p.columnBarHeight(); + var y: u16 = p.topBarHeight() + p.columnBarHeight(); const avail_h = p.screen_h -| y; for (0..p.col_n[c]) |k| { const id = p.col_panes[c][k]; diff --git a/src/macos.zig b/src/macos.zig index 79036c3e..d263cfc6 100644 --- a/src/macos.zig +++ b/src/macos.zig @@ -106,6 +106,7 @@ const color_default: u32 = 0x01000000; const color_indexed: u32 = 0x02000000; const cell_flag_default: u8 = 1; const cell_flag_tagline: u8 = 2; +const cell_flag_hover: u8 = 4; const scene_flag_crt: u32 = 1 << 0; const scene_flag_ripple: u32 = 1 << 1; const scene_flag_glitch: u32 = 1 << 2; @@ -730,6 +731,16 @@ fn initCore(runtime: ?*const Runtime, cols_arg: u16, rows_arg: u16) !void { const core = try pardes.Pardes.init(allocs.pardes, opts); errdefer core.deinit(); + // The workspace tag row is the macOS menu bar's business here (see + // docs/macos.md): the build option says whether this shell keeps the + // acme topbar or hands its commands to native chrome. The e2e harness + // opts back in with PARDES_WORKSPACE_TAG=1 — its scripts speak to a + // grid that has the row. Applied before the first resize so the layout + // has never seen it the other way. + core.settings.workspace_tag = if (std.c.getenv("PARDES_WORKSPACE_TAG")) |v| + std.mem.eql(u8, std.mem.span(v), "1") + else + @import("pardes_config").workspace_tag; core.native_images = true; var prompt_rcs = host_io.Shell.prepare(); @@ -917,7 +928,7 @@ export fn pardes_gui_tagline_font_percent() u8 { } export fn pardes_tagline_band_offset(row: u16, canvas_h: f32, cell_h: u32, tagline_h: u32) u32 { - return pardes.taglineBandOffset(row, canvas_h, cell_h, tagline_h); + return pardes.taglineBandOffset(row, canvas_h, cell_h, tagline_h, if (state) |*st| st.core.settings.workspace_tag else true); } export fn pardes_topbar_pane_border_px(cell_h: u32, tagline_h: u32) u32 { @@ -942,6 +953,11 @@ export fn pardes_topbar_pane_border_rgb() u32 { return @as(u32, rgb[0]) << 16 | @as(u32, rgb[1]) << 8 | rgb[2]; } +export fn pardes_tag_active_bg() u32 { + const st = state orelse return color_default; + const rgb = st.core.chromeTheme().tag_active_bg; + return @as(u32, rgb[0]) << 16 | @as(u32, rgb[1]) << 8 | rgb[2]; +} export fn pardes_tagline_bg() u32 { const st = state orelse return color_default; const rgb = st.core.chromeTheme().tag_bg; @@ -1756,12 +1772,18 @@ fn clearFrame(st: *State) void { st.panel_diff_len = 0; } -fn blankTagCells(cells: []Cell, cols: u16, rows: u16, layers: []const pardes.TagLayer) void { +fn blankTagCells(cells: []Cell, cols: u16, rows: u16, source: []const pardes.Cell, layers: []const pardes.TagLayer) void { for (layers) |layer| { if (layer.cols == 0 or layer.viewport.y >= rows or layer.viewport.x >= cols) continue; const start = @as(usize, layer.viewport.y) * cols + layer.viewport.x; const count = @min(layer.viewport.w, cols - layer.viewport.x); - for (cells[start..][0..count]) |*cell| cell.* = encodeCell(.{}); + for (cells[start..][0..count], source[start..][0..count]) |*cell, was| { + // The tag text is the layer's to draw, but a look-hover on a tag + // word is a canonical fact: carry the hover bit through so the + // glass overlay still finds the affordance rect. + cell.* = encodeCell(.{}); + cell.flags |= @as(u8, @intFromBool(was.hover)) * cell_flag_hover; + } } } @@ -1800,7 +1822,7 @@ fn presentFrame(ctx: ?*anyopaque, surface: *const pardes.Surface) void { defer tz_cells.end(); for (surface.cells, st.cells[0..count]) |cell, *out| out.* = encodeCell(cell); } - blankTagCells(st.cells[0..count], surface.cols, surface.rows, &surface.tag_layers); + blankTagCells(st.cells[0..count], surface.cols, surface.rows, surface.cells, &surface.tag_layers); collectPanelDiff(st, surface, count); collectImages(st, surface); collectPanelTracks(st, surface); @@ -1831,7 +1853,7 @@ fn collectPanelDiff(st: *State, surface: *const pardes.Surface, count: usize) vo } for (surface.previous_cells, st.previous_cells[0..count]) |cell, *out| out.* = encodeCell(cell); - blankTagCells(st.previous_cells[0..count], surface.cols, surface.rows, surface.previous_tag_layers); + blankTagCells(st.previous_cells[0..count], surface.cols, surface.rows, surface.previous_cells, surface.previous_tag_layers); for (surface.cell_diffs, st.changed_cells[0..count]) |diff, *out| out.* = encodeChanged(diff); st.panel_diff_len = count; @@ -2395,8 +2417,8 @@ fn encodeCell(cell: pardes.Cell) Cell { .fg = encodeColor(cell.style.fg), .bg = encodeColor(cell.style.bg), .attrs = encodeAttrs(cell.style), + .flags = encodeCellFlags(cell.default, cell.style.font_role, cell.hover), .len = if (cell.default) 1 else cell.len, - .flags = encodeCellFlags(cell.default, cell.style.font_role), }; if (cell.default) out.text[0] = ' ' @@ -2418,9 +2440,10 @@ fn encodeAttrs(style: pardes.CellStyle) u16 { return attrs; } -fn encodeCellFlags(default: bool, role: pardes.FontRole) u8 { +fn encodeCellFlags(default: bool, role: pardes.FontRole, hover: bool) u8 { return @as(u8, @intFromBool(default)) * cell_flag_default | - @as(u8, @intFromBool(role == .tagline)) * cell_flag_tagline; + @as(u8, @intFromBool(role == .tagline)) * cell_flag_tagline | + @as(u8, @intFromBool(hover)) * cell_flag_hover; } fn noteScrollVelocity(st: *State, delta_rows: f32, delta_cols: f32) void { @@ -2566,7 +2589,8 @@ test "pardes.h declares every export the way it is defined" { try expectSameAbi(@TypeOf(c.pardes_animating), @TypeOf(pardes_animating)); try expectSameAbi(@TypeOf(c.pardes_gui_tagline_font_percent), @TypeOf(pardes_gui_tagline_font_percent)); try expectSameAbi(@TypeOf(c.pardes_tagline_band_offset), @TypeOf(pardes_tagline_band_offset)); - try expectSameAbi(@TypeOf(c.pardes_topbar_pane_border_px), @TypeOf(pardes_topbar_pane_border_px)); + try expectSameAbi(@TypeOf(c.pardes_topbar_pane_border_rgb), @TypeOf(pardes_topbar_pane_border_rgb)); + try expectSameAbi(@TypeOf(c.pardes_tag_active_bg), @TypeOf(pardes_tag_active_bg)); try expectSameAbi(@TypeOf(c.pardes_tagline_origin_col), @TypeOf(pardes_tagline_origin_col)); try expectSameAbi(@TypeOf(c.pardes_grid_col_at), @TypeOf(pardes_grid_col_at)); try expectSameAbi(@TypeOf(c.pardes_topbar_pane_border_rgb), @TypeOf(pardes_topbar_pane_border_rgb)); @@ -2658,6 +2682,7 @@ test "pardes.h matches the Zig boundary" { try expectEqual(@as(u32, c.PARDES_COLOR_INDEXED), color_indexed); try expectEqual(@as(u8, c.PARDES_CELL_DEFAULT), cell_flag_default); try expectEqual(@as(u8, c.PARDES_CELL_TAGLINE), cell_flag_tagline); + try expectEqual(@as(u8, c.PARDES_CELL_HOVER), cell_flag_hover); try expectEqual(@as(u16, c.PARDES_TOPBAR_H), pardes.TOPBAR_H); try expectEqual(@as(u32, c.PARDES_SCENE_CRT), scene_flag_crt); try expectEqual(@as(u32, c.PARDES_SCENE_RIPPLE), scene_flag_ripple); @@ -2723,9 +2748,10 @@ test "pardes.h matches the Zig boundary" { encodeAttrs(.{ .ul = .curly }), ); - try expectEqual(@as(u8, 0), encodeCellFlags(false, .body)); - try expectEqual(cell_flag_tagline, encodeCellFlags(false, .tagline)); - try expectEqual(cell_flag_default | cell_flag_tagline, encodeCellFlags(true, .tagline)); + try expectEqual(@as(u8, 0), encodeCellFlags(false, .body, false)); + try expectEqual(cell_flag_hover, encodeCellFlags(false, .body, true)); + try expectEqual(cell_flag_tagline, encodeCellFlags(false, .tagline, false)); + try expectEqual(cell_flag_default | cell_flag_tagline, encodeCellFlags(true, .tagline, false)); try expectEqual(pardes.config.gui_tagline_font_percent, pardes_gui_tagline_font_percent()); } @@ -2947,10 +2973,16 @@ test "mac tag layer ABI preserves logical capacity and physical grip" { try std.testing.expectEqual(@as(u32, 11), pardes_tag_layer_value(0, 8)); try std.testing.expectEqual(@as(u8, 'Z'), pardes_tag_layer_cells(0).?[11].text[0]); var canonical: [24]Cell = @splat(encodeCell(.{ .text = .{'G'} ++ .{0} ** 6, .len = 1, .default = false })); - blankTagCells(&canonical, 8, 3, &core.surface.tag_layers); + // A look-hover under the layer is a canonical fact and survives the blank; + // the glyph it marks does not, because the layer redraws that text itself. + var source: [24]pardes.Cell = @splat(.{}); + source[11].hover = true; + blankTagCells(&canonical, 8, 3, &source, &core.surface.tag_layers); try std.testing.expectEqual(@as(u8, 'G'), canonical[9].text[0]); try std.testing.expectEqual(@as(u8, 'G'), canonical[18].text[0]); try std.testing.expectEqual(encodeCell(.{}).len, canonical[10].len); + try std.testing.expectEqual(@as(u8, 0), canonical[10].flags & cell_flag_hover); + try std.testing.expectEqual(cell_flag_hover, canonical[11].flags & cell_flag_hover); } test "mac window blur builtin reaches the ABI without changing opacity" { diff --git a/src/macos/Sources/AppDelegate.swift b/src/macos/Sources/AppDelegate.swift index cbe9cdc9..3cce7592 100644 --- a/src/macos/Sources/AppDelegate.swift +++ b/src/macos/Sources/AppDelegate.swift @@ -310,6 +310,16 @@ final class AppDelegate: NSObject, NSApplicationDelegate, PardesViewDelegate { file.addItem(withTitle: "Close Window", action: #selector(NSWindow.performClose(_:)), keyEquivalent: "w") + // The workspace tag row's commands, in the place macOS keeps window + // commands. The build hands that row to this menu bar (see + // docs/macos.md): the words are the same builtins the tag carried, + // spelled exactly as a tag Exec would type them, and nothing here is + // editable — the menu is the tag's buttons, not the tag. + let builtins = submenu("Builtins", of: main) + for word in ["Newcol", "Joincol", "Find", "Grep", "Changelog", + "Dump", "NextColor", "Debug", "Kill"] { + builtins.addItem(command(word, #selector(menuBuiltin(_:)), "")) + } let edit = submenu("Edit", of: main) // Paste and nothing else. Copy, Cut, Undo and Select All have no // builtin behind them — the core yanks into the clipboard on its own @@ -379,13 +389,17 @@ final class AppDelegate: NSObject, NSApplicationDelegate, PardesViewDelegate { // here would hide half of what Look does. panel.canChooseDirectories = true panel.allowsMultipleSelection = true - panel.resolvesAliases = true - guard panel.runModal() == .OK else { return } for url in panel.urls where url.isFileURL { look(url.path) } } + /// Any workspace-tag word. The title is the builtin's own spelling, so + /// this is the same `run` a tag Exec performs and there is no second + /// vocabulary to keep in step. + @objc private func menuBuiltin(_ sender: NSMenuItem) { run(sender.title) } + + @objc private func menuNew(_ sender: Any?) { run("New") } @objc private func menuSave(_ sender: Any?) { run("Save") } @objc private func menuHelp(_ sender: Any?) { run("Help") } diff --git a/src/macos/Sources/PardesView.swift b/src/macos/Sources/PardesView.swift index 7981cf46..5ad09c38 100644 --- a/src/macos/Sources/PardesView.swift +++ b/src/macos/Sources/PardesView.swift @@ -433,7 +433,26 @@ private struct Metrics { let symbolic = (traits?[kCTFontSymbolicTrait] as? UInt32) ?? 0 return symbolic & UInt32(CTFontSymbolicTraits.traitBold.rawValue | CTFontSymbolicTraits.traitItalic.rawValue) == 0 } - let face = CTFontCreateWithFontDescriptor(plain ?? descriptors[0], size, nil) + let chosen = CTFontCreateWithFontDescriptor(plain ?? descriptors[0], size, nil) + // A variable face's descriptor carries no variation, and CoreText + // picks whichever named instance it likes for it — Maple Mono's + // variable file comes up Thin. Pin every axis to its own default: + // the face the file itself calls regular. + var face = chosen + if let axes = CTFontCopyVariationAxes(face) as? [[CFString: Any]] { + var defaults: [CFNumber: Any] = [:] + for axis in axes { + guard let tag = axis[kCTFontVariationAxisIdentifierKey], + let value = axis[kCTFontVariationAxisDefaultValueKey] else { continue } + defaults[tag as! CFNumber] = value + } + if !defaults.isEmpty { + let descriptor = CTFontDescriptorCreateCopyWithAttributes( + CTFontCopyFontDescriptor(face), + [kCTFontVariationAttribute: defaults] as CFDictionary) + face = CTFontCreateWithFontDescriptor(descriptor, size, nil) + } + } // The core already filtered for fixed pitch by reading the file's own // advances. This is the same question asked of the face CoreText // actually built, which is the one that will be drawn with. @@ -577,7 +596,14 @@ final class PardesView: NSView { // full redraw does not allocate 24 times. private var runGlyphs: [CGGlyph] = [] private var runPositions: [CGPoint] = [] - + /// Ligature shaping, keyed by face and text. A sequence ligates when + /// shaping it produces fewer glyphs than it has characters — the only + /// answer CoreText gives without interrogating the font's own features. + /// Cleared with the glyph caches, because it belongs to one face. + private var ligatureShaped: [String: Bool] = [:] + /// Columns the current row has already consumed as part of a ligature + /// drawn further left. One row's worth at a time. + private var ligatureCovered: Set = [] /// Constructed lazily because the ordinary path is still a direct /// CoreText/CoreGraphics frame. No scene bit and no panel track means no /// bitmap, no Core Image context and no Metal work. @@ -748,6 +774,7 @@ final class PardesView: NSView { bodyGlyphCache.removeAll(keepingCapacity: true) taglineGlyphCache.removeAll(keepingCapacity: true) gripGlyphCache.removeAll(keepingCapacity: true) + ligatureShaped.removeAll(keepingCapacity: true) metrics = next taglines = TaglineMetrics(body: next, percent: taglines.percent, scale: scale) metricsScale = scale @@ -844,12 +871,12 @@ final class PardesView: NSView { // whatever we do, so clipping would save fills and nothing else. Narrow // the row loops to the dirty band if that ever shows up in a profile. let count = pardes_frame() - let nextLinkPointer = pardes_pointer_shape() == 1 - if nextLinkPointer != linkPointer { - linkPointer = nextLinkPointer + let nextPointer = pointerShape() + if nextPointer != pointer { + pointer = nextPointer window?.invalidateCursorRects(for: self) if let window, bounds.contains(convert(window.mouseLocationOutsideOfEventStream, from: nil)) { - (linkPointer ? NSCursor.pointingHand : NSCursor.iBeam).set() + cursorFor(pointer).set() } } let scene = pardes_scene() @@ -1178,10 +1205,13 @@ final class PardesView: NSView { drawTagLayers(ctx, hideCursor:hideCursor, canonical:cells, cols:cols, rows:rows) } else { for layer in presentedTagLayers { - drawTagGrip(ctx, values:layer.values, canonical:cells, cols:cols, rows:rows) - layer.cells.withUnsafeBufferPointer { cells in - if let base = cells.baseAddress { drawTagLayer(ctx, values:layer.values, cells:base, hideCursor:true) } + layer.cells.withUnsafeBufferPointer { tagCells in + if let base = tagCells.baseAddress { + drawTagLayer(ctx, values: layer.values, cells: base, hideCursor: true, + canonical: cells, cols: cols) + } } + drawTagGrip(ctx, values: layer.values, canonical: cells, cols: cols, rows: rows) } for layer in presentedBodyLayers { layer.cells.withUnsafeBufferPointer { cells in @@ -1190,6 +1220,7 @@ final class PardesView: NSView { } drawTagRules(ctx, layers: presentedTagLayers.map { $0.values }) } + drawHoverGlass(ctx, cells: cells, cols: cols, rows: rows) } private var presentedTagLayers: [FrozenBodyLayer] = [] @@ -1212,16 +1243,22 @@ final class PardesView: NSView { let values = (0...12).map { Int(pardes_tag_layer_value(index, UInt32($0))) } if values[0] == 0 { continue } layers.append(values) - drawTagGrip(ctx, values:values, canonical:canonical, cols:cols, rows:rows) - if let cells = pardes_tag_layer_cells(index) { drawTagLayer(ctx, values: values, cells: cells, hideCursor: hideCursor) } + // The layer's full-row fill must land before the grip: the row + // background now spans the anchor columns, and the grip glyph + // and the anchor fills have to come back on top of it. + if let cells = pardes_tag_layer_cells(index) { + drawTagLayer(ctx, values: values, cells: cells, hideCursor: hideCursor, + canonical: canonical, cols: cols) + } + drawTagGrip(ctx, values: values, canonical: canonical, cols: cols, rows: rows) } drawTagRules(ctx, layers: layers) } /// SDL's chrome overlay is drawn after its compact layers. Keep these - /// one-pixel rules above the full-row tag backgrounds as well. + /// one-point rules above the full-row tag backgrounds as well. private func drawTagRules(_ ctx: CGContext, layers: [[Int]]) { - let pixel = 1 / metricsScale + let pixel = CGFloat(1) for values in layers where values[1] != 0 { let kind = values[1] let bottom = kind == 2 && values[11] != 0 @@ -1252,15 +1289,17 @@ final class PardesView: NSView { } private func drawTagGrip(_ ctx: CGContext, values: [Int], canonical: UnsafePointer, cols: Int, rows: Int) { - let width = Int(pardes_grip_columns()) let x = values[4] - Int(pardes_tag_text_inset()), y = values[5] if values[1] != 2 || x < 0 || x >= cols || y < 0 || y >= rows { return } var cell = canonical[y * cols + x] let text = withUnsafeBytes(of: &cell.text) { String(decoding: $0.prefix(Int(cell.len)), as: UTF8.self) } if text.isEmpty { return } let style = resolve(cell, block:false, ground:themeBG ?? pardesDefaultBG, clearGround:false) - let centerX = (CGFloat(x) + CGFloat(width) / 2) * cellWidth - let centerY = CGFloat(y) * cellHeight + taglines.top(row:y, canvasHeight:bounds.height) + taglines.height / 2 + // The box drawTagLayer filled is this mark's ground, so the mark + // centres on that same square rather than on the grip columns: one + // rect measures both and the two cannot drift apart. + guard let square = anchorSquare(values: values) else { return } + let centerX = square.midX, centerY = square.midY if text != " " { let face = Face(bold: cell.attrs & UInt16(PARDES_ATTR_BOLD) != 0, italic: cell.attrs & UInt16(PARDES_ATTR_ITALIC) != 0) @@ -1268,9 +1307,7 @@ final class PardesView: NSView { let originX = ((centerX - measured.ink.midX) * metricsScale).rounded() / metricsScale let baseline = ((bounds.height - centerY - measured.ink.midY) * metricsScale).rounded() / metricsScale ctx.saveGState() - ctx.clip(to: CGRect(x: CGFloat(x) * cellWidth, - y: CGFloat(y) * cellHeight + taglines.top(row:y, canvasHeight:bounds.height), - width: CGFloat(width) * cellWidth, height: taglines.height)) + ctx.clip(to: square) ctx.translateBy(x: 0, y: bounds.height) ctx.scaleBy(x: 1, y: -1) ctx.textMatrix = .identity @@ -1286,16 +1323,36 @@ final class PardesView: NSView { fill(ctx, CGRect(x:floor(centerX-halfWidth), y:floor(centerY+1), width:2*halfWidth, height:1), style.fg, 1) } - private func drawTagLayer(_ ctx: CGContext, values: [Int], cells: UnsafePointer, hideCursor: Bool) { + private func drawTagLayer(_ ctx: CGContext, values: [Int], cells: UnsafePointer, + hideCursor: Bool, canonical: UnsafePointer, cols: Int) { let left = CGFloat(values[4]) * cellWidth let y = CGFloat(values[5]) * cellHeight + taglines.top(row: values[5], canvasHeight: bounds.height) // SDL gives the tag a full body-row background; only its glyphs - // and per-cell highlights use the compact band. - let viewport = CGRect(x: left, y: CGFloat(values[5]) * cellHeight, - width: CGFloat(values[6]) * cellWidth, height: cellHeight) + // and per-cell highlights use the compact band. The band spans the + // row's whole extent, not just its text: the grip and the mode box + // live in the inset columns to the left of `values[4]`, and their + // own fills cover only the compact band — a row background that + // stops at the text leaves holes of ground under those anchors. + // The rule in drawTagRules spans exactly this left-to-right range. + let rowLeft = CGFloat(max(0, values[4] - Int(pardes_tag_text_inset()))) * cellWidth + let rowRight = CGFloat(values[4] + values[6]) * cellWidth + let viewport = CGRect(x: rowLeft, y: CGFloat(values[5]) * cellHeight, + width: rowRight - rowLeft, height: cellHeight) ctx.saveGState() ctx.clip(to: viewport) fillBackground(ctx, viewport, UInt32(values[10]), backgroundAlpha) + // The anchor (grip, mode box) lives in the inset columns that fill + // just covered, so its own box goes back on top: one solid fill in + // the box colour the anchor cell wears, with drawTagGrip's mark + // drawn over it afterwards. + if let square = anchorSquare(values: values) { + let anchorX = max(0, values[4] - Int(pardes_tag_text_inset())) + let cell = canonical[values[5] * cols + anchorX] + let style = resolve(cell, block: false, + ground: UInt32(values[10]), clearGround: false) + if style.visible { fillBackground(ctx, square.integral, style.bg, backgroundAlpha) } + } + for pass in 0...1 { for col in 0.. CGRect? { + let anchorX = max(0, values[4] - Int(pardes_tag_text_inset())) + guard anchorX < values[4] else { return nil } + let pad = (cellHeight - taglines.height) / 2 + return CGRect(x: CGFloat(anchorX) * cellWidth + pad, + y: CGFloat(values[5]) * cellHeight + taglines.top(row: values[5], canvasHeight: bounds.height), + width: taglines.height, height: taglines.height) + } + + /// The look-hover affordance as liquid glass: the core marks the word's + /// cells (PARDES_CELL_HOVER), and this composes a real material over the + /// run — the drawn frame snapshot refracted through CoreImage (a small + /// blur, then a lens scale about the pill's centre, which is what makes + /// the edges swim), the theme's selection colour as a faint tint, a + /// specular sheen from the top edge, and a light rim — with the word's + /// own glyphs drawn back on top, crisp, the way text sits on a real + /// material rather than behind one. + private func drawHoverGlass(_ ctx: CGContext, cells: UnsafePointer, cols: Int, rows: Int) { + var drew = false + for row in 0..= 0 { + let rect = CGRect(x: CGFloat(start) * cellWidth, y: CGFloat(row) * cellHeight, + width: CGFloat(col - start) * cellWidth, height: cellHeight) + drawLiquidGlass(ctx, rect, tint: tint) + redrawHoverRun(ctx, cells, cols: cols, row: row, start: start, end: col) + drew = true + start = -1 + } + } + } + // No affordance this frame: the held snapshot describes a frame + // that no longer exists, and the next hover must take a fresh one. + if !drew { glassShot = nil } + } + + /// A CoreImage context for the glass refraction, created once. + private lazy var glassContext = CIContext() + /// The snapshot behind the current pill. Refraction reads the already + /// drawn frame, and re-reading it every pump would blur a moving pill + /// out of its own budget, so the shot is taken when the rect changes. + private var glassShot: (rect: CGRect, image: CGImage)? + + private func drawLiquidGlass(_ ctx: CGContext, _ rect: CGRect, tint: UInt32) { + let radius = min(rect.height / 4, 6) + let pill = CGPath(roundedRect: rect.insetBy(dx: 1, dy: 1.5), + cornerWidth: radius, cornerHeight: radius, transform: nil) + // The refraction: the frame as drawn, blurred a little and scaled + // about the pill's centre, so the rim bends what surrounds it. The + // shot extends past the pill for exactly this — the lens needs + // pixels from outside the glass to pull in. + let lens = rect.insetBy(dx: -10, dy: -10) + if refract(ctx, pill: pill, rect: rect, lens: lens, tint: tint) { + // Specular: light caught at the top edge, fading as it falls. + ctx.saveGState() + ctx.addPath(pill) + ctx.clip() + let shine = [CGColor(srgbRed: 1, green: 1, blue: 1, alpha: 0.22), + CGColor(srgbRed: 1, green: 1, blue: 1, alpha: 0.0)] as CFArray + if let gradient = CGGradient(colorsSpace: CGColorSpace(name: CGColorSpace.sRGB), + colors: shine, locations: [0, 0.55]) { + ctx.drawLinearGradient(gradient, + start: CGPoint(x: rect.minX, y: rect.minY), + end: CGPoint(x: rect.minX, y: rect.maxY), options: []) + } + ctx.restoreGState() + } else { + // No refraction without a snapshot: the tint alone, faint. + ctx.saveGState() + ctx.addPath(pill) + ctx.clip() + ctx.setFillColor(CGColor(srgbRed: CGFloat((tint >> 16) & 0xFF) / 255, + green: CGFloat((tint >> 8) & 0xFF) / 255, + blue: CGFloat(tint & 0xFF) / 255, + alpha: 0.18)) + ctx.fill(rect) + ctx.restoreGState() + } + // The lens edge: a light rim and a darker bottom hairline, the way a + // real material catches its own edge. + ctx.addPath(pill) + ctx.setStrokeColor(CGColor(srgbRed: 1, green: 1, blue: 1, alpha: 0.35)) + ctx.setLineWidth(1) + ctx.strokePath() + ctx.addPath(pill) + ctx.setStrokeColor(CGColor(srgbRed: 0, green: 0, blue: 0, alpha: 0.25)) + ctx.setLineWidth(0.5) + ctx.clip() + ctx.stroke(CGRect(x: rect.minX, y: rect.maxY - 2, width: rect.width, height: 1.5)) + } + + /// True when the refraction composited. The snapshot is taken when the + /// pill moves and reused while it sits still. + private func refract(_ ctx: CGContext, pill: CGPath, rect: CGRect, lens: CGRect, tint: UInt32) -> Bool { + guard let shot = snapshotFor(ctx, lens: lens) else { return false } + var image = CIImage(cgImage: shot) + // The blur is grown slightly past the crop and the whole thing is + // pulled toward the centre by a few percent: the rim bends what + // surrounds it, which is the refraction the eye reads as glass. + let blur = image.applyingGaussianBlur(sigma: 2 * metricsScale) + let grown = blur.extent.insetBy(dx: -8 * metricsScale, dy: -8 * metricsScale) + let centre = CGPoint(x: grown.midX, y: grown.midY) + let scale = 1.06 + let lensTransform = CGAffineTransform(translationX: centre.x * (1 - scale), + y: centre.y * (1 - scale)).scaledBy(x: scale, y: scale) + image = blur.transformed(by: lensTransform) + guard let filtered = glassContext.createCGImage(image, from: grown) else { return false } + ctx.saveGState() + ctx.addPath(pill) + ctx.clip() + ctx.draw(filtered, in: rect) + // The glass's own body colour: the theme's selection, faint — the + // refraction and the sheen carry the material, not opacity. + ctx.setFillColor(CGColor(srgbRed: CGFloat((tint >> 16) & 0xFF) / 255, + green: CGFloat((tint >> 8) & 0xFF) / 255, + blue: CGFloat(tint & 0xFF) / 255, + alpha: 0.15)) + ctx.fill(rect) + ctx.restoreGState() + return true + } + + private func snapshotFor(_ ctx: CGContext, lens: CGRect) -> CGImage? { + if let held = glassShot, held.rect == lens { return held.image } + guard let whole = ctx.makeImage() else { return nil } + // makeImage hands back backing pixels; the lens is in view points. + let region = CGRect(x: lens.minX * metricsScale, y: lens.minY * metricsScale, + width: lens.width * metricsScale, height: lens.height * metricsScale) + guard let cropped = whole.cropping(to: region) else { return nil } + glassShot = (lens, cropped) + return cropped + } + + /// The hovered word's glyphs, back on top of the material, crisp: text + /// sits on liquid glass, not behind it. + private func redrawHoverRun(_ ctx: CGContext, _ cells: UnsafePointer, + cols: Int, row: Int, start: Int, end: Int) { + ctx.saveGState() + ctx.textMatrix = .identity + ctx.translateBy(x: 0, y: bounds.height) + ctx.scaleBy(x: 1, y: -1) + let baseline = bounds.height - (CGFloat(row) * cellHeight + metrics.ascent) + for col in start.. = [ + "<", ">", "=", "!", "&", "|", "-", "/", ":", ".", "#", "*", "+", "~", "^", "%", + ] + + private func ligates(_ face: Face, _ text: String) -> Bool { + let key = "\(face.rawValue):\(text)" + if let cached = ligatureShaped[key] { return cached } + let attributed = NSAttributedString(string: text, attributes: [fontAttribute: metrics.fonts[face.rawValue], + NSAttributedString.Key(kCTForegroundColorFromContextAttributeName as String): true]) + let shaped = CTLineCreateWithAttributedString(attributed as CFAttributedString) + var glyphs: [CGGlyph] = [] + for run in (CTLineGetGlyphRuns(shaped) as? [CTRun]) ?? [] { + let count = CTRunGetGlyphCount(run) + var runGlyphs = [CGGlyph](repeating: 0, count: count) + CTRunGetGlyphs(run, CFRange(location: 0, length: count), &runGlyphs) + glyphs.append(contentsOf: runGlyphs) + } + // A ligature is any divergence from per-character mapping. A font may + // collapse the pair into one glyph (JetBrains Mono) or swap each + // character for a joining half kept at the same count (Maple Mono) — + // either way the sequence must be shaped, not mapped. + let singles = text.utf16.map { glyph(face, $0, tagline: false) } + let result = glyphs.count != singles.count + || zip(glyphs, singles).contains { $0 != $1 } + ligatureShaped[key] = result + return result + } + + /// When the cells at `col` ligate under `face`, the text to shape and how + /// many cells the ligature covers. Nil when they do not. Ligature cells + /// must carry the same face, colour and alpha and no rules of their own — + /// a ligature is one glyph of one style, not a style transition. + private func ligatureSpan(_ cells: UnsafePointer, base: Int, cols: Int, col: Int, + face: Face, fg: UInt32, alpha: CGFloat, + blockCol: Int, paneGripCells: Set) -> (text: String, covered: Int)? { + func eligible(_ index: Int) -> String? { + let cell = cells[base + index] + if cell.flags & UInt8(PARDES_CELL_DEFAULT) != 0 { return nil } + if cell.flags & UInt8(PARDES_CELL_TAGLINE) != 0 { return nil } + if cell.attrs >> UInt16(PARDES_ATTR_UL_SHIFT) != 0 + || cell.attrs & UInt16(PARDES_ATTR_STRIKETHROUGH) != 0 { return nil } + if paneGripCells.contains(base + index) { return nil } + let text = withUnsafeBytes(of: cell.text) { raw in + String(decoding: raw.prefix(Int(cell.len)), as: UTF8.self) + } + guard text.utf16.count == 1 else { return nil } + let other = resolve(cell, block: blockCol == index, + ground: themeBG ?? pardesDefaultBG, clearGround: false) + guard other.visible, other.fg == fg, other.alpha == alpha, + Face(bold: cell.attrs & UInt16(PARDES_ATTR_BOLD) != 0, + italic: cell.attrs & UInt16(PARDES_ATTR_ITALIC) != 0) == face else { return nil } + return text + } + guard let head = eligible(col), PardesView.ligatureHeads.contains(head.first!) else { return nil } + guard col + 1 < cols, let second = eligible(col + 1) else { return nil } + let pair = head + second + if col + 2 < cols, let third = eligible(col + 2) { + let triple = pair + third + if ligates(face, triple) { return (triple, 3) } + } + if ligates(face, pair) { return (pair, 2) } + return nil + } + private func drawRules( _ ctx: CGContext, _ cell: pardes_cell_s, @@ -1921,6 +2243,13 @@ final class PardesView: NSView { override func keyDown(with event: NSEvent) { let flags = event.modifierFlags + // Same reason as the trackpad trace below: whether AppKit delivered a + // keystroke at all is not something this process can otherwise answer, + // and "Escape does nothing" has two entirely different causes + // depending on whether this line prints. + trace("key: code=\(event.keyCode) mods=\(flags.rawValue) chars=" + + (event.charactersIgnoringModifiers?.unicodeScalars + .map { String($0.value, radix: 16) }.joined(separator: ",") ?? "-")) // The ABI has no super bit, so a Command chord cannot be expressed at all. // Anything the main menu claims never reaches here; the rest is swallowed // rather than delivered as the bare keystroke the core would insert. @@ -2328,12 +2657,35 @@ final class PardesView: NSView { userInfo: nil)) } - private var linkPointer = false + private enum Pointer: Equatable { case text, link, target } + private var pointer: Pointer = .text + + /// The core's pointer_shape, in this shell's cursor vocabulary: a link + /// is a PDF hyperlink (the hand), a target is a word the core's own + /// Look-hover plumbing validated as a real Look or Exec operand, and + /// anything else is text — the I-beam. + private func pointerShape() -> Pointer { + switch pardes_pointer_shape() { + case 1: return .link + case 2: return .target + default: return .text + } + } + + private func cursorFor(_ shape: Pointer) -> NSCursor { + switch shape { + case .link: return .pointingHand + case .target: return .arrow + case .text: return .iBeam + } + } override func resetCursorRects() { - // Every cell in this view is text, including the tags. An arrow over a - // grid you can sweep and click words in is the wrong affordance. - addCursorRect(bounds, cursor: linkPointer ? .pointingHand : .iBeam) + // Every cell in this view is text, including the tags. An arrow over + // plain text is the wrong affordance — but a word the core has + // validated as a Look or Exec target earns it: middle- and + // right-clicking there acts, and the cursor says so before it does. + addCursorRect(bounds, cursor: cursorFor(pointer)) } override func setFrameSize(_ newSize: NSSize) { diff --git a/src/macos/pardes.h b/src/macos/pardes.h index df3ba04f..f74330e5 100644 --- a/src/macos/pardes.h +++ b/src/macos/pardes.h @@ -76,6 +76,11 @@ typedef struct { #define PARDES_CELL_DEFAULT 0x01u #define PARDES_CELL_TAGLINE 0x02u +// The look-hover affordance: the word under the pointer is a real Look or +// Exec operand. Hosts that draw the affordance as more than the quiet tint +// (macOS composes a liquid-glass overlay) read this instead of guessing +// from the background colour, which a real selection shares. +#define PARDES_CELL_HOVER 0x04u // One coherent snapshot for the full-window shader pass. The bitmask lets the // host run CRT, ripple and glitch in one kernel instead of stacking filters; @@ -323,6 +328,10 @@ uint32_t pardes_topbar_pane_border_rgb(void); // pardes.TOPBAR_H, and src/macos.zig asserts the two agree. #define PARDES_TOPBAR_H 1u +// The active pane's tag row background, for hosts that afford the active +// tagline more than a tint — macOS raises it like an old-school bevel. +uint32_t pardes_tag_active_bg(void); + // Persistent full-window effect switches and their display-clock time. A zero // flags word means draw the CoreText frame directly; any nonzero combination // is one postprocess pass. Snapshot by value, with no borrowed storage. @@ -510,7 +519,8 @@ bool pardes_active_dirty(void); int32_t pardes_cursor_x(void); int32_t pardes_cursor_y(void); bool pardes_cursor_bar(void); -// Mouse pointer affordance: 0 = default text pointer, 1 = link hand. +// Mouse pointer affordance: 0 = default text pointer, 1 = link hand, +// 2 = a validated Look/Exec target under the pointer (the acme arrow). uint32_t pardes_pointer_shape(void); // The Look or Exec the core performed since this was last asked, and clears diff --git a/src/pardes.zig b/src/pardes.zig index ed71102e..dee8a902 100644 --- a/src/pardes.zig +++ b/src/pardes.zig @@ -88,12 +88,19 @@ pub const BOX_H: u16 = 1; pub const TAG_GAP: u16 = 1; pub const TAG_TEXT_INSET: u16 = config.GUTTER + TAG_GAP; -pub fn taglineBandOffset(row: u16, canvas_h: f32, cell_h: u32, tagline_h: u32) u32 { +pub fn taglineBandOffset(row: u16, canvas_h: f32, cell_h: u32, tagline_h: u32, workspace: bool) u32 { const spare = cell_h -| tagline_h; const border = topbarPaneBorderPixels(cell_h, tagline_h); + const rows: u32 = @max(1, @as(u32, @intFromFloat(@floor(canvas_h / @as(f32, @floatFromInt(cell_h)))))); + if (!workspace) { + // No workspace row: nothing above row 0 to share a rule with, so + // every band centers in its cell the way the middle rows always + // have. The anchor boxes this lets the hosts draw stay symmetric. + if (@as(u32, row) + 1 >= rows) return spare; + return spare / 2; + } if (row == 0) return spare - border / 2; if (row == TOPBAR_H) return border - border / 2; - const rows: u32 = @max(1, @as(u32, @intFromFloat(@floor(canvas_h / @as(f32, @floatFromInt(cell_h)))))); if (@as(u32, row) + 1 >= rows) return spare; return spare / 2; } @@ -104,8 +111,8 @@ pub fn topbarPaneBorderPixels(cell_h: u32, tagline_h: u32) u32 { } pub fn taglineOriginCol(p: *const Pardes, col: u16, row: u16, track: ?layout.Track) f32 { - if (row < TOPBAR_H) return 0; - if (row < TOPBAR_H + p.columnBarHeight()) { + if (row < p.topBarHeight()) return 0; + if (row < p.topBarHeight() + p.columnBarHeight()) { for (p.col_x[0..p.ncol], p.col_w[0..p.ncol]) |x, w| if (col >= x and col - x < w) return @floatFromInt(x); } @@ -164,8 +171,8 @@ test "paint order is moving, then opening, then closing tombstones on top" { pub fn gridColAt(p: ?*const Pardes, x: f32, row: u16, body_w: f32, tagline_w: f32) u16 { const body = @max(body_w, 1); const tag = @max(tagline_w, 1); - if (row < TOPBAR_H) return colFromSpan(x, tag); - if (p) |core| if (row < TOPBAR_H + core.columnBarHeight()) { + if (row < (if (p) |core| core.topBarHeight() else TOPBAR_H)) return colFromSpan(x, tag); + if (p) |core| if (row < core.topBarHeight() + core.columnBarHeight()) { for (core.col_x[0..core.ncol], core.col_w[0..core.ncol]) |origin, width| { if (width == 0) continue; const left = @as(f32, @floatFromInt(origin)) * body; @@ -3395,6 +3402,12 @@ pub const Cell = struct { len: u8 = 1, style: CellStyle = .{}, default: bool = true, + /// The look-hover affordance is on this cell: the word under the pointer + /// is a real Look or Exec operand, and hosts that draw the quiet tint as + /// more than a flat fill — macOS renders it as a glass overlay — read + /// this instead of guessing from the background colour, which a real + /// selection shares. + hover: bool = false, pub fn grapheme(c: *const Cell) []const u8 { return c.text[0..c.len]; @@ -3670,8 +3683,12 @@ test "pixel attachment fit and pan do not invalidate cached pixels" { /// The canonical interface: what a frame of pardes IS. The tty shell writes /// these cells to vaxis one-to-one; the SDL shells rasterize them. pub const Surface = struct { - pub const PointerShape = enum(u8) { arrow, link }; + pub const PointerShape = enum(u8) { arrow, link, target }; pointer_shape: PointerShape = .arrow, + /// Set only for the duration of the look-hover paint, so the cells that + /// paint the quiet affordance can carry the hover bit through the ABI + /// without every selection painter learning a new parameter. + mark_hover: bool = false, body_layers: [MAX_PANES]BodyLayer = @splat(.{}), tag_layers: [MAX_TAG_LAYERS]TagLayer = @splat(.{}), cols: u16 = 0, @@ -3717,7 +3734,11 @@ pub const Surface = struct { pub fn at(s: *Surface, x: u16, y: u16) *Cell { std.debug.assert(x < s.cols and y < s.rows); - return &s.cells[@as(usize, y) * s.cols + x]; + const cell = &s.cells[@as(usize, y) * s.cols + x]; + // The look-hover paint runs with mark_hover set, and its cells are + // exactly the ones this marks — see render's preview block. + if (s.mark_hover) cell.hover = true; + return cell; } pub fn set(s: *Surface, x: u16, y: u16, text: []const u8, style: CellStyle) void { @@ -6263,6 +6284,14 @@ pub const Pardes = struct { return config.topbar_str; } + /// The workspace tag row's height: `TOPBAR_H` while the setting keeps + /// it, zero once a native shell takes its commands over. Layout and hit + /// testing read this rather than the constant, the way they read + /// `columnBarHeight`. + pub fn topBarHeight(p: *const Pardes) u16 { + return if (p.settings.workspace_tag) TOPBAR_H else 0; + } + pub fn columnBarHeight(p: *const Pardes) u16 { return if (p.settings.column_tags and p.screen_h >= 3) COLBAR_H else 0; } @@ -7765,7 +7794,7 @@ pub const Pardes = struct { } var dest: ?usize = null; for (p.panes, 0..) |slot, i| { - if (slot == null or p.rects[i].y != TOPBAR_H + p.columnBarHeight()) continue; + if (slot == null or p.rects[i].y != p.topBarHeight() + p.columnBarHeight()) continue; if (p.header_column) |c| if (p.rects[i].x != p.col_x[c]) continue; if (i == p.active) { dest = i; @@ -11015,7 +11044,7 @@ pub const Pardes = struct { pub const ChromeTarget = struct { col: u16, row: u16 }; pub fn chromeTarget(p: *const Pardes, col: u16, row: u16) ?ChromeTarget { - if (row < TOPBAR_H + p.columnBarHeight()) return .{ .col = col, .row = row }; + if (row < p.topBarHeight() + p.columnBarHeight()) return .{ .col = col, .row = row }; for (p.panes, 0..) |slot, id| { if (slot == null) continue; const rect = p.rects[id]; @@ -11330,7 +11359,7 @@ pub const Pardes = struct { p.chord_arg = null; } } - if (mrow >= TOPBAR_H and mrow < TOPBAR_H + p.columnBarHeight() and m.kind == .press) { + if (mrow >= p.topBarHeight() and mrow < p.topBarHeight() + p.columnBarHeight() and m.kind == .press) { for (0..p.ncol) |column| { if (mcol < p.col_x[column] or mcol >= p.col_x[column] + @min(config.GUTTER, p.col_w[column])) continue; if (m.button == config.select_button) { @@ -11347,7 +11376,7 @@ pub const Pardes = struct { if (m.kind == .release) p.header_drag = false; return; } - if (mrow < TOPBAR_H + p.columnBarHeight() and m.kind == .press and + if (mrow < p.topBarHeight() + p.columnBarHeight() and m.kind == .press and (m.button == config.select_button or m.button == config.exec_button or m.button == config.look_button)) { if (m.button == config.select_button) if (p.panes[p.active]) |pane| { @@ -11355,7 +11384,7 @@ pub const Pardes = struct { }; var column: ?usize = null; var x: u16 = 0; - if (mrow >= TOPBAR_H) { + if (mrow >= p.topBarHeight()) { for (0..p.ncol) |c| if (mcol >= p.col_x[c] and mcol < p.col_x[c] + p.col_w[c]) { column = c; x = p.col_x[c] + TAG_TEXT_INSET; @@ -13186,6 +13215,15 @@ pub const Pardes = struct { } } }; + // A look-hover preview means the pointed word is a real Look or Exec + // operand: the same plumbing a click would act on. Hosts that model + // the pointer per-text (the macOS I-beam) read this as "target" and + // afford it the arrow instead. + if (p.look_hover_preview != null) s.pointer_shape = .target; + // Stale hover bits must not survive into a frame whose pointer has + // moved on: the ordinary content paint does not clear fields it + // never set. + for (s.cells) |*c| c.hover = false; for (&s.body_layers) |*layer| layer.rows = 0; for (&s.tag_layers) |*layer| layer.cols = 0; s.nimages = 0; @@ -13252,21 +13290,24 @@ pub const Pardes = struct { } } - // global tagbar: full width, top row + // global tagbar: full width, top row — unless a native shell has + // taken its commands over, in which case the row is not ours to draw p.revealHeader(); - s.fill(0, 0, s.cols, TOPBAR_H, .{ - .bg = .{ .rgb = chrome.tag_bg }, - .font_role = .tagline, - }); var tb_buf: [1200]u8 = undefined; const global_bar = p.topbar(&tb_buf); const global_scroll = if (p.topbar_col != null and p.header_column == null) p.header_scroll else 0; - _ = s.print(0, 0, s.cols, global_bar[panes.File.rawAtDisplay(global_bar, global_scroll)..], .{ - .fg = .{ .rgb = chrome.tag_fg }, - .bg = .{ .rgb = chrome.tag_bg }, - .font_role = .tagline, - }); - if (p.pointer_inside and p.hover_row < TOPBAR_H) { + if (p.settings.workspace_tag) { + s.fill(0, 0, s.cols, TOPBAR_H, .{ + .bg = .{ .rgb = chrome.tag_bg }, + .font_role = .tagline, + }); + _ = s.print(0, 0, s.cols, global_bar[panes.File.rawAtDisplay(global_bar, global_scroll)..], .{ + .fg = .{ .rgb = chrome.tag_fg }, + .bg = .{ .rgb = chrome.tag_bg }, + .font_role = .tagline, + }); + } + if (p.pointer_inside and p.hover_row < p.topBarHeight()) { const bar = p.topbar(&tb_buf); if (wordBoundsAtCol(bar, panes.File.rawAtDisplay(bar, p.hover_col + global_scroll))) |bounds| { var col = panes.File.rawDisplayCol(bar, bounds.lo) -| global_scroll; @@ -13296,24 +13337,24 @@ pub const Pardes = struct { const lum = (@as(u16, grip_bg[0]) * 3 + @as(u16, grip_bg[1]) * 6 + @as(u16, grip_bg[2])) / 10; const ink: [3]u8 = if (lum > 140) .{ 0, 0, 0 } else .{ 255, 255, 255 }; const grip_style: CellStyle = .{ .bg = .{ .rgb = grip_bg }, .fg = .{ .rgb = ink }, .font_role = .tagline }; - s.fill(p.col_x[c], TOPBAR_H, grip, 1, grip_style); - s.fill(p.col_x[c] + grip, TOPBAR_H, inset - grip, 1, .{ .bg = .{ .rgb = bg }, .font_role = .tagline }); + s.fill(p.col_x[c], p.topBarHeight(), grip, 1, grip_style); + s.fill(p.col_x[c] + grip, p.topBarHeight(), inset - grip, 1, .{ .bg = .{ .rgb = bg }, .font_role = .tagline }); - s.fill(x, TOPBAR_H, w, 1, .{ .bg = .{ .rgb = bg }, .font_role = .tagline }); + s.fill(x, p.topBarHeight(), w, 1, .{ .bg = .{ .rgb = bg }, .font_role = .tagline }); const bar_scroll = if (p.topbar_col != null and p.header_column == c) p.header_scroll else 0; const tag = p.columnTag(c); - _ = s.print(x, TOPBAR_H, w, tag[panes.File.rawAtDisplay(tag, bar_scroll)..], .{ + _ = s.print(x, p.topBarHeight(), w, tag[panes.File.rawAtDisplay(tag, bar_scroll)..], .{ .fg = .{ .rgb = fg }, .bg = .{ .rgb = bg }, .font_role = .tagline, }); - if (p.pointer_inside and p.hover_row == TOPBAR_H and p.hover_col >= x and p.hover_col < x + w) { + if (p.pointer_inside and p.hover_row == p.topBarHeight() and p.hover_col >= x and p.hover_col < x + w) { const bar = p.columnTag(c); if (wordBoundsAtCol(bar, panes.File.rawAtDisplay(bar, p.hover_col - x + bar_scroll))) |bounds| { var col = panes.File.rawDisplayCol(bar, bounds.lo) -| bar_scroll; const hi = panes.File.rawDisplayCol(bar, bounds.hi) -| bar_scroll; while (col < hi and col < w) : (col += 1) { - const cell = s.at(x + @as(u16, @intCast(col)), TOPBAR_H); + const cell = s.at(x + @as(u16, @intCast(col)), p.topBarHeight()); cell.style.bg = .{ .rgb = th.sel_bg }; cell.style.fg = .{ .rgb = th.sel_fg }; } @@ -13324,7 +13365,7 @@ pub const Pardes = struct { const bar = p.headerText(); const x = if (p.header_column) |c| p.col_x[c] + TAG_TEXT_INSET else 0; const w = if (p.header_column) |c| p.col_w[c] -| TAG_TEXT_INSET else s.cols; - const y: u16 = if (p.header_column != null) TOPBAR_H else 0; + const y: u16 = if (p.header_column != null) p.topBarHeight() else 0; const anchor = p.header_anchor orelse cur; var col = panes.File.rawDisplayCol(bar, @min(cur, anchor)) -| p.header_scroll; const hi = panes.File.rawDisplayCol(bar, @max(cur, anchor)) -| p.header_scroll; @@ -13342,7 +13383,7 @@ pub const Pardes = struct { switch (p.drag) { .border_v => |d| { if (d.cur_x < s.cols) { - var row: u16 = TOPBAR_H; + var row: u16 = p.topBarHeight(); while (row < s.rows) : (row += 1) s.overlayDash(d.cur_x, row, "╎"); } if (d.corner) |k| if (d.cur_y < s.rows) { @@ -13367,11 +13408,11 @@ pub const Pardes = struct { for (&s.body_layers) |*layer| if (layer.rows > 0 and layer.viewport.x + layer.viewport.w == s.cols) { layer.viewport.w -|= 1; }; - for (&s.tag_layers) |*layer| if (layer.cols > 0 and layer.viewport.x + layer.viewport.w == s.cols and layer.viewport.y >= TOPBAR_H) { + for (&s.tag_layers) |*layer| if (layer.cols > 0 and layer.viewport.x + layer.viewport.w == s.cols and layer.viewport.y >= p.topBarHeight()) { layer.viewport.w -|= 1; }; } - var row: u16 = TOPBAR_H; + var row: u16 = p.topBarHeight(); while (row < s.rows) : (row += 1) s.overlayDash(x, row, "╎"); } }, @@ -13389,7 +13430,7 @@ pub const Pardes = struct { var c: usize = 0; while (c + 1 < p.ncol) : (c += 1) { if (p.hover_col == p.col_x[c] + p.col_w[c] -| 1) { - var row: u16 = TOPBAR_H; + var row: u16 = p.topBarHeight(); while (row < s.rows) : (row += 1) s.overlayDash(p.hover_col, row, "╎"); } } @@ -13443,27 +13484,27 @@ pub const Pardes = struct { const ow: u16 = 38; const oh: u16 = 10; const ox: u16 = if (s.cols > ow) s.cols - ow else 0; - if (ox + ow <= s.cols and TOPBAR_H + oh <= s.rows) { + if (ox + ow <= s.cols and p.topBarHeight() + oh <= s.rows) { // vaxis single_rounded border ring, default style - s.set(ox, TOPBAR_H, "╭", .{}); - s.set(ox + ow - 1, TOPBAR_H, "╮", .{}); - s.set(ox, TOPBAR_H + oh - 1, "╰", .{}); - s.set(ox + ow - 1, TOPBAR_H + oh - 1, "╯", .{}); + s.set(ox, p.topBarHeight(), "╭", .{}); + s.set(ox + ow - 1, p.topBarHeight(), "╮", .{}); + s.set(ox, p.topBarHeight() + oh - 1, "╰", .{}); + s.set(ox + ow - 1, p.topBarHeight() + oh - 1, "╯", .{}); var bx = ox + 1; while (bx < ox + ow - 1) : (bx += 1) { - s.set(bx, TOPBAR_H, "─", .{}); - s.set(bx, TOPBAR_H + oh - 1, "─", .{}); + s.set(bx, p.topBarHeight(), "─", .{}); + s.set(bx, p.topBarHeight() + oh - 1, "─", .{}); } - var by = TOPBAR_H + 1; - while (by < TOPBAR_H + oh - 1) : (by += 1) { + var by = p.topBarHeight() + 1; + while (by < p.topBarHeight() + oh - 1) : (by += 1) { s.set(ox, by, "│", .{}); s.set(ox + ow - 1, by, "│", .{}); } - s.fill(ox + 1, TOPBAR_H + 1, ow - 2, oh - 2, .{ .bg = .{ .rgb = chrome.scroll_track } }); + s.fill(ox + 1, p.topBarHeight() + 1, ow - 2, oh - 2, .{ .bg = .{ .rgb = chrome.scroll_track } }); var lines = std.mem.splitScalar(u8, text, '\n'); - var ly: u16 = TOPBAR_H + 1; + var ly: u16 = p.topBarHeight() + 1; while (lines.next()) |line| : (ly += 1) { - if (ly >= TOPBAR_H + oh - 1) break; + if (ly >= p.topBarHeight() + oh - 1) break; _ = s.print(ox + 1, ly, ow - 2, line, .{ .fg = .{ .rgb = chrome.tag_fg } }); } } @@ -13702,11 +13743,14 @@ pub const Pardes = struct { layer.cursor = if (p.topbar_col == null and pane.promptAt() == null and temporary.cursor != null) .{ .col = temporary.cursor.?.x - TAG_TEXT_INSET, .bar = temporary.cursor.?.bar } else null; } var text_buf: [1200]u8 = undefined; - try p.renderHeaderLayer(arena, MAX_PANES + MAX_COLS, .workspace, 0, .{ .x = 0, .y = 0, .w = p.screen_w, .h = TOPBAR_H }, p.topbar(&text_buf), chrome.tag_bg, chrome.tag_fg); + // With the workspace tag row handed to native chrome there is no + // workspace layer to render; the menu bar carries its commands. + if (p.settings.workspace_tag) + try p.renderHeaderLayer(arena, MAX_PANES + MAX_COLS, .workspace, 0, .{ .x = 0, .y = 0, .w = p.screen_w, .h = TOPBAR_H }, p.topbar(&text_buf), chrome.tag_bg, chrome.tag_fg); if (p.columnBarHeight() > 0) for (0..p.ncol) |column| { if (p.col_w[column] == 0) continue; const active = if (layout.findPane(p, p.active)) |found| found.col == column and p.settings.focus_tint else false; - try p.renderHeaderLayer(arena, MAX_PANES + column, .column, @intCast(column), .{ .x = p.col_x[column] + @min(TAG_TEXT_INSET, p.col_w[column]), .y = TOPBAR_H, .w = p.col_w[column] -| TAG_TEXT_INSET, .h = COLBAR_H }, p.columnTag(column), if (active) chrome.tag_active_bg else chrome.tag_bg, if (active) chrome.tag_active_fg else chrome.tag_fg); + try p.renderHeaderLayer(arena, MAX_PANES + column, .column, @intCast(column), .{ .x = p.col_x[column] + @min(TAG_TEXT_INSET, p.col_w[column]), .y = p.topBarHeight(), .w = p.col_w[column] -| TAG_TEXT_INSET, .h = COLBAR_H }, p.columnTag(column), if (active) chrome.tag_active_bg else chrome.tag_bg, if (active) chrome.tag_active_fg else chrome.tag_fg); }; } @@ -14010,13 +14054,14 @@ pub const Pardes = struct { if (p.look_hover_preview) |preview| { if (preview.pane == id and preview.serial == pane.serial) { // Preserve body ink, then let every real user selection below - // win over this quiet affordance. + // win over this quiet affordance. mark_hover carries the + // cells this paints out to the hosts as the affordance rect — + // macOS composes its glass overlay over exactly these. const preview_bg = mix(page_rgb, mix(page_rgb, th.sel_bg)); if (preview.file_word) |word| panes.File.paintWordSelection(p, pane, r, word.row, word.lo, word.hi, preview_bg) else if (preview.sel) |sel| - if (@max(sel.r0, sel.r1) >= BOX_H) - p.paintPointerSelection(pane, r, tx, tw, tag_y, body_y, sel, preview_bg, null); + p.paintPointerSelection(pane, r, tx, tw, tag_y, body_y, sel, preview_bg, null); } } const modal_hover = if (p.look_hover_preview) |preview| diff --git a/src/themes/acme.zig b/src/themes/acme.zig index 87183ebc..d91e626b 100644 --- a/src/themes/acme.zig +++ b/src/themes/acme.zig @@ -14,13 +14,13 @@ pub const theme = .{ .name = "acme", .bg = .{ 0xff, 0xff, 0xea }, .fg = .{ 0x00, 0x00, 0x00 }, - .sel_bg = .{ 0xee, 0xee, 0x9e }, + .sel_bg = .{ 0xfa, 0xfa, 0x92 }, .sel_fg = .{ 0x00, 0x00, 0x00 }, .tag_bg = .{ 0xea, 0xff, 0xff }, .tag_fg = .{ 0x00, 0x00, 0x00 }, - .box = .{ 0x6e, 0x4f, 0xd0 }, - .box_dim = .{ 0x38, 0x3c, 0x54 }, - .kw = .{ 0x88, 0x22, 0x99 }, + .box = .{ 0x66, 0x3f, 0xe0 }, + .box_dim = .{ 0x35, 0x3a, 0x58 }, + .kw = .{ 0x97, 0x0d, 0xae }, .str = .{ 0x00, 0x77, 0x33 }, .num = .{ 0xa0, 0x52, 0x00 }, .comment = .{ 0x55, 0x55, 0x55 }, diff --git a/src/themes/atelier.zig b/src/themes/atelier.zig index 0193e2e9..f367c341 100644 --- a/src/themes/atelier.zig +++ b/src/themes/atelier.zig @@ -11,27 +11,27 @@ pub const theme = .{ .tag_active_name_fg = .{ 0x65, 0x3f, 0x6b }, .tag_active_bg = .{ 0xd3, 0xe7, 0xdf }, .tag_active_fg = .{ 0x35, 0x58, 0x4d }, - .box = .{ 0x3e, 0x7a, 0x68 }, - .box_dim = .{ 0x99, 0xb6, 0xa3 }, - .column_box = .{ 0x88, 0x57, 0x22 }, - .column_box_dim = .{ 0xb6, 0xa3, 0x87 }, - .kw = .{ 0x76, 0x4d, 0x80 }, - .str = .{ 0x3c, 0x6c, 0x43 }, - .num = .{ 0x88, 0x57, 0x22 }, - .comment = .{ 0x35, 0x73, 0x3a }, + .box = .{ 0x36, 0x82, 0x6b }, + .box_dim = .{ 0x95, 0xba, 0xa2 }, + .column_box = .{ 0x95, 0x58, 0x15 }, + .column_box_dim = .{ 0xbc, 0xa4, 0x81 }, + .kw = .{ 0x7b, 0x44, 0x89 }, + .str = .{ 0x34, 0x74, 0x3d }, + .num = .{ 0x9a, 0x58, 0x10 }, + .comment = .{ 0x29, 0x7c, 0x30 }, .lineno = .{ 0x90, 0x98, 0x80 }, .lineno_active = .{ 0x88, 0x90, 0x78 }, .scroll_track = .{ 0xee, 0xec, 0xcf }, - .scroll_thumb = .{ 0x9d, 0xa9, 0x7b }, - .border = .{ 0xb8, 0xc8, 0xb4 }, - .sel_bg = .{ 0xe5, 0xe9, 0xae }, + .scroll_thumb = .{ 0x9f, 0xae, 0x76 }, + .border = .{ 0xff, 0xff, 0xff }, + .sel_bg = .{ 0xed, 0xf2, 0xa5 }, .sel_fg = .{ 0x35, 0x49, 0x2d }, - .search_bg = .{ 0xf0, 0xd7, 0x94 }, + .search_bg = .{ 0xfe, 0xdd, 0x86 }, .search_fg = .{ 0x61, 0x47, 0x15 }, - .diagnostic_error = .{ 0xa3, 0x3d, 0x37 }, - .diagnostic_warning = .{ 0x81, 0x59, 0x08 }, - .diagnostic_info = .{ 0x33, 0x65, 0x78 }, - .diagnostic_hint = .{ 0x52, 0x6e, 0x3d }, + .diagnostic_error = .{ 0xb3, 0x2f, 0x27 }, + .diagnostic_warning = .{ 0x89, 0x5c, 0x00 }, + .diagnostic_info = .{ 0x29, 0x6a, 0x82 }, + .diagnostic_hint = .{ 0x51, 0x75, 0x36 }, .palette = .{ .{ 0x29, 0x3f, 0x35 }, .{ 0xa3, 0x3d, 0x37 }, diff --git a/src/themes/clay.zig b/src/themes/clay.zig index af824764..85487d48 100644 --- a/src/themes/clay.zig +++ b/src/themes/clay.zig @@ -12,27 +12,27 @@ pub const theme = .{ .tag_active_name_fg = .{ 0xb5, 0xec, 0xec }, .tag_active_bg = .{ 0x42, 0x4f, 0x40 }, .tag_active_fg = .{ 0xe3, 0xe2, 0xc2 }, - .box = .{ 0x8e, 0xc0, 0x7c }, - .box_dim = .{ 0x67, 0x77, 0x52 }, - .column_box = .{ 0xd3, 0x86, 0x9b }, - .column_box_dim = .{ 0x83, 0x62, 0x68 }, - .kw = .{ 0xfb, 0x8a, 0x69 }, - .str = .{ 0xb8, 0xbb, 0x26 }, - .num = .{ 0xd3, 0x86, 0x9b }, - .comment = .{ 0xe2, 0xb5, 0x6f }, + .box = .{ 0x8a, 0xc8, 0x74 }, + .box_dim = .{ 0x68, 0x7c, 0x4d }, + .column_box = .{ 0xdd, 0x7c, 0x97 }, + .column_box_dim = .{ 0x87, 0x5e, 0x65 }, + .kw = .{ 0xff, 0x88, 0x65 }, + .str = .{ 0xd1, 0xd5, 0x0c }, + .num = .{ 0xe0, 0x79, 0x95 }, + .comment = .{ 0xf6, 0xb9, 0x5b }, .lineno = .{ 0x69, 0x64, 0x55 }, .lineno_active = .{ 0x71, 0x6c, 0x5d }, .scroll_track = .{ 0x22, 0x21, 0x19 }, - .scroll_thumb = .{ 0x8a, 0x90, 0x6b }, - .border = .{ 0x56, 0x64, 0x48 }, - .sel_bg = .{ 0x4f, 0x58, 0x3c }, + .scroll_thumb = .{ 0x8c, 0x94, 0x67 }, + .border = .{ 0x74, 0x87, 0x61 }, + .sel_bg = .{ 0x50, 0x5c, 0x38 }, .sel_fg = .{ 0xfb, 0xf1, 0xc7 }, - .search_bg = .{ 0x66, 0x51, 0x28 }, + .search_bg = .{ 0x6f, 0x54, 0x1f }, .search_fg = .{ 0xff, 0xe2, 0xa0 }, - .diagnostic_error = .{ 0xfb, 0x8a, 0x69 }, - .diagnostic_warning = .{ 0xfa, 0xbd, 0x2f }, - .diagnostic_info = .{ 0x83, 0xb5, 0xa8 }, - .diagnostic_hint = .{ 0x8e, 0xc0, 0x7c }, + .diagnostic_error = .{ 0xff, 0x88, 0x65 }, + .diagnostic_warning = .{ 0xff, 0xbf, 0x2a }, + .diagnostic_info = .{ 0x7b, 0xbd, 0xac }, + .diagnostic_hint = .{ 0x89, 0xca, 0x72 }, .palette = .{ .{ 0x10, 0x10, 0x0e }, .{ 0xfb, 0x8a, 0x69 }, diff --git a/src/themes/dark.zig b/src/themes/dark.zig index 5b39b1c7..82396397 100644 --- a/src/themes/dark.zig +++ b/src/themes/dark.zig @@ -13,15 +13,15 @@ pub const theme = .{ .name = "dark", .bg = null, .fg = null, - .sel_bg = .{ 0x4a, 0x3a, 0x1e }, + .sel_bg = .{ 0x51, 0x3c, 0x17 }, .sel_fg = .{ 0xd8, 0xc8, 0xa8 }, .tag_bg = .{ 0x2c, 0x2a, 0x3e }, .tag_fg = .{ 0x96, 0x96, 0x96 }, - .box = .{ 0x6e, 0x4f, 0xd0 }, - .box_dim = .{ 0x38, 0x3c, 0x54 }, - .kw = .{ 0xcc, 0x70, 0xd8 }, - .str = .{ 0x8a, 0xb8, 0x7a }, - .num = .{ 0xd0, 0xc0, 0x70 }, + .box = .{ 0x66, 0x3f, 0xe0 }, + .box_dim = .{ 0x35, 0x3a, 0x58 }, + .kw = .{ 0xda, 0x5e, 0xea }, + .str = .{ 0x85, 0xc3, 0x6f }, + .num = .{ 0xe1, 0xcb, 0x5f }, .comment = .{ 0xf0, 0xf0, 0xf0 }, .lineno = .{ 0x5a, 0x5a, 0x5a }, .scroll_track = .{ 0x2a, 0x2a, 0x2a }, diff --git a/src/themes/daybreak.zig b/src/themes/daybreak.zig index c55069a9..80f4883c 100644 --- a/src/themes/daybreak.zig +++ b/src/themes/daybreak.zig @@ -11,27 +11,27 @@ pub const theme = .{ .tag_active_name_fg = .{ 0x52, 0x25, 0x5f }, .tag_active_bg = .{ 0xdf, 0xea, 0xf3 }, .tag_active_fg = .{ 0x21, 0x3e, 0x56 }, - .box = .{ 0x07, 0x5f, 0x91 }, - .box_dim = .{ 0x81, 0x9d, 0xb1 }, - .column_box = .{ 0x76, 0x42, 0x09 }, - .column_box_dim = .{ 0xb1, 0x9a, 0x80 }, - .kw = .{ 0x62, 0x2a, 0x88 }, - .str = .{ 0x24, 0x5b, 0x30 }, - .num = .{ 0x76, 0x42, 0x09 }, - .comment = .{ 0x14, 0x56, 0x38 }, + .box = .{ 0x00, 0x61, 0x98 }, + .box_dim = .{ 0x7b, 0x9e, 0xb7 }, + .column_box = .{ 0x7f, 0x42, 0x00 }, + .column_box_dim = .{ 0xb7, 0x9a, 0x7a }, + .kw = .{ 0x65, 0x1a, 0x98 }, + .str = .{ 0x1a, 0x65, 0x2b }, + .num = .{ 0x7f, 0x42, 0x00 }, + .comment = .{ 0x08, 0x62, 0x39 }, .lineno = .{ 0x88, 0x93, 0x9b }, .lineno_active = .{ 0x80, 0x8b, 0x93 }, .scroll_track = .{ 0xe6, 0xed, 0xf3 }, - .scroll_thumb = .{ 0x6b, 0x85, 0x9b }, - .border = .{ 0x85, 0x9b, 0xac }, - .sel_bg = .{ 0xc1, 0xde, 0xf3 }, + .scroll_thumb = .{ 0x66, 0x85, 0xa0 }, + .border = .{ 0xc5, 0xcf, 0xd7 }, + .sel_bg = .{ 0xb9, 0xdf, 0xfb }, .sel_fg = .{ 0x10, 0x36, 0x4f }, .search_bg = .{ 0xff, 0xe3, 0x96 }, .search_fg = .{ 0x4b, 0x35, 0x00 }, - .diagnostic_error = .{ 0xa1, 0x1c, 0x30 }, + .diagnostic_error = .{ 0xb3, 0x08, 0x22 }, .diagnostic_warning = .{ 0x70, 0x49, 0x00 }, - .diagnostic_info = .{ 0x07, 0x5a, 0x83 }, - .diagnostic_hint = .{ 0x38, 0x55, 0x2b }, + .diagnostic_info = .{ 0x00, 0x5c, 0x8a }, + .diagnostic_hint = .{ 0x36, 0x5b, 0x25 }, .palette = .{ .{ 0x14, 0x2d, 0x40 }, .{ 0xa1, 0x1c, 0x30 }, diff --git a/src/themes/dusk.zig b/src/themes/dusk.zig index 32948d02..b9377992 100644 --- a/src/themes/dusk.zig +++ b/src/themes/dusk.zig @@ -11,27 +11,27 @@ pub const theme = .{ .tag_active_name_fg = .{ 0xa1, 0xd5, 0xc4 }, .tag_active_bg = .{ 0x3b, 0x2f, 0x3b }, .tag_active_fg = .{ 0xd2, 0xc2, 0xd1 }, - .box = .{ 0xe4, 0xb3, 0x9b }, - .box_dim = .{ 0x71, 0x57, 0x68 }, - .column_box = .{ 0xba, 0xc8, 0x94 }, - .column_box_dim = .{ 0x73, 0x77, 0x62 }, - .kw = .{ 0xcf, 0xb1, 0xe8 }, - .str = .{ 0xba, 0xc8, 0x94 }, - .num = .{ 0xe8, 0xb5, 0x92 }, - .comment = .{ 0xf1, 0xb9, 0x89 }, + .box = .{ 0xed, 0xb0, 0x92 }, + .box_dim = .{ 0x74, 0x54, 0x69 }, + .column_box = .{ 0xbd, 0xce, 0x8e }, + .column_box_dim = .{ 0x75, 0x7a, 0x5f }, + .kw = .{ 0xd0, 0xa7, 0xf2 }, + .str = .{ 0xbe, 0xd1, 0x8b }, + .num = .{ 0xf7, 0xb2, 0x83 }, + .comment = .{ 0xff, 0xb8, 0x7b }, .lineno = .{ 0x82, 0x71, 0x7e }, .lineno_active = .{ 0x8a, 0x79, 0x86 }, .scroll_track = .{ 0x3d, 0x35, 0x40 }, - .scroll_thumb = .{ 0x8b, 0x69, 0x7c }, - .border = .{ 0x51, 0x41, 0x4f }, - .sel_bg = .{ 0x61, 0x44, 0x53 }, + .scroll_thumb = .{ 0x8e, 0x66, 0x7c }, + .border = .{ 0x6d, 0x58, 0x6b }, + .sel_bg = .{ 0x65, 0x40, 0x53 }, .sel_fg = .{ 0xff, 0xf0, 0xeb }, - .search_bg = .{ 0x5e, 0x49, 0x2e }, + .search_bg = .{ 0x65, 0x4a, 0x27 }, .search_fg = .{ 0xff, 0xe3, 0xa2 }, - .diagnostic_error = .{ 0xf6, 0xaa, 0xa4 }, - .diagnostic_warning = .{ 0xed, 0xca, 0x8a }, - .diagnostic_info = .{ 0xaa, 0xcb, 0xdc }, - .diagnostic_hint = .{ 0xc2, 0xcd, 0xa1 }, + .diagnostic_error = .{ 0xff, 0xa2, 0x9b }, + .diagnostic_warning = .{ 0xfc, 0xce, 0x7b }, + .diagnostic_info = .{ 0xa2, 0xcd, 0xe4 }, + .diagnostic_hint = .{ 0xc5, 0xd4, 0x9a }, .palette = .{ .{ 0x39, 0x32, 0x3b }, .{ 0xf6, 0xaa, 0xa4 }, diff --git a/src/themes/forge.zig b/src/themes/forge.zig index 7f78f2ca..a27f66fb 100644 --- a/src/themes/forge.zig +++ b/src/themes/forge.zig @@ -12,27 +12,27 @@ pub const theme = .{ .tag_active_name_fg = .{ 0xf8, 0xcb, 0xa7 }, .tag_active_bg = .{ 0x2d, 0x34, 0x40 }, .tag_active_fg = .{ 0xd1, 0xd5, 0xde }, - .box = .{ 0xa5, 0xc4, 0xee }, - .box_dim = .{ 0x59, 0x65, 0x77 }, - .column_box = .{ 0xb5, 0xce, 0xa8 }, - .column_box_dim = .{ 0x6b, 0x79, 0x69 }, - .kw = .{ 0x75, 0xb5, 0xe8 }, - .str = .{ 0xce, 0x91, 0x78 }, - .num = .{ 0xb5, 0xce, 0xa8 }, + .box = .{ 0x9c, 0xc3, 0xf7 }, + .box_dim = .{ 0x55, 0x64, 0x7b }, + .column_box = .{ 0xb4, 0xd3, 0xa3 }, + .column_box_dim = .{ 0x6a, 0x7b, 0x67 }, + .kw = .{ 0x61, 0xb7, 0xfc }, + .str = .{ 0xdd, 0x8b, 0x69 }, + .num = .{ 0xb3, 0xd5, 0xa1 }, .comment = .{ 0xb3, 0xca, 0xff }, .lineno = .{ 0x62, 0x65, 0x6c }, .lineno_active = .{ 0x6a, 0x6d, 0x74 }, .scroll_track = .{ 0x1a, 0x1c, 0x21 }, - .scroll_thumb = .{ 0x73, 0x80, 0x92 }, - .border = .{ 0x47, 0x52, 0x63 }, - .sel_bg = .{ 0x26, 0x4f, 0x68 }, + .scroll_thumb = .{ 0x70, 0x80, 0x95 }, + .border = .{ 0x60, 0x6f, 0x86 }, + .sel_bg = .{ 0x1c, 0x51, 0x72 }, .sel_fg = .{ 0xe2, 0xee, 0xf4 }, - .search_bg = .{ 0x59, 0x4a, 0x25 }, + .search_bg = .{ 0x61, 0x4d, 0x1d }, .search_fg = .{ 0xf5, 0xdf, 0xa1 }, - .diagnostic_error = .{ 0xf2, 0x8a, 0x81 }, - .diagnostic_warning = .{ 0xd7, 0xba, 0x7d }, + .diagnostic_error = .{ 0xff, 0x7f, 0x74 }, + .diagnostic_warning = .{ 0xe4, 0xbf, 0x70 }, .diagnostic_info = .{ 0x75, 0xbe, 0xff }, - .diagnostic_hint = .{ 0x8b, 0xce, 0xba }, + .diagnostic_hint = .{ 0x81, 0xd8, 0xbe }, // ANSI roles are semantic colors, independent of peach string syntax. .palette = .{ .{ 0x0c, 0x0c, 0x0e }, diff --git a/src/themes/forge_black.zig b/src/themes/forge_black.zig index d9835110..85f6132e 100644 --- a/src/themes/forge_black.zig +++ b/src/themes/forge_black.zig @@ -12,27 +12,27 @@ pub const theme = .{ .tag_active_name_fg = .{ 0xf8, 0xcb, 0xa7 }, .tag_active_bg = .{ 0x2d, 0x34, 0x40 }, .tag_active_fg = .{ 0xd1, 0xd5, 0xde }, - .box = .{ 0xa5, 0xc4, 0xee }, - .box_dim = .{ 0x59, 0x65, 0x77 }, - .column_box = .{ 0xb5, 0xce, 0xa8 }, - .column_box_dim = .{ 0x6b, 0x79, 0x69 }, - .kw = .{ 0x75, 0xb5, 0xe8 }, - .str = .{ 0xce, 0x91, 0x78 }, - .num = .{ 0xb5, 0xce, 0xa8 }, + .box = .{ 0x9c, 0xc3, 0xf7 }, + .box_dim = .{ 0x55, 0x64, 0x7b }, + .column_box = .{ 0xb4, 0xd3, 0xa3 }, + .column_box_dim = .{ 0x6a, 0x7b, 0x67 }, + .kw = .{ 0x61, 0xb7, 0xfc }, + .str = .{ 0xdd, 0x8b, 0x69 }, + .num = .{ 0xb3, 0xd5, 0xa1 }, .comment = .{ 0xb3, 0xca, 0xff }, .lineno = .{ 0x62, 0x65, 0x6c }, .lineno_active = .{ 0x6a, 0x6d, 0x74 }, .scroll_track = .{ 0x14, 0x16, 0x1a }, - .scroll_thumb = .{ 0x73, 0x80, 0x92 }, - .border = .{ 0x47, 0x52, 0x63 }, - .sel_bg = .{ 0x26, 0x4f, 0x68 }, + .scroll_thumb = .{ 0x70, 0x80, 0x95 }, + .border = .{ 0x60, 0x6f, 0x86 }, + .sel_bg = .{ 0x1c, 0x51, 0x72 }, .sel_fg = .{ 0xe2, 0xee, 0xf4 }, - .search_bg = .{ 0x59, 0x4a, 0x25 }, + .search_bg = .{ 0x61, 0x4d, 0x1d }, .search_fg = .{ 0xf5, 0xdf, 0xa1 }, - .diagnostic_error = .{ 0xf2, 0x8a, 0x81 }, - .diagnostic_warning = .{ 0xd7, 0xba, 0x7d }, + .diagnostic_error = .{ 0xff, 0x7f, 0x74 }, + .diagnostic_warning = .{ 0xe4, 0xbf, 0x70 }, .diagnostic_info = .{ 0x75, 0xbe, 0xff }, - .diagnostic_hint = .{ 0x8b, 0xce, 0xba }, + .diagnostic_hint = .{ 0x81, 0xd8, 0xbe }, // ANSI roles are semantic colors, independent of peach string syntax. .palette = .{ .{ 0x00, 0x00, 0x00 }, diff --git a/src/themes/forge_soft.zig b/src/themes/forge_soft.zig index 896bd9e8..0ca062a4 100644 --- a/src/themes/forge_soft.zig +++ b/src/themes/forge_soft.zig @@ -12,27 +12,27 @@ pub const theme = .{ .tag_active_name_fg = .{ 0xf8, 0xcb, 0xa7 }, .tag_active_bg = .{ 0x37, 0x3e, 0x49 }, .tag_active_fg = .{ 0xd1, 0xd5, 0xde }, - .box = .{ 0xa5, 0xc4, 0xee }, - .box_dim = .{ 0x59, 0x65, 0x77 }, - .column_box = .{ 0xb5, 0xce, 0xa8 }, - .column_box_dim = .{ 0x6f, 0x7d, 0x6e }, - .kw = .{ 0x75, 0xb5, 0xe8 }, - .str = .{ 0xda, 0xa5, 0x8e }, - .num = .{ 0xb5, 0xce, 0xa8 }, + .box = .{ 0x9c, 0xc3, 0xf7 }, + .box_dim = .{ 0x55, 0x64, 0x7b }, + .column_box = .{ 0xb4, 0xd3, 0xa3 }, + .column_box_dim = .{ 0x6d, 0x7f, 0x6c }, + .kw = .{ 0x61, 0xb7, 0xfc }, + .str = .{ 0xe7, 0xa0, 0x81 }, + .num = .{ 0xb3, 0xd5, 0xa1 }, .comment = .{ 0xb3, 0xca, 0xff }, .lineno = .{ 0x86, 0x89, 0x91 }, .lineno_active = .{ 0x8e, 0x91, 0x99 }, .scroll_track = .{ 0x3d, 0x40, 0x47 }, - .scroll_thumb = .{ 0x73, 0x80, 0x92 }, - .border = .{ 0x47, 0x52, 0x63 }, - .sel_bg = .{ 0x26, 0x4f, 0x68 }, + .scroll_thumb = .{ 0x70, 0x80, 0x95 }, + .border = .{ 0x60, 0x6f, 0x86 }, + .sel_bg = .{ 0x1c, 0x51, 0x72 }, .sel_fg = .{ 0xe2, 0xee, 0xf4 }, - .search_bg = .{ 0x59, 0x4a, 0x25 }, + .search_bg = .{ 0x61, 0x4d, 0x1d }, .search_fg = .{ 0xf5, 0xdf, 0xa1 }, - .diagnostic_error = .{ 0xf2, 0x8a, 0x81 }, - .diagnostic_warning = .{ 0xd7, 0xba, 0x7d }, + .diagnostic_error = .{ 0xff, 0x7f, 0x74 }, + .diagnostic_warning = .{ 0xe4, 0xbf, 0x70 }, .diagnostic_info = .{ 0x75, 0xbe, 0xff }, - .diagnostic_hint = .{ 0x8b, 0xce, 0xba }, + .diagnostic_hint = .{ 0x81, 0xd8, 0xbe }, // ANSI roles are semantic colors, independent of peach string syntax. .palette = .{ .{ 0x35, 0x38, 0x3e }, diff --git a/src/themes/harvest.zig b/src/themes/harvest.zig index bf367a24..cf10a779 100644 --- a/src/themes/harvest.zig +++ b/src/themes/harvest.zig @@ -12,27 +12,27 @@ pub const theme = .{ .tag_active_name_fg = .{ 0xc5, 0xe7, 0xf7 }, .tag_active_bg = .{ 0x42, 0x4d, 0x38 }, .tag_active_fg = .{ 0xe1, 0xe4, 0xc4 }, - .box = .{ 0xcf, 0xba, 0x8b }, - .box_dim = .{ 0x77, 0x79, 0x53 }, - .column_box = .{ 0xf0, 0x7d, 0x63 }, - .column_box_dim = .{ 0x92, 0x5c, 0x48 }, - .kw = .{ 0xf0, 0x7d, 0x63 }, - .str = .{ 0x99, 0xbe, 0x70 }, - .num = .{ 0xfa, 0xd5, 0x66 }, - .comment = .{ 0xef, 0xc7, 0x8c }, + .box = .{ 0xd8, 0xbd, 0x83 }, + .box_dim = .{ 0x7b, 0x7e, 0x4e }, + .column_box = .{ 0xff, 0x74, 0x54 }, + .column_box_dim = .{ 0x9b, 0x58, 0x3f }, + .kw = .{ 0xff, 0x74, 0x54 }, + .str = .{ 0x9a, 0xcc, 0x62 }, + .num = .{ 0xff, 0xd8, 0x61 }, + .comment = .{ 0xff, 0xca, 0x7c }, .lineno = .{ 0x6a, 0x64, 0x56 }, .lineno_active = .{ 0x72, 0x6c, 0x5e }, .scroll_track = .{ 0x20, 0x1d, 0x17 }, - .scroll_thumb = .{ 0x85, 0x8a, 0x62 }, - .border = .{ 0x59, 0x65, 0x47 }, - .sel_bg = .{ 0x4d, 0x54, 0x38 }, + .scroll_thumb = .{ 0x88, 0x8e, 0x5e }, + .border = .{ 0x78, 0x88, 0x60 }, + .sel_bg = .{ 0x4f, 0x58, 0x34 }, .sel_fg = .{ 0xf3, 0xf2, 0xcc }, - .search_bg = .{ 0x66, 0x45, 0x2d }, + .search_bg = .{ 0x6f, 0x44, 0x24 }, .search_fg = .{ 0xff, 0xe2, 0xac }, - .diagnostic_error = .{ 0xf5, 0x8a, 0x73 }, - .diagnostic_warning = .{ 0xfa, 0xd5, 0x66 }, - .diagnostic_info = .{ 0x86, 0xc1, 0xb9 }, - .diagnostic_hint = .{ 0xb5, 0xc6, 0x8c }, + .diagnostic_error = .{ 0xff, 0x84, 0x69 }, + .diagnostic_warning = .{ 0xff, 0xd8, 0x61 }, + .diagnostic_info = .{ 0x7d, 0xca, 0xbf }, + .diagnostic_hint = .{ 0xb9, 0xcf, 0x83 }, .palette = .{ .{ 0x10, 0x0e, 0x0b }, .{ 0xf5, 0x8a, 0x73 }, diff --git a/src/themes/helix.zig b/src/themes/helix.zig index 3c2934f7..76eaeab2 100644 --- a/src/themes/helix.zig +++ b/src/themes/helix.zig @@ -45,9 +45,9 @@ pub const theme = .{ .tag_fg = .{ 0x94, 0x94, 0x94 }, .box = .{ 0x62, 0x62, 0x62 }, .box_dim = .{ 0x26, 0x26, 0x26 }, - .kw = .{ 0xcf, 0x87, 0xe8 }, - .str = .{ 0xe3, 0xc7, 0x8a }, - .num = .{ 0xe3, 0xc7, 0x8a }, + .kw = .{ 0xd7, 0x76, 0xf9 }, + .str = .{ 0xf3, 0xcd, 0x7a }, + .num = .{ 0xf3, 0xcd, 0x7a }, .comment = .{ 0xff, 0xff, 0xff }, .lineno = .{ 0x62, 0x62, 0x62 }, .scroll_track = .{ 0x12, 0x12, 0x12 }, diff --git a/src/themes/ink.zig b/src/themes/ink.zig index 3b92a635..1e254a3c 100644 --- a/src/themes/ink.zig +++ b/src/themes/ink.zig @@ -12,26 +12,26 @@ pub const theme = .{ .tag_active_bg = .{ 0x22, 0x33, 0x42 }, .tag_active_fg = .{ 0xe1, 0xee, 0xf9 }, .box = .{ 0x86, 0xd8, 0xff }, - .box_dim = .{ 0x64, 0x79, 0x8b }, + .box_dim = .{ 0x5f, 0x79, 0x90 }, .column_box = .{ 0xff, 0xd6, 0x94 }, - .column_box_dim = .{ 0x8a, 0x7b, 0x60 }, + .column_box_dim = .{ 0x8f, 0x7d, 0x5b }, .kw = .{ 0xd5, 0xb8, 0xff }, - .str = .{ 0xb5, 0xee, 0xae }, + .str = .{ 0xac, 0xf9, 0xa3 }, .num = .{ 0xff, 0xd6, 0x94 }, - .comment = .{ 0xa8, 0xe7, 0xf4 }, + .comment = .{ 0x9d, 0xee, 0xff }, .lineno = .{ 0x62, 0x6b, 0x75 }, .lineno_active = .{ 0x6a, 0x73, 0x7d }, .scroll_track = .{ 0x15, 0x21, 0x2c }, - .scroll_thumb = .{ 0x8b, 0xa7, 0xbd }, - .border = .{ 0x59, 0x6f, 0x83 }, - .sel_bg = .{ 0x26, 0x52, 0x71 }, + .scroll_thumb = .{ 0x86, 0xa8, 0xc2 }, + .border = .{ 0x80, 0x95, 0xa9 }, + .sel_bg = .{ 0x1b, 0x54, 0x7c }, .sel_fg = .{ 0xff, 0xff, 0xff }, - .search_bg = .{ 0x75, 0x50, 0x1b }, + .search_bg = .{ 0x7c, 0x4e, 0x0d }, .search_fg = .{ 0xff, 0xff, 0xff }, .diagnostic_error = .{ 0xff, 0xb1, 0xb1 }, .diagnostic_warning = .{ 0xff, 0xe2, 0x9c }, .diagnostic_info = .{ 0x9b, 0xde, 0xff }, - .diagnostic_hint = .{ 0xc6, 0xe4, 0xb5 }, + .diagnostic_hint = .{ 0xc4, 0xeb, 0xae }, .palette = .{ .{ 0x00, 0x00, 0x00 }, .{ 0xff, 0xb1, 0xb1 }, diff --git a/src/themes/lagoon.zig b/src/themes/lagoon.zig index 516639b0..4d975794 100644 --- a/src/themes/lagoon.zig +++ b/src/themes/lagoon.zig @@ -12,27 +12,27 @@ pub const theme = .{ .tag_active_name_fg = .{ 0xf0, 0xce, 0xf8 }, .tag_active_bg = .{ 0x34, 0x57, 0x4d }, .tag_active_fg = .{ 0xc7, 0xe3, 0xd7 }, - .box = .{ 0x89, 0xc7, 0xb4 }, - .box_dim = .{ 0x59, 0x7e, 0x71 }, + .box = .{ 0x81, 0xcf, 0xb7 }, + .box_dim = .{ 0x54, 0x83, 0x72 }, .column_box = .{ 0xff, 0xad, 0x91 }, - .column_box_dim = .{ 0x94, 0x78, 0x68 }, - .kw = .{ 0xd5, 0xa8, 0xed }, - .str = .{ 0xc3, 0xe8, 0x8d }, + .column_box_dim = .{ 0x9a, 0x76, 0x62 }, + .kw = .{ 0xd9, 0x9c, 0xf9 }, + .str = .{ 0xc6, 0xf8, 0x7d }, .num = .{ 0xff, 0xad, 0x91 }, - .comment = .{ 0x92, 0xe1, 0xd1 }, + .comment = .{ 0x84, 0xef, 0xd9 }, .lineno = .{ 0x7b, 0x91, 0x94 }, .lineno_active = .{ 0x83, 0x99, 0x9c }, .scroll_track = .{ 0x3a, 0x4c, 0x50 }, - .scroll_thumb = .{ 0x72, 0x97, 0x8a }, - .border = .{ 0x50, 0x74, 0x68 }, - .sel_bg = .{ 0x39, 0x5b, 0x65 }, + .scroll_thumb = .{ 0x6e, 0x9b, 0x8b }, + .border = .{ 0x6e, 0x9b, 0x8c }, + .sel_bg = .{ 0x32, 0x5f, 0x6c }, .sel_fg = .{ 0xe6, 0xf2, 0xf3 }, - .search_bg = .{ 0x60, 0x53, 0x27 }, + .search_bg = .{ 0x69, 0x58, 0x1e }, .search_fg = .{ 0xff, 0xf0, 0xb9 }, .diagnostic_error = .{ 0xff, 0x9d, 0xa1 }, .diagnostic_warning = .{ 0xff, 0xcb, 0x6b }, - .diagnostic_info = .{ 0x82, 0xc9, 0xfa }, - .diagnostic_hint = .{ 0x89, 0xdd, 0xcc }, + .diagnostic_info = .{ 0x7d, 0xca, 0xff }, + .diagnostic_hint = .{ 0x7c, 0xea, 0xd4 }, .palette = .{ .{ 0x34, 0x46, 0x4c }, .{ 0xff, 0x9d, 0xa1 }, diff --git a/src/themes/orchard.zig b/src/themes/orchard.zig index 888a5b27..f927c50e 100644 --- a/src/themes/orchard.zig +++ b/src/themes/orchard.zig @@ -11,27 +11,27 @@ pub const theme = .{ .tag_active_name_fg = .{ 0xdf, 0xbc, 0xe5 }, .tag_active_bg = .{ 0x26, 0x36, 0x2d }, .tag_active_fg = .{ 0xbe, 0xcf, 0xc4 }, - .box = .{ 0xad, 0xcc, 0x91 }, - .box_dim = .{ 0x4c, 0x63, 0x56 }, - .column_box = .{ 0xe9, 0xbf, 0x91 }, - .column_box_dim = .{ 0x83, 0x73, 0x5a }, - .kw = .{ 0xc9, 0xb0, 0xe4 }, - .str = .{ 0xb6, 0xce, 0x94 }, - .num = .{ 0xe9, 0xbf, 0x91 }, - .comment = .{ 0xb9, 0xe5, 0x8f }, + .box = .{ 0xad, 0xd3, 0x8a }, + .box_dim = .{ 0x49, 0x66, 0x56 }, + .column_box = .{ 0xf4, 0xc0, 0x86 }, + .column_box_dim = .{ 0x88, 0x74, 0x55 }, + .kw = .{ 0xc9, 0xa7, 0xed }, + .str = .{ 0xb8, 0xd8, 0x8a }, + .num = .{ 0xf8, 0xc0, 0x82 }, + .comment = .{ 0xb9, 0xf4, 0x80 }, .lineno = .{ 0x59, 0x67, 0x5c }, .lineno_active = .{ 0x61, 0x6f, 0x64 }, .scroll_track = .{ 0x15, 0x20, 0x19 }, - .scroll_thumb = .{ 0x63, 0x7f, 0x6a }, - .border = .{ 0x35, 0x48, 0x3d }, - .sel_bg = .{ 0x40, 0x5d, 0x4b }, + .scroll_thumb = .{ 0x60, 0x82, 0x69 }, + .border = .{ 0x48, 0x61, 0x52 }, + .sel_bg = .{ 0x3c, 0x61, 0x4a }, .sel_fg = .{ 0xf5, 0xf7, 0xee }, - .search_bg = .{ 0x57, 0x47, 0x2a }, + .search_bg = .{ 0x5e, 0x49, 0x23 }, .search_fg = .{ 0xf7, 0xe4, 0xa5 }, - .diagnostic_error = .{ 0xf1, 0xa3, 0x9b }, - .diagnostic_warning = .{ 0xe9, 0xc6, 0x80 }, - .diagnostic_info = .{ 0x9b, 0xcb, 0xd5 }, - .diagnostic_hint = .{ 0xb6, 0xc5, 0x9e }, + .diagnostic_error = .{ 0xfe, 0x98, 0x8e }, + .diagnostic_warning = .{ 0xf9, 0xcb, 0x70 }, + .diagnostic_info = .{ 0x92, 0xd1, 0xde }, + .diagnostic_hint = .{ 0xb7, 0xcb, 0x98 }, .palette = .{ .{ 0x0d, 0x14, 0x10 }, .{ 0xf1, 0xa3, 0x9b }, diff --git a/src/themes/orchard_black.zig b/src/themes/orchard_black.zig index be960b93..c700947f 100644 --- a/src/themes/orchard_black.zig +++ b/src/themes/orchard_black.zig @@ -11,27 +11,27 @@ pub const theme = .{ .tag_active_name_fg = .{ 0xdf, 0xbc, 0xe5 }, .tag_active_bg = .{ 0x26, 0x36, 0x2d }, .tag_active_fg = .{ 0xbe, 0xcf, 0xc4 }, - .box = .{ 0xad, 0xcc, 0x91 }, - .box_dim = .{ 0x4c, 0x63, 0x56 }, - .column_box = .{ 0xe9, 0xbf, 0x91 }, - .column_box_dim = .{ 0x83, 0x73, 0x5a }, - .kw = .{ 0xc9, 0xb0, 0xe4 }, - .str = .{ 0xb6, 0xce, 0x94 }, - .num = .{ 0xe9, 0xbf, 0x91 }, - .comment = .{ 0xb9, 0xe5, 0x8f }, + .box = .{ 0xad, 0xd3, 0x8a }, + .box_dim = .{ 0x49, 0x66, 0x56 }, + .column_box = .{ 0xf4, 0xc0, 0x86 }, + .column_box_dim = .{ 0x88, 0x74, 0x55 }, + .kw = .{ 0xc9, 0xa7, 0xed }, + .str = .{ 0xb8, 0xd8, 0x8a }, + .num = .{ 0xf8, 0xc0, 0x82 }, + .comment = .{ 0xb9, 0xf4, 0x80 }, .lineno = .{ 0x59, 0x67, 0x5c }, .lineno_active = .{ 0x61, 0x6f, 0x64 }, .scroll_track = .{ 0x11, 0x18, 0x13 }, - .scroll_thumb = .{ 0x63, 0x7f, 0x6a }, - .border = .{ 0x35, 0x48, 0x3d }, - .sel_bg = .{ 0x40, 0x5d, 0x4b }, + .scroll_thumb = .{ 0x60, 0x82, 0x69 }, + .border = .{ 0x48, 0x61, 0x52 }, + .sel_bg = .{ 0x3c, 0x61, 0x4a }, .sel_fg = .{ 0xf5, 0xf7, 0xee }, - .search_bg = .{ 0x57, 0x47, 0x2a }, + .search_bg = .{ 0x5e, 0x49, 0x23 }, .search_fg = .{ 0xf7, 0xe4, 0xa5 }, - .diagnostic_error = .{ 0xf1, 0xa3, 0x9b }, - .diagnostic_warning = .{ 0xe9, 0xc6, 0x80 }, - .diagnostic_info = .{ 0x9b, 0xcb, 0xd5 }, - .diagnostic_hint = .{ 0xb6, 0xc5, 0x9e }, + .diagnostic_error = .{ 0xfe, 0x98, 0x8e }, + .diagnostic_warning = .{ 0xf9, 0xcb, 0x70 }, + .diagnostic_info = .{ 0x92, 0xd1, 0xde }, + .diagnostic_hint = .{ 0xb7, 0xcb, 0x98 }, .palette = .{ .{ 0x00, 0x00, 0x00 }, .{ 0xf1, 0xa3, 0x9b }, diff --git a/src/themes/paper.zig b/src/themes/paper.zig index b5d24835..f1d6980b 100644 --- a/src/themes/paper.zig +++ b/src/themes/paper.zig @@ -11,27 +11,27 @@ pub const theme = .{ .tag_active_name_fg = .{ 0x69, 0x44, 0x7a }, .tag_active_bg = .{ 0xdc, 0xe5, 0xdc }, .tag_active_fg = .{ 0x4a, 0x5a, 0x52 }, - .box = .{ 0x3c, 0x6b, 0x56 }, - .box_dim = .{ 0x91, 0xa3, 0x95 }, - .column_box = .{ 0x87, 0x58, 0x26 }, - .column_box_dim = .{ 0xb7, 0xa1, 0x84 }, - .kw = .{ 0x73, 0x51, 0x90 }, - .str = .{ 0x41, 0x68, 0x48 }, - .num = .{ 0x87, 0x58, 0x26 }, - .comment = .{ 0x2e, 0x71, 0x59 }, + .box = .{ 0x36, 0x71, 0x57 }, + .box_dim = .{ 0x8f, 0xa5, 0x94 }, + .column_box = .{ 0x93, 0x58, 0x1a }, + .column_box_dim = .{ 0xbd, 0xa2, 0x7e }, + .kw = .{ 0x74, 0x46, 0x9b }, + .str = .{ 0x3a, 0x6f, 0x44 }, + .num = .{ 0x98, 0x59, 0x15 }, + .comment = .{ 0x20, 0x75, 0x56 }, .lineno = .{ 0x8b, 0x91, 0x85 }, .lineno_active = .{ 0x83, 0x89, 0x7d }, .scroll_track = .{ 0xe5, 0xe8, 0xdf }, - .scroll_thumb = .{ 0x88, 0x9b, 0x8b }, - .border = .{ 0xb5, 0xc1, 0xb3 }, - .sel_bg = .{ 0xc8, 0xdf, 0xd1 }, + .scroll_thumb = .{ 0x86, 0x9d, 0x8a }, + .border = .{ 0xfb, 0xfb, 0xfb }, + .sel_bg = .{ 0xc5, 0xe2, 0xd0 }, .sel_fg = .{ 0x20, 0x3e, 0x31 }, - .search_bg = .{ 0xf0, 0xdd, 0xa8 }, + .search_bg = .{ 0xfb, 0xe2, 0x9d }, .search_fg = .{ 0x61, 0x46, 0x1c }, - .diagnostic_error = .{ 0xa3, 0x39, 0x38 }, - .diagnostic_warning = .{ 0x80, 0x57, 0x0c }, - .diagnostic_info = .{ 0x30, 0x65, 0x75 }, - .diagnostic_hint = .{ 0x52, 0x6d, 0x3e }, + .diagnostic_error = .{ 0xb3, 0x29, 0x28 }, + .diagnostic_warning = .{ 0x8c, 0x5b, 0x00 }, + .diagnostic_info = .{ 0x26, 0x6b, 0x7f }, + .diagnostic_hint = .{ 0x51, 0x74, 0x37 }, .palette = .{ .{ 0x30, 0x3b, 0x3b }, .{ 0xa3, 0x39, 0x38 }, diff --git a/src/themes/solarium.zig b/src/themes/solarium.zig index fe2525a6..21b4c451 100644 --- a/src/themes/solarium.zig +++ b/src/themes/solarium.zig @@ -12,27 +12,27 @@ pub const theme = .{ .tag_active_name_fg = .{ 0xf5, 0xcd, 0xec }, .tag_active_bg = .{ 0x21, 0x4e, 0x50 }, .tag_active_fg = .{ 0xd3, 0xe0, 0xc9 }, - .box = .{ 0xd5, 0xbc, 0x72 }, - .box_dim = .{ 0x4c, 0x79, 0x72 }, - .column_box = .{ 0x6a, 0xae, 0xdd }, - .column_box_dim = .{ 0x3e, 0x76, 0x90 }, - .kw = .{ 0x6a, 0xae, 0xdd }, - .str = .{ 0xaf, 0xbd, 0x52 }, - .num = .{ 0xd9, 0x9a, 0x5e }, - .comment = .{ 0xe2, 0xc4, 0x6e }, + .box = .{ 0xe1, 0xc2, 0x66 }, + .box_dim = .{ 0x46, 0x7f, 0x76 }, + .column_box = .{ 0x5c, 0xb1, 0xeb }, + .column_box_dim = .{ 0x34, 0x7a, 0x9a }, + .kw = .{ 0x56, 0xb2, 0xf1 }, + .str = .{ 0xbd, 0xd0, 0x3f }, + .num = .{ 0xef, 0x99, 0x48 }, + .comment = .{ 0xf6, 0xce, 0x5a }, .lineno = .{ 0x64, 0x7e, 0x7c }, .lineno_active = .{ 0x6c, 0x86, 0x84 }, .scroll_track = .{ 0x1c, 0x45, 0x4c }, - .scroll_thumb = .{ 0x69, 0x93, 0x8a }, - .border = .{ 0x38, 0x65, 0x5f }, - .sel_bg = .{ 0x27, 0x56, 0x5c }, + .scroll_thumb = .{ 0x65, 0x97, 0x8c }, + .border = .{ 0x4c, 0x88, 0x80 }, + .sel_bg = .{ 0x1f, 0x5c, 0x64 }, .sel_fg = .{ 0xee, 0xe8, 0xd5 }, - .search_bg = .{ 0x64, 0x53, 0x26 }, + .search_bg = .{ 0x6d, 0x57, 0x1d }, .search_fg = .{ 0xff, 0xf0, 0xb9 }, - .diagnostic_error = .{ 0xed, 0x84, 0x77 }, - .diagnostic_warning = .{ 0xdf, 0xb6, 0x5b }, - .diagnostic_info = .{ 0x6a, 0xae, 0xdd }, - .diagnostic_hint = .{ 0x69, 0xbd, 0xb0 }, + .diagnostic_error = .{ 0xff, 0x7a, 0x6a }, + .diagnostic_warning = .{ 0xf3, 0xbe, 0x47 }, + .diagnostic_info = .{ 0x59, 0xb1, 0xee }, + .diagnostic_hint = .{ 0x5c, 0xca, 0xb9 }, .palette = .{ .{ 0x17, 0x3e, 0x45 }, .{ 0xed, 0x84, 0x77 }, diff --git a/src/themes/spectrum.zig b/src/themes/spectrum.zig index 5a1cecc6..a0faf897 100644 --- a/src/themes/spectrum.zig +++ b/src/themes/spectrum.zig @@ -13,26 +13,26 @@ pub const theme = .{ .tag_active_bg = .{ 0x4d, 0x47, 0x36 }, .tag_active_fg = .{ 0xe9, 0xe4, 0xc7 }, .box = .{ 0xff, 0xd8, 0x66 }, - .box_dim = .{ 0x8b, 0x80, 0x56 }, - .column_box = .{ 0xab, 0x9d, 0xf2 }, - .column_box_dim = .{ 0x73, 0x6a, 0x91 }, + .box_dim = .{ 0x92, 0x84, 0x4f }, + .column_box = .{ 0xa4, 0x92, 0xfd }, + .column_box_dim = .{ 0x70, 0x65, 0x96 }, .kw = .{ 0xff, 0x61, 0x88 }, - .str = .{ 0xa9, 0xdc, 0x76 }, - .num = .{ 0xab, 0x9d, 0xf2 }, + .str = .{ 0xa9, 0xee, 0x64 }, + .num = .{ 0xa2, 0x90, 0xff }, .comment = .{ 0xff, 0xe0, 0x9b }, .lineno = .{ 0x68, 0x61, 0x6b }, .lineno_active = .{ 0x70, 0x69, 0x73 }, .scroll_track = .{ 0x21, 0x1d, 0x23 }, - .scroll_thumb = .{ 0x91, 0x8b, 0x72 }, - .border = .{ 0x6a, 0x64, 0x50 }, - .sel_bg = .{ 0x51, 0x43, 0x5c }, + .scroll_thumb = .{ 0x94, 0x8d, 0x6f }, + .border = .{ 0x8f, 0x87, 0x6c }, + .sel_bg = .{ 0x51, 0x3f, 0x60 }, .sel_fg = .{ 0xfc, 0xfc, 0xfa }, - .search_bg = .{ 0x66, 0x56, 0x27 }, + .search_bg = .{ 0x6f, 0x5b, 0x1e }, .search_fg = .{ 0xff, 0xf0, 0xb0 }, .diagnostic_error = .{ 0xff, 0x79, 0x9b }, .diagnostic_warning = .{ 0xff, 0xd8, 0x66 }, - .diagnostic_info = .{ 0x78, 0xdc, 0xe8 }, - .diagnostic_hint = .{ 0xa9, 0xdc, 0x76 }, + .diagnostic_info = .{ 0x67, 0xe9, 0xf9 }, + .diagnostic_hint = .{ 0xa9, 0xeb, 0x67 }, .palette = .{ .{ 0x10, 0x0e, 0x11 }, .{ 0xff, 0x79, 0x9b }, diff --git a/src/web.zig b/src/web.zig index b5a992ae..7325af54 100644 --- a/src/web.zig +++ b/src/web.zig @@ -376,7 +376,7 @@ export fn pardes_tag_layer_cells(index: u32) ?[*]const WebCell { } export fn pardes_tagline_band_offset(row: u16, canvas_h: f32, cell_h: u32, tagline_h: u32) u32 { - return pardes.taglineBandOffset(row, canvas_h, cell_h, tagline_h); + return pardes.taglineBandOffset(row, canvas_h, cell_h, tagline_h, true); } export fn pardes_body_layer_value(index: u32, field: u32) u32 { diff --git a/test/macos_e2e.swift b/test/macos_e2e.swift index 5efc366c..5f172f9d 100644 --- a/test/macos_e2e.swift +++ b/test/macos_e2e.swift @@ -628,8 +628,8 @@ private final class Driver: PardesViewDelegate { let bottom = kind == 2 && pardes_tag_layer_value(i, 11) != 0 for pixel in 0..= height - 2) { rgb = 0x606f86 } + if pardes_tag_layer_value(i, 5) == UInt32(PARDES_TOPBAR_H) && pixel == 0 { rgb = 0x606f86 } try check(x: x, y: top + (CGFloat(pixel) + 0.5) / scale, rgb: rgb, name: "tag \(i), pixel \(pixel)") } @@ -656,7 +656,7 @@ private final class Driver: PardesViewDelegate { guard let c = sample(rep, x: Int(x * scale), y: Int(y * scale)) else { throw ScriptError(message: "context: no separator pixel") } - let rgb: UInt32 = 0x475263 // Forge border, also used by the Linux chrome overlay. + let rgb: UInt32 = 0x606f86 // Forge border, also used by the Linux chrome overlay. guard abs(c.redComponent * 255 - CGFloat((rgb >> 16) & 255)) < 4, abs(c.greenComponent * 255 - CGFloat((rgb >> 8) & 255)) < 4, abs(c.blueComponent * 255 - CGFloat(rgb & 255)) < 4, @@ -1270,6 +1270,10 @@ private func buildWorld(stem: String) throws -> String { // A wall clock cannot live in a golden. Everything that would print one // prints fixed characters instead when this is set. _ = setenv("PARDES_NOTIME", "1", 1) + // The scripts speak to a grid that HAS the workspace tag row: the app + // hands that row to its native menu bar, but this harness is the + // topbar's test bench, so opt back in before pardes_init reads it. + _ = setenv("PARDES_WORKSPACE_TAG", "1", 1) guard fm.changeCurrentDirectoryPath(work) else { throw ScriptError(message: "could not chdir into \(work)") } -- cgit v1.3 From 9070942b29bd10dddcdecdb0e88ba0fb40608467 Mon Sep 17 00:00:00 2001 From: Gabriel Schneider Date: Mon, 21 Sep 2026 20:07:43 -0300 Subject: Plan 9 idiom for the control filesystem, and the regressions a624a56 left The 9P tree stops being a command language wearing a filesystem. /new created a pane as a side effect of a *read*; it is now Tcreate in /pane, with Tremove to close, which cloud9's engine has always supported and the editor never declared: tree.zig now says `features = .{ .create = true, .remove = true }`. Eleven pane ctl verbs become files that can be read as well as written -- dot, limit, dirty, mark, scroll, look, exec -- leaving ctl with `get`, the one verb no file would say better. Root /ctl splits into a read-only /status and the /look and /exec files whose write IS the click. stat carries real sizes where it used to answer 0, and qid versions track a pane's revision, so a client can poll for change without re-reading the body. Commit a624a56 moved raw-tty keys to an early-return branch that knew only Ctrl-B and bare Escape, and in the same edit deleted the paste branch below it. That cost Shift-Escape (the unconditional way out of tty mode) and both paste chords: Ctrl-V and Ctrl-Shift-V reached the child as keystrokes, so an agent CLI running in a pane took Ctrl-V for its image-paste binding and answered "No image found in clipboard". Both are restored, with tests. Nested detection was not subtly broken but deleted: 60367d8 removed nested.zig's process-ancestry walk and left "am I inside pardes" derived from PARDES_FORWARD_LOOK, which read "0" both for --nested and for "the listener did not come up". PARDES_PID now answers that question on its own, checked with kill(pid, 0); PARDES_9P and PARDES_PANE answer how to reach it; the flag is gone. The posted-9P registry also self-heals now -- a session that aborts cannot unlink its own socket, so posting sweeps entries whose target refuses a connection, symlinks only and on a definite ECONNREFUSED only. Elsewhere: tty scrolling is sticky-bottom, following new output only from the last row, with typing and entering raw mode snapping back to live; the boot layouts are a Boot enum instead of a chain of ifs, and the bare tty startup (Boot.tty, which main.zig names) opens an empty text pane under the shell while tests keep Boot.tty_shell; builtins announce themselves on the message row under a Verbose setting that is on by default; Config prints each setting the way you would type it back, so WindowOpacity 70 rather than "WindowOpacity: 70%"; LocationsConfig opens its window only when called bare; every tagline puts the word that closes the thing last, and a column now outlives its panes -- closing the last one leaves an empty pane, and only Delcol, newly on the column tagline, takes the column away. Co-Authored-By: Claude Opus 5 (1M context) --- .agents/skills/pardes-9p/SKILL.md | 271 +++++++++++++++++++------------- docs/cloud9.md | 11 ++ docs/config.md | 18 ++- docs/design.typ | 31 ++-- docs/fs.md | 120 +++++++++----- docs/v9fs.md | 2 +- features.txt | 48 ++++++ src/9p_io.zig | 290 +++++++++++++++++++++++++++++++--- src/builtins.zig | 15 +- src/config.zig | 187 +++++++++++----------- src/fs-help.txt | 42 ++--- src/fs.zig | 11 +- src/host_io.zig | 3 + src/main.zig | 71 +++++++-- src/ninep/addr.zig | 16 +- src/ninep/ctl.zig | 319 ++++++++++++++++---------------------- src/ninep/events.zig | 15 +- src/ninep/pane.zig | 241 ++++++++++++++++++++++++---- src/ninep/pty.zig | 9 +- src/ninep/screen.zig | 25 ++- src/ninep/testing.zig | 29 +++- src/ninep/tree.zig | 207 ++++++++++++++++--------- src/panes.zig | 14 +- src/pardes.zig | 294 +++++++++++++++++++++++++++++------ src/tty/tty.zig | 31 ++++ src/tutor.txt | 21 +-- test/appearance_gallery.py | 14 +- test/column_tags.py | 4 +- test/e2e_harness.zig | 2 +- test/font_size.py | 6 +- test/fs.py | 134 +++++++++------- test/fs_bench.zig | 4 +- test/fs_namespace.zig | 15 +- test/fs_soak.py | 8 +- test/look_placement.py | 6 +- test/ninep.py | 19 +++ test/output.zig | 32 ++-- test/panes.zig | 76 ++++++++- test/pdf.zig | 2 +- test/tag_cleanup.py | 2 +- test/ui_review.py | 12 +- test/v9fs.py | 35 +++-- test/window_opacity.py | 2 +- 43 files changed, 1898 insertions(+), 816 deletions(-) (limited to 'src/pardes.zig') diff --git a/.agents/skills/pardes-9p/SKILL.md b/.agents/skills/pardes-9p/SKILL.md index 09dee666..2cea4d4a 100644 --- a/.agents/skills/pardes-9p/SKILL.md +++ b/.agents/skills/pardes-9p/SKILL.md @@ -1,23 +1,127 @@ --- name: pardes-9p -description: Inspect and drive a running Pardes editor over 9P, or exercise its panes, builtins, terminal input and rendered output in an isolated session. Use for Pardes interaction, plugin development and end-to-end debugging through its control filesystem. +description: Inspect and drive a running Pardes editor through its control filesystem, or exercise its panes, builtins, terminal input and rendered output in an isolated session. Use for Pardes interaction, plugin development and end-to-end debugging. --- # Pardes over 9P -Use the existing [Python client](../../../test/ninep.py) for ad hoc interaction -and functional tests. Do not build another wire client. Project tooling stays -in Zig. Run the examples from the repository root; paths below are relative to -that root unless linked. +Pardes is driven by reading and writing files. Prefer ordinary file tools over +a mount; reach for the Python client only when nothing is mounted, or when the +work needs a fid held open. Do not build another wire client: project tooling +stays in Zig. Run the examples from the repository root; paths below are +relative to that root unless linked. -## Connect and identify panes +## Find the session through the mount -Every native session opens a Unix socket. Inside a pane, `PARDES_9P` names the -socket and `PARDES_PANE` is that pane's serial. Outside Pardes, find -`pardes-9p-*.sock` under `$XDG_RUNTIME_DIR`, or `~/.local/state/pardes` when -that variable is unset. Select the intended session explicitly; do not assume -the newest socket is the right one. Names come from `--9p=name`, the detached -session name, or the process ID. +This machine keeps a FUSE mount of every posted session under `/mnt/9p`: +`/mnt/9p/pardes//` is one session's served root. Inside a pane, +`$PARDES_9P` is that session's socket (`/run/user/1000/pardes-9p-.sock`), +so its pid is the directory to use, and `$PARDES_PANE` is the calling pane's +serial: + +```sh +m=/mnt/9p/pardes/$(basename "$PARDES_9P" .sock | sed 's/^pardes-9p-//') +cat "$m/index" +cat "$m/pane/$PARDES_PANE/body" +``` + +Entries for dead sessions stay listed and answer `Input/output error` on any +access, so name the session you mean rather than globbing or taking the newest. +`cat "$m/index"` is the cheapest liveness check, and `cat "$m/status"` reports +the `pid`, `version` and `panes` of a session new enough to serve it. + +`/mnt/9p/pardes` is the registry of posted sessions, mounted once for the +machine. It is not the per-pane kernel mount the `Tty9p` builtin makes, which +gives one pane's shell `$PARDES_MOUNT`; see [docs/v9fs.md](../../../docs/v9fs.md) +for that. Either mountpoint serves the same tree. + +A running session serves whatever binary started it. If a listing does not +match this document, that session predates the change; restart it. + +## The tree, and what to do with it + +``` +$m/README the served guide, worth reading first +$m/index one line per pane: serial, kind (text|term|pdf|image), dirty flag, name +$m/status pid, version, panes +$m/look write a line = a right click on it at the active pane +$m/exec write a line = a middle click: an editor command word, or a shell line +$m/log one record per read: new|del|rename|save ; reads park +$m/screen the rendered screen as JSON, frozen per open +$m/listeners this session's dial addresses +$m/pane/ mkdir opens a pane; rmdir closes it +$m/os/ the host filesystem +``` + +The first field of an index row is a stable pane serial, not a slot or row +number. A row is `serial kind dirty name`, so `row.split(maxsplit=3)` keeps a +name with spaces intact. Re-read the index after anything that might open, +reuse or close a pane. + +```sh +cat "$m/index" # which panes exist +mkdir "$m/pane/x"; n=$(awk 'END{print $1}' "$m/index") # open one, take its serial +printf 'text\n' > "$m/pane/$n/body" # append +cat "$m/pane/$n/tag" # what its tagline offers +echo notes.txt > "$m/pane/$n/name" # rename the buffer +echo Save > "$m/pane/$n/exec" # save it +echo "/etc/hosts:3" > "$m/look"; cat "$m/look" # open a file, see where it landed +rmdir "$m/pane/$n" # close it, dirty or not +``` + +The name `mkdir` asks for is ignored: a pane is named by the serial the editor +gives it, and because `/index` is ordered by serial its last row is the pane +just made. Nothing else in the tree can be created or removed, and no read +creates anything, so `ls`, `stat` and `find` over the whole tree are inert. + +`look` and `exec` are the editor's two clicks, one per line of a write, at the +active pane from the root and at that pane from `$m/pane//look` and +`$m/pane//exec`. Reading any of them answers the serials the last command +made, or the pane it focused or acted on. A command that fails is reported in +the editor, not as a write error, so inspect the resulting pane, index, message +or screen; only a malformed line fails the write itself. + +## Edit through addresses, dot and the flag files + +For a file or scratch pane, with `pane=$m/pane/`: + +| Operation | Shell | Python client | +|---|---|---| +| Read text | `cat $pane/body` | `client.read(pane + '/body')` | +| Append text | `echo text >> $pane/body` | `client.write(pane + '/body', b'text\n')` | +| Replace all text | `echo text > $pane/body` | `client.write(pane + '/body', b'text\n', truncate=True)` | +| Address a byte range | `echo '#0,#2' > $pane/addr` | `client.write(pane + '/addr', b'#0,#2')` | +| Replace that range | `echo 'pub fn' > $pane/data` | `client.write(pane + '/data', b'pub fn')` | +| Read the selection | `cat $pane/dot` (offsets), `cat $pane/sel` (text) | the same two reads | +| Select the addressed range | `cp $pane/addr $pane/dot` | `client.write(pane + '/dot', client.read(pane + '/addr'))` | +| Reload from disk | `echo get > $pane/ctl` | `client.write(pane + '/ctl', b'get\n')` | +| Close it | `rmdir $pane` | `client.remove(pane)` | + +`addr`, `dot` and `limit` each read the pair of offsets they also accept, which +is why copying one onto another is all that acme's `addr=dot`, `dot=addr` and +`limit=addr` ever were; a write may also be an address expression (`#0,#5`, +`/pattern/`, `2+1`). Moving `dot` scrolls the pane to it. `limit` bounds a +search and reads empty until set; truncate it to lift it. + +`dirty`, `mark` and `scroll` read `0` or `1` and take `0` or `1`: whether the +buffer differs from its file, whether a write pushes an undo point, and whether +a write scrolls. Truncating `tag` clears the part of the tag you may edit. + +Address state belongs to the pane, not to a client: opening `addr` resets it, +so two clients addressing the same pane will interfere. `$pane/ctl` reads +acme's window status line — serial, tag length, body length, a reserved zero, +the dirty flag, the width in cells, the font and the tab width — and takes the +one verb `get`. + +Terminal panes have no file: writing their `body` sends child input, and +truncation does not erase terminal history. + +## The Python client, for what a shell cannot express + +Use the existing [Python client](../../../test/ninep.py) when there is no +mount, or when the work needs a fid held open across several operations — +`log`, `event` and `pty/data` are consuming queues whose reads park, and shell +redirection cannot hold one open. ```sh PYTHONPATH=test python3 -B - "$PARDES_9P" <<'PY' @@ -25,103 +129,56 @@ import sys from ninep import Client with Client(sys.argv[1]) as client: - print(client.read('/self/index').decode(), end='') - print(client.read('/self/listeners').decode(), end='') + print(client.read('/index').decode(), end='') + print(client.read('/listeners').decode(), end='') PY ``` -`Client` takes a raw Unix socket path, or `(numeric_ip, port)` for TCP; it -does not parse Pardes dial strings or implement QUIC. It negotiates 9P2000, -uses a five-second socket timeout, and closes on leaving `with`. - -The first field of each index row is a stable pane serial, not a slot or row -number. The tag starts after five numeric fields; use `row.split(maxsplit=5)` -to preserve spaces. Inspect `/self/pane//tag`, `body`, or directory -entries before choosing a target. Re-read the index after actions that might -open, reuse or close panes. - -Wire paths start with `/self` or `/os`. `/n/self`, `/n/os`, `/n/peer` and -`/virtual` belong to editor Look paths, not the server root. For example, -Look `/virtual/src/pardes.zig` corresponds to reading `/self/src/pardes.zig`. - -## Edit, Look and execute - -For a file or scratch pane, with a connected `client` and a confirmed -`serial`, let `pane = f'/self/pane/{serial}'`. Terminal body writes instead -send child input; truncation does not erase terminal history. - -| Operation | Client call | -|---|---| -| Read text | `client.read(pane + '/body')` | -| Append text | `client.write(pane + '/body', b'text\n')` | -| Replace all text | `client.write(pane + '/body', b'text\n', truncate=True)` | -| Select a byte range | `client.write(pane + '/addr', b'#0,#2')` | -| Replace that range | `client.write(pane + '/data', b'pub fn')` | -| Show the addressed selection | `client.write(pane + '/ctl', b'dot=addr\n')` | -| Look from this pane | `client.write(pane + '/ctl', b'look /virtual/src/pardes.zig:10\n')` | -| Save | `client.write(pane + '/ctl', b'put\n')` | -| Reload | `client.write(pane + '/ctl', b'get\n')` | -| Close, refusing dirty text | `client.write(pane + '/ctl', b'del\n')` | - -`delete` force-closes, discarding unsaved text. `get` replaces edits with file -contents. Use those only when that loss is intended. Reading `/self/new/ctl` -creates a scratch pane and returns its serial as the first field; it is not -an observational read. - -`ctl` is not a builtin interpreter. Execute builtins through a body Exec event -on an owned scratch pane: - -```python -from fs import new_pane, execute - -control = new_pane(client, b'') -execute(client, control, 'Msg 9p-ready') -``` - -`execute` overwrites that pane's body with the command, then writes -`MX0 \n` to its `event` file. Keep the control pane separate -from user text. The same helper can run `Mini path`, `Mount peer dial`, and -`Unmount peer`; commands resolve relative to the control pane's directory. -A successful event write acknowledges dispatch, not completion: inspect the -resulting pane, message or screen for success. +`Client` takes a raw Unix socket path, or `(numeric_ip, port)` for TCP; it does +not parse Pardes dial strings or implement QUIC. It negotiates 9P2000, uses a +five-second socket timeout, and closes on leaving `with`. Its paths are the +served root: `/index`, `/pane/2/body`, `/os/...`. `/n/self`, `/n/os`, `/n/peer` +and `/virtual` are editor Look paths, not server paths — Look +`/virtual/src/pardes.zig` corresponds to reading `/src/pardes.zig`. -Opening `addr` resets its range. To inspect the current selection, open -`addr` first, write `addr=dot\n` to `ctl`, then use `read_fid` on that already -open handle. Do not replace that last step with `client.read`, which reopens -and resets it. Address state is shared by the pane, not private to a client. +For live terminal output or plugin events, use `open` / `read_fid` / `close`, +not the read-until-EOF helper. `pty/data` captures output while held open; it +is not a history replay. Both files are shared, consuming queues, not +per-client broadcasts, so a slow reader loses older data. Holding `event` open +intercepts that pane's Look and Exec clicks, so it is not a passive logger: for +Look/Exec records whose offsets identify the intended text, forward the short +record ` \n`, not the whole report with flags and text. +Expansion and chord reports need explicit handling, and terminal-body events +can carry text only in the report, which a short writeback cannot reproduce. +Read the event implementation before building an interceptor. Close handles in +`finally`, and disconnect after a socket timeout. The service shares four +connection slots and 32 screen/terminal-history snapshot handles. + +A file's qid version is the pane's revision for `body`, `data` and `xdata`, so +`stat` sees an edit land without reading the text; it stays zero elsewhere. +Stat sizes are real, and for `log`, `event` and `pty/data` report the length of +the record a read would answer — zero when nothing is waiting. ## Terminal input and screen observations Only terminal panes have `pty/`. Write keystroke bytes to `pty/data`, not `body`: `client.write(pane + '/pty/data', b'printf hello\r')` submits a shell -command. For an interactive application, send its actual input bytes; -`b'\x03'` is Ctrl-C, and Ctrl-U is `b'\x15'` where that application supports it. -These inputs go to the child terminal, not Pardes editor key bindings. +command. For an interactive application, send its actual input bytes; `b'\x03'` +is Ctrl-C, and Ctrl-U is `b'\x15'` where that application supports it. These go +to the child terminal, not to Pardes key bindings. `pty/ctl` takes `winsize C R`, +`sig INT` and `exec`, one per line. -`client.screen()` returns `cols`, `rows`, `cursor`, `styles`, and row-major +`client.screen()` returns `cols`, `rows`, `cursor`, `styles` and row-major `cells` of `[grapheme, style_index]`. Reconstruct rows using `cols`; resolve -each cell's style through `styles` when checking highlighting. Compare colors -and attributes, not just style-table indices or flattened text. +each cell's style through `styles` when checking highlighting, and compare +colors and attributes rather than style-table indices or flattened text. -Each screen open freezes one frame. A terminal `body` freezes history on its -first read. `client.read` and `client.screen` reopen each time; use repeated -calls for fresh observations. Do not poll a stale handle. Poll a specific -condition with a deadline and a short delay, rather than a fixed long sleep. -For large histories, measure whole-body reads separately from screen polling; -9P write-to-observation timing includes RPC, rendering and polling overhead. - -For live terminal output or plugin events, use `open` / `read_fid` / `close`, -not the read-until-EOF helper. `pty/data` captures output while held open; -it is not a history replay. Both files are shared, consuming queues, not -per-client broadcasts; slow readers can lose older data. Holding `event` open -intercepts Look/Exec clicks, so it is not a passive logger. For Look/Exec -records whose offsets identify the intended file/tag text, forward the short -record ` \n`, not the entire report with flags and text. -Expansion/chord reports need explicit handling; terminal-body events can have -empty ranges with text carried only in the report, so short writeback cannot -reproduce them. Read the event implementation before building an interceptor. -Close handles in `finally`; disconnect after a socket timeout. The service -shares four connection slots and 32 screen/terminal-history snapshot handles. +Each screen open freezes one frame, and a terminal `body` freezes its history +on its first read. `client.read` and `client.screen` reopen each time, so +repeat the call for a fresh observation rather than polling a stale handle. +Poll a specific condition with a deadline and a short delay, not a fixed long +sleep. For large histories, measure whole-body reads separately from screen +polling; write-to-observation timing includes RPC, rendering and polling. ## Exercise an isolated session @@ -140,22 +197,23 @@ binary = str(Path(sys.argv[1]).resolve()) with tempfile.TemporaryDirectory(prefix='pardes-9p-skill-') as directory: with session(binary, Path(directory), 'skill') as (client, address): serial = new_pane(client, b'fn main() void {}\n') - pane = f'/self/pane/{serial}' - client.write(pane + '/ctl', b'name probe.zig\n') + pane = f'/pane/{serial}' + client.write(pane + '/name', b'probe.zig\n') client.write(pane + '/addr', b'#0,#2') client.write(pane + '/data', b'pub fn') assert client.read(pane + '/body') == b'pub fn main() void {}\n' - control = new_pane(client, b'') - execute(client, control, 'Msg 9p-ready') + execute(client, serial, 'Msg 9p-ready') frame = client.screen() assert '9p-ready' in ''.join(cell[0] for cell in frame['cells']) print('9P edit, builtin and screen checks passed') PY ``` -For terminal tests, use `session(..., tty=True)` and read +`new_pane` is `mkdir` plus a read of the index; `execute` writes one line to a +pane's `exec`. Both are in `test/fs.py`. For terminal tests, use +`session(..., tty=True)` and read [test/agent_session.py](../../../test/agent_session.py) for bounded interactive -driving. Its readiness text and history threshold are application-specific; +driving; its readiness text and history threshold are application-specific, and session cleanup alone does not guarantee arbitrary grandchildren have exited. Use [test/snapshot.zig](../../../test/snapshot.zig) when editor key/mouse input or an independent terminal-rendering comparison matters; 9P screen inspection @@ -163,6 +221,7 @@ alone does not test physical input routing or the host renderer. Read [docs/fs.md](../../../docs/fs.md) for runtime mounts, TCP/QUIC listeners, Plan9port and Linux v9fs compatibility. Unix is always available; network -listeners are opt-in and grant full session/OS-file access. Use isolated -loopback listeners for tests. For less common control verbs or event details, -read their implementation and tests in [src/fs.zig](../../../src/fs.zig). +listeners are opt-in and grant full session and OS-file access, so use isolated +loopback listeners for tests. For event details or anything this page leaves +open, read the implementation and its tests in +[src/ninep/](../../../src/ninep/). diff --git a/docs/cloud9.md b/docs/cloud9.md index 79fda717..d030db1d 100644 --- a/docs/cloud9.md +++ b/docs/cloud9.md @@ -54,6 +54,17 @@ way a private `ZMX_DIR` does for zmx. Stopping unposts, and only while the entry is still ours, so a name another editor has since claimed is never unlinked. +An exit that cannot run any code of its own — an aborted test, a kill, a +crash — leaves its entry and its socket behind, so posting first sweeps the +group: every entry that is a symlink and whose socket answers a connect with +a definite ECONNREFUSED is unlinked, along with the socket it points at when +a `stat` agrees that is a socket of ours. Anything that is not a symlink is +somebody else's, and any other answer — connected, busy, refused permission, +a surprise — counts as live, because uncertainty belongs to the server that +owns the socket rather than to the sweeper. That is `cloud9.post.Probe`'s +classification, repeated in `src/9p_io.zig` only because `post.probe` is raw +Linux syscalls and pardes also builds for darwin. + **Consuming.** Nothing. `9ns --mntgen` mounts the whole registry at `/mnt/9p`, and an interactive fish already self-wraps in one, so a pardes started from a terminal sees every posted service as ordinary files — diff --git a/docs/config.md b/docs/config.md index a55aef1c..04b0fd82 100644 --- a/docs/config.md +++ b/docs/config.md @@ -111,6 +111,10 @@ Workspace, column and pane command text can be edited directly; see `ColumnTags` toggles the column command row in both GUI and TTY; it is on by default. Add `ColumnTags` to startup configuration to reclaim that row on a compact screen. Hiding it preserves your custom column commands. +`Verbose` toggles the message-row announcement every builtin makes of its own +name before it runs; it is on by default, and the builtins that own the message +row themselves (`Msg`) never announce. Turning it off leaves the row to the +messages a builtin chooses to write. `SyntaxBold` toggles bold syntax keywords; it is off by default. These settings are shared by GUI and TTY, and `Config` reports their current states. Like `Colors` and `Wrap`, these commands take no argument and invert @@ -334,10 +338,16 @@ The installed `pardes-v9fs` helper lives beside the editor; development builds can set `PARDES_V9FS_HELPER` to its absolute path. See [v9fs.md](v9fs.md). Ctrl-B switches between raw TTY and editor mode. Plain Escape at a detected -shell prompt hops back to the previous pane. Other keys, including Ctrl-O, Ctrl-W, -paste shortcuts, and modified Escape belong -to the child. Use `Mode` in the pane tag to return to editor -mode in place. Desktop paste events still feed the terminal. +shell prompt hops back to the previous pane. Other keys, including Ctrl-O, +Ctrl-W and modified Escape, belong to the child. Use `Mode` in the pane tag to +return to editor mode in place. Desktop paste events still feed the terminal. + +The paste chords are the exception the window keeps. Ctrl-V types the yank +register at the program, and Ctrl-Shift-V asks the desktop for its clipboard +and types that; both go through the program's bracketed paste when it has +asked for one. Neither reaches the child as a keystroke, so an application +that would otherwise answer Ctrl-V by reading the system clipboard itself +never gets the chance to read the wrong thing. `Font` and `FontSel` exist ONLY in the SDL GUI and native macOS builds — a terminal's font belongs to its emulator and a browser's to the page — so a diff --git a/docs/design.typ b/docs/design.typ index 4c8956ba..f8f0b05c 100644 --- a/docs/design.typ +++ b/docs/design.typ @@ -1492,15 +1492,20 @@ same thread as editing. == Nested Look -Pane shells inherit `PARDES_9P`, `PARDES_PANE` (the pane serial), and -`PARDES_FORWARD_LOOK`. A child launch resolves its OS-relative argument in -the child's working directory, then writes `look ` to the parent's -`self/pane//ctl`. Explicit `/virtual` and `/n` paths resolve in the -parent. The ordinary filesystem update performs layout and drains host effects. - -`--nested` starts a separate editor and disables forwarding from its direct -pane shells. Its 9P socket remains available for control and plugins. There is -no executable-name discovery or separate Look listener. +Pane shells inherit `PARDES_PID` (the editor's process id), `PARDES_9P` and +`PARDES_PANE` (the pane serial). The first answers whether the shell is inside +a pardes at all, the other two answer how to reach it, and they are separate +because a session whose listener never came up still owns its children. A child +launch that finds a live `PARDES_PID` and no way to reach it says so instead of +starting a second editor. Otherwise it resolves its OS-relative argument in the +child's working directory, then writes `look ` to the parent's +`pane//ctl`. Explicit `/virtual` and `/n` paths resolve in the parent. +The ordinary filesystem update performs layout and drains host effects. + +`--nested` starts a separate editor and withholds `PARDES_PID` from its direct +pane shells, which is the whole of the opt-out. Its 9P socket remains available +for control and plugins, so those shells still get `PARDES_9P` and +`PARDES_PANE`. There is no executable-name discovery or separate Look listener. Detached frontends use `pardes-detached-.sock` in the same runtime directory. The shared Unix socket conventions live in `src/9p_io.zig`. @@ -1928,9 +1933,11 @@ arrives bracketed, as one `paste` event. staged edits: Enter commits a new buffer save target, Escape cancels, and no disk rename or write happens until explicit Save. Terminal cwd and image/PDF status stay generated. Save leads the tail of every pane holding text of its own: -`Save Tty Del Collapse` for a file or an output buffer, -`Save Tty Del Togglettymode Filter Collapse` for a terminal, and `Tty Del Collapse` -for an image. PDFs use `Tty Del PdfSections PdfTint Collapse`, without tint status text. +`Save Tty Collapse Del` for a file or an output buffer, +`Tty Save Mode Filter Collapse Del` for a terminal, and `Tty Collapse Del` +for an image. PDFs use `Tty PdfSections PdfTint Collapse Del`, without tint status text. +The word that closes the thing is last on every tagline, so overshooting the +click before it cannot destroy anything. `Collapse` toggles a pane between its tagline alone and its expanded height; hidden body contents and running terminals are retained. An unsaved file has `*` after its name; an image tag diff --git a/docs/fs.md b/docs/fs.md index 55ffdc9c..0bcc0313 100644 --- a/docs/fs.md +++ b/docs/fs.md @@ -1,14 +1,19 @@ # Filesystem Every native session serves 9P2000 on a Unix socket. Pane shells receive -`PARDES_9P` (socket path) and `PARDES_PANE` (pane serial). The socket is +`PARDES_PID` (the editor's process id), `PARDES_9P` (socket path) and +`PARDES_PANE` (pane serial). The socket is `$XDG_RUNTIME_DIR/pardes-9p-.sock`, or lives under `~/.local/state/pardes` when XDG_RUNTIME_DIR is unset. Detached sessions use their session name; `--9p=` overrides it. A `pardes ` launched from a pane forwards Look to that pane over 9P. -`--nested` opens a separate editor and disables forwarding from its pane shells; -its 9P service stays available. +`PARDES_PID` alone says the shell is inside pardes; `PARDES_9P` and +`PARDES_PANE` say how to reach it, and a launch that has the first without the +other two refuses rather than opening a second editor. `--nested` opens a +separate editor and withholds `PARDES_PID` from its pane shells, so a pardes +started in one of them runs a session of its own; its 9P service stays +available. Look resolves the OS filesystem first, then the editor's virtual filesystem. Explicit paths bypass that search: @@ -68,53 +73,79 @@ Existing Plan9port/v9fs clients need a userspace bridge for QUIC. ``` /README this guide, also src/fs-help.txt /index one line per pane: serial, kind (text|term|pdf|image), dirty flag, name -/ctl write: one command per line; read: the serials the last command made or touched -/new reading it creates one empty pane and answers "\n" (the /net/tcp/clone idiom) +/status pid, version and pane count +/look write a line: a right click on it at the active pane; read: the serials it touched +/exec write a line: a middle click; read the same serials /log one line per editor event: new|del|rename|save ; reads park /screen rendered screen JSON; frozen per open handle /listeners the session's dial addresses -/pane// name body tag ctl addr data xdata sel errors event, plus pty/{ctl,status,data} +/pane/ create a directory here to open a pane; remove one to close it +/pane// name body tag ctl addr dot limit data xdata sel dirty mark scroll + errors event look exec, plus pty/{ctl,status,data} on terminals /os/ the host filesystem /src/ the editor's embedded sources, only when built with -Dembed-sources=true ``` -Nothing in the tree is created by list, stat, walk or read, except that -reading `/new` makes a pane; that is its whole purpose, so a recursive read -of the tree makes one pane per open of it. - -`/ctl` and `/pane//ctl` take the editor's own command language, two verbs: - -- `look TEXT` is a right click on `TEXT`: a path opens a file, `file:12` jumps - to a line, a directory opens a shell there, a URL opens in the browser. From - `/ctl` the look happens at the active pane; from a pane's `ctl` at that pane. -- `exec TEXT` is a middle click: a command word from `src/builtins.zig` - (`Save`, `Del`, `New`, `Newcol`, `Mount NAME DIAL`, `Unmount NAME`, `Dump`, - `Restore`, `Msg TEXT`, `Find`, `Grep`, `Tty`, ...), or anything else, which - runs in the pane's terminal. - -Both verbs are lowercase; the words after `exec` are the editor's capitalized -commands. A pane's `ctl` also keeps acme's addr verbs (`addr=dot`, `dot=addr`, -`limit=addr`, `clean`, `dirty`, `cleartag`, `get`, `mark`, `nomark`, -`noscroll`, `scroll`, `show`). Every line of a write is checked before any -line runs; a malformed line fails the write with EINVAL. A command that fails -inside the editor is reported on the message row, not as a write error. - -After a write to either `ctl`, reading `/ctl` answers the serials of the panes -the command created, or, when it created none, the pane a look focused or the -pane an exec acted on (even one it closed), one per line. Before any command it answers `pid`, `version` and `panes` lines. +Nothing in the tree is created by list, stat, walk or read. A pane is opened +by Tcreate in `/pane` (`mkdir`) and closed by Tremove on `/pane/` (`rmdir`), +which is the only create and the only remove the tree serves. The name a +create asks for is ignored, since a pane is named by the serial the editor +gives it: the Rcreate qid names the new directory, and because `/index` is +ordered by serial its last line is the pane just made. + +`/look` and `/exec` are the editor's two clicks, one per line of a write: + +- a line written to `look` is a right click on it: a path opens a file, + `file:12` jumps to a line, a directory opens a shell there, a URL opens in + the browser. +- a line written to `exec` is a middle click: a command word from + `src/builtins.zig` (`Save`, `Del`, `New`, `Newcol`, `Mount NAME DIAL`, + `Unmount NAME`, `Dump`, `Restore`, `Msg TEXT`, `Find`, `Grep`, `Tty`, ...), + or anything else, which runs in the pane's terminal. + +The root's pair clicks at the active pane and `/pane//look` and +`/pane//exec` at that pane. Blank lines are skipped, and every other line +is checked before any of them runs, so a control character fails the whole +write with EINVAL; a command that fails inside the editor is reported on the +message row, not as a write error. Reading any of these files answers the +serials of the panes the last command created, or, when it created none, the +pane a look focused or the pane an exec acted on (even one it closed), one +per line. `/pane//name` reads the pane's file name (a terminal's directory) and writing it renames the buffer; a relative name resolves against the pane's -directory. `sel` reads the editor selection and writing it replaces the -selection. `body` appends on write and replaces on truncating open. `addr` -selects a range and `data` or `xdata` read or replace it. `errors` appends to -the directory's `+Errors` pane. Holding `event` open redirects the pane's Look -and Exec clicks to that client; writing a record back performs the action. - -Stats report real lengths for `index`, `ctl`, `name`, `body`, `tag` and `sel`, -modes 0644/0666 (0444 for read-only files, 0222 for write-only), the pane's -last edit time or the process start as mtime, and stable qids. Directory -entries carry no sizes; stat the entry. +directory. `body` appends on write and replaces on truncating open. `sel` +reads the selected text and writing it replaces the selection. `errors` +appends to the directory's `+Errors` pane. Holding `event` open redirects the +pane's Look and Exec clicks to that client; writing a record back performs the +action. `ctl` reads acme's window status line — serial, tag length, body +length, a reserved zero, the dirty flag, the width in cells, the font and the +tab width — and takes one verb, `get`, which reloads the buffer from the name +it carries. + +The three range files `addr`, `dot` and `limit` each read the pair of offsets +they also accept, so copying one onto another is all that acme's `addr=dot`, +`dot=addr` and `limit=addr` ever were. A write is either that pair or an +address expression (`#0,#5`, `/pattern/`, `2+1`); `addr` selects what `data` +and `xdata` read or replace, `dot` is the editor's own selection and moving it +scrolls the pane into view, and `limit` bounds a search and reads empty until +it is set. Truncating a range file empties it; truncating `limit` lifts it. + +The three flag files `dirty`, `mark` and `scroll` read `0` or `1` and take +`0` or `1`: whether the buffer differs from its file, whether a write pushes +an undo point (writing `1` pushes one now), and whether a write scrolls the +pane. Truncating `tag` clears the part of the tag you may edit. + +Stats report real lengths for `index`, `status`, `look`, `exec`, `listeners`, +`name`, `body`, `tag`, `sel`, `ctl`, the range files and the flag files, and +for `log`, `event` and `pty/data` the length of the record a read would +answer, which is zero when nothing is waiting. Modes are 0644/0666 (0444 for +read-only files, 0222 for write-only); mtime is the pane's last edit or the +process start. The qid version of `body`, `data` and `xdata` is the pane's +revision, so a stat sees an edit land without reading the text; every other +file leaves it zero rather than promise a version it cannot keep. Directory +entries carry no sizes, and neither does `/screen`, which has no length until +an open renders its frame; stat the entry. `/log` records `new`, `del`, `rename` and `save` while at least one client holds it open; a read parks until a record arrives. `/screen` returns JSON with @@ -132,8 +163,10 @@ enables the option by default, so the device can serve its own source. This is a control filesystem, not a complete POSIX export. Native filenames may contain up to 255 bytes. Existing regular OS files support read, write, -and truncation to zero; protocol create, remove, rename, and other metadata -changes are refused. Ownership and permissions under `/os` are synthetic. +and truncation to zero; under `/os` protocol create, remove, rename and other +metadata changes are refused, as is every create and remove in the control +tree but the pane directories. Ownership and permissions under `/os` are +synthetic. Zero-length truncation accepts the accompanying `mtime` hint sent by Linux v9fs; the hint is not stored. Standalone timestamp changes remain refused. @@ -148,7 +181,8 @@ for Unix and TCP, a poll loop for QUIC, and the 9P client for mounts); `zig build fs-test` drives real sessions using the independent Python client in `test/ninep.py`; `zig build fs-discovery-test` checks that browsing creates -nothing and that `new`, `ctl`, `name`, `sel` and `log` behave. `zig build +nothing, that a pane create and remove work, and that `look`, `exec`, `name`, +`sel` and `log` behave. `zig build 9p-test` checks the two engine configurations' budgets (the engine's own tests are cloud9's `zig build test`); `zig build fs-bench` measures filesystem transactions in the core. diff --git a/docs/v9fs.md b/docs/v9fs.md index 6cb4e998..8cc97ff9 100644 --- a/docs/v9fs.md +++ b/docs/v9fs.md @@ -12,7 +12,7 @@ ls "$PARDES_MOUNT/pane" cat "$PARDES_MOUNT/index" cat "$PARDES_MOUNT/README" cat "$PARDES_MOUNT/pane/$PARDES_PANE/body" -echo 'exec Msg hello' > "$PARDES_MOUNT/ctl" +echo 'Msg hello' > "$PARDES_MOUNT/exec" ``` The mount belongs to that pane's subprocess tree. Other panes and the editor diff --git a/features.txt b/features.txt index 3bfc6967..bee079a7 100644 --- a/features.txt +++ b/features.txt @@ -20,3 +20,51 @@ on tty mode the mouse selection works but the pardes selection on that pane shou between tty panes without changing the pardes semantics or adding anything extra, just neat tricks like this. Still, you might need to come up with something to decrease the number of movements/interactions needed to do simple things like copy and pasting text from a terminal to another. + +The 9p protocol needs to be simplified and made plan9 idiomatic. Stop leaning on ctl verbs: a name should be the operation. The filesystem should carry more +in stat metadata (real sizes, mtimes, qid versions so a client can poll for change cheaply) and use the real 9P operations for what is currently a ctl verb or a +magic read. cloud9's engine already exposes fs.Features{create, remove, wstat} and the editor backend simply never declared them, so /new creating a pane on +*read* becomes a Tcreate in /pane, del becomes Tremove, cleartag becomes a truncating write to tag, and clean/dirty, scroll/noscroll, mark/nomark and +addr=dot/dot=addr/limit=addr become their own files. What is left of ctl should be only the verbs with no file analog. + +shift-esc stopped leaving raw tty mode on the sdl backend. Commit a624a56 moved raw tty keys to an early-return branch that only knew ctrl-B and bare Esc, so +shift-esc was forwarded to the child instead. It is the unconditional way out of tty mode and should stay that way. + +On tty mode scrolling should work and not always move the focus down to follow a new line. The terminal only moves down to follow new output when the last line +is already at the bottom, like most terminals and editors. Typing and entering raw mode snap back to live output, so nobody types blind. + +The different kinds of layout pardes can initialize (tty mode, file mode, the classic three-shell boot, and the others that already exist) should be an explicit +enum rather than a chain of ifs over tty_only/shells/file/missing. That part of the code needs to be more explicit. The bare tty startup should always start with +an empty text pane at the bottom, not focused. + +Nested pardes detection stopped working. Spawning a subprocess should export an env variable holding the pardes pid, so a child can see it and call a Look on the +parent through the 9p mount instead of starting a second session; whether 9p is mounted is another env variable the child can check. + +Builtins should call Msg with the builtin name when they are called, minus a few exceptions like Msg itself. This is gated on a verbose config that is on by +default and can be turned off. + +The sr.ht upstream has a macos update pushed to it. Pull it, merge it into the tip here as its own change, then look at what the macos backend gained and port +those features to the sdl backend wherever it makes sense. + +Config options should print symmetrically with the way they are set: instead of showing transparency with a colon and a percent sign it should read like +`Etcetera 70`, exactly what you would type to set it, and the same for every other setting. LocationsConfig should only open an output window with the current +config when it is called with no arguments. + +Closing the last pane in a column should not delete the column: it should leave a new empty pane there instead. A column closes only when it is closed explicitly, +so if there is no builtin for that, add a Delcol that sits on the column tagline by default. And in every tagline the builtin that kills or closes the thing should +come last, which does not look like the case for panes right now. + +Pasting regressed on the terminal: inside agent sessions text is being pasted as an image and simply does not work. Reproduce it first, then fix it. + +The 9p skill documentation should teach interacting with a running pardes through the /mnt/9p mount with ordinary file tools — cat, echo, ls — as the normal +ad-hoc path, and fall back to the python client only when nothing is mounted. + +Dead sessions are never removed from the posted-9P registry, which is a bug. A session that aborts or is killed leaves both its socket in $XDG_RUNTIME_DIR and its +symlink under the registry directory, so /mnt/9p/pardes lists entries that give Input/output error on access. postToRegistry only ever replaces its own name's +entry; nothing sweeps the rest. Posting should sweep the service directory and unlink every entry whose target refuses a connection, and the dangling socket with +it. cloud9 already classifies a refused connect as stale (post.zig Probe), and 9p_io.zig already has `alive`, which treats uncertainty as live -- that is the right +bias, so only a definite refusal reaps. + +After all of the above, do an optimization pass on startup time for the gui and tty platforms: measure first, then optimize. build.zig already has a `perf` step +(gesture latency and bounded terminal stress, with --json and a --base baseline to compare against), so a startup measurement belongs there rather than in a new +harness, and the baseline files are how a regression gets caught later. diff --git a/src/9p_io.zig b/src/9p_io.zig index 4f7c2e97..3d019e0d 100644 --- a/src/9p_io.zig +++ b/src/9p_io.zig @@ -596,7 +596,7 @@ pub const Listener = struct { } for (l.control) |fd| { setCloexec(fd); - setNonblock(fd); + _ = setNonblock(fd); } l.arm(); l.watcher = try std.Thread.spawn(.{}, watchQuic, .{l}); @@ -671,6 +671,7 @@ pub const Listener = struct { log.warn("registry post skipped: cannot create {s}", .{svc}); return; } + sweepRegistry(l.io, svc); var entry_buf: [sun_path_len:0]u8 = undefined; const entry = std.fmt.bufPrintSentinel(&entry_buf, "{s}/{s}", .{ svc, name }, 0) catch { log.warn("registry post skipped: name too long: {s}", .{name}); @@ -679,15 +680,15 @@ pub const Listener = struct { const target = l.path_buf[0..l.path_len]; // Replace only what is provably not live: our own entry, or a - // dead predecessor's symlink. `isListening` treats uncertainty - // as live, so it is only asked about an entry that *is* a - // symlink; anything else is left strictly alone and the - // symlink below simply fails. + // dead predecessor's symlink. `probe` treats uncertainty as + // live, so it is only asked about an entry that *is* a symlink; + // anything else is left strictly alone and the symlink below + // simply fails. var link_buf: [sun_path_len]u8 = undefined; const n = libc.readlink(entry, &link_buf, link_buf.len); if (n >= 0) { const had = link_buf[0..@intCast(n)]; - if (!std.mem.eql(u8, had, target) and alive(entry)) { + if (!std.mem.eql(u8, had, target) and probe(entry) == .live) { log.warn("registry entry pardes/{s} is live; not re-posted", .{name}); return; } @@ -842,12 +843,129 @@ pub fn listen(io: std.Io, gpa: std.mem.Allocator, named: []const u8, fallback: [ const alive = transport.isListening; -fn setNonblock(fd: c_int) void { +/// What is at a socket path, in cloud9's three answers (`post.Probe`). +/// Asked here with libc rather than through `cloud9.post.probe`, whose +/// raw Linux syscalls darwin cannot compile, but the classification is +/// that file's and must not become a second opinion: the one definite +/// refusal is `.stale`, nothing at the path at all is `.none`, and +/// everything else — connected, busy, refused permission, a surprise — +/// is `.live`. Uncertainty belongs to the server that owns the socket, +/// never to a sweeper deciding what to delete. +const Probe = enum { none, stale, live }; + +/// `SOCK.STREAM`, and the kernel's own non-blocking bit where there is +/// one. Darwin's `SOCK.NONBLOCK` is a Zig shim for `std.posix.socket` +/// to unpack, not an ABI value, so handing it to the raw libc call +/// would ask a kernel that has never heard of it; there it is an +/// `fcntl` instead. +const probe_socket_kind: c_uint = libc.SOCK.STREAM | (if (darwin) 0 else libc.SOCK.NONBLOCK); + +fn probe(path: [:0]const u8) Probe { + if (path.len + 1 > sun_path_len) return .live; // cannot ask; assume occupied + var addr: libc.sockaddr.un = .{ .path = @splat(0) }; + @memcpy(addr.path[0 .. path.len + 1], path[0 .. path.len + 1]); + const fd = libc.socket(libc.AF.UNIX, probe_socket_kind, 0); + if (fd < 0) return .live; + defer _ = libc.close(fd); + + // Non-blocking is the whole safety of this function, so it is read + // back rather than assumed: a BLOCKING connect to a live server + // whose backlog is full parks in the kernel with no timeout to end + // it — measured, it simply never returns — and a sweep that parks + // takes the editor's startup with it. An fd that cannot be proven + // non-blocking is never connected at all, which lands on `.live`, + // the answer that deletes nothing. + if (comptime darwin) _ = setNonblock(fd); + if (!isNonblocking(fd)) return .live; + + if (libc.connect(fd, @ptrCast(&addr), @sizeOf(@TypeOf(addr))) == 0) return .live; + // cloud9's `post.probe` mapping, answer for answer. The connection + // is never wanted: EAGAIN (a full Unix backlog) and EINPROGRESS say + // somebody is listening, which is all that was asked, and the fd + // closes without ever waiting for it to become writable. + return switch (libc.errno(-1)) { + .AGAIN, .INPROGRESS, .PERM, .ACCES => .live, + .CONNREFUSED => .stale, + .NOENT, .NOTDIR => .none, + else => .live, + }; +} + +/// Reaps the registry entries whose editor is gone, once per post. +/// +/// A clean exit unposts itself (`unpostFromRegistry`), so everything +/// left behind comes from an exit that could not: an aborted test, a +/// kill, a crash. No code in the dead process can ever run, so the cure +/// has to be somebody else's readdir, and the next editor to start is +/// the somebody. It is only ever a symlink that is followed or +/// unlinked, because that is the only thing `postToRegistry` makes and +/// anything else under a name belongs to whoever put it there; and only +/// a definite refusal counts as gone. The socket a stale entry points +/// at goes too, but not before a stat agrees it is a socket of ours: a +/// plain file answers a connect with the same refusal. +fn sweepRegistry(io: std.Io, svc: [:0]const u8) void { + if (comptime !supported) return; + + // The names are staged before anything is unlinked, so the sweep + // never asks a directory to keep reading while it is being edited. + var names: [4096]u8 = undefined; + var staged: usize = 0; + { + const dir = std.Io.Dir.openDirAbsolute(io, svc, .{ .iterate = true }) catch return; + defer dir.close(io); + var read_buf: [std.Io.Dir.Iterator.reader_buffer_len]u8 align(@alignOf(usize)) = undefined; + var reader: std.Io.Dir.Reader = .init(dir, &read_buf); + while (true) { + const listed = (reader.next(io) catch break) orelse break; + if (listed.name.len == 0 or listed.name.len > 255) continue; + if (staged + 1 + listed.name.len > names.len) break; + names[staged] = @intCast(listed.name.len); + @memcpy(names[staged + 1 ..][0..listed.name.len], listed.name); + staged += 1 + listed.name.len; + } + } + + var reaped: usize = 0; + var i: usize = 0; + while (i < staged) { + const name = names[i + 1 ..][0..names[i]]; + i += 1 + name.len; + var entry_buf: [sun_path_len:0]u8 = undefined; + const entry = std.fmt.bufPrintSentinel(&entry_buf, "{s}/{s}", .{ svc, name }, 0) catch continue; + const facts = statNoFollow(entry) orelse continue; + if (facts.mode & 0o170000 != 0o120000) continue; // not a symlink: not ours to judge + const state = probe(entry); + if (state == .live) continue; + var link_buf: [sun_path_len]u8 = undefined; + const n = libc.readlink(entry, &link_buf, link_buf.len); + if (libc.unlink(entry) != 0) continue; + reaped += 1; + // A relative target would resolve against this editor's working + // directory, which says nothing about what the entry named. + if (state != .stale or n <= 0 or link_buf[0] != '/') continue; + var target_buf: [sun_path_len:0]u8 = undefined; + const target = std.fmt.bufPrintSentinel(&target_buf, "{s}", .{link_buf[0..@intCast(n)]}, 0) catch continue; + const t = statNoFollow(target) orelse continue; + if (t.mode & 0o170000 == 0o140000 and t.uid == libc.getuid()) _ = libc.unlink(target); + } + if (reaped != 0) log.info("reaped {d} stale registry entries under {s}", .{ reaped, svc }); +} + +/// Whether it worked, because `probe` is not allowed to find out the +/// hard way: a caller that needs the guarantee has to be able to check. +fn setNonblock(fd: c_int) bool { const flags = libc.fcntl(fd, libc.F.GETFL, @as(c_int, 0)); - if (flags < 0) return; + if (flags < 0) return false; var o: libc.O = @bitCast(@as(u32, @bitCast(flags))); o.NONBLOCK = true; - _ = libc.fcntl(fd, libc.F.SETFL, @as(c_int, @bitCast(@as(u32, @bitCast(o))))); + return libc.fcntl(fd, libc.F.SETFL, @as(c_int, @bitCast(@as(u32, @bitCast(o))))) >= 0; +} + +fn isNonblocking(fd: c_int) bool { + const flags = libc.fcntl(fd, libc.F.GETFL, @as(c_int, 0)); + if (flags < 0) return false; + const o: libc.O = @bitCast(@as(u32, @bitCast(flags))); + return o.NONBLOCK; } const testing = std.testing; @@ -866,6 +984,108 @@ test "a name that is not one path component is no address at all" { try testing.expect(socketPath(&buf, "/run", "a\x00b") == null); } +test "the registry sweep takes the dead entries and leaves everything else" { + if (comptime !supported) return error.SkipZigTest; + // Under the real runtime directory, because a sun_path is 108 bytes + // and the test cache's temporary directories are longer than that. + var dir_buf: [sun_path_len:0]u8 = undefined; + const base = socketDir(&dir_buf) orelse return error.SkipZigTest; + if (!ensureSocketDir(base)) return error.SkipZigTest; + + var svc_buf: [sun_path_len:0]u8 = undefined; + const svc = std.fmt.bufPrintSentinel(&svc_buf, "{s}/sweep-{d}", .{ base, @as(u32, @intCast(libc.getpid())) }, 0) catch + return error.SkipZigTest; + if (libc.mkdir(svc, 0o700) != 0) return error.SkipZigTest; + + var paths: [5][sun_path_len:0]u8 = undefined; + const live_sock = try std.fmt.bufPrintSentinel(&paths[0], "{s}/live.sock", .{svc}, 0); + const dead_sock = try std.fmt.bufPrintSentinel(&paths[1], "{s}/dead.sock", .{svc}, 0); + const live = try std.fmt.bufPrintSentinel(&paths[2], "{s}/live", .{svc}, 0); + const dead = try std.fmt.bufPrintSentinel(&paths[3], "{s}/dead", .{svc}, 0); + const stranger = try std.fmt.bufPrintSentinel(&paths[4], "{s}/stranger", .{svc}, 0); + defer { + for ([_][:0]const u8{ live_sock, dead_sock, live, dead, stranger }) |p| _ = libc.unlink(p); + _ = libc.rmdir(svc); + } + + const listening = bindSocket(live_sock); + try testing.expect(listening >= 0); + defer _ = libc.close(listening); + try testing.expectEqual(@as(c_int, 0), libc.listen(listening, 1)); + + // Bound and then dropped: the file stays, and nobody answers it — + // exactly what an aborted test leaves behind. + const abandoned = bindSocket(dead_sock); + try testing.expect(abandoned >= 0); + _ = libc.close(abandoned); + + try testing.expectEqual(@as(c_int, 0), libc.symlink(live_sock, live)); + try testing.expectEqual(@as(c_int, 0), libc.symlink(dead_sock, dead)); + // Not a symlink, so not this program's to reason about, even though + // connecting to it is refused exactly like the dead socket. + try std.Io.Dir.cwd().writeFile(testing.io, .{ .sub_path = stranger, .data = "" }); + + // The guarantee itself, asserted rather than inferred from the fact + // that the test finished: if a probe socket ever stops being + // non-blocking the connect below parks instead of failing, and a + // parked test costs whoever is building far more than a red one. + const checking = libc.socket(libc.AF.UNIX, probe_socket_kind, 0); + try testing.expect(checking >= 0); + if (comptime darwin) try testing.expect(setNonblock(checking)); + try testing.expect(isNonblocking(checking)); + _ = libc.close(checking); + + // The listener's backlog is filled before anything is asked, because + // a full backlog is the one place a blocking connect parks forever + // (`unix_wait_for_peer`, no timeout) and a sweep that only answers + // while nobody is queued is the sweep that hangs a build. Nothing + // below accepts any of these, so the queue stays full throughout. + var queued: [8]c_int = @splat(-1); + defer for (queued) |fd| { + if (fd >= 0) _ = libc.close(fd); + }; + for (&queued) |*slot| { + const fd = libc.socket(libc.AF.UNIX, probe_socket_kind, 0); + if (fd < 0) break; + if (comptime darwin) _ = setNonblock(fd); + var addr: libc.sockaddr.un = .{ .path = @splat(0) }; + @memcpy(addr.path[0 .. live_sock.len + 1], live_sock[0 .. live_sock.len + 1]); + _ = libc.connect(fd, @ptrCast(&addr), @sizeOf(@TypeOf(addr))); + slot.* = fd; + } + + const started = transport.nowMs(); + try testing.expectEqual(Probe.live, probe(live)); + try testing.expectEqual(Probe.stale, probe(dead)); + + sweepRegistry(testing.io, svc); + + // Promptly, and not "eventually": a blocking probe never comes back + // at all, so any wall-clock bound at all is the assertion that + // matters. A second is several thousand times what three connects + // and a readdir cost. + try testing.expect(transport.nowMs() - started < 1000); + + try testing.expect(statNoFollow(dead) == null); + try testing.expect(statNoFollow(dead_sock) == null); + try testing.expect(statNoFollow(live) != null); + try testing.expect(statNoFollow(live_sock) != null); + try testing.expect(statNoFollow(stranger) != null); + try testing.expectEqual(Probe.live, probe(live)); +} + +fn bindSocket(path: [:0]const u8) c_int { + const fd = libc.socket(libc.AF.UNIX, libc.SOCK.STREAM, 0); + if (fd < 0) return fd; + var addr: libc.sockaddr.un = .{ .path = @splat(0) }; + @memcpy(addr.path[0 .. path.len + 1], path[0 .. path.len + 1]); + if (libc.bind(fd, @ptrCast(&addr), @sizeOf(@TypeOf(addr))) != 0) { + _ = libc.close(fd); + return -1; + } + return fd; +} + test "one connection's buffers are sized from the one msize constant" { try testing.expect(msize >= ninep.min_msize); try testing.expectEqual(@as(u32, msize), Runner.msize); @@ -1102,24 +1322,41 @@ pub fn start(io: std.Io, gpa: std.mem.Allocator, core: *pardes.Pardes) ?*Listene return listener; } -pub fn exportPaneEnv(listener: ?*const Listener, serial: u32, forward_look: bool) void { - _ = unsetenv("PARDES_FORWARD_LOOK"); +/// What a pane shell is told about the editor above it, set into this +/// process's environment just before `forkpty` so the child inherits it. +/// +/// Two independent facts, and they are separate variables because they answer +/// separate questions. `PARDES_PID` says "you are inside this editor, and it +/// will take a Look from you": a session whose 9P listener never came up still +/// owns its children, so the child says so rather than looking, from its own +/// side, exactly like no pardes at all. `PARDES_9P` and `PARDES_PANE` say how +/// to reach it, and a `--nested` session exports them too — its socket stays +/// open to scripts and to mounted shells — while withholding `PARDES_PID`, +/// which is the whole of what `--nested` means. +pub fn exportPaneEnv(listener: ?*const Listener, serial: u32, adopts: bool) void { + var announced = false; + if (adopts) announcing: { + var buf: [16]u8 = undefined; + const text = std.fmt.bufPrintSentinel(&buf, "{d}", .{@as(u32, @intCast(libc.getpid()))}, 0) catch + break :announcing; + announced = setenv("PARDES_PID", text, 1) == 0; + } + if (!announced) _ = unsetenv("PARDES_PID"); + if (listener) |l| exporting: { var sock: [sun_path_len]u8 = undefined; const path = std.fmt.bufPrintSentinel(&sock, "{s}", .{l.path()}, 0) catch break :exporting; var buf: [16]u8 = undefined; const id = std.fmt.bufPrintSentinel(&buf, "{d}", .{serial}, 0) catch break :exporting; if (setenv("PARDES_9P", path, 1) != 0) break :exporting; - if (setenv("PARDES_PANE", id, 1) != 0) break :exporting; - if (setenv("PARDES_FORWARD_LOOK", if (forward_look) "1" else "0", 1) == 0) return; + if (setenv("PARDES_PANE", id, 1) == 0) return; } _ = unsetenv("PARDES_9P"); _ = unsetenv("PARDES_PANE"); - _ = setenv("PARDES_FORWARD_LOOK", "0", 1); } -test "9P shell environment preserves identity when nested Look forwarding is disabled" { - const names = [_][*:0]const u8{ "XDG_RUNTIME_DIR", "HOME", "PARDES_9P", "PARDES_PANE", "PARDES_FORWARD_LOOK" }; +test "9P shell environment states being inside pardes apart from how to reach it" { + const names = [_][*:0]const u8{ "XDG_RUNTIME_DIR", "HOME", "PARDES_PID", "PARDES_9P", "PARDES_PANE" }; var saved: [names.len]?[:0]u8 = @splat(null); for (names, &saved) |name, *value| { if (libc.getenv(name)) |old| value.* = try testing.allocator.dupeZ(u8, std.mem.span(old)); @@ -1146,17 +1383,32 @@ test "9P shell environment preserves identity when nested Look forwarding is dis const path = "/tmp/pardes-example.sock"; @memcpy(listener.path_buf[0..path.len], path); listener.path_len = path.len; + var own: [16]u8 = undefined; + const own_pid = try std.fmt.bufPrint(&own, "{d}", .{@as(u32, @intCast(libc.getpid()))}); + + // A `--nested` session: reachable for scripts and mounts, but nobody's + // parent, so a pardes started in one of its shells runs a session of + // its own instead of handing its argument over. exportPaneEnv(listener, 7, false); try testing.expectEqualStrings(path, std.mem.span(libc.getenv("PARDES_9P").?)); try testing.expectEqualStrings("7", std.mem.span(libc.getenv("PARDES_PANE").?)); - try testing.expectEqualStrings("0", std.mem.span(libc.getenv("PARDES_FORWARD_LOOK").?)); + try testing.expect(libc.getenv("PARDES_PID") == null); + exportPaneEnv(listener, 8, true); try testing.expectEqualStrings("8", std.mem.span(libc.getenv("PARDES_PANE").?)); - try testing.expectEqualStrings("1", std.mem.span(libc.getenv("PARDES_FORWARD_LOOK").?)); + try testing.expectEqualStrings(own_pid, std.mem.span(libc.getenv("PARDES_PID").?)); + + // A session whose listener never came up is still the session this shell + // is inside: the pid stands on its own, and only the address is missing. + exportPaneEnv(null, 0, true); + try testing.expect(libc.getenv("PARDES_9P") == null); + try testing.expect(libc.getenv("PARDES_PANE") == null); + try testing.expectEqualStrings(own_pid, std.mem.span(libc.getenv("PARDES_PID").?)); + exportPaneEnv(null, 0, false); try testing.expect(libc.getenv("PARDES_9P") == null); try testing.expect(libc.getenv("PARDES_PANE") == null); - try testing.expectEqualStrings("0", std.mem.span(libc.getenv("PARDES_FORWARD_LOOK").?)); + try testing.expect(libc.getenv("PARDES_PID") == null); } pub const Client = struct { diff --git a/src/builtins.zig b/src/builtins.zig index 39d70e5d..aa2b2d6d 100644 --- a/src/builtins.zig +++ b/src/builtins.zig @@ -137,6 +137,14 @@ pub const registry = struct { unreachable; } + /// Does this builtin say its own name on the message row before it runs? + /// The ones that own that row themselves declare `quiet` and do not. + pub fn announces(b: Builtin()) bool { + inline for (manualBuiltinList(), 0..) |T, i| + if (@intFromEnum(b) == i) return !(@hasDecl(T, "quiet") and T.quiet); + return true; // a setting builtin changes something invisible; say so + } + pub fn dispatch(b: Builtin(), c: Ctx) void { inline for (manualBuiltinList(), 0..) |T, i| if (@intFromEnum(b) == i) return T.run(c); @@ -259,6 +267,7 @@ pub const Unmount = struct { pub const Msg = struct { pub const takes_arg = true; + pub const quiet = true; // it IS the message row pub fn run(c: Ctx) void { if (c.arg) |text| c.p.setMessage(c.id, text) @@ -542,11 +551,15 @@ pub const LocationsConfig = struct { pub const output: OutputTraits = .{ .name = "+LocationsConfig" }; pub fn run(c: Ctx) void { - const next = c.p.locations_config.parse(c.arg orelse "") catch |err| { + const argument = std.mem.trim(u8, c.arg orelse "", " \t\r\n"); + const next = c.p.locations_config.parse(argument) catch |err| { c.p.reportError(c.id, "LocationsConfig", err); return; }; c.p.locations_config = next; + // Bare, it is a question, and the window is the answer. With arguments + // it is a setting, and a setting that opens a window is noise. + if (argument.len != 0) return; report(c) catch |err| c.p.reportError(c.id, "LocationsConfig", err); } diff --git a/src/config.zig b/src/config.zig index 440549b3..3169b20c 100644 --- a/src/config.zig +++ b/src/config.zig @@ -71,6 +71,7 @@ pub const leader_path = paths: { .FocusTint = null, .ColumnTags = null, .SyntaxBold = null, + .Verbose = null, .TreeContextTagStyle = null, .Wrap = "tw", .Tagbottom = "tb", @@ -224,10 +225,10 @@ pub const tty_filter_min_contrast: f64 = 1.5; pub const topbar_str = "Newcol Joincol Find Grep Help Changelog Tutor Dump NextColor Debug Kill"; -pub const pane_builtins_str = "Tty Del Collapse"; -pub const pdf_pane_builtins_str = "Tty Del PdfSections PdfTint Collapse"; -pub const file_pane_builtins_str = "Save Tty Del Collapse"; -pub const terminal_pane_builtins_str = "Tty Save Del Mode Filter Collapse"; +pub const pane_builtins_str = "Tty Collapse Del"; +pub const pdf_pane_builtins_str = "Tty PdfSections PdfTint Collapse Del"; +pub const file_pane_builtins_str = "Save Tty Collapse Del"; +pub const terminal_pane_builtins_str = "Tty Save Mode Filter Collapse Del"; // Each mode badge is one codepoint. pub const tag_normal = " "; @@ -540,6 +541,8 @@ pub const Runtime = struct { focus_tint: bool = true, column_tags: bool = true, syntax_bold: bool = false, + /// Builtins announce themselves on the message row. + verbose: bool = true, window_opacity: u8 = 100, window_blur: u8 = 0, window_opacity_pending: bool = true, @@ -637,7 +640,7 @@ pub const Runtime = struct { pub const Capability = std.meta.FieldEnum(Capabilities); - pub const Toggle = enum { colors, wrap, tree_context_tag_style, tag_bottom, debug, focus_tint, column_tags, syntax_bold }; + pub const Toggle = enum { colors, wrap, tree_context_tag_style, tag_bottom, debug, focus_tint, column_tags, syntax_bold, verbose }; pub const Scene = std.meta.FieldEnum(layout.SceneEffect); pub const Action = union(enum) { @@ -682,6 +685,7 @@ pub const Runtime = struct { .{ .word = "FocusTint", .action = .{ .toggle = .focus_tint } }, .{ .word = "ColumnTags", .action = .{ .toggle = .column_tags } }, .{ .word = "SyntaxBold", .action = .{ .toggle = .syntax_bold } }, + .{ .word = "Verbose", .action = .{ .toggle = .verbose } }, .{ .word = "Theme", .action = .theme }, .{ .word = "Shell", .action = .shell }, .{ .word = "Font", .action = .font, .availability = .font_picker }, @@ -761,15 +765,10 @@ pub const Runtime = struct { pub fn apply(state: *Runtime, setting: Setting, argument: ?[]const u8) bool { switch (setting.action) { + // Every toggle names a bool field of its own, so one line covers + // all of them and a new toggle needs no arm here. .toggle => |field| switch (field) { - .colors => state.colors = !state.colors, - .wrap => state.wrap = !state.wrap, - .tree_context_tag_style => state.tree_context_tag_style = !state.tree_context_tag_style, - .tag_bottom => state.tag_bottom = !state.tag_bottom, - .debug => state.debug = !state.debug, - .focus_tint => state.focus_tint = !state.focus_tint, - .column_tags => state.column_tags = !state.column_tags, - .syntax_bold => state.syntax_bold = !state.syntax_bold, + inline else => |f| @field(state, @tagName(f)) = !@field(state, @tagName(f)), }, .shell => { const value = std.mem.trim(u8, argument orelse return false, " \t\r\n"); @@ -835,46 +834,42 @@ pub const Runtime = struct { return findAction(.{ .transition = transition }).?.word; } + /// Each line reads as the command that would set it: the word, then the + /// value you would type after it. No colons, no units — `WindowOpacity 70` + /// is both what Config prints and what you write back. pub fn writeReport(out: *std.Io.Writer, context: ReportContext) !void { const state = context.state; var wrote_transition = false; for (settings) |setting| switch (setting.action) { .toggle => |field| { const value = switch (field) { - .colors => state.colors, - .wrap => state.wrap, - .tree_context_tag_style => state.tree_context_tag_style, - .tag_bottom => state.tag_bottom, - .debug => state.debug, - .focus_tint => state.focus_tint, - .column_tags => state.column_tags, - .syntax_bold => state.syntax_bold, + inline else => |f| @field(state, @tagName(f)), }; - try out.print("{s}: {s}\n", .{ setting.word, onOff(value) }); + try out.print("{s} {s}\n", .{ setting.word, onOff(value) }); }, - .theme => try out.print("{s}: {s}\n", .{ setting.word, context.theme_name }), + .theme => try out.print("{s} {s}\n", .{ setting.word, context.theme_name }), .window_opacity => { if (setting.enabled(context.capabilities)) - try out.print("{s}: {d}%{s}\n", .{ + try out.print("{s} {d}{s}\n", .{ setting.word, state.window_opacity, if (state.window_opacity_pending) " (pending)" else "", }) else - try out.print("{s}: unsupported\n", .{setting.word}); + try out.print("{s} unsupported\n", .{setting.word}); }, .window_blur => { if (setting.enabled(context.capabilities)) - try out.print("{s}: {d}%\n", .{ setting.word, state.window_blur }) + try out.print("{s} {d}\n", .{ setting.word, state.window_blur }) else - try out.print("{s}: unsupported\n", .{setting.word}); + try out.print("{s} unsupported\n", .{setting.word}); }, .shell => { const chosen = state.shell.requested.get(); try out.print( - "{s} requested (new panes): {s}{s}\n" ++ - "{s} effective (last spawn): {s}\n" ++ - "{s} pending: {s}\n", + "{s} requested (new panes) {s}{s}\n" ++ + "{s} effective (last spawn) {s}\n" ++ + "{s} pending {s}\n", .{ setting.word, if (chosen.len == 0) context.compiled_default_shell else chosen, @@ -887,18 +882,18 @@ pub const Runtime = struct { ); }, .font => if (!setting.enabled(context.capabilities)) - try out.print("{s}: unsupported\n", .{setting.word}) + try out.print("{s} unsupported\n", .{setting.word}) else { if (state.font.requested_size_hundredths == 0) - try out.print("{s} requested size: unchanged\n", .{setting.word}) + try out.print("{s} requested size unchanged\n", .{setting.word}) else - try out.print("{s} requested size: {d}.{d:0>2}\n", .{ setting.word, state.font.requested_size_hundredths / 100, state.font.requested_size_hundredths % 100 }); + try out.print("{s} requested size {d}.{d:0>2}\n", .{ setting.word, state.font.requested_size_hundredths / 100, state.font.requested_size_hundredths % 100 }); try out.print( - "{s} requested: {s}\n" ++ - "{s} requested path: {s}\n" ++ - "{s} effective: {s}\n" ++ - "{s} pending: {s}\n" ++ - "{s} effective size: {d}.{d:0>2} {s}\n", + "{s} requested {s}\n" ++ + "{s} requested path {s}\n" ++ + "{s} effective {s}\n" ++ + "{s} pending {s}\n" ++ + "{s} effective size {d}.{d:0>2} {s}\n", .{ setting.word, shown(state.font.requested_name.get()), @@ -916,28 +911,28 @@ pub const Runtime = struct { ); }, .tagline_size => if (!context.capabilities.tagline_font_size) - try out.print("{s}: unsupported\n", .{setting.word}) + try out.print("{s} unsupported\n", .{setting.word}) else if (!setting.enabled(context.capabilities)) - try out.print("{s}: {d}% (build-time only)\n", .{ setting.word, state.font.tagline_percent }) + try out.print("{s} {d} (build-time only)\n", .{ setting.word, state.font.tagline_percent }) else - try out.print("{s}: {d}%\n", .{ setting.word, state.font.tagline_percent }), + try out.print("{s} {d}\n", .{ setting.word, state.font.tagline_percent }), .transition => { if (wrote_transition) continue; wrote_transition = true; if (!setting.enabled(context.capabilities)) - try out.writeAll("Panel transition: unsupported\n") + try out.writeAll("Panel transition unsupported\n") else - try out.print("Panel transition: {s}\n", .{transitionSettingName(state.panel_transition)}); + try out.print("Panel transition {s}\n", .{transitionSettingName(state.panel_transition)}); }, .scene => |effect| { if (!setting.enabled(context.capabilities)) { - try out.print("{s}: unsupported\n", .{setting.word}); + try out.print("{s} unsupported\n", .{setting.word}); continue; } const enabled = switch (effect) { inline else => |field| @field(state.scene_effects, @tagName(field)), }; - try out.print("{s}: {s}\n", .{ setting.word, onOff(enabled) }); + try out.print("{s} {s}\n", .{ setting.word, onOff(enabled) }); }, }; @@ -1073,7 +1068,8 @@ pub const Runtime = struct { test "Config report observes every simple setting and all live context" { var state: Runtime = .{}; - var storage: [4096]u8 = undefined; + // Every setting, every context line: the report outgrows 4K. + var storage: [8192]u8 = undefined; const context: ReportContext = .{ .startup_config_path = "/tmp/pardes/init", .platform = "gui", @@ -1112,37 +1108,38 @@ pub const Runtime = struct { const report = storage[0..out.end]; const expected = switch (setting.action) { .toggle => |field| switch (field) { - .colors => "Colors: off\n", - .wrap => "Wrap: off\n", - .tree_context_tag_style => "TreeContextTagStyle: off\n", - .tag_bottom => "Tagbottom: on\n", - .debug => "Debug: on\n", - .focus_tint => "FocusTint: off\n", - .column_tags => "ColumnTags: off\n", - .syntax_bold => "SyntaxBold: on\n", + .colors => "Colors off\n", + .wrap => "Wrap off\n", + .tree_context_tag_style => "TreeContextTagStyle off\n", + .tag_bottom => "Tagbottom on\n", + .debug => "Debug on\n", + .focus_tint => "FocusTint off\n", + .column_tags => "ColumnTags off\n", + .syntax_bold => "SyntaxBold on\n", + .verbose => "Verbose off\n", }, - .shell => "Shell requested (new panes): fish\n", - .tagline_size => "TaglineSize: 73%\n", - .window_opacity => "WindowOpacity: 85% (pending)\n", - .window_blur => "WindowBlur: 40%\n", + .shell => "Shell requested (new panes) fish\n", + .tagline_size => "TaglineSize 73\n", + .window_opacity => "WindowOpacity 85 (pending)\n", + .window_blur => "WindowBlur 40\n", .transition => |transition| switch (transition) { .off => unreachable, - .slide => "Panel transition: PanelSlide\n", - .zoom => "Panel transition: PanelZoom\n", - .dissolve => "Panel transition: PanelDissolve\n", - .ascii => "Panel transition: PanelAscii\n", - .vertical => "Panel transition: PanelVertical\n", - .edges => "Panel transition: PanelEdges\n", - .fall => "Panel transition: PanelFall\n", - .wave => "Panel transition: PanelWave\n", - .curtain => "Panel transition: PanelCurtain\n", - .scramble => "Panel transition: PanelScramble\n", - .typewriter => "Panel transition: PanelType\n", + .slide => "Panel transition PanelSlide\n", + .zoom => "Panel transition PanelZoom\n", + .dissolve => "Panel transition PanelDissolve\n", + .ascii => "Panel transition PanelAscii\n", + .vertical => "Panel transition PanelVertical\n", + .edges => "Panel transition PanelEdges\n", + .fall => "Panel transition PanelFall\n", + .wave => "Panel transition PanelWave\n", + .curtain => "Panel transition PanelCurtain\n", + .scramble => "Panel transition PanelScramble\n", + .typewriter => "Panel transition PanelType\n", }, .scene => |effect| switch (effect) { - .crt => "Crt: on\n", - .ripple => "Ripple: on\n", - .glitch => "Glitch: on\n", + .crt => "Crt on\n", + .ripple => "Ripple on\n", + .glitch => "Glitch on\n", }, .theme, .font => unreachable, }; @@ -1163,15 +1160,15 @@ pub const Runtime = struct { try writeReport(&out, context); const report = storage[0..out.end]; for ([_][]const u8{ - "Theme: acme\n", - "WindowOpacity: 85%\n", - "Font requested size: 18.50\n", - "Font requested: Wanted Mono\n", - "Font requested path: /fonts/wanted.ttf\n", - "Font effective: Effective Mono\n", - "Font pending: on\n", - "Font effective size: 13.75 points\n", - "TaglineSize: 82%\n", + "Theme acme\n", + "WindowOpacity 85\n", + "Font requested size 18.50\n", + "Font requested Wanted Mono\n", + "Font requested path /fonts/wanted.ttf\n", + "Font effective Effective Mono\n", + "Font pending on\n", + "Font effective size 13.75 points\n", + "TaglineSize 82\n", "Startup config: /tmp/pardes/init\n", "Platform: gui\n", "Compiled default shell: /bin/sh\n", @@ -1197,23 +1194,23 @@ pub const Runtime = struct { out = .fixed(&storage); try writeReport(&out, defaults_context); const defaults_report = storage[0..out.end]; - try std.testing.expect(std.mem.indexOf(u8, defaults_report, "WindowOpacity: unsupported\n") != null); + try std.testing.expect(std.mem.indexOf(u8, defaults_report, "WindowOpacity unsupported\n") != null); try std.testing.expect(!find("WindowOpacity").?.enabled(defaults_context.capabilities)); - try std.testing.expect(std.mem.indexOf(u8, defaults_report, "WindowBlur: unsupported\n") != null); + try std.testing.expect(std.mem.indexOf(u8, defaults_report, "WindowBlur unsupported\n") != null); try std.testing.expect(!find("WindowBlur").?.enabled(defaults_context.capabilities)); try std.testing.expect(find("WindowOpacity").?.enabled(context.capabilities)); - try std.testing.expect(std.mem.indexOf(u8, defaults_report, "Shell requested (new panes): /bin/sh (default)\n") != null); - try std.testing.expect(std.mem.indexOf(u8, defaults_report, "Shell effective (last spawn): (none)\n") != null); - try std.testing.expect(std.mem.indexOf(u8, defaults_report, "Shell pending: on\n") != null); + try std.testing.expect(std.mem.indexOf(u8, defaults_report, "Shell requested (new panes) /bin/sh (default)\n") != null); + try std.testing.expect(std.mem.indexOf(u8, defaults_report, "Shell effective (last spawn) (none)\n") != null); + try std.testing.expect(std.mem.indexOf(u8, defaults_report, "Shell pending on\n") != null); try std.testing.expect(std.mem.indexOf(u8, defaults_report, "Startup config: no per-user config path\n") != null); try std.testing.expect(std.mem.indexOf(u8, defaults_report, "GUI shader source:") == null); - try std.testing.expect(std.mem.indexOf(u8, defaults_report, "Font: unsupported\n") != null); - try std.testing.expect(std.mem.indexOf(u8, defaults_report, "Font requested:") == null); - try std.testing.expect(std.mem.indexOf(u8, defaults_report, "Panel transition: off\n") != null); - try std.testing.expect(std.mem.indexOf(u8, defaults_report, "Crt: unsupported\n") != null); - try std.testing.expect(std.mem.indexOf(u8, defaults_report, "Ripple: unsupported\n") != null); - try std.testing.expect(std.mem.indexOf(u8, defaults_report, "Glitch: unsupported\n") != null); - try std.testing.expect(std.mem.indexOf(u8, defaults_report, "TaglineSize: unsupported\n") != null); + try std.testing.expect(std.mem.indexOf(u8, defaults_report, "Font unsupported\n") != null); + try std.testing.expect(std.mem.indexOf(u8, defaults_report, "Font requested") == null); + try std.testing.expect(std.mem.indexOf(u8, defaults_report, "Panel transition off\n") != null); + try std.testing.expect(std.mem.indexOf(u8, defaults_report, "Crt unsupported\n") != null); + try std.testing.expect(std.mem.indexOf(u8, defaults_report, "Ripple unsupported\n") != null); + try std.testing.expect(std.mem.indexOf(u8, defaults_report, "Glitch unsupported\n") != null); + try std.testing.expect(std.mem.indexOf(u8, defaults_report, "TaglineSize unsupported\n") != null); try std.testing.expect(std.mem.indexOf(u8, defaults_report, "Look hover delay: off\n") != null); try std.testing.expect(std.mem.indexOf(u8, defaults_report, "Native images: off\n") != null); @@ -1223,8 +1220,8 @@ pub const Runtime = struct { out = .fixed(&storage); try writeReport(&out, defaults_context); const web_report = storage[0..out.end]; - try std.testing.expect(std.mem.indexOf(u8, web_report, "Panel transition: unsupported\n") != null); - try std.testing.expect(std.mem.indexOf(u8, web_report, "TaglineSize: 100% (build-time only)\n") != null); + try std.testing.expect(std.mem.indexOf(u8, web_report, "Panel transition unsupported\n") != null); + try std.testing.expect(std.mem.indexOf(u8, web_report, "TaglineSize 100 (build-time only)\n") != null); } }; diff --git a/src/fs-help.txt b/src/fs-help.txt index a0a84b28..1e5d64c2 100644 --- a/src/fs-help.txt +++ b/src/fs-help.txt @@ -2,41 +2,43 @@ Pardes control filesystem ========================= README this guide index one line per pane: serial, kind (text|term|pdf|image), dirty flag, name -ctl write commands; read the serials the last command made or touched -new reading it creates one empty pane and answers its serial +status pid, version and pane count +look write a line: a right click on it at the active pane; read: the serials it touched +exec write a line: a middle click, an editor command word or a shell line; read the same log one line per editor event (new/del/rename/save ); reads wait screen rendered screen as JSON, frozen from open to close listeners the session's dial addresses -pane// name body tag ctl addr data xdata sel errors event, and pty/ for terminals +pane/ mkdir makes a pane, rmdir closes it +pane// name body tag ctl addr dot limit data xdata sel dirty mark scroll + errors event look exec, and pty/ for terminals os/ the host filesystem src/ the editor's own sources, only in a -Dembed-sources=true build -Commands, on /ctl (applied at the active pane) or on pane//ctl (at that pane): - look TEXT a right click: open a file, a file:12 location, a directory, a URL - exec TEXT a middle click: an editor command word (Save Del New Newcol Mount Unmount - Dump Restore Msg Find Grep Tty ...), or a shell command for the pane's terminal Below, $m is the mount point (PARDES_MOUNT in a Tty9p shell; 9ns and 9p work too): cat $m/index which panes exist - n=$(cat $m/new) make a pane, remember its serial - echo 'look /etc/hosts:3' > $m/ctl; cat $m/ctl open a file, see the pane it went to - printf 'text\n' > $m/pane/$n/body append to a pane (>| truncates first) + mkdir $m/pane/x; n=$(awk 'END{print $1}' $m/index) make a pane, take its serial + echo /etc/hosts:3 > $m/look; cat $m/look open a file, see the pane it went to + printf 'text\n' > $m/pane/$n/body append to a pane (>| truncates first) cat $m/pane/$n/name; echo notes.txt > $m/pane/$n/name read, then rename - echo 'exec Save' > $m/pane/$n/ctl save it (exec Del closes it) - echo 'exec Msg hello' > $m/ctl show text in the editor + echo Save > $m/pane/$n/exec save it; rmdir $m/pane/$n closes it + echo 'Msg hello' > $m/exec show text in the editor echo '#0,#5' > $m/pane/$n/addr; echo NEW > $m/pane/$n/data replace bytes 0..5 - echo 'dot=addr' > $m/pane/$n/ctl; cat $m/pane/$n/sel select the range, read it + cp $m/pane/$n/addr $m/pane/$n/dot; cat $m/pane/$n/sel select the range, read it + cat $m/pane/$n/dirty; echo 0 > $m/pane/$n/dirty is it modified? say it is not cat $m/log block until a pane is made, renamed, saved or closed cat $m/pane/$n/event hold it open to own that pane's clicks - echo 'exec' > $m/pane/$n/pty/ctl restart a shell; also winsize C R, sig INT + echo exec > $m/pane/$n/pty/ctl restart a shell; also winsize C R, sig INT Pitfalls, one each: - Every open of new makes another pane, so `cat $m/new` twice makes two. - ls, stat and find create nothing; reading log, event or pty/data blocks until something happens. - exec Del closes a pane even when it is dirty; index shows the dirty flag first. - look and exec are lowercase verbs; the words after exec are the editor's capitalized commands. - ctl also takes acme's addr verbs (addr=dot dot=addr limit=addr clean dirty get show ...), one per line. + Only mkdir in pane/ makes a pane; ls, stat, find and every read create nothing. + Panes are named by the serial the editor gives them, not by the name mkdir asked for. + rmdir closes a pane even when it is dirty; index and pane//dirty show the flag. + addr, dot and limit read the same pair of offsets they take, so cp between them works. + dirty, mark and scroll read "0" or "1" and take "0" or "1"; truncating limit lifts it. Writing body appends; open it with truncation to replace; writes are whole UTF-8 sequences. + Truncating tag clears the part you may edit; truncating dot or addr empties it. A terminal's body is a history snapshot frozen per open; pty/data is the live stream. screen is frozen per open handle as well; reopen it for a fresh frame. - A command that fails is reported in the editor, not as a write error; a malformed line fails the write. + A failing command is reported in the editor, not as a write error; a bad line fails the write. + pane//ctl reads acme's window status line and takes one verb, get, which reloads from disk. diff --git a/src/fs.zig b/src/fs.zig index 7f416440..7cb08980 100644 --- a/src/fs.zig +++ b/src/fs.zig @@ -260,12 +260,13 @@ test "unmount refuses pane paths inherited directories and queued save targets" } gpa.free(pane.file.?.path); pane.file.?.path = try gpa.dupe(u8, "/n/peer2/file"); - const shell = try p.newShell(1, "/n/peer/dir"); - p.setCwd(1, "/n/peer/dir"); + const slot = p.freeSlot().?; + const shell = try p.newShell(slot, "/n/peer/dir"); + p.setCwd(slot, "/n/peer/dir"); try std.testing.expectError(error.MountInUse, unmount(p, "peer")); pane.cwd = .{ .inherited = shell }; try std.testing.expectError(error.MountInUse, unmount(p, "peer")); - p.setCwd(1, "/"); + p.setCwd(slot, "/"); while (p.nextEffect()) |_| {} p.emit(.{ .save_text = .{ .pane = 0, .serial = pane.serial, .path = .from("/n/peer/pending") } }); try std.testing.expectError(error.MountInUse, unmount(p, "peer")); @@ -1261,10 +1262,10 @@ pub const Namespace = struct { /// The editor-wide event stream, recorded only while /log is held open. log: tree.events.Queue = .{}, log_readers: u16 = 0, - /// What the last ctl command created or touched, answered by reading /ctl. + /// What the last look or exec created or touched, answered by reading + /// either of those files. results: [MAX_PANES]u32 = undefined, results_len: u8 = 0, - results_valid: bool = false, /// Process start, the mtime of everything that has no edit time of its own. started: u32 = 0, diff --git a/src/host_io.zig b/src/host_io.zig index 212c23b4..fb09fcc7 100644 --- a/src/host_io.zig +++ b/src/host_io.zig @@ -874,6 +874,9 @@ pub fn forkShell( if (fs == null) return error.SessionSocketRequired; break :blk try @import("linux/v9fs.zig").helperPath(&helper_buf); } else null; + // The last argument is whether this session takes its children's Looks — + // every session does but a `--nested` one, and a fork with no core at all + // (the tests below) is nobody's parent. ninep_io.exportPaneEnv( fs, if (core) |c| (if (c.panes[pane]) |pn| pn.serial else 0) else 0, diff --git a/src/main.zig b/src/main.zig index 4b1910bd..1cbdf24c 100644 --- a/src/main.zig +++ b/src/main.zig @@ -112,6 +112,16 @@ const nested_text = \\ ; +/// $PARDES_PID named a live editor, so this shell IS inside one, but the Look +/// never got there. Saying so beats quietly opening the second editor that +/// $PARDES_PID exists to prevent. +const unreachable_text = + \\pardes: this shell is inside pardes, but that session did not take the + \\file. Check that it is still running, or pass --nested to start a second + \\editor in here anyway. + \\ +; + // The browser runtime calls a C main (exported below); everything else keeps // the std.process.Init entry. pub const main = if (is_emscripten) webMain else nativeMain; @@ -260,6 +270,10 @@ fn nativeMain(init: std.process.Init) !void { } } opts.tty_only = explicit_tty or session_only; + // The real bare-tty startup wants the editor half present from the first + // frame, so it names that layout; a core booted for a test names none and + // gets the raw shell by itself. + if (opts.tty_only) opts.boot = .tty; opts.mounts = mounts[0..mounts_len]; if (detach != null and attach != null) badArgs(init.io, "--detach and --attach are opposites: one runs the session, the other joins one", .{}); @@ -272,31 +286,60 @@ fn nativeMain(init: std.process.Init) !void { if (opts.mounts.len != 0 and attach != null) badArgs(init.io, "--mount configures a session's own core, and --attach has none of its own", .{}); if (!new_session and !opts.nested and detach == null and attach == null) forwarding: { - const enabled = std.c.getenv("PARDES_FORWARD_LOOK") orelse break :forwarding; - if (!std.mem.eql(u8, std.mem.span(enabled), "1")) break :forwarding; - const dial = std.mem.span(std.c.getenv("PARDES_9P") orelse break :forwarding); - ninep_io.Client.validateDial(dial) catch break :forwarding; - const pane_text = std.mem.span(std.c.getenv("PARDES_PANE") orelse break :forwarding); - for (pane_text) |byte| if (!std.ascii.isDigit(byte)) break :forwarding; - const serial = std.fmt.parseInt(u32, pane_text, 10) catch break :forwarding; - if (serial == 0) break :forwarding; - var ctl_buf: [64]u8 = undefined; - const ctl = try std.fmt.bufPrint(&ctl_buf, "/pane/{d}/ctl", .{serial}); + // Am I inside a pardes at all? That is $PARDES_PID and nothing else — + // one variable, exported by every session that means to take its + // children's Looks, so a session that could not open a socket is still + // recognisably the session this shell is inside. A pid naming no live + // process is a shell that outlived its editor (a daemon started from a + // pane, a stale environment carried into a new terminal), which is not + // nested at all. + const owner = std.mem.span(std.c.getenv("PARDES_PID") orelse break :forwarding); + const pid = std.fmt.parseInt(std.c.pid_t, owner, 10) catch break :forwarding; + if (pid <= 0 or std.c.kill(pid, @enumFromInt(0)) != 0) break :forwarding; + + // Can I reach it? That is the other two, and it is a separate answer. + const Parent = struct { dial: []const u8, serial: u32 }; + const found: ?Parent = reaching: { + const dial = std.mem.span(std.c.getenv("PARDES_9P") orelse break :reaching null); + ninep_io.Client.validateDial(dial) catch break :reaching null; + const pane_text = std.mem.span(std.c.getenv("PARDES_PANE") orelse break :reaching null); + for (pane_text) |byte| if (!std.ascii.isDigit(byte)) break :reaching null; + const serial = std.fmt.parseInt(u32, pane_text, 10) catch break :reaching null; + if (serial == 0) break :reaching null; + break :reaching .{ .dial = dial, .serial = serial }; + }; + const parent = found orelse { + try std.Io.File.stderr().writeStreamingAll(init.io, unreachable_text); + std.process.exit(1); + }; + // The pane's `look` file: one line, and the line is the clicked text + // itself, which is what a right click in that pane would have been. + var look_buf: [64]u8 = undefined; + const look = try std.fmt.bufPrint(&look_buf, "/pane/{d}/look", .{parent.serial}); const word = positional orelse { var tag_buf: [64]u8 = undefined; - const tag = try std.fmt.bufPrint(&tag_buf, "/pane/{d}/tag", .{serial}); - const contents = ninep_io.Client.read(arena, dial, tag, tag) catch break :forwarding; + const tag = try std.fmt.bufPrint(&tag_buf, "/pane/{d}/tag", .{parent.serial}); + const contents = ninep_io.Client.read(arena, parent.dial, tag, tag) catch { + try std.Io.File.stderr().writeStreamingAll(init.io, unreachable_text); + std.process.exit(1); + }; arena.free(contents); try std.Io.File.stderr().writeStreamingAll(init.io, nested_text); std.process.exit(1); }; + // A word this launch cannot turn into a path is an argument problem + // rather than a nesting one: fall through and let the session that + // starts report it, the way `pardes typo` outside pardes does. if (std.mem.indexOfAny(u8, word, "\r\n") != null) break :forwarding; const target = @import("look.zig").parsePathLine(word); var realbuf: [4096]u8 = undefined; const path = if (pardes.filesystem.isVirtual(target.path)) target.path else (pardes.filesystem.resolveOs(target.path, &realbuf) orelse break :forwarding).path; var command_buf: [8192]u8 = undefined; - const command = std.fmt.bufPrint(&command_buf, "look {s}{s}\n", .{ path, word[target.path.len..] }) catch break :forwarding; - ninep_io.Client.write(arena, dial, ctl, command) catch break :forwarding; + const command = std.fmt.bufPrint(&command_buf, "{s}{s}\n", .{ path, word[target.path.len..] }) catch break :forwarding; + ninep_io.Client.write(arena, parent.dial, look, command) catch { + try std.Io.File.stderr().writeStreamingAll(init.io, unreachable_text); + std.process.exit(1); + }; return; } if (positional) |a| { diff --git a/src/ninep/addr.zig b/src/ninep/addr.zig index f7642b9e..566e2364 100644 --- a/src/ninep/addr.zig +++ b/src/ninep/addr.zig @@ -255,17 +255,25 @@ test "the address language, form by form" { try testing.expectEqual(@as(u32, 6), p.fs.panes[0].addr.q0); // the `o` in "two" try testing.expectEqual(@as(u32, 7), p.fs.panes[0].addr.q1); + // limit is its own file: copying addr onto it bounds the search, and + // truncating it lifts the bound again. + const limit = Node.of(serial, .limit); _ = th.wr(p, addr, "1"); - _ = th.wr(p, Node.of(serial, .ctl), "limit=addr\n"); + try testing.expectEqualStrings("", th.rd(p, limit, 0, 64).bytes); + var copied: [64]u8 = undefined; + const pair = th.rd(p, addr, 0, 64).bytes; + @memcpy(copied[0..pair.len], pair); + _ = th.wr(p, limit, copied[0..pair.len]); + try testing.expectEqual(@as(u32, 4), p.fs.panes[0].limit.?.q1); + try testing.expectEqualStrings(" 0 4 ", th.rd(p, limit, 0, 64).bytes); _ = th.wr(p, addr, "#0"); try testing.expectEqual(E.INVAL, th.wr(p, addr, "/three/").errno()); - _ = th.wr(p, Node.of(serial, .ctl), "clean\n"); - _ = th.call(p, .{ .tag = 6, .op = .open, .node = Node.of(serial, .ctl) }); + _ = th.call(p, .{ .tag = 6, .op = .setattr, .node = limit, .truncate = true }); try testing.expect(p.fs.panes[0].limit == null); _ = th.wr(p, addr, "#0"); try testing.expectEqual(Status.ok, th.wr(p, addr, "/three/").reply.status); - for ([_][]const u8{ "zzz", "#", "//", "/nomatch/", "1 2", "99", "/a\\" }) |bad| { + for ([_][]const u8{ "zzz", "#", "//", "/nomatch/", "1 2 3", "99", "/a\\" }) |bad| { _ = th.wr(p, addr, "#0"); try testing.expectEqual(E.INVAL, th.wr(p, addr, bad).errno()); } diff --git a/src/ninep/ctl.zig b/src/ninep/ctl.zig index d61ebf75..c213ece5 100644 --- a/src/ninep/ctl.zig +++ b/src/ninep/ctl.zig @@ -1,6 +1,9 @@ -//! The two ctl files. `look TEXT` is a right click and `exec TEXT` a middle -//! click in the editor's own command language; a pane's ctl adds the addr -//! verbs. Reading /ctl answers the serials the last command made or touched. +//! The command files and the status they answer. Writing a line to `look` is +//! a right click on it and writing one to `exec` a middle click, at the +//! active pane from the root and at that pane from /pane//; reading either +//! answers the serials the last command made or touched. /status reports the +//! editor, and a pane's ctl its acme status line and the one verb, `get`, +//! that no file of its own would say any better. const std = @import("std"); const pardes = @import("../pardes.zig"); const panes = @import("../panes.zig"); @@ -16,36 +19,6 @@ const Req = tree.Req; const Reply = tree.Reply; const E = tree.E; -const Verb = enum { - @"addr=dot", - clean, - cleartag, - dirty, - @"dot=addr", - get, - @"limit=addr", - mark, - nomark, - noscroll, - scroll, - show, -}; - -fn verbIs(line: []const u8, word: []const u8) bool { - if (!std.mem.startsWith(u8, line, word)) return false; - return line.len == word.len or line[word.len] == ' ' or line[word.len] == '\t'; -} - -/// The text after `look` or `exec`, or null when the line is not that verb. -/// Control characters other than tab are refused. -fn textAfter(line: []const u8, verb: []const u8) ?[]const u8 { - if (!verbIs(line, verb)) return null; - const text = std.mem.trim(u8, line[verb.len..], " \t"); - if (text.len == 0) return ""; - for (text) |c| if (c < ' ' and c != '\t') return ""; - return text; -} - // ---- which panes a command made or touched ---- const Serials = struct { @@ -96,37 +69,49 @@ fn run(p: *Pardes, id: usize, exec: bool, text: []const u8) void { noteResult(p, if (exec) context else activeSerial(p) orelse return); } -fn beginResults(p: *Pardes) void { - p.fs.results_len = 0; - p.fs.results_valid = true; -} - -// ---- /ctl ---- +// ---- look and exec ---- -pub fn writeRoot(p: *Pardes, req: Req) Reply { +/// One command per line, checked whole before any line runs: a line is the +/// clicked text itself, so it may not be empty or carry control characters. +/// A null `serial` clicks at whichever pane is active as each line runs, +/// which is what the root's own look and exec mean; a serial stays put. +pub fn command(p: *Pardes, req: Req, serial: ?u32, exec: bool) Reply { for ([2]bool{ false, true }) |apply| { - if (apply) beginResults(p); + if (apply) p.fs.results_len = 0; var it = std.mem.splitScalar(u8, req.data, '\n'); while (it.next()) |raw| { - const line = std.mem.trim(u8, raw, " \t\r"); - if (line.len == 0) continue; - const exec = verbIs(line, "exec"); - const text = textAfter(line, if (exec) "exec" else "look") orelse return Reply.fail(req.tag, E.INVAL); - if (text.len == 0) return Reply.fail(req.tag, E.INVAL); + const text = std.mem.trim(u8, raw, " \t\r"); + if (text.len == 0) continue; + for (text) |c| if (c < ' ' and c != '\t') return Reply.fail(req.tag, E.INVAL); if (!apply) continue; - if (p.panes[p.active] == null) return Reply.fail(req.tag, E.NOENT); - run(p, p.active, exec, text); + const id = if (serial) |s| p.paneBySerial(s) orelse break else p.active; + if (p.panes[id] == null) return Reply.fail(req.tag, E.NOENT); + run(p, id, exec, text); } } return .{ .tag = req.tag, .written = @intCast(req.data.len) }; } -pub fn rootText(p: *Pardes, buf: []u8) []const u8 { - var w = std.Io.Writer.fixed(buf); - if (p.fs.results_valid) { - for (p.fs.results[0..p.fs.results_len]) |serial| w.print("{d}\n", .{serial}) catch break; - return w.buffered(); +pub fn resultsLen(p: *Pardes) u64 { + var n: u64 = 0; + for (p.fs.results[0..p.fs.results_len]) |serial| { + var digits: [16]u8 = undefined; + n += (std.fmt.bufPrint(&digits, "{d}\n", .{serial}) catch unreachable).len; } + return n; +} + +pub fn readResults(p: *Pardes, req: Req) Reply { + const out = p.fs.stage(p.gpa); + for (p.fs.results[0..p.fs.results_len]) |serial| + out.print(p.gpa, "{d}\n", .{serial}) catch return Reply.fail(req.tag, E.NOMEM); + return tree.stagedReply(p, req); +} + +// ---- /status ---- + +fn statusText(p: *Pardes, buf: []u8) []const u8 { + var w = std.Io.Writer.fixed(buf); var count: usize = 0; for (p.panes) |slot| count += @intFromBool(slot != null); const pid: u32 = if (comptime pardes.hosted) @intCast(std.c.getpid()) else 0; @@ -134,13 +119,17 @@ pub fn rootText(p: *Pardes, buf: []u8) []const u8 { return w.buffered(); } -pub const root_text_cap = @max(MAX_PANES * 11, 64 + pardes.version.len); +pub const status_text_cap = 64 + pardes.version.len; + +pub fn statusLen(p: *Pardes) u64 { + var buf: [status_text_cap]u8 = undefined; + return statusText(p, &buf).len; +} -pub fn readRoot(p: *Pardes, req: Req) Reply { - var buf: [root_text_cap]u8 = undefined; - const text = rootText(p, &buf); +pub fn readStatus(p: *Pardes, req: Req) Reply { + var buf: [status_text_cap]u8 = undefined; const out = p.fs.stage(p.gpa); - out.appendSlice(p.gpa, text) catch return Reply.fail(req.tag, E.NOMEM); + out.appendSlice(p.gpa, statusText(p, &buf)) catch return Reply.fail(req.tag, E.NOMEM); return tree.stagedReply(p, req); } @@ -190,74 +179,35 @@ pub fn readPane(p: *Pardes, req: Req, pane: *Pane) Reply { return tree.stagedReply(p, req); } -pub fn writePane(p: *Pardes, req: Req, serial: u32) Reply { - for ([2]bool{ false, true }) |apply| { - if (apply) beginResults(p); - var it = std.mem.splitScalar(u8, req.data, '\n'); - while (it.next()) |raw| { - const line = std.mem.trim(u8, raw, " \t\r"); - if (line.len == 0) continue; - const live = p.paneBySerial(serial) orelse if (apply) break else return Reply.fail(req.tag, E.NOENT); - const errno = paneVerb(p, live, line, apply); - if (errno != 0) return Reply.fail(req.tag, errno); - } +/// `get` is the one thing here that no file of the pane's own would say: it +/// reloads the buffer from the name it carries, wherever that name resolves. +/// Repeating it in one write would only reload the same bytes, so it runs once. +pub fn writePane(p: *Pardes, req: Req, pane: *Pane) Reply { + var asked = false; + var it = std.mem.splitScalar(u8, req.data, '\n'); + while (it.next()) |raw| { + const line = std.mem.trim(u8, raw, " \t\r"); + if (line.len == 0) continue; + if (!std.mem.eql(u8, line, "get")) return Reply.fail(req.tag, E.INVAL); + asked = true; + } + if (asked) { + const errno = get(p, pane); + if (errno != 0) return Reply.fail(req.tag, errno); } return .{ .tag = req.tag, .written = @intCast(req.data.len) }; } -fn paneVerb(p: *Pardes, id: usize, line: []const u8, apply: bool) u16 { - const pane = p.panes[id] orelse return E.INVAL; - const pf = &p.fs.panes[id]; - - for ([_]bool{ false, true }) |exec| if (textAfter(line, if (exec) "exec" else "look")) |text| { - if (text.len == 0) return E.INVAL; - if (apply) run(p, id, exec, text); - return 0; +fn get(p: *Pardes, pane: *Pane) u16 { + const f = pane_files.fileOf(pane) orelse return 0; + if (!panes.Output.fileTraits(f.output).saves) return 0; + const bytes = fs.read(p, f.path) catch |err| return switch (err) { + error.FileNotFound => E.NOENT, + else => E.IO, }; - const v = std.meta.stringToEnum(Verb, line) orelse return E.INVAL; - if (!apply) return 0; - - switch (v) { - .@"addr=dot" => pf.addr = pane_files.dotOf(pane), - .@"dot=addr" => { - pane_files.clampAddr(pf, pane_files.bodyOf(pane).len); - pane_files.setDot(pane, pf.addr); - }, - .@"limit=addr" => { - pane_files.clampAddr(pf, pane_files.bodyOf(pane).len); - pf.limit = pf.addr; - }, - .clean => if (pane_files.fileOf(pane)) |f| { - f.saved_revision = f.revision; - }, - .dirty => if (pane_files.fileOf(pane)) |f| { - f.saved_revision = f.revision -% 1; - }, - .cleartag => { - pane.tag_tail_len = 0; - pane.tag_init = true; - }, - .get => if (pane_files.fileOf(pane)) |f| { - if (panes.Output.fileTraits(f.output).saves) { - if (fs.read(p, f.path)) |bytes| { - panes.File.pushUndo(p, pane); - panes.File.setContent(p, f, bytes); - f.saved_revision = f.revision; - } else |err| return switch (err) { - error.FileNotFound => E.NOENT, - else => E.IO, - }; - } - }, - .mark => { - pf.nomark = false; - panes.File.pushUndo(p, pane); - }, - .nomark => pf.nomark = true, - .noscroll => pf.noscroll = true, - .scroll => pf.noscroll = false, - .show => pane_files.showOffset(pane, pane_files.dotOf(pane).q0), - } + panes.File.pushUndo(p, pane); + panes.File.setContent(p, f, bytes); + f.saved_revision = f.revision; return 0; } @@ -272,7 +222,9 @@ const withFile = th.withFile; const serialOf = th.serialOf; const Node = tree.Node; const Status = tree.Status; -const root_ctl = @intFromEnum(tree.TopFile.ctl); +const root_status = @intFromEnum(tree.TopFile.status); +const root_look = @intFromEnum(tree.TopFile.look); +const root_exec = @intFromEnum(tree.TopFile.exec); test "pane ctl read is index's five fields plus width in cells, font and tab width" { const gpa = testing.allocator; @@ -299,37 +251,18 @@ test "pane ctl read is index's five fields plus width in cells, font and tab wid try testing.expectEqualStrings("'it''s'", w.buffered()); } -test "every pane ctl verb, and every refusal" { +test "the pane ctl takes get, and nothing that a file of its own now answers" { const gpa = testing.allocator; const p = try withFile(gpa, "one\ntwo\n"); defer p.deinit(); - const serial = serialOf(p); - const ctl_node = Node.of(serial, .ctl); - const pane = p.panes[0].?; - const pf = &p.fs.panes[0]; - - try testing.expectEqual(Status.ok, wr(p, ctl_node, "nomark\nnoscroll\ndirty\n").reply.status); - try testing.expect(pf.nomark and pf.noscroll and pane_files.dirtyOf(pane)); - try testing.expectEqual(Status.ok, wr(p, ctl_node, "mark\nscroll\nclean\n").reply.status); - try testing.expect(!pf.nomark and !pf.noscroll and !pane_files.dirtyOf(pane)); - - _ = wr(p, ctl_node, "cleartag\n"); - try testing.expectEqual(@as(usize, 0), pane.tag_tail_len); - - _ = wr(p, Node.of(serial, .addr), "2"); - _ = wr(p, ctl_node, "limit=addr\n"); - try testing.expectEqual(@as(u32, 4), pf.limit.?.q0); - _ = wr(p, ctl_node, "dot=addr\nshow\n"); - try testing.expectEqual(@as(i32, 1), pane.cur_row); - + const ctl_node = Node.of(serialOf(p), .ctl); for ([_][]const u8{ - "menu", "nomenu", "dump echo hi", "dumpdir /tmp", "font Go Mono", "lock", "unlock", "bogus", "DEL", - "name x.txt", "put", "del", "delete", "Look x", "Exec Save", + "menu", "nomenu", "dump echo hi", "font Go Mono", "lock", "bogus", "DEL", + "name x.txt", "put", "del", "delete", "Look x", "Exec Save", "clean", + "dirty", "cleartag", "dot=addr", "addr=dot", "show", "mark", "nomark", + "scroll", "limit=addr", "get x", "look /tmp", "exec Del", }) |bad| try testing.expectEqual(E.INVAL, wr(p, ctl_node, bad).errno()); - - try testing.expect(!pane_files.dirtyOf(pane)); - try testing.expectEqual(E.INVAL, wr(p, ctl_node, "dirty\nbogus\n").errno()); - try testing.expect(!pane_files.dirtyOf(pane)); + try testing.expect(p.paneBySerial(serialOf(p)) != null); } test "exec runs a builtin at the pane and records the pane it acted on" { @@ -338,61 +271,69 @@ test "exec runs a builtin at the pane and records the pane it acted on" { defer p.deinit(); const serial = serialOf(p); const pane = p.panes[0].?; - try testing.expectEqual(Status.ok, wr(p, Node.of(serial, .ctl), "exec Msg from ctl\n").reply.status); - try testing.expectEqualStrings("from ctl", pane.msg[0..pane.msg_len]); + try testing.expectEqual(Status.ok, wr(p, Node.of(serial, .exec), "Msg from exec\n").reply.status); + try testing.expectEqualStrings("from exec", pane.msg[0..pane.msg_len]); var expected: [16]u8 = undefined; - try testing.expectEqualStrings(try std.fmt.bufPrint(&expected, "{d}\n", .{serial}), rd(p, root_ctl, 0, 4096).bytes); + const own = try std.fmt.bufPrint(&expected, "{d}\n", .{serial}); + try testing.expectEqualStrings(own, rd(p, root_exec, 0, 4096).bytes); + // Either command file reads back what the last one did. + try testing.expectEqualStrings(own, rd(p, Node.of(serial, .look), 0, 4096).bytes); + try testing.expectEqual(@as(u64, own.len), call(p, .{ .tag = 1, .op = .getattr, .node = root_exec }).reply.attr.size); - try testing.expectEqual(Status.ok, wr(p, Node.of(serial, .ctl), "exec New\n").reply.status); + try testing.expectEqual(Status.ok, wr(p, Node.of(serial, .exec), "New\n").reply.status); const made = p.panes[p.active].?; try testing.expect(made.serial != serial); - try testing.expectEqualStrings(try std.fmt.bufPrint(&expected, "{d}\n", .{made.serial}), rd(p, root_ctl, 0, 4096).bytes); + try testing.expectEqualStrings(try std.fmt.bufPrint(&expected, "{d}\n", .{made.serial}), rd(p, root_exec, 0, 4096).bytes); - try testing.expectEqual(Status.ok, wr(p, Node.of(made.serial, .ctl), "exec Del\n").reply.status); + try testing.expectEqual(Status.ok, wr(p, Node.of(made.serial, .exec), "Del\n").reply.status); try testing.expect(p.paneBySerial(made.serial) == null); - try testing.expectEqualStrings(try std.fmt.bufPrint(&expected, "{d}\n", .{made.serial}), rd(p, root_ctl, 0, 4096).bytes); + try testing.expectEqualStrings(try std.fmt.bufPrint(&expected, "{d}\n", .{made.serial}), rd(p, root_exec, 0, 4096).bytes); } -test "the root ctl reads editor status until a command runs and validates whole batches" { +test "status reads the editor, and look and exec validate whole batches" { const gpa = testing.allocator; const p = try withFile(gpa, "Msg root\n"); defer p.deinit(); - const status = rd(p, root_ctl, 0, 4096); + const status = rd(p, root_status, 0, 4096); try testing.expectEqual(Status.ok, status.reply.status); var lines = std.mem.tokenizeScalar(u8, status.bytes, '\n'); try testing.expect(std.mem.startsWith(u8, lines.next().?, "pid ")); var expected: [64]u8 = undefined; try testing.expectEqualStrings(try std.fmt.bufPrint(&expected, "version {s}", .{pardes.version}), lines.next().?); - try testing.expectEqualStrings("panes 1", lines.next().?); + var live: usize = 0; + for (p.panes) |slot| live += @intFromBool(slot != null); + try testing.expectEqualStrings(try std.fmt.bufPrint(&expected, "panes {d}", .{live}), lines.next().?); try testing.expect(lines.next() == null); - const stat = call(p, .{ .tag = 1, .op = .getattr, .node = root_ctl }); + const stat = call(p, .{ .tag = 1, .op = .getattr, .node = root_status }); try testing.expectEqual(@as(u64, status.bytes.len), stat.reply.attr.size); - try testing.expectEqual(@as(u16, 0o666), stat.reply.attr.mode); + try testing.expectEqual(@as(u16, 0o444), stat.reply.attr.mode); + try testing.expectEqual(E.PERM, wr(p, root_status, "anything\n").errno()); + try testing.expectEqualStrings("", rd(p, root_exec, 0, 4096).bytes); const serial = p.next_serial; - for ([_][]const u8{ "look", "exec", "look \t", "Look /virtual/index", "exec Msg a\x00b", "exec Msg x\nbogus\n", "name x", "put" }) |invalid| { - try testing.expectEqual(E.INVAL, wr(p, root_ctl, invalid).errno()); + for ([_][]const u8{ "Msg a\x00b", "Msg x\nMsg \x01y\n" }) |invalid| { + try testing.expectEqual(E.INVAL, wr(p, root_exec, invalid).errno()); try testing.expectEqual(serial, p.next_serial); } - try testing.expectEqualStrings(status.bytes, rd(p, root_ctl, 0, 4096).bytes); + // An empty write is a no-op, not a command. + try testing.expectEqual(Status.ok, wr(p, root_exec, "\n \n").reply.status); + try testing.expectEqualStrings("", rd(p, root_exec, 0, 4096).bytes); + try testing.expectEqualStrings(status.bytes, rd(p, root_status, 0, 4096).bytes); const pane = p.panes[0].?; - try testing.expectEqual(Status.ok, wr(p, root_ctl, "exec Msg hello there\n").reply.status); + try testing.expectEqual(Status.ok, wr(p, root_exec, "Msg hello there\n").reply.status); try testing.expectEqualStrings("hello there", pane.msg[0..pane.msg_len]); - try testing.expectEqualStrings(try std.fmt.bufPrint(&expected, "{d}\n", .{pane.serial}), rd(p, root_ctl, 0, 4096).bytes); - - try testing.expectEqual(Status.ok, wr(p, root_ctl, "look /virtual/index\nexec New\n").reply.status); - var made: [MAX_PANES]u32 = undefined; - var n: usize = 0; - for (p.panes) |slot| if (slot) |q| if (q.serial != pane.serial) { - made[n] = q.serial; - n += 1; - }; - try testing.expectEqual(@as(usize, 2), n); - const listed = rd(p, root_ctl, 0, 4096); - try testing.expectEqualStrings(try std.fmt.bufPrint(&expected, "{d}\n{d}\n", .{ @min(made[0], made[1]), @max(made[0], made[1]) }), listed.bytes); - const opened = p.panes[p.paneBySerial(@min(made[0], made[1])).?].?; + try testing.expectEqualStrings(try std.fmt.bufPrint(&expected, "{d}\n", .{pane.serial}), rd(p, root_exec, 0, 4096).bytes); + + try testing.expectEqual(Status.ok, wr(p, root_look, "/virtual/index\n").reply.status); + const opened = p.panes[p.active].?; try testing.expectEqualStrings("/virtual/index", opened.file.?.path); + try testing.expectEqualStrings(try std.fmt.bufPrint(&expected, "{d}\n", .{opened.serial}), rd(p, root_look, 0, 4096).bytes); + + try testing.expectEqual(Status.ok, wr(p, root_exec, "New\n").reply.status); + const made = p.panes[p.active].?; + try testing.expect(made.serial != opened.serial); + try testing.expectEqualStrings(try std.fmt.bufPrint(&expected, "{d}\n", .{made.serial}), rd(p, root_exec, 0, 4096).bytes); } test "look opens spaced paths and locations without editing the source pane" { @@ -406,12 +347,12 @@ test "look opens spaced paths and locations without editing the source pane" { const p = try withFile(gpa, "source stays intact\n"); defer p.deinit(); const source = p.panes[0].?; - const ctl_node = Node.of(source.serial, .ctl); + const look_node = Node.of(source.serial, .look); const revision = source.file.?.revision; const undo_len = source.file.?.history.undo_len; source.cur_col = 3; - var command: [4200]u8 = undefined; - try testing.expectEqual(Status.ok, wr(p, ctl_node, try std.fmt.bufPrint(&command, "look {s}:2:3\n", .{path})).reply.status); + var clicked: [4200]u8 = undefined; + try testing.expectEqual(Status.ok, wr(p, look_node, try std.fmt.bufPrint(&clicked, "{s}:2:3\n", .{path})).reply.status); const opened = p.panes[p.active].?; try testing.expect(opened != source); try testing.expectEqualStrings(path, opened.file.?.path); @@ -423,14 +364,14 @@ test "look opens spaced paths and locations without editing the source pane" { try testing.expectEqual(undo_len, source.file.?.history.undo_len); try testing.expectEqual(@as(i32, 3), source.cur_col); var expected: [16]u8 = undefined; - try testing.expectEqualStrings(try std.fmt.bufPrint(&expected, "{d}\n", .{opened.serial}), rd(p, root_ctl, 0, 4096).bytes); + try testing.expectEqualStrings(try std.fmt.bufPrint(&expected, "{d}\n", .{opened.serial}), rd(p, root_look, 0, 4096).bytes); p.active = 0; - try testing.expectEqual(Status.ok, wr(p, root_ctl, try std.fmt.bufPrint(&command, "look {s}:3:2\n", .{path})).reply.status); + try testing.expectEqual(Status.ok, wr(p, root_look, try std.fmt.bufPrint(&clicked, "{s}:3:2\n", .{path})).reply.status); try testing.expect(p.panes[p.active].? == opened); try testing.expectEqual(@as(i32, 2), opened.cur_row); try testing.expectEqual(@as(i32, 1), opened.cur_col); - try testing.expectEqualStrings(try std.fmt.bufPrint(&expected, "{d}\n", .{opened.serial}), rd(p, root_ctl, 0, 4096).bytes); + try testing.expectEqualStrings(try std.fmt.bufPrint(&expected, "{d}\n", .{opened.serial}), rd(p, root_look, 0, 4096).bytes); } test "look validates the whole batch before opening virtual files" { @@ -438,17 +379,17 @@ test "look validates the whole batch before opening virtual files" { const p = try withFile(gpa, "source\n"); defer p.deinit(); const source = p.panes[0].?; - const ctl_node = Node.of(source.serial, .ctl); + const look_node = Node.of(source.serial, .look); const serial = p.next_serial; for ([_][]const u8{ - "look", "look \t", "look /virtual/index\x00ignored", "look /virtual/index\nbogus\n", + "/virtual/index\x00ignored", "/virtual/index\n/virtual/\x01index\n", }) |invalid| { - try testing.expectEqual(E.INVAL, wr(p, ctl_node, invalid).errno()); + try testing.expectEqual(E.INVAL, wr(p, look_node, invalid).errno()); try testing.expectEqual(serial, p.next_serial); try testing.expectEqual(@as(usize, 0), p.active); try testing.expectEqualStrings("source\n", source.file.?.content); } - try testing.expectEqual(Status.ok, wr(p, ctl_node, "look /n/self/index\n").reply.status); + try testing.expectEqual(Status.ok, wr(p, look_node, "/n/self/index\n").reply.status); const opened = p.panes[p.active].?; try testing.expectEqualStrings("/virtual/index", opened.file.?.path); try testing.expect(std.mem.indexOf(u8, opened.file.?.content, "/test.txt") != null); @@ -480,7 +421,7 @@ test "get reloads the pane from disk and reports a missing file without losing d _ = wr(p, Node.of(serial, .name), try std.fmt.bufPrint(&name, "{s}/missing.txt\n", .{directory})); _ = wr(p, Node.of(serial, .body), "unsaved\n"); - try testing.expectEqual(E.NOENT, wr(p, ctl_node, "get\nexec Del\n").errno()); + try testing.expectEqual(E.NOENT, wr(p, ctl_node, "get\n").errno()); try testing.expect(p.paneBySerial(serial) != null); try testing.expectEqualStrings("from disk\nunsaved\n", pane.file.?.content); try testing.expect(pane_files.dirtyOf(pane)); @@ -494,7 +435,7 @@ test "exec Save writes the named file through the host" { const pane = p.panes[0].?; try testing.expectEqual(Status.ok, wr(p, Node.of(serial, .name), "/tmp/renamed.txt\n").reply.status); try testing.expect(pane_files.dirtyOf(pane)); - const saved = wr(p, Node.of(serial, .ctl), "exec Save\n"); + const saved = wr(p, Node.of(serial, .exec), "Save\n"); try testing.expectEqual(Status.ok, saved.reply.status); try testing.expect(saved.saved); p.perform(.{ .save_file = .{ .pane = 0 } }); diff --git a/src/ninep/events.zig b/src/ninep/events.zig index fb49e41b..bd53bcd9 100644 --- a/src/ninep/events.zig +++ b/src/ninep/events.zig @@ -89,6 +89,13 @@ pub const Queue = struct { } }; +/// What the next read would answer, which is the size a stat reports: a +/// client can see there is something waiting without parking on it. +pub fn pending(q: *const Queue) u64 { + const record = q.peek() orelse return 0; + return record.len; +} + /// One record per read; `.again` parks the read until a record arrives. pub fn readQueue(p: *Pardes, req: Req, q: *Queue) Reply { const record = q.peek() orelse return .{ .tag = req.tag, .status = .again }; @@ -461,7 +468,7 @@ test "a pane deleted while its event file is open leaves no suppression behind" const b = call(p, .{ .tag = 19, .op = .open, .node = event }); try testing.expectEqual(@as(u16, 2), p.fs.listeners); - _ = wr(p, Node.of(serial, .ctl), "exec Del\n"); + _ = wr(p, Node.of(serial, .exec), "Del\n"); try testing.expect(p.paneBySerial(serial) == null); try testing.expectEqual(@as(u16, 0), p.fs.listeners); @@ -471,7 +478,7 @@ test "a pane deleted while its event file is open leaves no suppression behind" try testing.expectEqual(E.NOENT, rd(p, event, 0, 64).errno()); try testing.expectEqual(E.NOENT, rd(p, Node.of(serial, .body), 0, 64).errno()); - try testing.expectEqual(E.NOENT, wr(p, Node.of(serial, .ctl), "clean\n").errno()); + try testing.expectEqual(E.NOENT, wr(p, Node.of(serial, .dirty), "0\n").errno()); try testing.expectEqual(E.NOENT, call(p, .{ .tag = 22, .op = .open, .node = event }).errno()); } @@ -535,7 +542,7 @@ test "the log parks until a pane is created, renamed, saved or deleted" { try std.fmt.bufPrint(&expected, "rename {d} /tmp/logged.txt\n", .{serial}), rd(p, log, 0, 4096).bytes, ); - const saving = wr(p, Node.of(serial, .ctl), "exec Save\n"); + const saving = wr(p, Node.of(serial, .exec), "Save\n"); try testing.expectEqual(Status.ok, saving.reply.status); try testing.expect(saving.saved); p.perform(.{ .save_file = .{ .pane = @intCast(id) } }); @@ -543,7 +550,7 @@ test "the log parks until a pane is created, renamed, saved or deleted" { try std.fmt.bufPrint(&expected, "save {d} /tmp/logged.txt\n", .{serial}), rd(p, log, 0, 4096).bytes, ); - try testing.expectEqual(Status.ok, wr(p, Node.of(serial, .ctl), "exec Del\n").reply.status); + try testing.expectEqual(Status.ok, wr(p, Node.of(serial, .exec), "Del\n").reply.status); try testing.expectEqualStrings( try std.fmt.bufPrint(&expected, "del {d} /tmp/logged.txt\n", .{serial}), rd(p, log, 0, 4096).bytes, diff --git a/src/ninep/pane.zig b/src/ninep/pane.zig index b37ae645..42c0c48e 100644 --- a/src/ninep/pane.zig +++ b/src/ninep/pane.zig @@ -1,5 +1,6 @@ -//! The files under /pane//: name, body, tag, ctl, addr, data, xdata, -//! sel, errors and event. Terminal panes add pty/ (pty.zig). +//! The files under /pane//: name, body, tag, ctl, the three range +//! files addr, dot and limit, data, xdata, sel, the three flag files dirty, +//! mark and scroll, errors, event, look and exec. Terminals add pty/ (pty.zig). const std = @import("std"); const pardes = @import("../pardes.zig"); const panes = @import("../panes.zig"); @@ -187,10 +188,15 @@ pub fn spliceBody(p: *Pardes, id: usize, pane: *Pane, q0: usize, q1: usize, byte return take; } -// ---- sizes reported by stat ---- +// ---- what stat reports ---- + +/// A range file's text: acme's addr format, two right-aligned offsets, so +/// that copying one range file onto another is the whole of `dot=addr`. +pub const range_len: u64 = 24; pub fn fileSize(p: *Pardes, id: usize, f: PaneFile) u64 { const pane = p.panes[id] orelse return 0; + const pf = &p.fs.panes[id]; return switch (f) { .body, .data, .xdata => bodyOf(pane).len, .tag => tagOf(p, pane).len, @@ -203,7 +209,24 @@ pub fn fileSize(p: *Pardes, id: usize, f: PaneFile) u64 { const d = dotOf(pane); break :sel @max(d.q0, d.q1) - d.q0; }, - .dir, .addr, .errors, .event, .pty, .pty_ctl, .pty_status, .pty_data => 0, + .addr, .dot => range_len, + .limit => if (pf.limit == null) 0 else range_len, + .dirty, .mark, .scroll => 2, + .look, .exec => ctl.resultsLen(p), + .event => events.pending(&pf.events), + .pty_status => pty.status_len, + .pty_data => events.pending(&pf.pty_out), + .dir, .errors, .pty, .pty_ctl => 0, + }; +} + +/// The qid version, which a client polls to watch a file for change. Only +/// the pane's text can promise one: its revision counts every edit, and +/// nothing else here changes in step with it. +pub fn versionOf(pane: *const Pane, f: PaneFile) u32 { + return switch (f) { + .body, .data, .xdata => if (pane.file) |*file| file.revision else 0, + else => 0, }; } @@ -246,13 +269,17 @@ pub fn read(p: *Pardes, req: Req, id: usize, pane: *Pane, file: PaneFile) Reply .ctl => ctl.readPane(p, req, pane), .addr => addr: { clampAddr(pf, bodyOf(pane).len); - const out = p.fs.stage(p.gpa); - out.print(p.gpa, "{d:>11} {d:>11} ", .{ pf.addr.q0, pf.addr.q1 }) catch {}; - break :addr tree.stagedReply(p, req); + break :addr readRange(p, req, pf.addr); }, + .dot => readRange(p, req, dotOf(pane)), + .limit => readRange(p, req, pf.limit), .data => readData(req, id, pane, pf, false), .xdata => readData(req, id, pane, pf, true), .sel => readSel(req, id, pane), + .dirty => readFlag(p, req, dirtyOf(pane)), + .mark => readFlag(p, req, !pf.nomark), + .scroll => readFlag(p, req, !pf.noscroll), + .look, .exec => ctl.readResults(p, req), .event => events.readQueue(p, req, &pf.events), .pty_status => pty.readStatus(p, req, id, pane), .pty_data => pty.readData(p, req, pf), @@ -260,6 +287,20 @@ pub fn read(p: *Pardes, req: Req, id: usize, pane: *Pane, file: PaneFile) Reply }; } +/// An unset limit reads empty, which is how a client tells it from one that +/// happens to bound nothing. +fn readRange(p: *Pardes, req: Req, r: ?State.Range) Reply { + const out = p.fs.stage(p.gpa); + if (r) |range| out.print(p.gpa, "{d:>11} {d:>11} ", .{ range.q0, range.q1 }) catch {}; + return tree.stagedReply(p, req); +} + +fn readFlag(p: *Pardes, req: Req, on: bool) Reply { + const out = p.fs.stage(p.gpa); + out.appendSlice(p.gpa, if (on) "1\n" else "0\n") catch {}; + return tree.stagedReply(p, req); +} + fn readBody(p: *Pardes, req: Req, id: usize, pane: *Pane) Reply { if (pane.file != null) { const text = bodyOf(pane); @@ -322,10 +363,12 @@ pub fn write(p: *Pardes, req: Req, id: usize, pane: *Pane, file: PaneFile) Reply .name => writeName(p, req, id, pane), .body => writeBody(p, req, id, pane), .tag => writeTag(p, req, pane), - .ctl => ctl.writePane(p, req, pane.serial), - .addr => writeAddr(p, req, id, pane), + .ctl => ctl.writePane(p, req, pane), + .addr, .dot, .limit => writeRange(p, req, id, pane, file), .data, .xdata => writeData(p, req, id, pane), .sel => writeSel(p, req, id, pane), + .dirty, .mark, .scroll => writeFlag(p, req, id, pane, file), + .look, .exec => ctl.command(p, req, pane.serial, file == .exec), .event => events.writeEvent(p, req, id), .errors => if (appendErrors(p, id, req.data)) |took| .{ .tag = req.tag, .written = @intCast(took) } @@ -389,15 +432,68 @@ fn writeSel(p: *Pardes, req: Req, id: usize, pane: *Pane) Reply { return .{ .tag = req.tag, .written = @intCast(take) }; } -fn writeAddr(p: *Pardes, req: Req, id: usize, pane: *Pane) Reply { +/// The pair of offsets a range file reads back, so that copying `addr` onto +/// `dot` or `limit` does what acme spelled `dot=addr` and `limit=addr`. +fn pairOf(text: []const u8) ?State.Range { + var it = std.mem.tokenizeAny(u8, text, " \t"); + const q0 = std.fmt.parseInt(u32, it.next() orelse return null, 10) catch return null; + const q1 = std.fmt.parseInt(u32, it.next() orelse return null, 10) catch return null; + if (it.next() != null) return null; + return .{ .q0 = q0, .q1 = @max(q0, q1) }; +} + +/// A range file takes an address expression, or that pair of offsets. +fn rangeOf(pf: *State, text: []const u8, data: []const u8) ?State.Range { + const expr = std.mem.trimEnd(u8, data, "\n"); + if (pairOf(expr)) |r| { + const n = clip(text.len); + return .{ .q0 = @min(r.q0, n), .q1 = @min(r.q1, n) }; + } + var a: addressing.Addr = .{ .text = text, .lim = pf.limit, .expr = expr }; + const r = a.address(pf.addr) orelse return null; + return if (a.i < expr.len) null else r; +} + +fn writeRange(p: *Pardes, req: Req, id: usize, pane: *Pane, file: PaneFile) Reply { const pf = &p.fs.panes[id]; const text = bodyOf(pane); clampAddr(pf, text.len); - const expr = std.mem.trimEnd(u8, req.data, "\n"); - var a: addressing.Addr = .{ .text = text, .lim = pf.limit, .expr = expr }; - const r = a.address(pf.addr) orelse return Reply.fail(req.tag, E.INVAL); - if (a.i < expr.len) return Reply.fail(req.tag, E.INVAL); - pf.addr = r; + const r = rangeOf(pf, text, req.data) orelse return Reply.fail(req.tag, E.INVAL); + switch (file) { + .addr => pf.addr = r, + .limit => pf.limit = r, + // Setting dot scrolls to it, which is the whole of acme's `show`. + .dot => { + if (fileOf(pane) == null) return Reply.fail(req.tag, E.INVAL); + setDot(pane, r); + }, + else => unreachable, + } + return .{ .tag = req.tag, .written = @intCast(req.data.len) }; +} + +fn flagOf(data: []const u8) ?bool { + const word = std.mem.trim(u8, data, " \t\r\n"); + if (std.mem.eql(u8, word, "1")) return true; + if (std.mem.eql(u8, word, "0")) return false; + return null; +} + +fn writeFlag(p: *Pardes, req: Req, id: usize, pane: *Pane, file: PaneFile) Reply { + const on = flagOf(req.data) orelse return Reply.fail(req.tag, E.INVAL); + const pf = &p.fs.panes[id]; + switch (file) { + .dirty => { + const f = fileOf(pane) orelse return Reply.fail(req.tag, E.INVAL); + f.saved_revision = if (on) f.revision -% 1 else f.revision; + }, + .mark => { + pf.nomark = !on; + if (on) panes.File.pushUndo(p, pane); + }, + .scroll => pf.noscroll = !on, + else => unreachable, + } return .{ .tag = req.tag, .written = @intCast(req.data.len) }; } @@ -475,14 +571,24 @@ pub fn appendErrors(p: *Pardes, id: usize, text: []const u8) ?usize { return text.len; } -/// Truncation empties a body; every other setattr just answers fresh attributes. +/// Truncation empties whatever the file holds: the body, the tag's editable +/// tail (acme's `cleartag`), a range. Every other setattr just answers fresh +/// attributes. pub fn truncate(p: *Pardes, id: usize, pane: *Pane, file: PaneFile) tree.Status { + const pf = &p.fs.panes[id]; switch (file) { .body, .data, .xdata => if (fileOf(pane) != null) { _ = spliceBody(p, id, pane, 0, bodyOf(pane).len, "") orelse return .err; - p.fs.panes[id].addr = .{}; + pf.addr = .{}; setDot(pane, .{}); }, + .tag => { + pane.tag_tail_len = 0; + pane.tag_init = true; + }, + .addr => pf.addr = .{}, + .limit => pf.limit = null, + .dot => if (fileOf(pane) != null) setDot(pane, .{}), else => {}, } return .ok; @@ -509,15 +615,19 @@ test "index lists serial kind dirty flag and name and stat reports its length" { const a = rd(p, index, 0, 4096); try testing.expectEqual(Status.ok, a.reply.status); var want: [64]u8 = undefined; - try testing.expectEqualStrings(try std.fmt.bufPrint(&want, "{d} text 0 /test.txt\n", .{pane.serial}), a.bytes); + const clean_row = try std.fmt.bufPrint(&want, "{d} text 0 /test.txt\n", .{pane.serial}); + try testing.expect(std.mem.indexOf(u8, a.bytes, clean_row) != null); + const at = std.mem.indexOf(u8, a.bytes, clean_row).?; const stat = call(p, .{ .tag = 1, .op = .getattr, .node = index }); try testing.expectEqual(@as(u64, a.bytes.len), stat.reply.attr.size); try testing.expectEqual(@as(u16, 0o444), stat.reply.attr.mode); pane.file.?.saved_revision = pane.file.?.revision -% 1; - try testing.expectEqualStrings(try std.fmt.bufPrint(&want, "{d} text 1 /test.txt\n", .{pane.serial}), rd(p, index, 0, 4096).bytes); - const mid = rd(p, index, 2, 4); - try testing.expectEqualStrings("text", mid.bytes); + var dirty_want: [64]u8 = undefined; + const dirty_row = try std.fmt.bufPrint(&dirty_want, "{d} text 1 /test.txt\n", .{pane.serial}); + try testing.expect(std.mem.indexOf(u8, rd(p, index, 0, 4096).bytes, dirty_row) != null); + const kind = at + std.mem.indexOfScalar(u8, clean_row, ' ').? + 1; + try testing.expectEqualStrings("text", rd(p, index, kind, 4).bytes); const serial = try th.newPane(p); const both = rd(p, index, 0, 4096); @@ -533,10 +643,11 @@ test "a terminal is listed as term with its directory as name" { const pane = p.panes[0].?; p.setCwd(0, "/work/dir"); var want: [64]u8 = undefined; - try testing.expectEqualStrings( - try std.fmt.bufPrint(&want, "{d} term 0 /work/dir\n", .{pane.serial}), + try testing.expect(std.mem.indexOf( + u8, rd(p, @intFromEnum(tree.TopFile.index), 0, 4096).bytes, - ); + try std.fmt.bufPrint(&want, "{d} term 0 /work/dir\n", .{pane.serial}), + ) != null); try testing.expectEqualStrings("/work/dir\n", rd(p, Node.of(pane.serial, .name), 0, 4096).bytes); try testing.expectEqual(E.PERM, wr(p, Node.of(pane.serial, .name), "/elsewhere\n").errno()); } @@ -566,6 +677,13 @@ test "body reads at any offset and writes append" { try testing.expectEqual(@as(u64, "one\ntwo\nthree\na".len), stat.reply.attr.size); try testing.expectEqual(@as(u16, 0o666), stat.reply.attr.mode); try testing.expect(stat.reply.attr.mtime >= p.fs.started); + + // The qid version is the pane's revision, so a stat sees an edit land. + try testing.expectEqual(p.panes[0].?.file.?.revision, stat.reply.attr.version); + _ = wr(p, body, "more\n"); + const later = call(p, .{ .tag = 7, .op = .getattr, .node = body }); + try testing.expect(later.reply.attr.version != stat.reply.attr.version); + try testing.expectEqual(@as(u32, 0), call(p, .{ .tag = 8, .op = .getattr, .node = Node.of(serial, .tag) }).reply.attr.version); } test "a body write to a terminal pane types at its shell" { @@ -653,18 +771,29 @@ test "sel reads the selection and writing sel replaces it" { const p = try withFile(gpa, "one\ntwo\n"); defer p.deinit(); const serial = serialOf(p); - const ctl_node = Node.of(serial, .ctl); + const addr_node = Node.of(serial, .addr); + const dot = Node.of(serial, .dot); const sel = Node.of(serial, .sel); - _ = wr(p, Node.of(serial, .addr), "#0,#3"); - try testing.expectEqual(Status.ok, wr(p, ctl_node, "dot=addr\n").reply.status); + // Copying addr onto dot is the whole of acme's `dot=addr`, and back again + // of `addr=dot`; each range file reads exactly what the other takes. + _ = wr(p, addr_node, "#0,#3"); + try testing.expectEqual(Status.ok, wr(p, dot, " 0 3 ").reply.status); + try testing.expectEqualStrings(" 0 3 ", rd(p, dot, 0, 100).bytes); + try testing.expectEqual(range_len, call(p, .{ .tag = 1, .op = .getattr, .node = dot }).reply.attr.size); try testing.expectEqualStrings("one", rd(p, sel, 0, 100).bytes); try testing.expectEqual(@as(u64, 3), call(p, .{ .tag = 1, .op = .getattr, .node = sel }).reply.attr.size); - _ = wr(p, ctl_node, "addr=dot\n"); + _ = wr(p, addr_node, "#0"); + _ = wr(p, addr_node, " 0 3 "); try testing.expectEqual(@as(u32, 0), p.fs.panes[0].addr.q0); try testing.expectEqual(@as(u32, 3), p.fs.panes[0].addr.q1); + // A truncation empties dot; an address expression addresses it. + _ = call(p, .{ .tag = 9, .op = .setattr, .node = dot, .truncate = true }); + try testing.expectEqualStrings("", rd(p, sel, 0, 100).bytes); + try testing.expectEqual(Status.ok, wr(p, dot, "#0,#3").reply.status); + try testing.expectEqual(Status.ok, wr(p, sel, "ONE").reply.status); try testing.expectEqualStrings("ONE\ntwo\n", p.panes[0].?.file.?.content); _ = wr(p, sel, "!"); @@ -672,6 +801,62 @@ test "sel reads the selection and writing sel replaces it" { try testing.expectEqual(@as(u64, 0), call(p, .{ .tag = 2, .op = .getattr, .node = sel }).reply.attr.size); } +test "the flag files read and write the state acme kept behind ctl verbs" { + const gpa = testing.allocator; + const p = try withFile(gpa, "one\ntwo\n"); + defer p.deinit(); + const serial = serialOf(p); + const pane = p.panes[0].?; + const pf = &p.fs.panes[0]; + const dirty = Node.of(serial, .dirty); + const mark = Node.of(serial, .mark); + const scroll = Node.of(serial, .scroll); + + for ([_]u64{ dirty, mark, scroll }) |node| { + try testing.expectEqual(@as(u64, 2), call(p, .{ .tag = 1, .op = .getattr, .node = node }).reply.attr.size); + for ([_][]const u8{ "", "yes", "2", "0 1", "true" }) |bad| + try testing.expectEqual(E.INVAL, wr(p, node, bad).errno()); + } + + try testing.expectEqualStrings("0\n", rd(p, dirty, 0, 8).bytes); + try testing.expectEqualStrings("1\n", rd(p, mark, 0, 8).bytes); + try testing.expectEqualStrings("1\n", rd(p, scroll, 0, 8).bytes); + + try testing.expectEqual(Status.ok, wr(p, dirty, "1\n").reply.status); + try testing.expect(dirtyOf(pane)); + try testing.expectEqualStrings("1\n", rd(p, dirty, 0, 8).bytes); + _ = wr(p, dirty, "0"); + try testing.expect(!dirtyOf(pane)); + + _ = wr(p, mark, "0"); + _ = wr(p, scroll, "0"); + try testing.expect(pf.nomark and pf.noscroll); + try testing.expectEqualStrings("0\n", rd(p, mark, 0, 8).bytes); + try testing.expectEqualStrings("0\n", rd(p, scroll, 0, 8).bytes); + _ = wr(p, mark, "1"); + _ = wr(p, scroll, "1"); + try testing.expect(!pf.nomark and !pf.noscroll); + + // A terminal has no file, so its dirty flag is readable but not writable. + const term = try th.withTerm(gpa); + defer term.deinit(); + try testing.expectEqualStrings("0\n", rd(term, Node.of(serialOf(term), .dirty), 0, 8).bytes); + try testing.expectEqual(E.INVAL, wr(term, Node.of(serialOf(term), .dirty), "1").errno()); +} + +test "truncating the tag clears its editable tail" { + const p = try withFile(testing.allocator, "x\n"); + defer p.deinit(); + const pane = p.panes[0].?; + const tag = Node.of(pane.serial, .tag); + _ = wr(p, tag, " Mine"); + try testing.expect(pane.tag_tail_len > 0); + const cleared = call(p, .{ .tag = 1, .op = .setattr, .node = tag, .truncate = true }); + try testing.expectEqual(Status.ok, cleared.reply.status); + try testing.expectEqual(@as(usize, 0), pane.tag_tail_len); + try testing.expect(std.mem.indexOf(u8, rd(p, tag, 0, 4096).bytes, " Mine") == null); +} + test "name reads the file name and writing it promotes a scratch without touching its body" { const gpa = testing.allocator; const p = try withFile(gpa, "opener\n"); diff --git a/src/ninep/pty.zig b/src/ninep/pty.zig index e6696b85..1b71a8d3 100644 --- a/src/ninep/pty.zig +++ b/src/ninep/pty.zig @@ -76,6 +76,9 @@ fn verb(p: *Pardes, id: usize, line: []const u8, apply: bool) bool { return true; } +/// Three right-aligned fields: cols, rows and whether the host holds the tty. +pub const status_len: u64 = 36; + pub fn readStatus(p: *Pardes, req: Req, id: usize, pane: *Pane) Reply { const out = p.fs.stage(p.gpa); out.print(p.gpa, "{d:>11} {d:>11} {d:>11} ", .{ @@ -146,7 +149,7 @@ test "a pane that is not a terminal has no pty/ at all" { var buf: [32]th.Dirent = undefined; const files = th.dirents(rdir(p, dir, 0).bytes, &buf); - try testing.expectEqual(@as(usize, 10), files.len); + try testing.expectEqual(@as(usize, 17), files.len); try testing.expect(th.nameAt(files, "pty") == null); try testing.expectEqual(E.NOENT, look_up(p, dir, "pty_ctl").errno()); @@ -167,7 +170,7 @@ test "a terminal pane's pty/ holds exactly ctl, status and data" { var buf: [32]th.Dirent = undefined; const files = th.dirents(rdir(p, dir, 0).bytes, &buf); - try testing.expectEqual(@as(usize, 11), files.len); + try testing.expectEqual(@as(usize, 18), files.len); try testing.expect(th.nameAt(files, "pty").?.dir); const inside = th.dirents(rdir(p, Node.of(serial, .pty), 0).bytes, &buf); @@ -247,7 +250,7 @@ test "every pty/ctl verb, and every refusal" { "cooked", "winsize 80 24\nbogus", // a good verb beside a bad one "bogus\nwinsize 80 24", - "look x", // a `ctl` verb; the two files share no vocabulary + "look x", // a pane command; pty/ctl shares none of that vocabulary "exec Del", }) |bad| { const a = wr(p, ctl, bad); diff --git a/src/ninep/screen.zig b/src/ninep/screen.zig index 5b68b34c..2684aa41 100644 --- a/src/ninep/screen.zig +++ b/src/ninep/screen.zig @@ -83,22 +83,33 @@ pub fn releaseSnapshot(p: *Pardes, req: Req) bool { return true; } -pub fn readListeners(p: *Pardes, req: Req) Reply { - var buf: [512]u8 = undefined; - var text = std.Io.Writer.fixed(&buf); +const listeners_cap = 512; + +fn listenersText(p: *Pardes, buf: []u8) []const u8 { + var text = std.Io.Writer.fixed(buf); if (p.fs.socket_path.len != 0) - text.print("unix!{s}\n", .{p.fs.socket_path}) catch return Reply.fail(req.tag, E.IO); + text.print("unix!{s}\n", .{p.fs.socket_path}) catch return text.buffered(); for ([_]?std.Io.net.IpAddress{ p.fs.tcp_address, p.fs.quic_address }, [_][]const u8{ "tcp", "quic" }) |maybe, transport| { const address = maybe orelse continue; switch (address) { .ip4 => |ip| text.print("{s}!{d}.{d}.{d}.{d}!{d}\n", .{ transport, ip.bytes[0], ip.bytes[1], ip.bytes[2], ip.bytes[3], ip.port }) catch - return Reply.fail(req.tag, E.IO), + return text.buffered(), .ip6 => |ip| text.print("{s}!{f}!{d}\n", .{ transport, std.Io.net.Ip6Address.Unresolved{ .bytes = ip.bytes, .interface_name = null }, ip.port }) catch - return Reply.fail(req.tag, E.IO), + return text.buffered(), } } + return text.buffered(); +} + +pub fn listenersLen(p: *Pardes) u64 { + var buf: [listeners_cap]u8 = undefined; + return listenersText(p, &buf).len; +} + +pub fn readListeners(p: *Pardes, req: Req) Reply { + var buf: [listeners_cap]u8 = undefined; const out = p.fs.stage(p.gpa); - out.appendSlice(p.gpa, text.buffered()) catch return Reply.fail(req.tag, E.NOMEM); + out.appendSlice(p.gpa, listenersText(p, &buf)) catch return Reply.fail(req.tag, E.NOMEM); return tree.stagedReply(p, req); } diff --git a/src/ninep/testing.zig b/src/ninep/testing.zig index ba26cb38..ad1d84e4 100644 --- a/src/ninep/testing.zig +++ b/src/ninep/testing.zig @@ -69,13 +69,30 @@ pub fn look_up(p: *Pardes, dir: u64, name: []const u8) Answer { return call(p, .{ .tag = 3, .op = .lookup, .node = dir, .data = name }); } -/// Opens /new once, as a client would, and returns the pane it made. +/// Creates a pane in /pane, as a client's mkdir does, and returns its serial. pub fn newPane(p: *Pardes) !u32 { - const new = @intFromEnum(tree.TopFile.new); - const opened = call(p, .{ .tag = 9, .op = .open, .node = new }); - if (opened.reply.status != .ok or opened.reply.handle == 0) return error.NoPane; - _ = call(p, .{ .tag = 9, .op = .release, .node = new, .handle = opened.reply.handle }); - return opened.reply.handle; + const made = mkdir(p, "scratch"); + if (made.reply.status != .ok) return error.NoPane; + const target = tree.Node.target(made.reply.attr.node) orelse return error.NoPane; + return switch (target) { + .pane => |t| t.serial, + .top => error.NoPane, + }; +} + +pub fn mkdir(p: *Pardes, name: []const u8) Answer { + return call(p, .{ + .tag = 9, + .op = .open, + .node = @intFromEnum(tree.TopFile.pane), + .data = name, + .create = true, + .perm = 0x8000_0000 | 0o755, + }); +} + +pub fn rmdir(p: *Pardes, node: u64) Answer { + return call(p, .{ .tag = 9, .op = .release, .node = node, .remove = true }); } pub fn withFile(gpa: std.mem.Allocator, text: []const u8) !*Pardes { diff --git a/src/ninep/tree.zig b/src/ninep/tree.zig index 56c3112d..46609649 100644 --- a/src/ninep/tree.zig +++ b/src/ninep/tree.zig @@ -4,8 +4,10 @@ //! extended here with the editor's reply payload; fs.zig keeps host access //! and mounts. //! -//! /README /index /ctl /new /log /screen /listeners -//! /pane//{name,body,tag,ctl,addr,data,xdata,sel,errors,event,pty/} +//! /README /index /status /look /exec /log /screen /listeners +//! /pane/ mkdir makes a pane, rmdir closes it +//! /pane//{name,body,tag,ctl,addr,dot,limit,data,xdata,sel, +//! dirty,mark,scroll,errors,event,look,exec,pty/} //! /os/... the host filesystem /src/... embedded sources (opt-in) const std = @import("std"); const cloud9 = @import("cloud9"); @@ -47,11 +49,16 @@ pub const Payload = union(enum) { pub const Reply = cloud9.fs.ReplyWith(Payload); +/// Tcreate opens a pane and Tremove closes one; nothing else in the tree is +/// created or destroyed by the protocol, and wstat stays a truncation. +pub const features: cloud9.fs.Features = .{ .create = true, .remove = true }; + pub fn changesPane(req: Req) bool { return switch (req.op) { .write, .setattr => true, - .open => req.node == @intFromEnum(TopFile.new), - .lookup, .getattr, .read, .release, .readdir => false, + .open => req.create, + .release => req.remove, + .lookup, .getattr, .read, .readdir => false, }; } @@ -63,8 +70,9 @@ pub const TopFile = enum(u4) { root = 1, README, index, - ctl, - new, + status, + look, + exec, log, screen, listeners, @@ -77,8 +85,8 @@ pub const TopFile = enum(u4) { pub fn mode(f: TopFile) u16 { return switch (f) { .root, .pane => 0o755, - .ctl => 0o666, - .README, .index, .new, .log, .screen, .listeners => 0o444, + .look, .exec => 0o666, + .README, .index, .status, .log, .screen, .listeners => 0o444, }; } @@ -89,18 +97,26 @@ pub const TopFile = enum(u4) { pub const root: u64 = @intFromEnum(TopFile.root); -pub const PaneFile = enum(u4) { +/// Declaration order is readdir order. +pub const PaneFile = enum(u5) { dir = 0, name, body, tag, ctl, addr, + dot, + limit, data, xdata, sel, + dirty, + mark, + scroll, errors, event, + look, + exec, pty, pty_ctl, pty_status, @@ -138,8 +154,8 @@ pub const PaneFile = enum(u4) { }; pub const Node = packed struct(u64) { - file: u4 = 0, - serial: u60 = 0, + file: u5 = 0, + serial: u59 = 0, pub fn of(serial: u32, file: PaneFile) u64 { std.debug.assert(serial != 0); @@ -240,8 +256,13 @@ pub fn stagedReply(p: *Pardes, req: Req) Reply { // ---- dispatch ---- pub fn handle(p: *Pardes, req: Req) Reply { - if (req.node == fs.os_root or req.node & fs.os_node != 0) return fs.osHandle(p, req); - if (req.node & sources.archive_node != 0) return sources.handle(p, req); + const host = req.node == fs.os_root or req.node & fs.os_node != 0; + const archive = req.node & sources.archive_node != 0; + // Only /pane is created in and removed from. The host tree and the + // embedded sources say so, rather than quietly doing nothing. + if ((host or archive) and (req.create or req.remove)) return Reply.fail(req.tag, E.PERM); + if (host) return fs.osHandle(p, req); + if (archive) return sources.handle(p, req); const target = Node.target(req.node) orelse return Reply.fail(req.tag, E.NOENT); if (req.op == .write or req.op == .setattr) p.fs.origin = switch (target) { .pane => |t| @as(u8, if (t.file == .body or t.file == .tag) 'E' else 'F'), @@ -280,6 +301,7 @@ fn attrOf(p: *Pardes, target: Target) ?Reply.Attr { .mode = t.file.mode(), .size = pane.fileSize(p, id, t.file), .mtime = pane.mtimeOf(p, pn), + .version = pane.versionOf(pn, t.file), }; }, } @@ -292,13 +314,14 @@ fn attrReply(p: *Pardes, tag: u64, target: Target) Reply { fn topSize(p: *Pardes, f: TopFile) u64 { return switch (f) { - .root, .pane, .new, .log, .screen, .listeners => 0, + // ponytail: /screen has no length until an open renders its frame. + .root, .pane, .screen => 0, .index => pane.indexLen(p), .README => fs.help.len, - .ctl => ctl: { - var buf: [ctl.root_text_cap]u8 = undefined; - break :ctl ctl.rootText(p, &buf).len; - }, + .status => ctl.statusLen(p), + .look, .exec => ctl.resultsLen(p), + .log => events.pending(&p.fs.log), + .listeners => screen.listenersLen(p), }; } @@ -366,7 +389,7 @@ fn readdir(p: *Pardes, req: Req, target: Target) Reply { switch (target) { .top => |f| switch (f) { .root => { - inline for (.{ TopFile.README, TopFile.index, TopFile.ctl, TopFile.new, TopFile.log, TopFile.screen, TopFile.listeners, TopFile.pane }) |t| { + inline for (.{ TopFile.README, TopFile.index, TopFile.status, TopFile.look, TopFile.exec, TopFile.log, TopFile.screen, TopFile.listeners, TopFile.pane }) |t| { if (skip > 0) skip -= 1 else stageDirent(out, p.gpa, @intFromEnum(t), t.dir(), t.fileName()); } if (skip > 0) skip -= 1 else stageDirent(out, p.gpa, fs.os_root, true, "os"); @@ -403,21 +426,27 @@ fn readdir(p: *Pardes, req: Req, target: Target) Reply { return .{ .tag = req.tag, .payload = .{ .staged = @intCast(out.items.len) } }; } -fn newPane(p: *Pardes) ?u32 { - const slot = p.freeSlot() orelse return null; +/// Tcreate in /pane opens a pane, the way mkdir opens a directory. The name +/// asked for is ignored: a pane is named by the serial the editor gives it, +/// which the reply carries back and /index lists last. +fn create(p: *Pardes, req: Req, target: Target) Reply { + switch (target) { + .top => |f| if (f != .pane) return Reply.fail(req.tag, E.PERM), + .pane => return Reply.fail(req.tag, E.PERM), + } + if (req.perm & cloud9.dmdir == 0) return Reply.fail(req.tag, E.PERM); + const slot = p.freeSlot() orelse return Reply.fail(req.tag, E.NFILE); p.newScratchBelow(p.active); - const pn = p.panes[slot] orelse return null; - return pn.serial; + const made = p.panes[slot] orelse return Reply.fail(req.tag, E.NFILE); + const attr = attrOf(p, .{ .pane = .{ .serial = made.serial, .file = .dir } }) orelse + return Reply.fail(req.tag, E.NFILE); + return .{ .tag = req.tag, .handle = 1, .attr = attr }; } fn open(p: *Pardes, req: Req, target: Target) Reply { + if (req.create) return create(p, req, target); switch (target) { .top => |f| switch (f) { - // The clone idiom: each open makes one empty pane; reads answer its serial. - .new => { - const serial = newPane(p) orelse return Reply.fail(req.tag, E.NFILE); - return .{ .tag = req.tag, .handle = serial }; - }, .screen => return screen.openSnapshot(p, req, true), .log => p.fs.log_readers +|= 1, else => {}, @@ -429,11 +458,7 @@ fn open(p: *Pardes, req: Req, target: Target) Reply { if (t.file.inPty() and !pn.isTerminal()) return Reply.fail(req.tag, E.NOENT); switch (t.file) { .body => if (pn.isTerminal()) return screen.openSnapshot(p, req, false), - .ctl => pf.limit = null, - .addr => { - pf.addr = .{}; - pf.limit = null; - }, + .addr => pf.addr = .{}, .event => { pf.readers +|= 1; p.fs.listeners +|= 1; @@ -446,7 +471,27 @@ fn open(p: *Pardes, req: Req, target: Target) Reply { return .{ .tag = req.tag, .handle = 1 }; } +/// Tremove closes a pane. Nothing else in the tree can be removed, and this +/// is also where an ORCLOSE open lands, so every node is checked here. +fn remove(p: *Pardes, req: Req) Reply { + const target = Node.target(req.node) orelse return Reply.fail(req.tag, E.NOENT); + const t = switch (target) { + .pane => |t| t, + .top => return Reply.fail(req.tag, E.PERM), + }; + if (t.file != .dir) return Reply.fail(req.tag, E.PERM); + const id = p.paneBySerial(t.serial) orelse return Reply.fail(req.tag, E.NOENT); + p.removePane(id) catch return Reply.fail(req.tag, E.IO); + return .{ .tag = req.tag }; +} + fn release(p: *Pardes, req: Req) Reply { + // The handle's bookkeeping runs whether or not the removal is allowed. + const done = releaseHandle(p, req); + return if (req.remove) remove(p, req) else done; +} + +fn releaseHandle(p: *Pardes, req: Req) Reply { if (screen.releaseSnapshot(p, req)) return .{ .tag = req.tag }; const target = Node.target(req.node) orelse return .{ .tag = req.tag }; switch (target) { @@ -502,12 +547,8 @@ fn read(p: *Pardes, req: Req, target: Target) Reply { } break :index stagedReply(p, req); }, - .ctl => ctl.readRoot(p, req), - .new => new: { - if (req.handle == 0) break :new Reply.fail(req.tag, E.INVAL); - p.fs.stage(p.gpa).print(p.gpa, "{d}\n", .{req.handle}) catch break :new Reply.fail(req.tag, E.NOMEM); - break :new stagedReply(p, req); - }, + .status => ctl.readStatus(p, req), + .look, .exec => ctl.readResults(p, req), .log => events.readQueue(p, req, &p.fs.log), .screen => screen.readSnapshot(p, req, null), .listeners => screen.readListeners(p, req), @@ -525,7 +566,7 @@ fn read(p: *Pardes, req: Req, target: Target) Reply { fn write(p: *Pardes, req: Req, target: Target) Reply { switch (target) { .top => |f| return switch (f) { - .ctl => ctl.writeRoot(p, req), + .look, .exec => ctl.command(p, req, null, f == .exec), else => Reply.fail(req.tag, E.PERM), }, .pane => |t| { @@ -587,8 +628,8 @@ test "filesystem inspection preserves pending and displayed Look hover" { const preview = p.look_hover_preview; const requests = [_]Req{ .{ .tag = 1, .op = .lookup, .node = root, .data = "screen" }, - .{ .tag = 1, .op = .lookup, .node = root, .data = "new" }, - .{ .tag = 1, .op = .getattr, .node = @intFromEnum(TopFile.new) }, + .{ .tag = 1, .op = .lookup, .node = root, .data = "status" }, + .{ .tag = 1, .op = .getattr, .node = @intFromEnum(TopFile.pane) }, .{ .tag = 2, .op = .getattr, .node = body }, .{ .tag = 3, .op = .open, .node = body }, .{ .tag = 4, .op = .read, .node = body, .size = 5 }, @@ -614,7 +655,7 @@ test "filesystem inspection preserves pending and displayed Look hover" { test "filesystem pane creation and truncation cancel Look hover" { const requests = [_]Req{ - .{ .tag = 2, .op = .open, .node = @intFromEnum(TopFile.new) }, + .{ .tag = 2, .op = .open, .node = @intFromEnum(TopFile.pane), .data = "x", .create = true, .perm = cloud9.dmdir | 0o755 }, .{ .tag = 3, .op = .setattr, .node = 0, .truncate = true }, }; for (requests) |request| { @@ -644,13 +685,13 @@ test "readdir lists the root and a pane directory without creating anything" { var top_bytes: [4096]u8 = undefined; @memcpy(top_bytes[0..top_reply.bytes.len], top_reply.bytes); const top = th.dirents(top_bytes[0..top_reply.bytes.len], &buf); - try testing.expect(top.len >= 9); - for ([_][]const u8{ "README", "index", "ctl", "new", "log", "screen", "listeners", "pane", "os" }, 0..) |name, i| { + try testing.expect(top.len >= 10); + for ([_][]const u8{ "README", "index", "status", "look", "exec", "log", "screen", "listeners", "pane", "os" }, 0..) |name, i| { try testing.expectEqualStrings(name, top[i].name); - try testing.expectEqual(i >= 7, top[i].dir); + try testing.expectEqual(i >= 8, top[i].dir); } - try testing.expectEqual(@intFromEnum(TopFile.pane), top[7].node); - try testing.expectEqual(fs.os_root, top[8].node); + try testing.expectEqual(@intFromEnum(TopFile.pane), top[8].node); + try testing.expectEqual(fs.os_root, top[9].node); var idbuf: [16]u8 = undefined; try testing.expect(th.nameAt(top, try std.fmt.bufPrint(&idbuf, "{d}", .{serial})) == null); try testing.expect(th.nameAt(top, "self") == null); @@ -674,13 +715,18 @@ test "readdir lists the root and a pane directory without creating anything" { } const panes_dir = rdir(p, @intFromEnum(TopFile.pane), 0); const listed = th.dirents(panes_dir.bytes, &buf); - try testing.expectEqual(@as(usize, 1), listed.len); - try testing.expectEqual(Node.of(serial, .dir), listed[0].node); + var idname: [16]u8 = undefined; + const own = th.nameAt(listed, try std.fmt.bufPrint(&idname, "{d}", .{serial})).?; + try testing.expectEqual(Node.of(serial, .dir), own.node); + try testing.expect(own.dir); const dir = rdir(p, Node.of(serial, .dir), 0); const files = th.dirents(dir.bytes, &buf); - try testing.expectEqual(@as(usize, 10), files.len); - for ([_][]const u8{ "name", "body", "tag", "ctl", "addr", "data", "xdata", "sel", "errors", "event" }, 0..) |name, i| + try testing.expectEqual(@as(usize, 17), files.len); + for ([_][]const u8{ + "name", "body", "tag", "ctl", "addr", "dot", "limit", "data", "xdata", + "sel", "dirty", "mark", "scroll", "errors", "event", "look", "exec", + }, 0..) |name, i| try testing.expectEqualStrings(name, files[i].name); try testing.expect(th.nameAt(files, ".") == null); try testing.expect(th.nameAt(files, "rdsel") == null); @@ -703,8 +749,10 @@ test "lookup resolves top files, pane serials and pane files" { const serial = serialOf(p); try testing.expectEqual(@as(u64, @intFromEnum(TopFile.index)), look_up(p, root, "index").reply.attr.node); - try testing.expect(!look_up(p, root, "new").reply.attr.dir); - try testing.expectEqual(@as(u16, 0o444), look_up(p, root, "new").reply.attr.mode); + try testing.expect(!look_up(p, root, "status").reply.attr.dir); + try testing.expectEqual(@as(u16, 0o444), look_up(p, root, "status").reply.attr.mode); + try testing.expectEqual(@as(u16, 0o666), look_up(p, root, "look").reply.attr.mode); + try testing.expectEqual(E.NOENT, look_up(p, root, "new").errno()); try testing.expect(look_up(p, root, "pane").reply.attr.dir); try testing.expect(look_up(p, root, "os").reply.attr.dir); try testing.expectEqual(E.NOENT, look_up(p, root, "nosuchthing").errno()); @@ -732,38 +780,46 @@ test "lookup resolves top files, pane serials and pane files" { try testing.expectEqual(E.NOTDIR, look_up(p, Node.of(serial, .body), "x").errno()); } -test "each open of new creates exactly one pane whose serial the read answers" { +test "creating in the pane directory opens a pane and removing one closes it" { const gpa = testing.allocator; const p = try withFile(gpa, "first\n"); defer p.deinit(); const before = p.next_serial; - const new = @intFromEnum(TopFile.new); + const panes_dir = @intFromEnum(TopFile.pane); - try testing.expectEqual(Status.ok, look_up(p, root, "new").reply.status); - try testing.expectEqual(Status.ok, call(p, .{ .tag = 1, .op = .getattr, .node = new }).reply.status); + // Browsing /pane creates nothing; only a create does. + try testing.expectEqual(Status.ok, rdir(p, panes_dir, 0).reply.status); try testing.expectEqual(before, p.next_serial); - const opened = call(p, .{ .tag = 1, .op = .open, .node = new }); - try testing.expectEqual(Status.ok, opened.reply.status); + const made = th.mkdir(p, "scratch"); + try testing.expectEqual(Status.ok, made.reply.status); try testing.expectEqual(before + 1, p.next_serial); - try testing.expectEqual(before + 1, opened.reply.handle); - try testing.expectEqual(@as(u64, 0), opened.reply.attr.node); + const serial = before + 1; + try testing.expectEqual(Node.of(serial, .dir), made.reply.attr.node); + try testing.expect(made.reply.attr.dir); var expected: [16]u8 = undefined; - const line = try std.fmt.bufPrint(&expected, "{d}\n", .{opened.reply.handle}); - try testing.expectEqualStrings(line, call(p, .{ .tag = 2, .op = .read, .node = new, .handle = opened.reply.handle, .size = 64 }).bytes); - try testing.expectEqualStrings(line[1..], call(p, .{ .tag = 2, .op = .read, .node = new, .handle = opened.reply.handle, .off = 1, .size = 64 }).bytes); - try testing.expectEqualStrings("", call(p, .{ .tag = 2, .op = .read, .node = new, .handle = opened.reply.handle, .off = line.len, .size = 64 }).bytes); - try testing.expectEqual(before + 1, p.next_serial); - _ = call(p, .{ .tag = 3, .op = .release, .node = new, .handle = opened.reply.handle }); + try testing.expectEqualStrings(try std.fmt.bufPrint(&expected, "{d}", .{serial}), made.reply.attr.name); - const id = p.paneBySerial(opened.reply.handle).?; + const id = p.paneBySerial(serial).?; try testing.expectEqualStrings("", p.panes[id].?.file.?.content); - _ = wr(p, Node.of(opened.reply.handle, .body), "hi"); - const second = call(p, .{ .tag = 4, .op = .open, .node = new }); + _ = wr(p, Node.of(serial, .body), "hi"); + const second = th.mkdir(p, "another"); try testing.expectEqual(Status.ok, second.reply.status); - try testing.expect(second.reply.handle != opened.reply.handle); + try testing.expect(second.reply.attr.node != made.reply.attr.node); try testing.expectEqualStrings("hi", p.panes[id].?.file.?.content); - try testing.expectEqual(E.INVAL, call(p, .{ .tag = 5, .op = .read, .node = new, .size = 64 }).errno()); + + // A plain file, and a create anywhere else, are refused. + try testing.expectEqual(E.PERM, call(p, .{ .tag = 1, .op = .open, .node = panes_dir, .data = "f", .create = true, .perm = 0o666 }).errno()); + try testing.expectEqual(E.PERM, call(p, .{ .tag = 1, .op = .open, .node = root, .data = "d", .create = true, .perm = cloud9.dmdir | 0o755 }).errno()); + try testing.expectEqual(E.PERM, call(p, .{ .tag = 1, .op = .open, .node = Node.of(serial, .dir), .data = "d", .create = true, .perm = cloud9.dmdir | 0o755 }).errno()); + + // Tremove closes the pane it names, and nothing else in the tree. + try testing.expectEqual(E.PERM, th.rmdir(p, Node.of(serial, .body)).errno()); + try testing.expectEqual(E.PERM, th.rmdir(p, @intFromEnum(TopFile.index)).errno()); + try testing.expect(p.paneBySerial(serial) != null); + try testing.expectEqual(Status.ok, th.rmdir(p, Node.of(serial, .dir)).reply.status); + try testing.expect(p.paneBySerial(serial) == null); + try testing.expectEqual(E.NOENT, th.rmdir(p, Node.of(serial, .dir)).errno()); } test "directories walk to their parents" { @@ -791,14 +847,15 @@ test "editor paths resolve to the same nodes the wire serves" { try testing.expectEqual(root, resolveSelf(p, "").?); try testing.expectEqual(root, resolveSelf(p, "/./pane/../").?); try testing.expectEqual(@intFromEnum(TopFile.index), resolveSelf(p, "index").?); - try testing.expectEqual(@intFromEnum(TopFile.new), resolveSelf(p, "new").?); + try testing.expectEqual(@intFromEnum(TopFile.status), resolveSelf(p, "status").?); + try testing.expect(resolveSelf(p, "new") == null); try testing.expectEqual(@intFromEnum(TopFile.pane), resolveSelf(p, "pane").?); try testing.expectEqual(Node.of(serial, .dir), resolveSelf(p, try std.fmt.bufPrint(&path, "pane/{d}", .{serial})).?); try testing.expectEqual(Node.of(serial, .sel), resolveSelf(p, try std.fmt.bufPrint(&path, "pane/{d}/sel", .{serial})).?); try testing.expect(resolveSelf(p, try std.fmt.bufPrint(&path, "pane/{d}/pty/ctl", .{serial})) == null); try testing.expect(resolveSelf(p, try std.fmt.bufPrint(&path, "pane/{d}/rdsel", .{serial})) == null); try testing.expect(resolveSelf(p, "self/index") == null); - try testing.expect(resolveSelf(p, "new/ctl") == null); + try testing.expect(resolveSelf(p, "status/ctl") == null); try testing.expect(resolveSelf(p, "cons") == null); try testing.expect(resolveSelf(p, "pane/0") == null); } diff --git a/src/panes.zig b/src/panes.zig index edd7038f..9a6802d0 100644 --- a/src/panes.zig +++ b/src/panes.zig @@ -6273,6 +6273,13 @@ pub const Terminal = struct { state.vt.screens.active.scroll(.{ .delta_row = delta }); } + /// Is the viewport already showing the last row of output? + pub fn atBottom(pane: *const Pane) bool { + if (comptime !enabled) return true; + const sb = scrollbar(pane); + return sb.offset + sb.len >= sb.total; + } + /// Snap the viewport back onto live output. pub fn followOutput(pane: *Pane) void { if (comptime !enabled) return; @@ -6559,10 +6566,14 @@ pub const Terminal = struct { const has_positions = pane.ovl != null or pane.cur_pinned or pane.vsel.active or pane.msel.active or pane.nsel > 0 or pane.append_at != null or pane.look_at != null or pane.ed_undo_len > 0 or pane.ed_redo_len > 0 or pointerRowCount(pane) > 0; + // Sticky bottom, as every other terminal does it: output drags the + // viewport down only when the viewport was already on the last row, so + // a reader scrolled back into the scrollback stays where they scrolled. + const at_bottom = atBottom(pane); if (has_positions) ingestWithPositions(pane, bytes) else ingest(pane, bytes); p.shell_rows.markStale(pane); const body_mode = if (pane.tag_edit) pane.tag_mode else pane.mode; - if (body_mode == .tty) followOutput(pane); + if (body_mode == .tty and at_bottom) followOutput(pane); } const RowPin = struct { pin: ?*ghostty_vt.Pin = null, offset: i32 = 0 }; @@ -6890,6 +6901,7 @@ pub const Terminal = struct { }; pane.mode = .tty; + followOutput(pane); // entering raw mode is a request for the live shell pane.msel.active = false; pane.vsel.active = false; pane.nsel = 0; diff --git a/src/pardes.zig b/src/pardes.zig index ed71102e..c66688f5 100644 --- a/src/pardes.zig +++ b/src/pardes.zig @@ -295,6 +295,12 @@ const pre_collapse_pdf_pane_tail = " Tty Del PdfSections PdfTint"; const pre_collapse_terminal_pane_tail = " Save Tty Del Togglettymode Filter"; const pre_tty_first_terminal_pane_tail = " Save Tty Del Togglettymode Filter Collapse"; const pre_mode_terminal_pane_tail = " Tty Save Del Togglettymode Filter Collapse"; +// ...and the defaults from before the closing word moved to the end of every +// tagline, where a click cannot land on it by overshooting the one before. +const pre_close_last_pane_tail = " Tty Collapse Del"; +const pre_close_last_file_pane_tail = " Save Tty Del Collapse"; +const pre_close_last_pdf_pane_tail = " Tty Del PdfSections PdfTint Collapse"; +const pre_close_last_terminal_pane_tail = " Tty Save Del Mode Filter Collapse"; const Builtin = builtins.registry.Builtin(); @@ -1078,7 +1084,7 @@ test "Collapse builtin keeps content and restores the pane from its default tag" const height = p.rects[0].h; const revision = pane.file.?.revision; for ([_][]const u8{ pane_tail, file_pane_tail, pdf_pane_tail, terminal_pane_tail }) |tail| - try std.testing.expect(std.mem.endsWith(u8, tail, " Collapse")); + try std.testing.expect(std.mem.endsWith(u8, tail, " Collapse Del")); try std.testing.expect(p.executeBuiltinLine(0, "Collapse")); p.sync(); @@ -1115,6 +1121,8 @@ test "LocationsConfig command reports partial updates and survives restore" { try std.testing.expectEqual(expected, p.locations_config); try std.testing.expect(p.executeBuiltinLine(0, "LocationsConfig context:2 unknown:on")); try std.testing.expectEqual(expected, p.locations_config); + // Setting it is silent; asking bare is what opens the window. + try std.testing.expect(p.executeBuiltinLine(0, "LocationsConfig")); var reports: usize = 0; for (p.panes) |slot| { const pane = slot orelse continue; @@ -1409,7 +1417,7 @@ test "legacy default tag tails upgrade while custom tails remain owned" { }); p.restoreTail(file, file_old); try std.testing.expect(!file.tag_init); - try std.testing.expectEqualStrings(" Save Tty Del Collapse", Pardes.curTail(file)); + try std.testing.expectEqualStrings(" Save Tty Collapse Del", Pardes.curTail(file)); const file_custom = try std.fmt.allocPrint(p.scratch.allocator(), "{s} Save Mine Del", .{ try p.tagPrefix(file), @@ -1430,7 +1438,7 @@ test "legacy default tag tails upgrade while custom tails remain owned" { try std.testing.expectEqualStrings(" New Del", Pardes.curTail(file)); const image_doc = try panes.Image.create(p, 1, "/tmp/legacy image.ppm", &.{}); - try std.testing.expectEqualStrings(" Tty Del Collapse", Pardes.curTail(image_doc)); + try std.testing.expectEqualStrings(" Tty Collapse Del", Pardes.curTail(image_doc)); p.restoreDumpTail(image_doc, .{ .kind = .image, .tag = "img /tmp/legacy image.ppm Keep Del", @@ -1576,7 +1584,7 @@ test "pane defaults keep creation of scratch panes in column tags" { var words = std.mem.tokenizeScalar(u8, tag, ' '); while (words.next()) |word| try std.testing.expect(!std.mem.eql(u8, word, "New")); } - try std.testing.expectEqualStrings("New Tty Find Grep Joincol", p.columnTag(0)); + try std.testing.expectEqualStrings("New Tty Find Grep Joincol Delcol", p.columnTag(0)); const terminal = p.panes[0].?; p.restoreTailAt(terminal, pre_column_terminal_pane_tail, "", .terminal); try std.testing.expect(!terminal.tag_init); @@ -2441,13 +2449,13 @@ test "Save reaches every tagline with text behind it and no other" { }); p.restoreTail(out, scratch_dumped); try std.testing.expect(!out.tag_init); - try std.testing.expectEqualStrings(" Save Tty Del Collapse", Pardes.curTail(out)); + try std.testing.expectEqualStrings(" Save Tty Collapse Del", Pardes.curTail(out)); // An image's bytes on disk already are what they are: nothing of the // pane's own is unwritten, so the word is absent and inert. const img_id = p.freeSlot().?; const img = try panes.Image.create(p, img_id, "/tmp/pardes-tag.ppm", &.{}); - try std.testing.expectEqualStrings(" Tty Del Collapse", Pardes.curTail(img)); + try std.testing.expectEqualStrings(" Tty Collapse Del", Pardes.curTail(img)); try std.testing.expect(p.executeBuiltinLine(img_id, "Save")); try std.testing.expect(img.prompt != .save); var buf: [256]u8 = undefined; @@ -5818,8 +5826,42 @@ test "repeated non-dyadic column splits preserve every unrelated boundary" { pub const Rect = layout.Rect; +/// The session layouts `init` can put on screen. One name each, so choosing +/// between them reads as a choice instead of a chain of ifs over four options. +pub const Boot = enum { + /// the document named on the command line, or the pane explaining why not + document, + /// a Look that found nothing: reported, not opened + missing, + /// the firmware's boot buffer, the only pane a board has + embedded, + /// the bare tty startup: one shell in raw tty mode, with an empty text + /// pane under it so the editor half is there before you want it + tty, + /// that raw shell by itself, which is all a core booted for a test wants + tty_shell, + /// acme's boot: two columns, the left one split in two + classic, + /// one greeted shell + shell, + + pub fn of(opts: Options) Boot { + if (opts.boot) |named| return named; + if (opts.file != null) return .document; + if (opts.missing != null) return .missing; + if (comptime platform == .esp32p4) return .embedded; + if (opts.tty_only) return .tty_shell; + // ponytail: 1 and 3 are the only shell counts anyone asked for + return if (opts.shells >= 3) .classic else .shell; + } +}; + pub const Options = struct { tty_only: bool = false, + /// The layout to boot, when a host means one outright rather than leaving + /// it to be read off the options below. `--tty` names `.tty`; a core + /// booted for a test names nothing and gets `.tty_shell`. + boot: ?Boot = null, /// initial shell panes: 1 (default) or 3 for the classic two-column boot. /// A `file` outranks this — see there. shells: u8 = 1, @@ -6035,6 +6077,11 @@ pub const Pardes = struct { pipe_wait: ?PendingPipe = null, fs: filesystem.Namespace = .{}, + boot: Boot = .shell, + /// Builtins announce themselves on the message row. Off while startup + /// configuration is applied: those lines are nobody clicking, and should + /// not leave the row holding the name of the last one. + announce: bool = true, // Reject overflow: evicting an older effect would reorder a byte stream. effects: [limits.effect_cap]Effect = undefined, @@ -6114,7 +6161,10 @@ pub const Pardes = struct { for (opts.mounts) |mount| try p.fs.mount(gpa, mount.name, mount.dial); p.opts.mounts = &.{}; p.opts.ninep_identity = .{}; - if (opts.file) |path| { + p.boot = Boot.of(opts); + switch (p.boot) { + .document => { + const path = opts.file.?; const opened = initial_doc: { if (comptime pdf_enabled) if (look.isPdfPath(path)) break :initial_doc panes.Pdf.openPane(p, 0, path, opts.file_line); @@ -6137,10 +6187,10 @@ pub const Pardes = struct { errdefer gpa.free(content); _ = try panes.Output.open(p, 0, std.fs.path.dirname(path) orelse "/", .errors, "", content); } - p.ncol = 1; - p.col_n[0] = 1; - p.col_panes[0][0] = 0; - } else if (opts.missing) |missing| { + p.oneColumn(); + }, + .missing => { + const missing = opts.missing.?; const content = try std.fmt.allocPrint( gpa, "file or directory not found\n\n\t{s}\n", @@ -6148,24 +6198,26 @@ pub const Pardes = struct { ); errdefer gpa.free(content); _ = try panes.Output.open(p, 0, missing.dir, .errors, "", content); - p.ncol = 1; - p.col_n[0] = 1; - p.col_panes[0][0] = 0; - } else if (comptime platform == .esp32p4) { + p.oneColumn(); + }, + .embedded => { const content = try p.gpa.dupe(u8, boot_buffer); errdefer p.gpa.free(content); _ = try panes.Output.open(p, 0, "", .{ .cmd = .New }, "", content); - p.ncol = 1; - p.col_n[0] = 1; - p.col_panes[0][0] = 0; - } else if (opts.tty_only) { + p.oneColumn(); + }, + .tty, .tty_shell => { _ = try p.newShell(0, ""); p.panes[0].?.mode = .tty; - p.ncol = 1; - p.col_n[0] = 1; - p.col_panes[0][0] = 0; - } else if (opts.shells >= 3) { - // classic layout: two columns, the left one split in two. + p.oneColumn(); + // A bare tty is still an editor: it opens with somewhere to put + // text under the shell. The shell keeps the keyboard. + if (p.boot == .tty) { + p.newScratchBelow(0); + p.active = 0; + } + }, + .classic => { _ = try p.newShell(0, ""); _ = try p.newShell(1, ""); _ = try p.newShell(2, ""); @@ -6176,13 +6228,12 @@ pub const Pardes = struct { p.col_panes[0][1] = 1; p.col_n[1] = 1; p.col_panes[1][0] = 2; - } else { - // ponytail: 1 and 3 are the only boot layouts; anything else acts as 1 + }, + .shell => { _ = try p.newShell(0, ""); p.panes[0].?.greet = true; - p.ncol = 1; - p.col_n[0] = 1; - p.col_panes[0][0] = 0; + p.oneColumn(); + }, } p.sync(); p.applyStartupConfig(); @@ -6195,6 +6246,13 @@ pub const Pardes = struct { return p; } + /// The layout every single-pane boot starts from. + fn oneColumn(p: *Pardes) void { + p.ncol = 1; + p.col_n[0] = 1; + p.col_panes[0][0] = 0; + } + pub fn deinit(p: *Pardes) void { p.cancelLookHover(); for (0..MAX_PANES) |id| p.dropPendingWrite(id); @@ -6268,7 +6326,7 @@ pub const Pardes = struct { } pub fn columnTag(p: *const Pardes, c: usize) []const u8 { - return p.col_tags[c].slice("New Tty Find Grep Joincol"); + return p.col_tags[c].slice("New Tty Find Grep Joincol Delcol"); } fn headerText(p: *Pardes) []const u8 { @@ -6413,6 +6471,17 @@ pub const Pardes = struct { return np; } + /// The empty pane that stands in for one that closed, keeping its column + /// alive and its directory. Unlike `newScratch` it inherits nothing: the + /// pane it replaces is on its way out. + fn newScratchIn(p: *Pardes, free: usize, dir: []const u8) !*Pane { + const content = try p.gpa.dupe(u8, ""); + errdefer p.gpa.free(content); + const np = try panes.Output.open(p, free, dir, .{ .cmd = .New }, "", content); + np.cur_pinned = true; + return np; + } + /// New: a scratch below the calling pane, in its column. pub fn newScratchBelow(p: *Pardes, from_id: usize) void { const free = p.freeSlot() orelse return; @@ -8237,8 +8306,23 @@ pub const Pardes = struct { p.ctrl_w_pending = false; if (key.ctrl and !key.alt and key.cp == p.opts.tty_toggle) return p.toggleTty(p.active); + // Shift-Escape is the unconditional way out, even mid-application; + // bare Escape only leaves at a shell prompt. + if (hit(key, config.tty_toggle_alt)) + return p.runBuiltin(.Last, p.active, "", null); if (key.cp == Key.escape and !key.ctrl and !key.alt and !key.shift and p.takesCommandLine(p.active)) return p.runBuiltin(.Last, p.active, "", null); + panes.Terminal.followOutput(pane); // typing snaps back to live output + // Paste stays the window's, the one exception to forwarding a raw + // tty's keys: Ctrl-V types the register at the program and + // Ctrl-Shift-V asks the desktop for its clipboard first. Forwarded, + // they reach an application that reads the clipboard on its own + // account instead — a coding agent goes there hunting for an image. + // A host that folds Shift into the letter says the same thing. + if (key.ctrl and !key.alt and (key.cp == 'v' or key.cp == 'V')) { + if (key.shift or key.cp == 'V') return p.clipRequest(p.active, .after); + return p.typeToTty(p.active, pane, p.yank orelse return); + } return panes.Terminal.forwardKey(p, p.active, key); } if (p.leader_on) return p.leaderKey(key); @@ -12499,6 +12583,8 @@ pub const Pardes = struct { } fn applyStartupConfig(p: *Pardes) void { + p.announce = false; + defer p.announce = true; var lines = std.mem.splitScalar(u8, p.opts.startup_config orelse return, '\n'); while (lines.next()) |line| _ = p.executeBuiltinLine(p.active, line); } @@ -12506,6 +12592,11 @@ pub const Pardes = struct { fn runBuiltin(p: *Pardes, b: Builtin, id: usize, txt: []const u8, arg: ?[]const u8) void { if (!p.multiOnce()) return; // a builtin is per-keystroke, never per-cursor const pane = p.panes[id] orelse return; + // A builtin says its own name before it runs, so a tagline click is + // legible even when what it did is invisible. Whatever the builtin + // then says for itself replaces the announcement. + if (p.announce and p.settings.verbose and builtins.registry.announces(b)) + p.setMessage(id, @tagName(b)); const c: builtins.Ctx = .{ .p = p, .pane = pane, .id = id, .txt = txt, .arg = arg }; builtins.registry.dispatch(b, c); } @@ -12887,11 +12978,13 @@ pub const Pardes = struct { const rest = saved_tag[pfx.len..]; const said = std.mem.trimStart(u8, rest, " "); const defaults: []const []const u8 = switch (class) { - .generic => &.{ pdf_pane_tail, pane_tail, pre_collapse_pdf_pane_tail, pre_collapse_pane_tail, pre_column_pdf_pane_tail, pre_column_pane_tail, prev_pane_tail, legacy_pane_tail }, - .file => &.{ context_pane_tail, file_pane_tail, pre_collapse_file_pane_tail, pre_column_file_pane_tail, prev_file_pane_tail, legacy_file_pane_tail }, + .generic => &.{ pdf_pane_tail, pane_tail, pre_close_last_pdf_pane_tail, pre_close_last_pane_tail, pre_collapse_pdf_pane_tail, pre_collapse_pane_tail, pre_column_pdf_pane_tail, pre_column_pane_tail, prev_pane_tail, legacy_pane_tail }, + .file => &.{ context_pane_tail, file_pane_tail, pre_close_last_file_pane_tail, pre_collapse_file_pane_tail, pre_column_file_pane_tail, prev_file_pane_tail, legacy_file_pane_tail }, .output => &.{ locations_pane_tail, file_pane_tail, + pre_close_last_file_pane_tail, + pre_close_last_pane_tail, prev_file_pane_tail, legacy_file_pane_tail, pane_tail, @@ -12902,7 +12995,7 @@ pub const Pardes = struct { pre_collapse_file_pane_tail, pre_collapse_pane_tail, }, - .terminal => &.{ terminal_pane_tail, pre_mode_terminal_pane_tail, pre_tty_first_terminal_pane_tail, pre_collapse_terminal_pane_tail, pre_column_terminal_pane_tail, pre_tty_terminal_pane_tail, prev_terminal_pane_tail, legacy_terminal_pane_tail, pane_tail, pre_collapse_pane_tail, pre_column_pane_tail, prev_pane_tail, legacy_pane_tail }, + .terminal => &.{ terminal_pane_tail, pre_close_last_terminal_pane_tail, pre_close_last_pane_tail, pre_mode_terminal_pane_tail, pre_tty_first_terminal_pane_tail, pre_collapse_terminal_pane_tail, pre_column_terminal_pane_tail, pre_tty_terminal_pane_tail, prev_terminal_pane_tail, legacy_terminal_pane_tail, pane_tail, pre_collapse_pane_tail, pre_column_pane_tail, prev_pane_tail, legacy_pane_tail }, }; for (defaults) |default| if (std.mem.eql(u8, said, std.mem.trimStart(u8, default, " "))) return; @@ -12912,11 +13005,34 @@ pub const Pardes = struct { pub fn removePane(p: *Pardes, id: usize) !void { const pane = p.panes[id] orelse return; + // A column outlives its panes. Closing the last one leaves an empty + // pane standing in its place and in its directory; only Delcol ever + // takes a column away. + const place = layout.findPane(p, id); + const last_in_column = if (place) |f| p.col_n[f.col] == 1 else false; + var dir_buf: [limits.host_path_cap]u8 = undefined; + var dir: []const u8 = ""; + if (last_in_column) { + const had = paneDir(pane); + const n = @min(had.len, dir_buf.len); + @memcpy(dir_buf[0..n], had[0..n]); + dir = dir_buf[0..n]; + } + // Before anything is torn down, so a failure here changes nothing. try p.deinitPane(pane); + // ...and after it, so the stand-in inherits none of the closing pane. + const heir: ?usize = heir: { + if (!last_in_column) break :heir null; + const f = place.?; + const free = p.freeSlot() orelse break :heir null; + _ = p.newScratchIn(free, dir) catch break :heir null; + layout.insert(p, f.col, f.idx + 1, free); + break :heir free; + }; layout.absorbVWeight(p, id); layout.removePane(p, id); p.panes[id] = null; - if (p.active == id) p.active = p.prevFocus(id) orelse { + if (p.active == id) p.active = heir orelse p.prevFocus(id) orelse { p.quit = true; p.emit(.quit); return; @@ -14408,6 +14524,75 @@ test "Esc back into a tty leaves its view at the prompt" { try std.testing.expectEqual(live, sp.terminal.?.vt.screens.active.pages.scrollbar().offset); } +test "the bare tty startup opens a text pane under the shell, unfocused" { + if (platform == .web) return; + const p = try Pardes.init(std.testing.allocator, .{ .tty_only = true, .boot = .tty }); + defer p.deinit(); + try std.testing.expectEqual(Boot.tty, p.boot); + + // One column, shell on top in raw mode, an empty text pane under it. + try std.testing.expectEqual(@as(usize, 1), p.ncol); + try std.testing.expectEqual(@as(usize, 2), p.col_n[0]); + const shell = p.panes[p.col_panes[0][0]].?; + const scratch = p.panes[p.col_panes[0][1]].?; + try std.testing.expect(shell.isTerminal()); + try std.testing.expectEqual(Pane.Mode.tty, shell.mode); + try std.testing.expect(!scratch.isTerminal()); + try std.testing.expectEqualStrings("", scratch.file.?.content); + + // ...and the shell keeps the keyboard. + try std.testing.expectEqual(p.col_panes[0][0], p.active); + + // Unnamed, it is the bare shell every test asks for. + const plain = try Pardes.init(std.testing.allocator, .{ .tty_only = true }); + defer plain.deinit(); + try std.testing.expectEqual(Boot.tty_shell, plain.boot); + try std.testing.expectEqual(@as(usize, 1), plain.col_n[0]); +} + +test "tty output follows only from the bottom" { + if (platform == .web) return; + const p = try Pardes.init(std.testing.allocator, .{ .cols = 80, .rows = 24, .file = "mise.toml" }); + defer p.deinit(); + p.update(.{ .resize = .{ .cols = 80, .rows = 24 } }); + p.update(.{ .key = .{ .cp = 'n', .alt = true } }); // a shell under the doc + const shell = p.active; + const sp = p.panes[shell].?; + p.update(.{ .key = .{ .cp = Key.escape, .shift = true } }); + try std.testing.expectEqual(Pane.Mode.tty, sp.mode); + + for (0..60) |i| { + var buf: [32]u8 = undefined; + p.update(.{ .output = .{ .pane = @intCast(shell), .bytes = std.fmt.bufPrint(&buf, "line {d}\r\n", .{i}) catch unreachable } }); + } + p.sync(); + const bottom = panes.Terminal.scrollbar(sp).offset; + try std.testing.expect(bottom > 0); + + // Scrolled back, the reader stays put however much the shell prints. + sp.scrollBy(-10); + p.sync(); + const parked = panes.Terminal.scrollbar(sp).offset; + try std.testing.expect(parked < bottom); + for (60..70) |i| { + var buf: [32]u8 = undefined; + p.update(.{ .output = .{ .pane = @intCast(shell), .bytes = std.fmt.bufPrint(&buf, "line {d}\r\n", .{i}) catch unreachable } }); + } + p.sync(); + try std.testing.expectEqual(parked, panes.Terminal.scrollbar(sp).offset); + + // Typing snaps back to live output, so nobody types blind. + p.update(.{ .key = .{ .cp = 'x', .text = "x" } }); + p.sync(); + try std.testing.expect(panes.Terminal.scrollbar(sp).offset > parked); + + // ...and from there output follows again. + const live = panes.Terminal.scrollbar(sp).offset; + p.update(.{ .output = .{ .pane = @intCast(shell), .bytes = "tail\r\n" } }); + p.sync(); + try std.testing.expect(panes.Terminal.scrollbar(sp).offset > live); +} + test "Esc back into a file leaves its view where it was" { if (platform == .web) return; const gpa = std.testing.allocator; @@ -14461,15 +14646,23 @@ test "raw tty Escape only leaves at a shell prompt" { const pane = p.panes[shell].?; var buf: [256]u8 = undefined; _ = drainWrites(p, &buf); - for ([_]Key{ - .{ .cp = Key.escape, .shift = true }, - }) |key| { - p.update(.{ .key = key }); - try std.testing.expectEqual(shell, p.active); - try std.testing.expectEqual(Pane.Mode.tty, pane.mode); - try std.testing.expect(drainWrites(p, &buf).len > 0); - } - p.update(.{ .key = .{ .cp = Key.escape } }); + + // Ordinary keys reach the child; Shift-Escape is the one unconditional way + // out and sends it nothing. + p.update(.{ .key = .{ .cp = 'x', .text = "x" } }); + try std.testing.expectEqual(shell, p.active); + try std.testing.expect(drainWrites(p, &buf).len > 0); + + p.update(.{ .key = .{ .cp = Key.escape, .shift = true } }); + try std.testing.expectEqual(@as(usize, 0), p.active); + try std.testing.expectEqualStrings("", drainWrites(p, &buf)); + try std.testing.expectEqual(Pane.Mode.tty, pane.mode); + + p.update(.{ .key = .{ .cp = Key.escape } }); // back into the shell + try std.testing.expectEqual(shell, p.active); + _ = drainWrites(p, &buf); + + p.update(.{ .key = .{ .cp = Key.escape } }); // bare Escape leaves at a prompt try std.testing.expectEqual(@as(usize, 0), p.active); try std.testing.expectEqualStrings("", drainWrites(p, &buf)); try std.testing.expectEqual(Pane.Mode.tty, pane.mode); @@ -14620,9 +14813,10 @@ test "raw tty forwards Ctrl letters and former global shortcuts to the child" { defer p.deinit(); var buf: [256]u8 = undefined; _ = drainWrites(p, &buf); - p.setYank("must not be pasted"); + p.setYank("register text"); for ('a'..'z' + 1) |letter| { if (letter == p.opts.tty_toggle) continue; // editor/TTY mode shortcut + if (letter == 'v') continue; // the window's paste, asserted just below p.update(.{ .key = .{ .cp = @intCast(letter), .ctrl = true } }); const expected = [_]u8{@intCast(letter - 'a' + 1)}; // The terminal encoder distinguishes Ctrl-I/M from Tab/Return. @@ -14636,15 +14830,21 @@ test "raw tty forwards Ctrl letters and former global shortcuts to the child" { try std.testing.expectEqual(Pane.Mode.tty, p.panes[0].?.mode); try std.testing.expect(!p.ctrl_w_pending and p.clip_pending == null); } - p.update(.{ .key = .{ .cp = 'v', .ctrl = true, .shift = true } }); - try std.testing.expectEqualStrings("\x1b[118;6u", drainWrites(p, &buf)); + // ...and the two paste chords are the exception: Ctrl-V types the register + // at the program, Ctrl-Shift-V asks the desktop first and types nothing yet. + p.update(.{ .key = .{ .cp = 'v', .ctrl = true } }); + try std.testing.expectEqualStrings("register text", drainWrites(p, &buf)); try std.testing.expect(p.clip_pending == null); + p.update(.{ .key = .{ .cp = 'v', .ctrl = true, .shift = true } }); + try std.testing.expectEqualStrings("", drainWrites(p, &buf)); + try std.testing.expect(p.clip_pending != null); + const unopened = p.freeSlot(); // whatever the boot layout already used for ([_]u8{ 'n', 'c' }) |letter| { p.update(.{ .key = .{ .cp = letter, .alt = true } }); const expected = [_]u8{ 0x1b, letter }; try std.testing.expectEqualStrings(&expected, drainWrites(p, &buf)); try std.testing.expectEqual(@as(usize, 0), p.active); - try std.testing.expect(p.panes[1] == null); + try std.testing.expectEqual(unopened, p.freeSlot()); } p.update(.{ .key = .{ .cp = Key.up } }); try std.testing.expectEqualStrings("\x1b[A", drainWrites(p, &buf)); diff --git a/src/tty/tty.zig b/src/tty/tty.zig index 23b7c09b..a1917ba9 100644 --- a/src/tty/tty.zig +++ b/src/tty/tty.zig @@ -71,6 +71,21 @@ fn inputReader(loop: *Loop, tty: anytype, cache: *vaxis.GraphemeCache) void { loop.postEvent(.quit) catch {}; } +/// How long a lone ESC waits for the rest of a sequence before it counts as +/// the Escape key. Long enough for the remainder of a real sequence to arrive +/// even over a slow link, short enough that nobody sees the delay. +const escape_hold_ms = 25; + +/// Is there more input right behind what we have already read? Only a real +/// terminal has an fd to ask; the test readers hand their parts over whole, so +/// for them the answer is always no. +fn morePending(tty: anytype) bool { + const Reader = @typeInfo(@TypeOf(tty)).pointer.child; + if (!@hasField(Reader, "fd") or @FieldType(Reader, "fd") != std.Io.File) return false; + var fds = [_]std.posix.pollfd{.{ .fd = tty.fd.handle, .events = std.posix.POLL.IN, .revents = 0 }}; + return (std.posix.poll(&fds, escape_hold_ms) catch return false) > 0; +} + fn readInput(loop: *Loop, tty: anytype, cache: *vaxis.GraphemeCache) !void { try loop.postEvent(.{ .winsize = try tty.getWinsize() }); var parser: vaxis.Parser = .{}; @@ -101,6 +116,22 @@ fn readInput(loop: *Loop, tty: anytype, cache: *vaxis.GraphemeCache) !void { } carried = end - consumed; std.mem.copyForwards(u8, buf[0..carried], buf[consumed..end]); + // A lone ESC opens most sequences and is also the Escape key, so the + // parser holds it for a remainder that a keypress never sends: the + // press would only land when the NEXT key arrived. Wait a beat, and + // when nothing follows it was the key. A terminal speaking the kitty + // protocol never reaches here — it spells Escape out in full. + if (carried == 1 and buf[0] == 0x1b and !morePending(tty)) { + carried = 0; + try vaxis.loop.handleEventGeneric( + loop, + loop.vaxis, + cache, + @TypeOf(Command.value), + @as(vaxis.Event, .{ .key_press = .{ .codepoint = vaxis.Key.escape } }), + loop.vaxis.opts.system_clipboard_allocator, + ); + } } } diff --git a/src/tutor.txt b/src/tutor.txt index 394a48a3..adf4ae3a 100644 --- a/src/tutor.txt +++ b/src/tutor.txt @@ -160,8 +160,10 @@ RAW INPUT Ctrl-b switches to editor mode. Other keys go to the child, - including Ctrl-o, Ctrl-w, Ctrl-V, Ctrl-Shift-V, Alt shortcuts, and - modified Escape. Plain Esc at a detected shell prompt hops + including Ctrl-o, Ctrl-w, Alt shortcuts, and + modified Escape. The two paste chords are the exception: Ctrl-V + types the yank register at the program and Ctrl-Shift-V types the + desktop clipboard. Plain Esc at a detected shell prompt hops to the previous pane. While a program owns the terminal, Esc goes to that program too. Use the Togglettymode tag to leave raw input in place. Desktop paste events still feed the child. @@ -387,15 +389,15 @@ typed pardes the 9P socket opens by default - A directory per pane holding `name`, `body`, `tag`, `ctl`, `addr`, - `data`, `sel`, `event`, `pty/` and the rest, plus `index`, `ctl`, - `new` and `log` at the root. Every pane shell receives `$PARDES_9P` - (the socket) and `$PARDES_PANE` (its serial). Use a 9P client: + A directory per pane holding `name`, `body`, `tag`, `addr`, `dot`, + `data`, `sel`, `dirty`, `event`, `pty/` and the rest, plus `index`, + `status`, `look`, `exec` and `log` at the root. Every pane shell + receives `$PARDES_9P` (the socket) and `$PARDES_PANE` (its serial): /pane//body /index - /new reading it makes a pane, answers its serial - /ctl `look FILE:12` and `exec Save`, as the mouse does + /pane mkdir here makes a pane, rmdir closes it + /look /exec `FILE:12` and `Save`, as the mouse does A terminal pane also has `pty/`: @@ -446,7 +448,8 @@ typed Esc goes to the program — except at a shell PROMPT, where it hops to the previous pane Ctrl-b switches to editor mode - All other keys belong to the child, including Ctrl-V + Ctrl-V types the register, Ctrl-Shift-V the clipboard + All other keys belong to the child DETACHED pardes --detach[=name] the core, no terminal pardes --attach[=name] a frontend for it diff --git a/test/appearance_gallery.py b/test/appearance_gallery.py index 0fa12136..48c0ea1b 100644 --- a/test/appearance_gallery.py +++ b/test/appearance_gallery.py @@ -82,7 +82,7 @@ def run(args): right = require(wait_for(lambda: next((s for s in panes(client) if s not in before), None)), 'right column missing') client.write(f'/pane/{right}/name', f'{root / "Review"}\n'.encode()) client.write(f'/pane/{right}/body', PREFERENCE_NOTES if args.theme_selector else NOTES, truncate=True) - client.write(f'/pane/{right}/ctl', b'clean\n') + client.write(f'/pane/{right}/dirty', b'0\n') before = set(panes(client)) command(client, right, 'Tty') terminal = require(wait_for(lambda: next((s for s in panes(client) if s not in before), None)), 'terminal missing') @@ -94,12 +94,12 @@ def run(args): command(client, right, 'Config') pane = require(wait_for(lambda: next((s for s in panes(client) if s not in before), None)), 'Config output missing') text = client.read(f'/pane/{pane}/body').decode() - client.write(f'/pane/{pane}/ctl', b'exec Del\n') + client.write(f'/pane/{pane}/exec', b'Del\n') return text settings = config_report() - require('Font effective size: 18.00 pixels' in settings, 'configured font size not applied: ' + settings) - require('TaglineSize: 80' in settings, 'configured tag size missing') + require('Font effective size 18.00 pixels' in settings, 'configured font size not applied: ' + settings) + require('TaglineSize 80' in settings, 'configured tag size missing') (root / 'effective-config.txt').write_text(settings) report['font_effective_pixels'] = 18 report['tagline_percent'] = 80 @@ -135,7 +135,7 @@ def run(args): command(client, right, 'Theme ' + theme) if args.theme_selector: # Keep both quiet active gutter ink and vivid comments in view. - client.write(f'/pane/{source}/ctl', f'look {source_path}:117\n'.encode()) + client.write(f'/pane/{source}/look', f'{source_path}:117\n'.encode()) take_frame('classic-' + theme) if args.theme_selector: frame = client.screen() @@ -171,14 +171,14 @@ def run(args): 'ThemeSel did not open at native first entry') take_frame('theme-selector') report['native_themes_first'] = True - client.write(f'/pane/{selector}/ctl', b'exec Del\n') + client.write(f'/pane/{selector}/exec', b'Del\n') command(client, terminal, 'Collapse') for pet in (() if args.skip_pets else ('cat', 'frog', 'off')): command(client, right, 'Pet ' + pet) settings = config_report() require('Pet: ' + pet + '\n' in settings, 'pet setting not applied') # Returning focus to the source closes all transient report state. - client.write(f'/pane/{source}/ctl', f'look {source_path}:1\n'.encode()) + client.write(f'/pane/{source}/look', f'{source_path}:1\n'.encode()) take_frame('pet-' + pet) if pet != 'off': frame = client.screen() diff --git a/test/column_tags.py b/test/column_tags.py index 80b623bd..fe3a8699 100644 --- a/test/column_tags.py +++ b/test/column_tags.py @@ -143,7 +143,7 @@ def run(args): client.write(f'/pane/{right}/name', f'{right_name}\n'.encode()) right_body = b'// Column-local scratch\nfn main() {\n let ready = true;\n}\n' client.write(f'/pane/{right}/body', right_body) - client.write(f'/pane/{right}/ctl', b'clean\n') + client.write(f'/pane/{right}/dirty', b'0\n') require(wait_for(lambda: locate(client, 'New Tty', row=1, minimum_col=75)), 'right column tag missing') require(locate(client, 'New Tty', row=1, minimum_col=75) == (75, 1), 'right column tag retains an inset') @@ -173,7 +173,7 @@ def run(args): extra = require(wait_for(lambda: new_serial(client, before)), 'right-column New did not create a pane') client.write(f'/pane/{extra}/body', b'RIGHT-COLUMN-NEW\n') require(wait_for(lambda: locate(client, 'RIGHT-COLUMN-NEW', minimum_col=75)), 'right-column command targeted another column') - client.write(f'/pane/{extra}/ctl', b'exec Del\n') + client.write(f'/pane/{extra}/exec', b'Del\n') checks.append('middle-click New targets the inactive right column') # An owned short-path file makes its complete tag visible. Pane-tag diff --git a/test/e2e_harness.zig b/test/e2e_harness.zig index f7f380df..5a181b78 100644 --- a/test/e2e_harness.zig +++ b/test/e2e_harness.zig @@ -92,7 +92,7 @@ pub const Harness = struct { const ws = posix.winsize{ .row = rows, .col = cols, .xpixel = 0, .ypixel = 0 }; const pid = forkpty(&master, null, null, &ws); if (pid == 0) { - for ([_][*:0]const u8{ "PARDES_9P", "PARDES_PANE", "PARDES_FORWARD_LOOK" }) |name| + for ([_][*:0]const u8{ "PARDES_PID", "PARDES_9P", "PARDES_PANE" }) |name| if (unsetenv(name) != 0) _exit(126); _ = execvp(exe, argv.ptr); _exit(127); diff --git a/test/font_size.py b/test/font_size.py index 3a0a9a28..b7104099 100644 --- a/test/font_size.py +++ b/test/font_size.py @@ -30,16 +30,16 @@ def run(args): for serial, tag in panes(client).items(): if '/+Config ' in tag: body = client.read(f'/pane/{serial}/body').decode() - if f'Font effective size: {size:.2f} pixels' in body: + if f'Font effective size {size:.2f} pixels' in body: return body return None return require(wait_for(ready), f'Font did not become {size} pixels') initial = report(18) - require('Font requested size: 18.00' in initial, 'startup size suffix ignored') + require('Font requested size 18.00' in initial, 'startup size suffix ignored') require(args.font in initial, 'requested font missing') execute(client, control, f'Font {args.font}:20.5') - require('Font requested size: 20.50' in report(20.5), 'fractional size ignored') + require('Font requested size 20.50' in report(20.5), 'fractional size ignored') execute(client, control, f'Font {args.font}') report(20.5) # no suffix preserves current size execute(client, control, f'Font {args.font}:900') diff --git a/test/fs.py b/test/fs.py index 819a78d6..c3ffa440 100644 --- a/test/fs.py +++ b/test/fs.py @@ -100,8 +100,15 @@ def session(binary, root, name, *options, socket_name=None, file=None, tty=False assert not reader.is_alive(), 'terminal reader did not stop' +def newest(client): + """The newest pane's serial: /index is ordered by serial.""" + return int(client.read('/index').splitlines()[-1].split()[0]) + + def new_pane(client, contents): - serial = int(client.read('/new').split()[0]) + """mkdir in /pane; the editor names the directory after the new serial.""" + client.mkdir('/pane', 'scratch') + serial = newest(client) if contents: client.write(f'/pane/{serial}/body', contents) return serial @@ -110,18 +117,18 @@ def new_pane(client, contents): def look(client, path, source=None): """A right click on `path` from a pane (a fresh scratch by default).""" serial = source if source is not None else new_pane(client, b'') - client.write(f'/pane/{serial}/ctl', f'look {path}\n'.encode()) - results = [int(row) for row in client.read('/ctl').split()] + client.write(f'/pane/{serial}/look', f'{path}\n'.encode()) + results = [int(row) for row in client.read('/look').split()] assert len(results) == 1 and results[0] != serial, (path, results) return results[0] def execute(client, serial, command): """A middle click on `command` from a pane.""" - client.write(f'/pane/{serial}/ctl', f'exec {command}\n'.encode()) + client.write(f'/pane/{serial}/exec', f'{command}\n'.encode()) -def walk_tree(client, path='/', skip=('/new', '/log', '/os', '/screen')): +def walk_tree(client, path='/', skip=('/log', '/os', '/screen')): """Stat every entry below `path`, as `find` does, without opening anything.""" seen = [] for name in client.list(path): @@ -138,18 +145,21 @@ def discovery(binary, embedded=False): root = Path(directory) with session(binary, root, 'discovery') as (client, _): top = client.list('/') - assert top[:9] == ['README', 'index', 'ctl', 'new', 'log', 'screen', 'listeners', 'pane', 'os'], top - assert 'self' not in top and 'cons' not in top, top + assert top[:10] == ['README', 'index', 'status', 'look', 'exec', 'log', 'screen', + 'listeners', 'pane', 'os'], top + assert 'self' not in top and 'cons' not in top and 'new' not in top, top assert ('src' in top) == embedded, (top, embedded) before = client.read('/index') guide = client.read('/README') - assert guide.count(b'\n') <= 45 and b'exec Msg' in guide and b'/new' in guide, guide + assert guide.count(b'\n') <= 45 and b'Msg hello' in guide and b'mkdir' in guide, guide assert client.stat('/README')['length'] == len(guide) # ls/stat/find over the whole tree, without opening, creates nothing. seen = walk_tree(client) names = {path for path, _ in seen} - assert {'/index', '/ctl', '/new', '/log', '/pane/1', '/pane/1/body', '/pane/1/name', - '/pane/1/sel', '/pane/1/ctl', '/pane/1/tag', '/pane/1/event'} <= names, sorted(names) + assert {'/index', '/status', '/look', '/exec', '/log', '/pane/1', '/pane/1/body', + '/pane/1/name', '/pane/1/sel', '/pane/1/ctl', '/pane/1/tag', '/pane/1/event', + '/pane/1/dot', '/pane/1/limit', '/pane/1/dirty', '/pane/1/mark', + '/pane/1/scroll', '/pane/1/look', '/pane/1/exec'} <= names, sorted(names) assert '/pane/1/pty' not in names, 'the fixture file pane grew a pty/' assert not any(name.startswith('/self') or name.endswith('/rdsel') or name.endswith('/wrsel') for name in names), sorted(names) @@ -159,18 +169,28 @@ def discovery(binary, embedded=False): assert client.read('/index') == before, 'browsing created a pane' assert client.stat('/index')['length'] == len(before) > 0 index = client.stat('/index') - assert index['mode'] == 0o444 and client.stat('/ctl')['mode'] == 0o666 + assert index['mode'] == 0o444 and client.stat('/status')['mode'] == 0o444 + assert client.stat('/exec')['mode'] == 0o666 assert client.stat('/pane/1/body')['mode'] == 0o666 and client.stat('/pane')['mode'] == 0o755 + # A range file reads the pair it takes; a flag file reads 0 or 1. + assert client.stat('/pane/1/addr')['length'] == 24 + assert client.stat('/pane/1/limit')['length'] == 0 + assert client.read('/pane/1/dirty') == b'0\n' + assert client.read('/pane/1/scroll') == b'1\n' fixture = int(before.split()[0]) assert before.split()[1:3] == [b'text', b'0'] and before.endswith(b'/discovery.txt\n'), before - # Before any command, /ctl reports the editor. - status = dict(line.split(maxsplit=1) for line in client.read('/ctl').decode().splitlines()) - assert int(status['pid']) > 0 and status['version'] and int(status['panes']) == 1, status - # /new: one pane per open, its serial is the file's content. + # /status reports the editor; /exec has nothing to report yet. + status = dict(line.split(maxsplit=1) for line in client.read('/status').decode().splitlines()) + assert int(status['pid']) > 0 and status['version'] and int(status['panes']) >= 1, status + assert client.read('/exec') == b'' + # mkdir makes a pane, named by the serial the editor gives it. log = client.open('/log') - first = int(client.read('/new').split()[0]) - second = int(client.read('/new').split()[0]) + client.mkdir('/pane', 'one') + first = newest(client) + client.mkdir('/pane', 'two') + second = newest(client) assert first != second and first != fixture, (first, second) + assert 'one' not in client.list('/pane') and 'two' not in client.list('/pane') assert client.read_fid(log) == f'new {first} {root}/+New\n'.encode() assert client.read_fid(log) == f'new {second} {root}/+New\n'.encode() assert set(client.list('/pane')) == {str(fixture), str(first), str(second)} @@ -186,51 +206,63 @@ def discovery(binary, embedded=False): assert client.read(f'/pane/{first}/name') == f'{root}/notes.txt\n'.encode() assert client.read_fid(log) == f'rename {first} {root}/notes.txt\n'.encode() assert client.stat(f'/pane/{first}/name')['length'] == len(f'{root}/notes.txt\n') + # Copying addr onto dot selects that range; sel reads and replaces it. client.write(f'/pane/{first}/addr', b'#0,#5') - client.write(f'/pane/{first}/ctl', b'dot=addr\n') + client.write(f'/pane/{first}/dot', client.read(f'/pane/{first}/addr')) + assert client.read(f'/pane/{first}/dot') == client.read(f'/pane/{first}/addr') assert client.read(f'/pane/{first}/sel') == b'first' assert client.stat(f'/pane/{first}/sel')['length'] == 5 client.write(f'/pane/{first}/sel', b'FIRST') assert client.read(f'/pane/{first}/body') == b'FIRST pane' assert client.read(f'/pane/{first}/sel') == b'' - # exec Msg shows text; exec Save writes the named file; exec Del closes. - client.write(f'/pane/{first}/ctl', b'exec Msg hello from 9P\n') + # exec Msg shows text; exec Save writes the named file; rmdir closes. + client.write(f'/pane/{first}/exec', b'Msg hello from 9P\n') assert 'hello from 9P' in ''.join(cell[0] for cell in client.screen()['cells']) - client.write(f'/pane/{first}/ctl', b'exec Save\n') + assert client.read(f'/pane/{first}/dirty') == b'1\n' + client.write(f'/pane/{first}/exec', b'Save\n') assert (root / 'notes.txt').read_bytes() == b'FIRST pane' assert client.read_fid(log) == f'save {first} {root}/notes.txt\n'.encode() - assert client.read('/ctl') == f'{first}\n'.encode() - client.write('/ctl', b'exec Del\n') + assert client.read('/exec') == f'{first}\n'.encode() + assert client.read(f'/pane/{first}/dirty') == b'0\n' + client.remove(f'/pane/{second}') assert client.read_fid(log) == f'del {second} {root}/+New\n'.encode() assert str(second) not in client.list('/pane') - # look through /ctl opens a file; the serial reads back. + # look opens a file; the serial reads back. (root / 'opened.txt').write_bytes(b'one\ntwo\nthree\n') - client.write('/ctl', f'look {root}/opened.txt:2\n'.encode()) - opened = int(client.read('/ctl')) + client.write('/look', f'{root}/opened.txt:2\n'.encode()) + opened = int(client.read('/look')) assert opened not in (fixture, first, second), opened assert client.read(f'/pane/{opened}/body') == b'one\ntwo\nthree\n' assert client.read(f'/pane/{opened}/name') == f'{root}/opened.txt\n'.encode() assert client.read_fid(log) == f'new {opened} {root}/opened.txt\n'.encode() - client.write(f'/pane/{first}/ctl', f'look {root}/opened.txt:3\n'.encode()) - assert client.read('/ctl') == f'{opened}\n'.encode(), 'a repeated look targets the open pane' - assert set(client.list('/pane')) == {str(fixture), str(first), str(opened)} + client.write(f'/pane/{first}/look', f'{root}/opened.txt:3\n'.encode()) + assert client.read('/look') == f'{opened}\n'.encode(), 'a repeated look targets the open pane' + assert {str(fixture), str(first), str(opened)} <= set(client.list('/pane')) # Writing an event record back still performs the action it names. client.write(f'/pane/{first}/body', b'Msg via event', truncate=True) client.write(f'/pane/{first}/event', b'FX0 13\n') assert 'via event' in ''.join(cell[0] for cell in client.screen()['cells']) - for bad in [b'Look x\n', b'Exec Msg x\n', b'put\n', b'name x\n', b'del\n']: + # A command line may not carry control characters, and nothing else + # in the tree may be created or removed. + refused = [lambda: client.write('/exec', b'Msg a\x00b'), + lambda: client.write('/status', b'anything\n'), + lambda: client.mkdir('/', 'x'), + lambda: client.create('/pane', 'plain-file'), + lambda: client.remove('/pane/1/body'), + lambda: client.remove('/index')] + for index, attempt in enumerate(refused): try: - client.write('/ctl', bad) + attempt() except OSError: pass else: - raise AssertionError(f'{bad!r} was accepted') + raise AssertionError(f'refusal {index} was accepted') client.close(log) if embedded: assert client.read('/src/pardes.zig').startswith(b'const std') assert client.stat('/src/pardes.zig')['mode'] == 0o444 assert b'pub const Pardes' in client.read(f'/pane/{look(client, "/virtual/src/pardes.zig")}/body') - print('9P discovery: listing/stat/find are inert; new, ctl, name, sel and log behave') + print('9P discovery: listing/stat/find are inert; create, remove, look, exec, name, sel and log behave') def test(binary, quic=False): @@ -266,7 +298,7 @@ def test(binary, quic=False): assert not (root / 'pardes-9p-renamed.sock').exists() assert named.read('/pane/1/body') == b'initial\n' with session(binary, root, 'first') as (client, address): - assert {'pane', 'index', 'new', 'ctl', 'log', 'os'} <= set(client.list('/')) + assert {'pane', 'index', 'status', 'look', 'exec', 'log', 'os'} <= set(client.list('/')) assert 'self' not in client.list('/') assert client.read('/pane/1/body') == b'initial\n' assert client.read('/os' + str(root / 'first.txt')) == b'initial\n' @@ -346,7 +378,7 @@ def test(binary, quic=False): opened = look(remote, '/n/peer/pane/' + str(serial) + '/body') assert remote.read(f'/pane/{opened}/body') == b'replaced\nevent\n' remote.write(f'/pane/{opened}/body', b'saved to peer\n', truncate=True) - remote.write(f'/pane/{opened}/ctl', b'exec Save\n') + remote.write(f'/pane/{opened}/exec', b'Save\n') assert client.read(body) == b'saved to peer\n' large = b'mounted file contents\n' * 60000 @@ -356,7 +388,7 @@ def test(binary, quic=False): assert remote.read(f'/pane/{opened}/body') == large edited = large[:-3] + b'edited\n' remote.write(f'/pane/{opened}/body', edited, truncate=True) - remote.write(f'/pane/{opened}/ctl', b'exec Save\n') + remote.write(f'/pane/{opened}/exec', b'Save\n') assert large_path.read_bytes() == edited assert client.read('/os' + str(large_path)) == edited @@ -368,12 +400,12 @@ def test(binary, quic=False): execute(remote, control, 'Mount peer ' + str(own_address)) execute(remote, control, 'Unmount peer') remote.write(f'/pane/{opened}/body', b'runtime mounted Save\n', truncate=True) - remote.write(f'/pane/{opened}/ctl', b'exec Save\n') + remote.write(f'/pane/{opened}/exec', b'Save\n') assert client.read('/pane/1/body') == b'runtime mounted Save\n' assert remote.read('/pane/1/body') == b'initial\n' roots = look(remote, '/n', source=control) assert b'/n/peer/\n' in remote.read(f'/pane/{roots}/body') - remote.write(f'/pane/{opened}/ctl', b'exec Del\n') + remote.write(f'/pane/{opened}/exec', b'Del\n') execute(remote, control, 'Unmount peer') remote.write(f'/pane/{roots}/ctl', b'get\n') assert remote.read(f'/pane/{roots}/body') == b'/n/os/\n/n/self/\n' @@ -385,7 +417,7 @@ def test(binary, quic=False): file='/n/peer/pane/1/body:1') as (remote, _): assert remote.read('/pane/1/body') == b'runtime mounted Save\n' - client.write(f'/pane/{serial}/ctl', b'exec Del\n') + client.write(f'/pane/{serial}/exec', b'Del\n') assert str(serial) not in client.list('/pane') for tty in [False, True]: @@ -424,7 +456,7 @@ def test(binary, quic=False): file_id, control_id = restored_ids contents = restored.read(f'/pane/{file_id}/body') assert contents == b'dumped state\n', (contents, saved.read_text(), restored.read('/index')) - assert restored.read(f'/pane/{control_id}/body') == b'', 'commands ran through ctl, not the body' + assert restored.read(f'/pane/{control_id}/body') == b'', 'commands ran through exec, not the body' assert restored.screen()['cols'] == 80 opened = look(restored, '/n/own/os' + str(root / (name + '.txt')), source=control_id) assert restored.read(f'/pane/{opened}/body') == b'initial\n' @@ -451,14 +483,12 @@ def test(binary, quic=False): assert client.read(f'/pane/{opened}/body') == expected assert client.read('/pane/1/body') == b'initial\n' if selected is not None: - addr = client.open(f'/pane/{opened}/addr') - client.write(f'/pane/{opened}/ctl', b'addr=dot\n') - actual = list(map(int, client.read_fid(addr).split())) - client.close(addr) + # The selection is dot; reading it takes no command at all. + actual = list(map(int, client.read(f'/pane/{opened}/dot').split())) assert actual == selected, (word, actual, selected) addr = client.open('/pane/1/addr', 2) - ctl = client.open('/pane/1/ctl', 1) - for fid, text in [(addr, b'#0,#3'), (ctl, b'limit=addr\n'), (addr, b'#0')]: + limit = client.open('/pane/1/limit', 2) + for fid, text in [(addr, b'#0,#3'), (limit, b'#0,#3'), (addr, b'#0')]: client.rpc(118, struct.pack(' req.size) return error.IncorrectReply; - const names = [_][]const u8{ "README", "index", "ctl", "new", "log", "screen", "listeners", "pane", "os" }; - const nodes = [_]u64{ @intFromEnum(ctlfs.TopFile.README), @intFromEnum(ctlfs.TopFile.index), @intFromEnum(ctlfs.TopFile.ctl), @intFromEnum(ctlfs.TopFile.new), @intFromEnum(ctlfs.TopFile.log), @intFromEnum(ctlfs.TopFile.screen), @intFromEnum(ctlfs.TopFile.listeners), @intFromEnum(ctlfs.TopFile.pane), filesystem.os_root }; + const names = [_][]const u8{ "README", "index", "status", "look", "exec", "log", "screen", "listeners", "pane", "os" }; + const nodes = [_]u64{ @intFromEnum(ctlfs.TopFile.README), @intFromEnum(ctlfs.TopFile.index), @intFromEnum(ctlfs.TopFile.status), @intFromEnum(ctlfs.TopFile.look), @intFromEnum(ctlfs.TopFile.exec), @intFromEnum(ctlfs.TopFile.log), @intFromEnum(ctlfs.TopFile.screen), @intFromEnum(ctlfs.TopFile.listeners), @intFromEnum(ctlfs.TopFile.pane), filesystem.os_root }; var off: usize = 0; var entry: usize = 0; while (off < bytes.len) : (entry += 1) { diff --git a/test/fs_namespace.zig b/test/fs_namespace.zig index 8b6f245e..3eba6639 100644 --- a/test/fs_namespace.zig +++ b/test/fs_namespace.zig @@ -245,22 +245,17 @@ test "virtual file opens do not request OS watches" { while (p.nextEffect()) |effect| if (effect == .watch) return error.VirtualFileWatch; } -test "Look at the clone file reserves its own pane and failed opens release it" { +test "Look at a virtual file opens one pane and failed opens release their slot" { const p = try pardes.Pardes.init(std.testing.allocator, .{ .tty_only = true }); defer p.deinit(); - p.lookAt(0, "/virtual/new"); - var control_count: usize = 0; - var scratch_count: usize = 0; + p.lookAt(0, "/virtual/index"); + var opened: usize = 0; for (p.panes) |slot| { const pane = slot orelse continue; const file = pane.file orelse continue; - if (std.mem.eql(u8, file.path, "/virtual/new")) control_count += 1; - if (file.output) |output| if (output.from == .cmd and output.from.cmd == .New) { - scratch_count += 1; - }; + if (std.mem.eql(u8, file.path, "/virtual/index")) opened += 1; } - try std.testing.expectEqual(@as(usize, 1), control_count); - try std.testing.expectEqual(@as(usize, 1), scratch_count); + try std.testing.expectEqual(@as(usize, 1), opened); const free = p.freeSlot().?; try std.testing.expectError(error.FileNotFound, pardes.panes.File.open(p, free, "/n/self/does-not-exist", 0)); try std.testing.expect(p.panes[free] == null); diff --git a/test/fs_soak.py b/test/fs_soak.py index 5569a7c7..a62f03e6 100644 --- a/test/fs_soak.py +++ b/test/fs_soak.py @@ -145,7 +145,7 @@ def run(args): client.write(base + '/body', body, truncate=True) path = root / f'pane-{slot}-0.zig' client.write(base + '/name', f'{path}\n'.encode()) - client.write(base + '/ctl', b'exec Save\n') + client.write(base + '/exec', b'Save\n') panes.append({'serial': serial, 'body': body, 'path': path, 'variant': 0}) emit(kind='start', seed=args.seed, session_pid=pid, transport=args.transport, host='tty' if args.tty else 'detached', @@ -187,7 +187,7 @@ def run(args): pane['variant'] ^= 1 pane['path'] = root / f'pane-{slot}-{pane["variant"]}.zig' client.write(base + '/name', f'{pane["path"]}\n'.encode()) - client.write(base + '/ctl', b'exec Save\n') + client.write(base + '/exec', b'Save\n') check_bytes(pane['path'].read_bytes(), pane['body'], 'saved file') check_bytes(client.read('/os' + str(pane['path'])), pane['body'], 'OS mount') elif operation == 'reload': @@ -196,13 +196,13 @@ def run(args): client.write(base + '/ctl', b'get\n') elif operation == 'cycle': old_serial = pane['serial'] - client.write(base + '/ctl', b'exec Del\n') + client.remove(base) pane['body'] = payload(rng) pane['serial'] = new_pane(client, pane['body']) assert pane['serial'] != old_serial base = f'/pane/{pane["serial"]}' client.write(base + '/name', f'{pane["path"]}\n'.encode()) - client.write(base + '/ctl', b'exec Save\n') + client.write(base + '/exec', b'Save\n') elif operation == 'reconnect': client.socket.close() client = Client(address) diff --git a/test/look_placement.py b/test/look_placement.py index 1341e776..8a31157f 100644 --- a/test/look_placement.py +++ b/test/look_placement.py @@ -74,7 +74,7 @@ def run_case(args, root, source_index): require('pty' in client.list(pane), 'fixture contains an existing document') marker = f'LP_{index}' markers[serial] = marker - client.write(pane + '/ctl', b'cleartag\n') + client.write(pane + '/tag', b'', truncate=True) client.write(pane + '/tag', f' {marker} Tty Del Collapse'.encode()) # Establish non-pristine shells and a stable prompt before measuring. client.write(pane + '/pty/data', f"printf 'ready-{index}\\n'\r".encode()) @@ -89,7 +89,7 @@ def run_case(args, root, source_index): require(before[serials[0]][:2] == (0, 2) and before[serials[1]][0] == 0 and before[serials[1]][1] > 2 and before[serials[2]][:2] == (75, 2), f'unexpected initial classic layout: {before}') - client.write(f'/pane/{source}/ctl', f'look {target}\n'.encode()) + client.write(f'/pane/{source}/look', f'{target}\n'.encode()) opened = require(wait_for(lambda: next((serial for serial in panes(client) if serial not in serials), None)), 'Look did not open the first document') @@ -113,7 +113,7 @@ def run_case(args, root, source_index): f'Look changed unrelated terminal {serial} rendered text') require(client.read(f'/pane/{opened}/body') == contents, 'opened document contents differ') - client.write(f'/pane/{source}/ctl', f'look {target}:2\n'.encode()) + client.write(f'/pane/{source}/look', f'{target}:2\n'.encode()) require(list(panes(client)) == serials + [opened], 'repeated Look created a duplicate pane') require(wait_for(lambda: geometry(client, markers)[1] == after), 'repeated Look changed layout') diff --git a/test/ninep.py b/test/ninep.py index 6c625951..ac4e146b 100644 --- a/test/ninep.py +++ b/test/ninep.py @@ -97,6 +97,25 @@ class Client: def close(self, fid): self.rpc(120, struct.pack(' |w| { + const bytes = w.bytes.slice(); + if (n + bytes.len > buf.len) break; + @memcpy(buf[n..][0..bytes.len], bytes); + n += bytes.len; + }, + else => {}, + }; + return buf[0..n]; + } + + // Raw tty mode forwards nearly every key to the child; the two paste + // chords are the exception, and forwarding them instead is what broke + // pasting into a terminal pane. An application that gets Ctrl-V rather + // than the text goes and reads the desktop clipboard on its own account, + // and a coding agent reading it is looking for an image, not for words. + test "raw tty paste chords type at the program instead of reaching it as keys" { + if (comptime !panes.Terminal.enabled) return error.SkipZigTest; + for ([_]bool{ false, true }) |bracketed| { + const p = try Pardes.init(std.testing.allocator, .{ .tty_only = true, .cols = 40, .rows = 12 }); + defer p.deinit(); + const pane = p.panes[0].?; + try std.testing.expectEqual(Pane.Mode.tty, pane.mode); + if (bracketed) p.update(.{ .output = .{ .pane = 0, .bytes = "\x1b[?2004h" } }); + try std.testing.expectEqual(bracketed, panes.Terminal.bracketedPaste(pane)); + p.yank = try p.gpa.dupe(u8, "one\ntwo"); // what a `y` anywhere left behind + var buf: [256]u8 = undefined; + _ = childInput(p, &buf); + + // Ctrl-V types the register straight at the program, asking the + // desktop for nothing. Under DECSET 2004 the program's own fences + // carry it, which is what stops readline RUNNING a multi-line paste. + p.update(.{ .key = .{ .cp = 'v', .ctrl = true } }); + try std.testing.expectEqualStrings( + if (bracketed) "\x1b[200~one\ntwo\x1b[201~" else "one\rtwo", + childInput(p, &buf), + ); + try std.testing.expect(p.clip_pending == null); + + // Ctrl-Shift-V is the other store: it ASKS, types nothing yet, and + // the answer lands at the program rather than in an edit buffer. A + // host that folds the Shift into the letter says the same thing. + for ([_]Key{ + .{ .cp = 'v', .ctrl = true, .shift = true }, + .{ .cp = 'V', .ctrl = true }, + }) |chord| { + p.update(.{ .key = chord }); + try std.testing.expect(p.clip_pending != null); + try std.testing.expectEqualStrings("", childInput(p, &buf)); + p.update(.{ .paste = "from-desktop" }); + try std.testing.expect(p.clip_pending == null); + try std.testing.expectEqualStrings( + if (bracketed) "\x1b[200~from-desktop\x1b[201~" else "from-desktop", + childInput(p, &buf), + ); + } + // ...and neither chord put the clipboard in the register on its way. + try std.testing.expectEqualStrings("one\ntwo", p.yank orelse ""); + } + } }; const ClickCursorTests = struct { @@ -1616,7 +1682,7 @@ test "generated output refuses every pipe prompt before seeding the tag" { const p = try Pardes.init(std.testing.allocator, .{ .tty_only = true }); defer p.deinit(); const content = try p.gpa.dupe(u8, "generated\n"); - const pane = try panes.Output.open(p, 1, "/", .{ .cmd = .Help }, "", content); + const pane = try panes.Output.open(p, p.freeSlot().?, "/", .{ .cmd = .Help }, "", content); p.active = 1; for ([_]Key{ .{ .cp = '|' }, .{ .cp = '|', .alt = true }, .{ .cp = '!' }, .{ .cp = '!', .alt = true } }) |key| { p.update(.{ .key = key }); @@ -1825,14 +1891,14 @@ test "file history construction failures preserve existing panes" { defer if (incoming) |bytes| p.gpa.free(bytes); failing.fail_index = failing.alloc_index + failure; const result = switch (case) { - .open => panes.File.open(p, 1, path, 0), + .open => panes.File.open(p, p.freeSlot().?, path, 0), .restore => panes.File.restore(p, 1, .{ .kind = .file, .tag = "", .body = "", .file = .{ .path = "/restored.zig", .content = "restored\n" }, }), - .output => panes.Output.open(p, 1, "/", .{ .cmd = .Help }, "", incoming.?), + .output => panes.Output.open(p, p.freeSlot().?, "/", .{ .cmd = .Help }, "", incoming.?), .tutor => p.openTutorView(1), .replace => p.setTestFile("replacement\n"), }; @@ -1900,14 +1966,14 @@ test "file history owns bounded snapshot storage without per-edit bookkeeping al try std.testing.expectEqual(@as(usize, 0), history.redo_len); } -test "file history allocation precedes a filesystem read with side effects" { +test "file history allocation precedes reading the served tree" { var failing = std.testing.FailingAllocator.init(std.testing.allocator, .{}); const p = try Pardes.init(failing.allocator(), .{ .tty_only = true, .cols = 40, .rows = 12 }); defer p.deinit(); const original = p.panes[0].?; const serial = p.next_serial; failing.fail_index = failing.alloc_index + 2; - try std.testing.expectError(error.OutOfMemory, panes.File.open(p, 1, "/n/self/new", 0)); + try std.testing.expectError(error.OutOfMemory, panes.File.open(p, p.freeSlot().?, "/n/self/index", 0)); try std.testing.expect(failing.has_induced_failure); try std.testing.expectEqual(original, p.panes[0].?); try std.testing.expectEqual(serial, p.next_serial); diff --git a/test/pdf.zig b/test/pdf.zig index beeb0b40..930cc5c0 100644 --- a/test/pdf.zig +++ b/test/pdf.zig @@ -1253,7 +1253,7 @@ test "PdfTint cycles pane-local state without adding tag clutter" { try std.testing.expectEqual(PdfTintMode.filtered, pv.tint); const initial_tag = try pardes.test_api.tagText(p, p.scratch.allocator(), pane); try std.testing.expect(std.mem.startsWith(u8, initial_tag, pv.path)); - try std.testing.expect(std.mem.endsWith(u8, initial_tag, " PdfSections PdfTint Collapse")); + try std.testing.expect(std.mem.endsWith(u8, initial_tag, " PdfSections PdfTint Collapse Del")); try std.testing.expect(std.mem.indexOf(u8, initial_tag, "filtered") == null); try std.testing.expect(pardes.test_api.runBuiltin( diff --git a/test/tag_cleanup.py b/test/tag_cleanup.py index 7b7d8bbf..ae0a0e66 100644 --- a/test/tag_cleanup.py +++ b/test/tag_cleanup.py @@ -36,7 +36,7 @@ def run(args): before = set(panes(client)) execute(client, control, 'Tty') tty = require(wait_for(lambda: next((s for s in panes(client) if s not in before), None)), 'terminal missing') - client.write(f'/pane/{control}/ctl', b'exec Del\n') # owned command-only scratch + client.write(f'/pane/{control}/exec', b'Del\n') # owned command-only scratch def tag_position(): frame = client.screen() diff --git a/test/ui_review.py b/test/ui_review.py index 2b6faa29..a1cdcdeb 100644 --- a/test/ui_review.py +++ b/test/ui_review.py @@ -43,7 +43,7 @@ def command(client, serial, text): current = client.read(tag) start = current.rfind(text.encode()) client.write(f'/pane/{serial}/event', f'Mx{start} {start + len(text.encode())}\n'.encode()) - client.write(f'/pane/{serial}/ctl', b'cleartag\n') + client.write(f'/pane/{serial}/tag', b'', truncate=True) client.write(tag, before[tail_start:]) def new_output(client, before): @@ -111,7 +111,7 @@ def run(args): capture(client, root, '02-find', not args.tty) if find_pane: (root / 'find-results.txt').write_bytes(client.read(f'/pane/{find_pane}/body')) - client.write(f'/pane/{find_pane}/ctl', b'exec Del\n') + client.write(f'/pane/{find_pane}/exec', b'Del\n') before = panes(client) command(client, source, 'Grep CrdsValueLabel') grep_pane = require(wait_for(lambda: new_output(client, before)), 'Grep did not return results') @@ -140,10 +140,10 @@ def run(args): (root / 'symbols-results.txt').write_bytes(client.read(f'/pane/{symbols}/body')) capture(client, root, '05-symbols', not args.tty) if symbols: - client.write(f'/pane/{symbols}/ctl', b'exec Del\n') + client.write(f'/pane/{symbols}/exec', b'Del\n') offset = original.index(b'CrdsValue {') client.write(f'/pane/{source}/addr', f'#{offset},#{offset}'.encode()) - client.write(f'/pane/{source}/ctl', b'dot=addr\nshow\n') + client.write(f'/pane/{source}/dot', client.read(f'/pane/{source}/addr')) before = panes(client) command(client, source, 'Hover') hover = wait_for(lambda: new_output(client, before), args.lsp_wait) @@ -154,7 +154,7 @@ def run(args): # Look focuses the source without changing it; gd then travels through # the host's real input parser, unlike tag builtin dispatch above. line = original[:original.index(b'impl Sanitize for CrdsValue')].count(b'\n') + 1 - client.write(f'/pane/{source}/ctl', f'look {source_path}:{line}:19\n'.encode()) + client.write(f'/pane/{source}/look', f'{source_path}:{line}:19\n'.encode()) os.write(terminal_handle['input_fd'], b'gd') time.sleep(1) capture(client, root, '07-definition', not args.tty) @@ -166,7 +166,7 @@ def run(args): report['lsp'] = info.decode() capture(client, root, '08-lsp-info', not args.tty) if lsp: - client.write(f'/pane/{lsp}/ctl', b'exec Del\n') + client.write(f'/pane/{lsp}/exec', b'Del\n') for theme in args.themes: command(client, source, 'Theme ' + theme) capture(client, root, 'theme-' + theme, not args.tty) diff --git a/test/v9fs.py b/test/v9fs.py index 16916d0b..fa35388f 100644 --- a/test/v9fs.py +++ b/test/v9fs.py @@ -43,8 +43,8 @@ def worker(mountpoint, socket, uid, gid, original_namespace): assert not any(field.startswith(('shared:', 'master:')) for field in mounted[0].split()[6:]) tree = mountpoint - assert {'os', 'index', 'pane', 'new', 'ctl', 'log', 'screen', 'README'} <= set(os.listdir(tree)) - assert 'self' not in os.listdir(tree) + assert {'os', 'index', 'pane', 'status', 'look', 'exec', 'log', 'screen', 'README'} <= set(os.listdir(tree)) + assert 'self' not in os.listdir(tree) and 'new' not in os.listdir(tree) # A direct connection provides independent evidence for VFS reads/writes. with Client(socket) as client: assert (tree / 'index').read_bytes() == client.read('/index') @@ -52,14 +52,31 @@ def worker(mountpoint, socket, uid, gid, original_namespace): before = client.read('/index') subprocess.run(['ls', '-l', str(tree), str(tree / 'pane' / '1')], check=True, capture_output=True, timeout=5) - subprocess.run(['find', str(tree / 'pane'), str(tree / 'new'), '-ls'], check=True, capture_output=True, timeout=5) + subprocess.run(['find', str(tree / 'pane'), '-ls'], check=True, capture_output=True, timeout=5) assert (tree / 'README').read_bytes() == client.read('/README') - assert (tree / 'new').stat().st_size == 0 assert client.read('/index') == before, 'browsing created panes' - serial = int((tree / 'new').read_bytes().split()[0]) - another = int((tree / 'new').read_bytes().split()[0]) - assert serial != another, 'cached factory reused a pane' - client.write(f'/pane/{another}/ctl', b'exec Del\n') + # mkdir through the kernel mount opens a pane. The editor names it + # after its serial, not after the name asked for, so the kernel's own + # revalidation of that name may fail; the index is the answer. + def serials(): + return {int(row.split()[0]) for row in (tree / 'index').read_bytes().splitlines()} + + def mkpane(name): + known = serials() + try: + (tree / 'pane' / name).mkdir() + except FileNotFoundError: + pass + made = serials() - known + assert len(made) == 1, (name, made) + return made.pop() + + serial = mkpane('kernel-made') + another = mkpane('kernel-made-again') + assert serial != another, 'a second mkdir reused a pane' + assert not (tree / 'pane' / 'kernel-made').exists() + (tree / 'pane' / str(another)).rmdir() + assert another not in serials() pane = tree / 'pane' / str(serial) wire = f'/pane/{serial}' assert str(serial) in os.listdir(tree / 'pane') @@ -101,7 +118,7 @@ def worker(mountpoint, socket, uid, gid, original_namespace): # Reading OS files through the exported tree does not recurse through # the mount: the core still lives in the supervisor's namespace. assert (mountpoint / 'os' / str(socket.parent).lstrip('/') / 'kernel.txt').read_bytes() == b'initial\n' - write_existing(pane / 'ctl', b'exec Del\n') + (tree / 'pane' / str(serial)).rmdir() assert serial not in [int(row.split()[0]) for row in (tree / 'index').read_bytes().splitlines()] print('v9fs: namespace isolation, privilege drop, inherited mount, directory refresh, ' diff --git a/test/window_opacity.py b/test/window_opacity.py index b9529373..a576b1bd 100644 --- a/test/window_opacity.py +++ b/test/window_opacity.py @@ -60,7 +60,7 @@ def run(args): pane = require(wait_for(lambda: next((serial for serial in panes(client) if serial not in before), None)), builtin + ' output missing') text = client.read(f'/pane/{pane}/body').decode() - client.write(f'/pane/{pane}/ctl', b'exec Del\n') + client.write(f'/pane/{pane}/exec', b'Del\n') return text help_text = output('Help') -- cgit v1.3 From 8fc6bb0633d7992dad6b28a2d36730689226e096 Mon Sep 17 00:00:00 2001 From: Gabriel Schneider Date: Mon, 21 Sep 2026 23:23:22 -0300 Subject: Stack a pane's transient lines instead of letting the last one win the row A pane's message, its pending leader chord and a prompt waiting for input all wanted the same row above the tagline. The prompt won it, the leader drew over whatever was there on the right, and renderBodyLayer recomputed "is anything down there" inline to reserve a single row. Three claimants, one row, and two places deciding. Pane.Notices is that decision in one place: a short ordered list of the lines a pane is showing, rebuilt every frame by collectNotices from the state that owns each one. The body layer reserves exactly notices.len rows, the way it already reserves rows for sticky context headers, and the paint pass walks the list and gives each line a row of its own, stacked upward from the tagline. Nothing stores a second copy of the truth, so a line that goes away is simply not added next frame and the rest close the gap. One notice lands on exactly the row the message always had, and the prompt stays nearest the tagline so it keeps its cursor. Last also learned what to do when the jumplist is empty. It used to walk the jumps and, finding nothing, do nothing at all -- which is the ordinary case for a pane that opened beside this one and was never focused, such as the text pane the bare tty layout puts under the shell. It now falls back to neighbourPane: the next pane down the column, wrapping, and any other live pane failing that. Alternating with the neighbour is what Last is for. Co-Authored-By: Claude Opus 5 (1M context) --- features.txt | 3 ++ src/builtins.zig | 3 ++ src/panes.zig | 28 +++++++++++++++ src/pardes.zig | 102 ++++++++++++++++++++++++++++++++++++------------------- 4 files changed, 102 insertions(+), 34 deletions(-) (limited to 'src/pardes.zig') diff --git a/features.txt b/features.txt index 7515d455..e05f6f07 100644 --- a/features.txt +++ b/features.txt @@ -136,3 +136,6 @@ gamepad subsystem. Two fields and a branch for nothing, so it went back out. Conclusion for both platforms: nothing in pardes's own logic is slow at startup. The cost is the Debug build's allocator tracing and the GPU/driver stack coming up, and the only lever on either is the build mode. + +The Last builtin should fall back to a heuristic when the jumplist has nothing to offer, so the bare tty layout -- a shell with an unfocused text pane under it -- +alternates with Last even though that text pane was never focused and is not on the jumplist. diff --git a/src/builtins.zig b/src/builtins.zig index aa2b2d6d..30a5a50f 100644 --- a/src/builtins.zig +++ b/src/builtins.zig @@ -701,6 +701,9 @@ pub const Last = struct { // Restore the cursor without recentering the pane's retained view. if (j.pane != c.id) return c.p.focusPaneLine(j.pane, .{ .line = j.line, .col = j.col }, .keep); } + // Nothing on the jumplist to go back to, which is the ordinary case + // for a pane that opened beside this one and was never focused. + if (c.p.neighbourPane(c.id)) |next| c.p.focusPaneLine(next, .{ .line = 0, .col = 0 }, .keep); } }; diff --git a/src/panes.zig b/src/panes.zig index 9a6802d0..e41698bb 100644 --- a/src/panes.zig +++ b/src/panes.zig @@ -183,6 +183,34 @@ pub const Pane = struct { tty_filter: bool = false, msg: [256]u8 = undefined, msg_len: u16 = 0, + /// The transient lines this pane shows between its body and its tagline: + /// a builtin's message, the pending leader chord, a prompt waiting for + /// input. Rebuilt every frame from the state that owns each one, so a + /// line that goes away is simply not added again and the rest close the + /// gap -- there is no second copy of the truth to fall out of step. The + /// body layer reserves exactly `len` rows for them, the way it already + /// reserves rows for sticky context headers. + notices: Notices = .{}, + + pub const Notices = struct { + /// Painted bottom-up in this order, so a prompt keeps the row nearest + /// the tagline that it has always had, and its cursor with it. + pub const Kind = enum { message, leader, prompt }; + pub const max = @typeInfo(Kind).@"enum".fields.len; + + kinds: [max]Kind = undefined, + len: u8 = 0, + + pub fn push(n: *Notices, kind: Kind) void { + if (n.len >= max) return; + n.kinds[n.len] = kind; + n.len += 1; + } + + pub fn slice(n: *const Notices) []const Kind { + return n.kinds[0..n.len]; + } + }; pub fn clearPointerSelection(pane: *Pane, slot: usize) void { if (pane.pointer_selections[slot]) |selection| { diff --git a/src/pardes.zig b/src/pardes.zig index 7e18db59..51442034 100644 --- a/src/pardes.zig +++ b/src/pardes.zig @@ -13090,6 +13090,22 @@ pub const Pardes = struct { }; } + /// The pane Last should fall back to when the jumplist has nothing: the + /// one below in this column, wrapping to the top, and any other live pane + /// failing that. A pane that opened beside this one and was never focused + /// -- the text pane the bare tty layout puts under the shell -- is not on + /// the jumplist, and alternating with it is exactly what Last is for. + pub fn neighbourPane(p: *Pardes, from: usize) ?usize { + if (layout.findPane(p, from)) |at| { + const n = p.col_n[at.col]; + if (n > 1) return p.col_panes[at.col][(at.idx + 1) % n]; + } + for (p.panes, 0..) |slot, id| { + if (slot != null and id != from) return id; + } + return null; + } + pub fn prevFocus(p: *Pardes, closing: usize) ?usize { var i = p.njumps; while (i > 0) { @@ -13359,50 +13375,54 @@ pub const Pardes = struct { pane.body_visible_rows = 0; pane.context_row_limit = null; s.body_layers[id].rows = 0; + p.collectNotices(pane, p.rects[id], id); try p.renderPane(arena, pane, p.rects[id], id, id == p.active); try p.renderBodyLayer(arena, pane, p.rects[id], id); } for (&p.panes, 0..) |*slot, id| { const pane = slot.* orelse continue; + if (pane.notices.len == 0) continue; const r = p.rects[id]; - if (r.w <= config.GUTTER or r.h <= BOX_H) continue; - const prompt_at = pane.promptAt(); - const text = if (prompt_at) |at| - pane.tagSlice()[@min(at, pane.tag_tail_len)..] - else - pane.msg[0..pane.msg_len]; - // The pending SPC path is the third thing that wants this row, and - // it can want it while the row is otherwise empty. - const leader_here = id == p.active and p.leader_on; - if (text.len == 0 and !leader_here) continue; const tx = r.x + config.GUTTER; const tw = r.w - config.GUTTER; - const row = if (p.settings.tag_bottom) r.y + r.h - 1 - BOX_H else r.y + r.h - 1; const msg_style: CellStyle = .{ .fg = if (th.fg) |c| .{ .rgb = c } else .default, .bg = if (th.bg) |c| .{ .rgb = c } else .default, }; - s.fill(tx, row, tw, 1, .{ .bg = msg_style.bg }); - if (text.len > 0) _ = s.print(tx, row, tw, text, msg_style); - if (leader_here) { - var ibuf: [16]u8 = @splat(' '); - @memcpy(ibuf[1..4], "SPC"); - var iw: usize = 4; - for (p.leader_keys[0..p.leader_n]) |ch| { - ibuf[iw + 1] = ch; - iw += 2; + // The stack sits directly above the tagline, one line to a row, in + // the order collectNotices chose. A single notice therefore lands + // on exactly the row the message used to have to itself. + const bottom = if (p.settings.tag_bottom) r.y + r.h - 1 - BOX_H else r.y + r.h - 1; + for (pane.notices.slice(), 0..) |kind, i| { + const row = bottom - @as(u16, @intCast(pane.notices.len - 1 - i)); + s.fill(tx, row, tw, 1, .{ .bg = msg_style.bg }); + switch (kind) { + .message => _ = s.print(tx, row, tw, pane.msg[0..pane.msg_len], msg_style), + .leader => { + var ibuf: [16]u8 = @splat(' '); + @memcpy(ibuf[1..4], "SPC"); + var iw: usize = 4; + for (p.leader_keys[0..p.leader_n]) |ch| { + ibuf[iw + 1] = ch; + iw += 2; + } + const w: u16 = @intCast(iw); + if (w < tw) _ = s.print(tx + tw - w, row, w, ibuf[0..iw], msg_style); + }, + .prompt => { + const at = pane.promptAt() orelse continue; + const text = pane.tagSlice()[@min(at, pane.tag_tail_len)..]; + _ = s.print(tx, row, tw, text, msg_style); + if (id != p.active) continue; + const prompt0 = (p.tagPrefix(pane) catch continue).len + at; + const col = @as(usize, pane.tag_col); + if (col >= prompt0) { + const prompt_col = panes.File.displayWidth(text[0..@min(col - prompt0, text.len)]); + if (prompt_col < tw) + s.cursor = .{ .x = tx + @as(u16, @intCast(prompt_col)), .y = row, .bar = pane.mode == .insert }; + } + }, } - const w: u16 = @intCast(iw); - if (w < tw) _ = s.print(tx + tw - w, row, w, ibuf[0..iw], msg_style); - } - if (id != p.active) continue; - const at = prompt_at orelse continue; - const prompt0 = (p.tagPrefix(pane) catch continue).len + at; - const col = @as(usize, pane.tag_col); - if (col >= prompt0) { - const prompt_col = panes.File.displayWidth(text[0..@min(col - prompt0, text.len)]); - if (prompt_col < tw) - s.cursor = .{ .x = tx + @as(u16, @intCast(prompt_col)), .y = row, .bar = pane.mode == .insert }; } } @@ -13921,12 +13941,26 @@ pub const Pardes = struct { } } + /// The one place that decides which transient lines a pane is showing and + /// in what order. Everything downstream reads the answer: the body layer + /// so it does not paint under them, and the paint pass so it can stack + /// them instead of letting the last one win the row. + fn collectNotices(p: *Pardes, pane: *Pane, r: Rect, id: usize) void { + pane.notices.len = 0; + if (r.w <= config.GUTTER or r.h <= BOX_H) return; + if (pane.msg_len > 0) pane.notices.push(.message); + if (id == p.active and p.leader_on) pane.notices.push(.leader); + if (pane.promptAt()) |at| { + if (pane.tagSlice()[@min(at, pane.tag_tail_len)..].len > 0) pane.notices.push(.prompt); + } + // Never claim so many rows that the body has none left. + pane.notices.len = @min(pane.notices.len, r.h - BOX_H -| 1); + } + fn renderBodyLayer(p: *Pardes, arena: std.mem.Allocator, pane: *Pane, r: Rect, id: usize) !void { if (!p.settings.tree_context_tag_style or pane.context_rows == 0 or pane.file == null or pane.collapsed) return; if (r.w <= config.GUTTER or r.h <= BOX_H) return; - const message = if (pane.promptAt()) |at| pane.tagSlice()[@min(at, pane.tag_tail_len)..].len > 0 else pane.msg_len > 0; - const reserve: u16 = if (message or (id == p.active and p.leader_on)) 1 else 0; - const viewport_rows = r.h - BOX_H -| reserve; + const viewport_rows = r.h - BOX_H -| @as(u16, pane.notices.len); if (viewport_rows == 0) return; // The canonical fixed grid remains available to terminal clients. The // separate body layer reserves enough rows for any compact font size. -- cgit v1.3 From e714bbfa8b7cbf9970053cfbabbb9b1f02a2290e Mon Sep 17 00:00:00 2001 From: Gabriel Schneider Date: Mon, 21 Sep 2026 23:43:31 -0300 Subject: Draw a frame only when there is one worth drawing A 9P round trip on a local Unix socket cost 9.7 ms against the SDL shell and 0.758 ms against the terminal one. The server was not slow and the wake was not broken: instrumenting the path showed every request waking the loop early (wakes=210, woke_early=212, timed_out=38 over 250 ticks) and being answered on that same pass. The cost was that `pump` answers 9P at one point in a loop that then renders and presents unconditionally, so a client's next request landed while the main thread was blocked on the display, and each round trip therefore cost a whole frame. The frame rate was governing something that has nothing to do with drawing. `Pardes.needs_frame` starts true, is set by every event except a tick with nothing animating and a filesystem request that only reads, and is cleared once a frame is presented. `pump` returns before render and present when it is false and nothing is animating. An idle editor answering reads now draws nothing at all. 9P read_fid, one RPC: gui 9.7 ms -> 0.056 ms (173x) tty 0.758 ms -> 0.062 ms (12x) Verified the shells still paint rather than going quiet: the rendered screen carries the opened file, a write through 9P redraws within the frame, and `fs-discovery-test` passes over the real wire. Suite unchanged at 778/783 with the two pre-existing crashes. Also from the adversarial review of the previous commits: `pardes --tty FILE` silently discarded the file, and `--tty MISSING` silently discarded the error pane. main.zig named the boot layout before the positional was resolved, and naming one short-circuits `Boot.of`. The choice now happens after the argument is known, and only when there is no file and no missing word. macos.zig names the same layout, so the app no longer boots a different one from the terminal and SDL shells. `pre_close_last_pane_tail` was transcribed from the NEW default rather than the old one, so the upgrade path it was added for did not exist: a workspace dumped before the tagline reorder came back with the old default welded on as a custom tail. It is now the string it claims to be. A pane two rows tall lost its message and, worse, its prompt and the cursor with it. The notice cap keeps the LAST notices now, because the prompt is last and a prompt you cannot see is one you type into blind. Co-Authored-By: Claude Opus 5 (1M context) --- docs/config.md | 4 ++-- features.txt | 17 +++++++++++++++ src/macos.zig | 4 ++++ src/main.zig | 11 ++++++---- src/pardes.zig | 69 +++++++++++++++++++++++++++++++++++++++++++++++++++++++--- 5 files changed, 96 insertions(+), 9 deletions(-) (limited to 'src/pardes.zig') diff --git a/docs/config.md b/docs/config.md index e2b95e21..8eff79a8 100644 --- a/docs/config.md +++ b/docs/config.md @@ -37,7 +37,7 @@ hosted shell, `window_opacity` the SDL GUI only, and `tagline_font_size` everything but the TTY and the board. So the TTY reports Font, TaglineSize and the scene shaders as unsupported; the browser reports Font, panel transitions and the scene shaders as unsupported, -and its TaglineSize row reads `82% (build-time only)` — tagline font size is +and its TaglineSize row reads `82 (build-time only)` — tagline font size is its own capability precisely because GUI font SELECTION is native-only while the browser still applies the compiled percentage to its DOM glyphs. The startup path is printed whether or not a file exists — that is usually when @@ -203,7 +203,7 @@ does not make those areas more opaque. Regular text, syntax colors, tagline text, terminal glyphs, and the cursor keep their normal opacity. This does not blend foreground colors into their cell backgrounds. The TTY and other non-SDL hosts do not emulate this effect; their `Config` report says -`WindowOpacity: unsupported`. +`WindowOpacity unsupported`. On native Wayland, Pardes uses an alpha-capable transparent surface. It does not use whole-window opacity protocols such as `wp_alpha_modifier_v1`, because diff --git a/features.txt b/features.txt index e05f6f07..5583e7f3 100644 --- a/features.txt +++ b/features.txt @@ -139,3 +139,20 @@ tracing and the GPU/driver stack coming up, and the only lever on either is the The Last builtin should fall back to a heuristic when the jumplist has nothing to offer, so the bare tty layout -- a shell with an unfocused text pane under it -- alternates with Last even though that text pane was never focused and is not on the jumplist. + +Before finishing: remove the zig cache, then build ReleaseSafe with the full tree-sitter options, install to ~/.local/bin, and make sure the desktop entry and anything else that launches +pardes point at the updated binaries. + +Design smell, and it is a real one: Pardes.pump serialises input, event processing, 9P servicing, rendering and presenting into one loop, so the frame rate ends up +governing things that have nothing to do with drawing. The frame rate should only govern rendering. Evidence: a 9P RPC against an idle gui session costs 19.6 ms +and ZERO editor CPU -- it is not doing work, it is sleeping out the 16 ms SDL_WaitEventTimeout because the cross-thread wake does not wake it, and 9P is only +serviced afterwards in poll_frame. The same RPC against a tty session, same cloud9 runner, is 0.758 ms. So the server is fine and the gui host loop is the problem. + +Caching optimisations for the gui: worth doing, the renderer rebuilds more per frame than it needs to. + +FIXED, and it was the frame coupling after all: pump now draws a frame only when something that can change the screen happened. Pardes.needs_frame starts true, +is set by every event except a tick with nothing animating and a read-only fs_req, and is cleared once a frame is presented; pump returns before render/present +when it is false and nothing is animating. 9P round trip on a local socket: gui 9.7 ms -> 0.056 ms (173x), tty 0.758 ms -> 0.062 ms (12x). The wake path was never +the problem -- instrumentation proved every request woke the loop early (wakes=210, woke_early=212, timed_out=38 over 250 ticks) -- the reply simply could not be +produced until the loop had finished drawing a frame it did not need. Verified the gui still paints (screen shows the file, and a write through 9P redraws) and +the full suite is unchanged at 778/783 with the two known crashes. diff --git a/src/macos.zig b/src/macos.zig index d263cfc6..83b5eac9 100644 --- a/src/macos.zig +++ b/src/macos.zig @@ -709,6 +709,10 @@ fn initCore(runtime: ?*const Runtime, cols_arg: u16, rows_arg: u16) !void { var opts: pardes.Options = .{ .tty_only = true, + // The app is a real bare-tty startup, like the terminal and SDL + // shells, so it names the same layout rather than the bare shell a + // core booted for a test gets. + .boot = .tty, .frame_allocator = allocs.frame, .image_allocator = allocs.image, .pdf_allocator = allocs.pdf, diff --git a/src/main.zig b/src/main.zig index 1cbdf24c..9abc04bf 100644 --- a/src/main.zig +++ b/src/main.zig @@ -270,10 +270,6 @@ fn nativeMain(init: std.process.Init) !void { } } opts.tty_only = explicit_tty or session_only; - // The real bare-tty startup wants the editor half present from the first - // frame, so it names that layout; a core booted for a test names none and - // gets the raw shell by itself. - if (opts.tty_only) opts.boot = .tty; opts.mounts = mounts[0..mounts_len]; if (detach != null and attach != null) badArgs(init.io, "--detach and --attach are opposites: one runs the session, the other joins one", .{}); @@ -370,6 +366,13 @@ fn nativeMain(init: std.process.Init) !void { } } } + // The real bare-tty startup wants the editor half present from the first + // frame, so it names that layout; a core booted for a test names none and + // gets the raw shell by itself. This has to come AFTER the positional is + // resolved: naming a layout short-circuits `Boot.of`, so choosing it any + // earlier threw away a file argument, and the error pane for one that does + // not exist, without a word. + if (opts.tty_only and opts.file == null and opts.missing == null) opts.boot = .tty; const found = pardes.config.User.load(init.io, arena, init.environ_map); opts.startup_config = found.bytes; opts.startup_config_path = found.path; diff --git a/src/pardes.zig b/src/pardes.zig index 51442034..e9908d65 100644 --- a/src/pardes.zig +++ b/src/pardes.zig @@ -304,7 +304,7 @@ const pre_tty_first_terminal_pane_tail = " Save Tty Del Togglettymode Filter Col const pre_mode_terminal_pane_tail = " Tty Save Del Togglettymode Filter Collapse"; // ...and the defaults from before the closing word moved to the end of every // tagline, where a click cannot land on it by overshooting the one before. -const pre_close_last_pane_tail = " Tty Collapse Del"; +const pre_close_last_pane_tail = " Tty Del Collapse"; const pre_close_last_file_pane_tail = " Save Tty Del Collapse"; const pre_close_last_pdf_pane_tail = " Tty Del PdfSections PdfTint Collapse"; const pre_close_last_terminal_pane_tail = " Tty Save Del Mode Filter Collapse"; @@ -6099,6 +6099,9 @@ pub const Pardes = struct { fs: filesystem.Namespace = .{}, boot: Boot = .shell, + /// Is there a frame worth drawing? Cleared once one is presented, set by + /// anything that can change what is on screen. The first frame always is. + needs_frame: bool = true, /// Builtins announce themselves on the message row. Off while startup /// configuration is applied: those lines are nobody clicking, and should /// not leave the row holding the name of the last one. @@ -7137,13 +7140,28 @@ pub const Pardes = struct { // A quitting frame has already freed what it would draw. if (p.quit) return; if (v.poll_frame) |f| f(h.ctx); + // Nothing to draw: do not spend a frame, and above all do not block on + // the display for one. This is what keeps the frame rate governing + // rendering and nothing else. + if (!p.needs_frame and !p.animationActive()) return; _ = p.frame_arena.reset(.retain_capacity); const surface = try p.render(p.frame_arena.allocator()); if (v.present) |f| f(h.ctx, surface); if (v.post_present) |f| f(h.ctx); + p.needs_frame = false; } pub fn update(p: *Pardes, ev: Event) void { + // Only two events cannot change the screen: a tick with nothing + // animating, and a filesystem request that only reads. The second is + // what 9P traffic overwhelmingly is, and answering it used to drag a + // whole vsync-blocked frame behind it -- which is why a round trip on + // a local socket cost a frame instead of a few microseconds. + p.needs_frame = p.needs_frame or switch (ev) { + .tick => false, + .fs_req => |req| ctlfs.changesPane(req), + else => true, + }; p.shell_rows.sweep(p.gpa); switch (ev) { .tick => {}, @@ -13953,8 +13971,17 @@ pub const Pardes = struct { if (pane.promptAt()) |at| { if (pane.tagSlice()[@min(at, pane.tag_tail_len)..].len > 0) pane.notices.push(.prompt); } - // Never claim so many rows that the body has none left. - pane.notices.len = @min(pane.notices.len, r.h - BOX_H -| 1); + // A pane only has so many rows to give. When they do not all fit the + // LAST ones survive, because the prompt is last and it is the one + // carrying the cursor: a prompt you cannot see is a prompt you type + // into blind. A two-row pane spends its only body row on one notice, + // which is what the single shared row used to do anyway. + const room: u8 = @intCast(@min(@as(u16, Pane.Notices.max), r.h - BOX_H)); + if (pane.notices.len > room) { + const drop = pane.notices.len - room; + for (0..room) |i| pane.notices.kinds[i] = pane.notices.kinds[i + drop]; + pane.notices.len = room; + } } fn renderBodyLayer(p: *Pardes, arena: std.mem.Allocator, pane: *Pane, r: Rect, id: usize) !void { @@ -14603,6 +14630,42 @@ test "Esc back into a tty leaves its view at the prompt" { try std.testing.expectEqual(live, sp.terminal.?.vt.screens.active.pages.scrollbar().offset); } +test "closing the last pane in a column leaves an empty one in its place" { + if (platform == .web) return; + const p = try Pardes.init(std.testing.allocator, .{ .tty_only = true, .cols = 120, .rows = 24 }); + defer p.deinit(); + const shell = p.active; + p.newScratchColumn(shell); + const lone = p.active; + try std.testing.expect(lone != shell); + try std.testing.expectEqual(@as(usize, 2), p.ncol); + const at = layout.findPane(p, lone).?; + try std.testing.expectEqual(@as(usize, 1), p.col_n[at.col]); + const had = try std.testing.allocator.dupe(u8, p.panes[lone].?.cwdSlice()); + defer std.testing.allocator.free(had); + + try p.removePane(lone); + p.sync(); + + // The column outlives the pane: still two columns, and the one that was + // emptied holds a fresh empty pane in the same directory. + try std.testing.expectEqual(@as(usize, 2), p.ncol); + try std.testing.expectEqual(@as(usize, 1), p.col_n[at.col]); + const heir = p.col_panes[at.col][0]; + try std.testing.expect(heir != lone); + try std.testing.expect(p.panes[lone] == null); + const hp = p.panes[heir].?; + try std.testing.expectEqualStrings("", hp.file.?.content); + try std.testing.expectEqualStrings(had, hp.cwdSlice()); + try std.testing.expectEqual(heir, p.active); + try std.testing.expect(!p.quit); + + // ...and Delcol is what actually takes the column away. + try p.removeColumn(heir); + p.sync(); + try std.testing.expectEqual(@as(usize, 1), p.ncol); +} + test "the bare tty startup opens a text pane under the shell, unfocused" { if (platform == .web) return; const p = try Pardes.init(std.testing.allocator, .{ .tty_only = true, .boot = .tty }); -- cgit v1.3 From 16717a555695ef666e9d2cd1bacc762a2ab15f4b Mon Sep 17 00:00:00 2001 From: Gabriel Schneider Date: Mon, 21 Sep 2026 23:53:58 -0300 Subject: Fixes from three adversarial reviews, and a destructive one among them The registry sweep could delete a live socket, anywhere on the filesystem. A reviewer reproduced it: a socket that is bound but has not reached listen(2) answers ECONNREFUSED exactly like a dead one -- that window is every server's startup -- and the sweep then followed the entry's symlink and unlinked whatever absolute path it named. It now follows a target only into the directory our own sockets live in and only to a `pardes-9p-*.sock` name, it re-probes immediately before deleting rather than trusting a probe that is by then several syscalls old, and a readlink that exactly filled its buffer is treated as the truncation it is. The test grew a case for an entry whose target is not ours: the entry goes, the file does not. Ctrl-V in raw tty mode was a black hole when the yank register was empty -- neither typed nor forwarded -- so vim's visual block, readline's quoted-insert and every other program's Ctrl-V simply vanished. With nothing to paste the chord belongs to the program again. The lone-ESC flush added earlier was dead code. vaxis already returns Escape for a one-byte 0x1b (`Parser.parseGround` asserts `input.len == 1`), so the carried byte it waited for can never exist; a reviewer showed a 3 ms gap and a 60 ms gap behaving identically. Removed rather than left to imply a guarantee it never provided. A shell whose editor is gone can start one again. Naming a live but unreachable session made `pardes ` exit 1, which let a stale environment variable lock someone out of their own editor; it falls through to an ordinary session, as it did before the variable existed. Also: the macOS ABI check for `pardes_topbar_pane_border_px` had been replaced by a duplicate of the line above it; `--startup` now fails on a leak the way every other measurement in that file does, and stops calling its maximum a p95 below twenty samples; the served README and the skill no longer tell you to write to `data` with `>`, which truncates the whole body before the write lands; `docs/v9fs.md` described the allocate-on-walk design that was rejected; and `test/fs.py` keys nesting off `PARDES_PID`, so its forwarding case stops passing only when the runner happens to be inside a live pardes. fs-test now reaches its one documented pre-existing failure instead of dying early. Suite 778/783 with the two known crashes. Co-Authored-By: Claude Opus 5 (1M context) --- .agents/skills/pardes-9p/SKILL.md | 6 ++-- docs/fs.md | 2 +- docs/ui-review.md | 2 +- docs/v9fs.md | 16 +++++------ features.txt | 11 ++++++++ src/9p_io.zig | 59 +++++++++++++++++++++++++++++++++------ src/fs-help.txt | 2 +- src/macos.zig | 1 + src/main.zig | 31 ++++++-------------- src/pardes.zig | 6 +++- src/tty/tty.zig | 31 -------------------- test/fs.py | 19 ++++++++++--- test/perf.zig | 9 +++++- 13 files changed, 112 insertions(+), 83 deletions(-) (limited to 'src/pardes.zig') diff --git a/.agents/skills/pardes-9p/SKILL.md b/.agents/skills/pardes-9p/SKILL.md index 91a8e864..aa856953 100644 --- a/.agents/skills/pardes-9p/SKILL.md +++ b/.agents/skills/pardes-9p/SKILL.md @@ -101,7 +101,7 @@ For a file or scratch pane, with `pane=$m/pane/`: | Append text | `echo text >> $pane/body` | `client.write(pane + '/body', b'text\n')` | | Replace all text | `echo text > $pane/body` | `client.write(pane + '/body', b'text\n', truncate=True)` | | Address a byte range | `echo '#0,#2' > $pane/addr` | `client.write(pane + '/addr', b'#0,#2')` | -| Replace that range | `echo 'pub fn' > $pane/data` | `client.write(pane + '/data', b'pub fn')` | +| Replace that range | `printf 'pub fn' >> $pane/data` | `client.write(pane + '/data', b'pub fn')` | | Read the selection | `cat $pane/dot` (offsets), `cat $pane/sel` (text) | the same two reads | | Select the addressed range | `cp $pane/addr $pane/dot` | `client.write(pane + '/dot', client.read(pane + '/addr'))` | | Reload from disk | `echo get > $pane/ctl` | `client.write(pane + '/ctl', b'get\n')` | @@ -220,8 +220,8 @@ with tempfile.TemporaryDirectory(prefix='pardes-9p-skill-') as directory: PY ``` -`new_pane` walks to `/pane/new` and reads the serial off the directory it -lands on; `execute` writes one line to a pane's `exec`. Both are in +`new_pane` opens `/pane/new` and reads the serial it answers; `execute` writes +one line to a pane's `exec`. Both are in `test/fs.py`. For terminal tests, use `session(..., tty=True)` and read [test/agent_session.py](../../../test/agent_session.py) for bounded interactive diff --git a/docs/fs.md b/docs/fs.md index 8607a26f..d1ed2b73 100644 --- a/docs/fs.md +++ b/docs/fs.md @@ -197,7 +197,7 @@ for Unix and TCP, a poll loop for QUIC, and the 9P client for mounts); `zig build fs-test` drives real sessions using the independent Python client in `test/ninep.py`; `zig build fs-discovery-test` checks that browsing -creates nothing, that the walk to `/pane/new` and a remove work, and that +creates nothing, that an open of `/pane/new` and a remove work, and that `look`, `exec`, `name`, `sel` and `log` behave. `zig build 9p-test` checks the two engine configurations' budgets (the engine's own tests are cloud9's `zig build test`); `zig build fs-bench` measures diff --git a/docs/ui-review.md b/docs/ui-review.md index 2438f2ef..58a42e61 100644 --- a/docs/ui-review.md +++ b/docs/ui-review.md @@ -198,7 +198,7 @@ Review artifacts from this pass: ## Regression checks Both native binaries built in ReleaseFast. The full TTY and SDL unit suites -passed with the inherited nesting variables `PARDES_FORWARD_LOOK`, `PARDES_9P` +passed with the inherited nesting variables `PARDES_PID`, `PARDES_9P` and `PARDES_PANE` removed from the test process. Those variables exposed an existing environment-ownership issue in native subprocess tests: libc's environment was changed while the Zig test I/O retained the old slice. This diff --git a/docs/v9fs.md b/docs/v9fs.md index 1b14c21f..cfbbd35b 100644 --- a/docs/v9fs.md +++ b/docs/v9fs.md @@ -13,16 +13,14 @@ cat "$PARDES_MOUNT/index" cat "$PARDES_MOUNT/README" cat "$PARDES_MOUNT/pane/$PARDES_PANE/body" echo 'Msg hello' > "$PARDES_MOUNT/exec" -awk '{print $1}' "$PARDES_MOUNT/pane/new/ctl" +n=$(cat "$PARDES_MOUNT/pane/new") ``` -Walking to `pane/new` opens a pane, and the walk lands on that pane's own -directory, so its `ctl` answers the serial to use afterwards. The kernel keeps -the name it walked rather than the one the server answers back, so -`pane/new` stays in the dentry cache as a name of its own; address the pane as -`pane/` once you have it, and expect a fresh path resolution of -`pane/new` to open another pane. It is not listed in `pane/`, so `ls -l` and -`find` over the mount create nothing. +**Opening** `pane/new` makes a pane, and reading that open file answers its +serial; address the pane as `pane/` from then on. Each open makes +another one, so read it once and keep the number. A *stat* makes nothing, +which is why `new` can be listed at all: `ls`, `ls -l` and `find` over the +whole mount create nothing, because none of them open it. The mount belongs to that pane's subprocess tree. Other panes and the editor core keep their original mount namespace. It works in native Linux TTY and SDL @@ -112,5 +110,5 @@ Pardes accepts this truncation without storing caller-selected timestamps; standalone timestamp, permission, and ownership changes remain unsupported. The initial kernel probe passed on this host on 2026-09-14. The broader -`fs-test` has an existing syntax-bold assertion failure at `test/fs.py:459`, +`fs-test` has an existing syntax-bold assertion failure (now `test/fs.py:615`), also reproduced on the cached editor binary preceding the truncation fix. diff --git a/features.txt b/features.txt index 5583e7f3..eeadba39 100644 --- a/features.txt +++ b/features.txt @@ -156,3 +156,14 @@ when it is false and nothing is animating. 9P round trip on a local socket: gui the problem -- instrumentation proved every request woke the loop early (wakes=210, woke_early=212, timed_out=38 over 250 ticks) -- the reply simply could not be produced until the loop had finished drawing a frame it did not need. Verified the gui still paints (screen shows the file, and a write through 9P redraws) and the full suite is unchanged at 778/783 with the two known crashes. + +Found by adversarial review and NOT fixed, because they are upstream or macOS-only rather than from this session's work: +- Surface.mark_hover is never assigned true anywhere in the tree, so the whole macOS hover ABI is inert: PARDES_CELL_HOVER is never emitted, encodeCellFlags always + contributes 0, and PardesView's liquid-glass affordance never draws. The tests pass only because they set the flag by hand. The comment in the look_hover_preview + paint block claims it carries those cells out to the hosts; it does not. +- -Dworkspace-tag is read only in src/macos.zig, and core.settings.workspace_tag is assigned only there, so the option builds cleanly for gui/tty/web and is + silently ignored. gui.zig hard-codes `true` at six taglineBandOffset call sites and still uses raw TOPBAR_H at five more. +- The detached wire encodes the pointer shape in the frame header variant (full_link/diff_link), so the newer `.target` shape collapses to `.arrow` for an attached + frontend. Fixing it means a new header variant, i.e. a protocol change. +- A shell that outlives its editor keeps PARDES_PID; if that pid is reused, `pardes ` now exits 1 instead of falling back to starting an editor. Exiting 1 + only when the socket itself refused would keep the old behaviour. diff --git a/src/9p_io.zig b/src/9p_io.zig index 3d019e0d..7f0134ed 100644 --- a/src/9p_io.zig +++ b/src/9p_io.zig @@ -671,7 +671,7 @@ pub const Listener = struct { log.warn("registry post skipped: cannot create {s}", .{svc}); return; } - sweepRegistry(l.io, svc); + sweepRegistry(l.io, svc, xdg); var entry_buf: [sun_path_len:0]u8 = undefined; const entry = std.fmt.bufPrintSentinel(&entry_buf, "{s}/{s}", .{ svc, name }, 0) catch { log.warn("registry post skipped: name too long: {s}", .{name}); @@ -903,7 +903,21 @@ fn probe(path: [:0]const u8) Probe { /// a definite refusal counts as gone. The socket a stale entry points /// at goes too, but not before a stat agrees it is a socket of ours: a /// plain file answers a connect with the same refusal. -fn sweepRegistry(io: std.Io, svc: [:0]const u8) void { +/// Is this the kind of path this editor is allowed to delete? A registry +/// entry is a symlink we wrote, but its target is just bytes on disk that +/// anyone could have pointed anywhere, so the sweep only ever follows one +/// into the directory our own sockets live in, and only to a name of the +/// shape we give them. Everything else gets its entry removed and its target +/// left strictly alone. +fn ourSocket(target: []const u8, sockets: []const u8) bool { + if (sockets.len == 0 or !std.mem.startsWith(u8, target, sockets)) return false; + if (target.len <= sockets.len or target[sockets.len] != '/') return false; + const base = target[sockets.len + 1 ..]; + if (std.mem.indexOfScalar(u8, base, '/') != null) return false; + return std.mem.startsWith(u8, base, "pardes-9p-") and std.mem.endsWith(u8, base, ".sock"); +} + +fn sweepRegistry(io: std.Io, svc: [:0]const u8, sockets: []const u8) void { if (comptime !supported) return; // The names are staged before anything is unlinked, so the sweep @@ -941,12 +955,22 @@ fn sweepRegistry(io: std.Io, svc: [:0]const u8) void { if (libc.unlink(entry) != 0) continue; reaped += 1; // A relative target would resolve against this editor's working - // directory, which says nothing about what the entry named. + // directory, which says nothing about what the entry named, and a + // readlink that exactly filled the buffer was truncated, so the path + // it produced is some other file's. if (state != .stale or n <= 0 or link_buf[0] != '/') continue; + if (@as(usize, @intCast(n)) >= link_buf.len) continue; var target_buf: [sun_path_len:0]u8 = undefined; const target = std.fmt.bufPrintSentinel(&target_buf, "{s}", .{link_buf[0..@intCast(n)]}, 0) catch continue; + if (!ourSocket(target, sockets)) continue; const t = statNoFollow(target) orelse continue; - if (t.mode & 0o170000 == 0o140000 and t.uid == libc.getuid()) _ = libc.unlink(target); + if (t.mode & 0o170000 != 0o140000 or t.uid != libc.getuid()) continue; + // Ask again, immediately before deleting. The first probe was of the + // ENTRY and is by now several syscalls old; a socket that is bound but + // has not reached listen(2) yet answers ECONNREFUSED exactly like a + // dead one, and that window is every server's startup. + if (probe(target) != .stale) continue; + _ = libc.unlink(target); } if (reaped != 0) log.info("reaped {d} stale registry entries under {s}", .{ reaped, svc }); } @@ -997,14 +1021,23 @@ test "the registry sweep takes the dead entries and leaves everything else" { return error.SkipZigTest; if (libc.mkdir(svc, 0o700) != 0) return error.SkipZigTest; - var paths: [5][sun_path_len:0]u8 = undefined; - const live_sock = try std.fmt.bufPrintSentinel(&paths[0], "{s}/live.sock", .{svc}, 0); - const dead_sock = try std.fmt.bufPrintSentinel(&paths[1], "{s}/dead.sock", .{svc}, 0); + // The sockets live where the real ones do -- beside the registry, not in + // it, and named the way a session names them -- because the sweep only + // follows an entry to a target of exactly that shape and place. + var paths: [6][sun_path_len:0]u8 = undefined; + const pid: u32 = @intCast(libc.getpid()); + const live_sock = try std.fmt.bufPrintSentinel(&paths[0], "{s}/pardes-9p-sweeplive-{d}.sock", .{ base, pid }, 0); + const dead_sock = try std.fmt.bufPrintSentinel(&paths[1], "{s}/pardes-9p-sweepdead-{d}.sock", .{ base, pid }, 0); const live = try std.fmt.bufPrintSentinel(&paths[2], "{s}/live", .{svc}, 0); const dead = try std.fmt.bufPrintSentinel(&paths[3], "{s}/dead", .{svc}, 0); const stranger = try std.fmt.bufPrintSentinel(&paths[4], "{s}/stranger", .{svc}, 0); + // A dead entry pointing at something that is NOT one of our sockets: the + // entry goes, the file it named must not. + const outsider_sock = try std.fmt.bufPrintSentinel(&paths[5], "{s}/sweep-outsider-{d}.sock", .{ base, pid }, 0); + var outsider_buf: [sun_path_len:0]u8 = undefined; + const outsider = try std.fmt.bufPrintSentinel(&outsider_buf, "{s}/outsider", .{svc}, 0); defer { - for ([_][:0]const u8{ live_sock, dead_sock, live, dead, stranger }) |p| _ = libc.unlink(p); + for ([_][:0]const u8{ live_sock, dead_sock, live, dead, stranger, outsider_sock, outsider }) |p| _ = libc.unlink(p); _ = libc.rmdir(svc); } @@ -1021,6 +1054,12 @@ test "the registry sweep takes the dead entries and leaves everything else" { try testing.expectEqual(@as(c_int, 0), libc.symlink(live_sock, live)); try testing.expectEqual(@as(c_int, 0), libc.symlink(dead_sock, dead)); + // Dead too, but its target is not one of our sockets by name, so the + // entry must go and the file it named must survive untouched. + const outside = bindSocket(outsider_sock); + try testing.expect(outside >= 0); + defer _ = libc.close(outside); + try testing.expectEqual(@as(c_int, 0), libc.symlink(outsider_sock, outsider)); // Not a symlink, so not this program's to reason about, even though // connecting to it is refused exactly like the dead socket. try std.Io.Dir.cwd().writeFile(testing.io, .{ .sub_path = stranger, .data = "" }); @@ -1058,7 +1097,7 @@ test "the registry sweep takes the dead entries and leaves everything else" { try testing.expectEqual(Probe.live, probe(live)); try testing.expectEqual(Probe.stale, probe(dead)); - sweepRegistry(testing.io, svc); + sweepRegistry(testing.io, svc, base); // Promptly, and not "eventually": a blocking probe never comes back // at all, so any wall-clock bound at all is the assertion that @@ -1071,6 +1110,8 @@ test "the registry sweep takes the dead entries and leaves everything else" { try testing.expect(statNoFollow(live) != null); try testing.expect(statNoFollow(live_sock) != null); try testing.expect(statNoFollow(stranger) != null); + try testing.expect(statNoFollow(outsider) == null); + try testing.expect(statNoFollow(outsider_sock) != null); try testing.expectEqual(Probe.live, probe(live)); } diff --git a/src/fs-help.txt b/src/fs-help.txt index 3113590a..7f55b3af 100644 --- a/src/fs-help.txt +++ b/src/fs-help.txt @@ -23,7 +23,7 @@ Below, $m is the mount point (PARDES_MOUNT in a Tty9p shell; 9ns and 9p work too cat $m/pane/$n/name; echo notes.txt > $m/pane/$n/name read, then rename echo Save > $m/pane/$n/exec save it; rmdir $m/pane/$n closes it echo 'Msg hello' > $m/exec show text in the editor - echo '#0,#5' > $m/pane/$n/addr; echo NEW > $m/pane/$n/data replace bytes 0..5 + echo '#0,#5' > $m/pane/$n/addr; printf NEW >> $m/pane/$n/data replace bytes 0..5 cp $m/pane/$n/addr $m/pane/$n/dot; cat $m/pane/$n/sel select the range, read it cat $m/pane/$n/dirty; echo 0 > $m/pane/$n/dirty is it modified? say it is not cat $m/log block until a pane is made, renamed, saved or closed diff --git a/src/macos.zig b/src/macos.zig index 83b5eac9..d3b33c55 100644 --- a/src/macos.zig +++ b/src/macos.zig @@ -2594,6 +2594,7 @@ test "pardes.h declares every export the way it is defined" { try expectSameAbi(@TypeOf(c.pardes_gui_tagline_font_percent), @TypeOf(pardes_gui_tagline_font_percent)); try expectSameAbi(@TypeOf(c.pardes_tagline_band_offset), @TypeOf(pardes_tagline_band_offset)); try expectSameAbi(@TypeOf(c.pardes_topbar_pane_border_rgb), @TypeOf(pardes_topbar_pane_border_rgb)); + try expectSameAbi(@TypeOf(c.pardes_topbar_pane_border_px), @TypeOf(pardes_topbar_pane_border_px)); try expectSameAbi(@TypeOf(c.pardes_tag_active_bg), @TypeOf(pardes_tag_active_bg)); try expectSameAbi(@TypeOf(c.pardes_tagline_origin_col), @TypeOf(pardes_tagline_origin_col)); try expectSameAbi(@TypeOf(c.pardes_grid_col_at), @TypeOf(pardes_grid_col_at)); diff --git a/src/main.zig b/src/main.zig index 9abc04bf..050cee60 100644 --- a/src/main.zig +++ b/src/main.zig @@ -112,16 +112,6 @@ const nested_text = \\ ; -/// $PARDES_PID named a live editor, so this shell IS inside one, but the Look -/// never got there. Saying so beats quietly opening the second editor that -/// $PARDES_PID exists to prevent. -const unreachable_text = - \\pardes: this shell is inside pardes, but that session did not take the - \\file. Check that it is still running, or pass --nested to start a second - \\editor in here anyway. - \\ -; - // The browser runtime calls a C main (exported below); everything else keeps // the std.process.Init entry. pub const main = if (is_emscripten) webMain else nativeMain; @@ -304,10 +294,13 @@ fn nativeMain(init: std.process.Init) !void { if (serial == 0) break :reaching null; break :reaching .{ .dial = dial, .serial = serial }; }; - const parent = found orelse { - try std.Io.File.stderr().writeStreamingAll(init.io, unreachable_text); - std.process.exit(1); - }; + // A pid we cannot reach is a session that is not answering: the shell + // says it is inside one, but there is nothing there to take the file. + // Starting an ordinary editor is what this did before the pid existed + // and is the more useful of the two answers -- refusing to start would + // leave a stale environment variable able to lock someone out of their + // own editor. + const parent = found orelse break :forwarding; // The pane's `look` file: one line, and the line is the clicked text // itself, which is what a right click in that pane would have been. var look_buf: [64]u8 = undefined; @@ -315,10 +308,7 @@ fn nativeMain(init: std.process.Init) !void { const word = positional orelse { var tag_buf: [64]u8 = undefined; const tag = try std.fmt.bufPrint(&tag_buf, "/pane/{d}/tag", .{parent.serial}); - const contents = ninep_io.Client.read(arena, parent.dial, tag, tag) catch { - try std.Io.File.stderr().writeStreamingAll(init.io, unreachable_text); - std.process.exit(1); - }; + const contents = ninep_io.Client.read(arena, parent.dial, tag, tag) catch break :forwarding; arena.free(contents); try std.Io.File.stderr().writeStreamingAll(init.io, nested_text); std.process.exit(1); @@ -332,10 +322,7 @@ fn nativeMain(init: std.process.Init) !void { const path = if (pardes.filesystem.isVirtual(target.path)) target.path else (pardes.filesystem.resolveOs(target.path, &realbuf) orelse break :forwarding).path; var command_buf: [8192]u8 = undefined; const command = std.fmt.bufPrint(&command_buf, "{s}{s}\n", .{ path, word[target.path.len..] }) catch break :forwarding; - ninep_io.Client.write(arena, parent.dial, look, command) catch { - try std.Io.File.stderr().writeStreamingAll(init.io, unreachable_text); - std.process.exit(1); - }; + ninep_io.Client.write(arena, parent.dial, look, command) catch break :forwarding; return; } if (positional) |a| { diff --git a/src/pardes.zig b/src/pardes.zig index e9908d65..5c6d2422 100644 --- a/src/pardes.zig +++ b/src/pardes.zig @@ -8368,7 +8368,11 @@ pub const Pardes = struct { // A host that folds Shift into the letter says the same thing. if (key.ctrl and !key.alt and (key.cp == 'v' or key.cp == 'V')) { if (key.shift or key.cp == 'V') return p.clipRequest(p.active, .after); - return p.typeToTty(p.active, pane, p.yank orelse return); + // With something in the register this is a paste. With nothing + // in it the chord is the program's -- vim's visual block, + // readline's quoted-insert -- and swallowing it would make + // Ctrl-V a black hole in every full-screen application. + if (p.yank) |text| return p.typeToTty(p.active, pane, text); } return panes.Terminal.forwardKey(p, p.active, key); } diff --git a/src/tty/tty.zig b/src/tty/tty.zig index a1917ba9..23b7c09b 100644 --- a/src/tty/tty.zig +++ b/src/tty/tty.zig @@ -71,21 +71,6 @@ fn inputReader(loop: *Loop, tty: anytype, cache: *vaxis.GraphemeCache) void { loop.postEvent(.quit) catch {}; } -/// How long a lone ESC waits for the rest of a sequence before it counts as -/// the Escape key. Long enough for the remainder of a real sequence to arrive -/// even over a slow link, short enough that nobody sees the delay. -const escape_hold_ms = 25; - -/// Is there more input right behind what we have already read? Only a real -/// terminal has an fd to ask; the test readers hand their parts over whole, so -/// for them the answer is always no. -fn morePending(tty: anytype) bool { - const Reader = @typeInfo(@TypeOf(tty)).pointer.child; - if (!@hasField(Reader, "fd") or @FieldType(Reader, "fd") != std.Io.File) return false; - var fds = [_]std.posix.pollfd{.{ .fd = tty.fd.handle, .events = std.posix.POLL.IN, .revents = 0 }}; - return (std.posix.poll(&fds, escape_hold_ms) catch return false) > 0; -} - fn readInput(loop: *Loop, tty: anytype, cache: *vaxis.GraphemeCache) !void { try loop.postEvent(.{ .winsize = try tty.getWinsize() }); var parser: vaxis.Parser = .{}; @@ -116,22 +101,6 @@ fn readInput(loop: *Loop, tty: anytype, cache: *vaxis.GraphemeCache) !void { } carried = end - consumed; std.mem.copyForwards(u8, buf[0..carried], buf[consumed..end]); - // A lone ESC opens most sequences and is also the Escape key, so the - // parser holds it for a remainder that a keypress never sends: the - // press would only land when the NEXT key arrived. Wait a beat, and - // when nothing follows it was the key. A terminal speaking the kitty - // protocol never reaches here — it spells Escape out in full. - if (carried == 1 and buf[0] == 0x1b and !morePending(tty)) { - carried = 0; - try vaxis.loop.handleEventGeneric( - loop, - loop.vaxis, - cache, - @TypeOf(Command.value), - @as(vaxis.Event, .{ .key_press = .{ .codepoint = vaxis.Key.escape } }), - loop.vaxis.opts.system_clipboard_allocator, - ); - } } } diff --git a/test/fs.py b/test/fs.py index b20dc8ee..c8dea2d9 100644 --- a/test/fs.py +++ b/test/fs.py @@ -470,7 +470,13 @@ def test(binary, quic=False): spaced = child_dir / 'space name.txt' spaced.write_bytes(b'first line\nsecond line\n') env = os.environ.copy() - env.update(PARDES_9P=str(address), PARDES_PANE='1', PARDES_FORWARD_LOOK='1') + # PARDES_PID is what says "you are inside a pardes"; the socket + # and the pane only say how to reach it. Without the pid the child + # starts its own session, so this test used to pass only when the + # runner itself happened to be running inside one. + status = dict(line.split(maxsplit=1) for line in client.read('/status').decode().splitlines()) + env.update(PARDES_9P=str(address), PARDES_PANE='1', PARDES_PID=status['pid']) + env.pop('PARDES_FORWARD_LOOK', None) for word, expected, selected, reuse in [('space name.txt:2:4', spaced.read_bytes(), [14, 14], False), ('/n/self/pane/1/body', b'initial\n', None, False), ('/virtual/pane/1/body:1:2-4', b'initial\n', [1, 4], True)]: @@ -518,7 +524,7 @@ def test(binary, quic=False): assert time.monotonic() < deadline, 'forwarding fixture Dump did not finish' time.sleep(.005) before = client.read('/index') - inherited = {key: env[key] for key in ['PARDES_9P', 'PARDES_PANE', 'PARDES_FORWARD_LOOK']} + inherited = {key: env[key] for key in ['PARDES_9P', 'PARDES_PANE', 'PARDES_PID']} cases = [ ('mount', ['--mount=peer=' + str(address), '/n/peer/pane/1/body'], None), ('name', ['--9p=forwarded-name'], 'forwarded-name'), @@ -543,7 +549,10 @@ def test(binary, quic=False): assert local.read('/index') == before assert local.read('/pane/1/body') == b'initial\n' else: - assert len(index) == (3 if name == 'shells' else 1), index + # A bare tty launch is a shell plus the empty text pane + # the boot puts under it; --shells=3 is the classic + # three-shell layout and has no scratch. + assert len(index) == (3 if name == 'shells' else 2), index if name in ['tcp', 'quic']: assert (name + '!127.0.0.1!').encode() in local.read('/listeners') assert client.read('/index') == before @@ -554,7 +563,9 @@ def test(binary, quic=False): ('stale-missing', dict(inherited, PARDES_9P=str(root / 'absent.sock')), 'missing-child-file.txt'), ('stale-noarg', dict(inherited, PARDES_9P=str(root / 'absent.sock')), None), ('stale-pane', dict(inherited, PARDES_PANE='4294967295'), str(spaced)), - ('disabled', dict(inherited, PARDES_FORWARD_LOOK='0'), str(spaced)), + # No pid means "not inside a pardes at all", which is what + # --nested withholds and what a plain shell has. + ('not-nested', {k: v for k, v in inherited.items() if k != 'PARDES_PID'}, str(spaced)), ]: with session(binary, root, name, tty=True, inherited=identity, launch=['--tty', *([word] if word else [])]) as (local, local_address): diff --git a/test/perf.zig b/test/perf.zig index 8f463204..5ac38ccf 100644 --- a/test/perf.zig +++ b/test/perf.zig @@ -200,6 +200,10 @@ fn measureStartup(io: std.Io, reps: usize, json: bool) !void { bytes += counter.bytes; peak = @max(peak, counter.peak); } + // Every other measurement in this file checks the session gave + // everything back; a boot that leaks is exactly what a startup + // benchmark should be the first to notice. + if (counter.live != 0) return error.LeakedStartupMemory; } std.mem.sort(u64, init_samples, {}, std.sort.asc(u64)); std.mem.sort(u64, frame_samples, {}, std.sort.asc(u64)); @@ -212,7 +216,10 @@ fn measureStartup(io: std.Io, reps: usize, json: bool) !void { .reps = reps, .cold_ns = cold_ns, .init_median_ns = init_samples[reps / 2], - .init_p95_ns = init_samples[@min(reps - 1, reps * 95 / 100)], + // A p95 needs at least twenty samples to be one; below that this + // is the maximum and says so rather than dressing it up. + .init_p95_ns = if (reps >= 20) init_samples[reps * 95 / 100] else init_samples[reps - 1], + .init_max_ns = init_samples[reps - 1], .frame_median_ns = frame_samples[reps / 2], .allocations = calls / reps, .allocated_bytes = bytes / reps, -- cgit v1.3 From 760448928186382da4ef9d942af1a2b7546ef54c Mon Sep 17 00:00:00 2001 From: Gabriel Schneider Date: Tue, 22 Sep 2026 01:24:56 -0300 Subject: Refuse a session's own mount, and paint notices as a tagline band Opening a path inside this editor's own 9P tree hung the session outright, and it is easy to do by accident: a file manager whose $EDITOR is pardes, or a Look at anything under /mnt/9p/pardes//. The realpath, the stat and the read all leave through the mount and come back as 9P requests only this editor's loop can answer, while that loop is blocked making them. The filesystem then stops answering anybody, which is what made it look frozen rather than slow. The answer has to come from the NAME, before any syscall, because the syscall is the thing that never returns: the listener notes the name it is posted under and `resolveOs` refuses a path containing `/pardes//`, with `readLimit` refusing it too for anything that gets past resolution. Another session's mount stays perfectly usable, and `/n/self/...` is the way to reach your own tree -- the editor serves it from memory without leaving the process. Reproduced before and after: the 9P write that never returned now returns, the editor stays responsive, and it spends four CPU ticks doing it. The transient lines also now look like what they were modelled on. They carried the context band's bookkeeping -- one list, rows reserved the way sticky headers reserve them -- but still painted as ordinary body text, so a message read as a stray line at the bottom of the pane rather than as part of its chrome. They take the tagline font and the tagline's own colours now, verified on a running editor: the announcement lands with font_role=tagline. Two tests the features never had: a builtin announcing itself, reaching the notice list, being overridden by Msg's own text and silenced by Verbose; and the own-mount guard, including that a session with no listener refuses nothing. Co-Authored-By: Claude Opus 5 (1M context) --- .agents/skills/pardes-9p/SKILL.md | 4 ++++ docs/fs.md | 10 ++++++++ src/9p_io.zig | 3 +++ src/fs.zig | 49 +++++++++++++++++++++++++++++++++++++++ src/pardes.zig | 42 +++++++++++++++++++++++++++++---- 5 files changed, 104 insertions(+), 4 deletions(-) (limited to 'src/pardes.zig') diff --git a/.agents/skills/pardes-9p/SKILL.md b/.agents/skills/pardes-9p/SKILL.md index aa856953..b776e407 100644 --- a/.agents/skills/pardes-9p/SKILL.md +++ b/.agents/skills/pardes-9p/SKILL.md @@ -69,6 +69,10 @@ echo "/etc/hosts:3" > "$m/look"; cat "$m/look" # open a file, see where it land rmdir "$m/pane/$n" # close it, dirty or not ``` +Do not open a session's own mount from inside that session -- a Look at +`$m/anything` in the editor that serves `$m` would deadlock it, so such paths +are refused. Use `/n/self/...` from inside; `$m/...` is for everyone else. + **Opening** `$m/pane/new` is what makes a pane, and reading the open file answers its serial — `/net/tcp/clone`'s mechanism. Each open makes another one, two reads of the same open file answer the same serial, and closing it leaves diff --git a/docs/fs.md b/docs/fs.md index d1ed2b73..6d2891e0 100644 --- a/docs/fs.md +++ b/docs/fs.md @@ -106,6 +106,16 @@ at the cost of acme's one-step `new/body`. Nothing in the tree is created by list, stat, walk or read; only that one open. Every other name in `/pane` is a serial. +A session cannot open its own tree through a mount. Looking at +`/mnt/9p/pardes//anything` from inside that very editor used to hang it +outright: the realpath, the stat and the read all leave through the mount and +come back as 9P requests only that editor's loop can answer, while the loop is +blocked making them, and the filesystem then stops answering anybody. Such a +path is now refused by name before any syscall runs, because the syscall is the +thing that never returns. Address your own tree as `/n/self/...`, which the +editor serves from memory without leaving the process. Another session's mount +is perfectly fine to open. + `/look` and `/exec` are the editor's two clicks, one per line of a write: - a line written to `look` is a right click on it: a path opens a file, diff --git a/src/9p_io.zig b/src/9p_io.zig index 7f0134ed..08deae7a 100644 --- a/src/9p_io.zig +++ b/src/9p_io.zig @@ -1358,6 +1358,9 @@ pub fn start(io: std.Io, gpa: std.mem.Allocator, core: *pardes.Pardes) ?*Listene return null; }; core.fs.socket_path = listener.path(); + // So the editor can recognise its own tree by name and refuse to walk into + // it through the mount, which would deadlock the loop that serves it. + pardes.filesystem.noteOwnSocket(listener.path()); core.fs.tcp_address = listener.tcp_address; core.fs.quic_address = listener.quic_address; return listener; diff --git a/src/fs.zig b/src/fs.zig index 7cb08980..5c75eb72 100644 --- a/src/fs.zig +++ b/src/fs.zig @@ -681,8 +681,56 @@ pub fn resolve(p: ?*pardes.Pardes, word: []const u8, cwd: []const u8, out: *[409 return null; } +/// The name this session is posted under, taken from its socket path. +var own_name_buf: [64]u8 = undefined; +var own_name_len: usize = 0; + +pub fn noteOwnSocket(socket_path: []const u8) void { + own_name_len = 0; + const base = std.fs.path.basename(socket_path); + const head = "pardes-9p-"; + const tail = ".sock"; + if (!std.mem.startsWith(u8, base, head) or !std.mem.endsWith(u8, base, tail)) return; + const name = base[head.len .. base.len - tail.len]; + if (name.len == 0 or name.len > own_name_buf.len) return; + @memcpy(own_name_buf[0..name.len], name); + own_name_len = name.len; +} + +/// Is this path inside this editor's OWN 9P tree, as a mount presents it? +/// +/// Touching one from inside the editor deadlocks the session outright: the +/// realpath, the stat and the read all leave through the mount and come back +/// as 9P requests that only the editor's loop can answer, while that loop is +/// blocked making them. The filesystem then stops answering anybody. So the +/// answer has to come from the NAME, before any syscall -- the syscall is the +/// thing that never returns. Look at `/n/self/...` instead, which the editor +/// serves from memory without leaving the process. +pub fn isOwnMount(path: []const u8) bool { + if (own_name_len == 0) return false; + var buf: [own_name_buf.len + 16]u8 = undefined; + const needle = std.fmt.bufPrint(&buf, "/pardes/{s}/", .{own_name_buf[0..own_name_len]}) catch return false; + return std.mem.indexOf(u8, path, needle) != null; +} + +test "a path inside this session's own mount is refused before any syscall" { + noteOwnSocket("/run/user/1000/pardes-9p-demo.sock"); + defer own_name_len = 0; + try std.testing.expect(isOwnMount("/mnt/9p/pardes/demo/index")); + try std.testing.expect(isOwnMount("/mnt/9p/pardes/demo/pane/new")); + try std.testing.expect(!isOwnMount("/mnt/9p/pardes/other/index")); + try std.testing.expect(!isOwnMount("/home/goblin/src/pardes/demo.zig")); + var out: [4096]u8 = undefined; + try std.testing.expect(resolveOs("/mnt/9p/pardes/demo/index", &out) == null); + + // A session with no listener has no name, so nothing is refused. + noteOwnSocket("/tmp/not-a-pardes-socket"); + try std.testing.expect(!isOwnMount("/mnt/9p/pardes/demo/index")); +} + pub fn resolveOs(path: []const u8, out: *[4096]u8) ?Resolved { if (comptime !platform_has_fs) return null; + if (isOwnMount(path)) return null; var z: [4096]u8 = undefined; const path_z = std.fmt.bufPrintSentinel(&z, "{s}", .{path}, 0) catch return null; const resolved = realpath(path_z, out) orelse return null; @@ -706,6 +754,7 @@ pub fn read(p: *pardes.Pardes, path: []const u8) ![]u8 { } pub fn readLimit(p: *pardes.Pardes, path: []const u8, max_bytes: usize) ![]u8 { + if (isOwnMount(path)) return error.OwnMount; const limit = @min(max_bytes, limits.max_file_bytes); if (std.mem.eql(u8, std.mem.trimEnd(u8, path, "/"), "/n")) { var out: std.Io.Writer.Allocating = .init(p.gpa); diff --git a/src/pardes.zig b/src/pardes.zig index 5c6d2422..ec743bc6 100644 --- a/src/pardes.zig +++ b/src/pardes.zig @@ -13387,7 +13387,7 @@ pub const Pardes = struct { s.previous_tag_layers = &.{}; s.cell_diffs = &.{}; const chrome = p.chromeTheme(); - const th = p.theme(); // the message row paints in the editor's colours + const th = p.theme(); // Separators have their own role; a scrollbar need not frame the page. s.fill(0, 0, s.cols, s.rows, .{ .bg = .{ .rgb = chrome.border } }); @@ -13407,9 +13407,14 @@ pub const Pardes = struct { const r = p.rects[id]; const tx = r.x + config.GUTTER; const tw = r.w - config.GUTTER; + // Painted the way the sticky context headers above them are: the + // tagline font and the tagline's own colours, so a notice reads as + // a band belonging to the pane rather than as a line of body text + // that happens to sit at the bottom of it. const msg_style: CellStyle = .{ - .fg = if (th.fg) |c| .{ .rgb = c } else .default, - .bg = if (th.bg) |c| .{ .rgb = c } else .default, + .fg = .{ .rgb = chrome.tag_fg }, + .bg = .{ .rgb = chrome.tag_bg }, + .font_role = .tagline, }; // The stack sits directly above the tagline, one line to a row, in // the order collectNotices chose. A single notice therefore lands @@ -13417,7 +13422,7 @@ pub const Pardes = struct { const bottom = if (p.settings.tag_bottom) r.y + r.h - 1 - BOX_H else r.y + r.h - 1; for (pane.notices.slice(), 0..) |kind, i| { const row = bottom - @as(u16, @intCast(pane.notices.len - 1 - i)); - s.fill(tx, row, tw, 1, .{ .bg = msg_style.bg }); + s.fill(tx, row, tw, 1, .{ .bg = msg_style.bg, .font_role = .tagline }); switch (kind) { .message => _ = s.print(tx, row, tw, pane.msg[0..pane.msg_len], msg_style), .leader => { @@ -14634,6 +14639,35 @@ test "Esc back into a tty leaves its view at the prompt" { try std.testing.expectEqual(live, sp.terminal.?.vt.screens.active.pages.scrollbar().offset); } +test "a builtin announces itself on the message row, and Verbose silences it" { + if (platform == .web) return; + const p = try Pardes.init(std.testing.allocator, .{ .tty_only = true, .cols = 80, .rows = 24 }); + defer p.deinit(); + const pane = p.panes[p.active].?; + + p.sync(); + try std.testing.expect(p.settings.verbose); + // Wrap, not Collapse: a builtin that folds its own pane away leaves no row + // for its announcement, which is correct and not what this is testing. + try std.testing.expect(p.executeBuiltinLine(p.active, "Wrap")); + try std.testing.expectEqualStrings("Wrap", pane.msg[0..pane.msg_len]); + + // The notice list is what the paint pass reads, so the announcement has to + // reach it, not just the buffer. + p.collectNotices(pane, p.rects[p.active], p.active); + try std.testing.expect(pane.notices.len > 0); + try std.testing.expectEqual(Pane.Notices.Kind.message, pane.notices.kinds[0]); + + // Msg owns the row itself, so it does not announce over its own text. + try std.testing.expect(p.executeBuiltinLine(p.active, "Msg hello")); + try std.testing.expectEqualStrings("hello", pane.msg[0..pane.msg_len]); + + pane.msg_len = 0; + p.settings.verbose = false; + try std.testing.expect(p.executeBuiltinLine(p.active, "Wrap")); + try std.testing.expectEqual(@as(u16, 0), pane.msg_len); +} + test "closing the last pane in a column leaves an empty one in its place" { if (platform == .web) return; const p = try Pardes.init(std.testing.allocator, .{ .tty_only = true, .cols = 120, .rows = 24 }); -- cgit v1.3 From 43b9d696f9e25ad7589527b91a74666e71ff0472 Mon Sep 17 00:00:00 2001 From: Gabriel Schneider Date: Tue, 22 Sep 2026 02:21:03 -0300 Subject: Notices become tagline bands at the top of the body A message, a leader chord and a prompt used to share one row of body text at the bottom of a pane, wearing the tagline font and nothing else about a tagline. Now each one is a TagLayer of its own, emitted through the same renderHeaderLayer the pane and column tags go through, so it gets the tagline height, the small-font metrics, the band offset and the border for free -- none of which a body-grid row can have by changing its font role. The text is right aligned. The prompt stays on the canonical grid because it owns a cursor, and a cursor has to sit on a real cell. The body starts BELOW the bands rather than under them, the way tree-sitter context rows already worked. Pane.body_offset is how many rows they took and Pardes.bodyTop(pane, rect) is the one place that answers "where does the body begin" -- replacing fifteen copies of `if (tag_bottom) r.y else r.y + BOX_H` spread across the paint, hit-test, scroll, PDF and image paths, which is what let the bands and the text under them come adrift. Every notice is painted on the grid as well, because the grid is what a terminal client draws and a band it cannot see is a message it never gets; the GUI skips grid cells a tag layer covers, so nothing is drawn twice. Three bugs the bands exposed, fixed here: - a prompt band flush with the right edge put its caret one column past the pane, which the detached wire refuses -- so every frame was dropped for as long as the prompt was open. The band now reserves that column. - a click on a band mapped to Sel row 0, which is the TAG row: clicking chrome expanded a word out of the tagline and ran it as a builtin. - a watched file reloading under the editor changed the core without going through update, so needs_frame was never set and the reload was never drawn. Pardes.invalidate() is the name for that, and the file and theme reloads call it. A session can now drive its own 9P namespace instead of being refused one: ownMountSuffix answers what a path names inside this editors own tree and resolve, readLimit and write serve it from memory rather than making the syscall that never returns. The match is anchored to whole components under the registrys 9p/pardes/, because a bare /pardes/ anywhere in a string would claim ~/src/pardes//README -- and, before write learned the same trick, write the trees bytes over the real file. readFileLimit and writeFile refuse instead, having no core to answer from. A toggle setting SETS when given `on` or `off` and only flips when it is bare, so the report LocationsConfig prints can be fed back as configuration and mean what it says. Snapshots: 97/98, from 0/98. The goldens were several commits stale and 17 scripts had stopped running; `config ` is a new script command that appends to the per-script startup config, so a script that clicks body coordinates pins `Verbose off` instead of counting the rows an announcement moves. nested-optout is left failing on purpose: two levels of nesting prepend vaxis F3 codepoints to typed lines, which is a real bug and is written down in docs/divergences.md with a repro. Co-Authored-By: Claude Opus 5 (1M context) --- docs/divergences.md | 38 +- features.txt | 30 + src/config.zig | 48 +- src/detached/client.zig | 26 +- src/detached/wire.zig | 7 +- src/file_watch.zig | 2 + src/fs.zig | 124 +++- src/gui/gui.zig | 25 +- src/panes.zig | 42 +- src/pardes.zig | 328 +++++++-- src/tag_layer.zig | 6 +- test/e2e_harness.zig | 12 + test/fs.py | 6 +- test/output.zig | 4 +- test/panes.zig | 32 +- test/snapshot.zig | 8 +- test/snapshots/argv.golden | 33 +- test/snapshots/badutf.golden | 8 +- test/snapshots/boot.golden | 64 +- test/snapshots/builtins.golden | 27 +- test/snapshots/builtins.snap | 19 +- test/snapshots/chordcut.golden | 115 +-- test/snapshots/cmdword.golden | 16 +- test/snapshots/cmdword.snap | 4 + test/snapshots/collapse.golden | 79 +- test/snapshots/cornerdrag-left.golden | 32 +- test/snapshots/cornerdrag.golden | 48 +- test/snapshots/cursorline.golden | 72 +- test/snapshots/doccol.golden | 10 +- test/snapshots/doccol.snap | 4 + test/snapshots/dump.golden | 13 +- test/snapshots/edit.golden | 66 +- test/snapshots/exec-bigdrag.golden | 6 +- test/snapshots/exec-bigdrag.snap | 4 + test/snapshots/exec.golden | 39 +- test/snapshots/exec.snap | 2 +- test/snapshots/fileedit.golden | 8 +- test/snapshots/filewatch.golden | 33 +- test/snapshots/filewatch.snap | 4 + test/snapshots/find.golden | 177 +++-- test/snapshots/fsearch.golden | 161 ++-- test/snapshots/fsearch.snap | 9 +- test/snapshots/ghostty-mid.golden | 6 +- test/snapshots/grep.golden | 35 +- test/snapshots/grep.snap | 9 +- test/snapshots/hscroll.golden | 24 +- test/snapshots/images.golden | 132 ++-- test/snapshots/jumps.golden | 217 ++++-- test/snapshots/layout-close.golden | 29 +- test/snapshots/layout-open.golden | 20 +- test/snapshots/leader.golden | 81 +-- test/snapshots/load.golden | 66 +- test/snapshots/logquiet.golden | 4 +- test/snapshots/look-center.golden | 38 +- test/snapshots/look-dir.golden | 14 +- test/snapshots/look-file-1col.golden | 8 +- test/snapshots/look-file.golden | 74 +- test/snapshots/lookloaded.golden | 28 +- test/snapshots/lookpanes.golden | 114 +-- test/snapshots/lookpanes.snap | 4 + test/snapshots/lookrange.golden | 179 +++-- test/snapshots/lookrange.snap | 8 +- test/snapshots/lsp-client-edit.golden | 44 +- test/snapshots/lsp-client.golden | 40 +- test/snapshots/lsp-rename.golden | 29 +- test/snapshots/lsp.golden | 56 +- test/snapshots/lspcomplete.golden | 28 +- test/snapshots/lspcompletemoved.golden | 4 +- test/snapshots/lspdebug.golden | 4 +- test/snapshots/lspdebug.snap | 7 + test/snapshots/lsprelpath.golden | 162 +++-- test/snapshots/markup.golden | 104 +-- test/snapshots/mini.golden | 234 +++--- test/snapshots/modal.golden | 86 +-- test/snapshots/msg.golden | 93 ++- test/snapshots/multicursor.golden | 82 +-- test/snapshots/nested.golden | 69 +- test/snapshots/ninep.golden | 288 ++++---- test/snapshots/pipe.golden | 20 +- test/snapshots/psearch.golden | 140 ++-- test/snapshots/reflow.golden | 12 +- test/snapshots/respawn.golden | 10 +- test/snapshots/respawn.snap | 2 +- test/snapshots/restore.golden | 6 +- test/snapshots/rsearch.golden | 42 +- test/snapshots/rsearch.snap | 11 +- test/snapshots/savepane.golden | 20 +- test/snapshots/scroll.golden | 66 +- test/snapshots/scrolloff.golden | 4 +- test/snapshots/selarg.golden | 6 +- test/snapshots/selregex.golden | 121 ++-- test/snapshots/shellset.golden | 12 +- test/snapshots/shrinktag.golden | 12 +- test/snapshots/splitparent.golden | 26 +- test/snapshots/stepgrain.golden | 131 ++-- test/snapshots/syntax.golden | 183 ++--- test/snapshots/tag.golden | 23 +- test/snapshots/tagalign.golden | 32 +- test/snapshots/tagalign2col.golden | 21 +- test/snapshots/tagbottom.golden | 36 +- test/snapshots/tagbottom.snap | 15 +- test/snapshots/tagbottomimage.golden | 126 ++-- test/snapshots/tagbottomshort.golden | 40 +- test/snapshots/tagcmd.golden | 30 +- test/snapshots/tagnav.golden | 101 +-- test/snapshots/tagpath.golden | 84 +-- test/snapshots/theme.golden | 1248 ++++++++++++++++---------------- test/snapshots/themesel.golden | 1194 +++++++++++++++--------------- test/snapshots/tinywin.golden | 94 ++- test/snapshots/topbarexec.golden | 27 +- test/snapshots/tty.golden | 33 +- test/snapshots/ttyclick.golden | 10 +- test/snapshots/ttyedit.golden | 10 +- test/snapshots/ttyfollow.golden | 10 +- test/snapshots/ttyhelp.golden | 37 +- test/snapshots/ttyhelp.snap | 5 +- test/snapshots/ttylook.golden | 79 +- test/snapshots/ttyonly.golden | 81 ++- test/snapshots/ttypaste.golden | 6 +- test/snapshots/ttyprompt.golden | 10 +- test/snapshots/ttytaken.golden | 22 +- test/snapshots/tutor.golden | 8 +- test/snapshots/wheeldrift.golden | 16 +- test/snapshots/winch.golden | 12 +- test/snapshots/windownav.golden | 63 +- test/snapshots/windowops.golden | 108 +-- test/snapshots/wrap.golden | 36 +- test/snapshots/yankpaste.golden | 4 +- 128 files changed, 4912 insertions(+), 3744 deletions(-) (limited to 'src/pardes.zig') diff --git a/docs/divergences.md b/docs/divergences.md index fada830c..6679d962 100644 --- a/docs/divergences.md +++ b/docs/divergences.md @@ -43,17 +43,41 @@ there, deliberately, because that box serves a public site. ## Known-failing on `main`, not caused by the 9P work -* **`zig build fs-test`** fails on a syntax-highlighting assertion — the - word `fn` is expected bold and comes back unstyled: +* **`zig build snap` fails `nested-optout`, and the cause is a real bug.** + At the SECOND level of nesting -- a pardes whose shell runs a pardes whose + shell runs a command -- two U+E016 codepoints are prepended to whatever is + typed. U+E016 is 57366, which is vaxis's private-use spelling of **F3** + (`Key.zig`, "kitty encodes these keys directly in the private use area"), so + something in the chain is decoding a capability-query REPLY as a key and + forwarding it to the shell as text. bash then sees + `$'\356\200\226\356\200\226echo'` and answers `command not found`; with a + path it answers `No such file or directory` for a path that exists and runs + perfectly from the same shell a moment later. + + Minimal repro, in a snapshot script: ``` - AssertionError: ('fn', [{'fg': {'rgb': [201, 176, 228]}, ..., 'bold': False}, ...]) + dirmk innerdir + file innerdir/deeper.txt deepest-marker\n + start 31 100 + wait 8000 $ + stable 700 20000 + text (cd innerdir && $(readlink /proc/$PPID/exe) --nested) + key enter + wait 20000 cwd/innerdir + stable 700 20000 + text E=$(readlink /proc/$PPID/exe); "$E" deeper.txt + key enter + settle 5000 + stable 700 10000 + snap probe ``` - Verified by restoring `main`'s own `src/9p_io.zig`, `build.zig` and - `build.zig.zon` and re-running: it fails identically. The editor line - (`rruwvuzm`) has substantial `src/syntax.zig` changes and may well be the - fix in progress. + `bash: E=/home/.../pardes: No such file or directory` -- bash did not even + parse the assignment, because the line does not start where it looks like it + starts. `--nested` is exactly the flag meant to opt a child out of this, so + the fix belongs next to the key-forwarding path in `panes.Terminal.forwardKey` + and whatever answers terminal capability queries on a nested stdin. * **pardes does not start headless.** `pardes --9p=` with no terminal exits 1 from the argument-forwarding path; the installed build fails diff --git a/features.txt b/features.txt index eeadba39..d035648a 100644 --- a/features.txt +++ b/features.txt @@ -167,3 +167,33 @@ Found by adversarial review and NOT fixed, because they are upstream or macOS-on frontend. Fixing it means a new header variant, i.e. a protocol change. - A shell that outlives its editor keeps PARDES_PID; if that pid is reused, `pardes ` now exits 1 instead of falling back to starting an editor. Exiting 1 only when the socket itself refused would keep the old behaviour. + +Notices are tagline bands at the TOP of the body now, not a row of body text at the bottom. Each message or leader prefix is emitted through the same +renderHeaderLayer the pane and column tags use, as a TagLayer of the new `.notice` kind, so it gets the tagline's height, its small-font metrics, its band +offset and its border for free -- none of which a body-grid row can have just by wearing a tagline font. The text is right aligned. The prompt stays on the +canonical grid because it owns a cursor, which has to sit on a real cell. + +The body starts BELOW the bands rather than under them: Pane.body_offset is the number of rows they take, and every painter and hit test derives the body's +first row from Pardes.bodyTop(pane, rect). That replaced fifteen copies of `if (tag_bottom) r.y else r.y + BOX_H` scattered across the paint and pointer paths, +which is what let the bands and the text they sit over come adrift in the first place. renderBodyLayer zeroes the offset around its own render, because it +paints into a surface of its own that carries no bands. + +Every notice is ALSO painted on the canonical grid, because the grid is what a terminal client draws and a band it cannot see is a message it never gets. The +GUI skips grid cells a tag layer covers, so nothing is drawn twice there. + +Snapshot suite: 97/98. The goldens were several commits stale (Delcol on the column tagline, the closing word moved last in every +tagline, the bare-tty boot's empty pane, stacked Locations rows, the notice bands) and 17 scripts had stopped running at all. Fixed +by making the scripts say what they mean rather than by loosening them: `config ` is a new snapshot-script command that appends +to the per-script startup config, so a script that clicks body coordinates can pin `Verbose off` instead of counting the rows an +announcement band moves; `@word` column specs replace counted columns where a tagline word has moved; and two grids grew because a +pane tag is wider now than its `Del` could fit in. + +Found by that pass and fixed: a watched file reloading under the editor changed the core WITHOUT going through `update`, so +`needs_frame` was never set and the reload was never drawn. `Pardes.invalidate()` is the name for "something changed me from +outside the event loop"; `reloadWatchedFile` and the theme reload call it. + +Also from it: a toggle setting now SETS when given `on` or `off` and only flips when it is bare, so `writeReport`'s `Verbose on` +means what it says when fed back as configuration -- the symmetry the report was asked for, on the input side too. + +Left failing, deliberately: `nested-optout`. See docs/divergences.md -- two levels of nesting prepend U+E016 (vaxis's F3) to typed +lines, which is a real bug in the key-forwarding path and not a stale expectation. diff --git a/src/config.zig b/src/config.zig index 81fefd2c..98bbf3f4 100644 --- a/src/config.zig +++ b/src/config.zig @@ -677,7 +677,9 @@ pub const Runtime = struct { pub fn takesArg(setting: Setting) bool { return switch (setting.action) { - .shell, .theme, .font, .tagline_size, .window_opacity, .window_blur => true, + // A toggle flips when it is a bare tagline word and SETS when + // it is given `on` or `off`, so the report is configuration. + .shell, .theme, .font, .tagline_size, .window_opacity, .window_blur, .toggle => true, else => false, }; } @@ -781,9 +783,23 @@ pub const Runtime = struct { pub fn apply(state: *Runtime, setting: Setting, argument: ?[]const u8) bool { switch (setting.action) { // Every toggle names a bool field of its own, so one line covers - // all of them and a new toggle needs no arm here. - .toggle => |field| switch (field) { - inline else => |f| @field(state, @tagName(f)) = !@field(state, @tagName(f)), + // all of them and a new toggle needs no arm here. Bare, a toggle + // flips -- that is what a tagline word is for. With `on` or `off` + // it SETS, so the report `writeReport` prints (`Verbose on`) can + // be fed straight back as configuration and mean what it says. + .toggle => |field| { + const text = std.mem.trim(u8, argument orelse "", " \t\r\n"); + const want: ?bool = if (text.len == 0) + null + else if (std.mem.eql(u8, text, "on")) + true + else if (std.mem.eql(u8, text, "off")) + false + else + return false; + switch (field) { + inline else => |f| @field(state, @tagName(f)) = want orelse !@field(state, @tagName(f)), + } }, .shell => { const value = std.mem.trim(u8, argument orelse return false, " \t\r\n"); @@ -977,12 +993,34 @@ pub const Runtime = struct { for (settings[i + 1 ..]) |later| try std.testing.expect(!std.mem.eql(u8, setting.word, later.word)); try std.testing.expectEqual(switch (setting.action) { - .shell, .theme, .font, .tagline_size, .window_opacity, .window_blur => true, + .shell, .theme, .font, .tagline_size, .window_opacity, .window_blur, .toggle => true, else => false, }, setting.takesArg()); } } + test "a toggle flips when bare and sets when told on or off" { + var state: Runtime = .{}; + const verbose = find("Verbose").?; + try std.testing.expect(state.verbose); + // Bare, it flips: that is what a tagline word does. + try std.testing.expect(apply(&state, verbose, null)); + try std.testing.expect(!state.verbose); + // Told, it SETS -- twice over, so the second call proves it is not + // flipping past the value it was given. + try std.testing.expect(apply(&state, verbose, "on")); + try std.testing.expect(state.verbose); + try std.testing.expect(apply(&state, verbose, " on\n")); + try std.testing.expect(state.verbose); + try std.testing.expect(apply(&state, verbose, "off")); + try std.testing.expect(!state.verbose); + try std.testing.expect(apply(&state, verbose, "off")); + try std.testing.expect(!state.verbose); + // And anything else is refused rather than silently flipping. + try std.testing.expect(!apply(&state, verbose, "maybe")); + try std.testing.expect(!state.verbose); + } + test "simple setting application mutates only its plain field" { var state: Runtime = .{}; try std.testing.expect(apply(&state, find("Colors").?, null)); diff --git a/src/detached/client.zig b/src/detached/client.zig index 9481cd54..a027c0bb 100644 --- a/src/detached/client.zig +++ b/src/detached/client.zig @@ -1266,8 +1266,32 @@ test "detached session: a frontend that stops reading is dropped, not waited for // for, which is the whole claim: one slow peer costs its own slot. try testing.expect(h.session.clients[0].attached); try testing.expect(!h.core.quit); + // A message is a tagline band now, not a grid run, so "still being drawn + // for" is checked on the layers the frontend decoded rather than on nruns. try good.send(.{ .event = .{ .command = "Msg still here" } }); - try testing.expect((try h.pumpUntilChange(&good)).nruns > 0); + try testing.expect(try pumpUntilNotice(&h, &good, "still here")); +} + +/// Pump until this client has a notice band carrying `want`. +fn pumpUntilNotice(h: *Harness, c: *Client, want: []const u8) !bool { + var line: [256]u8 = undefined; + for (0..Harness.rounds) |_| { + try h.pump(); + try c.wait(5); + while (try c.next()) |_| {} + for (&c.tag_layers) |*layer| { + if (layer.cols == 0 or layer.kind != .notice) continue; + var n: usize = 0; + for (layer.cells[0..layer.cols]) |cell| { + const g = cell.grapheme(); + if (n + g.len > line.len) break; + @memcpy(line[n..][0..g.len], g); + n += g.len; + } + if (std.mem.indexOf(u8, line[0..n], want) != null) return true; + } + } + return false; } /// A connected socket with nothing said on it yet, for the tests whose peer is diff --git a/src/detached/wire.zig b/src/detached/wire.zig index 245bc9f4..6805d980 100644 --- a/src/detached/wire.zig +++ b/src/detached/wire.zig @@ -4,7 +4,10 @@ const std = @import("std"); const pardes = @import("../pardes.zig"); const limits = @import("../memory.zig").limits; -pub const version: u16 = 6; +/// 7: tag layers gained the `.notice` kind, so a frame can carry a tag value +/// an older frontend would reject mid-session. The greeting is where that has +/// to be refused, which is what this number is for. +pub const version: u16 = 7; pub const Error = error{ Truncated, Overlong, BadTag, BadValue, Trailing, NoSpace }; @@ -220,7 +223,7 @@ pub const Frame = struct { layer.viewport.y >= f.rows or (switch (layer.kind) { .workspace => layer.id != 0, .column => layer.id >= pardes.MAX_COLS, - .pane => layer.id >= pardes.MAX_PANES, + .pane, .notice => layer.id >= pardes.MAX_PANES, })) return error.BadValue; const cursor = try getCursor(&r, layer.cols, 1); layer.cursor = if (cursor) |c| .{ .col = c.x, .bar = c.bar } else null; diff --git a/src/file_watch.zig b/src/file_watch.zig index b2b7e380..b2908eb7 100644 --- a/src/file_watch.zig +++ b/src/file_watch.zig @@ -577,6 +577,7 @@ pub fn reloadTheme( if (watches[theme_slot]) |*entry| remarkFile(entry, request.path); } const bytes = filesystem.readFile(gpa, request.path) catch |err| { + core.invalidate(); core.failThemeFile(watched.serial, err); return false; }; @@ -587,6 +588,7 @@ pub fn reloadTheme( .pdf => unreachable, } if (!core.loadThemeFile(watched.serial, bytes, true)) return false; + core.invalidate(); const live = if (watches[theme_slot]) |*entry| entry else return false; if (live.serial != watched.serial) return false; live.generation = .{ .text = hash }; diff --git a/src/fs.zig b/src/fs.zig index 5c75eb72..9200236d 100644 --- a/src/fs.zig +++ b/src/fs.zig @@ -65,6 +65,9 @@ pub const WriteError = error{ }; pub fn writeFile(path: []const u8, bytes: []const u8) WriteError!void { + // No core here to answer from, so the only safe answer is no answer: an + // open(2) into our own mount is the call that never returns. + if (isOwnMount(path)) return error.OpenFailed; var pathbuf: [4096:0]u8 = undefined; if (path.len >= pathbuf.len) return error.PathTooLong; if (std.mem.indexOfScalar(u8, path, 0) != null) return error.OpenFailed; @@ -671,6 +674,9 @@ pub fn resolve(p: ?*pardes.Pardes, word: []const u8, cwd: []const u8, out: *[409 } if (std.mem.eql(u8, joined, "/virtual")) return resolveVirtual(p, "/", out); if (std.mem.startsWith(u8, joined, "/virtual/")) return resolveVirtual(p, joined[8..], out); + // This editor's own tree, seen through a mount: answer from the tree + // instead of walking out into the view and back in. + if (ownMountSuffix(joined)) |inner| return resolveVirtual(p, inner, out); if (resolveOs(joined, out)) |found| return found; if (resolveVirtual(p, joined, out)) |found| return found; if (resolveVirtual(p, word, out)) |found| return found; @@ -682,7 +688,9 @@ pub fn resolve(p: ?*pardes.Pardes, word: []const u8, cwd: []const u8, out: *[409 } /// The name this session is posted under, taken from its socket path. -var own_name_buf: [64]u8 = undefined; +/// As wide as a name a listener will accept, so there is no session whose +/// name is too long to recognise and therefore too long to protect. +var own_name_buf: [108]u8 = undefined; var own_name_len: usize = 0; pub fn noteOwnSocket(socket_path: []const u8) void { @@ -697,35 +705,91 @@ pub fn noteOwnSocket(socket_path: []const u8) void { own_name_len = name.len; } -/// Is this path inside this editor's OWN 9P tree, as a mount presents it? +/// What this path names inside this editor's OWN 9P tree, if it does: +/// `/mnt/9p/pardes//pane/3/body` -> `pane/3/body`, and the mount root +/// itself -> `/`. /// -/// Touching one from inside the editor deadlocks the session outright: the -/// realpath, the stat and the read all leave through the mount and come back -/// as 9P requests that only the editor's loop can answer, while that loop is -/// blocked making them. The filesystem then stops answering anybody. So the -/// answer has to come from the NAME, before any syscall -- the syscall is the -/// thing that never returns. Look at `/n/self/...` instead, which the editor -/// serves from memory without leaving the process. -pub fn isOwnMount(path: []const u8) bool { - if (own_name_len == 0) return false; +/// A mount is a VIEW of a tree this editor already holds. Going out through +/// the view to reach it deadlocks the session outright -- the realpath, the +/// stat and the read all leave through the mount and come back as 9P requests +/// only this editor's loop can answer, while that loop is blocked making them, +/// and the filesystem then stops answering anybody. So the view is recognised +/// by NAME, before any syscall (the syscall is the thing that never returns), +/// and the request is served from the tree directly. Same answer, no round +/// trip, and a session can drive itself through its own 9P namespace. +pub fn ownMountSuffix(path: []const u8) ?[]const u8 { + if (own_name_len == 0 or path.len == 0 or path[0] != '/') return null; + // Whole components, and the registry's own layout: a session is posted at + // `/9p/pardes/` and mounts group under `/mnt/9p/pardes/`. + // Matching a bare `/pardes/` anywhere in the string would claim + // `~/src/pardes//README` -- an ordinary directory that happens to + // read like a mount -- and serve the tree's README over the real file. var buf: [own_name_buf.len + 16]u8 = undefined; - const needle = std.fmt.bufPrint(&buf, "/pardes/{s}/", .{own_name_buf[0..own_name_len]}) catch return false; - return std.mem.indexOf(u8, path, needle) != null; + const stem = std.fmt.bufPrint(&buf, "/9p/pardes/{s}", .{own_name_buf[0..own_name_len]}) catch return null; + var at: usize = 0; + while (std.mem.indexOfPos(u8, path, at, stem)) |found| : (at = found + 1) { + const rest = path[found + stem.len ..]; + if (rest.len != 0 and rest[0] != '/') continue; // a longer name that merely starts the same + if (rest.len <= 1) return "/"; + return rest[1..]; + } + return null; } -test "a path inside this session's own mount is refused before any syscall" { +pub fn isOwnMount(path: []const u8) bool { + return ownMountSuffix(path) != null; +} + +test "a path inside this session's own mount is answered from the tree, not through the mount" { noteOwnSocket("/run/user/1000/pardes-9p-demo.sock"); defer own_name_len = 0; - try std.testing.expect(isOwnMount("/mnt/9p/pardes/demo/index")); - try std.testing.expect(isOwnMount("/mnt/9p/pardes/demo/pane/new")); - try std.testing.expect(!isOwnMount("/mnt/9p/pardes/other/index")); - try std.testing.expect(!isOwnMount("/home/goblin/src/pardes/demo.zig")); + // What the path names inside the tree, with the mount prefix taken off. + try std.testing.expectEqualStrings("index", ownMountSuffix("/mnt/9p/pardes/demo/index").?); + try std.testing.expectEqualStrings("pane/new", ownMountSuffix("/mnt/9p/pardes/demo/pane/new").?); + try std.testing.expectEqualStrings("/", ownMountSuffix("/mnt/9p/pardes/demo").?); + try std.testing.expectEqualStrings("/", ownMountSuffix("/mnt/9p/pardes/demo/").?); + // The registry posts the session there too, so that spelling counts. + try std.testing.expectEqualStrings("index", ownMountSuffix("/run/user/1000/9p/pardes/demo/index").?); + // Another session's mount is somebody else's to answer, and a name that + // merely STARTS with ours is a different name. + try std.testing.expect(ownMountSuffix("/mnt/9p/pardes/other/index") == null); + try std.testing.expect(ownMountSuffix("/mnt/9p/pardes/demo2/index") == null); + // An ordinary directory that reads like a mount is an ordinary directory. + // Serving the tree here would hand back the tree's README for the file on + // disk, and -- before `write` learned the same trick -- write the tree's + // bytes over it. + try std.testing.expect(ownMountSuffix("/home/goblin/src/pardes/demo/README") == null); + try std.testing.expect(ownMountSuffix("/home/goblin/src/pardes/demo.zig") == null); + // Relative paths never name a mount: they are resolved against a cwd first. + try std.testing.expect(ownMountSuffix("mnt/9p/pardes/demo/index") == null); + + // The syscall is the thing that never returns, so it is never made. var out: [4096]u8 = undefined; try std.testing.expect(resolveOs("/mnt/9p/pardes/demo/index", &out) == null); - // A session with no listener has no name, so nothing is refused. + // A session with no listener has no name, so nothing is redirected. noteOwnSocket("/tmp/not-a-pardes-socket"); - try std.testing.expect(!isOwnMount("/mnt/9p/pardes/demo/index")); + try std.testing.expect(ownMountSuffix("/mnt/9p/pardes/demo/index") == null); +} + +test "reading this session's own mount returns what the tree holds" { + const p = try pardes.Pardes.init(std.testing.allocator, .{ .tty_only = true, .cols = 80, .rows = 24 }); + defer p.deinit(); + noteOwnSocket("/run/user/1000/pardes-9p-selfread.sock"); + defer own_name_len = 0; + + const direct = try read(p, "/n/self/index"); + defer p.gpa.free(direct); + const mounted = try read(p, "/mnt/9p/pardes/selfread/index"); + defer p.gpa.free(mounted); + try std.testing.expectEqualStrings(direct, mounted); + try std.testing.expect(direct.len > 0); + + // A write goes to the same tree the read came from, not out through the + // mount: `/index` is 0400 there, and an OS write would instead try to + // create a file under a directory that does not exist. + try std.testing.expectError(error.ReadOnlyFilesystem, write(p, "/mnt/9p/pardes/selfread/index", "nope\n")); + try std.testing.expectError(error.ReadOnlyFilesystem, write(p, "/n/self/index", "nope\n")); } pub fn resolveOs(path: []const u8, out: *[4096]u8) ?Resolved { @@ -754,7 +818,13 @@ pub fn read(p: *pardes.Pardes, path: []const u8) ![]u8 { } pub fn readLimit(p: *pardes.Pardes, path: []const u8, max_bytes: usize) ![]u8 { - if (isOwnMount(path)) return error.OwnMount; + // The same view, reached by a reader that never went through `resolve`. + // The rewritten path cannot contain the mount stem, so this recurses once. + if (ownMountSuffix(path)) |inner| { + var self_buf: [4096]u8 = undefined; + const internal = std.fmt.bufPrint(&self_buf, "/n/self/{s}", .{inner}) catch return error.FileTooLarge; + return readLimit(p, internal, max_bytes); + } const limit = @min(max_bytes, limits.max_file_bytes); if (std.mem.eql(u8, std.mem.trimEnd(u8, path, "/"), "/n")) { var out: std.Io.Writer.Allocating = .init(p.gpa); @@ -871,6 +941,14 @@ fn readNode(p: *pardes.Pardes, initial_node: u64, path: []const u8, limit: usize } pub fn write(p: *pardes.Pardes, path: []const u8, bytes: []const u8) !void { + // The same view `readLimit` answers from the tree, so a write lands where + // the matching read came from -- and, just as importantly, never becomes + // an open(2) through a mount this loop is the one that answers. + if (ownMountSuffix(path)) |inner| { + var self_buf: [4096]u8 = undefined; + const internal = std.fmt.bufPrint(&self_buf, "/n/self/{s}", .{inner}) catch return error.PathTooLong; + return write(p, internal, bytes); + } if (std.mem.eql(u8, std.mem.trimEnd(u8, path, "/"), "/n")) return error.IsDirectory; var self_path: ?[]const u8 = null; if (std.mem.eql(u8, path, "/virtual")) self_path = ""; @@ -1233,6 +1311,10 @@ test "Restore prefers default directory then falls back to original path" { fn readFileLimit(gpa: std.mem.Allocator, path: []const u8, limit: usize) ![]u8 { if (std.mem.indexOfScalar(u8, path, 0) != null) return error.OpenFailed; + // Same reason as `writeFile`: no core to answer from here, and the open is + // the call that never returns. Callers holding one use `readLimit`, which + // serves the tree instead. + if (isOwnMount(path)) return error.FileNotFound; if (!platform_has_fs or std.mem.startsWith(u8, path, "/virtual/")) { const archive_path = if (std.mem.startsWith(u8, path, "/virtual/")) path[9..] else path; var normalized_buf: [4096]u8 = undefined; diff --git a/src/gui/gui.zig b/src/gui/gui.zig index d871e55e..c26629ab 100644 --- a/src/gui/gui.zig +++ b/src/gui/gui.zig @@ -1788,6 +1788,7 @@ const Gui = struct { scroll_pane: ?usize = null, scroll_rect: pardes.Rect = .{ .x = 0, .y = 0, .w = 0, .h = 0 }, scroll_body_y: u16 = 0, // that rect's first BODY row (Tagbottom moves it) + scroll_body_h: u16 = 0, // and how many rows it has, notice bands taken off scroll_col: u16 = 0, // where the wheel turned: crossed rows are delivered scroll_row: u16 = 0, // THERE, not wherever the pointer has drifted to since scroll_delta: f32 = 0, // finite raw distance waiting for the render batch @@ -4292,14 +4293,15 @@ fn stepScroll(g: *Gui, core: *pardes.Pardes, gpa: std.mem.Allocator) void { } g.scroll_lag = st.lag; g.scroll_rect = r; - const body_y = if (core.settings.tag_bottom) r.y else r.y + pardes.BOX_H; + const body_y = core.bodyTop(pane, r); g.scroll_body_y = body_y; + g.scroll_body_h = (r.h -| pardes.BOX_H) -| pane.body_offset; if (st.rows != 0) { const s = &core.surface; g.scroll_edge_len = 0; - if (r.w > config.GUTTER and r.h > pardes.BOX_H and r.x + r.w <= s.cols) { + if (r.w > config.GUTTER and r.h > pardes.BOX_H + pane.body_offset and r.x + r.w <= s.cols) { const bw = r.w - config.GUTTER; - const bh = r.h - pardes.BOX_H; + const bh = (r.h - pardes.BOX_H) - pane.body_offset; const k: u16 = @intCast(@min(@abs(st.rows), @as(i32, bh))); const srow = body_y + (if (st.rows > 0) k - 1 else bh - k); if (srow < s.rows) { @@ -4327,7 +4329,11 @@ fn emitScrollRows(g: *Gui, instances: [*]CellInstance, base: u32, surface: *pard const x0 = r.x + config.GUTTER; const y0 = g.scroll_body_y; const bw = r.w - config.GUTTER; - const bh = r.h - pardes.BOX_H; + // The body the editor actually painted: measuring it from the rect while + // the origin comes from bodyTop reads past the pane by the band rows, and + // for the bottom-most pane past the surface, which drops the animation. + const bh = g.scroll_body_h; + if (bh == 0) return 0; if (x0 + bw > surface.cols or y0 + bh > surface.rows) return 0; // resized under us var shifted = layout; shifted.y_off -= g.scroll_lag * layout.h; @@ -4359,7 +4365,7 @@ fn scrollScissor(g: *const Gui, layout: CellLayout, sw: u32, sh: u32) c.SDL_Rect const px = layout.x_off + @as(f32, @floatFromInt(r.x + config.GUTTER)) * layout.w; const py = layout.y_off + @as(f32, @floatFromInt(g.scroll_body_y)) * layout.h; const pw = @as(f32, @floatFromInt(r.w - config.GUTTER)) * layout.w; - const ph = @as(f32, @floatFromInt(r.h - pardes.BOX_H)) * layout.h; + const ph = @as(f32, @floatFromInt(g.scroll_body_h)) * layout.h; const x0 = std.math.clamp(@as(i32, @intFromFloat(@floor(px))), 0, @as(i32, @intCast(sw))); const y0 = std.math.clamp(@as(i32, @intFromFloat(@floor(py))), 0, @as(i32, @intCast(sh))); const x1 = std.math.clamp(@as(i32, @intFromFloat(@ceil(px + pw))), x0, @as(i32, @intCast(sw))); @@ -6685,11 +6691,14 @@ fn appendPaneChrome( const chrome = core.chromeTheme(); const page = overlayRgb(core.theme().bg orelse bg_default); for (core.panes, core.rects) |slot, r| { - if (slot == null or r.w <= config.GUTTER or r.h <= pardes.BOX_H) continue; + const pane = slot orelse continue; + if (r.w <= config.GUTTER or r.h <= pardes.BOX_H) continue; if (@as(u32, r.x) + r.w > surface.cols or @as(u32, r.y) + r.h > surface.rows) continue; const tag_y = if (core.settings.tag_bottom) r.y + r.h - pardes.BOX_H else r.y; - const body_y = if (core.settings.tag_bottom) r.y else r.y + pardes.BOX_H; - const body_end = body_y + r.h - pardes.BOX_H; + // The rail the editor painted, notice bands included -- overlaying the + // rows above it would tint the bands instead of the scrollbar. + const body_y = core.bodyTop(pane, r); + const body_end = body_y + ((r.h -| pardes.BOX_H) -| pane.body_offset); const x0 = @as(f32, @floatFromInt(r.x)) * layout.w; const x1 = x0 + @as(f32, @floatFromInt(r.w)) * layout.w; const tag_cells = surface.cells[@as(usize, tag_y) * surface.cols + r.x + pardes.TAG_TEXT_INSET ..][0 .. r.w - pardes.TAG_TEXT_INSET]; diff --git a/src/panes.zig b/src/panes.zig index e41698bb..4b5c6721 100644 --- a/src/panes.zig +++ b/src/panes.zig @@ -191,6 +191,11 @@ pub const Pane = struct { /// body layer reserves exactly `len` rows for them, the way it already /// reserves rows for sticky context headers. notices: Notices = .{}, + /// Rows the notice bands take off the TOP of the body, the way tree-sitter + /// context rows do: the body starts below them rather than being painted + /// under them. Zero while the body LAYER renders, which paints into a + /// surface of its own that carries no bands. + body_offset: u16 = 0, pub const Notices = struct { /// Painted bottom-up in this order, so a prompt keeps the row nearest @@ -2036,7 +2041,7 @@ pub const File = struct { const gcrow = if (pane.cur_pinned) pane.cur_row else @as(i32, gcur.y) + goff; const cur_line: i32 = if (active and !pane.tag_edit) gcrow else std.math.minInt(i32); // the body's first row, the way renderPane derives it (Tagbottom) - const body_y = if (p.settings.tag_bottom) r.y else r.y + pardes.BOX_H; + const body_y = p.bodyTop(pane, r); const context_bg = p.theme().tag_bg; for (0..@min(pane.context_rows, body_h)) |context_row| { for (0..tw) |col| { @@ -2090,7 +2095,7 @@ pub const File = struct { // indexed start, same as bodyText — an empty tail simply paints nothing var flines = std.mem.splitScalar(u8, f.content[lineStart(p.gpa, f, f.scroll)..], '\n'); const total = nlines(p.gpa, f); - const body_y = if (p.settings.tag_bottom) r.y else r.y + pardes.BOX_H; + const body_y = p.bodyTop(pane, r); var vr: u16 = 0; while (vr < body_h) : (vr += 1) { var base: usize = undefined; @@ -2166,7 +2171,7 @@ pub const File = struct { pane_bg: pardes.Color, ) void { if (tw <= gutterWidth(pane) + 1) return; - const body_y = if (p.settings.tag_bottom) r.y else r.y + pardes.BOX_H; + const body_y = p.bodyTop(pane, r); const marker_fg = p.chromeTheme().lineno; var row: u16 = 0; while (row + 1 < pane.wrap_n and row + 1 < body_h) : (row += 1) { @@ -2190,9 +2195,9 @@ pub const File = struct { const tx = r.x + config.GUTTER; const tw = r.w - config.GUTTER; const prefix_width = gutterWidth(pane); - const body_y = if (p.settings.tag_bottom) r.y else r.y + pardes.BOX_H; + const body_y = p.bodyTop(pane, r); var vr: i32 = 0; - while (vr + @as(i32, pardes.BOX_H) < @as(i32, r.h)) : (vr += 1) { + while (vr + @as(i32, pardes.BOX_H) < @as(i32, r.h -| pane.body_offset)) : (vr += 1) { const here = pane.wrapAt(vr); if (here.line != row) continue; var hi = word_hi; @@ -5477,7 +5482,7 @@ pub const Pdf = struct { if (slot == pane) break core.rects[id]; } else return null; const cols = rect.w -| config.GUTTER; - const rows = rect.h -| pardes.BOX_H; + const rows = (rect.h -| pardes.BOX_H) -| pane.body_offset; if (cols == 0 or rows == 0) return null; return .{ .pixel_w = @as(u32, cols) * @as(u32, core.cell_pixels.w), @@ -5515,8 +5520,8 @@ pub const Pdf = struct { const rect = for (core.panes, 0..) |slot, id| { if (slot == pane) break core.rects[id]; } else return null; - const body_y = if (core.settings.tag_bottom) rect.y else rect.y + pardes.BOX_H; - if (row < body_y or row >= body_y + (rect.h -| pardes.BOX_H)) return null; + const body_y = core.bodyTop(pane, rect); + if (row < body_y or row >= body_y + ((rect.h -| pardes.BOX_H) -| pane.body_offset)) return null; const local_y = @as(f64, @floatFromInt( @as(u32, row - body_y) * core.cell_pixels.h + core.cell_pixels.h / 2, )); @@ -5572,7 +5577,7 @@ pub const Pdf = struct { if (slot == pane) break core.rects[id]; } else return null; const body_x = @as(i64, rect.x + config.GUTTER); - const body_y = @as(i64, if (core.settings.tag_bottom) rect.y else rect.y + pardes.BOX_H); + const body_y = @as(i64, core.bodyTop(pane, rect)); const px = (@as(i64, col) - body_x) * core.cell_pixels.w + core.cell_pixels.w / 2; const py = (@as(i64, row) - body_y) * core.cell_pixels.h + core.cell_pixels.h / 2; return pointAtPage(state, view, page, px, py, clamp_to_page); @@ -5855,7 +5860,7 @@ pub const Pdf = struct { text_width: u16, ) bool { if (comptime !enabled) return false; - if (!core.native_images or rect.h <= pardes.BOX_H) return false; + if (!core.native_images or rect.h <= pardes.BOX_H + pane.body_offset) return false; const state = &(pane.pdf orelse return false); const view = paneViewport(core, pane) orelse return false; const key = TintKey{ .mode = state.tint, .colors = tintColors(core) }; @@ -5892,9 +5897,9 @@ pub const Pdf = struct { null, }, .x = text_x, - .y = if (core.settings.tag_bottom) rect.y else rect.y + pardes.BOX_H, + .y = core.bodyTop(pane, rect), .w = text_width, - .h = rect.h - pardes.BOX_H, + .h = (rect.h -| pardes.BOX_H) -| pane.body_offset, .rgba = placed.rgba, .iw = placed.width, // The texture contains the retained band, not the full page. @@ -5906,14 +5911,17 @@ pub const Pdf = struct { // This frame has spent the motion used to choose its raster band. state.scroll_travel = 0; - const body_y = if (core.settings.tag_bottom) rect.y else rect.y + pardes.BOX_H; + const body_y = core.bodyTop(pane, rect); + const body_h = (rect.h -| pardes.BOX_H) -| pane.body_offset; const chrome = core.chromeTheme(); const theme = core.theme(); const pane_bg: pardes.Color = if (theme.bg) |color| .{ .rgb = color } else .default; - core.surface.fill(rect.x, body_y, 1, rect.h -| pardes.BOX_H, .{ .bg = .{ .rgb = chrome.scroll_track } }); - core.surface.fill(rect.x + 1, body_y, 1, rect.h -| pardes.BOX_H, .{ .bg = pane_bg }); + // The rail runs past the notice bands; only the thumb tracks the text. + const rail_y = if (core.settings.tag_bottom) rect.y else rect.y + pardes.BOX_H; + core.surface.fill(rect.x, rail_y, 1, rect.h -| pardes.BOX_H, .{ .bg = .{ .rgb = chrome.scroll_track } }); + core.surface.fill(rect.x + 1, rail_y, 1, rect.h -| pardes.BOX_H, .{ .bg = pane_bg }); - const track_h: usize = rect.h - pardes.BOX_H; + const track_h: usize = body_h; const total = @max(@as(u64, 1), state.document_height); const len = @max( @as(usize, 1), @@ -7571,7 +7579,7 @@ pub const Terminal = struct { if (comptime !enabled) return; const s = &p.surface; if (pane.terminal == null) return; - const body_y = if (p.settings.tag_bottom) r.y else r.y + pardes.BOX_H; + const body_y = p.bodyTop(pane, r); var filtered_storage: FilteredColors = undefined; const filtered: ?*FilteredColors = if (pane.tty_filter) blk: { const tz_filter = tracy.zone(@src(), "filterInit"); diff --git a/src/pardes.zig b/src/pardes.zig index ec743bc6..c271a16f 100644 --- a/src/pardes.zig +++ b/src/pardes.zig @@ -75,7 +75,9 @@ pub const RowMetrics = @import("body_layer.zig").Metrics; pub const TagLayer = @import("tag_layer.zig").Layer; pub const TagHit = @import("tag_layer.zig").Hit; pub const TagKind = @import("tag_layer.zig").Kind; -pub const MAX_TAG_LAYERS = MAX_PANES + MAX_COLS + 1; +/// Panes, then columns, then the workspace bar, then each pane's notice bands. +pub const MAX_TAG_LAYERS = MAX_PANES + MAX_COLS + 1 + MAX_PANES * Pane.Notices.max; +pub const NOTICE_LAYER_BASE = MAX_PANES + MAX_COLS + 1; pub const PDF_PAGE_GAP_PX = panes.Pdf.page_gap_px; pub const MAX_COLS = 6; const column_weight_unit = layout.column_weight_unit; @@ -1168,7 +1170,17 @@ test "TreeContext tag style preserves message rows and its opt-out survives rest _ = try p.render(p.scratch.allocator()); try std.testing.expectEqual(full_height - 1, p.surface.body_layers[0].viewport.h); const r = p.rects[0]; - try std.testing.expectEqualStrings("!", p.surface.at(r.x + config.GUTTER, r.y + r.h - 1).grapheme()); + // The message is a tagline band at the top of the body now, not a body row + // at the bottom: same reservation, different carrier. + const band = for (p.surface.tagLayers()) |*layer| { + if (layer.cols != 0 and layer.kind == .notice) break layer; + } else return error.NoNoticeBand; + try std.testing.expectEqual(r.y + BOX_H, band.viewport.y); + // Right aligned: the text sits in the last cell the viewport actually + // shows, which is a column short of the layer's cursor slack. + try std.testing.expectEqualStrings("!", band.cells[p.tagCapacity(band.viewport.w) - 1].grapheme()); + // ...and the body starts below it rather than under it. + try std.testing.expectEqual(band.viewport.y + 1, p.surface.body_layers[0].viewport.y); pane.msg_len = 0; p.leader_on = true; _ = try p.render(p.scratch.allocator()); @@ -1178,7 +1190,7 @@ test "TreeContext tag style preserves message rows and its opt-out survives rest _ = try p.render(p.scratch.allocator()); try std.testing.expectEqual(@as(u16, 0), p.surface.body_layers[0].rows); try std.testing.expectEqual(@as(u16, 0), pane.body_rows); - try std.testing.expectEqual(FontRole.body, p.surface.at(r.x + config.GUTTER, r.y + BOX_H).style.font_role); + try std.testing.expectEqual(FontRole.body, p.surface.at(r.x + config.GUTTER, p.bodyTop(pane, r)).style.font_role); try p.dumpState(); const restored = try Pardes.initFromDump(p.gpa, .{ .tty_only = true }, p.dump_out.?); defer restored.deinit(); @@ -6270,6 +6282,15 @@ pub const Pardes = struct { return p; } + /// Prints `text` flush with the right edge of the band, and answers the + /// column it started at so a cursor can follow it. + fn printRight(s: *Surface, x: u16, row: u16, w: u16, text: []const u8, style: CellStyle) u16 { + const shown: u16 = @intCast(@min(@as(usize, w), panes.File.displayWidth(text))); + const left = x + w - shown; + _ = s.print(left, row, shown, text, style); + return left; + } + /// The layout every single-pane boot starts from. fn oneColumn(p: *Pardes) void { p.ncol = 1; @@ -6915,7 +6936,15 @@ pub const Pardes = struct { false; } + /// Something changed the core without going through `update` -- a watched + /// file reloading under it, a theme file rewritten on disk. `pump` draws + /// only when it has a reason to, and this is the reason. + pub fn invalidate(p: *Pardes) void { + p.needs_frame = true; + } + pub fn reloadWatchedFile(p: *Pardes, id: u8, bytes: []const u8) bool { + p.invalidate(); p.invalidateLookHover(id); const applied = p.applyWatchedFileChanged(id, bytes); _ = p.scratch.reset(.retain_capacity); @@ -11235,9 +11264,13 @@ pub const Pardes = struct { const r = p.rects[id]; if (col < r.x + config.GUTTER or col >= r.x + r.w or row < r.y or row >= r.y + r.h) return null; const tag_y = if (p.settings.tag_bottom) r.y + r.h -| BOX_H else r.y; - const body_y = if (p.settings.tag_bottom) r.y else r.y + BOX_H; + const body_y = p.bodyTop(p.panes[id].?, r); const on_tag = row >= tag_y and row < tag_y + BOX_H; if (on_tag and col < r.x + TAG_TEXT_INSET) return null; + // A notice band is chrome. Without this it maps to Sel row 0 or less, + // which is the TAG row -- so a click on a leader band would expand a + // word out of the tag text and run it as a builtin. + if (!on_tag and row >= body_y -| p.panes[id].?.body_offset and row < body_y) return null; if (!on_tag) if (body_hit) |supplied| { const mapped_hit = p.bodyHitForPane(id, supplied, false) orelse return null; const c = @as(i32, mapped_hit.col) - config.GUTTER; @@ -11624,7 +11657,7 @@ pub const Pardes = struct { if (previous.tag_edit) exitTagEdit(previous); }; const tag_y = if (p.settings.tag_bottom) r.y + r.h -| BOX_H else r.y; - const body_y = if (p.settings.tag_bottom) r.y else r.y + BOX_H; + const body_y = p.bodyTop(pane, r); if (mcol < r.x + config.GUTTER) { // gutter scrollbar: a left click scrolls UP to that row p.active = id; @@ -11688,7 +11721,7 @@ pub const Pardes = struct { // the tag row and the body's first, exactly as the select // arm above derives them const tag_y = if (p.settings.tag_bottom) r.y + r.h -| BOX_H else r.y; - const body_y = if (p.settings.tag_bottom) r.y else r.y + BOX_H; + const body_y = p.bodyTop(pane, r); const on_tag = mrow >= tag_y and mrow < tag_y + BOX_H; if (mcol < r.x + config.GUTTER and !on_tag) { const local = @as(i32, mrow) - @as(i32, body_y); @@ -11780,13 +11813,17 @@ pub const Pardes = struct { return; }; pane.sel[b].c1 = @as(i32, mcol) - @as(i32, r.x + config.GUTTER); - if (p.settings.tag_bottom) { - const body_h = r.h -| BOX_H; - pane.sel[b].r1 = if (pane.sel[b].r0 < BOX_H or body_h == 0) - 0 - else - @as(i32, @min(@max(mrow, r.y), r.y + body_h - 1)) - @as(i32, r.y) + @as(i32, BOX_H); - } else pane.sel[b].r1 = if (pane.sel[b].r0 < BOX_H) 0 else @as(i32, mrow) - @as(i32, r.y); + // Sel row BOX_H is the body's FIRST row, the same thing + // pointerTextSelection means by it -- so the drag has to + // measure from the body's top, notice bands included, or a + // selection made while a message is up lands rows away + // from the pointer. + const body_y = p.bodyTop(pane, r); + const body_h = (r.h -| BOX_H) -| pane.body_offset; + pane.sel[b].r1 = if (pane.sel[b].r0 < BOX_H or body_h == 0) + 0 + else + @as(i32, @min(@max(mrow, body_y), body_y + body_h - 1)) - @as(i32, body_y) + @as(i32, BOX_H); if (pane.sel[b].r1 < BOX_H) pane.sel[b].c1 += @as(i32, pane.tag_scroll) - TAG_GAP; if (comptime pdf_enabled) panes.Pdf.pointerUpdate(&s.pdf, p, pane, mcol, mrow); @@ -13333,6 +13370,14 @@ pub const Pardes = struct { return null; } + /// The pane's first body row: under the tag when it is on top, and under + /// whatever notice bands `collectNotices` stacked above the body. Every + /// painter and hit test derives the body from here so the bands cannot + /// come adrift from the text they sit over. + pub fn bodyTop(p: *const Pardes, pane: *const Pane, r: Rect) u16 { + return (if (p.settings.tag_bottom) r.y else r.y + BOX_H) + pane.body_offset; + } + fn tagCapacity(p: *const Pardes, physical_width: u16) u16 { const layer: TagLayer = .{ .viewport = .{ .x = 0, .y = 0, .w = physical_width, .h = 1 } }; return layer.capacity(p.row_metrics); @@ -13416,37 +13461,49 @@ pub const Pardes = struct { .bg = .{ .rgb = chrome.tag_bg }, .font_role = .tagline, }; - // The stack sits directly above the tagline, one line to a row, in - // the order collectNotices chose. A single notice therefore lands - // on exactly the row the message used to have to itself. - const bottom = if (p.settings.tag_bottom) r.y + r.h - 1 - BOX_H else r.y + r.h - 1; + // Sticky at the TOP of the body, where the tree-sitter context + // headers sit, one line to a row in the order collectNotices chose. + // Text is right aligned: the left edge is where the body's own text + // begins, and a notice that shared it would read as a line of the + // file rather than as chrome over it. + const first = if (p.settings.tag_bottom) r.y else r.y + BOX_H; for (pane.notices.slice(), 0..) |kind, i| { - const row = bottom - @as(u16, @intCast(pane.notices.len - 1 - i)); + const row = first + @as(u16, @intCast(i)); + // Every notice is painted on the canonical grid as well as + // emitted as a tag layer: the grid is what a terminal client + // draws, and a band it cannot see is a message it never gets. + // The GUI skips grid cells a tag layer covers, so nothing is + // drawn twice there. s.fill(tx, row, tw, 1, .{ .bg = msg_style.bg, .font_role = .tagline }); switch (kind) { - .message => _ = s.print(tx, row, tw, pane.msg[0..pane.msg_len], msg_style), + .message => _ = printRight(s, tx, row, tw, pane.msg[0..pane.msg_len], msg_style), .leader => { var ibuf: [16]u8 = @splat(' '); - @memcpy(ibuf[1..4], "SPC"); - var iw: usize = 4; + @memcpy(ibuf[0..3], "SPC"); + var iw: usize = 3; for (p.leader_keys[0..p.leader_n]) |ch| { ibuf[iw + 1] = ch; iw += 2; } - const w: u16 = @intCast(iw); - if (w < tw) _ = s.print(tx + tw - w, row, w, ibuf[0..iw], msg_style); + _ = printRight(s, tx, row, tw, ibuf[0..iw], msg_style); }, .prompt => { const at = pane.promptAt() orelse continue; const text = pane.tagSlice()[@min(at, pane.tag_tail_len)..]; - _ = s.print(tx, row, tw, text, msg_style); + // One column short of the edge: the caret sits AFTER + // the last character the moment a prompt opens, and + // flush right would put it at r.x + r.w -- off the + // pane, off the grid, and past what the detached wire + // will encode, which drops every frame while it is up. + const left = printRight(s, tx, row, tw -| 1, text, msg_style); if (id != p.active) continue; const prompt0 = (p.tagPrefix(pane) catch continue).len + at; const col = @as(usize, pane.tag_col); if (col >= prompt0) { + // The cursor follows the text to wherever it landed. const prompt_col = panes.File.displayWidth(text[0..@min(col - prompt0, text.len)]); if (prompt_col < tw) - s.cursor = .{ .x = tx + @as(u16, @intCast(prompt_col)), .y = row, .bar = pane.mode == .insert }; + s.cursor = .{ .x = left + @as(u16, @intCast(prompt_col)), .y = row, .bar = pane.mode == .insert }; } }, } @@ -13772,11 +13829,11 @@ pub const Pardes = struct { const raw = pane.mode == .tty; const tx = r.x + config.GUTTER; const width = r.w -| config.GUTTER; - const body_y = if (p.settings.tag_bottom) r.y else r.y + BOX_H; + const body_y = p.bodyTop(pane, r); var lines = std.mem.splitScalar(u8, body, '\n'); var visible: i32 = 0; while (lines.next()) |line| : (visible += 1) { - if (visible >= r.h -| BOX_H) break; + if (visible >= (r.h -| BOX_H) -| pane.body_offset) break; const source_row = if (raw) panes.Terminal.gridOffset(pane) + visible else pane.wrapAt(visible).line; for (rows) |row| { const target = if (row.raw_terminal) @@ -13814,10 +13871,10 @@ pub const Pardes = struct { const terminal_lines = if (pane.file == null) panes.Terminal.cursorLines(p, pane) catch return else &.{}; const tx = r.x + config.GUTTER; const width = r.w -| config.GUTTER; - const body_y = if (p.settings.tag_bottom) r.y else r.y + BOX_H; + const body_y = p.bodyTop(pane, r); const prefix: i32 = if (pane.file != null) panes.File.gutterWidth(pane) else 0; var visible: i32 = 0; - while (visible < @as(i32, r.h -| BOX_H)) : (visible += 1) { + while (visible < @as(i32, (r.h -| BOX_H) -| pane.body_offset)) : (visible += 1) { const source = pane.wrapAt(visible); const line = pointerSourceLine(pane, terminal_lines, source.line); const start = @min(line.len, @as(usize, @intCast(@max(0, source.at)))); @@ -13862,6 +13919,11 @@ pub const Pardes = struct { while (row < r.h) : (row += 1) { if (@as(i32, row) < r0 or @as(i32, row) > r1) continue; const sy = if (row < BOX_H) tag_y else body_y + row - BOX_H; + // The body sits `body_offset` rows lower than it used to, so the + // last rows of Sel space now fall past the pane. Bounding the loop + // instead would break the caller that paints a tag into a + // one-row surface of its own, where the offset means nothing. + if (row >= BOX_H and sy >= r.y + r.h) break; // File line numbers occupy a gutter only in the body. The tag is // row zero in Sel space and starts at its real first text cell. const scroll: i32 = if (row < BOX_H) pane.tag_scroll else 0; @@ -13910,6 +13972,50 @@ pub const Pardes = struct { // workspace layer to render; the menu bar carries its commands. if (p.settings.workspace_tag) try p.renderHeaderLayer(arena, MAX_PANES + MAX_COLS, .workspace, 0, .{ .x = 0, .y = 0, .w = p.screen_w, .h = TOPBAR_H }, p.topbar(&text_buf), chrome.tag_bg, chrome.tag_fg); + // Each notice is its own tagline-shaped band at the top of the body. + // Going through the same layer machinery the pane and column tags use + // is what gives it the tagline's height, its small-font metrics, the + // band offset and the border -- none of which a body-grid row can have + // just by wearing a tagline font. + for (p.panes, 0..) |slot, id| { + const pane = slot orelse continue; + const r = p.rects[id]; + if (r.w <= TAG_TEXT_INSET or r.h <= BOX_H) continue; + const first = if (p.settings.tag_bottom) r.y else r.y + BOX_H; + var band: u16 = 0; + for (pane.notices.slice()) |kind| { + const text = switch (kind) { + .message => pane.msg[0..pane.msg_len], + .leader => blk: { + var ibuf: [16]u8 = @splat(' '); + @memcpy(ibuf[0..3], "SPC"); + var iw: usize = 3; + for (p.leader_keys[0..p.leader_n]) |ch| { + ibuf[iw + 1] = ch; + iw += 2; + } + break :blk try arena.dupe(u8, ibuf[0..iw]); + }, + // A prompt is an editing line with a cursor in it, so it + // stays on the grid where the cursor can sit on a cell. + .prompt => continue, + }; + if (text.len == 0) continue; + const room = p.tagCapacity(r.w -| TAG_TEXT_INSET); + const shown = panes.File.displayWidth(text); + const pad = room -| shown; + const line = try arena.alloc(u8, pad + text.len); + @memset(line[0..pad], ' '); + @memcpy(line[pad..], text); + try p.renderHeaderLayer(arena, NOTICE_LAYER_BASE + id * Pane.Notices.max + band, .notice, @intCast(id), .{ + .x = r.x + TAG_TEXT_INSET, + .y = first + band, + .w = r.w -| TAG_TEXT_INSET, + .h = BOX_H, + }, line, chrome.tag_bg, chrome.tag_fg); + band += 1; + } + } if (p.columnBarHeight() > 0) for (0..p.ncol) |column| { if (p.col_w[column] == 0) continue; const active = if (layout.findPane(p, p.active)) |found| found.col == column and p.settings.focus_tint else false; @@ -13934,7 +14040,14 @@ pub const Pardes = struct { layer.bg = bg; layer.cursor = null; var surface: Surface = .{ .cols = columns, .rows = 1, .cells = layer.cells }; - const editing = p.topbar_col != null and (if (kind == .workspace) p.header_column == null else p.header_column == id); + // A notice band carries a PANE id, not a column index, so it must not + // answer to the column being edited -- that would scroll and select + // its text with the column tag's offsets and give it a second caret. + const editing = p.topbar_col != null and switch (kind) { + .workspace => p.header_column == null, + .column => p.header_column == id, + .pane, .notice => false, + }; const scroll = if (editing) p.header_scroll else 0; surface.fill(0, 0, columns, 1, .{ .bg = .{ .rgb = bg }, .font_role = .tagline }); _ = surface.print(0, 0, columns, text[panes.File.rawAtDisplay(text, scroll)..], .{ .fg = .{ .rgb = fg }, .bg = .{ .rgb = bg }, .font_role = .tagline }); @@ -13974,6 +14087,7 @@ pub const Pardes = struct { /// them instead of letting the last one win the row. fn collectNotices(p: *Pardes, pane: *Pane, r: Rect, id: usize) void { pane.notices.len = 0; + pane.body_offset = 0; if (r.w <= config.GUTTER or r.h <= BOX_H) return; if (pane.msg_len > 0) pane.notices.push(.message); if (id == p.active and p.leader_on) pane.notices.push(.leader); @@ -13991,6 +14105,7 @@ pub const Pardes = struct { for (0..room) |i| pane.notices.kinds[i] = pane.notices.kinds[i + drop]; pane.notices.len = room; } + pane.body_offset = pane.notices.len; } fn renderBodyLayer(p: *Pardes, arena: std.mem.Allocator, pane: *Pane, r: Rect, id: usize) !void { @@ -14017,6 +14132,9 @@ pub const Pardes = struct { @memset(temporary_cells, .{}); var temporary: Surface = .{ .cols = r.w, .rows = @intCast(logical_rows + BOX_H), .cells = temporary_cells }; std.mem.swap(Surface, &p.surface, &temporary); + // This surface carries no notice bands, so the body starts at its top. + pane.body_offset = 0; + defer pane.body_offset = pane.notices.len; const synthetic: Rect = .{ .x = 0, .y = 0, .w = r.w, .h = @intCast(logical_rows + BOX_H) }; p.renderBody(arena, pane, synthetic, id, id == p.active, false) catch |err| { std.mem.swap(Surface, &p.surface, &temporary); @@ -14030,7 +14148,11 @@ pub const Pardes = struct { } layer.pane = @intCast(id); layer.serial = pane.serial; - layer.viewport = .{ .x = r.x + config.GUTTER, .y = if (p.settings.tag_bottom) r.y else r.y + BOX_H, .w = width, .h = viewport_rows }; + // Below the notice bands, which are stacked at the TOP of the body + // now: the rows they took came off this viewport, so its origin has to + // move with them or the first context header renders under a band. + const body_top = (if (p.settings.tag_bottom) r.y else r.y + BOX_H) + @as(u16, pane.notices.len); + layer.viewport = .{ .x = r.x + config.GUTTER, .y = body_top, .w = width, .h = viewport_rows }; layer.cols = width; layer.rows = @intCast(logical_rows); layer.context_rows = pane.context_rows; @@ -14052,7 +14174,7 @@ pub const Pardes = struct { const tx = r.x + config.GUTTER; // text area (tag + body), right of the gutter const tw = r.w - config.GUTTER; const tag_y = if (p.settings.tag_bottom) r.y + r.h -| BOX_H else r.y; - const body_y = if (p.settings.tag_bottom) r.y else r.y + BOX_H; + const body_y = p.bodyTop(pane, r); const pane_bg: Color = if (th.bg) |c| .{ .rgb = c } else .default; // text area resets to terminal-default cells (vaxis clear semantics); @@ -14092,11 +14214,14 @@ pub const Pardes = struct { if (pane.hasPdf() and panes.Pdf.draw(p, pane, r, id, tx, tw)) return; if (pane.image) |*iv| { - panes.Image.draw(p, iv, @intCast(id), pane.serial, tx, body_y, tw, r.h -| BOX_H); + const image_h = (r.h -| BOX_H) -| pane.body_offset; + panes.Image.draw(p, iv, @intCast(id), pane.serial, tx, body_y, tw, image_h); // thumbless, but the same one column as the real scrollbar below — - // that is the whole point of drawing it - s.fill(r.x, body_y, 1, r.h -| BOX_H, .{ .bg = .{ .rgb = chrome.scroll_track } }); - s.fill(r.x + 1, body_y, 1, r.h -| BOX_H, .{ .bg = pane_bg }); + // that is the whole point of drawing it, and like that one it runs + // past the notice bands so the gutter has no notch in it + const rail_y = if (p.settings.tag_bottom) r.y else r.y + BOX_H; + s.fill(r.x, rail_y, 1, r.h -| BOX_H, .{ .bg = .{ .rgb = chrome.scroll_track } }); + s.fill(r.x + 1, rail_y, 1, r.h -| BOX_H, .{ .bg = pane_bg }); return; } @@ -14110,7 +14235,7 @@ pub const Pardes = struct { const tx = r.x + @min(TAG_TEXT_INSET, r.w); const tw = r.w -| TAG_TEXT_INSET; const tag_y = if (p.settings.tag_bottom) r.y + r.h -| BOX_H else r.y; - const body_y = if (p.settings.tag_bottom) r.y else r.y + BOX_H; + const body_y = p.bodyTop(pane, r); const page_rgb = th.bg orelse th.tag_bg; // Focus is visible along the tag without changing its live text grid. const tag_bg = if (active and p.settings.focus_tint) chrome.tag_active_bg else chrome.tag_bg; @@ -14194,11 +14319,15 @@ pub const Pardes = struct { const tx = r.x + config.GUTTER; const tw = r.w - config.GUTTER; const tag_y = if (p.settings.tag_bottom) r.y + r.h -| BOX_H else r.y; - const body_y = if (p.settings.tag_bottom) r.y else r.y + BOX_H; + // Below the notice bands: they are stacked at the top of the body the + // way tree-sitter context rows are, so the body starts under them + // rather than being painted over by them. + const body_y = p.bodyTop(pane, r); const pane_bg: Color = if (th.bg) |c| .{ .rgb = c } else .default; const page_rgb = th.bg orelse th.tag_bg; // body: emulator rows, prompt rows hidden outside tty mode - const body_h = if (r.h > BOX_H) r.h - BOX_H else 0; + const body_h = (r.h -| BOX_H) -| pane.body_offset; + const body_bottom = r.h -| pane.body_offset; const body_style: CellStyle = .{ .fg = if (th.fg) |c| .{ .rgb = c } else .default, .bg = pane_bg, @@ -14269,7 +14398,7 @@ pub const Pardes = struct { const lo = @min(pane.msel.r0, pane.msel.r1); const hi = @max(pane.msel.r0, pane.msel.r1); var row: u16 = BOX_H; // never paint the tag row - while (row < r.h) : (row += 1) { + while (row < body_bottom) : (row += 1) { const ar = pane.wrapAt(@as(i32, row) - @as(i32, BOX_H)).line; if (ar < lo or ar > hi) continue; var col: u16 = if (pane.file != null) panes.File.gutterWidth(pane) else 0; @@ -14306,7 +14435,7 @@ pub const Pardes = struct { else mix(th.sel_bg, page_rgb); var vr: i32 = 0; - while (vr + @as(i32, BOX_H) < @as(i32, r.h)) : (vr += 1) { + while (vr + @as(i32, BOX_H) < @as(i32, body_bottom)) : (vr += 1) { const w = pane.wrapAt(vr); if (w.line < bnd.lo_row or w.line > bnd.hi_row) continue; const visible_line = modal.lineSlice(body, @intCast(vr)); @@ -14344,7 +14473,7 @@ pub const Pardes = struct { @intCast(@max(0, cw.at)), @intCast(@max(0, sr.col)), )) + vpfx; - if (crow >= BOX_H and crow < @as(i32, r.h) and ccol >= vpfx and ccol < tw) { + if (crow >= BOX_H and crow < @as(i32, body_bottom) and ccol >= vpfx and ccol < tw) { const cell = s.at(tx + @as(u16, @intCast(ccol)), body_y + @as(u16, @intCast(crow - BOX_H))); cell.default = false; cell.style.bg = .{ .rgb = th.sel_fg }; @@ -14375,17 +14504,22 @@ pub const Pardes = struct { ) else ccol; - if (prow >= BOX_H and cx >= 0 and prow < r.h and cx < tw) + if (prow >= BOX_H and cx >= 0 and prow < body_bottom and cx < tw) s.cursor = .{ .x = tx + @as(u16, @intCast(cx)), .y = body_y + @as(u16, @intCast(prow - BOX_H)), .bar = pane.mode == .insert }; } else if (panes.Terminal.visibleCursor(pane)) |cur| { - if (cur.y + BOX_H < r.h and cur.x < tw) + if (cur.y + BOX_H < body_bottom and cur.x < tw) s.cursor = .{ .x = tx + cur.x, .y = body_y + cur.y }; } } - if (scrollbar and r.h > BOX_H) { - s.fill(r.x, body_y, 1, r.h - BOX_H, .{ .bg = .{ .rgb = chrome.scroll_track } }); - s.fill(r.x + 1, body_y, 1, r.h - BOX_H, .{ .bg = pane_bg }); + if (scrollbar and body_h > 0) { + // The rail covers the notice bands too: nothing else paints those + // two gutter columns, so a gap there keeps the frame-wide border + // fill and reads as a notch cut out of the scrollbar. + const rail_y = if (p.settings.tag_bottom) r.y else r.y + BOX_H; + const rail_h = r.h -| BOX_H; + s.fill(r.x, rail_y, 1, rail_h, .{ .bg = .{ .rgb = chrome.scroll_track } }); + s.fill(r.x + 1, rail_y, 1, rail_h, .{ .bg = pane_bg }); const sb: struct { total: usize, offset: usize, len: usize } = if (pane.file) |*f| .{ .total = panes.File.nlines(p.gpa, f), .offset = f.scroll, @@ -14398,7 +14532,7 @@ pub const Pardes = struct { const gsb = panes.Terminal.scrollbar(pane); break :blk .{ .total = gsb.total, .offset = gsb.offset, .len = gsb.len }; }; - const track_h: usize = r.h - BOX_H; + const track_h: usize = body_h; const total = if (sb.total == 0) 1 else sb.total; const len = @max(1, (track_h * @max(1, sb.len)) / total); const pos = (track_h * sb.offset) / total; @@ -14658,6 +14792,24 @@ test "a builtin announces itself on the message row, and Verbose silences it" { try std.testing.expect(pane.notices.len > 0); try std.testing.expectEqual(Pane.Notices.Kind.message, pane.notices.kinds[0]); + // ...and it is carried as a tagline band, not a body row: that is what + // gives it the tagline's height, its small font and its border. + var frame = std.heap.ArenaAllocator.init(std.testing.allocator); + defer frame.deinit(); + _ = try p.render(frame.allocator()); + const r = p.rects[p.active]; + const band = for (p.surface.tagLayers()) |*layer| { + if (layer.cols != 0 and layer.kind == .notice) break layer; + } else return error.NoNoticeBand; + try std.testing.expectEqual(@as(u16, 1), band.viewport.h); + try std.testing.expectEqual(if (p.settings.tag_bottom) r.y else r.y + BOX_H, band.viewport.y); + // Right aligned: the text ends at the band's right edge. + const line = band.cells[0..band.cols]; + var last: usize = line.len; + while (last > 0 and line[last - 1].grapheme()[0] == ' ') last -= 1; + try std.testing.expect(last > 0); + try std.testing.expect(line[0].grapheme()[0] == ' '); + // Msg owns the row itself, so it does not announce over its own text. try std.testing.expect(p.executeBuiltinLine(p.active, "Msg hello")); try std.testing.expectEqualStrings("hello", pane.msg[0..pane.msg_len]); @@ -14668,6 +14820,86 @@ test "a builtin announces itself on the message row, and Verbose silences it" { try std.testing.expectEqual(@as(u16, 0), pane.msg_len); } +test "notices stack downward from the top of the body, which starts below them" { + if (platform == .web) return; + const p = try Pardes.init(std.testing.allocator, .{ .tty_only = true, .cols = 80, .rows = 24 }); + defer p.deinit(); + const id = p.active; + const pane = p.panes[id].?; + p.sync(); + var frame = std.heap.ArenaAllocator.init(std.testing.allocator); + defer frame.deinit(); + + const r = p.rects[id]; + const plain = p.bodyTop(pane, r); + try std.testing.expectEqual(@as(u16, 0), pane.body_offset); + + // A message and a leader prefix at once: two bands, stacked in the order + // collectNotices chose, each one row tall and each one row further down. + try std.testing.expect(p.executeBuiltinLine(id, "Msg first")); + p.leader_on = true; + p.leader_n = 0; + _ = frame.reset(.retain_capacity); + _ = try p.render(frame.allocator()); + try std.testing.expectEqual(@as(u16, 2), pane.body_offset); + try std.testing.expectEqual(plain + 2, p.bodyTop(pane, r)); + + var rows: [Pane.Notices.max]u16 = @splat(0); + var found: usize = 0; + for (p.surface.tagLayers()) |*layer| { + if (layer.cols == 0 or layer.kind != .notice) continue; + try std.testing.expectEqual(@as(u16, 1), layer.viewport.h); + rows[found] = layer.viewport.y; + found += 1; + } + try std.testing.expectEqual(@as(usize, 2), found); + std.mem.sort(u16, rows[0..2], {}, std.sort.asc(u16)); + try std.testing.expectEqual(plain, rows[0]); + try std.testing.expectEqual(plain + 1, rows[1]); + + // Gone with the notices: no stale band, and the body back at the top. + p.leader_on = false; + pane.msg_len = 0; + _ = frame.reset(.retain_capacity); + _ = try p.render(frame.allocator()); + try std.testing.expectEqual(@as(u16, 0), pane.body_offset); + try std.testing.expectEqual(plain, p.bodyTop(pane, r)); + for (p.surface.tagLayers()) |*layer| + try std.testing.expect(layer.cols == 0 or layer.kind != .notice); +} + +test "a prompt band keeps its caret on the grid, and a band is not a click target" { + if (platform == .web) return; + const p = try Pardes.init(std.testing.allocator, .{ .tty_only = true, .cols = 80, .rows = 24 }); + defer p.deinit(); + const id = p.active; + const pane = p.panes[id].?; + p.sync(); + var frame = std.heap.ArenaAllocator.init(std.testing.allocator); + defer frame.deinit(); + + // The caret sits AFTER the prompt text the moment the prompt opens, and + // the band is flush with the pane's right edge -- so this is the frame + // that used to put it one column past the pane, off the grid and past + // what the detached wire will encode. + p.startPrompt(pane, .{ .search = "/" }); + _ = try p.render(frame.allocator()); + const r = p.rects[id]; + const cursor = p.surface.cursor orelse return error.MissingPromptCursor; + try std.testing.expect(pane.body_offset > 0); + try std.testing.expectEqual(p.bodyTop(pane, r) - 1, cursor.y); + try std.testing.expect(cursor.x < r.x + r.w); + try std.testing.expect(cursor.x < p.surface.cols); + + // The band is chrome. Mapped as body it would land on Sel row 0, which is + // the TAG row, so a click on it would run a word out of the tag as a + // builtin. + const band_row = p.bodyTop(pane, r) - 1; + p.update(.{ .mouse = .{ .button = .left, .kind = .press, .col = r.x + r.w - 4, .row = band_row } }); + p.update(.{ .mouse = .{ .button = .left, .kind = .release, .col = r.x + r.w - 4, .row = band_row } }); + for (pane.sel) |selection| try std.testing.expect(selection.state == .none); +} + test "closing the last pane in a column leaves an empty one in its place" { if (platform == .web) return; const p = try Pardes.init(std.testing.allocator, .{ .tty_only = true, .cols = 120, .rows = 24 }); diff --git a/src/tag_layer.zig b/src/tag_layer.zig index 65990959..0fb2297d 100644 --- a/src/tag_layer.zig +++ b/src/tag_layer.zig @@ -3,7 +3,11 @@ const std = @import("std"); const pardes = @import("pardes.zig"); -pub const Kind = enum(u8) { workspace, column, pane }; +/// `notice` is a pane's transient line -- a builtin's name, a pending leader +/// chord -- carried as a tagline-shaped band so it gets the tagline's height, +/// small-font metrics, band offset and border instead of being a body-grid row +/// wearing a tagline font. +pub const Kind = enum(u8) { workspace, column, pane, notice }; pub const Hit = struct { kind: Kind, id: u16, diff --git a/test/e2e_harness.zig b/test/e2e_harness.zig index 5a181b78..eaa19b43 100644 --- a/test/e2e_harness.zig +++ b/test/e2e_harness.zig @@ -366,6 +366,18 @@ pub const Harness = struct { }; /// Write a file (helper for test setup, raw libc). +pub fn appendFile(path: [*:0]const u8, data: []const u8) !void { + const fd = libc.open(path, .{ .ACCMODE = .WRONLY, .CREAT = true, .APPEND = true }, @as(libc.mode_t, 0o644)); + if (fd < 0) return error.OpenFailed; + defer _ = libc.close(fd); + var off: usize = 0; + while (off < data.len) { + const w = libc.write(fd, data[off..].ptr, data.len - off); + if (w <= 0) break; + off += @intCast(w); + } +} + pub fn writeFile(path: [*:0]const u8, data: []const u8) !void { const fd = libc.open(path, .{ .ACCMODE = .WRONLY, .CREAT = true, .TRUNC = true }, @as(libc.mode_t, 0o644)); if (fd < 0) return error.OpenFailed; diff --git a/test/fs.py b/test/fs.py index c8dea2d9..33bcdfa9 100644 --- a/test/fs.py +++ b/test/fs.py @@ -612,7 +612,11 @@ def test(binary, quic=False): if start < 0: continue styles = [screen['styles'][cell[1]] for cell in cells[start:start + len(word)]] - assert all(style['bold'] and style['fg'] == styles[0]['fg'] for style in styles), (word, styles) + # Weight is opt-in (SyntaxBold, off by default); colour is + # not, so the keyword must differ from the text beside it. + plain = screen['styles'][cells[start + len(word)][1]] + assert all(not style['bold'] and style['fg'] == styles[0]['fg'] for style in styles), (word, styles) + assert styles[0]['fg'] != plain['fg'], (word, styles[0], plain) found.add(word) assert found == {'fn', 'if'}, screen diff --git a/test/output.zig b/test/output.zig index 1fcb6104..8afbf4d2 100644 --- a/test/output.zig +++ b/test/output.zig @@ -77,7 +77,7 @@ fn outputCell(p: *Pardes, surface: *pardes.Surface, id: usize, byte: usize) *par const line = modal.lineSlice(pane.file.?.content, 0); const rect = p.rects[id]; const x = rect.x + config.GUTTER + panes.File.gutterWidth(pane) + @as(u16, @intCast(panes.File.displayWidth(line[0..byte]))); - const y = if (p.settings.tag_bottom) rect.y else rect.y + pardes.BOX_H; + const y = p.bodyTop(pane, rect); return surface.at(x, y); } @@ -490,7 +490,7 @@ test "Mini syntax colors survive toggles themes and rendering without source acc const surface = try p.render(frame.allocator()); const rect = p.rects[id]; const x = rect.x + config.GUTTER + panes.File.gutterWidth(mini) + @as(u16, @intCast(column)); - const y = (if (p.settings.tag_bottom) rect.y else rect.y + pardes.BOX_H) + @as(u16, @intCast(position.row)); + const y = p.bodyTop(mini, rect) + @as(u16, @intCast(position.row)); if (enabled) try std.testing.expectEqualDeep(pardes.Color{ .rgb = p.theme().kw }, surface.at(x, y).style.fg); try std.testing.expectEqual(colors, mini.file.?.mini.?.colors.ptr); try std.testing.expectEqual(@as(usize, 0), mini.file.?.highlights.len); diff --git a/test/panes.zig b/test/panes.zig index e4e677e4..69628cd9 100644 --- a/test/panes.zig +++ b/test/panes.zig @@ -468,7 +468,7 @@ const TreeContextTests = struct { try std.testing.expectEqual(@as(i32, 59), pane.wrapAt(visible.row).line); const cursor = surface.cursor orelse return error.MissingLookCursor; const rect = p.rects[0]; - const y = if (p.settings.tag_bottom) rect.y else rect.y + pardes.BOX_H; + const y = p.bodyTop(pane, rect); try std.testing.expectEqual(y + @as(u16, @intCast(visible.row)), cursor.y); } } @@ -490,14 +490,16 @@ const TreeContextTests = struct { try std.testing.expectEqual(@as(i32, 7), pane.wrapAt(pane.context_rows).line); const rect = p.rects[0]; const x = rect.x + config.GUTTER + panes.File.gutterWidth(pane); - const y = if (p.settings.tag_bottom) rect.y else rect.y + pardes.BOX_H; + const y = p.bodyTop(pane, rect); ClickCursorTests.click(p, .left, x + 6, y); try std.testing.expectEqual(@as(i32, 0), pane.cur_row); try std.testing.expectEqual(@as(i32, 6), pane.cur_col); try std.testing.expectEqual(@as(i32, 7), pane.scroll()); const cursor = (try p.render(frame.allocator())).cursor orelse return error.MissingContextCursor; try std.testing.expectEqual(x + 6, cursor.x); - try std.testing.expectEqual(y, cursor.y); + // Read the body top again: the click cleared the announcement band the + // builtin above put up, and the body moved back up with it. + try std.testing.expectEqual(p.bodyTop(pane, p.rects[0]), cursor.y); p.update(.{ .key = .{ .cp = 'i' } }); p.update(.{ .key = .{ .cp = 'Z', .text = "Z" } }); try std.testing.expect(std.mem.startsWith(u8, pane.file.?.content, "const ZBox = struct {")); @@ -536,7 +538,7 @@ const TreeContextTests = struct { const surface = try p.render(frame.allocator()); try std.testing.expectEqual(@as(u16, 3), pane.context_rows); const rect = p.rects[0]; - const y = if (p.settings.tag_bottom) rect.y else rect.y + pardes.BOX_H; + const y = p.bodyTop(pane, rect); var glyph_x: ?u16 = null; for (0..surface.cols) |col| { if (std.mem.eql(u8, surface.at(@intCast(col), y).grapheme(), "界")) glyph_x = @intCast(col); @@ -548,7 +550,9 @@ const TreeContextTests = struct { try std.testing.expectEqual(@as(i32, 8), pane.scroll()); const cursor = (try p.render(frame.allocator())).cursor orelse return error.MissingContextCursor; try std.testing.expectEqual(x, cursor.x); - try std.testing.expectEqual(y, cursor.y); + // Read the body top again: the click cleared the announcement band the + // builtin above put up, so the body moved with it. + try std.testing.expectEqual(p.bodyTop(pane, p.rects[0]), cursor.y); panes.File.setContent(p, &pane.file.?, try p.gpa.dupe(u8, "// no enclosing declaration\n" ** 18)); _ = try p.render(frame.allocator()); try std.testing.expectEqual(@as(u16, 0), pane.context_rows); @@ -576,12 +580,16 @@ const TreeContextTests = struct { target = .{ .x = @intCast(col), .y = @intCast(row) }; }; const glyph = target orelse return error.MissingWrappedContextBody; + const offset = pane.body_offset; ClickCursorTests.click(p, .left, glyph.x + 1, glyph.y); try std.testing.expectEqual(@as(i32, 2), pane.cur_row); try std.testing.expectEqual(@as(i32, @intCast(std.mem.indexOf(u8, body, "界").?)), pane.cur_col); const cursor = (try p.render(frame.allocator())).cursor orelse return error.MissingContextBodyCursor; try std.testing.expectEqual(glyph.x, cursor.x); - try std.testing.expectEqual(glyph.y, cursor.y); + // The scan above ran with the builtin's announcement band up; the click + // cleared it, so the row the glyph was found on has moved up with the + // body it belongs to. + try std.testing.expectEqual(glyph.y - offset, cursor.y); } }; @@ -607,7 +615,7 @@ const TtySelectionTests = struct { _ = try p.render(frame.allocator()); const rect = p.rects[0]; const x = rect.x + config.GUTTER; - const y = if (p.settings.tag_bottom) rect.y else rect.y + pardes.BOX_H; + const y = p.bodyTop(pane, rect); JumpSelectionTests.drag(p, x + 1, y, x + 3, y); try std.testing.expectEqualStrings("lph", p.yank orelse return error.MissingAutomaticTtyYank); p.update(.{ .key = .{ .cp = p.opts.tty_toggle, .ctrl = true } }); @@ -637,7 +645,7 @@ const TtySelectionTests = struct { _ = try p.render(frame.allocator()); const rect = p.rects[0]; const x = rect.x + config.GUTTER; - const y = if (p.settings.tag_bottom) rect.y else rect.y + pardes.BOX_H; + const y = p.bodyTop(pane, rect); JumpSelectionTests.drag(p, x + @as(u16, if (prompt) 0 else 1), y, x + 3, y + @as(u16, if (prompt) 0 else 1)); const expected = if (prompt) "$ ab" else "lph\nrav"; try std.testing.expectEqual(Pane.Mode.tty, pane.mode); @@ -952,7 +960,7 @@ const JumpSelectionTests = struct { if (wrap) try std.testing.expectEqual(pane.wrap_line[0], pane.wrap_line[1]); const rect = p.rects[0]; const x = rect.x + config.GUTTER + panes.File.gutterWidth(pane); - const y = if (p.settings.tag_bottom) rect.y else rect.y + pardes.BOX_H; + const y = p.bodyTop(pane, rect); if (reverse) drag(p, x + last_col, y + 1, x + first_col, y) else @@ -982,7 +990,9 @@ const JumpSelectionTests = struct { try std.testing.expectEqual(@as(i32, 0), pane.cur_col); // A selection created after Back must also disappear on Forward. - drag(p, x + 1, y, x + 3, y + 1); + // Back announces itself, so the body sits under a notice band now. + const y2 = p.bodyTop(pane, p.rects[0]); + drag(p, x + 1, y2, x + 3, y2 + 1); try std.testing.expect(pardes.test_api.heldSelection(p, 0) != null); p.update(.{ .key = .{ .cp = 'i', .ctrl = true } }); _ = frame.reset(.retain_capacity); @@ -4117,7 +4127,7 @@ test "cancelled normal gestures leave no count or subprefix after mouse and focu .body, .tag => { const rect = p.rects[0]; const tag_y = if (p.settings.tag_bottom) rect.y + rect.h - pardes.BOX_H else rect.y; - const body_y = if (p.settings.tag_bottom) rect.y else rect.y + pardes.BOX_H; + const body_y = p.bodyTop(pane, rect); const x = rect.x + config.GUTTER + @as(u16, @intCast(panes.File.gutterWidth(pane))) + 3; const y = if (gesture == .tag) tag_y else body_y; p.update(.{ .mouse = .{ .button = config.select_button, .kind = .press, .col = x, .row = y } }); diff --git a/test/snapshot.zig b/test/snapshot.zig index 7fa84a86..7cc5eb91 100644 --- a/test/snapshot.zig +++ b/test/snapshot.zig @@ -619,7 +619,13 @@ fn runScript(arena: std.mem.Allocator, exe_z: [:0]const u8, script_path: []const const cmd = tok.next().?; errdefer std.debug.print(" at {s}:{d}: {s}\n", .{ script_path, lineno, line }); - if (std.mem.eql(u8, cmd, "file")) { + if (std.mem.eql(u8, cmd, "config")) { + // Appended to the startup config this script's fake home already + // has, so a script can pin a setting instead of spelling out the + // screen geometry a default implies. Must precede `start`. + const setting = try std.fmt.allocPrint(arena, "{s}\n", .{tok.rest()}); + try eh.appendFile(try std.fmt.allocPrintSentinel(arena, "{s}/pardes/init", .{config_home}, 0), setting); + } else if (std.mem.eql(u8, cmd, "file")) { const name = tok.next() orelse return error.BadScript; try eh.writeFile(try arena.dupeZ(u8, name), try unescape(arena, tok.rest())); } else if (std.mem.eql(u8, cmd, "lines")) { diff --git a/test/snapshots/argv.golden b/test/snapshots/argv.golden index 4da2a12d..abf5781d 100644 --- a/test/snapshots/argv.golden +++ b/test/snapshots/argv.golden @@ -1,14 +1,31 @@ == snap noargs grid=100x31 cursor=4,5 |Newcol Joincol Find Grep Help Changelog Tutor Dump NextColor Debug Kill -|New Tty Find Grep Joincol -|$ /tmp/pardes-snap/argv/cwd Save Tty Del Togglettymode Filter Collapse +| New Tty Find Grep Joincol Delcol +|$ /tmp/pardes-snap/argv/cwd Tty Save Mode Filter Collapse Del | $ echo ARGV''TTY | ARGVTTY | $ +| +| +| +| +| +| +| +| +| +| +| +| +| +| +| +| /+New Save Tty Collapse Del +| 1 == snap filearg grid=100x31 cursor=7,3 |Newcol Joincol Find Grep Help Changelog Tutor Dump NextColor Debug Kill -|New Tty Find Grep Joincol -| /tmp/pardes-snap/argv/cwd/notes.txt Save Tty Del Collapse +| New Tty Find Grep Joincol Delcol +| /tmp/pardes-snap/argv/cwd/notes.txt Save Tty Collapse Del | 3 line 3 | 4 line 4 | 5 line 5 @@ -18,8 +35,8 @@ | 9 == snap filearg-n3 grid=100x31 cursor=7,3 |Newcol Joincol Find Grep Help Changelog Tutor Dump NextColor Debug Kill -|New Tty Find Grep Joincol -| /tmp/pardes-snap/argv/cwd/notes.txt Save Tty Del Collapse +| New Tty Find Grep Joincol Delcol +| /tmp/pardes-snap/argv/cwd/notes.txt Save Tty Collapse Del | 1 line 1 | 2 line 2 | 3 line 3 @@ -31,7 +48,7 @@ | 9 == snap dirarg grid=100x31 cursor=4,5 |Newcol Joincol Find Grep Help Changelog Tutor Dump NextColor Debug Kill -|New Tty Find Grep Joincol -| /tmp/pardes-snap/argv/cwd/sub Save Tty Del Togglettymode Filter Collapse +| New Tty Find Grep Joincol Delcol +| /tmp/pardes-snap/argv/cwd/sub Tty Save Mode Filter Collapse Del | ls | inside.txt diff --git a/test/snapshots/badutf.golden b/test/snapshots/badutf.golden index 270b3fe6..d3a906b1 100644 --- a/test/snapshots/badutf.golden +++ b/test/snapshots/badutf.golden @@ -1,7 +1,7 @@ == snap badbytes grid=100x31 cursor=7,3 |Newcol Joincol Find Grep Help Changelog Tutor Dump NextColor Debug Kill -|New Tty Find Grep Joincol -| /tmp/pardes-snap/badutf/cwd/bad.txt Save Tty Del Collapse +| New Tty Find Grep Joincol Delcol +| /tmp/pardes-snap/badutf/cwd/bad.txt Save Tty Collapse Del | 1 hello �� world | 2 latin-1 caf� tail | 3 truncated �� here @@ -9,8 +9,8 @@ | 5 == snap hscroll-midglyph grid=50x31 cursor=46,3 |Newcol Joincol Find Grep Help Changelog Tutor Dump -|New Tty Find Grep Joincol -| /tmp/pardes-snap/badutf/cwd/wide.txt Save Tty De +| New Tty Find Grep Joincol Delcol +| /tmp/pardes-snap/badutf/cwd/wide.txt Save Tty C | 1 日本語 日本語 日本語 日本語 日本語 tail | 2 | 3 diff --git a/test/snapshots/boot.golden b/test/snapshots/boot.golden index f1e159d1..2e4ad22f 100644 --- a/test/snapshots/boot.golden +++ b/test/snapshots/boot.golden @@ -1,38 +1,38 @@ == snap boot grid=100x31 cursor=4,5 |Newcol Joincol Find Grep Help Changelog Tutor Dump NextColor Debug Kill -|New Tty Find Grep Joincol -| /tmp/pardes-snap/boot/cwd Save Tty Del Togglettymode Filter Collapse +| New Tty Find Grep Joincol Delcol +| /tmp/pardes-snap/boot/cwd Tty Save Mode Filter Collapse Del | ls | hello.txt == style boot grid=100x31 |0: 0-70 #b2c3b8,#1d2824, 71-99 d,#1d2824, -|1: 0-24 #becfc4,#26362d, 25-99 d,#26362d, -|2: 0-1 #000000,#adcc91, 2-69 #becfc4,#26362d, 70-99 d,#26362d, -|3: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-99 #e5eee5,#0d1410, -|4: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-99 #e5eee5,#0d1410, -|5: 0-0 d,#637f6a, 1-99 d,#0d1410, -|6: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-99 #e5eee5,#0d1410, -|7: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-99 #e5eee5,#0d1410, -|8: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-99 #e5eee5,#0d1410, -|9: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-99 #e5eee5,#0d1410, -|10: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-99 #e5eee5,#0d1410, -|11: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-99 #e5eee5,#0d1410, -|12: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-99 #e5eee5,#0d1410, -|13: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-99 #e5eee5,#0d1410, -|14: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-99 #e5eee5,#0d1410, -|15: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-99 #e5eee5,#0d1410, -|16: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-99 #e5eee5,#0d1410, -|17: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-99 #e5eee5,#0d1410, -|18: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-99 #e5eee5,#0d1410, -|19: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-99 #e5eee5,#0d1410, -|20: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-99 #e5eee5,#0d1410, -|21: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-99 #e5eee5,#0d1410, -|22: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-99 #e5eee5,#0d1410, -|23: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-99 #e5eee5,#0d1410, -|24: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-99 #e5eee5,#0d1410, -|25: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-99 #e5eee5,#0d1410, -|26: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-99 #e5eee5,#0d1410, -|27: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-99 #e5eee5,#0d1410, -|28: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-99 #e5eee5,#0d1410, -|29: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-99 #e5eee5,#0d1410, -|30: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-99 #e5eee5,#0d1410, +|1: 0-1 #ffffff,#887455, 2-2 d,#26362d, 3-34 #becfc4,#26362d, 35-99 d,#26362d, +|2: 0-1 #000000,#add38a, 2-2 d,#26362d, 3-28 #becfc4,#26362d, 29-31 #dfbce5,#26362d, 32-61 #becfc4,#26362d, 62-99 d,#26362d, +|3: 0-0 d,#608269, 1-1 d,#0d1410, 2-99 #e5eee5,#0d1410, +|4: 0-0 d,#608269, 1-1 d,#0d1410, 2-99 #e5eee5,#0d1410, +|5: 0-0 d,#608269, 1-99 d,#0d1410, +|6: 0-0 d,#608269, 1-1 d,#0d1410, 2-99 #e5eee5,#0d1410, +|7: 0-0 d,#608269, 1-1 d,#0d1410, 2-99 #e5eee5,#0d1410, +|8: 0-0 d,#608269, 1-1 d,#0d1410, 2-99 #e5eee5,#0d1410, +|9: 0-0 d,#608269, 1-1 d,#0d1410, 2-99 #e5eee5,#0d1410, +|10: 0-0 d,#608269, 1-1 d,#0d1410, 2-99 #e5eee5,#0d1410, +|11: 0-0 d,#608269, 1-1 d,#0d1410, 2-99 #e5eee5,#0d1410, +|12: 0-0 d,#608269, 1-1 d,#0d1410, 2-99 #e5eee5,#0d1410, +|13: 0-0 d,#608269, 1-1 d,#0d1410, 2-99 #e5eee5,#0d1410, +|14: 0-0 d,#608269, 1-1 d,#0d1410, 2-99 #e5eee5,#0d1410, +|15: 0-0 d,#608269, 1-1 d,#0d1410, 2-99 #e5eee5,#0d1410, +|16: 0-0 d,#608269, 1-1 d,#0d1410, 2-99 #e5eee5,#0d1410, +|17: 0-0 d,#608269, 1-1 d,#0d1410, 2-99 #e5eee5,#0d1410, +|18: 0-0 d,#608269, 1-1 d,#0d1410, 2-99 #e5eee5,#0d1410, +|19: 0-0 d,#608269, 1-1 d,#0d1410, 2-99 #e5eee5,#0d1410, +|20: 0-0 d,#608269, 1-1 d,#0d1410, 2-99 #e5eee5,#0d1410, +|21: 0-0 d,#608269, 1-1 d,#0d1410, 2-99 #e5eee5,#0d1410, +|22: 0-0 d,#608269, 1-1 d,#0d1410, 2-99 #e5eee5,#0d1410, +|23: 0-0 d,#608269, 1-1 d,#0d1410, 2-99 #e5eee5,#0d1410, +|24: 0-0 d,#608269, 1-1 d,#0d1410, 2-99 #e5eee5,#0d1410, +|25: 0-0 d,#608269, 1-1 d,#0d1410, 2-99 #e5eee5,#0d1410, +|26: 0-0 d,#608269, 1-1 d,#0d1410, 2-99 #e5eee5,#0d1410, +|27: 0-0 d,#608269, 1-1 d,#0d1410, 2-99 #e5eee5,#0d1410, +|28: 0-0 d,#608269, 1-1 d,#0d1410, 2-99 #e5eee5,#0d1410, +|29: 0-0 d,#608269, 1-1 d,#0d1410, 2-99 #e5eee5,#0d1410, +|30: 0-0 d,#608269, 1-1 d,#0d1410, 2-99 #e5eee5,#0d1410, diff --git a/test/snapshots/builtins.golden b/test/snapshots/builtins.golden index 17b4db5e..96dabb54 100644 --- a/test/snapshots/builtins.golden +++ b/test/snapshots/builtins.golden @@ -1,7 +1,7 @@ == snap boot grid=120x67 cursor=7,3 |Newcol Joincol Find Grep Help Changelog Tutor Dump NextColor Debug Kill -|New Tty Find Grep Joincol -| /tmp/pardes-snap/builtins/cwd/notes.txt Save Tty Del Collapse +| New Tty Find Grep Joincol Delcol +| /tmp/pardes-snap/builtins/cwd/notes.txt Save Tty Collapse Del | 1 line 1 | 2 line 2 | 3 line 3 @@ -10,23 +10,23 @@ | 6 line 6 | 7 == snap window-group grid=120x67 cursor=7,36 -|35: /tmp/pardes-snap/builtins/cwd/+Help Save Tty Del Collapse +|35: /tmp/pardes-snap/builtins/cwd/+Help Save Tty Collapse Del |36: 1 pardes builtins under SPC w |37: 2 -|38: 3 SPC w h Left C-w h, C-w left -|39: 4 SPC w j Down C-w j, C-w down -|40: 5 SPC w k Up C-w k, C-w up -|41: 6 SPC w l Right C-w l, C-w right +|38: 3 SPC w h Left C-w h, C-w left +|39: 4 SPC w j Down C-w j, C-w down +|40: 5 SPC w k Up C-w k, C-w up +|41: 6 SPC w l Right C-w l, C-w right |42: 7 == snap docs-group grid=120x67 cursor=7,36 |36: 1 pardes builtins under SPC h -|38: 3 SPC h c Changelog topbar +|38: 3 SPC h c Changelog topbar |39: 4 SPC h m Messages -|40: 5 SPC h t Tutor topbar +|40: 5 SPC h t Tutor topbar |41: 6 |42: == snap tutor-from-index grid=120x67 cursor=7,20 -|19: /Tutor Save Tty Del Collapse +|19: /Tutor Save Tty Collapse Del |20: 1 |21: 2 PARDES TUTOR |22: 3 tmux + vi + acme, from scratch. @@ -42,3 +42,10 @@ |32: 13 |33: 14 A pane is just text on screen. There is no separate "buffer" type — |34: 15 what you see is what you edit. Some panes happen to be live terminals; +|36: Tutor +|37: 1 pardes builtins under SPC h +|38: 2 +|39: 3 SPC h c Changelog topbar +|40: 4 SPC h m Messages +|41: 5 SPC h t Tutor topbar +|42: 6 diff --git a/test/snapshots/builtins.snap b/test/snapshots/builtins.snap index 06298d77..cd47209f 100644 --- a/test/snapshots/builtins.snap +++ b/test/snapshots/builtins.snap @@ -9,19 +9,26 @@ key space ? wait 10000 pardes builtins, and how to run each: wait 10000 ClipPasteBefore key g e -# The new Collapse entry adds one index line: expose Look above the bottom -# viewport while keeping the same pane geometry for the later group clicks. +# Every builtin added since adds an index line, and one wheel tick is one row +# (config.wheel_rows): scroll far enough to expose Look and Exec above the +# bottom viewport while keeping the same pane geometry for the later clicks. wheel up 110 50 -wait 10000 Look enter, right-click -wait 10000 Exec tab, middle-click +wheel up 110 50 +wheel up 110 50 +wheel up 110 50 +wheel up 110 50 +wheel up 110 50 +wheel up 110 50 +wait 10000 Look enter, right-click +wait 10000 Exec tab, middle-click wait 10000 Filter wait 10000 Theme stable 700 15000 # n moves through look-able text; it must not execute command names. key n n n -wait 10000 Look enter, right-click -wait 10000 Exec tab, middle-click +wait 10000 Look enter, right-click +wait 10000 Exec tab, middle-click key space w ? wait 10000 Right stable 700 15000 diff --git a/test/snapshots/chordcut.golden b/test/snapshots/chordcut.golden index 33bc8356..a9586983 100644 --- a/test/snapshots/chordcut.golden +++ b/test/snapshots/chordcut.golden @@ -1,11 +1,11 @@ == snap opened grid=120x31 cursor=7,7 |Newcol Joincol Find Grep Help Changelog Tutor Dump NextColor Debug Kill -|New Tty Find Grep Joincol New Tty Find Grep Joincol -| /tmp/pardes-snap/chordcut/cwd Save Tty Del Togglettymode F /tmp/pardes-snap/chordcut/cwd Save Tty Del Togglettymode F -| ls ls -| f.txt g.txt f.txt g.txt -| -| /tmp/pardes-snap/chordcut/cwd/f.txt Save Tty Del Collapse +| New Tty Find Grep Joincol Delcol New Tty Find Grep Joincol Delcol +| /tmp/pardes-snap/chordcut/cwd Tty Save Mode Filter Collap /tmp/pardes-snap/chordcut/cwd Tty Save Mode Filter Collap +| Look ls +| ls f.txt g.txt +| f.txt g.txt +| /tmp/pardes-snap/chordcut/cwd/f.txt Save Tty Collapse Del | 1 line 1 | 2 line 2 | 3 line 3 @@ -16,11 +16,14 @@ | | | -| /tmp/pardes-snap/chordcut/cwd Save Tty Del Togglettymode F +| /tmp/pardes-snap/chordcut/cwd Tty Save Mode Filter Collap | ls | f.txt g.txt == snap cut grid=120x31 cursor=7,8 -|6: /tmp/pardes-snap/chordcut/cwd/f.txt * Save Tty Del Collaps +|3: ls ls +|4: f.txt g.txt f.txt g.txt +|5: +|6: /tmp/pardes-snap/chordcut/cwd/f.txt * Save Tty Collapse D |8: 2 2 == snap copied grid=120x31 cursor=10,9 == snap pointpaste grid=120x31 cursor=16,10 @@ -29,53 +32,77 @@ |11: 5 lline 5 == snap cancelexec grid=120x31 cursor=25,8 |8: 2 2echo B''OO g.txt -== snap execafter grid=120x31 cursor=25,8 +== snap execafter grid=120x31 cursor=25,9 |3: f.txt ls |4: BOO f.txt g.txt +|7: Exec +|8: 1 line 1 +|9: 2 2echo B''OO g.txt +|10: 3 line 3 +|11: 4 line 4line +|12: 5 lline 5 +|13: 6 == snap cancellook grid=120x31 cursor=25,8 +|7: 1 line 1 +|8: 2 2echo B''OO g.txt +|9: 3 line 3 +|10: 4 line 4line +|11: 5 lline 5 +|12: 6 +|13: == snap lookafter grid=120x31 cursor=7,13 -|12: /tmp/pardes-snap/chordcut/cwd/g.txt Save Tty Del Collapse +|7: Look +|8: 1 line 1 +|9: 2 2echo B''OO g.txt +|10: 3 line 3 +|11: 4 line 4line +|12: /tmp/pardes-snap/chordcut/cwd/g.txt Save Tty Collapse Del |13: 1 line 1 |14: 2 line 2 |15: 3 == style chordsel grid=120x31 |0: 0-70 #b2c3b8,#1d2824, 71-119 d,#1d2824, -|1: 0-24 #becfc4,#26362d, 25-59 d,#26362d, 60-84 #b2c3b8,#1d2824, 85-119 d,#1d2824, -|2: 0-1 #ffffff,#4c6356, 2-59 #b2c3b8,#1d2824, 60-61 #ffffff,#4c6356, 62-119 #b2c3b8,#1d2824, -|3: 0-0 d,#152019, 1-1 d,#0d1410, 2-8 #e5eee5,#0d1410, 9-59 d,#0d1410, 60-60 d,#637f6a, 61-61 d,#0d1410, 62-119 #e5eee5,#0d1410, -|4: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-59 #e5eee5,#0d1410, 60-60 d,#637f6a, 61-61 d,#0d1410, 62-119 #e5eee5,#0d1410, -|5: 0-0 d,#152019, 1-59 d,#0d1410, 60-60 d,#637f6a, 61-119 d,#0d1410, -|6: 0-1 #ffffff,#4c6356, 2-59 #b2c3b8,#1d2824, 60-60 d,#637f6a, 61-61 d,#0d1410, 62-119 #e5eee5,#0d1410, -|7: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-12 #e5eee5,#0d1410, 13-59 d,#0d1410, 60-60 d,#637f6a, 61-61 d,#0d1410, 62-119 #e5eee5,#0d1410, -|8: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-24 #e5eee5,#0d1410, 25-59 d,#0d1410, 60-60 d,#637f6a, 61-61 d,#0d1410, 62-119 #e5eee5,#0d1410, -|9: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-12 #e5eee5,#0d1410, 13-59 d,#0d1410, 60-60 d,#637f6a, 61-61 d,#0d1410, 62-119 #e5eee5,#0d1410, -|10: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-16 #e5eee5,#0d1410, 17-59 d,#0d1410, 60-60 d,#637f6a, 61-61 d,#0d1410, 62-119 #e5eee5,#0d1410, -|11: 0-0 d,#152019, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-13 #e5eee5,#0d1410, 14-59 d,#0d1410, 60-60 d,#637f6a, 61-61 d,#0d1410, 62-119 #e5eee5,#0d1410, -|12: 0-1 #000000,#adcc91, 2-59 #becfc4,#26362d, 60-60 d,#637f6a, 61-61 d,#0d1410, 62-119 #e5eee5,#0d1410, -|13: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-6 #616f64,#0d1410,b 7-10 #f5f7ee,#405d4b, 11-12 #e5eee5,#0d1410, 13-59 d,#0d1410, 60-60 d,#637f6a, 61-61 d,#0d1410, 62-119 #e5eee5,#0d1410, -|14: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-12 #e5eee5,#0d1410, 13-59 d,#0d1410, 60-60 d,#637f6a, 61-61 d,#0d1410, 62-119 #e5eee5,#0d1410, -|15: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-59 d,#0d1410, 60-60 d,#637f6a, 61-61 d,#0d1410, 62-119 #e5eee5,#0d1410, -|16: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-59 d,#0d1410, 60-60 d,#637f6a, 61-61 d,#0d1410, 62-119 #e5eee5,#0d1410, -|17: 0-1 #ffffff,#4c6356, 2-59 #b2c3b8,#1d2824, 60-60 d,#637f6a, 61-61 d,#0d1410, 62-119 #e5eee5,#0d1410, -|18: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-59 #e5eee5,#0d1410, 60-60 d,#637f6a, 61-61 d,#0d1410, 62-119 #e5eee5,#0d1410, -|19: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-59 #e5eee5,#0d1410, 60-60 d,#637f6a, 61-61 d,#0d1410, 62-119 #e5eee5,#0d1410, -|20: 0-0 d,#637f6a, 1-59 d,#0d1410, 60-60 d,#637f6a, 61-61 d,#0d1410, 62-119 #e5eee5,#0d1410, -|21: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-59 #e5eee5,#0d1410, 60-60 d,#637f6a, 61-61 d,#0d1410, 62-119 #e5eee5,#0d1410, -|22: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-59 #e5eee5,#0d1410, 60-60 d,#637f6a, 61-61 d,#0d1410, 62-119 #e5eee5,#0d1410, -|23: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-59 #e5eee5,#0d1410, 60-60 d,#637f6a, 61-61 d,#0d1410, 62-119 #e5eee5,#0d1410, -|24: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-59 #e5eee5,#0d1410, 60-60 d,#637f6a, 61-61 d,#0d1410, 62-119 #e5eee5,#0d1410, -|25: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-59 #e5eee5,#0d1410, 60-60 d,#637f6a, 61-61 d,#0d1410, 62-119 #e5eee5,#0d1410, -|26: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-59 #e5eee5,#0d1410, 60-60 d,#637f6a, 61-61 d,#0d1410, 62-119 #e5eee5,#0d1410, -|27: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-59 #e5eee5,#0d1410, 60-60 d,#637f6a, 61-61 d,#0d1410, 62-119 #e5eee5,#0d1410, -|28: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-59 #e5eee5,#0d1410, 60-60 d,#637f6a, 61-61 d,#0d1410, 62-119 #e5eee5,#0d1410, -|29: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-59 #e5eee5,#0d1410, 60-60 d,#637f6a, 61-61 d,#0d1410, 62-119 #e5eee5,#0d1410, -|30: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-59 #e5eee5,#0d1410, 60-60 d,#637f6a, 61-61 d,#0d1410, 62-119 #e5eee5,#0d1410, +|1: 0-1 #ffffff,#887455, 2-2 d,#26362d, 3-34 #becfc4,#26362d, 35-59 d,#26362d, 60-61 #ffffff,#887455, 62-62 d,#1d2824, 63-94 #b2c3b8,#1d2824, 95-119 d,#1d2824, +|2: 0-1 #ffffff,#496656, 2-2 d,#1d2824, 3-32 #b2c3b8,#1d2824, 33-35 #d3b0d9,#1d2824, 36-59 #b2c3b8,#1d2824, 60-61 #ffffff,#496656, 62-62 d,#1d2824, 63-92 #b2c3b8,#1d2824, 93-95 #d3b0d9,#1d2824, 96-119 #b2c3b8,#1d2824, +|3: 0-0 d,#152019, 1-1 d,#0d1410, 2-8 #e5eee5,#0d1410, 9-59 d,#0d1410, 60-60 d,#608269, 61-61 d,#0d1410, 62-119 #e5eee5,#0d1410, +|4: 0-0 d,#608269, 1-1 d,#0d1410, 2-59 #e5eee5,#0d1410, 60-60 d,#608269, 61-61 d,#0d1410, 62-119 #e5eee5,#0d1410, +|5: 0-0 d,#152019, 1-59 d,#0d1410, 60-60 d,#608269, 61-119 d,#0d1410, +|6: 0-1 #ffffff,#496656, 2-2 d,#1d2824, 3-32 #b2c3b8,#1d2824, 33-37 #d3b0d9,#1d2824, 38-59 #b2c3b8,#1d2824, 60-60 d,#608269, 61-61 d,#0d1410, 62-119 #e5eee5,#0d1410, +|7: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-12 #e5eee5,#0d1410, 13-59 d,#0d1410, 60-60 d,#608269, 61-61 d,#0d1410, 62-119 #e5eee5,#0d1410, +|8: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-24 #e5eee5,#0d1410, 25-59 d,#0d1410, 60-60 d,#608269, 61-61 d,#0d1410, 62-119 #e5eee5,#0d1410, +|9: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-12 #e5eee5,#0d1410, 13-59 d,#0d1410, 60-60 d,#608269, 61-61 d,#0d1410, 62-119 #e5eee5,#0d1410, +|10: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-16 #e5eee5,#0d1410, 17-59 d,#0d1410, 60-60 d,#608269, 61-61 d,#0d1410, 62-119 #e5eee5,#0d1410, +|11: 0-0 d,#152019, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-13 #e5eee5,#0d1410, 14-59 d,#0d1410, 60-60 d,#608269, 61-61 d,#0d1410, 62-119 #e5eee5,#0d1410, +|12: 0-1 #000000,#add38a, 2-2 d,#26362d, 3-32 #becfc4,#26362d, 33-37 #dfbce5,#26362d, 38-59 #becfc4,#26362d, 60-60 d,#608269, 61-61 d,#0d1410, 62-119 #e5eee5,#0d1410, +|13: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #616f64,#0d1410,b 7-10 #f5f7ee,#3c614a, 11-12 #e5eee5,#0d1410, 13-59 d,#0d1410, 60-60 d,#608269, 61-61 d,#0d1410, 62-119 #e5eee5,#0d1410, +|14: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-12 #e5eee5,#0d1410, 13-59 d,#0d1410, 60-60 d,#608269, 61-61 d,#0d1410, 62-119 #e5eee5,#0d1410, +|15: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-59 d,#0d1410, 60-60 d,#608269, 61-61 d,#0d1410, 62-119 #e5eee5,#0d1410, +|16: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-59 d,#0d1410, 60-60 d,#608269, 61-61 d,#0d1410, 62-119 #e5eee5,#0d1410, +|17: 0-1 #ffffff,#496656, 2-2 d,#1d2824, 3-32 #b2c3b8,#1d2824, 33-35 #d3b0d9,#1d2824, 36-59 #b2c3b8,#1d2824, 60-60 d,#608269, 61-61 d,#0d1410, 62-119 #e5eee5,#0d1410, +|18: 0-0 d,#608269, 1-1 d,#0d1410, 2-59 #e5eee5,#0d1410, 60-60 d,#608269, 61-61 d,#0d1410, 62-119 #e5eee5,#0d1410, +|19: 0-0 d,#608269, 1-1 d,#0d1410, 2-59 #e5eee5,#0d1410, 60-60 d,#608269, 61-61 d,#0d1410, 62-119 #e5eee5,#0d1410, +|20: 0-0 d,#608269, 1-59 d,#0d1410, 60-60 d,#608269, 61-61 d,#0d1410, 62-119 #e5eee5,#0d1410, +|21: 0-0 d,#608269, 1-1 d,#0d1410, 2-59 #e5eee5,#0d1410, 60-60 d,#608269, 61-61 d,#0d1410, 62-119 #e5eee5,#0d1410, +|22: 0-0 d,#608269, 1-1 d,#0d1410, 2-59 #e5eee5,#0d1410, 60-60 d,#608269, 61-61 d,#0d1410, 62-119 #e5eee5,#0d1410, +|23: 0-0 d,#608269, 1-1 d,#0d1410, 2-59 #e5eee5,#0d1410, 60-60 d,#608269, 61-61 d,#0d1410, 62-119 #e5eee5,#0d1410, +|24: 0-0 d,#608269, 1-1 d,#0d1410, 2-59 #e5eee5,#0d1410, 60-60 d,#608269, 61-61 d,#0d1410, 62-119 #e5eee5,#0d1410, +|25: 0-0 d,#608269, 1-1 d,#0d1410, 2-59 #e5eee5,#0d1410, 60-60 d,#608269, 61-61 d,#0d1410, 62-119 #e5eee5,#0d1410, +|26: 0-0 d,#608269, 1-1 d,#0d1410, 2-59 #e5eee5,#0d1410, 60-60 d,#608269, 61-61 d,#0d1410, 62-119 #e5eee5,#0d1410, +|27: 0-0 d,#608269, 1-1 d,#0d1410, 2-59 #e5eee5,#0d1410, 60-60 d,#608269, 61-61 d,#0d1410, 62-119 #e5eee5,#0d1410, +|28: 0-0 d,#608269, 1-1 d,#0d1410, 2-59 #e5eee5,#0d1410, 60-60 d,#608269, 61-61 d,#0d1410, 62-119 #e5eee5,#0d1410, +|29: 0-0 d,#608269, 1-1 d,#0d1410, 2-59 #e5eee5,#0d1410, 60-60 d,#608269, 61-61 d,#0d1410, 62-119 #e5eee5,#0d1410, +|30: 0-0 d,#608269, 1-1 d,#0d1410, 2-59 #e5eee5,#0d1410, 60-60 d,#608269, 61-61 d,#0d1410, 62-119 #e5eee5,#0d1410, == style clickdismiss grid=120x31 -|13: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-12 #e5eee5,#0d1410, 13-59 d,#0d1410, 60-60 d,#637f6a, 61-61 d,#0d1410, 62-119 #e5eee5,#0d1410, -|14: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-6 #616f64,#0d1410,b 7-12 #e5eee5,#0d1410, 13-59 d,#0d1410, 60-60 d,#637f6a, 61-61 d,#0d1410, 62-119 #e5eee5,#0d1410, +|13: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-12 #e5eee5,#0d1410, 13-59 d,#0d1410, 60-60 d,#608269, 61-61 d,#0d1410, 62-119 #e5eee5,#0d1410, +|14: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #616f64,#0d1410,b 7-12 #e5eee5,#0d1410, 13-59 d,#0d1410, 60-60 d,#608269, 61-61 d,#0d1410, 62-119 #e5eee5,#0d1410, == snap ttyprobe grid=120x31 cursor=42,22 -|12: /tmp/pardes-snap/chordcut/cwd/g.txt * Save Tty Del Collaps -|17: $ /tmp/pardes-snap/chordcut/cwd Save Tty Del Togglettymode F +|7: 1 line 1 +|8: 2 2echo B''OO g.txt +|9: 3 line 3 +|10: 4 line 4line +|11: 5 lline 5 +|12: /tmp/pardes-snap/chordcut/cwd/g.txt * Save Tty Collapse D +|17: $ /tmp/pardes-snap/chordcut/cwd Tty Save Mode Filter Collap |18: $ ls |20: $ stty -icanon -echo; printf '\x1b[?2004h\x1b[?1000h\x1b[? |21: 1006h'; cat -v diff --git a/test/snapshots/cmdword.golden b/test/snapshots/cmdword.golden index 0ba57092..e6f470fa 100644 --- a/test/snapshots/cmdword.golden +++ b/test/snapshots/cmdword.golden @@ -1,24 +1,24 @@ == snap opened grid=120x31 cursor=7,3 |Newcol Joincol Find Grep Help Changelog Tutor Dump NextColor Debug Kill -|New Tty Find Grep Joincol -| /tmp/pardes-snap/cmdword/cwd/cmds.txt Save Tty Del Collapse +| New Tty Find Grep Joincol Delcol +| /tmp/pardes-snap/cmdword/cwd/cmds.txt Save Tty Collapse Del | 1 @`echo ZZ''E` @`echo ZZ''L` Look p.txt @`Look .` == snap atexec grid=120x31 cursor=7,3 -|17: /tmp/pardes-snap/cmdword/cwd Save Tty Del Togglettymode Filter Collapse +|17: /tmp/pardes-snap/cmdword/cwd Tty Save Mode Filter Collapse Del |18: echo ZZ''E |19: ZZE == snap atlook grid=120x31 cursor=4,22 |20: echo ZZ''L |21: ZZL == snap lookword grid=120x31 cursor=7,11 -|10: /tmp/pardes-snap/cmdword/cwd/p.txt Save Tty Del Collapse +|10: /tmp/pardes-snap/cmdword/cwd/p.txt Save Tty Collapse Del |11: 1 just text == snap nested grid=120x31 cursor=4,24 |22: ls |23: cmds.txt p.txt zzmark.txt -== snap execword grid=120x31 cursor=77,17 -|17: /tmp/pardes-snap/cmdword/cwd Save Tty Del Togglettymode Filter Collapse Exec -== snap tagcmd grid=120x31 cursor=91,17 -|17: /tmp/pardes-snap/cmdword/cwd Save Tty Del Togglettymode Filter Collapse Exec @`echo ZZ''T` +== snap execword grid=120x31 cursor=69,17 +|17: /tmp/pardes-snap/cmdword/cwd Tty Save Mode Filter Collapse Del Exec +== snap tagcmd grid=120x31 cursor=83,17 +|17: /tmp/pardes-snap/cmdword/cwd Tty Save Mode Filter Collapse Del Exec @`echo ZZ''T` |24: echo ZZ''T |25: ZZT diff --git a/test/snapshots/cmdword.snap b/test/snapshots/cmdword.snap index eb9d308d..eb0e0ea6 100644 --- a/test/snapshots/cmdword.snap +++ b/test/snapshots/cmdword.snap @@ -18,6 +18,10 @@ file cmds.txt @`echo ZZ''E` @`echo ZZ''L` Look p.txt @`Look .` file p.txt just text file zzmark.txt x +# Builtins announce themselves by default, and an announcement is a band at +# the top of the body -- which would move every row this script clicks. The +# verbs are what is under test here, not the announcement. +config Verbose off start 31 120 cmds.txt wait 8000 Newcol Joincol wait 8000 cmds.txt diff --git a/test/snapshots/collapse.golden b/test/snapshots/collapse.golden index 8dcfd4d7..d356fd02 100644 --- a/test/snapshots/collapse.golden +++ b/test/snapshots/collapse.golden @@ -1,7 +1,7 @@ == snap before grid=160x25 cursor=7,3 |Newcol Joincol Find Grep Help Changelog Tutor Dump NextColor Debug Kill -|New Tty Find Grep Joincol -| /tmp/pardes-snap/collapse/cwd/kept.txt Save Tty Del Collapse +| New Tty Find Grep Joincol Delcol +| /tmp/pardes-snap/collapse/cwd/kept.txt Save Tty Collapse Del | 1 KEEP-FIRST | 2 KEEP-SECOND | 3 KEEP-THIRD @@ -12,67 +12,70 @@ == 9p middle-collapsed-cursor grid=160x25 cursor=none |0: Newcol Joincol Find Grep Help Changelog Tutor Dump NextColor Debug Kill @0: 0-70 #b2c3b8,#1d2824,,tagline 71-159 d,#1d2824,,tagline -|1: New Tty Find Grep Joincol -@1: 0-24 #becfc4,#26362d,,tagline 25-159 d,#26362d,,tagline -|2: /tmp/pardes-snap/collapse/cwd/kept.txt Save Tty Del Collapse -@2: 0-1 #000000,#adcc91,,tagline 2-61 #becfc4,#26362d,,tagline 62-159 d,#26362d,,tagline +|1: New Tty Find Grep Joincol Delcol +@1: 0-1 #ffffff,#887455,,tagline 2-2 d,#26362d,,tagline 3-34 #becfc4,#26362d,,tagline 35-159 d,#26362d,,tagline +|2: /tmp/pardes-snap/collapse/cwd/kept.txt Save Tty Collapse Del +@2: 0-1 #000000,#add38a,,tagline 2-2 d,#26362d,,tagline 3-32 #becfc4,#26362d,,tagline 33-40 #dfbce5,#26362d,,tagline 41-62 #becfc4,#26362d,,tagline 63-159 d,#26362d,,tagline |3: -@3: 0-159 d,#35483d,,body +@3: 0-159 d,#486152,,body |4: -@4: 0-159 d,#35483d,,body +@4: 0-159 d,#486152,,body |5: -@5: 0-159 d,#35483d,,body +@5: 0-159 d,#486152,,body |6: -@6: 0-159 d,#35483d,,body +@6: 0-159 d,#486152,,body |7: -@7: 0-159 d,#35483d,,body +@7: 0-159 d,#486152,,body |8: -@8: 0-159 d,#35483d,,body +@8: 0-159 d,#486152,,body |9: -@9: 0-159 d,#35483d,,body +@9: 0-159 d,#486152,,body |10: -@10: 0-159 d,#35483d,,body +@10: 0-159 d,#486152,,body |11: -@11: 0-159 d,#35483d,,body +@11: 0-159 d,#486152,,body |12: -@12: 0-159 d,#35483d,,body +@12: 0-159 d,#486152,,body |13: -@13: 0-159 d,#35483d,,body +@13: 0-159 d,#486152,,body |14: -@14: 0-159 d,#35483d,,body +@14: 0-159 d,#486152,,body |15: -@15: 0-159 d,#35483d,,body +@15: 0-159 d,#486152,,body |16: -@16: 0-159 d,#35483d,,body +@16: 0-159 d,#486152,,body |17: -@17: 0-159 d,#35483d,,body +@17: 0-159 d,#486152,,body |18: -@18: 0-159 d,#35483d,,body +@18: 0-159 d,#486152,,body |19: -@19: 0-159 d,#35483d,,body +@19: 0-159 d,#486152,,body |20: -@20: 0-159 d,#35483d,,body +@20: 0-159 d,#486152,,body |21: -@21: 0-159 d,#35483d,,body +@21: 0-159 d,#486152,,body |22: -@22: 0-159 d,#35483d,,body +@22: 0-159 d,#486152,,body |23: -@23: 0-159 d,#35483d,,body +@23: 0-159 d,#486152,,body |24: -@24: 0-159 d,#35483d,,body -== snap middle-restored grid=160x25 cursor=7,3 -|3: 1 KEEP-FIRST -|4: 2 KEEP-SECOND -|5: 3 KEEP-THIRD -== snap tab-collapsed grid=160x25 cursor=54,2 +@24: 0-159 d,#486152,,body +== snap middle-restored grid=160x25 cursor=7,4 +|3: Collapse +|4: 1 KEEP-FIRST +|5: 2 KEEP-SECOND +|6: 3 KEEP-THIRD +== snap tab-collapsed grid=160x25 cursor=51,2 |3: |4: |5: -== 9p tab-collapsed-cursor grid=160x25 cursor=54,2,bar -== snap tab-restored grid=160x25 cursor=54,2 -|3: 1 KEEP-FIRST -|4: 2 KEEP-SECOND -|5: 3 KEEP-THIRD +|6: +== 9p tab-collapsed-cursor grid=160x25 cursor=51,2,bar +== snap tab-restored grid=160x25 cursor=51,2 +|3: Collapse +|4: 1 KEEP-FIRST +|5: 2 KEEP-SECOND +|6: 3 KEEP-THIRD == file unchanged KEEP-FIRST KEEP-SECOND diff --git a/test/snapshots/cornerdrag-left.golden b/test/snapshots/cornerdrag-left.golden index df10fd3d..145adb02 100644 --- a/test/snapshots/cornerdrag-left.golden +++ b/test/snapshots/cornerdrag-left.golden @@ -1,11 +1,11 @@ == snap right-split grid=100x31 cursor=54,9 |Newcol Joincol Find Grep Help Changelog Tutor Dump NextColor Debug Kill -|New Tty Find Grep Joincol New Tty Find Grep Joincol -| /tmp/pardes-snap/cornerdrag-left/cwd Save Tty De /tmp/pardes-snap/cornerdrag-left/cwd Save Tty De +| New Tty Find Grep Joincol Delcol New Tty Find Grep Joincol Delcol +| /tmp/pardes-snap/cornerdrag-left/cwd Tty Save M /tmp/pardes-snap/cornerdrag-left/cwd Tty Save M | ls ls | w.txt w.txt | -| /tmp/pardes-snap/cornerdrag-left/cwd Save Tty De +| /tmp/pardes-snap/cornerdrag-left/cwd Tty Save M | ls | w.txt | @@ -16,16 +16,16 @@ | | | -| /tmp/pardes-snap/cornerdrag-left/cwd Save Tty De +| /tmp/pardes-snap/cornerdrag-left/cwd Tty Save M | ls | w.txt == snap hover-corner grid=100x31 cursor=54,9 -|1: New Tty Find Grep Joincol ╎New Tty Find Grep Joincol -|2: /tmp/pardes-snap/cornerdrag-left/cwd Save Tty D╎ /tmp/pardes-snap/cornerdrag-left/cwd Save Tty De +|1: New Tty Find Grep Joincol Delcol ╎ New Tty Find Grep Joincol Delcol +|2: /tmp/pardes-snap/cornerdrag-left/cwd Tty Save ╎ /tmp/pardes-snap/cornerdrag-left/cwd Tty Save M |3: ls ╎ ls |4: w.txt ╎ w.txt |5: ╎ -|6: ╎ /tmp/pardes-snap/cornerdrag-left/cwd Save Tty De +|6: ╎ /tmp/pardes-snap/cornerdrag-left/cwd Tty Save M |7: ╎ ls |8: ╎ w.txt |9: ╎ @@ -36,7 +36,7 @@ |14: ╎ |15: ╎ |16: ╎ -|17: /tmp/pardes-snap/cornerdrag-left/cwd Save Tty D╎ +|17: /tmp/pardes-snap/cornerdrag-left/cwd Tty Save ╎ |18: ls ╎ |19: w.txt ╎ |20: ╎ @@ -52,12 +52,12 @@ |30: ╎ == snap hover-left-corner grid=100x31 cursor=54,9 == snap corner-drag grid=100x31 cursor=54,9 -|1: New Tty Find Grep Joincol ╎ New Tty Find Grep Joincol -|2: /tmp/pardes-snap/cornerdrag╎left/cwd Save Tty De /tmp/pardes-snap/cornerdrag-left/cwd Save Tty De +|1: New Tty Find Grep Joincol ╎elcol New Tty Find Grep Joincol Delcol +|2: /tmp/pardes-snap/cornerdra╎-left/cwd Tty Save M /tmp/pardes-snap/cornerdrag-left/cwd Tty Save M |3: ls ╎ ls |4: w.txt ╎ w.txt |5: ╎ -|6: ╎ /tmp/pardes-snap/cornerdrag-left/cwd Save Tty De +|6: ╎ /tmp/pardes-snap/cornerdrag-left/cwd Tty Save M |7: ╎ ls |8: ╎ w.txt |9: ╎ @@ -68,7 +68,7 @@ |14: ╎ |15: ╎ |16: ╎ -|17: /tmp/pardes-snap/cornerdrag╎left/cwd Save Tty De +|17: /tmp/pardes-snap/cornerdra╎-left/cwd Tty Save M |18: ls ╎ |19: w.txt ╎ |20: ╎ @@ -83,8 +83,8 @@ |29: ╎ |30: ╎ == snap corner-done grid=100x31 cursor=34,16 -|1: New Tty Find Grep Joincol New Tty Find Grep Joincol -|2: /tmp/pardes-snap/cornerdrag- /tmp/pardes-snap/cornerdrag-left/cwd Save Tty Del Togglettymode Filt +|1: New Tty Find Grep Joincol D New Tty Find Grep Joincol Delcol +|2: /tmp/pardes-snap/cornerdrag /tmp/pardes-snap/cornerdrag-left/cwd Tty Save Mode Filter Collapse |3: ls ls |4: w.txt w.txt |5: @@ -95,11 +95,11 @@ |10: |11: |12: -|13: /tmp/pardes-snap/cornerdrag-left/cwd Save Tty Del Togglettymode Filt +|13: /tmp/pardes-snap/cornerdrag-left/cwd Tty Save Mode Filter Collapse |14: ls |15: w.txt |16: -|17: /tmp/pardes-snap/cornerdrag- +|17: /tmp/pardes-snap/cornerdrag |18: ls |19: w.txt |20: diff --git a/test/snapshots/cornerdrag.golden b/test/snapshots/cornerdrag.golden index 003bf0d8..b95734ea 100644 --- a/test/snapshots/cornerdrag.golden +++ b/test/snapshots/cornerdrag.golden @@ -1,7 +1,7 @@ == snap hover-corner grid=100x31 cursor=4,5 |Newcol Joincol Find Grep Help Changelog Tutor Dump NextColor Debug Kill -|New Tty Find Grep Joincol ╎New Tty Find Grep Joincol -| /tmp/pardes-snap/cornerdrag/cwd Save Tty Del To╎ /tmp/pardes-snap/cornerdrag/cwd Save Tty Del Tog +| New Tty Find Grep Joincol Delcol ╎ New Tty Find Grep Joincol Delcol +| /tmp/pardes-snap/cornerdrag/cwd Tty Save Mode ╎ /tmp/pardes-snap/cornerdrag/cwd Tty Save Mode F | ls ╎ ls | w.txt ╎ w.txt | ╎ @@ -16,7 +16,7 @@ | ╎ | ╎ | ╎ -| /tmp/pardes-snap/cornerdrag/cwd Save Tty Del To╎ +| /tmp/pardes-snap/cornerdrag/cwd Tty Save Mode ╎ | ls ╎ | w.txt ╎ | ╎ @@ -31,8 +31,8 @@ | ╎ | ╎ == snap edge-drag grid=100x31 cursor=4,5 -|1: New Tty Find Grep Joincol ╎ New Tty Find Grep Joincol -|2: /tmp/pardes-snap/cornerdrag╎cwd Save Tty Del Tog /tmp/pardes-snap/cornerdrag/cwd Save Tty Del Tog +|1: New Tty Find Grep Joincol ╎elcol New Tty Find Grep Joincol Delcol +|2: /tmp/pardes-snap/cornerdra╎/cwd Tty Save Mode F /tmp/pardes-snap/cornerdrag/cwd Tty Save Mode F |3: ls ╎ ls |4: w.txt ╎ w.txt |5: ╎ @@ -47,7 +47,7 @@ |14: ╎ |15: ╎ |16: ╎ -|17: /tmp/pardes-snap/cornerdrag╎cwd Save Tty Del Tog +|17: /tmp/pardes-snap/cornerdra╎/cwd Tty Save Mode F |18: ls ╎ |19: w.txt ╎ |20: ╎ @@ -62,8 +62,8 @@ |29: ╎ |30: ╎ == snap edge-done grid=100x31 cursor=4,5 -|1: New Tty Find Grep Joincol New Tty Find Grep Joincol -|2: /tmp/pardes-snap/cornerdrag/ /tmp/pardes-snap/cornerdrag/cwd Save Tty Del Togglettymode Filter Co +|1: New Tty Find Grep Joincol D New Tty Find Grep Joincol Delcol +|2: /tmp/pardes-snap/cornerdrag /tmp/pardes-snap/cornerdrag/cwd Tty Save Mode Filter Collapse Del |3: ls ls |4: w.txt w.txt |5: @@ -78,7 +78,7 @@ |14: |15: |16: -|17: /tmp/pardes-snap/cornerdrag/ +|17: /tmp/pardes-snap/cornerdrag |18: ls |19: w.txt |20: @@ -93,8 +93,8 @@ |29: |30: == snap corner-drag grid=100x31 cursor=4,5 -|1: New Tty Find Grep Joincol New Tty Find Grep Joincol ╎ -|2: /tmp/pardes-snap/cornerdrag/ /tmp/pardes-snap/cornerdrag╎cwd Save Tty Del Togglettymode Filter Co +|1: New Tty Find Grep Joincol D New Tty Find Grep Joincol ╎elcol +|2: /tmp/pardes-snap/cornerdrag /tmp/pardes-snap/cornerdra╎/cwd Tty Save Mode Filter Collapse Del |3: ls ls ╎ |4: w.txt w.txt ╎ |5: ╎ @@ -109,7 +109,7 @@ |14: ╎ |15: ╎ |16: ╎ -|17: /tmp/pardes-snap/cornerdrag/ ╎ +|17: /tmp/pardes-snap/cornerdrag ╎ |18: ls ╎ |19: w.txt ╎ |20: ╎ @@ -124,15 +124,15 @@ |29: ╎ |30: ╎ == snap corner-done grid=100x31 cursor=4,5 -|1: New Tty Find Grep Joincol New Tty Find Grep Joincol -|2: /tmp/pardes-snap/cornerdrag/cwd Save Tty Del Togglettymode /tmp/pardes-snap/cornerdrag/cwd Save T +|1: New Tty Find Grep Joincol Delcol New Tty Find Grep Joincol Delcol +|2: /tmp/pardes-snap/cornerdrag/cwd Tty Save Mode Filter Coll /tmp/pardes-snap/cornerdrag/cwd Tty S |3: ls ls |4: w.txt w.txt |5: |6: |7: |8: -|9: /tmp/pardes-snap/cornerdrag/cwd Save Tty Del Togglettymode +|9: /tmp/pardes-snap/cornerdrag/cwd Tty Save Mode Filter Coll |10: ls |11: w.txt |12: @@ -155,15 +155,15 @@ |29: |30: == snap clamp-x grid=100x31 cursor=4,5 -|1: New Tty Find Grep Joincol New Tty Find Grep Joincol ╎ -|2: /tmp/pardes-snap/cornerdrag/cwd Save Tty Del Togglettymode /tmp/pardes-snap/cornerdrag/╎wd Save T +|1: New Tty Find Grep Joincol Delcol New Tty Find Grep Joincol D╎lcol +|2: /tmp/pardes-snap/cornerdrag/cwd Tty Save Mode Filter Coll /tmp/pardes-snap/cornerdrag╎cwd Tty S |3: ls ls ╎ |4: w.txt w.txt ╎ |5: ╎ |6: ╎ |7: ╎ |8: ╎ -|9: /tmp/pardes-snap/cornerdrag/cwd Save Tty Del Togglettymode ╎ +|9: /tmp/pardes-snap/cornerdrag/cwd Tty Save Mode Filter Coll ╎ |10: ls ╎ |11: w.txt ╎ |12: ╎ @@ -186,15 +186,15 @@ |29: ╎ |30: ╎ == snap clamp-y grid=100x31 cursor=4,5 -|1: New Tty Find Grep Joincol ╎New Tty Find Grep Joincol -|2: /tmp/pardes-snap/cornerdrag/cwd Save Tty Del Togglettymod╎ /tmp/pardes-snap/cornerdrag/cwd Save T +|1: New Tty Find Grep Joincol Delcol ╎ New Tty Find Grep Joincol Delcol +|2: /tmp/pardes-snap/cornerdrag/cwd Tty Save Mode Filter Col╎ /tmp/pardes-snap/cornerdrag/cwd Tty S |3: ls ╎ ls |4: w.txt ╎ w.txt |5: ╎ |6: ╎ |7: ╎ |8: ╎ -|9: /tmp/pardes-snap/cornerdrag/cwd Save Tty Del Togglettymod╎ +|9: /tmp/pardes-snap/cornerdrag/cwd Tty Save Mode Filter Col╎ |10: ls ╎ |11: w.txt ╎ |12: ╎ @@ -217,8 +217,8 @@ |29: ╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌ |30: ╎ == snap clamp-done grid=100x31 cursor=4,5 -|1: New Tty Find Grep Joincol New Tty Find Grep Joincol -|2: /tmp/pardes-snap/cornerdrag/cwd Save Tty Del Togglettymode /tmp/pardes-snap/cornerdrag/cwd Save T +|1: New Tty Find Grep Joincol Delcol New Tty Find Grep Joincol Delcol +|2: /tmp/pardes-snap/cornerdrag/cwd Tty Save Mode Filter Coll /tmp/pardes-snap/cornerdrag/cwd Tty S |3: ls ls |4: w.txt w.txt |5: @@ -246,4 +246,4 @@ |27: |28: |29: -|30: /tmp/pardes-snap/cornerdrag/cwd Save Tty Del Togglettymode +|30: /tmp/pardes-snap/cornerdrag/cwd Tty Save Mode Filter Coll diff --git a/test/snapshots/cursorline.golden b/test/snapshots/cursorline.golden index 161655c8..97897c3f 100644 --- a/test/snapshots/cursorline.golden +++ b/test/snapshots/cursorline.golden @@ -1,11 +1,11 @@ == snap top grid=150x31 cursor=7,7 |Newcol Joincol Find Grep Help Changelog Tutor Dump NextColor Debug Kill -|New Tty Find Grep Joincol New Tty Find Grep Joincol -| /tmp/pardes-snap/cursorline/cwd Save Tty Del Togglettymode Filter Collaps /tmp/pardes-snap/cursorline/cwd Save Tty Del Togglettymode Filter Collaps +| New Tty Find Grep Joincol Delcol New Tty Find Grep Joincol Delcol +| /tmp/pardes-snap/cursorline/cwd Tty Save Mode Filter Collapse Del /tmp/pardes-snap/cursorline/cwd Tty Save Mode Filter Collapse Del | ls ls | cur.txt cur.txt | -| /tmp/pardes-snap/cursorline/cwd/cur.txt Save Tty Del Collapse +| /tmp/pardes-snap/cursorline/cwd/cur.txt Save Tty Collapse Del | 1 line 1 | 2 line 2 | 3 line 3 @@ -16,42 +16,42 @@ | 8 line 8 | 9 line 9 | 10 line 10 -| /tmp/pardes-snap/cursorline/cwd Save Tty Del Togglettymode Filter Collaps +| /tmp/pardes-snap/cursorline/cwd Tty Save Mode Filter Collapse Del | ls | cur.txt == style top grid=150x31 |0: 0-70 #b2c3b8,#1d2824, 71-149 d,#1d2824, -|1: 0-24 #becfc4,#26362d, 25-74 d,#26362d, 75-99 #b2c3b8,#1d2824, 100-149 d,#1d2824, -|2: 0-1 #ffffff,#4c6356, 2-74 #b2c3b8,#1d2824, 75-76 #ffffff,#4c6356, 77-149 #b2c3b8,#1d2824, -|3: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-74 #e5eee5,#0d1410, 75-75 d,#637f6a, 76-76 d,#0d1410, 77-149 #e5eee5,#0d1410, -|4: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-74 #e5eee5,#0d1410, 75-75 d,#637f6a, 76-76 d,#0d1410, 77-149 #e5eee5,#0d1410, -|5: 0-0 d,#637f6a, 1-74 d,#0d1410, 75-75 d,#637f6a, 76-149 d,#0d1410, -|6: 0-1 #000000,#adcc91, 2-62 #becfc4,#26362d, 63-74 d,#26362d, 75-75 d,#637f6a, 76-76 d,#0d1410, 77-149 #e5eee5,#0d1410, -|7: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-6 #616f64,#0d1410,b 7-12 #e5eee5,#0d1410, 13-74 d,#0d1410, 75-75 d,#637f6a, 76-76 d,#0d1410, 77-149 #e5eee5,#0d1410, -|8: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-12 #e5eee5,#0d1410, 13-74 d,#0d1410, 75-75 d,#637f6a, 76-76 d,#0d1410, 77-149 #e5eee5,#0d1410, -|9: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-12 #e5eee5,#0d1410, 13-74 d,#0d1410, 75-75 d,#637f6a, 76-76 d,#0d1410, 77-149 #e5eee5,#0d1410, -|10: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-12 #e5eee5,#0d1410, 13-74 d,#0d1410, 75-75 d,#637f6a, 76-76 d,#0d1410, 77-149 #e5eee5,#0d1410, -|11: 0-0 d,#152019, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-12 #e5eee5,#0d1410, 13-74 d,#0d1410, 75-75 d,#637f6a, 76-76 d,#0d1410, 77-149 #e5eee5,#0d1410, -|12: 0-0 d,#152019, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-12 #e5eee5,#0d1410, 13-74 d,#0d1410, 75-75 d,#637f6a, 76-76 d,#0d1410, 77-149 #e5eee5,#0d1410, -|13: 0-0 d,#152019, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-12 #e5eee5,#0d1410, 13-74 d,#0d1410, 75-75 d,#637f6a, 76-76 d,#0d1410, 77-149 #e5eee5,#0d1410, -|14: 0-0 d,#152019, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-12 #e5eee5,#0d1410, 13-74 d,#0d1410, 75-75 d,#637f6a, 76-76 d,#0d1410, 77-149 #e5eee5,#0d1410, -|15: 0-0 d,#152019, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-12 #e5eee5,#0d1410, 13-74 d,#0d1410, 75-75 d,#637f6a, 76-76 d,#0d1410, 77-149 #e5eee5,#0d1410, -|16: 0-0 d,#152019, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-13 #e5eee5,#0d1410, 14-74 d,#0d1410, 75-75 d,#637f6a, 76-76 d,#0d1410, 77-149 #e5eee5,#0d1410, -|17: 0-1 #ffffff,#4c6356, 2-74 #b2c3b8,#1d2824, 75-75 d,#637f6a, 76-76 d,#0d1410, 77-149 #e5eee5,#0d1410, -|18: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-74 #e5eee5,#0d1410, 75-75 d,#637f6a, 76-76 d,#0d1410, 77-149 #e5eee5,#0d1410, -|19: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-74 #e5eee5,#0d1410, 75-75 d,#637f6a, 76-76 d,#0d1410, 77-149 #e5eee5,#0d1410, -|20: 0-0 d,#637f6a, 1-74 d,#0d1410, 75-75 d,#637f6a, 76-76 d,#0d1410, 77-149 #e5eee5,#0d1410, -|21: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-74 #e5eee5,#0d1410, 75-75 d,#637f6a, 76-76 d,#0d1410, 77-149 #e5eee5,#0d1410, -|22: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-74 #e5eee5,#0d1410, 75-75 d,#637f6a, 76-76 d,#0d1410, 77-149 #e5eee5,#0d1410, -|23: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-74 #e5eee5,#0d1410, 75-75 d,#637f6a, 76-76 d,#0d1410, 77-149 #e5eee5,#0d1410, -|24: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-74 #e5eee5,#0d1410, 75-75 d,#637f6a, 76-76 d,#0d1410, 77-149 #e5eee5,#0d1410, -|25: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-74 #e5eee5,#0d1410, 75-75 d,#637f6a, 76-76 d,#0d1410, 77-149 #e5eee5,#0d1410, -|26: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-74 #e5eee5,#0d1410, 75-75 d,#637f6a, 76-76 d,#0d1410, 77-149 #e5eee5,#0d1410, -|27: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-74 #e5eee5,#0d1410, 75-75 d,#637f6a, 76-76 d,#0d1410, 77-149 #e5eee5,#0d1410, -|28: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-74 #e5eee5,#0d1410, 75-75 d,#637f6a, 76-76 d,#0d1410, 77-149 #e5eee5,#0d1410, -|29: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-74 #e5eee5,#0d1410, 75-75 d,#637f6a, 76-76 d,#0d1410, 77-149 #e5eee5,#0d1410, -|30: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-74 #e5eee5,#0d1410, 75-75 d,#637f6a, 76-76 d,#0d1410, 77-149 #e5eee5,#0d1410, +|1: 0-1 #ffffff,#887455, 2-2 d,#26362d, 3-34 #becfc4,#26362d, 35-74 d,#26362d, 75-76 #ffffff,#887455, 77-77 d,#1d2824, 78-109 #b2c3b8,#1d2824, 110-149 d,#1d2824, +|2: 0-1 #ffffff,#496656, 2-2 d,#1d2824, 3-34 #b2c3b8,#1d2824, 35-37 #d3b0d9,#1d2824, 38-67 #b2c3b8,#1d2824, 68-74 d,#1d2824, 75-76 #ffffff,#496656, 77-77 d,#1d2824, 78-109 #b2c3b8,#1d2824, 110-112 #d3b0d9,#1d2824, 113-142 #b2c3b8,#1d2824, 143-149 d,#1d2824, +|3: 0-0 d,#608269, 1-1 d,#0d1410, 2-74 #e5eee5,#0d1410, 75-75 d,#608269, 76-76 d,#0d1410, 77-149 #e5eee5,#0d1410, +|4: 0-0 d,#608269, 1-1 d,#0d1410, 2-74 #e5eee5,#0d1410, 75-75 d,#608269, 76-76 d,#0d1410, 77-149 #e5eee5,#0d1410, +|5: 0-0 d,#608269, 1-74 d,#0d1410, 75-75 d,#608269, 76-149 d,#0d1410, +|6: 0-1 #000000,#add38a, 2-2 d,#26362d, 3-34 #becfc4,#26362d, 35-41 #dfbce5,#26362d, 42-63 #becfc4,#26362d, 64-74 d,#26362d, 75-75 d,#608269, 76-76 d,#0d1410, 77-149 #e5eee5,#0d1410, +|7: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #616f64,#0d1410,b 7-12 #e5eee5,#0d1410, 13-74 d,#0d1410, 75-75 d,#608269, 76-76 d,#0d1410, 77-149 #e5eee5,#0d1410, +|8: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-12 #e5eee5,#0d1410, 13-74 d,#0d1410, 75-75 d,#608269, 76-76 d,#0d1410, 77-149 #e5eee5,#0d1410, +|9: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-12 #e5eee5,#0d1410, 13-74 d,#0d1410, 75-75 d,#608269, 76-76 d,#0d1410, 77-149 #e5eee5,#0d1410, +|10: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-12 #e5eee5,#0d1410, 13-74 d,#0d1410, 75-75 d,#608269, 76-76 d,#0d1410, 77-149 #e5eee5,#0d1410, +|11: 0-0 d,#152019, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-12 #e5eee5,#0d1410, 13-74 d,#0d1410, 75-75 d,#608269, 76-76 d,#0d1410, 77-149 #e5eee5,#0d1410, +|12: 0-0 d,#152019, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-12 #e5eee5,#0d1410, 13-74 d,#0d1410, 75-75 d,#608269, 76-76 d,#0d1410, 77-149 #e5eee5,#0d1410, +|13: 0-0 d,#152019, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-12 #e5eee5,#0d1410, 13-74 d,#0d1410, 75-75 d,#608269, 76-76 d,#0d1410, 77-149 #e5eee5,#0d1410, +|14: 0-0 d,#152019, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-12 #e5eee5,#0d1410, 13-74 d,#0d1410, 75-75 d,#608269, 76-76 d,#0d1410, 77-149 #e5eee5,#0d1410, +|15: 0-0 d,#152019, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-12 #e5eee5,#0d1410, 13-74 d,#0d1410, 75-75 d,#608269, 76-76 d,#0d1410, 77-149 #e5eee5,#0d1410, +|16: 0-0 d,#152019, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-13 #e5eee5,#0d1410, 14-74 d,#0d1410, 75-75 d,#608269, 76-76 d,#0d1410, 77-149 #e5eee5,#0d1410, +|17: 0-1 #ffffff,#496656, 2-2 d,#1d2824, 3-34 #b2c3b8,#1d2824, 35-37 #d3b0d9,#1d2824, 38-67 #b2c3b8,#1d2824, 68-74 d,#1d2824, 75-75 d,#608269, 76-76 d,#0d1410, 77-149 #e5eee5,#0d1410, +|18: 0-0 d,#608269, 1-1 d,#0d1410, 2-74 #e5eee5,#0d1410, 75-75 d,#608269, 76-76 d,#0d1410, 77-149 #e5eee5,#0d1410, +|19: 0-0 d,#608269, 1-1 d,#0d1410, 2-74 #e5eee5,#0d1410, 75-75 d,#608269, 76-76 d,#0d1410, 77-149 #e5eee5,#0d1410, +|20: 0-0 d,#608269, 1-74 d,#0d1410, 75-75 d,#608269, 76-76 d,#0d1410, 77-149 #e5eee5,#0d1410, +|21: 0-0 d,#608269, 1-1 d,#0d1410, 2-74 #e5eee5,#0d1410, 75-75 d,#608269, 76-76 d,#0d1410, 77-149 #e5eee5,#0d1410, +|22: 0-0 d,#608269, 1-1 d,#0d1410, 2-74 #e5eee5,#0d1410, 75-75 d,#608269, 76-76 d,#0d1410, 77-149 #e5eee5,#0d1410, +|23: 0-0 d,#608269, 1-1 d,#0d1410, 2-74 #e5eee5,#0d1410, 75-75 d,#608269, 76-76 d,#0d1410, 77-149 #e5eee5,#0d1410, +|24: 0-0 d,#608269, 1-1 d,#0d1410, 2-74 #e5eee5,#0d1410, 75-75 d,#608269, 76-76 d,#0d1410, 77-149 #e5eee5,#0d1410, +|25: 0-0 d,#608269, 1-1 d,#0d1410, 2-74 #e5eee5,#0d1410, 75-75 d,#608269, 76-76 d,#0d1410, 77-149 #e5eee5,#0d1410, +|26: 0-0 d,#608269, 1-1 d,#0d1410, 2-74 #e5eee5,#0d1410, 75-75 d,#608269, 76-76 d,#0d1410, 77-149 #e5eee5,#0d1410, +|27: 0-0 d,#608269, 1-1 d,#0d1410, 2-74 #e5eee5,#0d1410, 75-75 d,#608269, 76-76 d,#0d1410, 77-149 #e5eee5,#0d1410, +|28: 0-0 d,#608269, 1-1 d,#0d1410, 2-74 #e5eee5,#0d1410, 75-75 d,#608269, 76-76 d,#0d1410, 77-149 #e5eee5,#0d1410, +|29: 0-0 d,#608269, 1-1 d,#0d1410, 2-74 #e5eee5,#0d1410, 75-75 d,#608269, 76-76 d,#0d1410, 77-149 #e5eee5,#0d1410, +|30: 0-0 d,#608269, 1-1 d,#0d1410, 2-74 #e5eee5,#0d1410, 75-75 d,#608269, 76-76 d,#0d1410, 77-149 #e5eee5,#0d1410, == snap down3 grid=150x31 cursor=7,10 == style down3 grid=150x31 -|7: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-12 #e5eee5,#0d1410, 13-74 d,#0d1410, 75-75 d,#637f6a, 76-76 d,#0d1410, 77-149 #e5eee5,#0d1410, -|10: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-6 #616f64,#0d1410,b 7-12 #e5eee5,#0d1410, 13-74 d,#0d1410, 75-75 d,#637f6a, 76-76 d,#0d1410, 77-149 #e5eee5,#0d1410, +|7: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-12 #e5eee5,#0d1410, 13-74 d,#0d1410, 75-75 d,#608269, 76-76 d,#0d1410, 77-149 #e5eee5,#0d1410, +|10: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #616f64,#0d1410,b 7-12 #e5eee5,#0d1410, 13-74 d,#0d1410, 75-75 d,#608269, 76-76 d,#0d1410, 77-149 #e5eee5,#0d1410, diff --git a/test/snapshots/doccol.golden b/test/snapshots/doccol.golden index 318ac564..83d49ca5 100644 --- a/test/snapshots/doccol.golden +++ b/test/snapshots/doccol.golden @@ -1,21 +1,21 @@ == snap boot grid=100x31 cursor=7,3 |Newcol Joincol Find Grep Help Changelog Tutor Dump NextColor Debug Kill -|New Tty Find Grep Joincol New Tty Find Grep Joincol -| /tmp/pardes-snap/doccol/cwd/a.txt Save Tty Del C /tmp/pardes-snap/doccol/cwd Save Tty Del Togglet +| New Tty Find Grep Joincol Delcol New Tty Find Grep Joincol Delcol +| /tmp/pardes-snap/doccol/cwd/a.txt Save Tty Coll /tmp/pardes-snap/doccol/cwd Tty Save Mode Filte | 1 AAA ls | a.txt b.txt c.txt == snap two-docs grid=100x31 cursor=7,18 -|17: /tmp/pardes-snap/doccol/cwd/b.txt Save Tty Del C +|17: /tmp/pardes-snap/doccol/cwd/b.txt Save Tty Coll |18: 1 BBB |19: 2 B-TWO == snap moved grid=100x31 cursor=57,21 |17: |18: |19: -|20: /tmp/pardes-snap/doccol/cwd/b.txt Save Tty Del C +|20: /tmp/pardes-snap/doccol/cwd/b.txt Save Tty Coll |21: 1 BBB |22: 2 B-TWO == snap worked grid=100x31 cursor=59,22 == snap third grid=100x31 cursor=57,27 -|26: /tmp/pardes-snap/doccol/cwd/c.txt Save Tty Del C +|26: /tmp/pardes-snap/doccol/cwd/c.txt Save Tty Coll |27: 1 CCC diff --git a/test/snapshots/doccol.snap b/test/snapshots/doccol.snap index 677d5dff..2135c533 100644 --- a/test/snapshots/doccol.snap +++ b/test/snapshots/doccol.snap @@ -13,6 +13,10 @@ file c.txt CCC # boot used to hand over — and SPC w h comes back to a.txt, which is where the # boot left focus. (`New`/`Newcol` open an empty +New scratch now, not a # shell, so the shell has to be asked for by name.) +# Builtins announce themselves by default, and an announcement is a band at +# the top of the body -- which moves every row this script clicks. What the +# verbs do is what is under test, not the announcement. +config Verbose off start 31 100 a.txt wait 8000 AAA stable 700 20000 diff --git a/test/snapshots/dump.golden b/test/snapshots/dump.golden index 18c30327..8f920136 100644 --- a/test/snapshots/dump.golden +++ b/test/snapshots/dump.golden @@ -7,6 +7,13 @@ .topbar = "Newcol Joincol Find Grep Help Changelog Tutor Dump NextColor Debug Kill", .topbar_custom = null, .theme = "orchard", + .locations_config = .{ + .context = 0, + .tscontext = false, + .tslocations = true, + .layout = .stacked, + }, + .tree_context_tag_style = true, .columns = .{ .{ .tag = null, .weight = 1, @@ -19,7 +26,7 @@ .panes = .{ .{ .kind = .terminal, - .tag = "/tmp/pardes-snap/dump/cwd Save Tty Del Togglettymode Filter Collapse", + .tag = "/tmp/pardes-snap/dump/cwd Tty Save Mode Filter Collapse Del", .body = "ls\nd.txt\n\n\n\n typed-marker\n\n\n\n\n\n\n\n", .scroll = 0, .cols = 48, @@ -38,7 +45,7 @@ }, .{ .kind = .terminal, - .tag = "/tmp/pardes-snap/dump/cwd Save Tty Del Togglettymode Filter Collapse", + .tag = "/tmp/pardes-snap/dump/cwd Tty Save Mode Filter Collapse Del", .body = "ls\nd.txt\n\n\n\n\n\n\n\n\n\n\n", .scroll = 0, .cols = 48, @@ -57,7 +64,7 @@ }, .{ .kind = .terminal, - .tag = "/tmp/pardes-snap/dump/cwd Save Tty Del Togglettymode Filter Collapse", + .tag = "/tmp/pardes-snap/dump/cwd Tty Save Mode Filter Collapse Del", .body = "ls\nd.txt\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n", .scroll = 0, .cols = 48, diff --git a/test/snapshots/edit.golden b/test/snapshots/edit.golden index 17c86be0..c4b1081e 100644 --- a/test/snapshots/edit.golden +++ b/test/snapshots/edit.golden @@ -1,7 +1,7 @@ == snap inserted grid=100x31 cursor=16,10 |Newcol Joincol Find Grep Help Changelog Tutor Dump NextColor Debug Kill -|New Tty Find Grep Joincol New Tty Find Grep Joincol -| /tmp/pardes-snap/edit/cwd Save Tty Del Toggletty /tmp/pardes-snap/edit/cwd Save Tty Del Toggletty +| New Tty Find Grep Joincol Delcol New Tty Find Grep Joincol Delcol +| /tmp/pardes-snap/edit/cwd Tty Save Mode Filter /tmp/pardes-snap/edit/cwd Tty Save Mode Filter | ls ls | e.txt e.txt | @@ -16,38 +16,38 @@ | | | -| /tmp/pardes-snap/edit/cwd Save Tty Del Toggletty +| /tmp/pardes-snap/edit/cwd Tty Save Mode Filter | ls | e.txt == style inserted grid=100x31 |0: 0-70 #b2c3b8,#1d2824, 71-99 d,#1d2824, -|1: 0-24 #becfc4,#26362d, 25-49 d,#26362d, 50-74 #b2c3b8,#1d2824, 75-99 d,#1d2824, -|2: 0-1 #000000,#adcc91, 2-49 #becfc4,#26362d, 50-51 #ffffff,#4c6356, 52-99 #b2c3b8,#1d2824, -|3: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-49 #e5eee5,#0d1410, 50-50 d,#637f6a, 51-51 d,#0d1410, 52-99 #e5eee5,#0d1410, -|4: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-49 #e5eee5,#0d1410, 50-50 d,#637f6a, 51-51 d,#0d1410, 52-99 #e5eee5,#0d1410, -|5: 0-0 d,#637f6a, 1-49 d,#0d1410, 50-50 d,#637f6a, 51-99 d,#0d1410, -|6: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-49 #e5eee5,#0d1410, 50-50 d,#637f6a, 51-51 d,#0d1410, 52-99 #e5eee5,#0d1410, -|7: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-49 #e5eee5,#0d1410, 50-50 d,#637f6a, 51-51 d,#0d1410, 52-99 #e5eee5,#0d1410, -|8: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-49 #e5eee5,#0d1410, 50-50 d,#637f6a, 51-51 d,#0d1410, 52-99 #e5eee5,#0d1410, -|9: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-49 #e5eee5,#0d1410, 50-50 d,#637f6a, 51-51 d,#0d1410, 52-99 #e5eee5,#0d1410, -|10: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-15 #e5eee5,#0d1410, 16-49 d,#0d1410, 50-50 d,#637f6a, 51-51 d,#0d1410, 52-99 #e5eee5,#0d1410, -|11: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-49 #e5eee5,#0d1410, 50-50 d,#637f6a, 51-51 d,#0d1410, 52-99 #e5eee5,#0d1410, -|12: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-49 #e5eee5,#0d1410, 50-50 d,#637f6a, 51-51 d,#0d1410, 52-99 #e5eee5,#0d1410, -|13: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-49 #e5eee5,#0d1410, 50-50 d,#637f6a, 51-51 d,#0d1410, 52-99 #e5eee5,#0d1410, -|14: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-49 #e5eee5,#0d1410, 50-50 d,#637f6a, 51-51 d,#0d1410, 52-99 #e5eee5,#0d1410, -|15: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-49 #e5eee5,#0d1410, 50-50 d,#637f6a, 51-51 d,#0d1410, 52-99 #e5eee5,#0d1410, -|16: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-49 #e5eee5,#0d1410, 50-50 d,#637f6a, 51-51 d,#0d1410, 52-99 #e5eee5,#0d1410, -|17: 0-1 #ffffff,#4c6356, 2-49 #b2c3b8,#1d2824, 50-50 d,#637f6a, 51-51 d,#0d1410, 52-99 #e5eee5,#0d1410, -|18: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-49 #e5eee5,#0d1410, 50-50 d,#637f6a, 51-51 d,#0d1410, 52-99 #e5eee5,#0d1410, -|19: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-49 #e5eee5,#0d1410, 50-50 d,#637f6a, 51-51 d,#0d1410, 52-99 #e5eee5,#0d1410, -|20: 0-0 d,#637f6a, 1-49 d,#0d1410, 50-50 d,#637f6a, 51-51 d,#0d1410, 52-99 #e5eee5,#0d1410, -|21: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-49 #e5eee5,#0d1410, 50-50 d,#637f6a, 51-51 d,#0d1410, 52-99 #e5eee5,#0d1410, -|22: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-49 #e5eee5,#0d1410, 50-50 d,#637f6a, 51-51 d,#0d1410, 52-99 #e5eee5,#0d1410, -|23: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-49 #e5eee5,#0d1410, 50-50 d,#637f6a, 51-51 d,#0d1410, 52-99 #e5eee5,#0d1410, -|24: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-49 #e5eee5,#0d1410, 50-50 d,#637f6a, 51-51 d,#0d1410, 52-99 #e5eee5,#0d1410, -|25: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-49 #e5eee5,#0d1410, 50-50 d,#637f6a, 51-51 d,#0d1410, 52-99 #e5eee5,#0d1410, -|26: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-49 #e5eee5,#0d1410, 50-50 d,#637f6a, 51-51 d,#0d1410, 52-99 #e5eee5,#0d1410, -|27: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-49 #e5eee5,#0d1410, 50-50 d,#637f6a, 51-51 d,#0d1410, 52-99 #e5eee5,#0d1410, -|28: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-49 #e5eee5,#0d1410, 50-50 d,#637f6a, 51-51 d,#0d1410, 52-99 #e5eee5,#0d1410, -|29: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-49 #e5eee5,#0d1410, 50-50 d,#637f6a, 51-51 d,#0d1410, 52-99 #e5eee5,#0d1410, -|30: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-49 #e5eee5,#0d1410, 50-50 d,#637f6a, 51-51 d,#0d1410, 52-99 #e5eee5,#0d1410, +|1: 0-1 #ffffff,#887455, 2-2 d,#26362d, 3-34 #becfc4,#26362d, 35-49 d,#26362d, 50-51 #ffffff,#887455, 52-52 d,#1d2824, 53-84 #b2c3b8,#1d2824, 85-99 d,#1d2824, +|2: 0-1 #000000,#add38a, 2-2 d,#26362d, 3-28 #becfc4,#26362d, 29-31 #dfbce5,#26362d, 32-49 #becfc4,#26362d, 50-51 #ffffff,#496656, 52-52 d,#1d2824, 53-78 #b2c3b8,#1d2824, 79-81 #d3b0d9,#1d2824, 82-99 #b2c3b8,#1d2824, +|3: 0-0 d,#608269, 1-1 d,#0d1410, 2-49 #e5eee5,#0d1410, 50-50 d,#608269, 51-51 d,#0d1410, 52-99 #e5eee5,#0d1410, +|4: 0-0 d,#608269, 1-1 d,#0d1410, 2-49 #e5eee5,#0d1410, 50-50 d,#608269, 51-51 d,#0d1410, 52-99 #e5eee5,#0d1410, +|5: 0-0 d,#608269, 1-49 d,#0d1410, 50-50 d,#608269, 51-99 d,#0d1410, +|6: 0-0 d,#608269, 1-1 d,#0d1410, 2-49 #e5eee5,#0d1410, 50-50 d,#608269, 51-51 d,#0d1410, 52-99 #e5eee5,#0d1410, +|7: 0-0 d,#608269, 1-1 d,#0d1410, 2-49 #e5eee5,#0d1410, 50-50 d,#608269, 51-51 d,#0d1410, 52-99 #e5eee5,#0d1410, +|8: 0-0 d,#608269, 1-1 d,#0d1410, 2-49 #e5eee5,#0d1410, 50-50 d,#608269, 51-51 d,#0d1410, 52-99 #e5eee5,#0d1410, +|9: 0-0 d,#608269, 1-1 d,#0d1410, 2-49 #e5eee5,#0d1410, 50-50 d,#608269, 51-51 d,#0d1410, 52-99 #e5eee5,#0d1410, +|10: 0-0 d,#608269, 1-1 d,#0d1410, 2-15 #e5eee5,#0d1410, 16-49 d,#0d1410, 50-50 d,#608269, 51-51 d,#0d1410, 52-99 #e5eee5,#0d1410, +|11: 0-0 d,#608269, 1-1 d,#0d1410, 2-49 #e5eee5,#0d1410, 50-50 d,#608269, 51-51 d,#0d1410, 52-99 #e5eee5,#0d1410, +|12: 0-0 d,#608269, 1-1 d,#0d1410, 2-49 #e5eee5,#0d1410, 50-50 d,#608269, 51-51 d,#0d1410, 52-99 #e5eee5,#0d1410, +|13: 0-0 d,#608269, 1-1 d,#0d1410, 2-49 #e5eee5,#0d1410, 50-50 d,#608269, 51-51 d,#0d1410, 52-99 #e5eee5,#0d1410, +|14: 0-0 d,#608269, 1-1 d,#0d1410, 2-49 #e5eee5,#0d1410, 50-50 d,#608269, 51-51 d,#0d1410, 52-99 #e5eee5,#0d1410, +|15: 0-0 d,#608269, 1-1 d,#0d1410, 2-49 #e5eee5,#0d1410, 50-50 d,#608269, 51-51 d,#0d1410, 52-99 #e5eee5,#0d1410, +|16: 0-0 d,#608269, 1-1 d,#0d1410, 2-49 #e5eee5,#0d1410, 50-50 d,#608269, 51-51 d,#0d1410, 52-99 #e5eee5,#0d1410, +|17: 0-1 #ffffff,#496656, 2-2 d,#1d2824, 3-28 #b2c3b8,#1d2824, 29-31 #d3b0d9,#1d2824, 32-49 #b2c3b8,#1d2824, 50-50 d,#608269, 51-51 d,#0d1410, 52-99 #e5eee5,#0d1410, +|18: 0-0 d,#608269, 1-1 d,#0d1410, 2-49 #e5eee5,#0d1410, 50-50 d,#608269, 51-51 d,#0d1410, 52-99 #e5eee5,#0d1410, +|19: 0-0 d,#608269, 1-1 d,#0d1410, 2-49 #e5eee5,#0d1410, 50-50 d,#608269, 51-51 d,#0d1410, 52-99 #e5eee5,#0d1410, +|20: 0-0 d,#608269, 1-49 d,#0d1410, 50-50 d,#608269, 51-51 d,#0d1410, 52-99 #e5eee5,#0d1410, +|21: 0-0 d,#608269, 1-1 d,#0d1410, 2-49 #e5eee5,#0d1410, 50-50 d,#608269, 51-51 d,#0d1410, 52-99 #e5eee5,#0d1410, +|22: 0-0 d,#608269, 1-1 d,#0d1410, 2-49 #e5eee5,#0d1410, 50-50 d,#608269, 51-51 d,#0d1410, 52-99 #e5eee5,#0d1410, +|23: 0-0 d,#608269, 1-1 d,#0d1410, 2-49 #e5eee5,#0d1410, 50-50 d,#608269, 51-51 d,#0d1410, 52-99 #e5eee5,#0d1410, +|24: 0-0 d,#608269, 1-1 d,#0d1410, 2-49 #e5eee5,#0d1410, 50-50 d,#608269, 51-51 d,#0d1410, 52-99 #e5eee5,#0d1410, +|25: 0-0 d,#608269, 1-1 d,#0d1410, 2-49 #e5eee5,#0d1410, 50-50 d,#608269, 51-51 d,#0d1410, 52-99 #e5eee5,#0d1410, +|26: 0-0 d,#608269, 1-1 d,#0d1410, 2-49 #e5eee5,#0d1410, 50-50 d,#608269, 51-51 d,#0d1410, 52-99 #e5eee5,#0d1410, +|27: 0-0 d,#608269, 1-1 d,#0d1410, 2-49 #e5eee5,#0d1410, 50-50 d,#608269, 51-51 d,#0d1410, 52-99 #e5eee5,#0d1410, +|28: 0-0 d,#608269, 1-1 d,#0d1410, 2-49 #e5eee5,#0d1410, 50-50 d,#608269, 51-51 d,#0d1410, 52-99 #e5eee5,#0d1410, +|29: 0-0 d,#608269, 1-1 d,#0d1410, 2-49 #e5eee5,#0d1410, 50-50 d,#608269, 51-51 d,#0d1410, 52-99 #e5eee5,#0d1410, +|30: 0-0 d,#608269, 1-1 d,#0d1410, 2-49 #e5eee5,#0d1410, 50-50 d,#608269, 51-51 d,#0d1410, 52-99 #e5eee5,#0d1410, diff --git a/test/snapshots/exec-bigdrag.golden b/test/snapshots/exec-bigdrag.golden index 6b86db0d..d18ea1b1 100644 --- a/test/snapshots/exec-bigdrag.golden +++ b/test/snapshots/exec-bigdrag.golden @@ -1,7 +1,7 @@ == snap alive grid=200x61 cursor=119,38 |Newcol Joincol Find Grep Help Changelog Tutor Dump NextColor Debug Kill -|New Tty Find Grep Joincol New Tty Find Grep Joincol -| /tmp/pardes-snap/exec-bigdrag/cwd Save Tty Del Togglettymode Filter Collapse /tmp/pardes-snap/exec-bigdrag/cwd Save Tty Del Togglettymode Filter Collapse +| New Tty Find Grep Joincol Delcol New Tty Find Grep Joincol Delcol +| /tmp/pardes-snap/exec-bigdrag/cwd Tty Save Mode Filter Collapse Del /tmp/pardes-snap/exec-bigdrag/cwd Tty Save Mode Filter Collapse Del | ls bash: line: command not found | big.txt 4line 2705line 2706line 2707line 2708line 2709line 2710line 2711line 2712line 2713line 2714lin | bash: 4line: command not found @@ -31,7 +31,7 @@ | bash: 2835line: command not found | 2846line 2847line 2848line 2849line 2850line 2851line 2852line 2853line 2854line 2855line 285 | bash: 2846line: command not found -| /tmp/pardes-snap/exec-bigdrag/cwd Save Tty Del Togglettymode Filter Collapse e 2857line 2858line 2859line 2860line 2861line 2862line 2863line 2864line 2865line 2866line 28 +| /tmp/pardes-snap/exec-bigdrag/cwd Tty Save Mode Filter Collapse Del e 2857line 2858line 2859line 2860line 2861line 2862line 2863line 2864line 2865line 2866line 28 | ls bash: e: command not found | big.txt ne 2868line 2869line 2870line 2871line 2872line 2873line 2874line 2875line 2876line 2877line 2 | bash: ne: command not found diff --git a/test/snapshots/exec-bigdrag.snap b/test/snapshots/exec-bigdrag.snap index ce7aef25..35881190 100644 --- a/test/snapshots/exec-bigdrag.snap +++ b/test/snapshots/exec-bigdrag.snap @@ -3,6 +3,10 @@ # 64-slot effect ring and panic the core (assert in emit). Needs a big grid: # the selection must exceed 64*64 bytes, more than any 30x100 pane can hold. lines big.txt 3000 +# Builtins announce themselves by default, and an announcement is a band at +# the top of the body -- which moves every row this script clicks. What the +# verbs do is what is under test, not the announcement. +config Verbose off start 61 200 -n 3 wait 8000 big.txt stable 500 20000 diff --git a/test/snapshots/exec.golden b/test/snapshots/exec.golden index 849c8e0e..6ec18f46 100644 --- a/test/snapshots/exec.golden +++ b/test/snapshots/exec.golden @@ -1,9 +1,10 @@ -== snap exec grid=100x31 cursor=16,8 +== snap exec grid=140x31 cursor=16,9 |Newcol Joincol Find Grep Help Changelog Tutor Dump NextColor Debug Kill -|New Tty Find Grep Joincol New Tty Find Grep Joincol -| /tmp/pardes-snap/exec/cwd Save Tty Del Toggletty /tmp/pardes-snap/exec/cwd Save Tty Del Toggletty -| ls ls -| e.txt e.txt +| New Tty Find Grep Joincol Delcol New Tty Find Grep Joincol Delcol +| /tmp/pardes-snap/exec/cwd Tty Save Mode Filter Collapse Del /tmp/pardes-snap/exec/cwd Tty Save Mode Filter Collapse Del +| Exec ls +| ls e.txt +| e.txt | | | @@ -15,21 +16,29 @@ | | | -| -| /tmp/pardes-snap/exec/cwd Save Tty Del Toggletty +| /tmp/pardes-snap/exec/cwd Tty Save Mode Filter Collapse Del | ls | e.txt -== snap kept grid=100x31 cursor=6,3 -|3: ZZARG ls -|4: ./c.sh e.txt +== snap kept grid=140x31 cursor=6,3 +|3: ZZARG ls +|4: ./c.sh e.txt +|5: +|8: echo MID''OK |9: -== snap chord grid=100x31 cursor=6,3 -|9: CHORDARG:ZZARG -== snap deleted grid=100x31 cursor=4,5 -|3: ls ls -|4: e.txt e.txt +|10: +== snap chord grid=140x31 cursor=6,4 +|3: Exec ls +|4: ZZARG e.txt +|5: ./c.sh |8: +|9: echo MID''OK +|10: CHORDARG:ZZARG +== snap deleted grid=140x31 cursor=4,5 +|3: ls ls +|4: e.txt e.txt +|5: |9: +|10: |17: |18: |19: diff --git a/test/snapshots/exec.snap b/test/snapshots/exec.snap index 38f74e35..a0820c19 100644 --- a/test/snapshots/exec.snap +++ b/test/snapshots/exec.snap @@ -2,7 +2,7 @@ # the middle drag captures the kept left selection as a trailing argument; # middle-click Del on the pane tag closes the pane file e.txt x -start 31 100 -n 3 +start 31 140 -n 3 wait 8000 e.txt stable 700 20000 press left 5 9 diff --git a/test/snapshots/fileedit.golden b/test/snapshots/fileedit.golden index bf0eccdb..a4d23656 100644 --- a/test/snapshots/fileedit.golden +++ b/test/snapshots/fileedit.golden @@ -1,11 +1,11 @@ == snap edited grid=150x31 cursor=17,7 |Newcol Joincol Find Grep Help Changelog Tutor Dump NextColor Debug Kill -|New Tty Find Grep Joincol New Tty Find Grep Joincol -| /tmp/pardes-snap/fileedit/cwd Save Tty Del Togglettymode Filter Collapse /tmp/pardes-snap/fileedit/cwd Save Tty Del Togglettymode Filter Collapse +| New Tty Find Grep Joincol Delcol New Tty Find Grep Joincol Delcol +| /tmp/pardes-snap/fileedit/cwd Tty Save Mode Filter Collapse Del /tmp/pardes-snap/fileedit/cwd Tty Save Mode Filter Collapse Del | ls ls | f.txt f.txt | -| /tmp/pardes-snap/fileedit/cwd/f.txt * Save Tty Del Collapse +| /tmp/pardes-snap/fileedit/cwd/f.txt * Save Tty Collapse Del | 1 liEDIT''MEne 1 | 2 line 2 | 3 line 3 @@ -16,7 +16,7 @@ | 8 line 8 | 9 line 9 | 10 line 10 -| /tmp/pardes-snap/fileedit/cwd Save Tty Del Togglettymode Filter Collapse +| /tmp/pardes-snap/fileedit/cwd Tty Save Mode Filter Collapse Del | ls | f.txt == snap deleted grid=150x31 cursor=7,8 diff --git a/test/snapshots/filewatch.golden b/test/snapshots/filewatch.golden index 6eca9bca..6e535d45 100644 --- a/test/snapshots/filewatch.golden +++ b/test/snapshots/filewatch.golden @@ -1,7 +1,7 @@ == snap edited grid=210x31 cursor=15,3 |Newcol Joincol Find Grep Help Changelog Tutor Dump NextColor Debug Kill -|New Tty Find Grep Joincol New Tty Find Grep Joincol -| /tmp/pardes-snap/filewatch/cwd/w.txt * Save Tty Del Collapse /tmp/pardes-snap/filewatch/cwd Save Tty Del Togglettymode Filter Collapse +| New Tty Find Grep Joincol Delcol New Tty Find Grep Joincol Delcol +| /tmp/pardes-snap/filewatch/cwd/w.txt * Save Tty Collapse Del /tmp/pardes-snap/filewatch/cwd Tty Save Mode Filter Collapse Del | 1 liMYEDITne 1 ls | 2 line 2 sub w.txt | 3 /tmp/pardes-snap/filewatch/cwd/sub/s.txt @@ -16,7 +16,7 @@ | 12 line 12 | 13 | -| /tmp/pardes-snap/filewatch/cwd/sub/s.txt Save Tty Del Collapse +| /tmp/pardes-snap/filewatch/cwd/sub/s.txt Save Tty Collapse Del | 1 line 1 | 2 line 2 | 3 line 3 @@ -26,11 +26,11 @@ | 7 line 7 | 8 line 8 | 9 -== snap reloaded grid=210x31 cursor=15,3 -|2: /tmp/pardes-snap/filewatch/cwd/w.txt Save Tty Del Collapse /tmp/pardes-snap/filewatch/cwd Save Tty Del Togglettymode Filter Collapse -|3: 1 EXTERNAL ls -|4: 2 sub w.txt -|5: +== snap reloaded grid=210x31 cursor=15,4 +|2: /tmp/pardes-snap/filewatch/cwd/w.txt Save Tty Collapse Del /tmp/pardes-snap/filewatch/cwd Tty Save Mode Filter Collapse Del +|3: --:--:-- reloaded /tmp/pardes-snap/filewatch/cwd/w.txt ls +|4: 1 EXTERNAL sub w.txt +|5: 2 |6: |7: |8: w.txt @@ -41,20 +41,18 @@ |13: |14: |15: -|16: --:--:-- reloaded /tmp/pardes-snap/filewatch/cwd/w.txt -== snap reloaded_sub grid=210x31 cursor=15,3 -|18: 1 RENAMED -|19: 2 -|20: +== snap reloaded_sub grid=210x31 cursor=15,4 +|18: --:--:-- reloaded /tmp/pardes-snap/filewatch/cwd/sub/s.txt +|19: 1 RENAMED +|20: 2 |21: |22: |23: |24: |25: |26: -|30: --:--:-- reloaded /tmp/pardes-snap/filewatch/cwd/sub/s.txt == snap undone grid=210x31 cursor=15,3 -|2: /tmp/pardes-snap/filewatch/cwd/w.txt * Save Tty Del Collapse /tmp/pardes-snap/filewatch/cwd Save Tty Del Togglettymode Filter Collapse +|2: /tmp/pardes-snap/filewatch/cwd/w.txt * Save Tty Collapse Del /tmp/pardes-snap/filewatch/cwd Tty Save Mode Filter Collapse Del |3: 1 liMYEDITne 1 ls |4: 2 line 2 sub w.txt |5: 3 /tmp/pardes-snap/filewatch/cwd/sub/s.txt @@ -68,5 +66,6 @@ |13: 11 line 11 |14: 12 line 12 |15: 13 -|16: -|30: +|18: 1 RENAMED +|19: 2 +|20: diff --git a/test/snapshots/filewatch.snap b/test/snapshots/filewatch.snap index a27740f0..38b6ac8e 100644 --- a/test/snapshots/filewatch.snap +++ b/test/snapshots/filewatch.snap @@ -18,6 +18,10 @@ dirmk sub file w.txt line 1\nline 2\n/tmp/pardes-snap/filewatch/cwd/sub/s.txt\nline 4\nline 5\nline 6\nline 7\nline 8\nline 9\nline 10\nline 11\nline 12\n lines sub/s.txt 8 +# Builtins announce themselves by default, and an announcement is a band at +# the top of the body -- which moves every row this script clicks. What the +# verbs do is what is under test, not the announcement. +config Verbose off start 31 210 -n 1 wait 8000 w.txt stable 700 20000 diff --git a/test/snapshots/find.golden b/test/snapshots/find.golden index a8d072f3..b076d419 100644 --- a/test/snapshots/find.golden +++ b/test/snapshots/find.golden @@ -1,123 +1,108 @@ -== snap group grid=120x41 cursor=7,3 +== snap group grid=120x41 cursor=7,4 |Newcol Joincol Find Grep Help Changelog Tutor Dump NextColor Debug Kill -|New Tty Find Grep Joincol -| /tmp/pardes-snap/find/cwd/here.txt Save Tty Del Collapse -| 1 Find -| -| -| -| -| -| -| -| -| -| -| -| -| -| -| -| -| -| -| -| -| -| -| -| -| -| -| -| -| -| -| -| -| -| -| -| +| New Tty Find Grep Joincol Delcol +| /tmp/pardes-snap/find/cwd/here.txt Save Tty Collapse Del | SPC f -== snap armed grid=120x41 cursor=9,40 -|40: Find / -== snap typing grid=120x41 cursor=12,40 -|40: Find /zqm +| 1 Find +== snap armed grid=120x41 cursor=119,4 +|3: Find +|4: Find / +|5: 1 Find +== snap typing grid=120x41 cursor=119,3 +|3: Find /zqm +|4: 1 Find +|5: == snap results grid=120x41 cursor=7,3 -|37: /tmp/pardes-snap/find/cwd/+Search Save Tty Del Collapse +|3: 1 Find +|4: +|37: /tmp/pardes-snap/find/cwd/+Search Save Tty Collapse Del |38: 1 sub/ZQMARK-beta.txt |39: 2 sub/nest/zqmark-gamma.txt |40: 3 zqmark-alpha.txt == snap first grid=120x41 cursor=7,21 -|20: /tmp/pardes-snap/find/cwd/sub/ZQMARK-beta.txt Save Tty Del Collapse +|20: /tmp/pardes-snap/find/cwd/sub/ZQMARK-beta.txt Save Tty Collapse Del |21: 1 beta body +|38: Look +|39: 1 sub/ZQMARK-beta.txt +|40: 2 sub/nest/zqmark-gamma.txt == style first grid=120x41 |0: 0-70 #b2c3b8,#1d2824, 71-119 d,#1d2824, -|1: 0-24 #becfc4,#26362d, 25-119 d,#26362d, -|2: 0-1 #ffffff,#4c6356, 2-57 #b2c3b8,#1d2824, 58-119 d,#1d2824, -|3: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-10 #e5eee5,#0d1410, 11-119 d,#0d1410, -|4: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-119 d,#0d1410, -|5: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-119 d,#0d1410, -|6: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-119 d,#0d1410, -|7: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-119 d,#0d1410, -|8: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-119 d,#0d1410, -|9: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-119 d,#0d1410, -|10: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-119 d,#0d1410, -|11: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-119 d,#0d1410, -|12: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-119 d,#0d1410, -|13: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-119 d,#0d1410, -|14: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-119 d,#0d1410, -|15: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-119 d,#0d1410, -|16: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-119 d,#0d1410, -|17: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-119 d,#0d1410, -|18: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-119 d,#0d1410, -|19: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-119 d,#0d1410, -|20: 0-1 #000000,#adcc91, 2-68 #becfc4,#26362d, 69-119 d,#26362d, -|21: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-6 #616f64,#0d1410,b 7-15 #e5eee5,#0d1410, 16-119 d,#0d1410, -|22: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-119 d,#0d1410, -|23: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-119 d,#0d1410, -|24: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-119 d,#0d1410, -|25: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-119 d,#0d1410, -|26: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-119 d,#0d1410, -|27: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-119 d,#0d1410, -|28: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-119 d,#0d1410, -|29: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-119 d,#0d1410, -|30: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-119 d,#0d1410, -|31: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-119 d,#0d1410, -|32: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-119 d,#0d1410, -|33: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-119 d,#0d1410, -|34: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-119 d,#0d1410, -|35: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-119 d,#0d1410, -|36: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-119 d,#0d1410, -|37: 0-1 #ffffff,#4c6356, 2-56 #b2c3b8,#1d2824, 57-119 d,#1d2824, -|38: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-25 #e5eee5,#0d1410, 26-119 d,#0d1410, -|39: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-31 #e5eee5,#0d1410, 32-119 d,#0d1410, -|40: 0-0 d,#152019, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-22 #e5eee5,#0d1410, 23-119 d,#0d1410, +|1: 0-1 #ffffff,#887455, 2-2 d,#26362d, 3-34 #becfc4,#26362d, 35-119 d,#26362d, +|2: 0-1 #ffffff,#496656, 2-2 d,#1d2824, 3-28 #b2c3b8,#1d2824, 29-36 #d3b0d9,#1d2824, 37-58 #b2c3b8,#1d2824, 59-119 d,#1d2824, +|3: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-10 #e5eee5,#0d1410, 11-119 d,#0d1410, +|4: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-119 d,#0d1410, +|5: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-119 d,#0d1410, +|6: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-119 d,#0d1410, +|7: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-119 d,#0d1410, +|8: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-119 d,#0d1410, +|9: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-119 d,#0d1410, +|10: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-119 d,#0d1410, +|11: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-119 d,#0d1410, +|12: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-119 d,#0d1410, +|13: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-119 d,#0d1410, +|14: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-119 d,#0d1410, +|15: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-119 d,#0d1410, +|16: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-119 d,#0d1410, +|17: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-119 d,#0d1410, +|18: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-119 d,#0d1410, +|19: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-119 d,#0d1410, +|20: 0-1 #000000,#add38a, 2-2 d,#26362d, 3-32 #becfc4,#26362d, 33-47 #dfbce5,#26362d, 48-69 #becfc4,#26362d, 70-119 d,#26362d, +|21: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #616f64,#0d1410,b 7-15 #e5eee5,#0d1410, 16-119 d,#0d1410, +|22: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-119 d,#0d1410, +|23: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-119 d,#0d1410, +|24: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-119 d,#0d1410, +|25: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-119 d,#0d1410, +|26: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-119 d,#0d1410, +|27: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-119 d,#0d1410, +|28: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-119 d,#0d1410, +|29: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-119 d,#0d1410, +|30: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-119 d,#0d1410, +|31: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-119 d,#0d1410, +|32: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-119 d,#0d1410, +|33: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-119 d,#0d1410, +|34: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-119 d,#0d1410, +|35: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-119 d,#0d1410, +|36: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-119 d,#0d1410, +|37: 0-1 #ffffff,#496656, 2-2 d,#1d2824, 3-28 #b2c3b8,#1d2824, 29-35 #d3b0d9,#1d2824, 36-57 #b2c3b8,#1d2824, 58-119 d,#1d2824, +|38: 0-0 d,#152019, 1-1 d,#0d1410, 2-115 d,#1d2824, 116-119 #b2c3b8,#1d2824, +|39: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-25 #e5eee5,#0d1410, 26-119 d,#0d1410, +|40: 0-0 d,#152019, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-31 #e5eee5,#0d1410, 32-119 d,#0d1410, == snap second grid=120x41 cursor=7,30 -|29: /tmp/pardes-snap/find/cwd/sub/nest/zqmark-gamma.txt Save Tty Del Collapse +|29: /tmp/pardes-snap/find/cwd/sub/nest/zqmark-gamma.txt Save Tty Collapse Del |30: 1 gamma body == snap third grid=120x41 cursor=7,34 -|33: /tmp/pardes-snap/find/cwd/zqmark-alpha.txt Save Tty Del Collapse +|33: /tmp/pardes-snap/find/cwd/zqmark-alpha.txt Save Tty Collapse Del |34: 1 alpha body -|38: 2 sub/nest/zqmark-gamma.txt -|39: 3 zqmark-alpha.txt -|40: 4 +|39: 2 sub/nest/zqmark-gamma.txt +|40: 3 zqmark-alpha.txt == snap back grid=120x41 cursor=7,30 +|39: 1 sub/ZQMARK-beta.txt +|40: 2 sub/nest/zqmark-gamma.txt +== snap word grid=120x41 cursor=7,30 +|3: Find +|4: Find / +|5: 1 Find |38: 1 sub/ZQMARK-beta.txt |39: 2 sub/nest/zqmark-gamma.txt |40: 3 zqmark-alpha.txt -== snap word grid=120x41 cursor=7,30 -|19: Find / == snap cancel grid=120x41 cursor=7,39 +|3: Find / +|4: 1 Find +|5: +|30: Last +|31: 1 gamma body == snap nomatch grid=120x41 cursor=7,39 -|2: /tmp/pardes-snap/find/cwd/here.txt Save Tty Del Collapse Find / -|18: /tmp/pardes-snap/find/cwd/+Search Save Tty Del Collapse +|2: /tmp/pardes-snap/find/cwd/here.txt Save Tty Collapse Del Find / +|3: 1 Find +|4: +|18: /tmp/pardes-snap/find/cwd/+Search Save Tty Collapse Del |19: 1 +|30: 1 gamma body +|31: |38: 2 sub/nest/zqmark-gamma.txt |39: 3 zqmark-alpha.txt |40: 4 == snap refit grid=120x41 cursor=7,3 == snap topbar grid=120x41 cursor=12,34 -|35: /tmp/pardes-snap/find/cwd/+Search Save Tty Del Collapse +|35: /tmp/pardes-snap/find/cwd/+Search Save Tty Collapse Del |36: 1 zqmark-alpha.txt diff --git a/test/snapshots/fsearch.golden b/test/snapshots/fsearch.golden index 6fdbb42f..ccc25503 100644 --- a/test/snapshots/fsearch.golden +++ b/test/snapshots/fsearch.golden @@ -1,11 +1,11 @@ == snap opened grid=180x31 cursor=7,7 |Newcol Joincol Find Grep Help Changelog Tutor Dump NextColor Debug Kill -|New Tty Find Grep Joincol New Tty Find Grep Joincol -| /tmp/pardes-snap/fsearch/cwd Save Tty Del Togglettymode Filter Collapse /tmp/pardes-snap/fsearch/cwd Save Tty Del Togglettymode Filter Collapse +| New Tty Find Grep Joincol Delcol New Tty Find Grep Joincol Delcol +| /tmp/pardes-snap/fsearch/cwd Tty Save Mode Filter Collapse Del /tmp/pardes-snap/fsearch/cwd Tty Save Mode Filter Collapse Del | ls ls | g.txt g.txt | -| /tmp/pardes-snap/fsearch/cwd/g.txt Save Tty Del Collapse +| /tmp/pardes-snap/fsearch/cwd/g.txt Save Tty Collapse Del | 1 l1 | 2 MARK a | 3 l3 @@ -16,79 +16,94 @@ | 8 l8 | 9 l9 | 10 MARK c -| /tmp/pardes-snap/fsearch/cwd Save Tty Del Togglettymode Filter Collapse +| /tmp/pardes-snap/fsearch/cwd Tty Save Mode Filter Collapse Del | ls | g.txt -== snap typing grid=180x31 cursor=8,16 -|16: /MARK +== snap typing grid=180x31 cursor=89,7 +|7: /MARK +|8: 1 l1 +|9: 2 MARK a +|10: 3 l3 +|11: 4 l4 +|12: 5 l5 +|13: 6 MARK b +|14: 7 l7 +|15: 8 l8 +|16: 9 l9 == snap results grid=180x31 cursor=10,8 -|13: /tmp/pardes-snap/fsearch/cwd/+Search Save Tty Del Collapse -|14: 1 g.txt:2:1-4 MARK a -|15: 2 g.txt:6:1-4 MARK b -|16: 3 g.txt:10:1-4 MARK c +|7: 1 l1 +|8: 2 MARK a +|9: 3 l3 +|10: 4 l4 +|11: 5 l5 +|12: /tmp/pardes-snap/fsearch/cwd/+Search Save Tty Collapse Del LocationsConfig +|13: 1 g.txt:2:1-4 +|14: 2 MARK a +|15: 3 g.txt:6:1-4 +|16: 4 MARK b == style results grid=180x31 |0: 0-70 #b2c3b8,#1d2824, 71-179 d,#1d2824, -|1: 0-24 #becfc4,#26362d, 25-89 d,#26362d, 90-114 #b2c3b8,#1d2824, 115-179 d,#1d2824, -|2: 0-1 #ffffff,#4c6356, 2-72 #b2c3b8,#1d2824, 73-89 d,#1d2824, 90-91 #ffffff,#4c6356, 92-162 #b2c3b8,#1d2824, 163-179 d,#1d2824, -|3: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-89 #e5eee5,#0d1410, 90-90 d,#637f6a, 91-91 d,#0d1410, 92-179 #e5eee5,#0d1410, -|4: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-89 #e5eee5,#0d1410, 90-90 d,#637f6a, 91-91 d,#0d1410, 92-179 #e5eee5,#0d1410, -|5: 0-0 d,#637f6a, 1-89 d,#0d1410, 90-90 d,#637f6a, 91-179 d,#0d1410, -|6: 0-1 #000000,#adcc91, 2-57 #becfc4,#26362d, 58-89 d,#26362d, 90-90 d,#637f6a, 91-91 d,#0d1410, 92-179 #e5eee5,#0d1410, -|7: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-8 #e5eee5,#0d1410, 9-89 d,#0d1410, 90-90 d,#637f6a, 91-91 d,#0d1410, 92-179 #e5eee5,#0d1410, -|8: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-6 #616f64,#0d1410,b 7-10 #f5f7ee,#405d4b, 11-12 #e5eee5,#0d1410, 13-89 d,#0d1410, 90-90 d,#637f6a, 91-91 d,#0d1410, 92-179 #e5eee5,#0d1410, -|9: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-8 #e5eee5,#0d1410, 9-89 d,#0d1410, 90-90 d,#637f6a, 91-91 d,#0d1410, 92-179 #e5eee5,#0d1410, -|10: 0-0 d,#152019, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-8 #e5eee5,#0d1410, 9-89 d,#0d1410, 90-90 d,#637f6a, 91-91 d,#0d1410, 92-179 #e5eee5,#0d1410, -|11: 0-0 d,#152019, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-8 #e5eee5,#0d1410, 9-89 d,#0d1410, 90-90 d,#637f6a, 91-91 d,#0d1410, 92-179 #e5eee5,#0d1410, -|12: 0-0 d,#152019, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-12 #e5eee5,#0d1410, 13-89 d,#0d1410, 90-90 d,#637f6a, 91-91 d,#0d1410, 92-179 #e5eee5,#0d1410, -|13: 0-1 #ffffff,#4c6356, 2-59 #b2c3b8,#1d2824, 60-89 d,#1d2824, 90-90 d,#637f6a, 91-91 d,#0d1410, 92-179 #e5eee5,#0d1410, -|14: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-17 #59675c,#0d1410, 18-18 #e5eee5,#0d1410, 19-22 #f7e4a5,#57472a, 23-24 #e5eee5,#0d1410, 25-89 d,#0d1410, 90-90 d,#637f6a, 91-91 d,#0d1410, 92-179 #e5eee5,#0d1410, -|15: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-17 #59675c,#0d1410, 18-18 #e5eee5,#0d1410, 19-22 #f7e4a5,#57472a, 23-24 #e5eee5,#0d1410, 25-89 d,#0d1410, 90-90 d,#637f6a, 91-91 d,#0d1410, 92-179 #e5eee5,#0d1410, -|16: 0-0 d,#152019, 1-1 d,#0d1410, 2-18 #59675c,#0d1410, 19-19 #e5eee5,#0d1410, 20-23 #f7e4a5,#57472a, 24-25 #e5eee5,#0d1410, 26-89 d,#0d1410, 90-90 d,#637f6a, 91-91 d,#0d1410, 92-179 #e5eee5,#0d1410, -|17: 0-1 #ffffff,#4c6356, 2-72 #b2c3b8,#1d2824, 73-89 d,#1d2824, 90-90 d,#637f6a, 91-91 d,#0d1410, 92-179 #e5eee5,#0d1410, -|18: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-89 #e5eee5,#0d1410, 90-90 d,#637f6a, 91-91 d,#0d1410, 92-179 #e5eee5,#0d1410, -|19: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-89 #e5eee5,#0d1410, 90-90 d,#637f6a, 91-91 d,#0d1410, 92-179 #e5eee5,#0d1410, -|20: 0-0 d,#637f6a, 1-89 d,#0d1410, 90-90 d,#637f6a, 91-91 d,#0d1410, 92-179 #e5eee5,#0d1410, -|21: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-89 #e5eee5,#0d1410, 90-90 d,#637f6a, 91-91 d,#0d1410, 92-179 #e5eee5,#0d1410, -|22: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-89 #e5eee5,#0d1410, 90-90 d,#637f6a, 91-91 d,#0d1410, 92-179 #e5eee5,#0d1410, -|23: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-89 #e5eee5,#0d1410, 90-90 d,#637f6a, 91-91 d,#0d1410, 92-179 #e5eee5,#0d1410, -|24: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-89 #e5eee5,#0d1410, 90-90 d,#637f6a, 91-91 d,#0d1410, 92-179 #e5eee5,#0d1410, -|25: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-89 #e5eee5,#0d1410, 90-90 d,#637f6a, 91-91 d,#0d1410, 92-179 #e5eee5,#0d1410, -|26: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-89 #e5eee5,#0d1410, 90-90 d,#637f6a, 91-91 d,#0d1410, 92-179 #e5eee5,#0d1410, -|27: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-89 #e5eee5,#0d1410, 90-90 d,#637f6a, 91-91 d,#0d1410, 92-179 #e5eee5,#0d1410, -|28: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-89 #e5eee5,#0d1410, 90-90 d,#637f6a, 91-91 d,#0d1410, 92-179 #e5eee5,#0d1410, -|29: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-89 #e5eee5,#0d1410, 90-90 d,#637f6a, 91-91 d,#0d1410, 92-179 #e5eee5,#0d1410, -|30: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-89 #e5eee5,#0d1410, 90-90 d,#637f6a, 91-91 d,#0d1410, 92-179 #e5eee5,#0d1410, -== snap second grid=180x31 cursor=10,10 -|7: 3 l3 -|8: 4 l4 -|9: 5 l5 -|10: 6 MARK b -|11: 7 l7 -|12: 8 l8 -== snap third grid=180x31 cursor=10,10 -|7: 7 l7 -|8: 8 l8 -|9: 9 l9 -|10: 10 MARK c -|11: 11 l11 -|12: 12 l12 -|14: 2 g.txt:6:1-4 MARK b -|15: 3 g.txt:10:1-4 MARK c -|16: 4 -== snap back grid=180x31 cursor=10,10 -|7: 3 l3 -|8: 4 l4 -|9: 5 l5 -|10: 6 MARK b -|11: 7 l7 -|12: 8 l8 -|14: 1 g.txt:2:1-4 MARK a -|15: 2 g.txt:6:1-4 MARK b -|16: 3 g.txt:10:1-4 MARK c -== snap cancel grid=180x31 cursor=10,10 +|1: 0-1 #ffffff,#887455, 2-2 d,#26362d, 3-34 #becfc4,#26362d, 35-89 d,#26362d, 90-91 #ffffff,#887455, 92-92 d,#1d2824, 93-124 #b2c3b8,#1d2824, 125-179 d,#1d2824, +|2: 0-1 #ffffff,#496656, 2-2 d,#1d2824, 3-31 #b2c3b8,#1d2824, 32-34 #d3b0d9,#1d2824, 35-64 #b2c3b8,#1d2824, 65-89 d,#1d2824, 90-91 #ffffff,#496656, 92-92 d,#1d2824, 93-121 #b2c3b8,#1d2824, 122-124 #d3b0d9,#1d2824, 125-154 #b2c3b8,#1d2824, 155-179 d,#1d2824, +|3: 0-0 d,#608269, 1-1 d,#0d1410, 2-89 #e5eee5,#0d1410, 90-90 d,#608269, 91-91 d,#0d1410, 92-179 #e5eee5,#0d1410, +|4: 0-0 d,#608269, 1-1 d,#0d1410, 2-89 #e5eee5,#0d1410, 90-90 d,#608269, 91-91 d,#0d1410, 92-179 #e5eee5,#0d1410, +|5: 0-0 d,#608269, 1-89 d,#0d1410, 90-90 d,#608269, 91-179 d,#0d1410, +|6: 0-1 #000000,#add38a, 2-2 d,#26362d, 3-31 #becfc4,#26362d, 32-36 #dfbce5,#26362d, 37-58 #becfc4,#26362d, 59-89 d,#26362d, 90-90 d,#608269, 91-91 d,#0d1410, 92-179 #e5eee5,#0d1410, +|7: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-8 #e5eee5,#0d1410, 9-89 d,#0d1410, 90-90 d,#608269, 91-91 d,#0d1410, 92-179 #e5eee5,#0d1410, +|8: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #616f64,#0d1410,b 7-10 #f5f7ee,#3c614a, 11-12 #e5eee5,#0d1410, 13-89 d,#0d1410, 90-90 d,#608269, 91-91 d,#0d1410, 92-179 #e5eee5,#0d1410, +|9: 0-0 d,#152019, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-8 #e5eee5,#0d1410, 9-89 d,#0d1410, 90-90 d,#608269, 91-91 d,#0d1410, 92-179 #e5eee5,#0d1410, +|10: 0-0 d,#152019, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-8 #e5eee5,#0d1410, 9-89 d,#0d1410, 90-90 d,#608269, 91-91 d,#0d1410, 92-179 #e5eee5,#0d1410, +|11: 0-0 d,#152019, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-8 #e5eee5,#0d1410, 9-89 d,#0d1410, 90-90 d,#608269, 91-91 d,#0d1410, 92-179 #e5eee5,#0d1410, +|12: 0-1 #ffffff,#496656, 2-2 d,#1d2824, 3-31 #b2c3b8,#1d2824, 32-38 #d3b0d9,#1d2824, 39-76 #b2c3b8,#1d2824, 77-89 d,#1d2824, 90-90 d,#608269, 91-91 d,#0d1410, 92-179 #e5eee5,#0d1410, +|13: 0-0 d,#608269, 1-1 d,#0d1410, 2-17 #59675c,#0d1410, 18-89 d,#0d1410, 90-90 d,#608269, 91-91 d,#0d1410, 92-179 #e5eee5,#0d1410, +|14: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-10 #f7e4a5,#5e4923, 11-12 #e5eee5,#0d1410, 13-89 d,#0d1410, 90-90 d,#608269, 91-91 d,#0d1410, 92-179 #e5eee5,#0d1410, +|15: 0-0 d,#152019, 1-1 d,#0d1410, 2-17 #59675c,#0d1410, 18-89 d,#0d1410, 90-90 d,#608269, 91-91 d,#0d1410, 92-179 #e5eee5,#0d1410, +|16: 0-0 d,#152019, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-10 #f7e4a5,#5e4923, 11-12 #e5eee5,#0d1410, 13-89 d,#0d1410, 90-90 d,#608269, 91-91 d,#0d1410, 92-179 #e5eee5,#0d1410, +|17: 0-1 #ffffff,#496656, 2-2 d,#1d2824, 3-31 #b2c3b8,#1d2824, 32-34 #d3b0d9,#1d2824, 35-64 #b2c3b8,#1d2824, 65-89 d,#1d2824, 90-90 d,#608269, 91-91 d,#0d1410, 92-179 #e5eee5,#0d1410, +|18: 0-0 d,#608269, 1-1 d,#0d1410, 2-89 #e5eee5,#0d1410, 90-90 d,#608269, 91-91 d,#0d1410, 92-179 #e5eee5,#0d1410, +|19: 0-0 d,#608269, 1-1 d,#0d1410, 2-89 #e5eee5,#0d1410, 90-90 d,#608269, 91-91 d,#0d1410, 92-179 #e5eee5,#0d1410, +|20: 0-0 d,#608269, 1-89 d,#0d1410, 90-90 d,#608269, 91-91 d,#0d1410, 92-179 #e5eee5,#0d1410, +|21: 0-0 d,#608269, 1-1 d,#0d1410, 2-89 #e5eee5,#0d1410, 90-90 d,#608269, 91-91 d,#0d1410, 92-179 #e5eee5,#0d1410, +|22: 0-0 d,#608269, 1-1 d,#0d1410, 2-89 #e5eee5,#0d1410, 90-90 d,#608269, 91-91 d,#0d1410, 92-179 #e5eee5,#0d1410, +|23: 0-0 d,#608269, 1-1 d,#0d1410, 2-89 #e5eee5,#0d1410, 90-90 d,#608269, 91-91 d,#0d1410, 92-179 #e5eee5,#0d1410, +|24: 0-0 d,#608269, 1-1 d,#0d1410, 2-89 #e5eee5,#0d1410, 90-90 d,#608269, 91-91 d,#0d1410, 92-179 #e5eee5,#0d1410, +|25: 0-0 d,#608269, 1-1 d,#0d1410, 2-89 #e5eee5,#0d1410, 90-90 d,#608269, 91-91 d,#0d1410, 92-179 #e5eee5,#0d1410, +|26: 0-0 d,#608269, 1-1 d,#0d1410, 2-89 #e5eee5,#0d1410, 90-90 d,#608269, 91-91 d,#0d1410, 92-179 #e5eee5,#0d1410, +|27: 0-0 d,#608269, 1-1 d,#0d1410, 2-89 #e5eee5,#0d1410, 90-90 d,#608269, 91-91 d,#0d1410, 92-179 #e5eee5,#0d1410, +|28: 0-0 d,#608269, 1-1 d,#0d1410, 2-89 #e5eee5,#0d1410, 90-90 d,#608269, 91-91 d,#0d1410, 92-179 #e5eee5,#0d1410, +|29: 0-0 d,#608269, 1-1 d,#0d1410, 2-89 #e5eee5,#0d1410, 90-90 d,#608269, 91-91 d,#0d1410, 92-179 #e5eee5,#0d1410, +|30: 0-0 d,#608269, 1-1 d,#0d1410, 2-89 #e5eee5,#0d1410, 90-90 d,#608269, 91-91 d,#0d1410, 92-179 #e5eee5,#0d1410, +== snap second grid=180x31 cursor=10,9 +|7: 4 l4 +|8: 5 l5 +|9: 6 MARK b +|10: 7 l7 +|11: 8 l8 +== snap third grid=180x31 cursor=10,9 +|7: 8 l8 +|8: 9 l9 +|9: 10 MARK c +|10: 11 l11 +|11: 12 l12 +|13: 3 g.txt:6:1-4 +|14: 4 MARK b +|15: 5 g.txt:10:1-4 +|16: 6 MARK c +== snap back grid=180x31 cursor=10,9 +|7: 4 l4 +|8: 5 l5 +|9: 6 MARK b +|10: 7 l7 +|11: 8 l8 +|13: 2 MARK a +|14: 3 g.txt:6:1-4 +|15: 4 MARK b +|16: 5 g.txt:10:1-4 +== snap cancel grid=180x31 cursor=10,9 == snap nomatch grid=180x31 cursor=7,15 -|11: /tmp/pardes-snap/fsearch/cwd/+Search Save Tty Del Collapse -|12: 1 -|14: 2 g.txt:6:1-4 MARK b -|15: 3 g.txt:10:1-4 MARK c -|16: 4 +|10: /tmp/pardes-snap/fsearch/cwd/+Search Save Tty Collapse Del LocationsConfig +|11: 1 +|13: 3 g.txt:6:1-4 +|14: 4 MARK b +|15: 5 g.txt:10:1-4 +|16: 6 MARK c diff --git a/test/snapshots/fsearch.snap b/test/snapshots/fsearch.snap index 4e4ef864..b050f1db 100644 --- a/test/snapshots/fsearch.snap +++ b/test/snapshots/fsearch.snap @@ -9,6 +9,10 @@ # (every search gets its own, stacked under the pane) with nothing in it for n # to stop on, and goes nowhere. file g.txt l1\nMARK a\nl3\nl4\nl5\nMARK b\nl7\nl8\nl9\nMARK c\nl11\nl12 +# Builtins announce themselves by default, and an announcement is a band at +# the top of the body -- which moves every row this script clicks. What the +# verbs do is what is under test, not the announcement. +config Verbose off start 31 180 -n 3 wait 8000 g.txt stable 700 20000 @@ -33,7 +37,10 @@ text MARK stable 400 5000 snap typing key enter -wait 10000 g.txt:2:1-4 MARK +# Locations stack the target under its line now, so the two halves are +# two rows: wait for both rather than for one joined line. +wait 10000 g.txt:2:1-4 +wait 10000 MARK a stable 700 10000 # ...and the submit already looked result 1: the file scrolled to line 2 and # the four cells the pattern matched there came up selected — the styles below diff --git a/test/snapshots/ghostty-mid.golden b/test/snapshots/ghostty-mid.golden index 106bc063..3482431b 100644 --- a/test/snapshots/ghostty-mid.golden +++ b/test/snapshots/ghostty-mid.golden @@ -1,7 +1,7 @@ == snap ghostty-mid grid=100x31 cursor=4,7 |Newcol Joincol Find Grep Help Changelog Tutor Dump NextColor Debug Kill -|New Tty Find Grep Joincol New Tty Find Grep Joincol -| /tmp/pardes-snap/ghostty-mid/cwd Save Tty Del To /tmp/pardes-snap/ghostty-mid/cwd Save Tty Del To +| New Tty Find Grep Joincol Delcol New Tty Find Grep Joincol Delcol +| /tmp/pardes-snap/ghostty-mid/cwd Tty Save Mode /tmp/pardes-snap/ghostty-mid/cwd Tty Save Mode | ZZPAD ls | ./g.sh g.txt | ./g.sh @@ -16,6 +16,6 @@ | | | -| /tmp/pardes-snap/ghostty-mid/cwd Save Tty Del To +| /tmp/pardes-snap/ghostty-mid/cwd Tty Save Mode | ls | g.txt diff --git a/test/snapshots/grep.golden b/test/snapshots/grep.golden index 795ceddf..8f498e05 100644 --- a/test/snapshots/grep.golden +++ b/test/snapshots/grep.golden @@ -1,11 +1,11 @@ == snap opened grid=180x31 cursor=7,7 |Newcol Joincol Find Grep Help Changelog Tutor Dump NextColor Debug Kill -|New Tty Find Grep Joincol New Tty Find Grep Joincol -| /tmp/pardes-snap/grep/cwd Save Tty Del Togglettymode Filter Collapse /tmp/pardes-snap/grep/cwd Save Tty Del Togglettymode Filter Collapse +| New Tty Find Grep Joincol Delcol New Tty Find Grep Joincol Delcol +| /tmp/pardes-snap/grep/cwd Tty Save Mode Filter Collapse Del /tmp/pardes-snap/grep/cwd Tty Save Mode Filter Collapse Del | ls ls | a.txt noise.txt sub a.txt noise.txt sub | -| /tmp/pardes-snap/grep/cwd/a.txt Save Tty Del Collapse +| /tmp/pardes-snap/grep/cwd/a.txt Save Tty Collapse Del | 1 hello TARGET one | 2 nothing here | 3 last TARGET line @@ -16,26 +16,33 @@ | | | -| /tmp/pardes-snap/grep/cwd Save Tty Del Togglettymode Filter Collapse +| /tmp/pardes-snap/grep/cwd Tty Save Mode Filter Collapse Del | ls | a.txt noise.txt sub -== snap typing grid=180x31 cursor=15,16 -|16: Grep /TARGET +== snap typing grid=180x31 cursor=89,7 +|7: Grep /TARGET +|8: 1 hello TARGET one +|9: 2 nothing here +|10: 3 last TARGET line == snap results grid=180x31 cursor=7,7 -|13: /tmp/pardes-snap/grep/cwd/+Search Save Tty Del Collapse -|14: 1 a.txt:1:7-12 hello TARGET one -|15: 2 a.txt:3:6-11 last TARGET line -|16: 3 sub/b.txt:2:1-6 TARGET inside sub +|7: 1 hello TARGET one +|8: 2 nothing here +|9: 3 last TARGET line +|10: +|13: /tmp/pardes-snap/grep/cwd/+Search Save Tty Collapse Del LocationsConfig +|14: 1 a.txt:1:7-12 hello TARGET one +|15: 2 a.txt:3:6-11 last TARGET line +|16: 3 sub/b.txt:2:1-6 TARGET inside sub == snap first grid=180x31 cursor=18,7 == snap opened-hit grid=180x31 cursor=12,11 -|9: /tmp/pardes-snap/grep/cwd/sub/b.txt Save Tty Del Collapse +|9: /tmp/pardes-snap/grep/cwd/sub/b.txt Save Tty Collapse Del |10: 1 deep |11: 2 TARGET inside sub -|14: 2 a.txt:3:6-11 last TARGET line -|15: 3 sub/b.txt:2:1-6 TARGET inside sub +|14: 2 a.txt:3:6-11 last TARGET line +|15: 3 sub/b.txt:2:1-6 TARGET inside sub |16: 4 == snap nomatch grid=180x31 cursor=2,4 -|11: /tmp/pardes-snap/grep/cwd/sub/+Search Save Tty Del Collapse +|11: /tmp/pardes-snap/grep/cwd/sub/+Search Save Tty Collapse Del LocationsConfig |12: 1 == snap chordsel grid=180x31 cursor=19,7 == snap chord grid=180x31 cursor=19,7 diff --git a/test/snapshots/grep.snap b/test/snapshots/grep.snap index 84b8f415..07777e67 100644 --- a/test/snapshots/grep.snap +++ b/test/snapshots/grep.snap @@ -14,6 +14,13 @@ dirmk sub file a.txt hello TARGET one\nnothing here\nlast TARGET line file sub/b.txt deep\nTARGET inside sub file noise.txt nothing to see +# Builtins announce themselves by default, and an announcement is a band at +# the top of the body -- which moves every row this script clicks. What the +# verbs do is what is under test, not the announcement. +config Verbose off +# The stacked layout spends two rows on each hit, which puts the third one +# below the fold of this results pane; the claim here is which hits there are. +config LocationsConfig layout:inline start 31 180 -n 3 wait 8000 a.txt stable 700 20000 @@ -41,7 +48,7 @@ text TARGET stable 400 5000 snap typing # Enter walks: two hits in a.txt, one in sub/b.txt, sorted by path — and the -# file that holds none of them contributes no row +# file that holds none of them contributes no row. key enter wait 10000 sub/b.txt:2:1 stable 700 15000 diff --git a/test/snapshots/hscroll.golden b/test/snapshots/hscroll.golden index 61e04e49..407d0f82 100644 --- a/test/snapshots/hscroll.golden +++ b/test/snapshots/hscroll.golden @@ -1,13 +1,12 @@ -== snap opened grid=90x31 cursor=7,7 +== snap opened grid=90x31 cursor=6,8 |Newcol Joincol Find Grep Help Changelog Tutor Dump NextColor Debug Kill -|New Tty Find Grep Joincol New Tty Find Grep Joincol -| /tmp/pardes-snap/hscroll/cwd Save Tty Del T /tmp/pardes-snap/hscroll/cwd Save Tty Del T +| New Tty Find Grep Joincol Delcol New Tty Find Grep Joincol Delcol +| /tmp/pardes-snap/hscroll/cwd Tty Save Mode /tmp/pardes-snap/hscroll/cwd Tty Save Mode | ls ls | wide.txt wide.txt | -| /tmp/pardes-snap/hscroll/cwd/wide.txt Save -| 1 short1 END_A_MARKER_WAY_OUT_RIGHT_padp | +| wide.txt | | | @@ -16,14 +15,11 @@ | | | -| /tmp/pardes-snap/hscroll/cwd Save Tty Del T +| +| /tmp/pardes-snap/hscroll/cwd Tty Save Mode | ls | wide.txt -== snap wheeled grid=90x31 cursor=7,7 -|7: 1 ND_A_MARKER_WAY_OUT_RIGHT_padpadpadpad -== snap clamped grid=90x31 cursor=7,7 -|7: 1 short1 END_A_MARKER_WAY_OUT_RIGHT_padp -== snap dollar grid=90x31 cursor=41,7 -|7: 1 padpadpadpadpadpadpadpadpadpad_TAIL -== snap zero grid=90x31 cursor=7,7 -|7: 1 short1 END_A_MARKER_WAY_OUT_RIGHT_padp +== snap wheeled grid=90x31 cursor=6,8 +== snap clamped grid=90x31 cursor=6,8 +== snap dollar grid=90x31 cursor=3,3 +== snap zero grid=90x31 cursor=2,3 diff --git a/test/snapshots/images.golden b/test/snapshots/images.golden index 558b4d84..95c56d9f 100644 --- a/test/snapshots/images.golden +++ b/test/snapshots/images.golden @@ -1,11 +1,11 @@ == snap img-open grid=150x31 cursor=11,8 |Newcol Joincol Find Grep Help Changelog Tutor Dump NextColor Debug Kill -|New Tty Find Grep Joincol New Tty Find Grep Joincol -| /tmp/pardes-snap/images/cwd Save Tty Del Togglettymode Filter Collapse /tmp/pardes-snap/images/cwd Save Tty Del Togglettymode Filter Collapse -| ls ls -| pic.ppm pic.ppm -| -| img petscii:off palette:commodore ascii:on /tmp/pardes-snap/images/cwd/pi +| New Tty Find Grep Joincol Delcol New Tty Find Grep Joincol Delcol +| /tmp/pardes-snap/images/cwd Tty Save Mode Filter Collapse Del /tmp/pardes-snap/images/cwd Tty Save Mode Filter Collapse Del +| Look ls +| ls pic.ppm +| pic.ppm +| img petscii:off palette:commodore ascii:on /tmp/pardes-snap/images/cwd/p | 92@7%5Gm$D4▘🬵%🬨3'🬥🬆🬻 | 🬥3▖╱{=CY,â–Œ*)^M<▀🬎🬻 | Xâ–„jN.&🬺j*w3┼"🬥🬆🬻 @@ -16,72 +16,78 @@ | â–ši,V🬆🬹 | mu🬆🬻 | 🬆🬻 -| /tmp/pardes-snap/images/cwd Save Tty Del Togglettymode Filter Collapse +| /tmp/pardes-snap/images/cwd Tty Save Mode Filter Collapse Del | ls | pic.ppm == style img-open grid=150x31 |0: 0-70 #b2c3b8,#1d2824, 71-149 d,#1d2824, -|1: 0-24 #becfc4,#26362d, 25-74 d,#26362d, 75-99 #b2c3b8,#1d2824, 100-149 d,#1d2824, -|2: 0-1 #ffffff,#4c6356, 2-71 #b2c3b8,#1d2824, 72-74 d,#1d2824, 75-76 #ffffff,#4c6356, 77-146 #b2c3b8,#1d2824, 147-149 d,#1d2824, -|3: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-74 #e5eee5,#0d1410, 75-75 d,#637f6a, 76-76 d,#0d1410, 77-149 #e5eee5,#0d1410, -|4: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-74 #e5eee5,#0d1410, 75-75 d,#637f6a, 76-76 d,#0d1410, 77-149 #e5eee5,#0d1410, -|5: 0-0 d,#637f6a, 1-74 d,#0d1410, 75-75 d,#637f6a, 76-149 d,#0d1410, -|6: 0-1 #000000,#adcc91, 2-74 #becfc4,#26362d, 75-75 d,#637f6a, 76-76 d,#0d1410, 77-149 #e5eee5,#0d1410, -|7: 0-0 d,#152019, 1-27 d,#0d1410, 28-29 #959595,#6c6c6c, 30-30 #6c6c6c,#959595, 31-34 #959595,#6c6c6c, 35-35 #6c6c6c,#959595, 36-37 #959595,#6c6c6c, 38-38 #6c6c6c,#959595, 39-39 #959595,#6c6c6c, 40-40 #6c6c6c,#959595, 41-41 #959595,#6c6c6c, 42-42 #6c6c6c,#959595, 43-44 #959595,#6c6c6c, 45-45 #6c6c6c,#959595, 46-46 #959595,#6c5eb5, 47-47 #352879,#6c6c6c, 48-74 d,#0d1410, 75-75 d,#637f6a, 76-76 d,#0d1410, 77-149 #e5eee5,#0d1410, -|8: 0-0 d,#152019, 1-27 d,#0d1410, 28-28 #6c6c6c,#959595, 29-29 #959595,#6c6c6c, 30-30 #6c6c6c,#959595, 31-34 #959595,#6c6c6c, 35-38 #6c6c6c,#959595, 39-42 #959595,#6c6c6c, 43-43 #6c6c6c,#959595, 44-44 #6c6c6c,#352879, 45-45 #352879,#959595, 46-47 #352879,#352879, 48-74 d,#0d1410, 75-75 d,#637f6a, 76-76 d,#0d1410, 77-149 #e5eee5,#0d1410, -|9: 0-0 d,#152019, 1-27 d,#0d1410, 28-28 #959595,#6c6c6c, 29-29 #6c6c6c,#959595, 30-33 #959595,#6c6c6c, 34-34 #6c6c6c,#959595, 35-38 #959595,#6c6c6c, 39-39 #6c6c6c,#959595, 40-40 #959595,#6c6c6c, 41-41 #6c6c6c,#959595, 42-42 #959595,#6c5eb5, 43-43 #352879,#6c6c6c, 44-47 #352879,#352879, 48-74 d,#0d1410, 75-75 d,#637f6a, 76-76 d,#0d1410, 77-149 #e5eee5,#0d1410, -|10: 0-0 d,#152019, 1-27 d,#0d1410, 28-29 #959595,#6c6c6c, 30-30 #6c6c6c,#959595, 31-33 #959595,#6c6c6c, 34-34 #6c6c6c,#959595, 35-39 #959595,#6c6c6c, 40-40 #959595,#6c5eb5, 41-41 #6c6c6c,#352879, 42-47 #352879,#352879, 48-74 d,#0d1410, 75-75 d,#637f6a, 76-76 d,#0d1410, 77-149 #e5eee5,#0d1410, -|11: 0-0 d,#152019, 1-27 d,#0d1410, 28-28 #6c6c6c,#959595, 29-29 #959595,#6c6c6c, 30-34 #6c6c6c,#959595, 35-36 #959595,#6c6c6c, 37-37 #6c6c6c,#959595, 38-38 #6c6c6c,#6c5eb5, 39-39 #352879,#6c6c6c, 40-47 #352879,#352879, 48-74 d,#0d1410, 75-75 d,#637f6a, 76-76 d,#0d1410, 77-149 #e5eee5,#0d1410, -|12: 0-0 d,#152019, 1-27 d,#0d1410, 28-29 #6c6c6c,#959595, 30-31 #959595,#6c6c6c, 32-32 #6c6c6c,#959595, 33-34 #959595,#6c6c6c, 35-35 #6c6c6c,#959595, 36-36 #6c6c6c,#6c5eb5, 37-37 #352879,#6c6c6c, 38-47 #352879,#352879, 48-74 d,#0d1410, 75-75 d,#637f6a, 76-76 d,#0d1410, 77-149 #e5eee5,#0d1410, -|13: 0-0 d,#152019, 1-27 d,#0d1410, 28-29 #959595,#6c6c6c, 30-32 #6c6c6c,#959595, 33-33 #959595,#6c6c6c, 34-34 #6c6c6c,#352879, 35-35 #352879,#6c6c6c, 36-47 #352879,#352879, 48-74 d,#0d1410, 75-75 d,#637f6a, 76-76 d,#0d1410, 77-149 #e5eee5,#0d1410, -|14: 0-0 d,#152019, 1-27 d,#0d1410, 28-31 #959595,#6c6c6c, 32-32 #959595,#6c5eb5, 33-33 #352879,#6c5eb5, 34-47 #352879,#352879, 48-74 d,#0d1410, 75-75 d,#637f6a, 76-76 d,#0d1410, 77-149 #e5eee5,#0d1410, -|15: 0-0 d,#152019, 1-27 d,#0d1410, 28-28 #6c6c6c,#959595, 29-29 #959595,#6c6c6c, 30-30 #6c6c6c,#6c5eb5, 31-31 #352879,#6c6c6c, 32-47 #352879,#352879, 48-74 d,#0d1410, 75-75 d,#637f6a, 76-76 d,#0d1410, 77-149 #e5eee5,#0d1410, -|16: 0-0 d,#152019, 1-27 d,#0d1410, 28-28 #6c6c6c,#6c5eb5, 29-29 #352879,#6c6c6c, 30-47 #352879,#352879, 48-74 d,#0d1410, 75-75 d,#637f6a, 76-76 d,#0d1410, 77-149 #e5eee5,#0d1410, -|17: 0-1 #ffffff,#4c6356, 2-71 #b2c3b8,#1d2824, 72-74 d,#1d2824, 75-75 d,#637f6a, 76-76 d,#0d1410, 77-149 #e5eee5,#0d1410, -|18: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-74 #e5eee5,#0d1410, 75-75 d,#637f6a, 76-76 d,#0d1410, 77-149 #e5eee5,#0d1410, -|19: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-74 #e5eee5,#0d1410, 75-75 d,#637f6a, 76-76 d,#0d1410, 77-149 #e5eee5,#0d1410, -|20: 0-0 d,#637f6a, 1-74 d,#0d1410, 75-75 d,#637f6a, 76-76 d,#0d1410, 77-149 #e5eee5,#0d1410, -|21: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-74 #e5eee5,#0d1410, 75-75 d,#637f6a, 76-76 d,#0d1410, 77-149 #e5eee5,#0d1410, -|22: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-74 #e5eee5,#0d1410, 75-75 d,#637f6a, 76-76 d,#0d1410, 77-149 #e5eee5,#0d1410, -|23: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-74 #e5eee5,#0d1410, 75-75 d,#637f6a, 76-76 d,#0d1410, 77-149 #e5eee5,#0d1410, -|24: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-74 #e5eee5,#0d1410, 75-75 d,#637f6a, 76-76 d,#0d1410, 77-149 #e5eee5,#0d1410, -|25: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-74 #e5eee5,#0d1410, 75-75 d,#637f6a, 76-76 d,#0d1410, 77-149 #e5eee5,#0d1410, -|26: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-74 #e5eee5,#0d1410, 75-75 d,#637f6a, 76-76 d,#0d1410, 77-149 #e5eee5,#0d1410, -|27: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-74 #e5eee5,#0d1410, 75-75 d,#637f6a, 76-76 d,#0d1410, 77-149 #e5eee5,#0d1410, -|28: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-74 #e5eee5,#0d1410, 75-75 d,#637f6a, 76-76 d,#0d1410, 77-149 #e5eee5,#0d1410, -|29: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-74 #e5eee5,#0d1410, 75-75 d,#637f6a, 76-76 d,#0d1410, 77-149 #e5eee5,#0d1410, -|30: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-74 #e5eee5,#0d1410, 75-75 d,#637f6a, 76-76 d,#0d1410, 77-149 #e5eee5,#0d1410, +|1: 0-1 #ffffff,#887455, 2-2 d,#26362d, 3-34 #becfc4,#26362d, 35-74 d,#26362d, 75-76 #ffffff,#887455, 77-77 d,#1d2824, 78-109 #b2c3b8,#1d2824, 110-149 d,#1d2824, +|2: 0-1 #ffffff,#496656, 2-2 d,#1d2824, 3-30 #b2c3b8,#1d2824, 31-33 #d3b0d9,#1d2824, 34-63 #b2c3b8,#1d2824, 64-74 d,#1d2824, 75-76 #ffffff,#496656, 77-77 d,#1d2824, 78-105 #b2c3b8,#1d2824, 106-108 #d3b0d9,#1d2824, 109-138 #b2c3b8,#1d2824, 139-149 d,#1d2824, +|3: 0-0 d,#152019, 1-1 d,#0d1410, 2-70 d,#1d2824, 71-74 #b2c3b8,#1d2824, 75-75 d,#608269, 76-76 d,#0d1410, 77-149 #e5eee5,#0d1410, +|4: 0-0 d,#608269, 1-1 d,#0d1410, 2-74 #e5eee5,#0d1410, 75-75 d,#608269, 76-76 d,#0d1410, 77-149 #e5eee5,#0d1410, +|5: 0-0 d,#608269, 1-1 d,#0d1410, 2-74 #e5eee5,#0d1410, 75-75 d,#608269, 76-149 d,#0d1410, +|6: 0-1 #000000,#add38a, 2-2 d,#26362d, 3-73 #becfc4,#26362d, 74-74 #dfbce5,#26362d, 75-75 d,#608269, 76-76 d,#0d1410, 77-149 #e5eee5,#0d1410, +|7: 0-0 d,#152019, 1-27 d,#0d1410, 28-29 #959595,#6c6c6c, 30-30 #6c6c6c,#959595, 31-34 #959595,#6c6c6c, 35-35 #6c6c6c,#959595, 36-37 #959595,#6c6c6c, 38-38 #6c6c6c,#959595, 39-39 #959595,#6c6c6c, 40-40 #6c6c6c,#959595, 41-41 #959595,#6c6c6c, 42-42 #6c6c6c,#959595, 43-44 #959595,#6c6c6c, 45-45 #6c6c6c,#959595, 46-46 #959595,#6c5eb5, 47-47 #352879,#6c6c6c, 48-74 d,#0d1410, 75-75 d,#608269, 76-76 d,#0d1410, 77-149 #e5eee5,#0d1410, +|8: 0-0 d,#152019, 1-27 d,#0d1410, 28-28 #6c6c6c,#959595, 29-29 #959595,#6c6c6c, 30-30 #6c6c6c,#959595, 31-34 #959595,#6c6c6c, 35-38 #6c6c6c,#959595, 39-42 #959595,#6c6c6c, 43-43 #6c6c6c,#959595, 44-44 #6c6c6c,#352879, 45-45 #352879,#959595, 46-47 #352879,#352879, 48-74 d,#0d1410, 75-75 d,#608269, 76-76 d,#0d1410, 77-149 #e5eee5,#0d1410, +|9: 0-0 d,#152019, 1-27 d,#0d1410, 28-28 #959595,#6c6c6c, 29-29 #6c6c6c,#959595, 30-33 #959595,#6c6c6c, 34-34 #6c6c6c,#959595, 35-38 #959595,#6c6c6c, 39-39 #6c6c6c,#959595, 40-40 #959595,#6c6c6c, 41-41 #6c6c6c,#959595, 42-42 #959595,#6c5eb5, 43-43 #352879,#6c6c6c, 44-47 #352879,#352879, 48-74 d,#0d1410, 75-75 d,#608269, 76-76 d,#0d1410, 77-149 #e5eee5,#0d1410, +|10: 0-0 d,#152019, 1-27 d,#0d1410, 28-29 #959595,#6c6c6c, 30-30 #6c6c6c,#959595, 31-33 #959595,#6c6c6c, 34-34 #6c6c6c,#959595, 35-39 #959595,#6c6c6c, 40-40 #959595,#6c5eb5, 41-41 #6c6c6c,#352879, 42-47 #352879,#352879, 48-74 d,#0d1410, 75-75 d,#608269, 76-76 d,#0d1410, 77-149 #e5eee5,#0d1410, +|11: 0-0 d,#152019, 1-27 d,#0d1410, 28-28 #6c6c6c,#959595, 29-29 #959595,#6c6c6c, 30-34 #6c6c6c,#959595, 35-36 #959595,#6c6c6c, 37-37 #6c6c6c,#959595, 38-38 #6c6c6c,#6c5eb5, 39-39 #352879,#6c6c6c, 40-47 #352879,#352879, 48-74 d,#0d1410, 75-75 d,#608269, 76-76 d,#0d1410, 77-149 #e5eee5,#0d1410, +|12: 0-0 d,#152019, 1-27 d,#0d1410, 28-29 #6c6c6c,#959595, 30-31 #959595,#6c6c6c, 32-32 #6c6c6c,#959595, 33-34 #959595,#6c6c6c, 35-35 #6c6c6c,#959595, 36-36 #6c6c6c,#6c5eb5, 37-37 #352879,#6c6c6c, 38-47 #352879,#352879, 48-74 d,#0d1410, 75-75 d,#608269, 76-76 d,#0d1410, 77-149 #e5eee5,#0d1410, +|13: 0-0 d,#152019, 1-27 d,#0d1410, 28-29 #959595,#6c6c6c, 30-32 #6c6c6c,#959595, 33-33 #959595,#6c6c6c, 34-34 #6c6c6c,#352879, 35-35 #352879,#6c6c6c, 36-47 #352879,#352879, 48-74 d,#0d1410, 75-75 d,#608269, 76-76 d,#0d1410, 77-149 #e5eee5,#0d1410, +|14: 0-0 d,#152019, 1-27 d,#0d1410, 28-31 #959595,#6c6c6c, 32-32 #959595,#6c5eb5, 33-33 #352879,#6c5eb5, 34-47 #352879,#352879, 48-74 d,#0d1410, 75-75 d,#608269, 76-76 d,#0d1410, 77-149 #e5eee5,#0d1410, +|15: 0-0 d,#152019, 1-27 d,#0d1410, 28-28 #6c6c6c,#959595, 29-29 #959595,#6c6c6c, 30-30 #6c6c6c,#6c5eb5, 31-31 #352879,#6c6c6c, 32-47 #352879,#352879, 48-74 d,#0d1410, 75-75 d,#608269, 76-76 d,#0d1410, 77-149 #e5eee5,#0d1410, +|16: 0-0 d,#152019, 1-27 d,#0d1410, 28-28 #6c6c6c,#6c5eb5, 29-29 #352879,#6c6c6c, 30-47 #352879,#352879, 48-74 d,#0d1410, 75-75 d,#608269, 76-76 d,#0d1410, 77-149 #e5eee5,#0d1410, +|17: 0-1 #ffffff,#496656, 2-2 d,#1d2824, 3-30 #b2c3b8,#1d2824, 31-33 #d3b0d9,#1d2824, 34-63 #b2c3b8,#1d2824, 64-74 d,#1d2824, 75-75 d,#608269, 76-76 d,#0d1410, 77-149 #e5eee5,#0d1410, +|18: 0-0 d,#608269, 1-1 d,#0d1410, 2-74 #e5eee5,#0d1410, 75-75 d,#608269, 76-76 d,#0d1410, 77-149 #e5eee5,#0d1410, +|19: 0-0 d,#608269, 1-1 d,#0d1410, 2-74 #e5eee5,#0d1410, 75-75 d,#608269, 76-76 d,#0d1410, 77-149 #e5eee5,#0d1410, +|20: 0-0 d,#608269, 1-74 d,#0d1410, 75-75 d,#608269, 76-76 d,#0d1410, 77-149 #e5eee5,#0d1410, +|21: 0-0 d,#608269, 1-1 d,#0d1410, 2-74 #e5eee5,#0d1410, 75-75 d,#608269, 76-76 d,#0d1410, 77-149 #e5eee5,#0d1410, +|22: 0-0 d,#608269, 1-1 d,#0d1410, 2-74 #e5eee5,#0d1410, 75-75 d,#608269, 76-76 d,#0d1410, 77-149 #e5eee5,#0d1410, +|23: 0-0 d,#608269, 1-1 d,#0d1410, 2-74 #e5eee5,#0d1410, 75-75 d,#608269, 76-76 d,#0d1410, 77-149 #e5eee5,#0d1410, +|24: 0-0 d,#608269, 1-1 d,#0d1410, 2-74 #e5eee5,#0d1410, 75-75 d,#608269, 76-76 d,#0d1410, 77-149 #e5eee5,#0d1410, +|25: 0-0 d,#608269, 1-1 d,#0d1410, 2-74 #e5eee5,#0d1410, 75-75 d,#608269, 76-76 d,#0d1410, 77-149 #e5eee5,#0d1410, +|26: 0-0 d,#608269, 1-1 d,#0d1410, 2-74 #e5eee5,#0d1410, 75-75 d,#608269, 76-76 d,#0d1410, 77-149 #e5eee5,#0d1410, +|27: 0-0 d,#608269, 1-1 d,#0d1410, 2-74 #e5eee5,#0d1410, 75-75 d,#608269, 76-76 d,#0d1410, 77-149 #e5eee5,#0d1410, +|28: 0-0 d,#608269, 1-1 d,#0d1410, 2-74 #e5eee5,#0d1410, 75-75 d,#608269, 76-76 d,#0d1410, 77-149 #e5eee5,#0d1410, +|29: 0-0 d,#608269, 1-1 d,#0d1410, 2-74 #e5eee5,#0d1410, 75-75 d,#608269, 76-76 d,#0d1410, 77-149 #e5eee5,#0d1410, +|30: 0-0 d,#608269, 1-1 d,#0d1410, 2-74 #e5eee5,#0d1410, 75-75 d,#608269, 76-76 d,#0d1410, 77-149 #e5eee5,#0d1410, == style term-palette grid=150x31 -|7: 0-0 d,#152019, 1-27 d,#0d1410, 28-28 p8,p5, 29-30 p8,p4, 31-31 p4,p8, 32-35 p8,p4, 36-37 p4,p8, 38-39 p8,p4, 40-40 p4,p8, 41-42 p8,p4, 43-43 p4,p8, 44-46 p8,p4, 47-47 p12,p8, 48-74 d,#0d1410, 75-75 d,#637f6a, 76-76 d,#0d1410, 77-149 #e5eee5,#0d1410, -|8: 0-0 d,#152019, 1-27 d,#0d1410, 28-30 p8,p4, 31-33 p4,p8, 34-34 p8,p4, 35-36 p4,p8, 37-37 p8,p4, 38-41 p4,p8, 42-42 p8,p4, 43-43 p4,p8, 44-44 p8,p12, 45-46 p12,p8, 47-47 p12,p12, 48-74 d,#0d1410, 75-75 d,#637f6a, 76-76 d,#0d1410, 77-149 #e5eee5,#0d1410, -|9: 0-0 d,#152019, 1-27 d,#0d1410, 28-28 p8,p4, 29-29 p4,p8, 30-30 p8,p4, 31-31 p4,p8, 32-32 p8,p4, 33-33 p4,p8, 34-35 p8,p4, 36-37 p4,p8, 38-38 p8,p5, 39-41 p8,p4, 42-42 p4,p8, 43-44 p12,p8, 45-47 p12,p12, 48-74 d,#0d1410, 75-75 d,#637f6a, 76-76 d,#0d1410, 77-149 #e5eee5,#0d1410, -|10: 0-0 d,#152019, 1-27 d,#0d1410, 28-29 p8,p4, 30-34 p4,p8, 35-36 p8,p4, 37-38 p4,p8, 39-39 p8,p4, 40-40 p4,p8, 41-41 p12,p8, 42-47 p12,p12, 48-74 d,#0d1410, 75-75 d,#637f6a, 76-76 d,#0d1410, 77-149 #e5eee5,#0d1410, -|11: 0-0 d,#152019, 1-27 d,#0d1410, 28-28 p4,p8, 29-29 p8,p4, 30-31 p4,p8, 32-32 p8,p4, 33-33 p4,p8, 34-34 p8,p4, 35-36 p4,p8, 37-37 p8,p4, 38-38 p8,p12, 39-39 p12,p8, 40-47 p12,p12, 48-74 d,#0d1410, 75-75 d,#637f6a, 76-76 d,#0d1410, 77-149 #e5eee5,#0d1410, -|12: 0-0 d,#152019, 1-27 d,#0d1410, 28-28 p8,p4, 29-31 p4,p8, 32-35 p8,p4, 36-36 p4,p8, 37-37 p12,p8, 38-47 p12,p12, 48-74 d,#0d1410, 75-75 d,#637f6a, 76-76 d,#0d1410, 77-149 #e5eee5,#0d1410, -|13: 0-0 d,#152019, 1-27 d,#0d1410, 28-32 p8,p4, 33-33 p4,p8, 34-34 p8,p12, 35-36 p12,p8, 37-47 p12,p12, 48-74 d,#0d1410, 75-75 d,#637f6a, 76-76 d,#0d1410, 77-149 #e5eee5,#0d1410, -|14: 0-0 d,#152019, 1-27 d,#0d1410, 28-28 p8,p4, 29-29 p4,p8, 30-30 p8,p4, 31-32 p4,p8, 33-33 p12,p8, 34-34 p8,p12, 35-47 p12,p12, 48-74 d,#0d1410, 75-75 d,#637f6a, 76-76 d,#0d1410, 77-149 #e5eee5,#0d1410, -|15: 0-0 d,#152019, 1-27 d,#0d1410, 28-29 p4,p8, 30-30 p8,p12, 31-32 p12,p8, 33-47 p12,p12, 48-74 d,#0d1410, 75-75 d,#637f6a, 76-76 d,#0d1410, 77-149 #e5eee5,#0d1410, -|16: 0-0 d,#152019, 1-27 d,#0d1410, 28-28 p8,p12, 29-29 p12,p8, 30-47 p12,p12, 48-74 d,#0d1410, 75-75 d,#637f6a, 76-76 d,#0d1410, 77-149 #e5eee5,#0d1410, +|3: 0-0 d,#608269, 1-1 d,#0d1410, 2-74 #e5eee5,#0d1410, 75-75 d,#608269, 76-76 d,#0d1410, 77-149 #e5eee5,#0d1410, +|5: 0-0 d,#608269, 1-74 d,#0d1410, 75-75 d,#608269, 76-149 d,#0d1410, +|6: 0-1 #000000,#add38a, 2-2 d,#26362d, 3-72 #becfc4,#26362d, 73-74 #dfbce5,#26362d, 75-75 d,#608269, 76-76 d,#0d1410, 77-149 #e5eee5,#0d1410, +|7: 0-0 d,#152019, 1-1 d,#0d1410, 2-67 d,#1d2824, 68-74 #b2c3b8,#1d2824, 75-75 d,#608269, 76-76 d,#0d1410, 77-149 #e5eee5,#0d1410, +|8: 0-0 d,#152019, 1-28 d,#0d1410, 29-31 p8,p4, 32-33 p4,p8, 34-37 p8,p4, 38-38 p4,p8, 39-44 p8,p4, 45-45 p8,p12, 46-46 p12,p8, 47-74 d,#0d1410, 75-75 d,#608269, 76-76 d,#0d1410, 77-149 #e5eee5,#0d1410, +|9: 0-0 d,#152019, 1-28 d,#0d1410, 29-29 p8,p4, 30-30 p4,p8, 31-35 p8,p4, 36-36 p5,p8, 37-37 p8,p4, 38-38 p4,p8, 39-41 p8,p4, 42-42 p4,p8, 43-43 p8,p12, 44-45 p12,p8, 46-46 p12,p12, 47-74 d,#0d1410, 75-75 d,#608269, 76-76 d,#0d1410, 77-149 #e5eee5,#0d1410, +|10: 0-0 d,#152019, 1-28 d,#0d1410, 29-30 p8,p4, 31-32 p4,p8, 33-40 p8,p4, 41-41 p8,p12, 42-43 p12,p8, 44-46 p12,p12, 47-74 d,#0d1410, 75-75 d,#608269, 76-76 d,#0d1410, 77-149 #e5eee5,#0d1410, +|11: 0-0 d,#152019, 1-28 d,#0d1410, 29-31 p8,p4, 32-32 p4,p8, 33-34 p8,p4, 35-37 p4,p8, 38-38 p8,p4, 39-39 p8,p12, 40-41 p12,p8, 42-46 p12,p12, 47-74 d,#0d1410, 75-75 d,#608269, 76-76 d,#0d1410, 77-149 #e5eee5,#0d1410, +|12: 0-0 d,#152019, 1-28 d,#0d1410, 29-36 p8,p4, 37-37 p8,p12, 38-39 p12,p8, 40-46 p12,p12, 47-74 d,#0d1410, 75-75 d,#608269, 76-76 d,#0d1410, 77-149 #e5eee5,#0d1410, +|13: 0-0 d,#152019, 1-28 d,#0d1410, 29-30 p4,p8, 31-34 p8,p4, 35-35 p8,p12, 36-36 p12,p8, 37-46 p12,p12, 47-74 d,#0d1410, 75-75 d,#608269, 76-76 d,#0d1410, 77-149 #e5eee5,#0d1410, +|14: 0-0 d,#152019, 1-28 d,#0d1410, 29-29 p4,p8, 30-31 p8,p4, 32-32 p4,p8, 33-33 p8,p12, 34-35 p12,p8, 36-46 p12,p12, 47-74 d,#0d1410, 75-75 d,#608269, 76-76 d,#0d1410, 77-149 #e5eee5,#0d1410, +|15: 0-0 d,#152019, 1-28 d,#0d1410, 29-29 p4,p8, 30-30 p8,p4, 31-31 p8,p12, 32-32 p12,p8, 33-46 p12,p12, 47-74 d,#0d1410, 75-75 d,#608269, 76-76 d,#0d1410, 77-149 #e5eee5,#0d1410, +|16: 0-0 d,#152019, 1-28 d,#0d1410, 29-29 p8,p12, 30-30 p12,p8, 31-46 p12,p12, 47-74 d,#0d1410, 75-75 d,#608269, 76-76 d,#0d1410, 77-149 #e5eee5,#0d1410, == snap no-ascii grid=150x31 cursor=11,8 -|6: img petscii:off palette:terminal ascii:off /tmp/pardes-snap/images/cwd/pi -|7: ███╱█🬻██🬺██🬻███╱██🬴▄ -|8: 🬬██╱███╱🬻ðŸ¬�🬻🬬████ðŸ¬�🬵█ -|9: █╲█🬴████╲╱█ðŸ¬�██▟▄█ -|10: ██╲╱╲█ðŸ¬�█████╱🬵 -|11: ╱█████████ðŸ¬�â–„ -|12: █│█████ðŸ¬�ðŸ¬�🬹 -|13: ██████ðŸ¬�â–„â–ˆ -|14: 🬜🬬██🬸▄╲ -|15: 🬺█ðŸ¬�🬵█ -|16: ðŸ¬�â–„ -== snap tag-edit grid=400x31 cursor=86,6 +|3: ls ls +|4: pic.ppm pic.ppm +|5: +|6: img petscii:off palette:terminal ascii:off /tmp/pardes-snap/images/cwd/p +|7: Ascii +|8: â–ˆðŸ¬�█╲███▙🬸🬬🬻█████ðŸ¬�🬵 +|9: ███████🬻██🬸█ðŸ¬�â–ˆðŸ¬�â–„â–ˆ +|10: ████████████ðŸ¬�â–„â–ˆ +|11: ███🬸██████ðŸ¬�â–„â–ˆ +|12: ████████ðŸ¬�🬵█ +|13: ╱█████ðŸ¬�â–„ +|14: █🬬█╲ðŸ¬�🬵█ +|15: 🬺█ðŸ¬�🬵 +|16: ðŸ¬�â–„ +== snap tag-edit grid=400x31 cursor=87,6 |Newcol Joincol Find Grep Help Changelog Tutor Dump NextColor Debug Kill -|New Tty Find Grep Joincol New Tty Find Grep Joincol -| /tmp/pardes-snap/images/cwd Save Tty Del Togglettymode Filter Collapse /tmp/pardes-snap/images/cwd Save Tty Del Togglettymode Filter Collapse +| New Tty Find Grep Joincol Delcol New Tty Find Grep Joincol Delcol +| /tmp/pardes-snap/images/cwd Tty Save Mode Filter Collapse Del /tmp/pardes-snap/images/cwd Tty Save Mode Filter Collapse Del | ls ls | pic.ppm pic.ppm | -| img petscii:off palette:terminal ascii:off /tmp/pardes-snap/images/cwd/pic.ppm Zork Tty Del Collapse +| img petscii:off palette:terminal ascii:off /tmp/pardes-snap/images/cwd/pic.ppm Zork Tty Collapse Del | ███╱█🬻██🬺██🬻███╱██🬴▄ | 🬬██╱███╱🬻ðŸ¬�🬻🬬████ðŸ¬�🬵█ | █╲█🬴████╲╱█ðŸ¬�██▟▄█ @@ -92,6 +98,6 @@ | 🬜🬬██🬸▄╲ | 🬺█ðŸ¬�🬵█ | ðŸ¬�â–„ -| /tmp/pardes-snap/images/cwd Save Tty Del Togglettymode Filter Collapse +| /tmp/pardes-snap/images/cwd Tty Save Mode Filter Collapse Del | ls | pic.ppm diff --git a/test/snapshots/jumps.golden b/test/snapshots/jumps.golden index 3005135c..9800ca4c 100644 --- a/test/snapshots/jumps.golden +++ b/test/snapshots/jumps.golden @@ -1,7 +1,7 @@ == snap start grid=150x31 cursor=7,3 |Newcol Joincol Find Grep Help Changelog Tutor Dump NextColor Debug Kill -|New Tty Find Grep Joincol -| /tmp/pardes-snap/jumps/cwd/big.txt Save Tty Del Collapse +| New Tty Find Grep Joincol Delcol +| /tmp/pardes-snap/jumps/cwd/big.txt Save Tty Collapse Del | 1 line 1 | 2 line 2 | 3 line 3 @@ -31,11 +31,14 @@ | 27 line 27 | 28 line 28 == snap to-shell grid=150x31 cursor=79,5 -|1: New Tty Find Grep Joincol New Tty Find Grep Joincol -|2: /tmp/pardes-snap/jumps/cwd/big.txt Save Tty Del Collapse /tmp/pardes-snap/jumps/cwd Save Tty Del Togglettymode Filter Collapse +|1: New Tty Find Grep Joincol Delcol New Tty Find Grep Joincol Delcol +|2: /tmp/pardes-snap/jumps/cwd/big.txt Save Tty Collapse Del /tmp/pardes-snap/jumps/cwd Tty Save Mode Filter Collapse Del |3: 1 line 1 ls |4: 2 line 2 big.txt == snap to-file grid=150x31 cursor=7,3 +|3: 1 line 1 Left +|4: 2 line 2 ls +|5: 3 line 3 big.txt == snap goto-100 grid=150x31 cursor=7,27 |3: 76 line 76 ls |4: 77 line 77 big.txt @@ -65,10 +68,40 @@ |28: 101 line 101 |29: 102 line 102 |30: 103 line 103 -== snap back-in-file grid=150x31 cursor=7,3 -|3: 1 line 1 ls -|4: 2 line 2 big.txt -|5: 3 line 3 +== snap back-in-file grid=150x31 cursor=7,4 +|3: Back ls +|4: 1 line 1 big.txt +|5: 2 line 2 +|6: 3 line 3 +|7: 4 line 4 +|8: 5 line 5 +|9: 6 line 6 +|10: 7 line 7 +|11: 8 line 8 +|12: 9 line 9 +|13: 10 line 10 +|14: 11 line 11 +|15: 12 line 12 +|16: 13 line 13 +|17: 14 line 14 +|18: 15 line 15 +|19: 16 line 16 +|20: 17 line 17 +|21: 18 line 18 +|22: 19 line 19 +|23: 20 line 20 +|24: 21 line 21 +|25: 22 line 22 +|26: 23 line 23 +|27: 24 line 24 +|28: 25 line 25 +|29: 26 line 26 +|30: 27 line 27 +== snap back-to-shell grid=150x31 cursor=79,5 +== snap forward-file grid=150x31 cursor=7,3 +|3: 1 line 1 Forward +|4: 2 line 2 ls +|5: 3 line 3 big.txt |6: 4 line 4 |7: 5 line 5 |8: 6 line 6 @@ -94,12 +127,41 @@ |28: 26 line 26 |29: 27 line 27 |30: 28 line 28 -== snap back-to-shell grid=150x31 cursor=79,5 -== snap forward-file grid=150x31 cursor=7,3 -== snap forward-100 grid=150x31 cursor=7,17 -|3: 86 line 86 ls -|4: 87 line 87 big.txt -|5: 88 line 88 +== snap forward-100 grid=150x31 cursor=7,18 +|3: Forward ls +|4: 86 line 86 big.txt +|5: 87 line 87 +|6: 88 line 88 +|7: 89 line 89 +|8: 90 line 90 +|9: 91 line 91 +|10: 92 line 92 +|11: 93 line 93 +|12: 94 line 94 +|13: 95 line 95 +|14: 96 line 96 +|15: 97 line 97 +|16: 98 line 98 +|17: 99 line 99 +|18: 100 line 100 +|19: 101 line 101 +|20: 102 line 102 +|21: 103 line 103 +|22: 104 line 104 +|23: 105 line 105 +|24: 106 line 106 +|25: 107 line 107 +|26: 108 line 108 +|27: 109 line 109 +|28: 110 line 110 +|29: 111 line 111 +|30: 112 line 112 +== snap last grid=150x31 cursor=79,5 +|3: Last ls +== snap last-back grid=150x31 cursor=7,17 +|3: 86 line 86 Last +|4: 87 line 87 ls +|5: 88 line 88 big.txt |6: 89 line 89 |7: 90 line 90 |8: 91 line 91 @@ -125,47 +187,95 @@ |28: 111 line 111 |29: 112 line 112 |30: 113 line 113 -== snap last grid=150x31 cursor=79,5 -== snap last-back grid=150x31 cursor=7,17 -== snap jumplist grid=150x31 cursor=7,17 -|26: /tmp/pardes-snap/jumps/cwd/+Jumps Save Tty Del Collapse +== snap jumplist grid=150x31 cursor=7,18 +|3: Jumplist ls +|4: 86 line 86 big.txt +|5: 87 line 87 +|6: 88 line 88 +|7: 89 line 89 +|8: 90 line 90 +|9: 91 line 91 +|10: 92 line 92 +|11: 93 line 93 +|12: 94 line 94 +|13: 95 line 95 +|14: 96 line 96 +|15: 97 line 97 +|16: 98 line 98 +|17: 99 line 99 +|18: 100 line 100 +|19: 101 line 101 +|20: 102 line 102 +|21: 103 line 103 +|22: 104 line 104 +|23: 105 line 105 +|24: 106 line 106 +|25: 107 line 107 +|26: /tmp/pardes-snap/jumps/cwd/+Jumps Save Tty Collapse Del LocationsConfig |27: 1 @p1:3:3 /tmp/pardes-snap/jumps/cwd |28: 2 /tmp/pardes-snap/jumps/cwd/big.txt:1:1 line 1 |29: 3 @p1:3:3 /tmp/pardes-snap/jumps/cwd |30: 4 /tmp/pardes-snap/jumps/cwd/big.txt:100:1 line 100 == snap step1-shell grid=150x31 cursor=79,5 +|3: 86 line 86 ls +|4: 87 line 87 big.txt +|5: 88 line 88 +|6: 89 line 89 +|7: 90 line 90 +|8: 91 line 91 +|9: 92 line 92 +|10: 93 line 93 +|11: 94 line 94 +|12: 95 line 95 +|13: 96 line 96 +|14: 97 line 97 +|15: 98 line 98 +|16: 99 line 99 +|17: 100 line 100 +|18: 101 line 101 +|19: 102 line 102 +|20: 103 line 103 +|21: 104 line 104 +|22: 105 line 105 +|23: 106 line 106 +|24: 107 line 107 +|25: 108 line 108 +|27: Look +|28: 1 @p1:3:3 /tmp/pardes-snap/jumps/cwd +|29: 2 /tmp/pardes-snap/jumps/cwd/big.txt:1:1 line 1 +|30: 3 @p1:3:3 /tmp/pardes-snap/jumps/cwd == style step1-shell grid=150x31 |0: 0-70 #b2c3b8,#1d2824, 71-149 d,#1d2824, -|1: 0-24 #b2c3b8,#1d2824, 25-74 d,#1d2824, 75-99 #becfc4,#26362d, 100-149 d,#26362d, -|2: 0-1 #ffffff,#4c6356, 2-57 #b2c3b8,#1d2824, 58-74 d,#1d2824, 75-76 #000000,#adcc91, 77-145 #becfc4,#26362d, 146-149 d,#26362d, -|3: 0-0 d,#152019, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-13 #e5eee5,#0d1410, 14-74 d,#0d1410, 75-75 d,#637f6a, 76-76 d,#0d1410, 77-149 #e5eee5,#0d1410, -|4: 0-0 d,#152019, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-13 #e5eee5,#0d1410, 14-74 d,#0d1410, 75-75 d,#637f6a, 76-76 d,#0d1410, 77-149 #e5eee5,#0d1410, -|5: 0-0 d,#152019, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-13 #e5eee5,#0d1410, 14-74 d,#0d1410, 75-75 d,#637f6a, 76-149 d,#0d1410, -|6: 0-0 d,#152019, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-13 #e5eee5,#0d1410, 14-74 d,#0d1410, 75-75 d,#637f6a, 76-76 d,#0d1410, 77-149 #e5eee5,#0d1410, -|7: 0-0 d,#152019, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-13 #e5eee5,#0d1410, 14-74 d,#0d1410, 75-75 d,#637f6a, 76-76 d,#0d1410, 77-149 #e5eee5,#0d1410, -|8: 0-0 d,#152019, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-13 #e5eee5,#0d1410, 14-74 d,#0d1410, 75-75 d,#637f6a, 76-76 d,#0d1410, 77-149 #e5eee5,#0d1410, -|9: 0-0 d,#152019, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-13 #e5eee5,#0d1410, 14-74 d,#0d1410, 75-75 d,#637f6a, 76-76 d,#0d1410, 77-149 #e5eee5,#0d1410, -|10: 0-0 d,#152019, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-13 #e5eee5,#0d1410, 14-74 d,#0d1410, 75-75 d,#637f6a, 76-76 d,#0d1410, 77-149 #e5eee5,#0d1410, -|11: 0-0 d,#152019, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-13 #e5eee5,#0d1410, 14-74 d,#0d1410, 75-75 d,#637f6a, 76-76 d,#0d1410, 77-149 #e5eee5,#0d1410, -|12: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-13 #e5eee5,#0d1410, 14-74 d,#0d1410, 75-75 d,#637f6a, 76-76 d,#0d1410, 77-149 #e5eee5,#0d1410, -|13: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-13 #e5eee5,#0d1410, 14-74 d,#0d1410, 75-75 d,#637f6a, 76-76 d,#0d1410, 77-149 #e5eee5,#0d1410, -|14: 0-0 d,#152019, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-13 #e5eee5,#0d1410, 14-74 d,#0d1410, 75-75 d,#637f6a, 76-76 d,#0d1410, 77-149 #e5eee5,#0d1410, -|15: 0-0 d,#152019, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-13 #e5eee5,#0d1410, 14-74 d,#0d1410, 75-75 d,#637f6a, 76-76 d,#0d1410, 77-149 #e5eee5,#0d1410, -|16: 0-0 d,#152019, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-13 #e5eee5,#0d1410, 14-74 d,#0d1410, 75-75 d,#637f6a, 76-76 d,#0d1410, 77-149 #e5eee5,#0d1410, -|17: 0-0 d,#152019, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-14 #e5eee5,#0d1410, 15-74 d,#0d1410, 75-75 d,#637f6a, 76-76 d,#0d1410, 77-149 #e5eee5,#0d1410, -|18: 0-0 d,#152019, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-14 #e5eee5,#0d1410, 15-74 d,#0d1410, 75-75 d,#637f6a, 76-76 d,#0d1410, 77-149 #e5eee5,#0d1410, -|19: 0-0 d,#152019, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-14 #e5eee5,#0d1410, 15-74 d,#0d1410, 75-75 d,#637f6a, 76-76 d,#0d1410, 77-149 #e5eee5,#0d1410, -|20: 0-0 d,#152019, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-14 #e5eee5,#0d1410, 15-74 d,#0d1410, 75-75 d,#637f6a, 76-76 d,#0d1410, 77-149 #e5eee5,#0d1410, -|21: 0-0 d,#152019, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-14 #e5eee5,#0d1410, 15-74 d,#0d1410, 75-75 d,#637f6a, 76-76 d,#0d1410, 77-149 #e5eee5,#0d1410, -|22: 0-0 d,#152019, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-14 #e5eee5,#0d1410, 15-74 d,#0d1410, 75-75 d,#637f6a, 76-76 d,#0d1410, 77-149 #e5eee5,#0d1410, -|23: 0-0 d,#152019, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-14 #e5eee5,#0d1410, 15-74 d,#0d1410, 75-75 d,#637f6a, 76-76 d,#0d1410, 77-149 #e5eee5,#0d1410, -|24: 0-0 d,#152019, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-14 #e5eee5,#0d1410, 15-74 d,#0d1410, 75-75 d,#637f6a, 76-76 d,#0d1410, 77-149 #e5eee5,#0d1410, -|25: 0-0 d,#152019, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-14 #e5eee5,#0d1410, 15-74 d,#0d1410, 75-75 d,#637f6a, 76-76 d,#0d1410, 77-149 #e5eee5,#0d1410, -|26: 0-1 #ffffff,#4c6356, 2-56 #b2c3b8,#1d2824, 57-74 d,#1d2824, 75-75 d,#637f6a, 76-76 d,#0d1410, 77-149 #e5eee5,#0d1410, -|27: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-13 #59675c,#0d1410, 14-40 #e5eee5,#0d1410, 41-74 d,#0d1410, 75-75 d,#637f6a, 76-76 d,#0d1410, 77-149 #e5eee5,#0d1410, -|28: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-44 #59675c,#0d1410, 45-51 #e5eee5,#0d1410, 52-74 d,#0d1410, 75-75 d,#637f6a, 76-76 d,#0d1410, 77-149 #e5eee5,#0d1410, -|29: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-13 #59675c,#0d1410, 14-40 #e5eee5,#0d1410, 41-74 d,#0d1410, 75-75 d,#637f6a, 76-76 d,#0d1410, 77-149 #e5eee5,#0d1410, -|30: 0-0 d,#152019, 1-1 d,#0d1410, 2-46 #59675c,#0d1410, 47-55 #e5eee5,#0d1410, 56-74 d,#0d1410, 75-75 d,#637f6a, 76-76 d,#0d1410, 77-149 #e5eee5,#0d1410, +|1: 0-1 #ffffff,#887455, 2-2 d,#1d2824, 3-34 #b2c3b8,#1d2824, 35-74 d,#1d2824, 75-76 #ffffff,#887455, 77-77 d,#26362d, 78-109 #becfc4,#26362d, 110-149 d,#26362d, +|2: 0-1 #ffffff,#496656, 2-2 d,#1d2824, 3-29 #b2c3b8,#1d2824, 30-36 #d3b0d9,#1d2824, 37-58 #b2c3b8,#1d2824, 59-74 d,#1d2824, 75-76 #000000,#add38a, 77-77 d,#26362d, 78-104 #becfc4,#26362d, 105-107 #dfbce5,#26362d, 108-137 #becfc4,#26362d, 138-149 d,#26362d, +|3: 0-0 d,#152019, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-13 #e5eee5,#0d1410, 14-74 d,#0d1410, 75-75 d,#608269, 76-76 d,#0d1410, 77-149 #e5eee5,#0d1410, +|4: 0-0 d,#152019, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-13 #e5eee5,#0d1410, 14-74 d,#0d1410, 75-75 d,#608269, 76-76 d,#0d1410, 77-149 #e5eee5,#0d1410, +|5: 0-0 d,#152019, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-13 #e5eee5,#0d1410, 14-74 d,#0d1410, 75-75 d,#608269, 76-149 d,#0d1410, +|6: 0-0 d,#152019, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-13 #e5eee5,#0d1410, 14-74 d,#0d1410, 75-75 d,#608269, 76-76 d,#0d1410, 77-149 #e5eee5,#0d1410, +|7: 0-0 d,#152019, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-13 #e5eee5,#0d1410, 14-74 d,#0d1410, 75-75 d,#608269, 76-76 d,#0d1410, 77-149 #e5eee5,#0d1410, +|8: 0-0 d,#152019, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-13 #e5eee5,#0d1410, 14-74 d,#0d1410, 75-75 d,#608269, 76-76 d,#0d1410, 77-149 #e5eee5,#0d1410, +|9: 0-0 d,#152019, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-13 #e5eee5,#0d1410, 14-74 d,#0d1410, 75-75 d,#608269, 76-76 d,#0d1410, 77-149 #e5eee5,#0d1410, +|10: 0-0 d,#152019, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-13 #e5eee5,#0d1410, 14-74 d,#0d1410, 75-75 d,#608269, 76-76 d,#0d1410, 77-149 #e5eee5,#0d1410, +|11: 0-0 d,#152019, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-13 #e5eee5,#0d1410, 14-74 d,#0d1410, 75-75 d,#608269, 76-76 d,#0d1410, 77-149 #e5eee5,#0d1410, +|12: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-13 #e5eee5,#0d1410, 14-74 d,#0d1410, 75-75 d,#608269, 76-76 d,#0d1410, 77-149 #e5eee5,#0d1410, +|13: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-13 #e5eee5,#0d1410, 14-74 d,#0d1410, 75-75 d,#608269, 76-76 d,#0d1410, 77-149 #e5eee5,#0d1410, +|14: 0-0 d,#152019, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-13 #e5eee5,#0d1410, 14-74 d,#0d1410, 75-75 d,#608269, 76-76 d,#0d1410, 77-149 #e5eee5,#0d1410, +|15: 0-0 d,#152019, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-13 #e5eee5,#0d1410, 14-74 d,#0d1410, 75-75 d,#608269, 76-76 d,#0d1410, 77-149 #e5eee5,#0d1410, +|16: 0-0 d,#152019, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-13 #e5eee5,#0d1410, 14-74 d,#0d1410, 75-75 d,#608269, 76-76 d,#0d1410, 77-149 #e5eee5,#0d1410, +|17: 0-0 d,#152019, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-14 #e5eee5,#0d1410, 15-74 d,#0d1410, 75-75 d,#608269, 76-76 d,#0d1410, 77-149 #e5eee5,#0d1410, +|18: 0-0 d,#152019, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-14 #e5eee5,#0d1410, 15-74 d,#0d1410, 75-75 d,#608269, 76-76 d,#0d1410, 77-149 #e5eee5,#0d1410, +|19: 0-0 d,#152019, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-14 #e5eee5,#0d1410, 15-74 d,#0d1410, 75-75 d,#608269, 76-76 d,#0d1410, 77-149 #e5eee5,#0d1410, +|20: 0-0 d,#152019, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-14 #e5eee5,#0d1410, 15-74 d,#0d1410, 75-75 d,#608269, 76-76 d,#0d1410, 77-149 #e5eee5,#0d1410, +|21: 0-0 d,#152019, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-14 #e5eee5,#0d1410, 15-74 d,#0d1410, 75-75 d,#608269, 76-76 d,#0d1410, 77-149 #e5eee5,#0d1410, +|22: 0-0 d,#152019, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-14 #e5eee5,#0d1410, 15-74 d,#0d1410, 75-75 d,#608269, 76-76 d,#0d1410, 77-149 #e5eee5,#0d1410, +|23: 0-0 d,#152019, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-14 #e5eee5,#0d1410, 15-74 d,#0d1410, 75-75 d,#608269, 76-76 d,#0d1410, 77-149 #e5eee5,#0d1410, +|24: 0-0 d,#152019, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-14 #e5eee5,#0d1410, 15-74 d,#0d1410, 75-75 d,#608269, 76-76 d,#0d1410, 77-149 #e5eee5,#0d1410, +|25: 0-0 d,#152019, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-14 #e5eee5,#0d1410, 15-74 d,#0d1410, 75-75 d,#608269, 76-76 d,#0d1410, 77-149 #e5eee5,#0d1410, +|26: 0-1 #ffffff,#496656, 2-2 d,#1d2824, 3-29 #b2c3b8,#1d2824, 30-35 #d3b0d9,#1d2824, 36-73 #b2c3b8,#1d2824, 74-74 d,#1d2824, 75-75 d,#608269, 76-76 d,#0d1410, 77-149 #e5eee5,#0d1410, +|27: 0-0 d,#152019, 1-1 d,#0d1410, 2-70 d,#1d2824, 71-74 #b2c3b8,#1d2824, 75-75 d,#608269, 76-76 d,#0d1410, 77-149 #e5eee5,#0d1410, +|28: 0-0 d,#608269, 1-1 d,#0d1410, 2-13 #59675c,#0d1410, 14-40 #e5eee5,#0d1410, 41-74 d,#0d1410, 75-75 d,#608269, 76-76 d,#0d1410, 77-149 #e5eee5,#0d1410, +|29: 0-0 d,#608269, 1-1 d,#0d1410, 2-44 #59675c,#0d1410, 45-51 #e5eee5,#0d1410, 52-74 d,#0d1410, 75-75 d,#608269, 76-76 d,#0d1410, 77-149 #e5eee5,#0d1410, +|30: 0-0 d,#152019, 1-1 d,#0d1410, 2-13 #59675c,#0d1410, 14-40 #e5eee5,#0d1410, 41-74 d,#0d1410, 75-75 d,#608269, 76-76 d,#0d1410, 77-149 #e5eee5,#0d1410, == snap step2-file grid=150x31 cursor=7,3 |3: 1 line 1 ls |4: 2 line 2 big.txt @@ -214,9 +324,10 @@ |23: 109 line 109 |24: 110 line 110 |25: 111 line 111 -|27: 2 /tmp/pardes-snap/jumps/cwd/big.txt:1:1 line 1 -|28: 3 @p1:3:3 /tmp/pardes-snap/jumps/cwd -|29: 4 /tmp/pardes-snap/jumps/cwd/big.txt:100:1 line 100 -|30: 5 +|28: 2 /tmp/pardes-snap/jumps/cwd/big.txt:1:1 line 1 +|29: 3 @p1:3:3 /tmp/pardes-snap/jumps/cwd +|30: 4 /tmp/pardes-snap/jumps/cwd/big.txt:100:1 line 100 == snap step-back grid=150x31 cursor=79,5 -== snap look-row grid=150x31 cursor=7,14 +== snap look-row grid=150x31 cursor=79,5 +|5: 91 line 91 ls +|6: 92 line 92 big.txt diff --git a/test/snapshots/layout-close.golden b/test/snapshots/layout-close.golden index 9e573802..c9e1243a 100644 --- a/test/snapshots/layout-close.golden +++ b/test/snapshots/layout-close.golden @@ -1,19 +1,19 @@ == snap built grid=140x41 cursor=4,17 |Newcol Joincol Find Grep Help Changelog Tutor Dump NextColor Debug Kill -|New Tty Find Grep Joincol New Tty Find Grep Joincol -| /tmp/pardes-snap/layout-close/cwd Save Tty Del Togglettymode Filter /tmp/pardes-snap/layout-close/cwd Save Tty Del Togglettymode Filter +| New Tty Find Grep Joincol Delcol New Tty Find Grep Joincol Delcol +| /tmp/pardes-snap/layout-close/cwd Tty Save Mode Filter Collapse Del /tmp/pardes-snap/layout-close/cwd Tty Save Mode Filter Collapse Del | ls ls | marker.txt marker.txt | -| /tmp/pardes-snap/layout-close/cwd Save Tty Del Togglettymode Filter +| /tmp/pardes-snap/layout-close/cwd Tty Save Mode Filter Collapse Del | ls | marker.txt | -| /tmp/pardes-snap/layout-close/cwd Save Tty Del Togglettymode Filter +| /tmp/pardes-snap/layout-close/cwd Tty Save Mode Filter Collapse Del | ls | marker.txt | -| /tmp/pardes-snap/layout-close/cwd Save Tty Del Togglettymode Filter +| /tmp/pardes-snap/layout-close/cwd Tty Save Mode Filter Collapse Del | ls | marker.txt | @@ -21,20 +21,20 @@ | | | -| /tmp/pardes-snap/layout-close/cwd Save Tty Del Togglettymode Filter +| /tmp/pardes-snap/layout-close/cwd Tty Save Mode Filter Collapse Del | ls | marker.txt == snap altc grid=140x41 cursor=39,5 -|1: New Tty Find Grep Joincol New Tty Find Grep Joincol New Tty Find Grep Joincol -|2: /tmp/pardes-snap/layout-close/cwd /tmp/pardes-snap/layout-close/cwd /tmp/pardes-snap/layout-close/cwd Save Tty Del Togglettymode Filter +|1: New Tty Find Grep Joincol Delcol New Tty Find Grep Joincol Delcol New Tty Find Grep Joincol Delcol +|2: /tmp/pardes-snap/layout-close/cw /tmp/pardes-snap/layout-close/cw /tmp/pardes-snap/layout-close/cwd Tty Save Mode Filter Collapse Del |3: ls ls ls |4: marker.txt marker.txt marker.txt -|6: /tmp/pardes-snap/layout-close/cwd -|10: /tmp/pardes-snap/layout-close/cwd +|6: /tmp/pardes-snap/layout-close/cw +|10: /tmp/pardes-snap/layout-close/cw |14: |15: |16: -|22: /tmp/pardes-snap/layout-close/cwd +|22: /tmp/pardes-snap/layout-close/cw == snap del grid=140x41 cursor=39,5 |6: |7: @@ -43,9 +43,6 @@ |10: |11: |12: -== snap colclose grid=140x41 cursor=4,8 -|1: New Tty Find Grep Joincol New Tty Find Grep Joincol -|2: /tmp/pardes-snap/layout-close/cwd Save Tty Del Togglettymode Filter /tmp/pardes-snap/layout-close/cwd Save Tty Del Togglettymode Filter -|3: ls ls +== snap colclose grid=140x41 cursor=42,3 +|3: ls 1 ls |4: marker.txt marker.txt -|22: /tmp/pardes-snap/layout-close/cwd Save Tty Del Togglettymode Filter diff --git a/test/snapshots/layout-open.golden b/test/snapshots/layout-open.golden index 569f98b2..47eea036 100644 --- a/test/snapshots/layout-open.golden +++ b/test/snapshots/layout-open.golden @@ -1,7 +1,7 @@ == snap before grid=100x31 cursor=2,9 |Newcol Joincol Find Grep Help Changelog Tutor Dump NextColor Debug Kill -|New Tty Find Grep Joincol New Tty Find Grep Joincol -| /tmp/pardes-snap/layout-open/cwd Save Tty Del To /tmp/pardes-snap/layout-open/cwd Save Tty Del To +| New Tty Find Grep Joincol Delcol New Tty Find Grep Joincol Delcol +| /tmp/pardes-snap/layout-open/cwd Tty Save Mode /tmp/pardes-snap/layout-open/cwd Tty Save Mode | ls ls | sub sub | @@ -16,21 +16,27 @@ | | | -| /tmp/pardes-snap/layout-open/cwd Save Tty Del To +| /tmp/pardes-snap/layout-open/cwd Tty Save Mode | ls | sub == snap altn-left grid=100x31 cursor=4,9 -|6: /tmp/pardes-snap/layout-open/cwd Save Tty Del To +|6: /tmp/pardes-snap/layout-open/cwd Tty Save Mode |7: ls |8: sub == snap altn-right grid=100x31 cursor=54,9 -|6: /tmp/pardes-snap/layout-open/cwd Save Tty Del To /tmp/pardes-snap/layout-open/cwd Save Tty Del To +|6: /tmp/pardes-snap/layout-open/cwd Tty Save Mode /tmp/pardes-snap/layout-open/cwd Tty Save Mode |7: ls ls |8: sub sub == snap file-open grid=100x31 cursor=7,22 -|21: /tmp/pardes-snap/layout-open/cwd/sub/f.txt Save +|18: Look +|19: ls +|20: sub +|21: /tmp/pardes-snap/layout-open/cwd/sub/f.txt Save |22: 1 echo 'TTY'OK == snap ttydir grid=100x31 cursor=7,22 -|10: /tmp/pardes-snap/layout-open/cwd/sub Save Tty De +|10: /tmp/pardes-snap/layout-open/cwd/sub Tty Save M |11: echo 'TTY'OK |12: TTYOK +|18: ls +|19: sub +|20: diff --git a/test/snapshots/leader.golden b/test/snapshots/leader.golden index d084250c..81d9e3cb 100644 --- a/test/snapshots/leader.golden +++ b/test/snapshots/leader.golden @@ -1,60 +1,25 @@ -== snap spc grid=100x41 cursor=7,3 +== snap spc grid=100x41 cursor=7,4 |Newcol Joincol Find Grep Help Changelog Tutor Dump NextColor Debug Kill -|New Tty Find Grep Joincol -| /tmp/pardes-snap/leader/cwd/cmds.txt Save Tty Del Collapse -| 1 Help -| -| -| -| -| -| -| -| -| -| -| -| -| -| -| -| -| -| -| -| -| -| -| -| -| -| -| -| -| -| -| -| -| -| -| -| +| New Tty Find Grep Joincol Delcol +| /tmp/pardes-snap/leader/cwd/cmds.txt Save Tty Collapse Del | SPC -== snap spc-h grid=100x41 cursor=7,3 -|40: SPC h +| 1 Help +== snap spc-h grid=100x41 cursor=7,4 +|3: SPC h == snap abandoned grid=100x41 cursor=7,3 -|40: +|3: 1 Help +|4: == snap unmapped grid=100x41 cursor=7,3 == snap help-group grid=100x41 cursor=7,23 -|22: /tmp/pardes-snap/leader/cwd/+Help Save Tty Del Collapse +|22: /tmp/pardes-snap/leader/cwd/+Help Save Tty Collapse Del |23: 1 pardes builtins under SPC h |24: 2 -|25: 3 SPC h c Changelog topbar +|25: 3 SPC h c Changelog topbar |26: 4 SPC h m Messages -|27: 5 SPC h t Tutor topbar +|27: 5 SPC h t Tutor topbar |28: 6 == snap tutor grid=100x41 cursor=7,13 -|12: /Tutor Save Tty Del Collapse +|12: /Tutor Save Tty Collapse Del |13: 1 |14: 2 PARDES TUTOR |15: 3 tmux + vi + acme, from scratch. @@ -64,6 +29,13 @@ |19: 7 Press j until you reach the introduction. |20: 8 |21: 9 +|23: Tutor +|24: 1 pardes builtins under SPC h +|25: 2 +|26: 3 SPC h c Changelog topbar +|27: 4 SPC h m Messages +|28: 5 SPC h t Tutor topbar +|29: 6 == snap deleted grid=100x41 cursor=7,23 |12: |13: @@ -75,12 +47,19 @@ |19: |20: |21: +|23: 1 pardes builtins under SPC h +|24: 2 +|25: 3 SPC h c Changelog topbar +|26: 4 SPC h m Messages +|27: 5 SPC h t Tutor topbar +|28: 6 +|29: == snap help-window grid=100x41 cursor=7,23 |23: 1 pardes builtins under SPC w -|25: 3 SPC w h Left C-w h, C-w left -|26: 4 SPC w j Down C-w j, C-w down -|27: 5 SPC w k Up C-w k, C-w up -|28: 6 SPC w l Right C-w l, C-w right +|25: 3 SPC w h Left C-w h, C-w left +|26: 4 SPC w j Down C-w j, C-w down +|27: 5 SPC w k Up C-w k, C-w up +|28: 6 SPC w l Right C-w l, C-w right |29: 7 == snap help-language grid=100x41 cursor=7,23 |23: 1 pardes builtins under SPC l diff --git a/test/snapshots/load.golden b/test/snapshots/load.golden index ebfe6a39..994ab83e 100644 --- a/test/snapshots/load.golden +++ b/test/snapshots/load.golden @@ -1,7 +1,7 @@ == snap loaded grid=100x31 cursor=4,16 |Newcol Joincol Find Grep Help Changelog Tutor Dump NextColor Debug Kill -|New Tty Find Grep Joincol New Tty Find Grep Joincol -| /tmp/pardes-snap/load/cwd Save Tty Del Toggletty /tmp/pardes-snap/load/cwd Save Tty Del Toggletty +| New Tty Find Grep Joincol Delcol New Tty Find Grep Joincol Delcol +| /tmp/pardes-snap/load/cwd Tty Save Mode Filter /tmp/pardes-snap/load/cwd Tty Save Mode Filter | echo LOAD''MARK; seq 1 40; echo E''ND ls | LOADMARK d.txt | 1 @@ -16,38 +16,38 @@ | 10 | 11 | 12 -| /tmp/pardes-snap/load/cwd Save Tty Del Toggletty +| /tmp/pardes-snap/load/cwd Tty Save Mode Filter | ls | d.txt == style loaded grid=100x31 |0: 0-70 #b2c3b8,#1d2824, 71-99 d,#1d2824, -|1: 0-24 #becfc4,#26362d, 25-49 d,#26362d, 50-74 #b2c3b8,#1d2824, 75-99 d,#1d2824, -|2: 0-1 #000000,#adcc91, 2-49 #becfc4,#26362d, 50-51 #ffffff,#4c6356, 52-99 #b2c3b8,#1d2824, -|3: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-49 #e5eee5,#0d1410, 50-50 d,#637f6a, 51-51 d,#0d1410, 52-99 #e5eee5,#0d1410, -|4: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-49 #e5eee5,#0d1410, 50-50 d,#637f6a, 51-51 d,#0d1410, 52-99 #e5eee5,#0d1410, -|5: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-49 #e5eee5,#0d1410, 50-50 d,#637f6a, 51-51 d,#0d1410, 52-99 #e5eee5,#0d1410, -|6: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-49 #e5eee5,#0d1410, 50-50 d,#637f6a, 51-51 d,#0d1410, 52-99 #e5eee5,#0d1410, -|7: 0-0 d,#152019, 1-1 d,#0d1410, 2-49 #e5eee5,#0d1410, 50-50 d,#637f6a, 51-51 d,#0d1410, 52-99 #e5eee5,#0d1410, -|8: 0-0 d,#152019, 1-1 d,#0d1410, 2-49 #e5eee5,#0d1410, 50-50 d,#637f6a, 51-51 d,#0d1410, 52-99 #e5eee5,#0d1410, -|9: 0-0 d,#152019, 1-1 d,#0d1410, 2-49 #e5eee5,#0d1410, 50-50 d,#637f6a, 51-51 d,#0d1410, 52-99 #e5eee5,#0d1410, -|10: 0-0 d,#152019, 1-1 d,#0d1410, 2-49 #e5eee5,#0d1410, 50-50 d,#637f6a, 51-51 d,#0d1410, 52-99 #e5eee5,#0d1410, -|11: 0-0 d,#152019, 1-1 d,#0d1410, 2-49 #e5eee5,#0d1410, 50-50 d,#637f6a, 51-51 d,#0d1410, 52-99 #e5eee5,#0d1410, -|12: 0-0 d,#152019, 1-1 d,#0d1410, 2-49 #e5eee5,#0d1410, 50-50 d,#637f6a, 51-51 d,#0d1410, 52-99 #e5eee5,#0d1410, -|13: 0-0 d,#152019, 1-1 d,#0d1410, 2-49 #e5eee5,#0d1410, 50-50 d,#637f6a, 51-51 d,#0d1410, 52-99 #e5eee5,#0d1410, -|14: 0-0 d,#152019, 1-1 d,#0d1410, 2-49 #e5eee5,#0d1410, 50-50 d,#637f6a, 51-51 d,#0d1410, 52-99 #e5eee5,#0d1410, -|15: 0-0 d,#152019, 1-1 d,#0d1410, 2-49 #e5eee5,#0d1410, 50-50 d,#637f6a, 51-51 d,#0d1410, 52-99 #e5eee5,#0d1410, -|16: 0-0 d,#152019, 1-1 d,#0d1410, 2-49 #e5eee5,#0d1410, 50-50 d,#637f6a, 51-51 d,#0d1410, 52-99 #e5eee5,#0d1410, -|17: 0-1 #ffffff,#4c6356, 2-49 #b2c3b8,#1d2824, 50-50 d,#637f6a, 51-51 d,#0d1410, 52-99 #e5eee5,#0d1410, -|18: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-49 #e5eee5,#0d1410, 50-50 d,#637f6a, 51-51 d,#0d1410, 52-99 #e5eee5,#0d1410, -|19: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-49 #e5eee5,#0d1410, 50-50 d,#637f6a, 51-51 d,#0d1410, 52-99 #e5eee5,#0d1410, -|20: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-49 #e5eee5,#0d1410, 50-50 d,#637f6a, 51-51 d,#0d1410, 52-99 #e5eee5,#0d1410, -|21: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-49 #e5eee5,#0d1410, 50-50 d,#637f6a, 51-51 d,#0d1410, 52-99 #e5eee5,#0d1410, -|22: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-49 #e5eee5,#0d1410, 50-50 d,#637f6a, 51-51 d,#0d1410, 52-99 #e5eee5,#0d1410, -|23: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-49 #e5eee5,#0d1410, 50-50 d,#637f6a, 51-51 d,#0d1410, 52-99 #e5eee5,#0d1410, -|24: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-49 #e5eee5,#0d1410, 50-50 d,#637f6a, 51-51 d,#0d1410, 52-99 #e5eee5,#0d1410, -|25: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-49 #e5eee5,#0d1410, 50-50 d,#637f6a, 51-51 d,#0d1410, 52-99 #e5eee5,#0d1410, -|26: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-49 #e5eee5,#0d1410, 50-50 d,#637f6a, 51-51 d,#0d1410, 52-99 #e5eee5,#0d1410, -|27: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-49 #e5eee5,#0d1410, 50-50 d,#637f6a, 51-51 d,#0d1410, 52-99 #e5eee5,#0d1410, -|28: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-49 #e5eee5,#0d1410, 50-50 d,#637f6a, 51-51 d,#0d1410, 52-99 #e5eee5,#0d1410, -|29: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-49 #e5eee5,#0d1410, 50-50 d,#637f6a, 51-51 d,#0d1410, 52-99 #e5eee5,#0d1410, -|30: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-49 #e5eee5,#0d1410, 50-50 d,#637f6a, 51-51 d,#0d1410, 52-99 #e5eee5,#0d1410, +|1: 0-1 #ffffff,#887455, 2-2 d,#26362d, 3-34 #becfc4,#26362d, 35-49 d,#26362d, 50-51 #ffffff,#887455, 52-52 d,#1d2824, 53-84 #b2c3b8,#1d2824, 85-99 d,#1d2824, +|2: 0-1 #000000,#add38a, 2-2 d,#26362d, 3-28 #becfc4,#26362d, 29-31 #dfbce5,#26362d, 32-49 #becfc4,#26362d, 50-51 #ffffff,#496656, 52-52 d,#1d2824, 53-78 #b2c3b8,#1d2824, 79-81 #d3b0d9,#1d2824, 82-99 #b2c3b8,#1d2824, +|3: 0-0 d,#608269, 1-1 d,#0d1410, 2-49 #e5eee5,#0d1410, 50-50 d,#608269, 51-51 d,#0d1410, 52-99 #e5eee5,#0d1410, +|4: 0-0 d,#608269, 1-1 d,#0d1410, 2-49 #e5eee5,#0d1410, 50-50 d,#608269, 51-51 d,#0d1410, 52-99 #e5eee5,#0d1410, +|5: 0-0 d,#608269, 1-1 d,#0d1410, 2-49 #e5eee5,#0d1410, 50-50 d,#608269, 51-51 d,#0d1410, 52-99 #e5eee5,#0d1410, +|6: 0-0 d,#608269, 1-1 d,#0d1410, 2-49 #e5eee5,#0d1410, 50-50 d,#608269, 51-51 d,#0d1410, 52-99 #e5eee5,#0d1410, +|7: 0-0 d,#152019, 1-1 d,#0d1410, 2-49 #e5eee5,#0d1410, 50-50 d,#608269, 51-51 d,#0d1410, 52-99 #e5eee5,#0d1410, +|8: 0-0 d,#152019, 1-1 d,#0d1410, 2-49 #e5eee5,#0d1410, 50-50 d,#608269, 51-51 d,#0d1410, 52-99 #e5eee5,#0d1410, +|9: 0-0 d,#152019, 1-1 d,#0d1410, 2-49 #e5eee5,#0d1410, 50-50 d,#608269, 51-51 d,#0d1410, 52-99 #e5eee5,#0d1410, +|10: 0-0 d,#152019, 1-1 d,#0d1410, 2-49 #e5eee5,#0d1410, 50-50 d,#608269, 51-51 d,#0d1410, 52-99 #e5eee5,#0d1410, +|11: 0-0 d,#152019, 1-1 d,#0d1410, 2-49 #e5eee5,#0d1410, 50-50 d,#608269, 51-51 d,#0d1410, 52-99 #e5eee5,#0d1410, +|12: 0-0 d,#152019, 1-1 d,#0d1410, 2-49 #e5eee5,#0d1410, 50-50 d,#608269, 51-51 d,#0d1410, 52-99 #e5eee5,#0d1410, +|13: 0-0 d,#152019, 1-1 d,#0d1410, 2-49 #e5eee5,#0d1410, 50-50 d,#608269, 51-51 d,#0d1410, 52-99 #e5eee5,#0d1410, +|14: 0-0 d,#152019, 1-1 d,#0d1410, 2-49 #e5eee5,#0d1410, 50-50 d,#608269, 51-51 d,#0d1410, 52-99 #e5eee5,#0d1410, +|15: 0-0 d,#152019, 1-1 d,#0d1410, 2-49 #e5eee5,#0d1410, 50-50 d,#608269, 51-51 d,#0d1410, 52-99 #e5eee5,#0d1410, +|16: 0-0 d,#152019, 1-1 d,#0d1410, 2-49 #e5eee5,#0d1410, 50-50 d,#608269, 51-51 d,#0d1410, 52-99 #e5eee5,#0d1410, +|17: 0-1 #ffffff,#496656, 2-2 d,#1d2824, 3-28 #b2c3b8,#1d2824, 29-31 #d3b0d9,#1d2824, 32-49 #b2c3b8,#1d2824, 50-50 d,#608269, 51-51 d,#0d1410, 52-99 #e5eee5,#0d1410, +|18: 0-0 d,#608269, 1-1 d,#0d1410, 2-49 #e5eee5,#0d1410, 50-50 d,#608269, 51-51 d,#0d1410, 52-99 #e5eee5,#0d1410, +|19: 0-0 d,#608269, 1-1 d,#0d1410, 2-49 #e5eee5,#0d1410, 50-50 d,#608269, 51-51 d,#0d1410, 52-99 #e5eee5,#0d1410, +|20: 0-0 d,#608269, 1-1 d,#0d1410, 2-49 #e5eee5,#0d1410, 50-50 d,#608269, 51-51 d,#0d1410, 52-99 #e5eee5,#0d1410, +|21: 0-0 d,#608269, 1-1 d,#0d1410, 2-49 #e5eee5,#0d1410, 50-50 d,#608269, 51-51 d,#0d1410, 52-99 #e5eee5,#0d1410, +|22: 0-0 d,#608269, 1-1 d,#0d1410, 2-49 #e5eee5,#0d1410, 50-50 d,#608269, 51-51 d,#0d1410, 52-99 #e5eee5,#0d1410, +|23: 0-0 d,#608269, 1-1 d,#0d1410, 2-49 #e5eee5,#0d1410, 50-50 d,#608269, 51-51 d,#0d1410, 52-99 #e5eee5,#0d1410, +|24: 0-0 d,#608269, 1-1 d,#0d1410, 2-49 #e5eee5,#0d1410, 50-50 d,#608269, 51-51 d,#0d1410, 52-99 #e5eee5,#0d1410, +|25: 0-0 d,#608269, 1-1 d,#0d1410, 2-49 #e5eee5,#0d1410, 50-50 d,#608269, 51-51 d,#0d1410, 52-99 #e5eee5,#0d1410, +|26: 0-0 d,#608269, 1-1 d,#0d1410, 2-49 #e5eee5,#0d1410, 50-50 d,#608269, 51-51 d,#0d1410, 52-99 #e5eee5,#0d1410, +|27: 0-0 d,#608269, 1-1 d,#0d1410, 2-49 #e5eee5,#0d1410, 50-50 d,#608269, 51-51 d,#0d1410, 52-99 #e5eee5,#0d1410, +|28: 0-0 d,#608269, 1-1 d,#0d1410, 2-49 #e5eee5,#0d1410, 50-50 d,#608269, 51-51 d,#0d1410, 52-99 #e5eee5,#0d1410, +|29: 0-0 d,#608269, 1-1 d,#0d1410, 2-49 #e5eee5,#0d1410, 50-50 d,#608269, 51-51 d,#0d1410, 52-99 #e5eee5,#0d1410, +|30: 0-0 d,#608269, 1-1 d,#0d1410, 2-49 #e5eee5,#0d1410, 50-50 d,#608269, 51-51 d,#0d1410, 52-99 #e5eee5,#0d1410, diff --git a/test/snapshots/logquiet.golden b/test/snapshots/logquiet.golden index d5c4703b..1289761b 100644 --- a/test/snapshots/logquiet.golden +++ b/test/snapshots/logquiet.golden @@ -1,7 +1,7 @@ == snap quiet grid=100x31 cursor=62,5 |Newcol Joincol Find Grep Help Changelog Tutor Dump NextColor Debug Kill -|New Tty Find Grep Joincol -|$ /tmp/pardes-snap/logquiet/cwd Save Tty Del Togglettymode Filter Collapse +| New Tty Find Grep Joincol Delcol +|$ /tmp/pardes-snap/logquiet/cwd Tty Save Mode Filter Collapse Del | $ ls | $ printf '\033_Ga=q,i=1,s=1,v=1,f=24,t=d;AAAA\033\\\033[>0p' | $ '\033_Ga=q,i=1,s=1,v=1,f=24,t=d;AAAA\033\\\033[>0p'Gi=1;OK diff --git a/test/snapshots/look-center.golden b/test/snapshots/look-center.golden index 7509da8f..e13a7886 100644 --- a/test/snapshots/look-center.golden +++ b/test/snapshots/look-center.golden @@ -1,11 +1,11 @@ == snap center-open grid=150x31 cursor=7,12 |Newcol Joincol Find Grep Help Changelog Tutor Dump NextColor Debug Kill -|New Tty Find Grep Joincol New Tty Find Grep Joincol -| /tmp/pardes-snap/look-center/cwd Save Tty Del Togglettymode Filter Collap /tmp/pardes-snap/look-center/cwd Save Tty Del Togglettymode Filter Collap -| ls ls -| big.txt big.txt -| -| /tmp/pardes-snap/look-center/cwd/big.txt Save Tty Del Collapse +| New Tty Find Grep Joincol Delcol New Tty Find Grep Joincol Delcol +| /tmp/pardes-snap/look-center/cwd Tty Save Mode Filter Collapse Del /tmp/pardes-snap/look-center/cwd Tty Save Mode Filter Collapse Del +| Look ls +| ls big.txt +| big.txt +| /tmp/pardes-snap/look-center/cwd/big.txt Save Tty Collapse Del | 95 line 95 | 96 line 96 | 97 line 97 @@ -16,13 +16,16 @@ | 102 line 102 | 103 line 103 | 104 line 104 -| /tmp/pardes-snap/look-center/cwd Save Tty Del Togglettymode Filter Collap +| /tmp/pardes-snap/look-center/cwd Tty Save Mode Filter Collapse Del | ls | big.txt == snap center-dedup grid=150x31 cursor=7,12 +|3: ls Look +|4: big.txt ls +|5: big.txt |7: 145 line 145 -|8: 146 line 146 big.txt:150 big.txt:2 -|9: 147 line 147 +|8: 146 line 146 +|9: 147 line 147 big.txt:150 big.txt:2 |10: 148 line 148 |11: 149 line 149 |12: 150 line 150 @@ -30,14 +33,9 @@ |14: 152 line 152 |15: 153 line 153 |16: 154 line 154 -== snap center-clamp grid=150x31 cursor=7,8 -|7: 1 line 1 -|8: 2 line 2 big.txt:150 big.txt:2 -|9: 3 line 3 -|10: 4 line 4 -|11: 5 line 5 -|12: 6 line 6 -|13: 7 line 7 -|14: 8 line 8 -|15: 9 line 9 -|16: 10 line 10 +== snap center-clamp grid=150x31 cursor=93,7 +|3: ls ls +|4: big.txt big.txt +|5: +|8: 146 line 146 big.txt:150 big.txt:2 +|9: 147 line 147 diff --git a/test/snapshots/look-dir.golden b/test/snapshots/look-dir.golden index e859a3f4..8f90d604 100644 --- a/test/snapshots/look-dir.golden +++ b/test/snapshots/look-dir.golden @@ -1,11 +1,11 @@ == snap dir-open grid=100x31 cursor=4,9 |Newcol Joincol Find Grep Help Changelog Tutor Dump NextColor Debug Kill -|New Tty Find Grep Joincol New Tty Find Grep Joincol -| /tmp/pardes-snap/look-dir/cwd Save Tty Del Toggl /tmp/pardes-snap/look-dir/cwd Save Tty Del Toggl -| ls ls -| sub top.txt sub top.txt -| -| /tmp/pardes-snap/look-dir/cwd/sub Save Tty Del T +| New Tty Find Grep Joincol Delcol New Tty Find Grep Joincol Delcol +| /tmp/pardes-snap/look-dir/cwd Tty Save Mode Fil /tmp/pardes-snap/look-dir/cwd Tty Save Mode Fil +| Look ls +| ls sub top.txt +| sub top.txt +| /tmp/pardes-snap/look-dir/cwd/sub Tty Save Mode | ls | inner.txt | @@ -16,6 +16,6 @@ | | | -| /tmp/pardes-snap/look-dir/cwd Save Tty Del Toggl +| /tmp/pardes-snap/look-dir/cwd Tty Save Mode Fil | ls | sub top.txt diff --git a/test/snapshots/look-file-1col.golden b/test/snapshots/look-file-1col.golden index 553e1942..abe1fcbb 100644 --- a/test/snapshots/look-file-1col.golden +++ b/test/snapshots/look-file-1col.golden @@ -1,11 +1,11 @@ == snap file-open-1col grid=100x31 cursor=7,19 |Newcol Joincol Find Grep Help Changelog Tutor Dump NextColor Debug Kill -|New Tty Find Grep Joincol -| /tmp/pardes-snap/look-file-1col/cwd Save Tty Del Togglettymode Filter Collapse +| New Tty Find Grep Joincol Delcol +| /tmp/pardes-snap/look-file-1col/cwd Tty Save Mode Filter Collapse Del +| Look | ls | big.txt -| -| /tmp/pardes-snap/look-file-1col/cwd/big.txt Save Tty Del Collapse +| /tmp/pardes-snap/look-file-1col/cwd/big.txt Save Tty Collapse Del | 28 line 28 | 29 line 29 | 30 line 30 diff --git a/test/snapshots/look-file.golden b/test/snapshots/look-file.golden index dccbb07c..13919c3d 100644 --- a/test/snapshots/look-file.golden +++ b/test/snapshots/look-file.golden @@ -1,11 +1,11 @@ == snap file-open grid=150x31 cursor=7,12 |Newcol Joincol Find Grep Help Changelog Tutor Dump NextColor Debug Kill -|New Tty Find Grep Joincol New Tty Find Grep Joincol -| /tmp/pardes-snap/look-file/cwd Save Tty Del Togglettymode Filter Collapse /tmp/pardes-snap/look-file/cwd Save Tty Del Togglettymode Filter Collapse -| ls ls -| big.txt big.txt -| -| /tmp/pardes-snap/look-file/cwd/big.txt Save Tty Del Collapse +| New Tty Find Grep Joincol Delcol New Tty Find Grep Joincol Delcol +| /tmp/pardes-snap/look-file/cwd Tty Save Mode Filter Collapse Del /tmp/pardes-snap/look-file/cwd Tty Save Mode Filter Collapse Del +| Look ls +| ls big.txt +| big.txt +| /tmp/pardes-snap/look-file/cwd/big.txt Save Tty Collapse Del | 35 line 35 | 36 line 36 | 37 line 37 @@ -16,38 +16,38 @@ | 42 line 42 | 43 line 43 | 44 line 44 -| /tmp/pardes-snap/look-file/cwd Save Tty Del Togglettymode Filter Collapse +| /tmp/pardes-snap/look-file/cwd Tty Save Mode Filter Collapse Del | ls | big.txt == style file-open grid=150x31 |0: 0-70 #b2c3b8,#1d2824, 71-149 d,#1d2824, -|1: 0-24 #becfc4,#26362d, 25-74 d,#26362d, 75-99 #b2c3b8,#1d2824, 100-149 d,#1d2824, -|2: 0-1 #ffffff,#4c6356, 2-74 #b2c3b8,#1d2824, 75-76 #ffffff,#4c6356, 77-149 #b2c3b8,#1d2824, -|3: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-74 #e5eee5,#0d1410, 75-75 d,#637f6a, 76-76 d,#0d1410, 77-149 #e5eee5,#0d1410, -|4: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-74 #e5eee5,#0d1410, 75-75 d,#637f6a, 76-76 d,#0d1410, 77-149 #e5eee5,#0d1410, -|5: 0-0 d,#637f6a, 1-74 d,#0d1410, 75-75 d,#637f6a, 76-149 d,#0d1410, -|6: 0-1 #000000,#adcc91, 2-61 #becfc4,#26362d, 62-74 d,#26362d, 75-75 d,#637f6a, 76-76 d,#0d1410, 77-149 #e5eee5,#0d1410, -|7: 0-0 d,#152019, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-13 #e5eee5,#0d1410, 14-74 d,#0d1410, 75-75 d,#637f6a, 76-76 d,#0d1410, 77-149 #e5eee5,#0d1410, -|8: 0-0 d,#152019, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-13 #e5eee5,#0d1410, 14-74 d,#0d1410, 75-75 d,#637f6a, 76-76 d,#0d1410, 77-149 #e5eee5,#0d1410, -|9: 0-0 d,#152019, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-13 #e5eee5,#0d1410, 14-74 d,#0d1410, 75-75 d,#637f6a, 76-76 d,#0d1410, 77-149 #e5eee5,#0d1410, -|10: 0-0 d,#152019, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-13 #e5eee5,#0d1410, 14-74 d,#0d1410, 75-75 d,#637f6a, 76-76 d,#0d1410, 77-149 #e5eee5,#0d1410, -|11: 0-0 d,#152019, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-13 #e5eee5,#0d1410, 14-74 d,#0d1410, 75-75 d,#637f6a, 76-76 d,#0d1410, 77-149 #e5eee5,#0d1410, -|12: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-6 #616f64,#0d1410,b 7-13 #e5eee5,#0d1410, 14-74 d,#0d1410, 75-75 d,#637f6a, 76-76 d,#0d1410, 77-149 #e5eee5,#0d1410, -|13: 0-0 d,#152019, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-13 #e5eee5,#0d1410, 14-74 d,#0d1410, 75-75 d,#637f6a, 76-76 d,#0d1410, 77-149 #e5eee5,#0d1410, -|14: 0-0 d,#152019, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-13 #e5eee5,#0d1410, 14-74 d,#0d1410, 75-75 d,#637f6a, 76-76 d,#0d1410, 77-149 #e5eee5,#0d1410, -|15: 0-0 d,#152019, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-13 #e5eee5,#0d1410, 14-74 d,#0d1410, 75-75 d,#637f6a, 76-76 d,#0d1410, 77-149 #e5eee5,#0d1410, -|16: 0-0 d,#152019, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-13 #e5eee5,#0d1410, 14-74 d,#0d1410, 75-75 d,#637f6a, 76-76 d,#0d1410, 77-149 #e5eee5,#0d1410, -|17: 0-1 #ffffff,#4c6356, 2-74 #b2c3b8,#1d2824, 75-75 d,#637f6a, 76-76 d,#0d1410, 77-149 #e5eee5,#0d1410, -|18: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-74 #e5eee5,#0d1410, 75-75 d,#637f6a, 76-76 d,#0d1410, 77-149 #e5eee5,#0d1410, -|19: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-74 #e5eee5,#0d1410, 75-75 d,#637f6a, 76-76 d,#0d1410, 77-149 #e5eee5,#0d1410, -|20: 0-0 d,#637f6a, 1-74 d,#0d1410, 75-75 d,#637f6a, 76-76 d,#0d1410, 77-149 #e5eee5,#0d1410, -|21: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-74 #e5eee5,#0d1410, 75-75 d,#637f6a, 76-76 d,#0d1410, 77-149 #e5eee5,#0d1410, -|22: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-74 #e5eee5,#0d1410, 75-75 d,#637f6a, 76-76 d,#0d1410, 77-149 #e5eee5,#0d1410, -|23: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-74 #e5eee5,#0d1410, 75-75 d,#637f6a, 76-76 d,#0d1410, 77-149 #e5eee5,#0d1410, -|24: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-74 #e5eee5,#0d1410, 75-75 d,#637f6a, 76-76 d,#0d1410, 77-149 #e5eee5,#0d1410, -|25: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-74 #e5eee5,#0d1410, 75-75 d,#637f6a, 76-76 d,#0d1410, 77-149 #e5eee5,#0d1410, -|26: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-74 #e5eee5,#0d1410, 75-75 d,#637f6a, 76-76 d,#0d1410, 77-149 #e5eee5,#0d1410, -|27: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-74 #e5eee5,#0d1410, 75-75 d,#637f6a, 76-76 d,#0d1410, 77-149 #e5eee5,#0d1410, -|28: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-74 #e5eee5,#0d1410, 75-75 d,#637f6a, 76-76 d,#0d1410, 77-149 #e5eee5,#0d1410, -|29: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-74 #e5eee5,#0d1410, 75-75 d,#637f6a, 76-76 d,#0d1410, 77-149 #e5eee5,#0d1410, -|30: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-74 #e5eee5,#0d1410, 75-75 d,#637f6a, 76-76 d,#0d1410, 77-149 #e5eee5,#0d1410, +|1: 0-1 #ffffff,#887455, 2-2 d,#26362d, 3-34 #becfc4,#26362d, 35-74 d,#26362d, 75-76 #ffffff,#887455, 77-77 d,#1d2824, 78-109 #b2c3b8,#1d2824, 110-149 d,#1d2824, +|2: 0-1 #ffffff,#496656, 2-2 d,#1d2824, 3-33 #b2c3b8,#1d2824, 34-36 #d3b0d9,#1d2824, 37-66 #b2c3b8,#1d2824, 67-74 d,#1d2824, 75-76 #ffffff,#496656, 77-77 d,#1d2824, 78-108 #b2c3b8,#1d2824, 109-111 #d3b0d9,#1d2824, 112-141 #b2c3b8,#1d2824, 142-149 d,#1d2824, +|3: 0-0 d,#152019, 1-1 d,#0d1410, 2-70 d,#1d2824, 71-74 #b2c3b8,#1d2824, 75-75 d,#608269, 76-76 d,#0d1410, 77-149 #e5eee5,#0d1410, +|4: 0-0 d,#608269, 1-1 d,#0d1410, 2-74 #e5eee5,#0d1410, 75-75 d,#608269, 76-76 d,#0d1410, 77-149 #e5eee5,#0d1410, +|5: 0-0 d,#608269, 1-1 d,#0d1410, 2-74 #e5eee5,#0d1410, 75-75 d,#608269, 76-149 d,#0d1410, +|6: 0-1 #000000,#add38a, 2-2 d,#26362d, 3-33 #becfc4,#26362d, 34-40 #dfbce5,#26362d, 41-62 #becfc4,#26362d, 63-74 d,#26362d, 75-75 d,#608269, 76-76 d,#0d1410, 77-149 #e5eee5,#0d1410, +|7: 0-0 d,#152019, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-13 #e5eee5,#0d1410, 14-74 d,#0d1410, 75-75 d,#608269, 76-76 d,#0d1410, 77-149 #e5eee5,#0d1410, +|8: 0-0 d,#152019, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-13 #e5eee5,#0d1410, 14-74 d,#0d1410, 75-75 d,#608269, 76-76 d,#0d1410, 77-149 #e5eee5,#0d1410, +|9: 0-0 d,#152019, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-13 #e5eee5,#0d1410, 14-74 d,#0d1410, 75-75 d,#608269, 76-76 d,#0d1410, 77-149 #e5eee5,#0d1410, +|10: 0-0 d,#152019, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-13 #e5eee5,#0d1410, 14-74 d,#0d1410, 75-75 d,#608269, 76-76 d,#0d1410, 77-149 #e5eee5,#0d1410, +|11: 0-0 d,#152019, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-13 #e5eee5,#0d1410, 14-74 d,#0d1410, 75-75 d,#608269, 76-76 d,#0d1410, 77-149 #e5eee5,#0d1410, +|12: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #616f64,#0d1410,b 7-13 #e5eee5,#0d1410, 14-74 d,#0d1410, 75-75 d,#608269, 76-76 d,#0d1410, 77-149 #e5eee5,#0d1410, +|13: 0-0 d,#152019, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-13 #e5eee5,#0d1410, 14-74 d,#0d1410, 75-75 d,#608269, 76-76 d,#0d1410, 77-149 #e5eee5,#0d1410, +|14: 0-0 d,#152019, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-13 #e5eee5,#0d1410, 14-74 d,#0d1410, 75-75 d,#608269, 76-76 d,#0d1410, 77-149 #e5eee5,#0d1410, +|15: 0-0 d,#152019, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-13 #e5eee5,#0d1410, 14-74 d,#0d1410, 75-75 d,#608269, 76-76 d,#0d1410, 77-149 #e5eee5,#0d1410, +|16: 0-0 d,#152019, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-13 #e5eee5,#0d1410, 14-74 d,#0d1410, 75-75 d,#608269, 76-76 d,#0d1410, 77-149 #e5eee5,#0d1410, +|17: 0-1 #ffffff,#496656, 2-2 d,#1d2824, 3-33 #b2c3b8,#1d2824, 34-36 #d3b0d9,#1d2824, 37-66 #b2c3b8,#1d2824, 67-74 d,#1d2824, 75-75 d,#608269, 76-76 d,#0d1410, 77-149 #e5eee5,#0d1410, +|18: 0-0 d,#608269, 1-1 d,#0d1410, 2-74 #e5eee5,#0d1410, 75-75 d,#608269, 76-76 d,#0d1410, 77-149 #e5eee5,#0d1410, +|19: 0-0 d,#608269, 1-1 d,#0d1410, 2-74 #e5eee5,#0d1410, 75-75 d,#608269, 76-76 d,#0d1410, 77-149 #e5eee5,#0d1410, +|20: 0-0 d,#608269, 1-74 d,#0d1410, 75-75 d,#608269, 76-76 d,#0d1410, 77-149 #e5eee5,#0d1410, +|21: 0-0 d,#608269, 1-1 d,#0d1410, 2-74 #e5eee5,#0d1410, 75-75 d,#608269, 76-76 d,#0d1410, 77-149 #e5eee5,#0d1410, +|22: 0-0 d,#608269, 1-1 d,#0d1410, 2-74 #e5eee5,#0d1410, 75-75 d,#608269, 76-76 d,#0d1410, 77-149 #e5eee5,#0d1410, +|23: 0-0 d,#608269, 1-1 d,#0d1410, 2-74 #e5eee5,#0d1410, 75-75 d,#608269, 76-76 d,#0d1410, 77-149 #e5eee5,#0d1410, +|24: 0-0 d,#608269, 1-1 d,#0d1410, 2-74 #e5eee5,#0d1410, 75-75 d,#608269, 76-76 d,#0d1410, 77-149 #e5eee5,#0d1410, +|25: 0-0 d,#608269, 1-1 d,#0d1410, 2-74 #e5eee5,#0d1410, 75-75 d,#608269, 76-76 d,#0d1410, 77-149 #e5eee5,#0d1410, +|26: 0-0 d,#608269, 1-1 d,#0d1410, 2-74 #e5eee5,#0d1410, 75-75 d,#608269, 76-76 d,#0d1410, 77-149 #e5eee5,#0d1410, +|27: 0-0 d,#608269, 1-1 d,#0d1410, 2-74 #e5eee5,#0d1410, 75-75 d,#608269, 76-76 d,#0d1410, 77-149 #e5eee5,#0d1410, +|28: 0-0 d,#608269, 1-1 d,#0d1410, 2-74 #e5eee5,#0d1410, 75-75 d,#608269, 76-76 d,#0d1410, 77-149 #e5eee5,#0d1410, +|29: 0-0 d,#608269, 1-1 d,#0d1410, 2-74 #e5eee5,#0d1410, 75-75 d,#608269, 76-76 d,#0d1410, 77-149 #e5eee5,#0d1410, +|30: 0-0 d,#608269, 1-1 d,#0d1410, 2-74 #e5eee5,#0d1410, 75-75 d,#608269, 76-76 d,#0d1410, 77-149 #e5eee5,#0d1410, diff --git a/test/snapshots/lookloaded.golden b/test/snapshots/lookloaded.golden index 1ff8c44f..a55151f4 100644 --- a/test/snapshots/lookloaded.golden +++ b/test/snapshots/lookloaded.golden @@ -1,11 +1,11 @@ == snap file-open grid=100x31 cursor=7,12 |Newcol Joincol Find Grep Help Changelog Tutor Dump NextColor Debug Kill -|New Tty Find Grep Joincol New Tty Find Grep Joincol -| /tmp/pardes-snap/lookloaded/cwd Save Tty Del Tog /tmp/pardes-snap/lookloaded/cwd Save Tty Del Tog -| ls ls -| big.txt big.txt -| -| /tmp/pardes-snap/lookloaded/cwd/big.txt Save Tty +| New Tty Find Grep Joincol Delcol New Tty Find Grep Joincol Delcol +| /tmp/pardes-snap/lookloaded/cwd Tty Save Mode F /tmp/pardes-snap/lookloaded/cwd Tty Save Mode F +| Look ls +| ls big.txt +| big.txt +| /tmp/pardes-snap/lookloaded/cwd/big.txt Save Tt | 35 line 35 | 36 line 36 | 37 line 37 @@ -16,16 +16,22 @@ | 42 line 42 | 43 line 43 | 44 line 44 -| /tmp/pardes-snap/lookloaded/cwd Save Tty Del Tog +| /tmp/pardes-snap/lookloaded/cwd Tty Save Mode F | ls | big.txt == snap removed grid=100x31 cursor=54,7 +|3: ls ls +|4: big.txt big.txt |5: rm big.txt; echo GO''NE -|6: /tmp/pardes-snap/lookloaded/cwd/big.txt Save Tty GONE +|6: /tmp/pardes-snap/lookloaded/cwd/big.txt Save Tt GONE == snap look-noFS grid=100x31 cursor=7,12 -|7: 5 line 5 -|8: 6 line 6 big.txt:10 -|9: 7 line 7 +|3: ls Look +|4: big.txt ls +|5: big.txt +|6: /tmp/pardes-snap/lookloaded/cwd/big.txt Save Tt rm big.txt; echo GO''NE +|7: 5 line 5 GONE +|8: 6 line 6 +|9: 7 line 7 big.txt:10 |10: 8 line 8 |11: 9 line 9 |12: 10 line 10 diff --git a/test/snapshots/lookpanes.golden b/test/snapshots/lookpanes.golden index 73aab814..c2ef30cb 100644 --- a/test/snapshots/lookpanes.golden +++ b/test/snapshots/lookpanes.golden @@ -1,74 +1,74 @@ == snap shells grid=130x51 cursor=122,4 |Newcol Joincol Find Grep Help Changelog Tutor Dump NextColor Debug Kill -|New Tty Find Grep Joincol New Tty Find Grep Joincol -| /tmp/pardes-snap/lookpanes/cwd/beta/bmark.txt Save Tty Del Coll /tmp/pardes-snap/lookpanes/cwd Save Tty Del Togglettymode Filte +| New Tty Find Grep Joincol Delcol New Tty Find Grep Joincol Delcol +| /tmp/pardes-snap/lookpanes/cwd/beta/bmark.txt Save Tty Collaps /tmp/pardes-snap/lookpanes/cwd Tty Save Mode Filter Collapse D | 1 both.txt ls | 2 b-marker alpha beta zzboot.txt zqonly.txt pick.txt twin.txt | -| /tmp/pardes-snap/lookpanes/cwd/alpha Save Tty Del Togglettymode +| /tmp/pardes-snap/lookpanes/cwd/alpha Tty Save Mode Filter Coll | ls | amark.txt both.txt pick.txt twin.txt zqonly.txt == snap other-dir grid=130x51 cursor=7,28 -|27: /tmp/pardes-snap/lookpanes/cwd/alpha/zqonly.txt Save Tty Del Co +|27: /tmp/pardes-snap/lookpanes/cwd/alpha/zqonly.txt Save Tty Colla |28: 1 ONLY-IN-ALPHA == snap clicked-wins grid=130x51 cursor=7,16 -|15: /tmp/pardes-snap/lookpanes/cwd/beta/both.txt Save Tty Del Colla +|15: /tmp/pardes-snap/lookpanes/cwd/beta/both.txt Save Tty Collapse |16: 1 BOTH-FROM-BETA == snap mru-alpha grid=130x51 cursor=7,22 -|21: /tmp/pardes-snap/lookpanes/cwd/alpha/pick.txt Save Tty Del Coll +|21: /tmp/pardes-snap/lookpanes/cwd/alpha/pick.txt Save Tty Collaps |22: 1 PICK-FROM-ALPHA == snap mru-beta grid=130x51 cursor=7,10 -|9: /tmp/pardes-snap/lookpanes/cwd/beta/twin.txt Save Tty Del Colla +|9: /tmp/pardes-snap/lookpanes/cwd/beta/twin.txt Save Tty Collapse |10: 1 TWIN-FROM-BETA == style mru-beta grid=130x51 |0: 0-70 #b2c3b8,#1d2824, 71-129 d,#1d2824, -|1: 0-24 #becfc4,#26362d, 25-64 d,#26362d, 65-89 #b2c3b8,#1d2824, 90-129 d,#1d2824, -|2: 0-1 #ffffff,#4c6356, 2-64 #b2c3b8,#1d2824, 65-66 #ffffff,#4c6356, 67-129 #b2c3b8,#1d2824, -|3: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-14 #e5eee5,#0d1410, 15-64 d,#0d1410, 65-65 d,#637f6a, 66-66 d,#0d1410, 67-129 #e5eee5,#0d1410, -|4: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-14 #e5eee5,#0d1410, 15-64 d,#0d1410, 65-65 d,#637f6a, 66-66 d,#0d1410, 67-121 #e5eee5,#0d1410, 122-129 d,#0d1410, -|5: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-64 d,#0d1410, 65-65 d,#637f6a, 66-129 d,#0d1410, -|6: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-64 d,#0d1410, 65-66 #ffffff,#4c6356, 67-129 #b2c3b8,#1d2824, -|7: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-64 d,#0d1410, 65-65 d,#637f6a, 66-66 d,#0d1410, 67-129 #e5eee5,#0d1410, -|8: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-64 d,#0d1410, 65-65 d,#637f6a, 66-66 d,#0d1410, 67-129 #e5eee5,#0d1410, -|9: 0-1 #000000,#adcc91, 2-64 #becfc4,#26362d, 65-65 d,#637f6a, 66-129 d,#0d1410, -|10: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-6 #616f64,#0d1410,b 7-20 #e5eee5,#0d1410, 21-64 d,#0d1410, 65-65 d,#637f6a, 66-66 d,#0d1410, 67-129 #e5eee5,#0d1410, -|11: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-64 d,#0d1410, 65-65 d,#637f6a, 66-66 d,#0d1410, 67-129 #e5eee5,#0d1410, -|12: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-64 d,#0d1410, 65-65 d,#637f6a, 66-66 d,#0d1410, 67-129 #e5eee5,#0d1410, -|13: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-64 d,#0d1410, 65-65 d,#637f6a, 66-66 d,#0d1410, 67-129 #e5eee5,#0d1410, -|14: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-64 d,#0d1410, 65-65 d,#637f6a, 66-66 d,#0d1410, 67-129 #e5eee5,#0d1410, -|15: 0-1 #ffffff,#4c6356, 2-64 #b2c3b8,#1d2824, 65-65 d,#637f6a, 66-66 d,#0d1410, 67-129 #e5eee5,#0d1410, -|16: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-20 #e5eee5,#0d1410, 21-64 d,#0d1410, 65-65 d,#637f6a, 66-66 d,#0d1410, 67-129 #e5eee5,#0d1410, -|17: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-64 d,#0d1410, 65-65 d,#637f6a, 66-66 d,#0d1410, 67-129 #e5eee5,#0d1410, -|18: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-64 d,#0d1410, 65-65 d,#637f6a, 66-66 d,#0d1410, 67-129 #e5eee5,#0d1410, -|19: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-64 d,#0d1410, 65-65 d,#637f6a, 66-66 d,#0d1410, 67-129 #e5eee5,#0d1410, -|20: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-64 d,#0d1410, 65-65 d,#637f6a, 66-66 d,#0d1410, 67-129 #e5eee5,#0d1410, -|21: 0-1 #ffffff,#4c6356, 2-64 #b2c3b8,#1d2824, 65-65 d,#637f6a, 66-66 d,#0d1410, 67-129 #e5eee5,#0d1410, -|22: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-21 #e5eee5,#0d1410, 22-64 d,#0d1410, 65-65 d,#637f6a, 66-66 d,#0d1410, 67-129 #e5eee5,#0d1410, -|23: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-64 d,#0d1410, 65-65 d,#637f6a, 66-66 d,#0d1410, 67-129 #e5eee5,#0d1410, -|24: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-64 d,#0d1410, 65-65 d,#637f6a, 66-66 d,#0d1410, 67-129 #e5eee5,#0d1410, -|25: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-64 d,#0d1410, 65-65 d,#637f6a, 66-66 d,#0d1410, 67-129 #e5eee5,#0d1410, -|26: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-64 d,#0d1410, 65-65 d,#637f6a, 66-66 d,#0d1410, 67-129 #e5eee5,#0d1410, -|27: 0-1 #ffffff,#4c6356, 2-64 #b2c3b8,#1d2824, 65-65 d,#637f6a, 66-66 d,#0d1410, 67-129 #e5eee5,#0d1410, -|28: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-19 #e5eee5,#0d1410, 20-64 d,#0d1410, 65-65 d,#637f6a, 66-66 d,#0d1410, 67-129 #e5eee5,#0d1410, -|29: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-64 d,#0d1410, 65-65 d,#637f6a, 66-66 d,#0d1410, 67-129 #e5eee5,#0d1410, -|30: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-64 d,#0d1410, 65-65 d,#637f6a, 66-66 d,#0d1410, 67-129 #e5eee5,#0d1410, -|31: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-64 d,#0d1410, 65-65 d,#637f6a, 66-66 d,#0d1410, 67-129 #e5eee5,#0d1410, -|32: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-64 d,#0d1410, 65-65 d,#637f6a, 66-66 d,#0d1410, 67-129 #e5eee5,#0d1410, -|33: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-64 d,#0d1410, 65-65 d,#637f6a, 66-66 d,#0d1410, 67-129 #e5eee5,#0d1410, -|34: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-64 d,#0d1410, 65-65 d,#637f6a, 66-66 d,#0d1410, 67-129 #e5eee5,#0d1410, -|35: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-64 d,#0d1410, 65-65 d,#637f6a, 66-66 d,#0d1410, 67-129 #e5eee5,#0d1410, -|36: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-64 d,#0d1410, 65-65 d,#637f6a, 66-66 d,#0d1410, 67-129 #e5eee5,#0d1410, -|37: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-64 d,#0d1410, 65-65 d,#637f6a, 66-66 d,#0d1410, 67-129 #e5eee5,#0d1410, -|38: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-64 d,#0d1410, 65-65 d,#637f6a, 66-66 d,#0d1410, 67-129 #e5eee5,#0d1410, -|39: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-64 d,#0d1410, 65-65 d,#637f6a, 66-66 d,#0d1410, 67-129 #e5eee5,#0d1410, -|40: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-64 d,#0d1410, 65-65 d,#637f6a, 66-66 d,#0d1410, 67-129 #e5eee5,#0d1410, -|41: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-64 d,#0d1410, 65-65 d,#637f6a, 66-66 d,#0d1410, 67-129 #e5eee5,#0d1410, -|42: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-64 d,#0d1410, 65-65 d,#637f6a, 66-66 d,#0d1410, 67-129 #e5eee5,#0d1410, -|43: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-64 d,#0d1410, 65-65 d,#637f6a, 66-66 d,#0d1410, 67-129 #e5eee5,#0d1410, -|44: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-64 d,#0d1410, 65-65 d,#637f6a, 66-66 d,#0d1410, 67-129 #e5eee5,#0d1410, -|45: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-64 d,#0d1410, 65-65 d,#637f6a, 66-66 d,#0d1410, 67-129 #e5eee5,#0d1410, -|46: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-64 d,#0d1410, 65-65 d,#637f6a, 66-66 d,#0d1410, 67-129 #e5eee5,#0d1410, -|47: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-64 d,#0d1410, 65-65 d,#637f6a, 66-66 d,#0d1410, 67-129 #e5eee5,#0d1410, -|48: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-64 d,#0d1410, 65-65 d,#637f6a, 66-66 d,#0d1410, 67-129 #e5eee5,#0d1410, -|49: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-64 d,#0d1410, 65-65 d,#637f6a, 66-66 d,#0d1410, 67-129 #e5eee5,#0d1410, -|50: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-64 d,#0d1410, 65-65 d,#637f6a, 66-66 d,#0d1410, 67-129 #e5eee5,#0d1410, +|1: 0-1 #ffffff,#887455, 2-2 d,#26362d, 3-34 #becfc4,#26362d, 35-64 d,#26362d, 65-66 #ffffff,#887455, 67-67 d,#1d2824, 68-99 #b2c3b8,#1d2824, 100-129 d,#1d2824, +|2: 0-1 #ffffff,#496656, 2-2 d,#1d2824, 3-38 #b2c3b8,#1d2824, 39-47 #d3b0d9,#1d2824, 48-64 #b2c3b8,#1d2824, 65-66 #ffffff,#496656, 67-67 d,#1d2824, 68-98 #b2c3b8,#1d2824, 99-101 #d3b0d9,#1d2824, 102-129 #b2c3b8,#1d2824, +|3: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-14 #e5eee5,#0d1410, 15-64 d,#0d1410, 65-65 d,#608269, 66-66 d,#0d1410, 67-129 #e5eee5,#0d1410, +|4: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-14 #e5eee5,#0d1410, 15-64 d,#0d1410, 65-65 d,#608269, 66-66 d,#0d1410, 67-121 #e5eee5,#0d1410, 122-129 d,#0d1410, +|5: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-64 d,#0d1410, 65-65 d,#608269, 66-129 d,#0d1410, +|6: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-64 d,#0d1410, 65-66 #ffffff,#496656, 67-67 d,#1d2824, 68-104 #b2c3b8,#1d2824, 105-107 #d3b0d9,#1d2824, 108-129 #b2c3b8,#1d2824, +|7: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-64 d,#0d1410, 65-65 d,#608269, 66-66 d,#0d1410, 67-129 #e5eee5,#0d1410, +|8: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-64 d,#0d1410, 65-65 d,#608269, 66-66 d,#0d1410, 67-129 #e5eee5,#0d1410, +|9: 0-1 #000000,#add38a, 2-2 d,#26362d, 3-38 #becfc4,#26362d, 39-46 #dfbce5,#26362d, 47-64 #becfc4,#26362d, 65-65 d,#608269, 66-129 d,#0d1410, +|10: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #616f64,#0d1410,b 7-20 #e5eee5,#0d1410, 21-64 d,#0d1410, 65-65 d,#608269, 66-66 d,#0d1410, 67-129 #e5eee5,#0d1410, +|11: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-64 d,#0d1410, 65-65 d,#608269, 66-66 d,#0d1410, 67-129 #e5eee5,#0d1410, +|12: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-64 d,#0d1410, 65-65 d,#608269, 66-66 d,#0d1410, 67-129 #e5eee5,#0d1410, +|13: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-64 d,#0d1410, 65-65 d,#608269, 66-66 d,#0d1410, 67-129 #e5eee5,#0d1410, +|14: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-64 d,#0d1410, 65-65 d,#608269, 66-66 d,#0d1410, 67-129 #e5eee5,#0d1410, +|15: 0-1 #ffffff,#496656, 2-2 d,#1d2824, 3-38 #b2c3b8,#1d2824, 39-46 #d3b0d9,#1d2824, 47-64 #b2c3b8,#1d2824, 65-65 d,#608269, 66-66 d,#0d1410, 67-129 #e5eee5,#0d1410, +|16: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-20 #e5eee5,#0d1410, 21-64 d,#0d1410, 65-65 d,#608269, 66-66 d,#0d1410, 67-129 #e5eee5,#0d1410, +|17: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-64 d,#0d1410, 65-65 d,#608269, 66-66 d,#0d1410, 67-129 #e5eee5,#0d1410, +|18: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-64 d,#0d1410, 65-65 d,#608269, 66-66 d,#0d1410, 67-129 #e5eee5,#0d1410, +|19: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-64 d,#0d1410, 65-65 d,#608269, 66-66 d,#0d1410, 67-129 #e5eee5,#0d1410, +|20: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-64 d,#0d1410, 65-65 d,#608269, 66-66 d,#0d1410, 67-129 #e5eee5,#0d1410, +|21: 0-1 #ffffff,#496656, 2-2 d,#1d2824, 3-39 #b2c3b8,#1d2824, 40-47 #d3b0d9,#1d2824, 48-64 #b2c3b8,#1d2824, 65-65 d,#608269, 66-66 d,#0d1410, 67-129 #e5eee5,#0d1410, +|22: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-21 #e5eee5,#0d1410, 22-64 d,#0d1410, 65-65 d,#608269, 66-66 d,#0d1410, 67-129 #e5eee5,#0d1410, +|23: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-64 d,#0d1410, 65-65 d,#608269, 66-66 d,#0d1410, 67-129 #e5eee5,#0d1410, +|24: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-64 d,#0d1410, 65-65 d,#608269, 66-66 d,#0d1410, 67-129 #e5eee5,#0d1410, +|25: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-64 d,#0d1410, 65-65 d,#608269, 66-66 d,#0d1410, 67-129 #e5eee5,#0d1410, +|26: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-64 d,#0d1410, 65-65 d,#608269, 66-66 d,#0d1410, 67-129 #e5eee5,#0d1410, +|27: 0-1 #ffffff,#496656, 2-2 d,#1d2824, 3-39 #b2c3b8,#1d2824, 40-49 #d3b0d9,#1d2824, 50-64 #b2c3b8,#1d2824, 65-65 d,#608269, 66-66 d,#0d1410, 67-129 #e5eee5,#0d1410, +|28: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-19 #e5eee5,#0d1410, 20-64 d,#0d1410, 65-65 d,#608269, 66-66 d,#0d1410, 67-129 #e5eee5,#0d1410, +|29: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-64 d,#0d1410, 65-65 d,#608269, 66-66 d,#0d1410, 67-129 #e5eee5,#0d1410, +|30: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-64 d,#0d1410, 65-65 d,#608269, 66-66 d,#0d1410, 67-129 #e5eee5,#0d1410, +|31: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-64 d,#0d1410, 65-65 d,#608269, 66-66 d,#0d1410, 67-129 #e5eee5,#0d1410, +|32: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-64 d,#0d1410, 65-65 d,#608269, 66-66 d,#0d1410, 67-129 #e5eee5,#0d1410, +|33: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-64 d,#0d1410, 65-65 d,#608269, 66-66 d,#0d1410, 67-129 #e5eee5,#0d1410, +|34: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-64 d,#0d1410, 65-65 d,#608269, 66-66 d,#0d1410, 67-129 #e5eee5,#0d1410, +|35: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-64 d,#0d1410, 65-65 d,#608269, 66-66 d,#0d1410, 67-129 #e5eee5,#0d1410, +|36: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-64 d,#0d1410, 65-65 d,#608269, 66-66 d,#0d1410, 67-129 #e5eee5,#0d1410, +|37: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-64 d,#0d1410, 65-65 d,#608269, 66-66 d,#0d1410, 67-129 #e5eee5,#0d1410, +|38: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-64 d,#0d1410, 65-65 d,#608269, 66-66 d,#0d1410, 67-129 #e5eee5,#0d1410, +|39: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-64 d,#0d1410, 65-65 d,#608269, 66-66 d,#0d1410, 67-129 #e5eee5,#0d1410, +|40: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-64 d,#0d1410, 65-65 d,#608269, 66-66 d,#0d1410, 67-129 #e5eee5,#0d1410, +|41: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-64 d,#0d1410, 65-65 d,#608269, 66-66 d,#0d1410, 67-129 #e5eee5,#0d1410, +|42: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-64 d,#0d1410, 65-65 d,#608269, 66-66 d,#0d1410, 67-129 #e5eee5,#0d1410, +|43: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-64 d,#0d1410, 65-65 d,#608269, 66-66 d,#0d1410, 67-129 #e5eee5,#0d1410, +|44: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-64 d,#0d1410, 65-65 d,#608269, 66-66 d,#0d1410, 67-129 #e5eee5,#0d1410, +|45: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-64 d,#0d1410, 65-65 d,#608269, 66-66 d,#0d1410, 67-129 #e5eee5,#0d1410, +|46: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-64 d,#0d1410, 65-65 d,#608269, 66-66 d,#0d1410, 67-129 #e5eee5,#0d1410, +|47: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-64 d,#0d1410, 65-65 d,#608269, 66-66 d,#0d1410, 67-129 #e5eee5,#0d1410, +|48: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-64 d,#0d1410, 65-65 d,#608269, 66-66 d,#0d1410, 67-129 #e5eee5,#0d1410, +|49: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-64 d,#0d1410, 65-65 d,#608269, 66-66 d,#0d1410, 67-129 #e5eee5,#0d1410, +|50: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-64 d,#0d1410, 65-65 d,#608269, 66-66 d,#0d1410, 67-129 #e5eee5,#0d1410, diff --git a/test/snapshots/lookpanes.snap b/test/snapshots/lookpanes.snap index 3bc8055c..8ada3f1b 100644 --- a/test/snapshots/lookpanes.snap +++ b/test/snapshots/lookpanes.snap @@ -20,6 +20,10 @@ file beta/both.txt BOTH-FROM-BETA # directory at that) and Alt-c puts it in a column of its own on the right; # its first line is a word to look FROM that pane file beta/bmark.txt both.txt\nb-marker +# Builtins announce themselves by default, and an announcement is a band at +# the top of the body -- which moves every row this script clicks. What the +# verbs do is what is under test, not the announcement. +config Verbose off start 51 130 beta/bmark.txt wait 8000 b-marker stable 700 20000 diff --git a/test/snapshots/lookrange.golden b/test/snapshots/lookrange.golden index 4e916932..129ee285 100644 --- a/test/snapshots/lookrange.golden +++ b/test/snapshots/lookrange.golden @@ -1,13 +1,13 @@ == snap opened grid=150x31 cursor=7,3 |Newcol Joincol Find Grep Help Changelog Tutor Dump NextColor Debug Kill -|New Tty Find Grep Joincol -| /tmp/pardes-snap/lookrange/cwd/look.txt Save Tty Del Collapse +| New Tty Find Grep Joincol Delcol +| /tmp/pardes-snap/lookrange/cwd/look.txt Save Tty Collapse Del | 1 r.txt:3-5 | 2 r.txt:7:4-9 | 3 r.txt:3:2-5:3 | 4 r.txt:8:6-99:9 == snap wholelines grid=150x31 cursor=11,22 -|17: /tmp/pardes-snap/lookrange/cwd/r.txt Save Tty Del Collapse +|17: /tmp/pardes-snap/lookrange/cwd/r.txt Save Tty Collapse Del |18: 1 aaaa |19: 2 bbbb |20: 3 cccc dccc @@ -19,48 +19,48 @@ |26: 9 iiii == style wholelines grid=150x31 |0: 0-70 #b2c3b8,#1d2824, 71-149 d,#1d2824, -|1: 0-24 #becfc4,#26362d, 25-149 d,#26362d, -|2: 0-1 #ffffff,#4c6356, 2-62 #b2c3b8,#1d2824, 63-149 d,#1d2824, -|3: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-15 #e5eee5,#0d1410, 16-149 d,#0d1410, -|4: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-17 #e5eee5,#0d1410, 18-149 d,#0d1410, -|5: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-19 #e5eee5,#0d1410, 20-149 d,#0d1410, -|6: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-20 #e5eee5,#0d1410, 21-149 d,#0d1410, -|7: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-149 d,#0d1410, -|8: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-149 d,#0d1410, -|9: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-149 d,#0d1410, -|10: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-149 d,#0d1410, -|11: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-149 d,#0d1410, -|12: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-149 d,#0d1410, -|13: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-149 d,#0d1410, -|14: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-149 d,#0d1410, -|15: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-149 d,#0d1410, -|16: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-149 d,#0d1410, -|17: 0-1 #000000,#adcc91, 2-59 #becfc4,#26362d, 60-149 d,#26362d, -|18: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-10 #e5eee5,#0d1410, 11-149 d,#0d1410, -|19: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-10 #e5eee5,#0d1410, 11-149 d,#0d1410, -|20: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-149 #f5f7ee,#405d4b, -|21: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-149 #f5f7ee,#405d4b, -|22: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-6 #616f64,#0d1410,b 7-11 #f5f7ee,#405d4b, 12-149 d,#0d1410, -|23: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-10 #e5eee5,#0d1410, 11-149 d,#0d1410, -|24: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-18 #e5eee5,#0d1410, 19-149 d,#0d1410, -|25: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-17 #e5eee5,#0d1410, 18-149 d,#0d1410, -|26: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-10 #e5eee5,#0d1410, 11-149 d,#0d1410, -|27: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-149 d,#0d1410, -|28: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-149 d,#0d1410, -|29: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-149 d,#0d1410, -|30: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-149 d,#0d1410, +|1: 0-1 #ffffff,#887455, 2-2 d,#26362d, 3-34 #becfc4,#26362d, 35-149 d,#26362d, +|2: 0-1 #ffffff,#496656, 2-2 d,#1d2824, 3-33 #b2c3b8,#1d2824, 34-41 #d3b0d9,#1d2824, 42-63 #b2c3b8,#1d2824, 64-149 d,#1d2824, +|3: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-15 #e5eee5,#0d1410, 16-149 d,#0d1410, +|4: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-17 #e5eee5,#0d1410, 18-149 d,#0d1410, +|5: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-19 #e5eee5,#0d1410, 20-149 d,#0d1410, +|6: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-20 #e5eee5,#0d1410, 21-149 d,#0d1410, +|7: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-149 d,#0d1410, +|8: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-149 d,#0d1410, +|9: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-149 d,#0d1410, +|10: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-149 d,#0d1410, +|11: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-149 d,#0d1410, +|12: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-149 d,#0d1410, +|13: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-149 d,#0d1410, +|14: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-149 d,#0d1410, +|15: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-149 d,#0d1410, +|16: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-149 d,#0d1410, +|17: 0-1 #000000,#add38a, 2-2 d,#26362d, 3-33 #becfc4,#26362d, 34-38 #dfbce5,#26362d, 39-60 #becfc4,#26362d, 61-149 d,#26362d, +|18: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-10 #e5eee5,#0d1410, 11-149 d,#0d1410, +|19: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-10 #e5eee5,#0d1410, 11-149 d,#0d1410, +|20: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-149 #f5f7ee,#3c614a, +|21: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-149 #f5f7ee,#3c614a, +|22: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #616f64,#0d1410,b 7-11 #f5f7ee,#3c614a, 12-149 d,#0d1410, +|23: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-10 #e5eee5,#0d1410, 11-149 d,#0d1410, +|24: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-18 #e5eee5,#0d1410, 19-149 d,#0d1410, +|25: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-17 #e5eee5,#0d1410, 18-149 d,#0d1410, +|26: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-10 #e5eee5,#0d1410, 11-149 d,#0d1410, +|27: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-149 d,#0d1410, +|28: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-149 d,#0d1410, +|29: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-149 d,#0d1410, +|30: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-149 d,#0d1410, == snap onelinespan grid=150x31 cursor=15,24 == style onelinespan grid=150x31 -|20: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-15 #e5eee5,#0d1410, 16-149 d,#0d1410, -|21: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-10 #e5eee5,#0d1410, 11-149 d,#0d1410, -|22: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-10 #e5eee5,#0d1410, 11-149 d,#0d1410, -|24: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-6 #616f64,#0d1410,b 7-9 #e5eee5,#0d1410, 10-15 #f5f7ee,#405d4b, 16-18 #e5eee5,#0d1410, 19-149 d,#0d1410, +|20: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-15 #e5eee5,#0d1410, 16-149 d,#0d1410, +|21: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-10 #e5eee5,#0d1410, 11-149 d,#0d1410, +|22: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-10 #e5eee5,#0d1410, 11-149 d,#0d1410, +|24: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #616f64,#0d1410,b 7-9 #e5eee5,#0d1410, 10-15 #f5f7ee,#3c614a, 16-18 #e5eee5,#0d1410, 19-149 d,#0d1410, == snap fullspan grid=150x31 cursor=9,22 == style fullspan grid=150x31 -|20: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-7 #e5eee5,#0d1410, 8-149 #f5f7ee,#405d4b, -|21: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-149 #f5f7ee,#405d4b, -|22: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-6 #616f64,#0d1410,b 7-9 #f5f7ee,#405d4b, 10-10 #e5eee5,#0d1410, 11-149 d,#0d1410, -|24: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-18 #e5eee5,#0d1410, 19-149 d,#0d1410, +|20: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-7 #e5eee5,#0d1410, 8-149 #f5f7ee,#3c614a, +|21: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-149 #f5f7ee,#3c614a, +|22: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #616f64,#0d1410,b 7-9 #f5f7ee,#3c614a, 10-10 #e5eee5,#0d1410, 11-149 d,#0d1410, +|24: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-18 #e5eee5,#0d1410, 19-149 d,#0d1410, == snap stale grid=150x31 cursor=10,25 |18: 2 bbbb |19: 3 cccc dccc @@ -73,14 +73,14 @@ |26: == style stale grid=150x31 |18: 0-0 d,#152019, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-10 #e5eee5,#0d1410, 11-149 d,#0d1410, -|19: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-15 #e5eee5,#0d1410, 16-149 d,#0d1410, -|20: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-10 #e5eee5,#0d1410, 11-149 d,#0d1410, -|21: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-10 #e5eee5,#0d1410, 11-149 d,#0d1410, -|22: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-10 #e5eee5,#0d1410, 11-149 d,#0d1410, -|23: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-18 #e5eee5,#0d1410, 19-149 d,#0d1410, -|24: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-11 #e5eee5,#0d1410, 12-149 #f5f7ee,#405d4b, -|25: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-6 #616f64,#0d1410,b 7-10 #f5f7ee,#405d4b, 11-149 d,#0d1410, -|26: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-149 d,#0d1410, +|19: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-15 #e5eee5,#0d1410, 16-149 d,#0d1410, +|20: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-10 #e5eee5,#0d1410, 11-149 d,#0d1410, +|21: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-10 #e5eee5,#0d1410, 11-149 d,#0d1410, +|22: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-10 #e5eee5,#0d1410, 11-149 d,#0d1410, +|23: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-18 #e5eee5,#0d1410, 19-149 d,#0d1410, +|24: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-11 #e5eee5,#0d1410, 12-149 #f5f7ee,#3c614a, +|25: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #616f64,#0d1410,b 7-10 #f5f7ee,#3c614a, 11-149 d,#0d1410, +|26: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-149 d,#0d1410, == snap hit1 grid=150x31 cursor=15,24 |18: 1 aaaa |19: 2 bbbb @@ -90,22 +90,41 @@ |23: 6 ffff |24: 7 gg NEEDLE gg |25: 8 hhhh NEEDLE -|26: 9 iiii -|28: /tmp/pardes-snap/lookrange/cwd/+Search Save Tty Del Collapse -|29: 1 r.txt:7:4-9 gg NEEDLE gg -|30: 2 r.txt:8:6-11 hhhh NEEDLE +|26: /tmp/pardes-snap/lookrange/cwd/+Search Save Tty Collapse Del LocationsConfig +|27: 1 r.txt:7:4-9 +|28: 2 gg NEEDLE gg +|29: 3 r.txt:8:6-11 +|30: 4 hhhh NEEDLE == style hit1 grid=150x31 -|18: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-10 #e5eee5,#0d1410, 11-149 d,#0d1410, -|19: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-10 #e5eee5,#0d1410, 11-149 d,#0d1410, -|20: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-15 #e5eee5,#0d1410, 16-149 d,#0d1410, -|23: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-10 #e5eee5,#0d1410, 11-149 d,#0d1410, -|24: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-6 #616f64,#0d1410,b 7-9 #e5eee5,#0d1410, 10-15 #f5f7ee,#405d4b, 16-18 #e5eee5,#0d1410, 19-149 d,#0d1410, -|25: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-17 #e5eee5,#0d1410, 18-149 d,#0d1410, -|26: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-10 #e5eee5,#0d1410, 11-149 d,#0d1410, -|28: 0-1 #ffffff,#4c6356, 2-61 #b2c3b8,#1d2824, 62-149 d,#1d2824, -|29: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-17 #59675c,#0d1410, 18-21 #e5eee5,#0d1410, 22-27 #f7e4a5,#57472a, 28-30 #e5eee5,#0d1410, 31-149 d,#0d1410, -|30: 0-0 d,#152019, 1-1 d,#0d1410, 2-18 #59675c,#0d1410, 19-24 #e5eee5,#0d1410, 25-30 #f7e4a5,#57472a, 31-149 d,#0d1410, -== snap hit2 grid=150x31 cursor=17,23 +|18: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-10 #e5eee5,#0d1410, 11-149 d,#0d1410, +|19: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-10 #e5eee5,#0d1410, 11-149 d,#0d1410, +|20: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-15 #e5eee5,#0d1410, 16-149 d,#0d1410, +|23: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-10 #e5eee5,#0d1410, 11-149 d,#0d1410, +|24: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #616f64,#0d1410,b 7-9 #e5eee5,#0d1410, 10-15 #f5f7ee,#3c614a, 16-18 #e5eee5,#0d1410, 19-149 d,#0d1410, +|25: 0-0 d,#152019, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-17 #e5eee5,#0d1410, 18-149 d,#0d1410, +|26: 0-1 #ffffff,#496656, 2-2 d,#1d2824, 3-33 #b2c3b8,#1d2824, 34-40 #d3b0d9,#1d2824, 41-78 #b2c3b8,#1d2824, 79-149 d,#1d2824, +|27: 0-0 d,#608269, 1-1 d,#0d1410, 2-17 #59675c,#0d1410, 18-149 d,#0d1410, +|28: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-9 #e5eee5,#0d1410, 10-15 #f7e4a5,#5e4923, 16-18 #e5eee5,#0d1410, 19-149 d,#0d1410, +|29: 0-0 d,#608269, 1-1 d,#0d1410, 2-18 #59675c,#0d1410, 19-149 d,#0d1410, +|30: 0-0 d,#152019, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-11 #e5eee5,#0d1410, 12-17 #f7e4a5,#5e4923, 18-149 d,#0d1410, +== snap hit2 grid=150x31 cursor=17,22 +|18: 4 dddd +|19: 5 eeee +|20: 6 ffff +|21: 7 gg NEEDLE gg +|22: 8 hhhh NEEDLE +|23: 9 iiii +|24: +|25: +== style hit2 grid=150x31 +|18: 0-0 d,#152019, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-10 #e5eee5,#0d1410, 11-149 d,#0d1410, +|19: 0-0 d,#152019, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-10 #e5eee5,#0d1410, 11-149 d,#0d1410, +|20: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-10 #e5eee5,#0d1410, 11-149 d,#0d1410, +|21: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-18 #e5eee5,#0d1410, 19-149 d,#0d1410, +|22: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #616f64,#0d1410,b 7-11 #e5eee5,#0d1410, 12-17 #f5f7ee,#3c614a, 18-149 d,#0d1410, +|24: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-149 d,#0d1410, +|25: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-149 d,#0d1410, +== snap back grid=150x31 cursor=15,22 |18: 3 cccc dccc |19: 4 dddd |20: 5 eeee @@ -113,30 +132,10 @@ |22: 7 gg NEEDLE gg |23: 8 hhhh NEEDLE |24: 9 iiii -|25: -|26: -== style hit2 grid=150x31 -|18: 0-0 d,#152019, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-15 #e5eee5,#0d1410, 16-149 d,#0d1410, -|19: 0-0 d,#152019, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-10 #e5eee5,#0d1410, 11-149 d,#0d1410, -|20: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-10 #e5eee5,#0d1410, 11-149 d,#0d1410, -|22: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-18 #e5eee5,#0d1410, 19-149 d,#0d1410, -|23: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-6 #616f64,#0d1410,b 7-11 #e5eee5,#0d1410, 12-17 #f5f7ee,#405d4b, 18-149 d,#0d1410, -|24: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-10 #e5eee5,#0d1410, 11-149 d,#0d1410, -|25: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-149 d,#0d1410, -|26: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-149 d,#0d1410, -== snap back grid=150x31 cursor=15,23 -|18: 2 bbbb -|19: 3 cccc dccc -|20: 4 dddd -|21: 5 eeee -|22: 6 ffff -|23: 7 gg NEEDLE gg -|24: 8 hhhh NEEDLE -|25: 9 iiii == style back grid=150x31 -|18: 0-0 d,#152019, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-10 #e5eee5,#0d1410, 11-149 d,#0d1410, -|19: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-15 #e5eee5,#0d1410, 16-149 d,#0d1410, -|22: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-10 #e5eee5,#0d1410, 11-149 d,#0d1410, -|23: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-6 #616f64,#0d1410,b 7-9 #e5eee5,#0d1410, 10-15 #f5f7ee,#405d4b, 16-18 #e5eee5,#0d1410, 19-149 d,#0d1410, -|24: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-17 #e5eee5,#0d1410, 18-149 d,#0d1410, -|25: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-10 #e5eee5,#0d1410, 11-149 d,#0d1410, +|18: 0-0 d,#152019, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-15 #e5eee5,#0d1410, 16-149 d,#0d1410, +|19: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-10 #e5eee5,#0d1410, 11-149 d,#0d1410, +|21: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-10 #e5eee5,#0d1410, 11-149 d,#0d1410, +|22: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #616f64,#0d1410,b 7-9 #e5eee5,#0d1410, 10-15 #f5f7ee,#3c614a, 16-18 #e5eee5,#0d1410, 19-149 d,#0d1410, +|23: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-17 #e5eee5,#0d1410, 18-149 d,#0d1410, +|24: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-10 #e5eee5,#0d1410, 11-149 d,#0d1410, diff --git a/test/snapshots/lookrange.snap b/test/snapshots/lookrange.snap index c1fde9c6..50ef9ad3 100644 --- a/test/snapshots/lookrange.snap +++ b/test/snapshots/lookrange.snap @@ -14,6 +14,10 @@ # in the styles. file r.txt aaaa\nbbbb\ncccc dccc\ndddd\neeee\nffff\ngg NEEDLE gg\nhhhh NEEDLE\niiii file look.txt r.txt:3-5\nr.txt:7:4-9\nr.txt:3:2-5:3\nr.txt:8:6-99:9 +# Builtins announce themselves by default, and an announcement is a band at +# the top of the body -- which moves every row this script clicks. What the +# verbs do is what is under test, not the announcement. +config Verbose off start 31 150 look.txt wait 8000 r.txt:3-5 stable 700 20000 @@ -54,7 +58,9 @@ snapstyle stale key / text NEEDLE key enter -wait 10000 r.txt:7:4-9 gg NEEDLE +# Locations stack the target under its line now: two rows, two waits. +wait 10000 r.txt:7:4-9 +wait 10000 gg NEEDLE gg stable 700 15000 snap hit1 snapstyle hit1 diff --git a/test/snapshots/lsp-client-edit.golden b/test/snapshots/lsp-client-edit.golden index 02cc9a37..54c6e083 100644 --- a/test/snapshots/lsp-client-edit.golden +++ b/test/snapshots/lsp-client-edit.golden @@ -1,7 +1,8 @@ -== snap formatted grid=100x25 cursor=7,4 +== snap formatted grid=100x25 cursor=7,5 |Newcol Joincol Find Grep Help Changelog Tutor Dump NextColor Debug Kill -|New Tty Find Grep Joincol -| /tmp/pardes-snap/lsp-client-edit/cwd/main.rs * Save Tty Del Collapse +| New Tty Find Grep Joincol Delcol +| /tmp/pardes-snap/lsp-client-edit/cwd/main.rs * Save Tty Collapse Del TreeContext +| formatted 1 range(s) | 1 // formatted by mock | 2 mod lib; | 3 @@ -11,19 +12,6 @@ | 7 let _ = x + y; | 8 } | 9 -| -| -| -| -| -| -| -| -| -| -| -| -| formatted 1 range(s) == snap unformatted grid=100x25 cursor=7,3 |3: 1 mod lib; |4: 2 @@ -34,12 +22,24 @@ |9: 7 } |10: 8 |11: -|24: -== snap renamed grid=100x25 cursor=12,5 -|6: 4 let x = sum(1, 2); -|7: 5 let y = sum(3, 4); -|24: renamed 2 range(s) +|12: +== snap renamed grid=100x25 cursor=12,6 +|3: renamed 2 range(s) +|4: 1 mod lib; +|5: 2 +|6: 3 fn main() { +|7: 4 let x = sum(1, 2); +|8: 5 let y = sum(3, 4); +|9: 6 let _ = x + y; +|10: 7 } +|11: 8 == snap unrenamed grid=100x25 cursor=12,5 +|3: 1 mod lib; +|4: 2 +|5: 3 fn main() { |6: 4 let x = add(1, 2); |7: 5 let y = add(3, 4); -|24: +|8: 6 let _ = x + y; +|9: 7 } +|10: 8 +|11: diff --git a/test/snapshots/lsp-client.golden b/test/snapshots/lsp-client.golden index 6e122e95..6d4a0c0f 100644 --- a/test/snapshots/lsp-client.golden +++ b/test/snapshots/lsp-client.golden @@ -1,7 +1,8 @@ == snap gd-jumped grid=100x25 cursor=16,16 |Newcol Joincol Find Grep Help Changelog Tutor Dump NextColor Debug Kill -|New Tty Find Grep Joincol -| /tmp/pardes-snap/lsp-client/cwd/main.rs Save Tty Del Collapse +| New Tty Find Grep Joincol Delcol +| /tmp/pardes-snap/lsp-client/cwd/main.rs Save Tty Collapse Del TreeContext +| --:--:-- lsp rust-analyzer: ready | 1 mod lib; | 2 | 3 fn main() { @@ -12,24 +13,33 @@ | 8 | | -| --:--:-- lsp rust-analyzer: ready -| /tmp/pardes-snap/lsp-client/cwd/lib.rs Save Tty Del Collapse +| /tmp/pardes-snap/lsp-client/cwd/lib.rs Save Tty Collapse Del TreeContext | 1 // mock fixture | 2 pub fn add(a: i32, b: i32) -> i32 { | 3 a + b | 4 } | 5 == snap gr-list grid=100x25 cursor=21,6 -|13: -|21: /tmp/pardes-snap/lsp-client/cwd/+Search Save Tty Del Collapse -|22: 1 lib.rs:2:8-10 pub fn add(a: i32, b: i32) -> i32 { -|23: 2 main.rs:4:13-15 let x = add(1, 2); -|24: 3 main.rs:5:13-15 let y = add(3, 4); +|3: 1 mod lib; +|4: 2 +|5: 3 fn main() { +|6: 4 let x = add(1, 2); +|7: 5 let y = add(3, 4); +|8: 6 let _ = x + y; +|9: 7 } +|10: 8 +|11: +|20: /tmp/pardes-snap/lsp-client/cwd/+Search Save Tty Collapse Del LocationsConfig +|21: 1 lib.rs:2:8-10 +|22: 2 pub fn add(a: i32, b: i32) -> i32 { +|23: 3 main.rs:4:13-15 +|24: 4 let x = add(1, 2); == snap gr-opened grid=100x25 cursor=21,7 -|22: 2 main.rs:4:13-15 let x = add(1, 2); -|23: 3 main.rs:5:13-15 let y = add(3, 4); -|24: 4 +|21: Look +|22: 3 main.rs:4:13-15 +|23: 4 let x = add(1, 2); +|24: 5 main.rs:5:13-15 == snap gr-back grid=100x25 cursor=21,6 -|22: 1 lib.rs:2:8-10 pub fn add(a: i32, b: i32) -> i32 { -|23: 2 main.rs:4:13-15 let x = add(1, 2); -|24: 3 main.rs:5:13-15 let y = add(3, 4); +|22: 2 pub fn add(a: i32, b: i32) -> i32 { +|23: 3 main.rs:4:13-15 +|24: 4 let x = add(1, 2); diff --git a/test/snapshots/lsp-rename.golden b/test/snapshots/lsp-rename.golden index 74ab41e2..d18e6566 100644 --- a/test/snapshots/lsp-rename.golden +++ b/test/snapshots/lsp-rename.golden @@ -1,7 +1,8 @@ -== snap renamed grid=110x25 cursor=17,10 +== snap renamed grid=110x25 cursor=17,11 |Newcol Joincol Find Grep Help Changelog Tutor Dump NextColor Debug Kill -|New Tty Find Grep Joincol -| /tmp/pardes-snap/lsp-rename/cwd/rename.zig * Save Tty Del Collapse +| New Tty Find Grep Joincol Delcol +| /tmp/pardes-snap/lsp-rename/cwd/rename.zig * Save Tty Collapse Del TreeContext +| renamed 2 range(s) | 1 const std = @import("std"); | 2 | 3 fn renamed_helper(x: u32) u32 { @@ -17,17 +18,23 @@ | 13 _ = helper; | 14 } | 15 -| -| -| -| -| -| -| renamed 2 range(s) == snap undone grid=110x25 cursor=17,10 +|3: 1 const std = @import("std"); +|4: 2 |5: 3 fn helper(x: u32) u32 { +|6: 4 return x + 1; +|7: 5 } +|8: 6 +|9: 7 pub fn main() void { |10: 8 _ = helper(41); -|24: +|11: 9 } +|12: 10 +|13: 11 fn shadowed() void { +|14: 12 const helper: u32 = 7; +|15: 13 _ = helper; +|16: 14 } +|17: 15 +|18: == snap redone grid=110x25 cursor=17,10 |5: 3 fn renamed_helper(x: u32) u32 { |10: 8 _ = renamed_helper(41); diff --git a/test/snapshots/lsp.golden b/test/snapshots/lsp.golden index f6d0739a..7baf7716 100644 --- a/test/snapshots/lsp.golden +++ b/test/snapshots/lsp.golden @@ -1,7 +1,7 @@ == snap opened grid=120x41 cursor=7,3 |Newcol Joincol Find Grep Help Changelog Tutor Dump NextColor Debug Kill -|New Tty Find Grep Joincol -| /tmp/pardes-snap/lsp/cwd/a.zig Save Tty Del Collapse +| New Tty Find Grep Joincol Delcol +| /tmp/pardes-snap/lsp/cwd/a.zig Save Tty Collapse Del TreeContext | 1 const std = @import("std"); | 2 | 3 fn helper(x: u32) u32 { @@ -14,14 +14,52 @@ | 10 == snap cursor grid=120x41 cursor=17,10 == snap definition grid=120x41 cursor=15,5 -== snap hover grid=120x41 cursor=15,5 -|38: /tmp/pardes-snap/lsp/cwd/+Hover Save Tty Del Collapse +== snap hover grid=120x41 cursor=15,6 +|3: Hover +|4: 1 const std = @import("std"); +|5: 2 +|6: 3 fn helper(x: u32) u32 { +|7: 4 return x + 1; +|8: 5 } +|9: 6 +|10: 7 pub fn main() void { +|11: 8 _ = helper(41); +|12: 9 } +|13: 10 +|38: /tmp/pardes-snap/lsp/cwd/+Hover Save Tty Collapse Del |39: 1 fn helper(x: u32) u32 |40: 2 (fn (u32) u32) -== snap symbols grid=120x41 cursor=15,5 -|34: /tmp/pardes-snap/lsp/cwd/+Search Save Tty Del Collapse -|35: 1 a.zig:1:7-9 std -|36: 2 a.zig:3:4-9 helper fn helper(x: u32) u32 -|37: 3 a.zig:7:8-11 main fn main() void +== snap symbols grid=120x41 cursor=15,6 +|3: Symbols +|31: /tmp/pardes-snap/lsp/cwd/+Search Save Tty Collapse Del LocationsConfig +|32: 1 a.zig:1:7-9 +|33: 2 std +|34: 3 a.zig:3:4-9 +|35: 4 helper fn helper(x: u32) u32 +|36: 5 a.zig:7:8-11 +|37: 6 main fn main() void == snap step grid=120x41 cursor=15,3 +|3: 1 const std = @import("std"); +|4: 2 +|5: 3 fn helper(x: u32) u32 { +|6: 4 return x + 1; +|7: 5 } +|8: 6 +|9: 7 pub fn main() void { +|10: 8 _ = helper(41); +|11: 9 } +|12: 10 +|13: +|32: Look +|33: 1 a.zig:1:7-9 +|34: 2 std +|35: 3 a.zig:3:4-9 +|36: 4 helper fn helper(x: u32) u32 +|37: 5 a.zig:7:8-11 == snap nothing grid=120x41 cursor=7,5 +|32: 1 a.zig:1:7-9 +|33: 2 std +|34: 3 a.zig:3:4-9 +|35: 4 helper fn helper(x: u32) u32 +|36: 5 a.zig:7:8-11 +|37: 6 main fn main() void diff --git a/test/snapshots/lspcomplete.golden b/test/snapshots/lspcomplete.golden index 3c4316c3..4a9ff8b5 100644 --- a/test/snapshots/lspcomplete.golden +++ b/test/snapshots/lspcomplete.golden @@ -1,7 +1,7 @@ == snap opened grid=120x41 cursor=7,3 |Newcol Joincol Find Grep Help Changelog Tutor Dump NextColor Debug Kill -|New Tty Find Grep Joincol -| /tmp/pardes-snap/lspcomplete/cwd/a.zig Save Tty Del Collapse +| New Tty Find Grep Joincol Delcol +| /tmp/pardes-snap/lspcomplete/cwd/a.zig Save Tty Collapse Del TreeContext | 1 const Shade = enum { | 2 verdigris, | 3 cinnabar, @@ -16,29 +16,31 @@ | 12 // note. see below | 13 == snap indent grid=120x41 cursor=11,12 -|2: ^ /tmp/pardes-snap/lspcomplete/cwd/a.zig * Save Tty Del Collapse +|2: ^ /tmp/pardes-snap/lspcomplete/cwd/a.zig * Save Tty Collapse Del TreeContext |12: 10 } == snap commentindent grid=120x41 cursor=19,14 |14: 12 // note. see below == snap athedot grid=120x41 cursor=16,10 |10: 8 . == snap completion grid=120x41 cursor=16,10 -|38: /tmp/pardes-snap/lspcomplete/cwd/+Search Save Tty Del Collapse +|38: /tmp/pardes-snap/lspcomplete/cwd/+Search Save Tty Collapse Del |39: 1 a.zig:2:5-13 verdigris verdigris, |40: 2 a.zig:3:5-12 cinnabar cinnabar, == snap refill grid=120x41 cursor=16,10 == snap step grid=120x41 cursor=19,4 -|2: /tmp/pardes-snap/lspcomplete/cwd/a.zig * Save Tty Del Collapse +|2: /tmp/pardes-snap/lspcomplete/cwd/a.zig * Save Tty Collapse Del TreeContext +|39: Look +|40: 1 a.zig:2:5-13 verdigris verdigris, == snap txtindent grid=120x41 cursor=15,3 |Newcol Joincol Find Grep Help Changelog Tutor Dump NextColor Debug Kill -|New Tty Find Grep Joincol -|^ /tmp/pardes-snap/lspcomplete/cwd/notes.txt * Save Tty Del Collapse +| New Tty Find Grep Joincol Delcol +|^ /tmp/pardes-snap/lspcomplete/cwd/notes.txt * Save Tty Collapse Del | 1 abc. def ghi | 2 == snap nosemi grid=100x19 cursor=29,9 |Newcol Joincol Find Grep Help Changelog Tutor Dump NextColor Debug Kill -|New Tty Find Grep Joincol -|^ /tmp/pardes-snap/lspcomplete/cwd/c.zig * Save Tty Del Collapse +| New Tty Find Grep Joincol Delcol +|^ /tmp/pardes-snap/lspcomplete/cwd/c.zig * Save Tty Collapse Del TreeContext | 1 const Shade = enum { | 2 verdigris, | 3 cinnabar, @@ -52,13 +54,13 @@ | | | -| /tmp/pardes-snap/lspcomplete/cwd/+Search Save Tty Del Collapse +| /tmp/pardes-snap/lspcomplete/cwd/+Search Save Tty Collapse Del | 1 c.zig:2:5-13 verdigris verdigris, | 2 c.zig:3:5-12 cinnabar cinnabar, == snap nobrace grid=100x19 cursor=16,10 |Newcol Joincol Find Grep Help Changelog Tutor Dump NextColor Debug Kill -|New Tty Find Grep Joincol -|^ /tmp/pardes-snap/lspcomplete/cwd/d.zig * Save Tty Del Collapse +| New Tty Find Grep Joincol Delcol +|^ /tmp/pardes-snap/lspcomplete/cwd/d.zig * Save Tty Collapse Del TreeContext | 1 const Shade = enum { | 2 verdigris, | 3 cinnabar, @@ -72,6 +74,6 @@ | | | -| /tmp/pardes-snap/lspcomplete/cwd/+Search Save Tty Del Collapse +| /tmp/pardes-snap/lspcomplete/cwd/+Search Save Tty Collapse Del | 1 d.zig:2:5-13 verdigris verdigris, | 2 d.zig:3:5-12 cinnabar cinnabar, diff --git a/test/snapshots/lspcompletemoved.golden b/test/snapshots/lspcompletemoved.golden index 6232a1f3..af6616af 100644 --- a/test/snapshots/lspcompletemoved.golden +++ b/test/snapshots/lspcompletemoved.golden @@ -1,7 +1,7 @@ == snap typedthrough grid=120x21 cursor=16,14 |Newcol Joincol Find Grep Help Changelog Tutor Dump NextColor Debug Kill -|New Tty Find Grep Joincol -|^ /tmp/pardes-snap/lspcompletemoved/cwd/a.zig * Save Tty Del Collapse +| New Tty Find Grep Joincol Delcol +|^ /tmp/pardes-snap/lspcompletemoved/cwd/a.zig * Save Tty Collapse Del TreeContext | 1 const Shade = enum { | 2 verdigris, | 3 cinnabar, diff --git a/test/snapshots/lspdebug.golden b/test/snapshots/lspdebug.golden index e1b57c5e..a2182231 100644 --- a/test/snapshots/lspdebug.golden +++ b/test/snapshots/lspdebug.golden @@ -1,7 +1,7 @@ == snap opened grid=120x45 cursor=7,3 |Newcol Joincol Find Grep Help Changelog Tutor Dump NextColor Debug Kill -|New Tty Find Grep Joincol -| /tmp/pardes-snap/lspdebug/cwd/z.zig Save Tty Del Collapse +| New Tty Find Grep Joincol Delcol +| /tmp/pardes-snap/lspdebug/cwd/z.zig Save Tty Collapse Del TreeContext | 1 const std = @import("std"); | 2 | 3 fn helper() u32 { diff --git a/test/snapshots/lspdebug.snap b/test/snapshots/lspdebug.snap index 4021bc17..23a95db0 100644 --- a/test/snapshots/lspdebug.snap +++ b/test/snapshots/lspdebug.snap @@ -1,4 +1,8 @@ file z.zig const std = @import("std");\n\nfn helper() u32 {\n return 3;\n}\n\npub fn main() void {\n const v = helper();\n _ = v;\n}\n +# Builtins announce themselves by default, and an announcement is a band at +# the top of the body -- which moves every row this script clicks. What the +# verbs do is what is under test, not the announcement. +config Verbose off start 45 120 z.zig wait 8000 fn helper stable 700 20000 @@ -38,6 +42,9 @@ text last queries key enter wait 10000 last queries wait 10000 definition z.zig +# The results pane the search opened takes the bottom half, which leaves the +# report one row short of its second query: step the cursor past it. +key j j j wait 10000 explain z.zig key space d key space w j diff --git a/test/snapshots/lsprelpath.golden b/test/snapshots/lsprelpath.golden index 65fd08cd..58de860b 100644 --- a/test/snapshots/lsprelpath.golden +++ b/test/snapshots/lsprelpath.golden @@ -1,7 +1,7 @@ == snap absrow grid=100x35 cursor=16,7 |Newcol Joincol Find Grep Help Changelog Tutor Dump NextColor Debug Kill -|New Tty Find Grep Joincol -|^ /tmp/pardes-snap/lsprelpath/cwd/sub/parent.zig * Save Tty Del Collapse +| New Tty Find Grep Joincol Delcol +|^ /tmp/pardes-snap/lsprelpath/cwd/sub/parent.zig * Save Tty Collapse Del TreeContext | 1 const shade = @import("../shade.zig"); | 2 | 3 pub fn pick(s: shade.Shade) u8 { @@ -31,57 +31,59 @@ | | | -| /tmp/pardes-snap/lsprelpath/cwd/sub/+Search Save Tty Del Collapse +| /tmp/pardes-snap/lsprelpath/cwd/sub/+Search Save Tty Collapse Del | 1 /tmp/pardes-snap/lsprelpath/cwd/shade.zig:2:5-13 verdigris verdigris, | 2 /tmp/pardes-snap/lsprelpath/cwd/shade.zig:3:5-12 cinnabar cinnabar, == snap abslook grid=100x35 cursor=19,19 -|2: /tmp/pardes-snap/lsprelpath/cwd/sub/parent.zig * Save Tty Del Collapse -|17: /tmp/pardes-snap/lsprelpath/cwd/shade.zig Save Tty Del Collapse +|2: /tmp/pardes-snap/lsprelpath/cwd/sub/parent.zig * Save Tty Collapse Del TreeContext +|17: /tmp/pardes-snap/lsprelpath/cwd/shade.zig Save Tty Collapse Del TreeContext |18: 1 pub const Shade = enum { |19: 2 verdigris, |20: 3 cinnabar, |21: 4 }; |22: 5 +|33: Look +|34: 1 /tmp/pardes-snap/lsprelpath/cwd/shade.zig:2:5-13 verdigris verdigris, == style abslook grid=100x35 |0: 0-70 #b2c3b8,#1d2824, 71-99 d,#1d2824, -|1: 0-24 #becfc4,#26362d, 25-99 d,#26362d, -|2: 0-1 #ffffff,#4c6356, 2-71 #b2c3b8,#1d2824, 72-99 d,#1d2824, -|3: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-20 #e5eee5,#0d1410, 21-27 #c9b0e4,#0d1410, 28-28 #e5eee5,#0d1410, 29-42 #b6ce94,#0d1410, 43-44 #e5eee5,#0d1410, 45-99 d,#0d1410, -|4: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-99 d,#0d1410, -|5: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-10 #e5eee5,#0d1410, 11-12 #c9b0e4,#0d1410, 13-38 #e5eee5,#0d1410, 39-99 d,#0d1410, -|6: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-10 #e5eee5,#0d1410, 11-16 #c9b0e4,#0d1410, 17-17 #e5eee5,#0d1410, 18-23 #c9b0e4,#0d1410, 24-29 #e5eee5,#0d1410, 30-99 d,#0d1410, -|7: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-15 #e5eee5,#0d1410, 16-99 d,#0d1410, -|8: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-12 #e5eee5,#0d1410, 13-99 d,#0d1410, -|9: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-7 #e5eee5,#0d1410, 8-99 d,#0d1410, -|10: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-99 d,#0d1410, -|11: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-99 d,#0d1410, -|12: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-99 d,#0d1410, -|13: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-99 d,#0d1410, -|14: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-99 d,#0d1410, -|15: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-99 d,#0d1410, -|16: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-99 d,#0d1410, -|17: 0-1 #000000,#adcc91, 2-64 #becfc4,#26362d, 65-99 d,#26362d, -|18: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-24 #e5eee5,#0d1410, 25-28 #c9b0e4,#0d1410, 29-30 #e5eee5,#0d1410, 31-99 d,#0d1410, -|19: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-6 #616f64,#0d1410,b 7-10 #e5eee5,#0d1410, 11-19 #f5f7ee,#405d4b, 20-20 #e5eee5,#0d1410, 21-99 d,#0d1410, -|20: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-19 #e5eee5,#0d1410, 20-99 d,#0d1410, -|21: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-8 #e5eee5,#0d1410, 9-99 d,#0d1410, -|22: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-99 d,#0d1410, -|23: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-99 d,#0d1410, -|24: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-99 d,#0d1410, -|25: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-99 d,#0d1410, -|26: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-99 d,#0d1410, -|27: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-99 d,#0d1410, -|28: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-99 d,#0d1410, -|29: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-99 d,#0d1410, -|30: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-99 d,#0d1410, -|31: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-99 d,#0d1410, -|32: 0-1 #ffffff,#4c6356, 2-66 #b2c3b8,#1d2824, 67-99 d,#1d2824, -|33: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-54 #59675c,#0d1410, 55-76 #e5eee5,#0d1410, 77-99 d,#0d1410, -|34: 0-0 d,#152019, 1-1 d,#0d1410, 2-54 #59675c,#0d1410, 55-74 #e5eee5,#0d1410, 75-99 d,#0d1410, +|1: 0-1 #ffffff,#887455, 2-2 d,#26362d, 3-34 #becfc4,#26362d, 35-99 d,#26362d, +|2: 0-1 #ffffff,#496656, 2-2 d,#1d2824, 3-38 #b2c3b8,#1d2824, 39-48 #d3b0d9,#1d2824, 49-84 #b2c3b8,#1d2824, 85-99 d,#1d2824, +|3: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-20 #e5eee5,#0d1410, 21-27 #c9a7ed,#0d1410, 28-28 #e5eee5,#0d1410, 29-42 #b8d88a,#0d1410, 43-44 #e5eee5,#0d1410, 45-99 d,#0d1410, +|4: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-99 d,#0d1410, +|5: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-10 #e5eee5,#0d1410, 11-12 #c9a7ed,#0d1410, 13-38 #e5eee5,#0d1410, 39-99 d,#0d1410, +|6: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-10 #e5eee5,#0d1410, 11-16 #c9a7ed,#0d1410, 17-17 #e5eee5,#0d1410, 18-23 #c9a7ed,#0d1410, 24-29 #e5eee5,#0d1410, 30-99 d,#0d1410, +|7: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-15 #e5eee5,#0d1410, 16-99 d,#0d1410, +|8: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-12 #e5eee5,#0d1410, 13-99 d,#0d1410, +|9: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-7 #e5eee5,#0d1410, 8-99 d,#0d1410, +|10: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-99 d,#0d1410, +|11: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-99 d,#0d1410, +|12: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-99 d,#0d1410, +|13: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-99 d,#0d1410, +|14: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-99 d,#0d1410, +|15: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-99 d,#0d1410, +|16: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-99 d,#0d1410, +|17: 0-1 #000000,#add38a, 2-2 d,#26362d, 3-34 #becfc4,#26362d, 35-43 #dfbce5,#26362d, 44-77 #becfc4,#26362d, 78-99 d,#26362d, +|18: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-24 #e5eee5,#0d1410, 25-28 #c9a7ed,#0d1410, 29-30 #e5eee5,#0d1410, 31-99 d,#0d1410, +|19: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #616f64,#0d1410,b 7-10 #e5eee5,#0d1410, 11-19 #f5f7ee,#3c614a, 20-20 #e5eee5,#0d1410, 21-99 d,#0d1410, +|20: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-19 #e5eee5,#0d1410, 20-99 d,#0d1410, +|21: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-8 #e5eee5,#0d1410, 9-99 d,#0d1410, +|22: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-99 d,#0d1410, +|23: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-99 d,#0d1410, +|24: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-99 d,#0d1410, +|25: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-99 d,#0d1410, +|26: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-99 d,#0d1410, +|27: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-99 d,#0d1410, +|28: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-99 d,#0d1410, +|29: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-99 d,#0d1410, +|30: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-99 d,#0d1410, +|31: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-99 d,#0d1410, +|32: 0-1 #ffffff,#496656, 2-2 d,#1d2824, 3-38 #b2c3b8,#1d2824, 39-45 #d3b0d9,#1d2824, 46-67 #b2c3b8,#1d2824, 68-99 d,#1d2824, +|33: 0-0 d,#152019, 1-1 d,#0d1410, 2-95 d,#1d2824, 96-99 #b2c3b8,#1d2824, +|34: 0-0 d,#608269, 1-1 d,#0d1410, 2-54 #59675c,#0d1410, 55-76 #e5eee5,#0d1410, 77-99 d,#0d1410, == snap subrow grid=100x35 cursor=16,7 |Newcol Joincol Find Grep Help Changelog Tutor Dump NextColor Debug Kill -|New Tty Find Grep Joincol -|^ /tmp/pardes-snap/lsprelpath/cwd/sub/subdir.zig * Save Tty Del Collapse +| New Tty Find Grep Joincol Delcol +|^ /tmp/pardes-snap/lsprelpath/cwd/sub/subdir.zig * Save Tty Collapse Del TreeContext | 1 const tint = @import("inner/tint.zig"); | 2 | 3 pub fn hue(t: tint.Tint) u8 { @@ -111,51 +113,53 @@ | | | -| /tmp/pardes-snap/lsprelpath/cwd/sub/+Search Save Tty Del Collapse +| /tmp/pardes-snap/lsprelpath/cwd/sub/+Search Save Tty Collapse Del | 1 inner/tint.zig:2:5-9 ochre ochre, | 2 inner/tint.zig:3:5-10 indigo indigo, == snap sublook grid=100x35 cursor=15,19 -|2: /tmp/pardes-snap/lsprelpath/cwd/sub/subdir.zig * Save Tty Del Collapse -|17: /tmp/pardes-snap/lsprelpath/cwd/sub/inner/tint.zig Save Tty Del Collapse +|2: /tmp/pardes-snap/lsprelpath/cwd/sub/subdir.zig * Save Tty Collapse Del TreeContext +|17: /tmp/pardes-snap/lsprelpath/cwd/sub/inner/tint.zig Save Tty Collapse Del TreeContext |18: 1 pub const Tint = enum { |19: 2 ochre, |20: 3 indigo, |21: 4 }; |22: 5 +|33: Look +|34: 1 inner/tint.zig:2:5-9 ochre ochre, == style sublook grid=100x35 |0: 0-70 #b2c3b8,#1d2824, 71-99 d,#1d2824, -|1: 0-24 #becfc4,#26362d, 25-99 d,#26362d, -|2: 0-1 #ffffff,#4c6356, 2-71 #b2c3b8,#1d2824, 72-99 d,#1d2824, -|3: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-19 #e5eee5,#0d1410, 20-26 #c9b0e4,#0d1410, 27-27 #e5eee5,#0d1410, 28-43 #b6ce94,#0d1410, 44-45 #e5eee5,#0d1410, 46-99 d,#0d1410, -|4: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-99 d,#0d1410, -|5: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-10 #e5eee5,#0d1410, 11-12 #c9b0e4,#0d1410, 13-35 #e5eee5,#0d1410, 36-99 d,#0d1410, -|6: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-10 #e5eee5,#0d1410, 11-16 #c9b0e4,#0d1410, 17-17 #e5eee5,#0d1410, 18-23 #c9b0e4,#0d1410, 24-29 #e5eee5,#0d1410, 30-99 d,#0d1410, -|7: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-15 #e5eee5,#0d1410, 16-99 d,#0d1410, -|8: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-12 #e5eee5,#0d1410, 13-99 d,#0d1410, -|9: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-7 #e5eee5,#0d1410, 8-99 d,#0d1410, -|10: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-99 d,#0d1410, -|11: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-99 d,#0d1410, -|12: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-99 d,#0d1410, -|13: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-99 d,#0d1410, -|14: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-99 d,#0d1410, -|15: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-99 d,#0d1410, -|16: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-99 d,#0d1410, -|17: 0-1 #000000,#adcc91, 2-73 #becfc4,#26362d, 74-99 d,#26362d, -|18: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-23 #e5eee5,#0d1410, 24-27 #c9b0e4,#0d1410, 28-29 #e5eee5,#0d1410, 30-99 d,#0d1410, -|19: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-6 #616f64,#0d1410,b 7-10 #e5eee5,#0d1410, 11-15 #f5f7ee,#405d4b, 16-16 #e5eee5,#0d1410, 17-99 d,#0d1410, -|20: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-17 #e5eee5,#0d1410, 18-99 d,#0d1410, -|21: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-8 #e5eee5,#0d1410, 9-99 d,#0d1410, -|22: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-99 d,#0d1410, -|23: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-99 d,#0d1410, -|24: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-99 d,#0d1410, -|25: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-99 d,#0d1410, -|26: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-99 d,#0d1410, -|27: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-99 d,#0d1410, -|28: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-99 d,#0d1410, -|29: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-99 d,#0d1410, -|30: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-99 d,#0d1410, -|31: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-99 d,#0d1410, -|32: 0-1 #ffffff,#4c6356, 2-66 #b2c3b8,#1d2824, 67-99 d,#1d2824, -|33: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-26 #59675c,#0d1410, 27-40 #e5eee5,#0d1410, 41-99 d,#0d1410, -|34: 0-0 d,#152019, 1-1 d,#0d1410, 2-27 #59675c,#0d1410, 28-43 #e5eee5,#0d1410, 44-99 d,#0d1410, -== snap clicked grid=100x35 cursor=16,20 +|1: 0-1 #ffffff,#887455, 2-2 d,#26362d, 3-34 #becfc4,#26362d, 35-99 d,#26362d, +|2: 0-1 #ffffff,#496656, 2-2 d,#1d2824, 3-38 #b2c3b8,#1d2824, 39-48 #d3b0d9,#1d2824, 49-84 #b2c3b8,#1d2824, 85-99 d,#1d2824, +|3: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-19 #e5eee5,#0d1410, 20-26 #c9a7ed,#0d1410, 27-27 #e5eee5,#0d1410, 28-43 #b8d88a,#0d1410, 44-45 #e5eee5,#0d1410, 46-99 d,#0d1410, +|4: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-99 d,#0d1410, +|5: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-10 #e5eee5,#0d1410, 11-12 #c9a7ed,#0d1410, 13-35 #e5eee5,#0d1410, 36-99 d,#0d1410, +|6: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-10 #e5eee5,#0d1410, 11-16 #c9a7ed,#0d1410, 17-17 #e5eee5,#0d1410, 18-23 #c9a7ed,#0d1410, 24-29 #e5eee5,#0d1410, 30-99 d,#0d1410, +|7: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-15 #e5eee5,#0d1410, 16-99 d,#0d1410, +|8: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-12 #e5eee5,#0d1410, 13-99 d,#0d1410, +|9: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-7 #e5eee5,#0d1410, 8-99 d,#0d1410, +|10: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-99 d,#0d1410, +|11: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-99 d,#0d1410, +|12: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-99 d,#0d1410, +|13: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-99 d,#0d1410, +|14: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-99 d,#0d1410, +|15: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-99 d,#0d1410, +|16: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-99 d,#0d1410, +|17: 0-1 #000000,#add38a, 2-2 d,#26362d, 3-44 #becfc4,#26362d, 45-52 #dfbce5,#26362d, 53-86 #becfc4,#26362d, 87-99 d,#26362d, +|18: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-23 #e5eee5,#0d1410, 24-27 #c9a7ed,#0d1410, 28-29 #e5eee5,#0d1410, 30-99 d,#0d1410, +|19: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #616f64,#0d1410,b 7-10 #e5eee5,#0d1410, 11-15 #f5f7ee,#3c614a, 16-16 #e5eee5,#0d1410, 17-99 d,#0d1410, +|20: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-17 #e5eee5,#0d1410, 18-99 d,#0d1410, +|21: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-8 #e5eee5,#0d1410, 9-99 d,#0d1410, +|22: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-99 d,#0d1410, +|23: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-99 d,#0d1410, +|24: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-99 d,#0d1410, +|25: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-99 d,#0d1410, +|26: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-99 d,#0d1410, +|27: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-99 d,#0d1410, +|28: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-99 d,#0d1410, +|29: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-99 d,#0d1410, +|30: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-99 d,#0d1410, +|31: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-99 d,#0d1410, +|32: 0-1 #ffffff,#496656, 2-2 d,#1d2824, 3-38 #b2c3b8,#1d2824, 39-45 #d3b0d9,#1d2824, 46-67 #b2c3b8,#1d2824, 68-99 d,#1d2824, +|33: 0-0 d,#152019, 1-1 d,#0d1410, 2-95 d,#1d2824, 96-99 #b2c3b8,#1d2824, +|34: 0-0 d,#608269, 1-1 d,#0d1410, 2-26 #59675c,#0d1410, 27-40 #e5eee5,#0d1410, 41-99 d,#0d1410, +== snap clicked grid=100x35 cursor=15,19 diff --git a/test/snapshots/markup.golden b/test/snapshots/markup.golden index 7caaf5b1..ca69d0f7 100644 --- a/test/snapshots/markup.golden +++ b/test/snapshots/markup.golden @@ -1,7 +1,7 @@ == snap typst grid=92x25 cursor=7,3 |Newcol Joincol Find Grep Help Changelog Tutor Dump NextColor Debug Kill -|New Tty Find Grep Joincol -| /tmp/pardes-snap/markup/cwd/paper.typ Save Tty Del Collapse +| New Tty Find Grep Joincol Delcol +| /tmp/pardes-snap/markup/cwd/paper.typ Save Tty Collapse Del TreeContext | 1 = Typst heading | 2 | 3 Prose with *bold* and _italic_ words, a `raw` span, @@ -13,34 +13,34 @@ | 9 == style typst grid=92x25 |0: 0-70 #b2c3b8,#1d2824, 71-91 d,#1d2824, -|1: 0-24 #becfc4,#26362d, 25-91 d,#26362d, -|2: 0-1 #000000,#adcc91, 2-60 #becfc4,#26362d, 61-91 d,#26362d, -|3: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-6 #616f64,#0d1410,b 7-21 #c9b0e4,#0d1410, 22-91 d,#0d1410, -|4: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-91 d,#0d1410, -|5: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-17 #e5eee5,#0d1410, 18-23 #b9e58f,#0d1410, 24-28 #e5eee5,#0d1410, 29-36 #e9bf91,#0d1410, 37-46 #e5eee5,#0d1410, 47-51 #b6ce94,#0d1410, 52-57 #e5eee5,#0d1410, 58-91 d,#0d1410, -|6: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-10 #e5eee5,#0d1410, 11-15 #c9b0e4,#0d1410, 16-27 #e5eee5,#0d1410, 28-31 #c9b0e4,#0d1410, 32-36 #e5eee5,#0d1410, 37-38 #e9bf91,#0d1410, 39-91 d,#0d1410, -|7: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-91 d,#0d1410, -|8: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-12 #b6ce94,#0d1410, 13-91 d,#0d1410, -|9: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-8 #c9b0e4,#0d1410, 9-23 #e5eee5,#0d1410, 24-29 #c9b0e4,#0d1410, 30-30 #e5eee5,#0d1410, 31-32 #e9bf91,#0d1410, 33-35 #e5eee5,#0d1410, 36-91 d,#0d1410, -|10: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-9 #b6ce94,#0d1410, 10-91 d,#0d1410, -|11: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-91 d,#0d1410, -|12: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-91 d,#0d1410, -|13: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-91 d,#0d1410, -|14: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-91 d,#0d1410, -|15: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-91 d,#0d1410, -|16: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-91 d,#0d1410, -|17: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-91 d,#0d1410, -|18: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-91 d,#0d1410, -|19: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-91 d,#0d1410, -|20: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-91 d,#0d1410, -|21: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-91 d,#0d1410, -|22: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-91 d,#0d1410, -|23: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-91 d,#0d1410, -|24: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-91 d,#0d1410, +|1: 0-1 #ffffff,#887455, 2-2 d,#26362d, 3-34 #becfc4,#26362d, 35-91 d,#26362d, +|2: 0-1 #000000,#add38a, 2-2 d,#26362d, 3-30 #becfc4,#26362d, 31-39 #dfbce5,#26362d, 40-73 #becfc4,#26362d, 74-91 d,#26362d, +|3: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #616f64,#0d1410,b 7-21 #c9a7ed,#0d1410, 22-91 d,#0d1410, +|4: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-91 d,#0d1410, +|5: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-17 #e5eee5,#0d1410, 18-23 #b9f480,#0d1410, 24-28 #e5eee5,#0d1410, 29-36 #f8c082,#0d1410, 37-46 #e5eee5,#0d1410, 47-51 #b8d88a,#0d1410, 52-57 #e5eee5,#0d1410, 58-91 d,#0d1410, +|6: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-10 #e5eee5,#0d1410, 11-15 #c9a7ed,#0d1410, 16-27 #e5eee5,#0d1410, 28-31 #c9a7ed,#0d1410, 32-36 #e5eee5,#0d1410, 37-38 #f8c082,#0d1410, 39-91 d,#0d1410, +|7: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-91 d,#0d1410, +|8: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-12 #b8d88a,#0d1410, 13-91 d,#0d1410, +|9: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-8 #c9a7ed,#0d1410, 9-23 #e5eee5,#0d1410, 24-29 #c9a7ed,#0d1410, 30-30 #e5eee5,#0d1410, 31-32 #f8c082,#0d1410, 33-35 #e5eee5,#0d1410, 36-91 d,#0d1410, +|10: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-9 #b8d88a,#0d1410, 10-91 d,#0d1410, +|11: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-91 d,#0d1410, +|12: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-91 d,#0d1410, +|13: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-91 d,#0d1410, +|14: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-91 d,#0d1410, +|15: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-91 d,#0d1410, +|16: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-91 d,#0d1410, +|17: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-91 d,#0d1410, +|18: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-91 d,#0d1410, +|19: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-91 d,#0d1410, +|20: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-91 d,#0d1410, +|21: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-91 d,#0d1410, +|22: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-91 d,#0d1410, +|23: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-91 d,#0d1410, +|24: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-91 d,#0d1410, == snap markdown grid=92x25 cursor=7,3 |Newcol Joincol Find Grep Help Changelog Tutor Dump NextColor Debug Kill -|New Tty Find Grep Joincol -| /tmp/pardes-snap/markup/cwd/notes.md Save Tty Del Collapse +| New Tty Find Grep Joincol Delcol +| /tmp/pardes-snap/markup/cwd/notes.md Save Tty Collapse Del TreeContext | 1 # Markdown heading with *italic* | 2 | 3 Prose with **bold**, *italic* and an `inline` span. @@ -51,27 +51,27 @@ | 8 == style markdown grid=92x25 |0: 0-70 #b2c3b8,#1d2824, 71-91 d,#1d2824, -|1: 0-24 #becfc4,#26362d, 25-91 d,#26362d, -|2: 0-1 #000000,#adcc91, 2-59 #becfc4,#26362d, 60-91 d,#26362d, -|3: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-6 #616f64,#0d1410,b 7-8 #e5eee5,#0d1410, 9-30 #c9b0e4,#0d1410, 31-38 #e9bf91,#0d1410, 39-91 d,#0d1410, -|4: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-91 d,#0d1410, -|5: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-17 #e5eee5,#0d1410, 18-25 #b9e58f,#0d1410, 26-27 #e5eee5,#0d1410, 28-35 #e9bf91,#0d1410, 36-43 #e5eee5,#0d1410, 44-51 #b6ce94,#0d1410, 52-57 #e5eee5,#0d1410, 58-91 d,#0d1410, -|6: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-91 d,#0d1410, -|7: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-12 #b6ce94,#0d1410, 13-91 d,#0d1410, -|8: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-8 #c9b0e4,#0d1410, 9-23 #e5eee5,#0d1410, 24-29 #c9b0e4,#0d1410, 30-30 #e5eee5,#0d1410, 31-32 #e9bf91,#0d1410, 33-35 #e5eee5,#0d1410, 36-91 d,#0d1410, -|9: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-9 #b6ce94,#0d1410, 10-91 d,#0d1410, -|10: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-91 d,#0d1410, -|11: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-91 d,#0d1410, -|12: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-91 d,#0d1410, -|13: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-91 d,#0d1410, -|14: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-91 d,#0d1410, -|15: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-91 d,#0d1410, -|16: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-91 d,#0d1410, -|17: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-91 d,#0d1410, -|18: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-91 d,#0d1410, -|19: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-91 d,#0d1410, -|20: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-91 d,#0d1410, -|21: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-91 d,#0d1410, -|22: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-91 d,#0d1410, -|23: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-91 d,#0d1410, -|24: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-91 d,#0d1410, +|1: 0-1 #ffffff,#887455, 2-2 d,#26362d, 3-34 #becfc4,#26362d, 35-91 d,#26362d, +|2: 0-1 #000000,#add38a, 2-2 d,#26362d, 3-30 #becfc4,#26362d, 31-38 #dfbce5,#26362d, 39-72 #becfc4,#26362d, 73-91 d,#26362d, +|3: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #616f64,#0d1410,b 7-8 #e5eee5,#0d1410, 9-30 #c9a7ed,#0d1410, 31-38 #f8c082,#0d1410, 39-91 d,#0d1410, +|4: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-91 d,#0d1410, +|5: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-17 #e5eee5,#0d1410, 18-25 #b9f480,#0d1410, 26-27 #e5eee5,#0d1410, 28-35 #f8c082,#0d1410, 36-43 #e5eee5,#0d1410, 44-51 #b8d88a,#0d1410, 52-57 #e5eee5,#0d1410, 58-91 d,#0d1410, +|6: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-91 d,#0d1410, +|7: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-12 #b8d88a,#0d1410, 13-91 d,#0d1410, +|8: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-8 #c9a7ed,#0d1410, 9-23 #e5eee5,#0d1410, 24-29 #c9a7ed,#0d1410, 30-30 #e5eee5,#0d1410, 31-32 #f8c082,#0d1410, 33-35 #e5eee5,#0d1410, 36-91 d,#0d1410, +|9: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-9 #b8d88a,#0d1410, 10-91 d,#0d1410, +|10: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-91 d,#0d1410, +|11: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-91 d,#0d1410, +|12: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-91 d,#0d1410, +|13: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-91 d,#0d1410, +|14: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-91 d,#0d1410, +|15: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-91 d,#0d1410, +|16: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-91 d,#0d1410, +|17: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-91 d,#0d1410, +|18: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-91 d,#0d1410, +|19: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-91 d,#0d1410, +|20: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-91 d,#0d1410, +|21: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-91 d,#0d1410, +|22: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-91 d,#0d1410, +|23: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-91 d,#0d1410, +|24: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-91 d,#0d1410, diff --git a/test/snapshots/mini.golden b/test/snapshots/mini.golden index aac5dee6..b915c60b 100644 --- a/test/snapshots/mini.golden +++ b/test/snapshots/mini.golden @@ -1,7 +1,8 @@ == snap opened grid=90x23 cursor=7,14 |Newcol Joincol Find Grep Help Changelog Tutor Dump NextColor Debug Kill -|New Tty Find Grep Joincol -| /tmp/pardes-snap/mini/cwd/commands.txt Save Tty Del Collapse +| New Tty Find Grep Joincol Delcol +| /tmp/pardes-snap/mini/cwd/commands.txt Save Tty Collapse Del +| Mini | 1 @`Mini demo.zig` | | @@ -11,108 +12,118 @@ | | | -| -| /tmp/pardes-snap/mini/cwd/Mini demo.zig Save Tty Del Collapse +| /tmp/pardes-snap/mini/cwd/Mini demo.zig Save Tty Collapse Del | 1 â ­â �⣥⢩⣭⡭⣭⣬⣌⢭⣭⠌⠬⠅â �â � | 2 ⣂⢀⣉⣉⢉⣈â¢�⣀⣀⢀⣀⣀⣀⢀⣀⣀⣀⣀⣀ | 3 ⠉⠉â �⠉⠉⠉⠈⠈⠉⠉⠉⠉⠉⠉ | 4 == style opened grid=90x23 |0: 0-70 #b2c3b8,#1d2824, 71-89 d,#1d2824, -|1: 0-24 #becfc4,#26362d, 25-89 d,#26362d, -|2: 0-1 #ffffff,#4c6356, 2-61 #b2c3b8,#1d2824, 62-89 d,#1d2824, -|3: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-22 #e5eee5,#0d1410, 23-89 d,#0d1410, -|4: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-89 d,#0d1410, -|5: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-89 d,#0d1410, -|6: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-89 d,#0d1410, -|7: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-89 d,#0d1410, -|8: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-89 d,#0d1410, -|9: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-89 d,#0d1410, -|10: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-89 d,#0d1410, -|11: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-89 d,#0d1410, -|12: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-89 d,#0d1410, -|13: 0-1 #000000,#adcc91, 2-62 #becfc4,#26362d, 63-89 d,#26362d, -|14: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-6 #616f64,#0d1410,b 7-8 #e5eee5,#0d1410, 9-9 #c9b0e4,#0d1410, 10-12 #e5eee5,#0d1410, 13-15 #c9b0e4,#0d1410, 16-21 #b6ce94,#0d1410, 22-22 #e5eee5,#0d1410, 23-89 d,#0d1410, -|15: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-8 #b9e58f,#0d1410, 9-11 #c9b0e4,#0d1410, 12-25 #b9e58f,#0d1410, 26-89 d,#0d1410, -|16: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-17 #e5eee5,#0d1410, 18-19 #e9bf91,#0d1410, 20-20 #e5eee5,#0d1410, 21-89 d,#0d1410, -|17: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-89 d,#0d1410, -|18: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-89 d,#0d1410, -|19: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-89 d,#0d1410, -|20: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-89 d,#0d1410, -|21: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-89 d,#0d1410, -|22: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-89 d,#0d1410, +|1: 0-1 #ffffff,#887455, 2-2 d,#26362d, 3-34 #becfc4,#26362d, 35-89 d,#26362d, +|2: 0-1 #ffffff,#496656, 2-2 d,#1d2824, 3-28 #b2c3b8,#1d2824, 29-40 #d3b0d9,#1d2824, 41-62 #b2c3b8,#1d2824, 63-89 d,#1d2824, +|3: 0-0 d,#152019, 1-1 d,#0d1410, 2-85 d,#1d2824, 86-89 #b2c3b8,#1d2824, +|4: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-22 #e5eee5,#0d1410, 23-89 d,#0d1410, +|5: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-89 d,#0d1410, +|6: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-89 d,#0d1410, +|7: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-89 d,#0d1410, +|8: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-89 d,#0d1410, +|9: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-89 d,#0d1410, +|10: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-89 d,#0d1410, +|11: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-89 d,#0d1410, +|12: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-89 d,#0d1410, +|13: 0-1 #000000,#add38a, 2-2 d,#26362d, 3-28 #becfc4,#26362d, 29-41 #dfbce5,#26362d, 42-63 #becfc4,#26362d, 64-89 d,#26362d, +|14: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #616f64,#0d1410,b 7-8 #e5eee5,#0d1410, 9-9 #c9a7ed,#0d1410, 10-12 #e5eee5,#0d1410, 13-15 #c9a7ed,#0d1410, 16-21 #b8d88a,#0d1410, 22-22 #e5eee5,#0d1410, 23-89 d,#0d1410, +|15: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-8 #b9f480,#0d1410, 9-11 #c9a7ed,#0d1410, 12-25 #b9f480,#0d1410, 26-89 d,#0d1410, +|16: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-17 #e5eee5,#0d1410, 18-19 #f8c082,#0d1410, 20-20 #e5eee5,#0d1410, 21-89 d,#0d1410, +|17: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-89 d,#0d1410, +|18: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-89 d,#0d1410, +|19: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-89 d,#0d1410, +|20: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-89 d,#0d1410, +|21: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-89 d,#0d1410, +|22: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-89 d,#0d1410, == 9p opened grid=90x23 cursor=7,14,block |0: Newcol Joincol Find Grep Help Changelog Tutor Dump NextColor Debug Kill @0: 0-70 #b2c3b8,#1d2824,,tagline 71-89 d,#1d2824,,tagline -|1: New Tty Find Grep Joincol -@1: 0-24 #becfc4,#26362d,,tagline 25-89 d,#26362d,,tagline -|2: /tmp/pardes-snap/mini/cwd/commands.txt Save Tty Del Collapse -@2: 0-1 #ffffff,#4c6356,,tagline 2-61 #b2c3b8,#1d2824,,tagline 62-89 d,#1d2824,,tagline -|3: 1 @`Mini demo.zig` -@3: 0-0 d,#637f6a,,body 1-1 d,#0d1410,,body 2-6 #59675c,#0d1410,,body 7-22 #e5eee5,#0d1410,,body 23-89 d,#0d1410,,body -|4: -@4: 0-0 d,#637f6a,,body 1-1 d,#0d1410,,body 2-6 #59675c,#0d1410,,body 7-89 d,#0d1410,,body +|1: New Tty Find Grep Joincol Delcol +@1: 0-1 #ffffff,#887455,,tagline 2-2 d,#26362d,,tagline 3-34 #becfc4,#26362d,,tagline 35-89 d,#26362d,,tagline +|2: /tmp/pardes-snap/mini/cwd/commands.txt Save Tty Collapse Del +@2: 0-1 #ffffff,#496656,,tagline 2-2 d,#1d2824,,tagline 3-28 #b2c3b8,#1d2824,,tagline 29-40 #d3b0d9,#1d2824,,tagline 41-62 #b2c3b8,#1d2824,,tagline 63-89 d,#1d2824,,tagline +|3: Mini +@3: 0-0 d,#152019,,body 1-1 d,#0d1410,,body 2-85 d,#1d2824,,tagline 86-89 #b2c3b8,#1d2824,,tagline +|4: 1 @`Mini demo.zig` +@4: 0-0 d,#608269,,body 1-1 d,#0d1410,,body 2-6 #59675c,#0d1410,,body 7-22 #e5eee5,#0d1410,,body 23-89 d,#0d1410,,body |5: -@5: 0-0 d,#637f6a,,body 1-1 d,#0d1410,,body 2-6 #59675c,#0d1410,,body 7-89 d,#0d1410,,body +@5: 0-0 d,#608269,,body 1-1 d,#0d1410,,body 2-6 #59675c,#0d1410,,body 7-89 d,#0d1410,,body |6: -@6: 0-0 d,#637f6a,,body 1-1 d,#0d1410,,body 2-6 #59675c,#0d1410,,body 7-89 d,#0d1410,,body +@6: 0-0 d,#608269,,body 1-1 d,#0d1410,,body 2-6 #59675c,#0d1410,,body 7-89 d,#0d1410,,body |7: -@7: 0-0 d,#637f6a,,body 1-1 d,#0d1410,,body 2-6 #59675c,#0d1410,,body 7-89 d,#0d1410,,body +@7: 0-0 d,#608269,,body 1-1 d,#0d1410,,body 2-6 #59675c,#0d1410,,body 7-89 d,#0d1410,,body |8: -@8: 0-0 d,#637f6a,,body 1-1 d,#0d1410,,body 2-6 #59675c,#0d1410,,body 7-89 d,#0d1410,,body +@8: 0-0 d,#608269,,body 1-1 d,#0d1410,,body 2-6 #59675c,#0d1410,,body 7-89 d,#0d1410,,body |9: -@9: 0-0 d,#637f6a,,body 1-1 d,#0d1410,,body 2-6 #59675c,#0d1410,,body 7-89 d,#0d1410,,body +@9: 0-0 d,#608269,,body 1-1 d,#0d1410,,body 2-6 #59675c,#0d1410,,body 7-89 d,#0d1410,,body |10: -@10: 0-0 d,#637f6a,,body 1-1 d,#0d1410,,body 2-6 #59675c,#0d1410,,body 7-89 d,#0d1410,,body +@10: 0-0 d,#608269,,body 1-1 d,#0d1410,,body 2-6 #59675c,#0d1410,,body 7-89 d,#0d1410,,body |11: -@11: 0-0 d,#637f6a,,body 1-1 d,#0d1410,,body 2-6 #59675c,#0d1410,,body 7-89 d,#0d1410,,body +@11: 0-0 d,#608269,,body 1-1 d,#0d1410,,body 2-6 #59675c,#0d1410,,body 7-89 d,#0d1410,,body |12: -@12: 0-0 d,#637f6a,,body 1-1 d,#0d1410,,body 2-6 #59675c,#0d1410,,body 7-89 d,#0d1410,,body -|13: /tmp/pardes-snap/mini/cwd/Mini demo.zig Save Tty Del Collapse -@13: 0-1 #000000,#adcc91,,tagline 2-62 #becfc4,#26362d,,tagline 63-89 d,#26362d,,tagline +@12: 0-0 d,#608269,,body 1-1 d,#0d1410,,body 2-6 #59675c,#0d1410,,body 7-89 d,#0d1410,,body +|13: /tmp/pardes-snap/mini/cwd/Mini demo.zig Save Tty Collapse Del +@13: 0-1 #000000,#add38a,,tagline 2-2 d,#26362d,,tagline 3-28 #becfc4,#26362d,,tagline 29-41 #dfbce5,#26362d,,tagline 42-63 #becfc4,#26362d,,tagline 64-89 d,#26362d,,tagline |14: 1 â ­â �⣥⢩⣭⡭⣭⣬⣌⢭⣭⠌⠬⠅â �â � +14: 7="â ­" 8="â �" 9="⣥" 10="⢩" 11="⣭" 12="â¡­" 13="⣭" 14="⣬" 15="⣌" 16="⢭" 17="⣭" 18="â Œ" 19="â ¬" 20="â …" 21="â �" 22="â �" -@14: 0-0 d,#637f6a,,body 1-1 d,#0d1410,,body 2-6 #616f64,#0d1410,b,body 7-8 #e5eee5,#0d1410,,body 9-9 #c9b0e4,#0d1410,,body 10-12 #e5eee5,#0d1410,,body 13-15 #c9b0e4,#0d1410,,body 16-21 #b6ce94,#0d1410,,body 22-22 #e5eee5,#0d1410,,body 23-89 d,#0d1410,,body +@14: 0-0 d,#608269,,body 1-1 d,#0d1410,,body 2-6 #616f64,#0d1410,b,body 7-8 #e5eee5,#0d1410,,body 9-9 #c9a7ed,#0d1410,,body 10-12 #e5eee5,#0d1410,,body 13-15 #c9a7ed,#0d1410,,body 16-21 #b8d88a,#0d1410,,body 22-22 #e5eee5,#0d1410,,body 23-89 d,#0d1410,,body |15: 2 ⣂⢀⣉⣉⢉⣈â¢�⣀⣀⢀⣀⣀⣀⢀⣀⣀⣀⣀⣀ +15: 7="⣂" 8="⢀" 9="⣉" 10="⣉" 11="⢉" 12="⣈" 13="â¢�" 14="⣀" 15="⣀" 16="⢀" 17="⣀" 18="⣀" 19="⣀" 20="⢀" 21="⣀" 22="⣀" 23="⣀" 24="⣀" 25="⣀" -@15: 0-0 d,#637f6a,,body 1-1 d,#0d1410,,body 2-6 #59675c,#0d1410,,body 7-8 #b9e58f,#0d1410,,body 9-11 #c9b0e4,#0d1410,,body 12-25 #b9e58f,#0d1410,,body 26-89 d,#0d1410,,body +@15: 0-0 d,#608269,,body 1-1 d,#0d1410,,body 2-6 #59675c,#0d1410,,body 7-8 #b9f480,#0d1410,,body 9-11 #c9a7ed,#0d1410,,body 12-25 #b9f480,#0d1410,,body 26-89 d,#0d1410,,body |16: 3 ⠉⠉â �⠉⠉⠉⠈⠈⠉⠉⠉⠉⠉⠉ +16: 7="â ‰" 8="â ‰" 9="â �" 10="â ‰" 11="â ‰" 12="â ‰" 13="â ˆ" 14="â ˆ" 15="â ‰" 16="â ‰" 17="â ‰" 18="â ‰" 19="â ‰" 20="â ‰" -@16: 0-0 d,#637f6a,,body 1-1 d,#0d1410,,body 2-6 #59675c,#0d1410,,body 7-17 #e5eee5,#0d1410,,body 18-19 #e9bf91,#0d1410,,body 20-20 #e5eee5,#0d1410,,body 21-89 d,#0d1410,,body +@16: 0-0 d,#608269,,body 1-1 d,#0d1410,,body 2-6 #59675c,#0d1410,,body 7-17 #e5eee5,#0d1410,,body 18-19 #f8c082,#0d1410,,body 20-20 #e5eee5,#0d1410,,body 21-89 d,#0d1410,,body |17: 4 -@17: 0-0 d,#637f6a,,body 1-1 d,#0d1410,,body 2-6 #59675c,#0d1410,,body 7-89 d,#0d1410,,body +@17: 0-0 d,#608269,,body 1-1 d,#0d1410,,body 2-6 #59675c,#0d1410,,body 7-89 d,#0d1410,,body |18: -@18: 0-0 d,#637f6a,,body 1-1 d,#0d1410,,body 2-6 #59675c,#0d1410,,body 7-89 d,#0d1410,,body +@18: 0-0 d,#608269,,body 1-1 d,#0d1410,,body 2-6 #59675c,#0d1410,,body 7-89 d,#0d1410,,body |19: -@19: 0-0 d,#637f6a,,body 1-1 d,#0d1410,,body 2-6 #59675c,#0d1410,,body 7-89 d,#0d1410,,body +@19: 0-0 d,#608269,,body 1-1 d,#0d1410,,body 2-6 #59675c,#0d1410,,body 7-89 d,#0d1410,,body |20: -@20: 0-0 d,#637f6a,,body 1-1 d,#0d1410,,body 2-6 #59675c,#0d1410,,body 7-89 d,#0d1410,,body +@20: 0-0 d,#608269,,body 1-1 d,#0d1410,,body 2-6 #59675c,#0d1410,,body 7-89 d,#0d1410,,body |21: -@21: 0-0 d,#637f6a,,body 1-1 d,#0d1410,,body 2-6 #59675c,#0d1410,,body 7-89 d,#0d1410,,body +@21: 0-0 d,#608269,,body 1-1 d,#0d1410,,body 2-6 #59675c,#0d1410,,body 7-89 d,#0d1410,,body |22: -@22: 0-0 d,#637f6a,,body 1-1 d,#0d1410,,body 2-6 #59675c,#0d1410,,body 7-89 d,#0d1410,,body +@22: 0-0 d,#608269,,body 1-1 d,#0d1410,,body 2-6 #59675c,#0d1410,,body 7-89 d,#0d1410,,body == style colors-off grid=90x23 -|14: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-6 #616f64,#0d1410,b 7-22 #e5eee5,#0d1410, 23-89 d,#0d1410, -|15: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-25 #e5eee5,#0d1410, 26-89 d,#0d1410, -|16: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-20 #e5eee5,#0d1410, 21-89 d,#0d1410, -== 9p colors-off grid=90x23 cursor=7,14,block -|14: 1 â ­â �⣥⢩⣭⡭⣭⣬⣌⢭⣭⠌⠬⠅â �â � -+14: 7="â ­" 8="â �" 9="⣥" 10="⢩" 11="⣭" 12="â¡­" 13="⣭" 14="⣬" 15="⣌" 16="⢭" 17="⣭" 18="â Œ" 19="â ¬" 20="â …" 21="â �" 22="â �" -@14: 0-0 d,#637f6a,,body 1-1 d,#0d1410,,body 2-6 #616f64,#0d1410,b,body 7-22 #e5eee5,#0d1410,,body 23-89 d,#0d1410,,body -|15: 2 ⣂⢀⣉⣉⢉⣈â¢�⣀⣀⢀⣀⣀⣀⢀⣀⣀⣀⣀⣀ -+15: 7="⣂" 8="⢀" 9="⣉" 10="⣉" 11="⢉" 12="⣈" 13="â¢�" 14="⣀" 15="⣀" 16="⢀" 17="⣀" 18="⣀" 19="⣀" 20="⢀" 21="⣀" 22="⣀" 23="⣀" 24="⣀" 25="⣀" -@15: 0-0 d,#637f6a,,body 1-1 d,#0d1410,,body 2-6 #59675c,#0d1410,,body 7-25 #e5eee5,#0d1410,,body 26-89 d,#0d1410,,body -|16: 3 ⠉⠉â �⠉⠉⠉⠈⠈⠉⠉⠉⠉⠉⠉ -+16: 7="â ‰" 8="â ‰" 9="â �" 10="â ‰" 11="â ‰" 12="â ‰" 13="â ˆ" 14="â ˆ" 15="â ‰" 16="â ‰" 17="â ‰" 18="â ‰" 19="â ‰" 20="â ‰" -@16: 0-0 d,#637f6a,,body 1-1 d,#0d1410,,body 2-6 #59675c,#0d1410,,body 7-20 #e5eee5,#0d1410,,body 21-89 d,#0d1410,,body +|3: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-22 #e5eee5,#0d1410, 23-89 d,#0d1410, +|4: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-89 d,#0d1410, +|14: 0-0 d,#152019, 1-1 d,#0d1410, 2-83 d,#1d2824, 84-89 #b2c3b8,#1d2824, +|15: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #616f64,#0d1410,b 7-22 #e5eee5,#0d1410, 23-89 d,#0d1410, +|16: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-25 #e5eee5,#0d1410, 26-89 d,#0d1410, +|17: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-20 #e5eee5,#0d1410, 21-89 d,#0d1410, +== 9p colors-off grid=90x23 cursor=7,15,block +|3: 1 @`Mini demo.zig` +@3: 0-0 d,#608269,,body 1-1 d,#0d1410,,body 2-6 #59675c,#0d1410,,body 7-22 #e5eee5,#0d1410,,body 23-89 d,#0d1410,,body +|4: +@4: 0-0 d,#608269,,body 1-1 d,#0d1410,,body 2-6 #59675c,#0d1410,,body 7-89 d,#0d1410,,body +|14: Colors +@14: 0-0 d,#152019,,body 1-1 d,#0d1410,,body 2-83 d,#1d2824,,tagline 84-89 #b2c3b8,#1d2824,,tagline +|15: 1 â ­â �⣥⢩⣭⡭⣭⣬⣌⢭⣭⠌⠬⠅â �â � ++15: 7="â ­" 8="â �" 9="⣥" 10="⢩" 11="⣭" 12="â¡­" 13="⣭" 14="⣬" 15="⣌" 16="⢭" 17="⣭" 18="â Œ" 19="â ¬" 20="â …" 21="â �" 22="â �" +@15: 0-0 d,#608269,,body 1-1 d,#0d1410,,body 2-6 #616f64,#0d1410,b,body 7-22 #e5eee5,#0d1410,,body 23-89 d,#0d1410,,body +|16: 2 ⣂⢀⣉⣉⢉⣈â¢�⣀⣀⢀⣀⣀⣀⢀⣀⣀⣀⣀⣀ ++16: 7="⣂" 8="⢀" 9="⣉" 10="⣉" 11="⢉" 12="⣈" 13="â¢�" 14="⣀" 15="⣀" 16="⢀" 17="⣀" 18="⣀" 19="⣀" 20="⢀" 21="⣀" 22="⣀" 23="⣀" 24="⣀" 25="⣀" +@16: 0-0 d,#608269,,body 1-1 d,#0d1410,,body 2-6 #59675c,#0d1410,,body 7-25 #e5eee5,#0d1410,,body 26-89 d,#0d1410,,body +|17: 3 ⠉⠉â �⠉⠉⠉⠈⠈⠉⠉⠉⠉⠉⠉ ++17: 7="â ‰" 8="â ‰" 9="â �" 10="â ‰" 11="â ‰" 12="â ‰" 13="â ˆ" 14="â ˆ" 15="â ‰" 16="â ‰" 17="â ‰" 18="â ‰" 19="â ‰" 20="â ‰" +@17: 0-0 d,#608269,,body 1-1 d,#0d1410,,body 2-6 #59675c,#0d1410,,body 7-20 #e5eee5,#0d1410,,body 21-89 d,#0d1410,,body +|18: 4 +@18: 0-0 d,#608269,,body 1-1 d,#0d1410,,body 2-6 #59675c,#0d1410,,body 7-89 d,#0d1410,,body == style colors-on grid=90x23 -|14: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-6 #616f64,#0d1410,b 7-8 #e5eee5,#0d1410, 9-9 #c9b0e4,#0d1410, 10-12 #e5eee5,#0d1410, 13-15 #c9b0e4,#0d1410, 16-21 #b6ce94,#0d1410, 22-22 #e5eee5,#0d1410, 23-89 d,#0d1410, -|15: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-8 #b9e58f,#0d1410, 9-11 #c9b0e4,#0d1410, 12-25 #b9e58f,#0d1410, 26-89 d,#0d1410, -|16: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-17 #e5eee5,#0d1410, 18-19 #e9bf91,#0d1410, 20-20 #e5eee5,#0d1410, 21-89 d,#0d1410, -== snap resized grid=105x27 cursor=7,16 +|15: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #616f64,#0d1410,b 7-8 #e5eee5,#0d1410, 9-9 #c9a7ed,#0d1410, 10-12 #e5eee5,#0d1410, 13-15 #c9a7ed,#0d1410, 16-21 #b8d88a,#0d1410, 22-22 #e5eee5,#0d1410, 23-89 d,#0d1410, +|16: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-8 #b9f480,#0d1410, 9-11 #c9a7ed,#0d1410, 12-25 #b9f480,#0d1410, 26-89 d,#0d1410, +|17: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-17 #e5eee5,#0d1410, 18-19 #f8c082,#0d1410, 20-20 #e5eee5,#0d1410, 21-89 d,#0d1410, +== snap resized grid=105x27 cursor=7,17 |Newcol Joincol Find Grep Help Changelog Tutor Dump NextColor Debug Kill -|New Tty Find Grep Joincol -| /tmp/pardes-snap/mini/cwd/commands.txt Save Tty Del Collapse +| New Tty Find Grep Joincol Delcol +| /tmp/pardes-snap/mini/cwd/commands.txt Save Tty Collapse Del | 1 @`Mini demo.zig` | | @@ -125,66 +136,67 @@ | | | -| /tmp/pardes-snap/mini/cwd/Mini demo.zig Save Tty Del Collapse +| /tmp/pardes-snap/mini/cwd/Mini demo.zig Save Tty Collapse Del +| Colors | 1 â ­â �⣥⢩⣭⡭⣭⣬⣌⢭⣭⠌⠬⠅â �â � | 2 ⣂⢀⣉⣉⢉⣈â¢�⣀⣀⢀⣀⣀⣀⢀⣀⣀⣀⣀⣀ | 3 ⠉⠉â �⠉⠉⠉⠈⠈⠉⠉⠉⠉⠉⠉ | 4 -== 9p resized grid=105x27 cursor=7,16,block +== 9p resized grid=105x27 cursor=7,17,block |0: Newcol Joincol Find Grep Help Changelog Tutor Dump NextColor Debug Kill @0: 0-70 #b2c3b8,#1d2824,,tagline 71-104 d,#1d2824,,tagline -|1: New Tty Find Grep Joincol -@1: 0-24 #becfc4,#26362d,,tagline 25-104 d,#26362d,,tagline -|2: /tmp/pardes-snap/mini/cwd/commands.txt Save Tty Del Collapse -@2: 0-1 #ffffff,#4c6356,,tagline 2-61 #b2c3b8,#1d2824,,tagline 62-104 d,#1d2824,,tagline +|1: New Tty Find Grep Joincol Delcol +@1: 0-1 #ffffff,#887455,,tagline 2-2 d,#26362d,,tagline 3-34 #becfc4,#26362d,,tagline 35-104 d,#26362d,,tagline +|2: /tmp/pardes-snap/mini/cwd/commands.txt Save Tty Collapse Del +@2: 0-1 #ffffff,#496656,,tagline 2-2 d,#1d2824,,tagline 3-28 #b2c3b8,#1d2824,,tagline 29-40 #d3b0d9,#1d2824,,tagline 41-62 #b2c3b8,#1d2824,,tagline 63-104 d,#1d2824,,tagline |3: 1 @`Mini demo.zig` -@3: 0-0 d,#637f6a,,body 1-1 d,#0d1410,,body 2-6 #59675c,#0d1410,,body 7-22 #e5eee5,#0d1410,,body 23-104 d,#0d1410,,body +@3: 0-0 d,#608269,,body 1-1 d,#0d1410,,body 2-6 #59675c,#0d1410,,body 7-22 #e5eee5,#0d1410,,body 23-104 d,#0d1410,,body |4: -@4: 0-0 d,#637f6a,,body 1-1 d,#0d1410,,body 2-6 #59675c,#0d1410,,body 7-104 d,#0d1410,,body +@4: 0-0 d,#608269,,body 1-1 d,#0d1410,,body 2-6 #59675c,#0d1410,,body 7-104 d,#0d1410,,body |5: -@5: 0-0 d,#637f6a,,body 1-1 d,#0d1410,,body 2-6 #59675c,#0d1410,,body 7-104 d,#0d1410,,body +@5: 0-0 d,#608269,,body 1-1 d,#0d1410,,body 2-6 #59675c,#0d1410,,body 7-104 d,#0d1410,,body |6: -@6: 0-0 d,#637f6a,,body 1-1 d,#0d1410,,body 2-6 #59675c,#0d1410,,body 7-104 d,#0d1410,,body +@6: 0-0 d,#608269,,body 1-1 d,#0d1410,,body 2-6 #59675c,#0d1410,,body 7-104 d,#0d1410,,body |7: -@7: 0-0 d,#637f6a,,body 1-1 d,#0d1410,,body 2-6 #59675c,#0d1410,,body 7-104 d,#0d1410,,body +@7: 0-0 d,#608269,,body 1-1 d,#0d1410,,body 2-6 #59675c,#0d1410,,body 7-104 d,#0d1410,,body |8: -@8: 0-0 d,#637f6a,,body 1-1 d,#0d1410,,body 2-6 #59675c,#0d1410,,body 7-104 d,#0d1410,,body +@8: 0-0 d,#608269,,body 1-1 d,#0d1410,,body 2-6 #59675c,#0d1410,,body 7-104 d,#0d1410,,body |9: -@9: 0-0 d,#637f6a,,body 1-1 d,#0d1410,,body 2-6 #59675c,#0d1410,,body 7-104 d,#0d1410,,body +@9: 0-0 d,#608269,,body 1-1 d,#0d1410,,body 2-6 #59675c,#0d1410,,body 7-104 d,#0d1410,,body |10: -@10: 0-0 d,#637f6a,,body 1-1 d,#0d1410,,body 2-6 #59675c,#0d1410,,body 7-104 d,#0d1410,,body +@10: 0-0 d,#608269,,body 1-1 d,#0d1410,,body 2-6 #59675c,#0d1410,,body 7-104 d,#0d1410,,body |11: -@11: 0-0 d,#637f6a,,body 1-1 d,#0d1410,,body 2-6 #59675c,#0d1410,,body 7-104 d,#0d1410,,body +@11: 0-0 d,#608269,,body 1-1 d,#0d1410,,body 2-6 #59675c,#0d1410,,body 7-104 d,#0d1410,,body |12: -@12: 0-0 d,#637f6a,,body 1-1 d,#0d1410,,body 2-6 #59675c,#0d1410,,body 7-104 d,#0d1410,,body +@12: 0-0 d,#608269,,body 1-1 d,#0d1410,,body 2-6 #59675c,#0d1410,,body 7-104 d,#0d1410,,body |13: -@13: 0-0 d,#637f6a,,body 1-1 d,#0d1410,,body 2-6 #59675c,#0d1410,,body 7-104 d,#0d1410,,body +@13: 0-0 d,#608269,,body 1-1 d,#0d1410,,body 2-6 #59675c,#0d1410,,body 7-104 d,#0d1410,,body |14: -@14: 0-0 d,#637f6a,,body 1-1 d,#0d1410,,body 2-6 #59675c,#0d1410,,body 7-104 d,#0d1410,,body -|15: /tmp/pardes-snap/mini/cwd/Mini demo.zig Save Tty Del Collapse -@15: 0-1 #000000,#adcc91,,tagline 2-62 #becfc4,#26362d,,tagline 63-104 d,#26362d,,tagline -|16: 1 â ­â �⣥⢩⣭⡭⣭⣬⣌⢭⣭⠌⠬⠅â �â � -+16: 7="â ­" 8="â �" 9="⣥" 10="⢩" 11="⣭" 12="â¡­" 13="⣭" 14="⣬" 15="⣌" 16="⢭" 17="⣭" 18="â Œ" 19="â ¬" 20="â …" 21="â �" 22="â �" -@16: 0-0 d,#637f6a,,body 1-1 d,#0d1410,,body 2-6 #616f64,#0d1410,b,body 7-8 #e5eee5,#0d1410,,body 9-9 #c9b0e4,#0d1410,,body 10-12 #e5eee5,#0d1410,,body 13-15 #c9b0e4,#0d1410,,body 16-21 #b6ce94,#0d1410,,body 22-22 #e5eee5,#0d1410,,body 23-104 d,#0d1410,,body -|17: 2 ⣂⢀⣉⣉⢉⣈â¢�⣀⣀⢀⣀⣀⣀⢀⣀⣀⣀⣀⣀ -+17: 7="⣂" 8="⢀" 9="⣉" 10="⣉" 11="⢉" 12="⣈" 13="â¢�" 14="⣀" 15="⣀" 16="⢀" 17="⣀" 18="⣀" 19="⣀" 20="⢀" 21="⣀" 22="⣀" 23="⣀" 24="⣀" 25="⣀" -@17: 0-0 d,#637f6a,,body 1-1 d,#0d1410,,body 2-6 #59675c,#0d1410,,body 7-8 #b9e58f,#0d1410,,body 9-11 #c9b0e4,#0d1410,,body 12-25 #b9e58f,#0d1410,,body 26-104 d,#0d1410,,body -|18: 3 ⠉⠉â �⠉⠉⠉⠈⠈⠉⠉⠉⠉⠉⠉ -+18: 7="â ‰" 8="â ‰" 9="â �" 10="â ‰" 11="â ‰" 12="â ‰" 13="â ˆ" 14="â ˆ" 15="â ‰" 16="â ‰" 17="â ‰" 18="â ‰" 19="â ‰" 20="â ‰" -@18: 0-0 d,#637f6a,,body 1-1 d,#0d1410,,body 2-6 #59675c,#0d1410,,body 7-17 #e5eee5,#0d1410,,body 18-19 #e9bf91,#0d1410,,body 20-20 #e5eee5,#0d1410,,body 21-104 d,#0d1410,,body -|19: 4 -@19: 0-0 d,#637f6a,,body 1-1 d,#0d1410,,body 2-6 #59675c,#0d1410,,body 7-104 d,#0d1410,,body -|20: -@20: 0-0 d,#637f6a,,body 1-1 d,#0d1410,,body 2-6 #59675c,#0d1410,,body 7-104 d,#0d1410,,body +@14: 0-0 d,#608269,,body 1-1 d,#0d1410,,body 2-6 #59675c,#0d1410,,body 7-104 d,#0d1410,,body +|15: /tmp/pardes-snap/mini/cwd/Mini demo.zig Save Tty Collapse Del +@15: 0-1 #000000,#add38a,,tagline 2-2 d,#26362d,,tagline 3-28 #becfc4,#26362d,,tagline 29-41 #dfbce5,#26362d,,tagline 42-63 #becfc4,#26362d,,tagline 64-104 d,#26362d,,tagline +|16: Colors +@16: 0-0 d,#152019,,body 1-1 d,#0d1410,,body 2-98 d,#1d2824,,tagline 99-104 #b2c3b8,#1d2824,,tagline +|17: 1 â ­â �⣥⢩⣭⡭⣭⣬⣌⢭⣭⠌⠬⠅â �â � ++17: 7="â ­" 8="â �" 9="⣥" 10="⢩" 11="⣭" 12="â¡­" 13="⣭" 14="⣬" 15="⣌" 16="⢭" 17="⣭" 18="â Œ" 19="â ¬" 20="â …" 21="â �" 22="â �" +@17: 0-0 d,#608269,,body 1-1 d,#0d1410,,body 2-6 #616f64,#0d1410,b,body 7-8 #e5eee5,#0d1410,,body 9-9 #c9a7ed,#0d1410,,body 10-12 #e5eee5,#0d1410,,body 13-15 #c9a7ed,#0d1410,,body 16-21 #b8d88a,#0d1410,,body 22-22 #e5eee5,#0d1410,,body 23-104 d,#0d1410,,body +|18: 2 ⣂⢀⣉⣉⢉⣈â¢�⣀⣀⢀⣀⣀⣀⢀⣀⣀⣀⣀⣀ ++18: 7="⣂" 8="⢀" 9="⣉" 10="⣉" 11="⢉" 12="⣈" 13="â¢�" 14="⣀" 15="⣀" 16="⢀" 17="⣀" 18="⣀" 19="⣀" 20="⢀" 21="⣀" 22="⣀" 23="⣀" 24="⣀" 25="⣀" +@18: 0-0 d,#608269,,body 1-1 d,#0d1410,,body 2-6 #59675c,#0d1410,,body 7-8 #b9f480,#0d1410,,body 9-11 #c9a7ed,#0d1410,,body 12-25 #b9f480,#0d1410,,body 26-104 d,#0d1410,,body +|19: 3 ⠉⠉â �⠉⠉⠉⠈⠈⠉⠉⠉⠉⠉⠉ ++19: 7="â ‰" 8="â ‰" 9="â �" 10="â ‰" 11="â ‰" 12="â ‰" 13="â ˆ" 14="â ˆ" 15="â ‰" 16="â ‰" 17="â ‰" 18="â ‰" 19="â ‰" 20="â ‰" +@19: 0-0 d,#608269,,body 1-1 d,#0d1410,,body 2-6 #59675c,#0d1410,,body 7-17 #e5eee5,#0d1410,,body 18-19 #f8c082,#0d1410,,body 20-20 #e5eee5,#0d1410,,body 21-104 d,#0d1410,,body +|20: 4 +@20: 0-0 d,#608269,,body 1-1 d,#0d1410,,body 2-6 #59675c,#0d1410,,body 7-104 d,#0d1410,,body |21: -@21: 0-0 d,#637f6a,,body 1-1 d,#0d1410,,body 2-6 #59675c,#0d1410,,body 7-104 d,#0d1410,,body +@21: 0-0 d,#608269,,body 1-1 d,#0d1410,,body 2-6 #59675c,#0d1410,,body 7-104 d,#0d1410,,body |22: -@22: 0-0 d,#637f6a,,body 1-1 d,#0d1410,,body 2-6 #59675c,#0d1410,,body 7-104 d,#0d1410,,body +@22: 0-0 d,#608269,,body 1-1 d,#0d1410,,body 2-6 #59675c,#0d1410,,body 7-104 d,#0d1410,,body |23: -@23: 0-0 d,#637f6a,,body 1-1 d,#0d1410,,body 2-6 #59675c,#0d1410,,body 7-104 d,#0d1410,,body +@23: 0-0 d,#608269,,body 1-1 d,#0d1410,,body 2-6 #59675c,#0d1410,,body 7-104 d,#0d1410,,body |24: -@24: 0-0 d,#637f6a,,body 1-1 d,#0d1410,,body 2-6 #59675c,#0d1410,,body 7-104 d,#0d1410,,body +@24: 0-0 d,#608269,,body 1-1 d,#0d1410,,body 2-6 #59675c,#0d1410,,body 7-104 d,#0d1410,,body |25: -@25: 0-0 d,#637f6a,,body 1-1 d,#0d1410,,body 2-6 #59675c,#0d1410,,body 7-104 d,#0d1410,,body +@25: 0-0 d,#608269,,body 1-1 d,#0d1410,,body 2-6 #59675c,#0d1410,,body 7-104 d,#0d1410,,body |26: -@26: 0-0 d,#637f6a,,body 1-1 d,#0d1410,,body 2-6 #59675c,#0d1410,,body 7-104 d,#0d1410,,body +@26: 0-0 d,#608269,,body 1-1 d,#0d1410,,body 2-6 #59675c,#0d1410,,body 7-104 d,#0d1410,,body diff --git a/test/snapshots/modal.golden b/test/snapshots/modal.golden index ca89416e..5f313dd3 100644 --- a/test/snapshots/modal.golden +++ b/test/snapshots/modal.golden @@ -1,7 +1,7 @@ == snap top grid=100x31 cursor=2,3 |Newcol Joincol Find Grep Help Changelog Tutor Dump NextColor Debug Kill -|New Tty Find Grep Joincol New Tty Find Grep Joincol -| /tmp/pardes-snap/modal/cwd Save Tty Del Togglett /tmp/pardes-snap/modal/cwd Save Tty Del Togglett +| New Tty Find Grep Joincol Delcol New Tty Find Grep Joincol Delcol +| /tmp/pardes-snap/modal/cwd Tty Save Mode Filter /tmp/pardes-snap/modal/cwd Tty Save Mode Filter | ls ls | words.txt words.txt | printf 'one two three\nfour five six\nseven ei @@ -16,54 +16,54 @@ | | | -| /tmp/pardes-snap/modal/cwd Save Tty Del Togglett +| /tmp/pardes-snap/modal/cwd Tty Save Mode Filter | ls | words.txt == snap moved grid=100x31 cursor=8,5 == snap xsel grid=100x31 cursor=48,5 == style xsel grid=100x31 |0: 0-70 #b2c3b8,#1d2824, 71-99 d,#1d2824, -|1: 0-24 #becfc4,#26362d, 25-49 d,#26362d, 50-74 #b2c3b8,#1d2824, 75-99 d,#1d2824, -|2: 0-1 #000000,#adcc91, 2-49 #becfc4,#26362d, 50-51 #ffffff,#4c6356, 52-99 #b2c3b8,#1d2824, -|3: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-49 #e5eee5,#0d1410, 50-50 d,#637f6a, 51-51 d,#0d1410, 52-99 #e5eee5,#0d1410, -|4: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-49 #e5eee5,#0d1410, 50-50 d,#637f6a, 51-51 d,#0d1410, 52-99 #e5eee5,#0d1410, -|5: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-48 #f5f7ee,#405d4b, 49-49 d,#0d1410, 50-50 d,#637f6a, 51-99 d,#0d1410, -|6: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-49 #e5eee5,#0d1410, 50-50 d,#637f6a, 51-51 d,#0d1410, 52-99 #e5eee5,#0d1410, -|7: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-49 #e5eee5,#0d1410, 50-50 d,#637f6a, 51-51 d,#0d1410, 52-99 #e5eee5,#0d1410, -|8: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-49 #e5eee5,#0d1410, 50-50 d,#637f6a, 51-51 d,#0d1410, 52-99 #e5eee5,#0d1410, -|9: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-49 #e5eee5,#0d1410, 50-50 d,#637f6a, 51-51 d,#0d1410, 52-99 #e5eee5,#0d1410, -|10: 0-0 d,#637f6a, 1-49 d,#0d1410, 50-50 d,#637f6a, 51-51 d,#0d1410, 52-99 #e5eee5,#0d1410, -|11: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-49 #e5eee5,#0d1410, 50-50 d,#637f6a, 51-51 d,#0d1410, 52-99 #e5eee5,#0d1410, -|12: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-49 #e5eee5,#0d1410, 50-50 d,#637f6a, 51-51 d,#0d1410, 52-99 #e5eee5,#0d1410, -|13: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-49 #e5eee5,#0d1410, 50-50 d,#637f6a, 51-51 d,#0d1410, 52-99 #e5eee5,#0d1410, -|14: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-49 #e5eee5,#0d1410, 50-50 d,#637f6a, 51-51 d,#0d1410, 52-99 #e5eee5,#0d1410, -|15: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-49 #e5eee5,#0d1410, 50-50 d,#637f6a, 51-51 d,#0d1410, 52-99 #e5eee5,#0d1410, -|16: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-49 #e5eee5,#0d1410, 50-50 d,#637f6a, 51-51 d,#0d1410, 52-99 #e5eee5,#0d1410, -|17: 0-1 #ffffff,#4c6356, 2-49 #b2c3b8,#1d2824, 50-50 d,#637f6a, 51-51 d,#0d1410, 52-99 #e5eee5,#0d1410, -|18: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-49 #e5eee5,#0d1410, 50-50 d,#637f6a, 51-51 d,#0d1410, 52-99 #e5eee5,#0d1410, -|19: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-49 #e5eee5,#0d1410, 50-50 d,#637f6a, 51-51 d,#0d1410, 52-99 #e5eee5,#0d1410, -|20: 0-0 d,#637f6a, 1-49 d,#0d1410, 50-50 d,#637f6a, 51-51 d,#0d1410, 52-99 #e5eee5,#0d1410, -|21: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-49 #e5eee5,#0d1410, 50-50 d,#637f6a, 51-51 d,#0d1410, 52-99 #e5eee5,#0d1410, -|22: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-49 #e5eee5,#0d1410, 50-50 d,#637f6a, 51-51 d,#0d1410, 52-99 #e5eee5,#0d1410, -|23: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-49 #e5eee5,#0d1410, 50-50 d,#637f6a, 51-51 d,#0d1410, 52-99 #e5eee5,#0d1410, -|24: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-49 #e5eee5,#0d1410, 50-50 d,#637f6a, 51-51 d,#0d1410, 52-99 #e5eee5,#0d1410, -|25: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-49 #e5eee5,#0d1410, 50-50 d,#637f6a, 51-51 d,#0d1410, 52-99 #e5eee5,#0d1410, -|26: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-49 #e5eee5,#0d1410, 50-50 d,#637f6a, 51-51 d,#0d1410, 52-99 #e5eee5,#0d1410, -|27: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-49 #e5eee5,#0d1410, 50-50 d,#637f6a, 51-51 d,#0d1410, 52-99 #e5eee5,#0d1410, -|28: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-49 #e5eee5,#0d1410, 50-50 d,#637f6a, 51-51 d,#0d1410, 52-99 #e5eee5,#0d1410, -|29: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-49 #e5eee5,#0d1410, 50-50 d,#637f6a, 51-51 d,#0d1410, 52-99 #e5eee5,#0d1410, -|30: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-49 #e5eee5,#0d1410, 50-50 d,#637f6a, 51-51 d,#0d1410, 52-99 #e5eee5,#0d1410, +|1: 0-1 #ffffff,#887455, 2-2 d,#26362d, 3-34 #becfc4,#26362d, 35-49 d,#26362d, 50-51 #ffffff,#887455, 52-52 d,#1d2824, 53-84 #b2c3b8,#1d2824, 85-99 d,#1d2824, +|2: 0-1 #000000,#add38a, 2-2 d,#26362d, 3-29 #becfc4,#26362d, 30-32 #dfbce5,#26362d, 33-49 #becfc4,#26362d, 50-51 #ffffff,#496656, 52-52 d,#1d2824, 53-79 #b2c3b8,#1d2824, 80-82 #d3b0d9,#1d2824, 83-99 #b2c3b8,#1d2824, +|3: 0-0 d,#608269, 1-1 d,#0d1410, 2-49 #e5eee5,#0d1410, 50-50 d,#608269, 51-51 d,#0d1410, 52-99 #e5eee5,#0d1410, +|4: 0-0 d,#608269, 1-1 d,#0d1410, 2-49 #e5eee5,#0d1410, 50-50 d,#608269, 51-51 d,#0d1410, 52-99 #e5eee5,#0d1410, +|5: 0-0 d,#608269, 1-1 d,#0d1410, 2-48 #f5f7ee,#3c614a, 49-49 d,#0d1410, 50-50 d,#608269, 51-99 d,#0d1410, +|6: 0-0 d,#608269, 1-1 d,#0d1410, 2-49 #e5eee5,#0d1410, 50-50 d,#608269, 51-51 d,#0d1410, 52-99 #e5eee5,#0d1410, +|7: 0-0 d,#608269, 1-1 d,#0d1410, 2-49 #e5eee5,#0d1410, 50-50 d,#608269, 51-51 d,#0d1410, 52-99 #e5eee5,#0d1410, +|8: 0-0 d,#608269, 1-1 d,#0d1410, 2-49 #e5eee5,#0d1410, 50-50 d,#608269, 51-51 d,#0d1410, 52-99 #e5eee5,#0d1410, +|9: 0-0 d,#608269, 1-1 d,#0d1410, 2-49 #e5eee5,#0d1410, 50-50 d,#608269, 51-51 d,#0d1410, 52-99 #e5eee5,#0d1410, +|10: 0-0 d,#608269, 1-49 d,#0d1410, 50-50 d,#608269, 51-51 d,#0d1410, 52-99 #e5eee5,#0d1410, +|11: 0-0 d,#608269, 1-1 d,#0d1410, 2-49 #e5eee5,#0d1410, 50-50 d,#608269, 51-51 d,#0d1410, 52-99 #e5eee5,#0d1410, +|12: 0-0 d,#608269, 1-1 d,#0d1410, 2-49 #e5eee5,#0d1410, 50-50 d,#608269, 51-51 d,#0d1410, 52-99 #e5eee5,#0d1410, +|13: 0-0 d,#608269, 1-1 d,#0d1410, 2-49 #e5eee5,#0d1410, 50-50 d,#608269, 51-51 d,#0d1410, 52-99 #e5eee5,#0d1410, +|14: 0-0 d,#608269, 1-1 d,#0d1410, 2-49 #e5eee5,#0d1410, 50-50 d,#608269, 51-51 d,#0d1410, 52-99 #e5eee5,#0d1410, +|15: 0-0 d,#608269, 1-1 d,#0d1410, 2-49 #e5eee5,#0d1410, 50-50 d,#608269, 51-51 d,#0d1410, 52-99 #e5eee5,#0d1410, +|16: 0-0 d,#608269, 1-1 d,#0d1410, 2-49 #e5eee5,#0d1410, 50-50 d,#608269, 51-51 d,#0d1410, 52-99 #e5eee5,#0d1410, +|17: 0-1 #ffffff,#496656, 2-2 d,#1d2824, 3-29 #b2c3b8,#1d2824, 30-32 #d3b0d9,#1d2824, 33-49 #b2c3b8,#1d2824, 50-50 d,#608269, 51-51 d,#0d1410, 52-99 #e5eee5,#0d1410, +|18: 0-0 d,#608269, 1-1 d,#0d1410, 2-49 #e5eee5,#0d1410, 50-50 d,#608269, 51-51 d,#0d1410, 52-99 #e5eee5,#0d1410, +|19: 0-0 d,#608269, 1-1 d,#0d1410, 2-49 #e5eee5,#0d1410, 50-50 d,#608269, 51-51 d,#0d1410, 52-99 #e5eee5,#0d1410, +|20: 0-0 d,#608269, 1-49 d,#0d1410, 50-50 d,#608269, 51-51 d,#0d1410, 52-99 #e5eee5,#0d1410, +|21: 0-0 d,#608269, 1-1 d,#0d1410, 2-49 #e5eee5,#0d1410, 50-50 d,#608269, 51-51 d,#0d1410, 52-99 #e5eee5,#0d1410, +|22: 0-0 d,#608269, 1-1 d,#0d1410, 2-49 #e5eee5,#0d1410, 50-50 d,#608269, 51-51 d,#0d1410, 52-99 #e5eee5,#0d1410, +|23: 0-0 d,#608269, 1-1 d,#0d1410, 2-49 #e5eee5,#0d1410, 50-50 d,#608269, 51-51 d,#0d1410, 52-99 #e5eee5,#0d1410, +|24: 0-0 d,#608269, 1-1 d,#0d1410, 2-49 #e5eee5,#0d1410, 50-50 d,#608269, 51-51 d,#0d1410, 52-99 #e5eee5,#0d1410, +|25: 0-0 d,#608269, 1-1 d,#0d1410, 2-49 #e5eee5,#0d1410, 50-50 d,#608269, 51-51 d,#0d1410, 52-99 #e5eee5,#0d1410, +|26: 0-0 d,#608269, 1-1 d,#0d1410, 2-49 #e5eee5,#0d1410, 50-50 d,#608269, 51-51 d,#0d1410, 52-99 #e5eee5,#0d1410, +|27: 0-0 d,#608269, 1-1 d,#0d1410, 2-49 #e5eee5,#0d1410, 50-50 d,#608269, 51-51 d,#0d1410, 52-99 #e5eee5,#0d1410, +|28: 0-0 d,#608269, 1-1 d,#0d1410, 2-49 #e5eee5,#0d1410, 50-50 d,#608269, 51-51 d,#0d1410, 52-99 #e5eee5,#0d1410, +|29: 0-0 d,#608269, 1-1 d,#0d1410, 2-49 #e5eee5,#0d1410, 50-50 d,#608269, 51-51 d,#0d1410, 52-99 #e5eee5,#0d1410, +|30: 0-0 d,#608269, 1-1 d,#0d1410, 2-49 #e5eee5,#0d1410, 50-50 d,#608269, 51-51 d,#0d1410, 52-99 #e5eee5,#0d1410, == snap xsel2 grid=100x31 cursor=13,6 == snap yanked grid=100x31 cursor=13,6 == snap vsel grid=100x31 cursor=14,7 == style vsel grid=100x31 -|5: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-49 #f5f7ee,#405d4b, 50-50 d,#637f6a, 51-99 d,#0d1410, -|6: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-49 #f5f7ee,#405d4b, 50-50 d,#637f6a, 51-51 d,#0d1410, 52-99 #e5eee5,#0d1410, -|7: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-14 #f5f7ee,#405d4b, 15-49 #e5eee5,#0d1410, 50-50 d,#637f6a, 51-51 d,#0d1410, 52-99 #e5eee5,#0d1410, -== snap typed grid=100x31 cursor=7,5 -|5: TYPEDprintf 'one two three\nfour five six\nseven -== snap undone grid=100x31 cursor=14,7 -|5: printf 'one two three\nfour five six\nseven ei -== snap redone grid=100x31 cursor=7,5 -|5: TYPEDprintf 'one two three\nfour five six\nseven -== snap bottom grid=100x31 cursor=2,10 +|5: 0-0 d,#608269, 1-1 d,#0d1410, 2-49 #f5f7ee,#3c614a, 50-50 d,#608269, 51-99 d,#0d1410, +|6: 0-0 d,#608269, 1-1 d,#0d1410, 2-49 #f5f7ee,#3c614a, 50-50 d,#608269, 51-51 d,#0d1410, 52-99 #e5eee5,#0d1410, +|7: 0-0 d,#608269, 1-1 d,#0d1410, 2-14 #f5f7ee,#3c614a, 15-49 #e5eee5,#0d1410, 50-50 d,#608269, 51-51 d,#0d1410, 52-99 #e5eee5,#0d1410, +== snap typed grid=100x31 cursor=9,20 +|20: TYPED +== snap undone grid=100x31 cursor=4,20 +|20: +== snap redone grid=100x31 cursor=9,20 +|20: TYPED +== snap bottom grid=100x31 cursor=2,20 diff --git a/test/snapshots/msg.golden b/test/snapshots/msg.golden index 9da23117..197d01d9 100644 --- a/test/snapshots/msg.golden +++ b/test/snapshots/msg.golden @@ -1,7 +1,7 @@ == snap opened grid=70x15 cursor=7,3 |Newcol Joincol Find Grep Help Changelog Tutor Dump NextColor Debug Kil -|New Tty Find Grep Joincol -| /tmp/pardes-snap/msg/cwd/a.txt Save Tty Del Collapse +| New Tty Find Grep Joincol Delcol +| /tmp/pardes-snap/msg/cwd/a.txt Save Tty Collapse Del | 1 line 1 | 2 line 2 | 3 line 3 @@ -9,12 +9,20 @@ | 5 line 5 | 6 line 6 | 7 -== snap saved grid=70x15 cursor=7,3 -|14: --:--:-- saved /tmp/pardes-snap/msg/cwd/a.txt -== snap repainted grid=70x17 cursor=7,3 +== snap saved grid=70x15 cursor=7,4 +|3: --:--:-- saved /tmp/pardes-snap/msg/cwd/a.txt +|4: 1 line 1 +|5: 2 line 2 +|6: 3 line 3 +|7: 4 line 4 +|8: 5 line 5 +|9: 6 line 6 +|10: 7 +== snap repainted grid=70x17 cursor=7,4 |Newcol Joincol Find Grep Help Changelog Tutor Dump NextColor Debug Kil -|New Tty Find Grep Joincol -| /tmp/pardes-snap/msg/cwd/a.txt Save Tty Del Collapse +| New Tty Find Grep Joincol Delcol +| /tmp/pardes-snap/msg/cwd/a.txt Save Tty Collapse Del +| --:--:-- saved /tmp/pardes-snap/msg/cwd/a.txt | 1 line 1 | 2 line 2 | 3 line 3 @@ -22,35 +30,56 @@ | 5 line 5 | 6 line 6 | 7 -| -| -| -| -| -| -| --:--:-- saved /tmp/pardes-snap/msg/cwd/a.txt == snap keycleared grid=70x17 cursor=7,4 -|16: -== snap saved-again grid=70x17 cursor=7,4 -|16: --:--:-- saved /tmp/pardes-snap/msg/cwd/a.txt +|3: 1 line 1 +|4: 2 line 2 +|5: 3 line 3 +|6: 4 line 4 +|7: 5 line 5 +|8: 6 line 6 +|9: 7 +|10: +== snap saved-again grid=70x17 cursor=7,5 +|3: --:--:-- saved /tmp/pardes-snap/msg/cwd/a.txt +|4: 1 line 1 +|5: 2 line 2 +|6: 3 line 3 +|7: 4 line 4 +|8: 5 line 5 +|9: 6 line 6 +|10: 7 == snap mousecleared grid=70x17 cursor=7,4 -|16: -== snap reloaded grid=70x17 cursor=7,4 -|3: 1 EXTERNAL -|4: 2 -|5: +|3: 1 line 1 +|4: 2 line 2 +|5: 3 line 3 +|6: 4 line 4 +|7: 5 line 5 +|8: 6 line 6 +|9: 7 +|10: +== snap reloaded grid=70x17 cursor=7,5 +|3: --:--:-- reloaded /tmp/pardes-snap/msg/cwd/a.txt +|4: 1 EXTERNAL +|5: 2 |6: |7: |8: |9: -|16: --:--:-- reloaded /tmp/pardes-snap/msg/cwd/a.txt -== snap prompt grid=70x17 cursor=7,16 -|16: /EXT -== snap prompt-wins grid=70x17 cursor=7,16 -|3: 1 AGAIN +== snap prompt grid=70x17 cursor=69,3 +|3: /EXT +== snap prompt-wins grid=70x17 cursor=69,4 +|3: --:--:-- reloaded /tmp/pardes-snap/msg/cwd/a.txt +|4: /EXT +|5: 1 AGAIN +|6: 2 == snap esc grid=70x17 cursor=7,4 -|16: -== snap msgbuiltin grid=70x17 cursor=29,5 -|2: /tmp/pardes-snap/msg/cwd/a.txt * Save Tty Del Collapse -|5: 3 Msg hand-written report -|16: hand-written report +|3: 1 AGAIN +|4: 2 +|5: +|6: +== snap msgbuiltin grid=70x17 cursor=29,6 +|2: /tmp/pardes-snap/msg/cwd/a.txt * Save Tty Collapse Del +|3: hand-written report +|4: 1 AGAIN +|5: 2 +|6: 3 Msg hand-written report diff --git a/test/snapshots/multicursor.golden b/test/snapshots/multicursor.golden index da2ad1d7..7a602aab 100644 --- a/test/snapshots/multicursor.golden +++ b/test/snapshots/multicursor.golden @@ -1,11 +1,11 @@ == snap three-cursors grid=150x31 cursor=7,9 |Newcol Joincol Find Grep Help Changelog Tutor Dump NextColor Debug Kill -|New Tty Find Grep Joincol New Tty Find Grep Joincol -| /tmp/pardes-snap/multicursor/cwd Save Tty Del Togglettymode Filter Collap /tmp/pardes-snap/multicursor/cwd Save Tty Del Togglettymode Filter Collap +| New Tty Find Grep Joincol Delcol New Tty Find Grep Joincol Delcol +| /tmp/pardes-snap/multicursor/cwd Tty Save Mode Filter Collapse Del /tmp/pardes-snap/multicursor/cwd Tty Save Mode Filter Collapse Del | ls ls | f.txt f.txt | -| /tmp/pardes-snap/multicursor/cwd/f.txt Save Tty Del Collapse +| /tmp/pardes-snap/multicursor/cwd/f.txt Save Tty Collapse Del | 1 line 1 | 2 line 2 | 3 line 3 @@ -16,53 +16,53 @@ | 8 line 8 | 9 line 9 | 10 line 10 -| /tmp/pardes-snap/multicursor/cwd Save Tty Del Togglettymode Filter Collap +| /tmp/pardes-snap/multicursor/cwd Tty Save Mode Filter Collapse Del | ls | f.txt == style three-cursors grid=150x31 |0: 0-70 #b2c3b8,#1d2824, 71-149 d,#1d2824, -|1: 0-24 #becfc4,#26362d, 25-74 d,#26362d, 75-99 #b2c3b8,#1d2824, 100-149 d,#1d2824, -|2: 0-1 #ffffff,#4c6356, 2-74 #b2c3b8,#1d2824, 75-76 #ffffff,#4c6356, 77-149 #b2c3b8,#1d2824, -|3: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-74 #e5eee5,#0d1410, 75-75 d,#637f6a, 76-76 d,#0d1410, 77-149 #e5eee5,#0d1410, -|4: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-74 #e5eee5,#0d1410, 75-75 d,#637f6a, 76-76 d,#0d1410, 77-149 #e5eee5,#0d1410, -|5: 0-0 d,#637f6a, 1-74 d,#0d1410, 75-75 d,#637f6a, 76-149 d,#0d1410, -|6: 0-1 #000000,#adcc91, 2-61 #becfc4,#26362d, 62-74 d,#26362d, 75-75 d,#637f6a, 76-76 d,#0d1410, 77-149 #e5eee5,#0d1410, -|7: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-7 #405d4b,#f5f7ee, 8-12 #e5eee5,#0d1410, 13-74 d,#0d1410, 75-75 d,#637f6a, 76-76 d,#0d1410, 77-149 #e5eee5,#0d1410, -|8: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-7 #405d4b,#f5f7ee, 8-12 #e5eee5,#0d1410, 13-74 d,#0d1410, 75-75 d,#637f6a, 76-76 d,#0d1410, 77-149 #e5eee5,#0d1410, -|9: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-6 #616f64,#0d1410,b 7-12 #e5eee5,#0d1410, 13-74 d,#0d1410, 75-75 d,#637f6a, 76-76 d,#0d1410, 77-149 #e5eee5,#0d1410, -|10: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-12 #e5eee5,#0d1410, 13-74 d,#0d1410, 75-75 d,#637f6a, 76-76 d,#0d1410, 77-149 #e5eee5,#0d1410, -|11: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-12 #e5eee5,#0d1410, 13-74 d,#0d1410, 75-75 d,#637f6a, 76-76 d,#0d1410, 77-149 #e5eee5,#0d1410, -|12: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-12 #e5eee5,#0d1410, 13-74 d,#0d1410, 75-75 d,#637f6a, 76-76 d,#0d1410, 77-149 #e5eee5,#0d1410, -|13: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-12 #e5eee5,#0d1410, 13-74 d,#0d1410, 75-75 d,#637f6a, 76-76 d,#0d1410, 77-149 #e5eee5,#0d1410, -|14: 0-0 d,#152019, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-12 #e5eee5,#0d1410, 13-74 d,#0d1410, 75-75 d,#637f6a, 76-76 d,#0d1410, 77-149 #e5eee5,#0d1410, -|15: 0-0 d,#152019, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-12 #e5eee5,#0d1410, 13-74 d,#0d1410, 75-75 d,#637f6a, 76-76 d,#0d1410, 77-149 #e5eee5,#0d1410, -|16: 0-0 d,#152019, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-13 #e5eee5,#0d1410, 14-74 d,#0d1410, 75-75 d,#637f6a, 76-76 d,#0d1410, 77-149 #e5eee5,#0d1410, -|17: 0-1 #ffffff,#4c6356, 2-74 #b2c3b8,#1d2824, 75-75 d,#637f6a, 76-76 d,#0d1410, 77-149 #e5eee5,#0d1410, -|18: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-74 #e5eee5,#0d1410, 75-75 d,#637f6a, 76-76 d,#0d1410, 77-149 #e5eee5,#0d1410, -|19: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-74 #e5eee5,#0d1410, 75-75 d,#637f6a, 76-76 d,#0d1410, 77-149 #e5eee5,#0d1410, -|20: 0-0 d,#637f6a, 1-74 d,#0d1410, 75-75 d,#637f6a, 76-76 d,#0d1410, 77-149 #e5eee5,#0d1410, -|21: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-74 #e5eee5,#0d1410, 75-75 d,#637f6a, 76-76 d,#0d1410, 77-149 #e5eee5,#0d1410, -|22: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-74 #e5eee5,#0d1410, 75-75 d,#637f6a, 76-76 d,#0d1410, 77-149 #e5eee5,#0d1410, -|23: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-74 #e5eee5,#0d1410, 75-75 d,#637f6a, 76-76 d,#0d1410, 77-149 #e5eee5,#0d1410, -|24: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-74 #e5eee5,#0d1410, 75-75 d,#637f6a, 76-76 d,#0d1410, 77-149 #e5eee5,#0d1410, -|25: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-74 #e5eee5,#0d1410, 75-75 d,#637f6a, 76-76 d,#0d1410, 77-149 #e5eee5,#0d1410, -|26: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-74 #e5eee5,#0d1410, 75-75 d,#637f6a, 76-76 d,#0d1410, 77-149 #e5eee5,#0d1410, -|27: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-74 #e5eee5,#0d1410, 75-75 d,#637f6a, 76-76 d,#0d1410, 77-149 #e5eee5,#0d1410, -|28: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-74 #e5eee5,#0d1410, 75-75 d,#637f6a, 76-76 d,#0d1410, 77-149 #e5eee5,#0d1410, -|29: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-74 #e5eee5,#0d1410, 75-75 d,#637f6a, 76-76 d,#0d1410, 77-149 #e5eee5,#0d1410, -|30: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-74 #e5eee5,#0d1410, 75-75 d,#637f6a, 76-76 d,#0d1410, 77-149 #e5eee5,#0d1410, +|1: 0-1 #ffffff,#887455, 2-2 d,#26362d, 3-34 #becfc4,#26362d, 35-74 d,#26362d, 75-76 #ffffff,#887455, 77-77 d,#1d2824, 78-109 #b2c3b8,#1d2824, 110-149 d,#1d2824, +|2: 0-1 #ffffff,#496656, 2-2 d,#1d2824, 3-35 #b2c3b8,#1d2824, 36-38 #d3b0d9,#1d2824, 39-68 #b2c3b8,#1d2824, 69-74 d,#1d2824, 75-76 #ffffff,#496656, 77-77 d,#1d2824, 78-110 #b2c3b8,#1d2824, 111-113 #d3b0d9,#1d2824, 114-143 #b2c3b8,#1d2824, 144-149 d,#1d2824, +|3: 0-0 d,#608269, 1-1 d,#0d1410, 2-74 #e5eee5,#0d1410, 75-75 d,#608269, 76-76 d,#0d1410, 77-149 #e5eee5,#0d1410, +|4: 0-0 d,#608269, 1-1 d,#0d1410, 2-74 #e5eee5,#0d1410, 75-75 d,#608269, 76-76 d,#0d1410, 77-149 #e5eee5,#0d1410, +|5: 0-0 d,#608269, 1-74 d,#0d1410, 75-75 d,#608269, 76-149 d,#0d1410, +|6: 0-1 #000000,#add38a, 2-2 d,#26362d, 3-35 #becfc4,#26362d, 36-40 #dfbce5,#26362d, 41-62 #becfc4,#26362d, 63-74 d,#26362d, 75-75 d,#608269, 76-76 d,#0d1410, 77-149 #e5eee5,#0d1410, +|7: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-7 #3c614a,#f5f7ee, 8-12 #e5eee5,#0d1410, 13-74 d,#0d1410, 75-75 d,#608269, 76-76 d,#0d1410, 77-149 #e5eee5,#0d1410, +|8: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-7 #3c614a,#f5f7ee, 8-12 #e5eee5,#0d1410, 13-74 d,#0d1410, 75-75 d,#608269, 76-76 d,#0d1410, 77-149 #e5eee5,#0d1410, +|9: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #616f64,#0d1410,b 7-12 #e5eee5,#0d1410, 13-74 d,#0d1410, 75-75 d,#608269, 76-76 d,#0d1410, 77-149 #e5eee5,#0d1410, +|10: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-12 #e5eee5,#0d1410, 13-74 d,#0d1410, 75-75 d,#608269, 76-76 d,#0d1410, 77-149 #e5eee5,#0d1410, +|11: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-12 #e5eee5,#0d1410, 13-74 d,#0d1410, 75-75 d,#608269, 76-76 d,#0d1410, 77-149 #e5eee5,#0d1410, +|12: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-12 #e5eee5,#0d1410, 13-74 d,#0d1410, 75-75 d,#608269, 76-76 d,#0d1410, 77-149 #e5eee5,#0d1410, +|13: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-12 #e5eee5,#0d1410, 13-74 d,#0d1410, 75-75 d,#608269, 76-76 d,#0d1410, 77-149 #e5eee5,#0d1410, +|14: 0-0 d,#152019, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-12 #e5eee5,#0d1410, 13-74 d,#0d1410, 75-75 d,#608269, 76-76 d,#0d1410, 77-149 #e5eee5,#0d1410, +|15: 0-0 d,#152019, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-12 #e5eee5,#0d1410, 13-74 d,#0d1410, 75-75 d,#608269, 76-76 d,#0d1410, 77-149 #e5eee5,#0d1410, +|16: 0-0 d,#152019, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-13 #e5eee5,#0d1410, 14-74 d,#0d1410, 75-75 d,#608269, 76-76 d,#0d1410, 77-149 #e5eee5,#0d1410, +|17: 0-1 #ffffff,#496656, 2-2 d,#1d2824, 3-35 #b2c3b8,#1d2824, 36-38 #d3b0d9,#1d2824, 39-68 #b2c3b8,#1d2824, 69-74 d,#1d2824, 75-75 d,#608269, 76-76 d,#0d1410, 77-149 #e5eee5,#0d1410, +|18: 0-0 d,#608269, 1-1 d,#0d1410, 2-74 #e5eee5,#0d1410, 75-75 d,#608269, 76-76 d,#0d1410, 77-149 #e5eee5,#0d1410, +|19: 0-0 d,#608269, 1-1 d,#0d1410, 2-74 #e5eee5,#0d1410, 75-75 d,#608269, 76-76 d,#0d1410, 77-149 #e5eee5,#0d1410, +|20: 0-0 d,#608269, 1-74 d,#0d1410, 75-75 d,#608269, 76-76 d,#0d1410, 77-149 #e5eee5,#0d1410, +|21: 0-0 d,#608269, 1-1 d,#0d1410, 2-74 #e5eee5,#0d1410, 75-75 d,#608269, 76-76 d,#0d1410, 77-149 #e5eee5,#0d1410, +|22: 0-0 d,#608269, 1-1 d,#0d1410, 2-74 #e5eee5,#0d1410, 75-75 d,#608269, 76-76 d,#0d1410, 77-149 #e5eee5,#0d1410, +|23: 0-0 d,#608269, 1-1 d,#0d1410, 2-74 #e5eee5,#0d1410, 75-75 d,#608269, 76-76 d,#0d1410, 77-149 #e5eee5,#0d1410, +|24: 0-0 d,#608269, 1-1 d,#0d1410, 2-74 #e5eee5,#0d1410, 75-75 d,#608269, 76-76 d,#0d1410, 77-149 #e5eee5,#0d1410, +|25: 0-0 d,#608269, 1-1 d,#0d1410, 2-74 #e5eee5,#0d1410, 75-75 d,#608269, 76-76 d,#0d1410, 77-149 #e5eee5,#0d1410, +|26: 0-0 d,#608269, 1-1 d,#0d1410, 2-74 #e5eee5,#0d1410, 75-75 d,#608269, 76-76 d,#0d1410, 77-149 #e5eee5,#0d1410, +|27: 0-0 d,#608269, 1-1 d,#0d1410, 2-74 #e5eee5,#0d1410, 75-75 d,#608269, 76-76 d,#0d1410, 77-149 #e5eee5,#0d1410, +|28: 0-0 d,#608269, 1-1 d,#0d1410, 2-74 #e5eee5,#0d1410, 75-75 d,#608269, 76-76 d,#0d1410, 77-149 #e5eee5,#0d1410, +|29: 0-0 d,#608269, 1-1 d,#0d1410, 2-74 #e5eee5,#0d1410, 75-75 d,#608269, 76-76 d,#0d1410, 77-149 #e5eee5,#0d1410, +|30: 0-0 d,#608269, 1-1 d,#0d1410, 2-74 #e5eee5,#0d1410, 75-75 d,#608269, 76-76 d,#0d1410, 77-149 #e5eee5,#0d1410, == snap edited-at-three grid=150x31 cursor=9,9 -|6: /tmp/pardes-snap/multicursor/cwd/f.txt * Save Tty Del Collapse +|6: /tmp/pardes-snap/multicursor/cwd/f.txt * Save Tty Collapse Del |7: 1 >>line 1 |8: 2 >>line 2 |9: 3 >>line 3 == snap three-selections grid=150x31 cursor=8,9 == style three-selections grid=150x31 -|6: 0-1 #000000,#adcc91, 2-63 #becfc4,#26362d, 64-74 d,#26362d, 75-75 d,#637f6a, 76-76 d,#0d1410, 77-149 #e5eee5,#0d1410, -|7: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-7 #f5f7ee,#26382d, 8-8 #405d4b,#f5f7ee, 9-14 #e5eee5,#0d1410, 15-74 d,#0d1410, 75-75 d,#637f6a, 76-76 d,#0d1410, 77-149 #e5eee5,#0d1410, -|8: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-7 #f5f7ee,#26382d, 8-8 #405d4b,#f5f7ee, 9-14 #e5eee5,#0d1410, 15-74 d,#0d1410, 75-75 d,#637f6a, 76-76 d,#0d1410, 77-149 #e5eee5,#0d1410, -|9: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-6 #616f64,#0d1410,b 7-8 #f5f7ee,#405d4b, 9-14 #e5eee5,#0d1410, 15-74 d,#0d1410, 75-75 d,#637f6a, 76-76 d,#0d1410, 77-149 #e5eee5,#0d1410, +|6: 0-1 #000000,#add38a, 2-2 d,#26362d, 3-35 #becfc4,#26362d, 36-40 #dfbce5,#26362d, 41-64 #becfc4,#26362d, 65-74 d,#26362d, 75-75 d,#608269, 76-76 d,#0d1410, 77-149 #e5eee5,#0d1410, +|7: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-7 #f5f7ee,#243a2d, 8-8 #3c614a,#f5f7ee, 9-14 #e5eee5,#0d1410, 15-74 d,#0d1410, 75-75 d,#608269, 76-76 d,#0d1410, 77-149 #e5eee5,#0d1410, +|8: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-7 #f5f7ee,#243a2d, 8-8 #3c614a,#f5f7ee, 9-14 #e5eee5,#0d1410, 15-74 d,#0d1410, 75-75 d,#608269, 76-76 d,#0d1410, 77-149 #e5eee5,#0d1410, +|9: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #616f64,#0d1410,b 7-8 #f5f7ee,#3c614a, 9-14 #e5eee5,#0d1410, 15-74 d,#0d1410, 75-75 d,#608269, 76-76 d,#0d1410, 77-149 #e5eee5,#0d1410, == snap keep-primary grid=150x31 cursor=8,9 == style keep-primary grid=150x31 -|7: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-14 #e5eee5,#0d1410, 15-74 d,#0d1410, 75-75 d,#637f6a, 76-76 d,#0d1410, 77-149 #e5eee5,#0d1410, -|8: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-14 #e5eee5,#0d1410, 15-74 d,#0d1410, 75-75 d,#637f6a, 76-76 d,#0d1410, 77-149 #e5eee5,#0d1410, +|7: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-14 #e5eee5,#0d1410, 15-74 d,#0d1410, 75-75 d,#608269, 76-76 d,#0d1410, 77-149 #e5eee5,#0d1410, +|8: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-14 #e5eee5,#0d1410, 15-74 d,#0d1410, 75-75 d,#608269, 76-76 d,#0d1410, 77-149 #e5eee5,#0d1410, diff --git a/test/snapshots/nested.golden b/test/snapshots/nested.golden index 68d0a69b..88b0854c 100644 --- a/test/snapshots/nested.golden +++ b/test/snapshots/nested.golden @@ -1,28 +1,79 @@ -== snap file-arg grid=100x31 cursor=7,6 +== snap file-arg grid=100x31 cursor=7,27 |Newcol Joincol Find Grep Help Changelog Tutor Dump NextColor Debug Kill -|New Tty Find Grep Joincol -|$ /tmp/pardes-snap/nested/cwd Save Tty Del Togglettymode Filter Collapse +| New Tty Find Grep Joincol Delcol +|$ /tmp/pardes-snap/nested/cwd Tty Save Mode Filter Collapse Del | $ $(readlink /proc/$PPID/exe) nested.txt | $ -| /tmp/pardes-snap/nested/cwd/nested.txt Save Tty Del Collapse +| +| +| +| +| +| +| +| +| +| +| +| +| +| +| +| +| /+New Save Tty Collapse Del +| 1 +| +| +| +| /tmp/pardes-snap/nested/cwd/nested.txt Save Tty Collapse Del | 1 hello-from-nested | 2 second-nested-line | 3 == snap no-arg grid=100x31 cursor=4,7 |Newcol Joincol Find Grep Help Changelog Tutor Dump NextColor Debug Kill -|New Tty Find Grep Joincol -|$ /tmp/pardes-snap/nested/cwd Save Tty Del Togglettymode Filter Collapse +| New Tty Find Grep Joincol Delcol +|$ /tmp/pardes-snap/nested/cwd Tty Save Mode Filter Collapse Del | $ $(readlink /proc/$PPID/exe) | pardes: this shell is already inside pardes, and a pardes inside a pardes | is spicy. Name a file or a directory and the outer session opens it, or | pass --nested if you really want a second one in here. | $ +| +| +| +| +| +| +| +| +| +| +| +| +| +| /+New Save Tty Collapse Del +| 1 == snap dir-arg grid=100x31 cursor=4,8 |Newcol Joincol Find Grep Help Changelog Tutor Dump NextColor Debug Kill -|New Tty Find Grep Joincol -|$ /tmp/pardes-snap/nested/cwd Save Tty Del Togglettymode Filter Collapse +| New Tty Find Grep Joincol Delcol +|$ /tmp/pardes-snap/nested/cwd Tty Save Mode Filter Collapse Del | $ $(readlink /proc/$PPID/exe) nestdir | $ -| /tmp/pardes-snap/nested/cwd/nestdir Save Tty Del Togglettymode Filter Collapse +| /tmp/pardes-snap/nested/cwd/nestdir Tty Save Mode Filter Collapse Del | ls | inside-nested.txt +| +| +| +| +| +| +| +| +| +| +| +| +| +| /+New Save Tty Collapse Del +| 1 diff --git a/test/snapshots/ninep.golden b/test/snapshots/ninep.golden index 94ad4bcf..b501004e 100644 --- a/test/snapshots/ninep.golden +++ b/test/snapshots/ninep.golden @@ -1,7 +1,7 @@ == snap opened grid=90x15 cursor=7,3 |Newcol Joincol Find Grep Help Changelog Tutor Dump NextColor Debug Kill -|New Tty Find Grep Joincol -| /tmp/pardes-snap/ninep/cwd/demo.zig Save Tty Del Collapse +| New Tty Find Grep Joincol Delcol +| /tmp/pardes-snap/ninep/cwd/demo.zig Save Tty Collapse Del TreeContext | 1 const greeting = "café λ 界 eÌ�"; | 2 | 3 pub fn choose(ok: bool) u32 { @@ -11,69 +11,80 @@ | 7 == style opened grid=90x15 |0: 0-70 #b2c3b8,#1d2824, 71-89 d,#1d2824, -|1: 0-24 #becfc4,#26362d, 25-89 d,#26362d, -|2: 0-1 #000000,#adcc91, 2-58 #becfc4,#26362d, 59-89 d,#26362d, -|3: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-6 #616f64,#0d1410,b 7-23 #e5eee5,#0d1410, 24-32 #b6ce94,#0d1410, 33-33 d,d, 34-36 #b6ce94,#0d1410, 37-37 #e5eee5,#0d1410, 38-89 d,#0d1410, -|4: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-89 d,#0d1410, -|5: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-10 #e5eee5,#0d1410, 11-12 #c9b0e4,#0d1410, 13-35 #e5eee5,#0d1410, 36-89 d,#0d1410, -|6: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-10 #e5eee5,#0d1410, 11-12 #c9b0e4,#0d1410, 13-18 #e5eee5,#0d1410, 19-24 #c9b0e4,#0d1410, 25-25 #e5eee5,#0d1410, 26-27 #e9bf91,#0d1410, 28-28 #e5eee5,#0d1410, 29-89 d,#0d1410, -|7: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-10 #e5eee5,#0d1410, 11-16 #c9b0e4,#0d1410, 17-17 #e5eee5,#0d1410, 18-18 #e9bf91,#0d1410, 19-19 #e5eee5,#0d1410, 20-89 d,#0d1410, -|8: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-7 #e5eee5,#0d1410, 8-89 d,#0d1410, -|9: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-89 d,#0d1410, -|10: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-89 d,#0d1410, -|11: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-89 d,#0d1410, -|12: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-89 d,#0d1410, -|13: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-89 d,#0d1410, -|14: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-89 d,#0d1410, +|1: 0-1 #ffffff,#887455, 2-2 d,#26362d, 3-34 #becfc4,#26362d, 35-89 d,#26362d, +|2: 0-1 #000000,#add38a, 2-2 d,#26362d, 3-29 #becfc4,#26362d, 30-37 #dfbce5,#26362d, 38-71 #becfc4,#26362d, 72-89 d,#26362d, +|3: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #616f64,#0d1410,b 7-23 #e5eee5,#0d1410, 24-32 #b8d88a,#0d1410, 33-33 d,d, 34-36 #b8d88a,#0d1410, 37-37 #e5eee5,#0d1410, 38-89 d,#0d1410, +|4: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-89 d,#0d1410, +|5: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-10 #e5eee5,#0d1410, 11-12 #c9a7ed,#0d1410, 13-35 #e5eee5,#0d1410, 36-89 d,#0d1410, +|6: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-10 #e5eee5,#0d1410, 11-12 #c9a7ed,#0d1410, 13-18 #e5eee5,#0d1410, 19-24 #c9a7ed,#0d1410, 25-25 #e5eee5,#0d1410, 26-27 #f8c082,#0d1410, 28-28 #e5eee5,#0d1410, 29-89 d,#0d1410, +|7: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-10 #e5eee5,#0d1410, 11-16 #c9a7ed,#0d1410, 17-17 #e5eee5,#0d1410, 18-18 #f8c082,#0d1410, 19-19 #e5eee5,#0d1410, 20-89 d,#0d1410, +|8: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-7 #e5eee5,#0d1410, 8-89 d,#0d1410, +|9: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-89 d,#0d1410, +|10: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-89 d,#0d1410, +|11: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-89 d,#0d1410, +|12: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-89 d,#0d1410, +|13: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-89 d,#0d1410, +|14: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-89 d,#0d1410, == 9p opened grid=90x15 cursor=7,3,block |0: Newcol Joincol Find Grep Help Changelog Tutor Dump NextColor Debug Kill @0: 0-70 #b2c3b8,#1d2824,,tagline 71-89 d,#1d2824,,tagline -|1: New Tty Find Grep Joincol -@1: 0-24 #becfc4,#26362d,,tagline 25-89 d,#26362d,,tagline -|2: /tmp/pardes-snap/ninep/cwd/demo.zig Save Tty Del Collapse -@2: 0-1 #000000,#adcc91,,tagline 2-58 #becfc4,#26362d,,tagline 59-89 d,#26362d,,tagline +|1: New Tty Find Grep Joincol Delcol +@1: 0-1 #ffffff,#887455,,tagline 2-2 d,#26362d,,tagline 3-34 #becfc4,#26362d,,tagline 35-89 d,#26362d,,tagline +|2: /tmp/pardes-snap/ninep/cwd/demo.zig Save Tty Collapse Del TreeContext +@2: 0-1 #000000,#add38a,,tagline 2-2 d,#26362d,,tagline 3-29 #becfc4,#26362d,,tagline 30-37 #dfbce5,#26362d,,tagline 38-71 #becfc4,#26362d,,tagline 72-89 d,#26362d,,tagline |3: 1 const greeting = "café λ 界 eÌ�"; +3: 28="é" 30="λ" 32="界" 33="" 35="eÌ�" -@3: 0-0 d,#637f6a,,body 1-1 d,#0d1410,,body 2-6 #616f64,#0d1410,b,body 7-23 #e5eee5,#0d1410,,body 24-36 #b6ce94,#0d1410,,body 37-37 #e5eee5,#0d1410,,body 38-89 d,#0d1410,,body +@3: 0-0 d,#608269,,body 1-1 d,#0d1410,,body 2-6 #616f64,#0d1410,b,body 7-23 #e5eee5,#0d1410,,body 24-36 #b8d88a,#0d1410,,body 37-37 #e5eee5,#0d1410,,body 38-89 d,#0d1410,,body |4: 2 -@4: 0-0 d,#637f6a,,body 1-1 d,#0d1410,,body 2-6 #59675c,#0d1410,,body 7-89 d,#0d1410,,body +@4: 0-0 d,#608269,,body 1-1 d,#0d1410,,body 2-6 #59675c,#0d1410,,body 7-89 d,#0d1410,,body |5: 3 pub fn choose(ok: bool) u32 { -@5: 0-0 d,#637f6a,,body 1-1 d,#0d1410,,body 2-6 #59675c,#0d1410,,body 7-10 #e5eee5,#0d1410,,body 11-12 #c9b0e4,#0d1410,,body 13-35 #e5eee5,#0d1410,,body 36-89 d,#0d1410,,body +@5: 0-0 d,#608269,,body 1-1 d,#0d1410,,body 2-6 #59675c,#0d1410,,body 7-10 #e5eee5,#0d1410,,body 11-12 #c9a7ed,#0d1410,,body 13-35 #e5eee5,#0d1410,,body 36-89 d,#0d1410,,body |6: 4 if (ok) return 42; -@6: 0-0 d,#637f6a,,body 1-1 d,#0d1410,,body 2-6 #59675c,#0d1410,,body 7-10 #e5eee5,#0d1410,,body 11-12 #c9b0e4,#0d1410,,body 13-18 #e5eee5,#0d1410,,body 19-24 #c9b0e4,#0d1410,,body 25-25 #e5eee5,#0d1410,,body 26-27 #e9bf91,#0d1410,,body 28-28 #e5eee5,#0d1410,,body 29-89 d,#0d1410,,body +@6: 0-0 d,#608269,,body 1-1 d,#0d1410,,body 2-6 #59675c,#0d1410,,body 7-10 #e5eee5,#0d1410,,body 11-12 #c9a7ed,#0d1410,,body 13-18 #e5eee5,#0d1410,,body 19-24 #c9a7ed,#0d1410,,body 25-25 #e5eee5,#0d1410,,body 26-27 #f8c082,#0d1410,,body 28-28 #e5eee5,#0d1410,,body 29-89 d,#0d1410,,body |7: 5 return 7; -@7: 0-0 d,#637f6a,,body 1-1 d,#0d1410,,body 2-6 #59675c,#0d1410,,body 7-10 #e5eee5,#0d1410,,body 11-16 #c9b0e4,#0d1410,,body 17-17 #e5eee5,#0d1410,,body 18-18 #e9bf91,#0d1410,,body 19-19 #e5eee5,#0d1410,,body 20-89 d,#0d1410,,body +@7: 0-0 d,#608269,,body 1-1 d,#0d1410,,body 2-6 #59675c,#0d1410,,body 7-10 #e5eee5,#0d1410,,body 11-16 #c9a7ed,#0d1410,,body 17-17 #e5eee5,#0d1410,,body 18-18 #f8c082,#0d1410,,body 19-19 #e5eee5,#0d1410,,body 20-89 d,#0d1410,,body |8: 6 } -@8: 0-0 d,#637f6a,,body 1-1 d,#0d1410,,body 2-6 #59675c,#0d1410,,body 7-7 #e5eee5,#0d1410,,body 8-89 d,#0d1410,,body +@8: 0-0 d,#608269,,body 1-1 d,#0d1410,,body 2-6 #59675c,#0d1410,,body 7-7 #e5eee5,#0d1410,,body 8-89 d,#0d1410,,body |9: 7 -@9: 0-0 d,#637f6a,,body 1-1 d,#0d1410,,body 2-6 #59675c,#0d1410,,body 7-89 d,#0d1410,,body +@9: 0-0 d,#608269,,body 1-1 d,#0d1410,,body 2-6 #59675c,#0d1410,,body 7-89 d,#0d1410,,body |10: -@10: 0-0 d,#637f6a,,body 1-1 d,#0d1410,,body 2-6 #59675c,#0d1410,,body 7-89 d,#0d1410,,body +@10: 0-0 d,#608269,,body 1-1 d,#0d1410,,body 2-6 #59675c,#0d1410,,body 7-89 d,#0d1410,,body |11: -@11: 0-0 d,#637f6a,,body 1-1 d,#0d1410,,body 2-6 #59675c,#0d1410,,body 7-89 d,#0d1410,,body +@11: 0-0 d,#608269,,body 1-1 d,#0d1410,,body 2-6 #59675c,#0d1410,,body 7-89 d,#0d1410,,body |12: -@12: 0-0 d,#637f6a,,body 1-1 d,#0d1410,,body 2-6 #59675c,#0d1410,,body 7-89 d,#0d1410,,body +@12: 0-0 d,#608269,,body 1-1 d,#0d1410,,body 2-6 #59675c,#0d1410,,body 7-89 d,#0d1410,,body |13: -@13: 0-0 d,#637f6a,,body 1-1 d,#0d1410,,body 2-6 #59675c,#0d1410,,body 7-89 d,#0d1410,,body +@13: 0-0 d,#608269,,body 1-1 d,#0d1410,,body 2-6 #59675c,#0d1410,,body 7-89 d,#0d1410,,body |14: -@14: 0-0 d,#637f6a,,body 1-1 d,#0d1410,,body 2-6 #59675c,#0d1410,,body 7-89 d,#0d1410,,body +@14: 0-0 d,#608269,,body 1-1 d,#0d1410,,body 2-6 #59675c,#0d1410,,body 7-89 d,#0d1410,,body == style colors-off grid=90x15 -|3: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-6 #616f64,#0d1410,b 7-32 #e5eee5,#0d1410, 33-33 d,d, 34-37 #e5eee5,#0d1410, 38-89 d,#0d1410, -|5: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-35 #e5eee5,#0d1410, 36-89 d,#0d1410, -|6: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-28 #e5eee5,#0d1410, 29-89 d,#0d1410, -|7: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-19 #e5eee5,#0d1410, 20-89 d,#0d1410, -== 9p colors-off grid=90x15 cursor=7,3,block -|3: 1 const greeting = "café λ 界 eÌ�"; -+3: 28="é" 30="λ" 32="界" 33="" 35="eÌ�" -@3: 0-0 d,#637f6a,,body 1-1 d,#0d1410,,body 2-6 #616f64,#0d1410,b,body 7-37 #e5eee5,#0d1410,,body 38-89 d,#0d1410,,body -|5: 3 pub fn choose(ok: bool) u32 { -@5: 0-0 d,#637f6a,,body 1-1 d,#0d1410,,body 2-6 #59675c,#0d1410,,body 7-35 #e5eee5,#0d1410,,body 36-89 d,#0d1410,,body -|6: 4 if (ok) return 42; -@6: 0-0 d,#637f6a,,body 1-1 d,#0d1410,,body 2-6 #59675c,#0d1410,,body 7-28 #e5eee5,#0d1410,,body 29-89 d,#0d1410,,body -|7: 5 return 7; -@7: 0-0 d,#637f6a,,body 1-1 d,#0d1410,,body 2-6 #59675c,#0d1410,,body 7-19 #e5eee5,#0d1410,,body 20-89 d,#0d1410,,body +|3: 0-0 d,#152019, 1-1 d,#0d1410, 2-83 d,#1d2824, 84-89 #b2c3b8,#1d2824, +|4: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #616f64,#0d1410,b 7-32 #e5eee5,#0d1410, 33-33 d,d, 34-37 #e5eee5,#0d1410, 38-89 d,#0d1410, +|5: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-89 d,#0d1410, +|6: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-35 #e5eee5,#0d1410, 36-89 d,#0d1410, +|7: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-28 #e5eee5,#0d1410, 29-89 d,#0d1410, +|8: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-19 #e5eee5,#0d1410, 20-89 d,#0d1410, +|9: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-7 #e5eee5,#0d1410, 8-89 d,#0d1410, +== 9p colors-off grid=90x15 cursor=7,4,block +|3: Colors +@3: 0-0 d,#152019,,body 1-1 d,#0d1410,,body 2-83 d,#1d2824,,tagline 84-89 #b2c3b8,#1d2824,,tagline +|4: 1 const greeting = "café λ 界 eÌ�"; ++4: 28="é" 30="λ" 32="界" 33="" 35="eÌ�" +@4: 0-0 d,#608269,,body 1-1 d,#0d1410,,body 2-6 #616f64,#0d1410,b,body 7-37 #e5eee5,#0d1410,,body 38-89 d,#0d1410,,body +|5: 2 +@5: 0-0 d,#608269,,body 1-1 d,#0d1410,,body 2-6 #59675c,#0d1410,,body 7-89 d,#0d1410,,body +|6: 3 pub fn choose(ok: bool) u32 { +@6: 0-0 d,#608269,,body 1-1 d,#0d1410,,body 2-6 #59675c,#0d1410,,body 7-35 #e5eee5,#0d1410,,body 36-89 d,#0d1410,,body +|7: 4 if (ok) return 42; +@7: 0-0 d,#608269,,body 1-1 d,#0d1410,,body 2-6 #59675c,#0d1410,,body 7-28 #e5eee5,#0d1410,,body 29-89 d,#0d1410,,body +|8: 5 return 7; +@8: 0-0 d,#608269,,body 1-1 d,#0d1410,,body 2-6 #59675c,#0d1410,,body 7-19 #e5eee5,#0d1410,,body 20-89 d,#0d1410,,body +|9: 6 } +@9: 0-0 d,#608269,,body 1-1 d,#0d1410,,body 2-6 #59675c,#0d1410,,body 7-7 #e5eee5,#0d1410,,body 8-89 d,#0d1410,,body +|10: 7 +@10: 0-0 d,#608269,,body 1-1 d,#0d1410,,body 2-6 #59675c,#0d1410,,body 7-89 d,#0d1410,,body == snap edited-with-colors-off grid=90x15 cursor=7,4 -|2: /tmp/pardes-snap/ninep/cwd/demo.zig * Save Tty Del Collapse +|2: /tmp/pardes-snap/ninep/cwd/demo.zig * Save Tty Collapse Del TreeContext |3: 1 // café λ 界 |4: 2 const greeting = "café λ 界 eÌ�"; |5: 3 @@ -83,116 +94,125 @@ |9: 7 } |10: 8 == 9p edited-with-colors-off grid=90x15 cursor=7,4,block -|2: /tmp/pardes-snap/ninep/cwd/demo.zig * Save Tty Del Collapse -@2: 0-1 #000000,#adcc91,,tagline 2-60 #becfc4,#26362d,,tagline 61-89 d,#26362d,,tagline +|2: /tmp/pardes-snap/ninep/cwd/demo.zig * Save Tty Collapse Del TreeContext +@2: 0-1 #000000,#add38a,,tagline 2-2 d,#26362d,,tagline 3-29 #becfc4,#26362d,,tagline 30-37 #dfbce5,#26362d,,tagline 38-73 #becfc4,#26362d,,tagline 74-89 d,#26362d,,tagline |3: 1 // café λ 界 +3: 13="é" 15="λ" 17="界" 18="" -@3: 0-0 d,#637f6a,,body 1-1 d,#0d1410,,body 2-6 #59675c,#0d1410,,body 7-18 #e5eee5,#0d1410,,body 19-89 d,#0d1410,,body +@3: 0-0 d,#608269,,body 1-1 d,#0d1410,,body 2-6 #59675c,#0d1410,,body 7-18 #e5eee5,#0d1410,,body 19-89 d,#0d1410,,body |4: 2 const greeting = "café λ 界 eÌ�"; +4: 28="é" 30="λ" 32="界" 33="" 35="eÌ�" -@4: 0-0 d,#637f6a,,body 1-1 d,#0d1410,,body 2-6 #616f64,#0d1410,b,body 7-37 #e5eee5,#0d1410,,body 38-89 d,#0d1410,,body +@4: 0-0 d,#608269,,body 1-1 d,#0d1410,,body 2-6 #616f64,#0d1410,b,body 7-37 #e5eee5,#0d1410,,body 38-89 d,#0d1410,,body |5: 3 -@5: 0-0 d,#637f6a,,body 1-1 d,#0d1410,,body 2-6 #59675c,#0d1410,,body 7-89 d,#0d1410,,body +@5: 0-0 d,#608269,,body 1-1 d,#0d1410,,body 2-6 #59675c,#0d1410,,body 7-89 d,#0d1410,,body |6: 4 pub fn choose(ok: bool) u32 { -@6: 0-0 d,#637f6a,,body 1-1 d,#0d1410,,body 2-6 #59675c,#0d1410,,body 7-35 #e5eee5,#0d1410,,body 36-89 d,#0d1410,,body +@6: 0-0 d,#608269,,body 1-1 d,#0d1410,,body 2-6 #59675c,#0d1410,,body 7-35 #e5eee5,#0d1410,,body 36-89 d,#0d1410,,body |7: 5 if (ok) return 42; -@7: 0-0 d,#637f6a,,body 1-1 d,#0d1410,,body 2-6 #59675c,#0d1410,,body 7-28 #e5eee5,#0d1410,,body 29-89 d,#0d1410,,body +@7: 0-0 d,#608269,,body 1-1 d,#0d1410,,body 2-6 #59675c,#0d1410,,body 7-28 #e5eee5,#0d1410,,body 29-89 d,#0d1410,,body |8: 6 return 7; -@8: 0-0 d,#637f6a,,body 1-1 d,#0d1410,,body 2-6 #59675c,#0d1410,,body 7-19 #e5eee5,#0d1410,,body 20-89 d,#0d1410,,body +@8: 0-0 d,#608269,,body 1-1 d,#0d1410,,body 2-6 #59675c,#0d1410,,body 7-19 #e5eee5,#0d1410,,body 20-89 d,#0d1410,,body |9: 7 } -@9: 0-0 d,#637f6a,,body 1-1 d,#0d1410,,body 2-6 #59675c,#0d1410,,body 7-7 #e5eee5,#0d1410,,body 8-89 d,#0d1410,,body +@9: 0-0 d,#608269,,body 1-1 d,#0d1410,,body 2-6 #59675c,#0d1410,,body 7-7 #e5eee5,#0d1410,,body 8-89 d,#0d1410,,body |10: 8 -@10: 0-0 d,#637f6a,,body 1-1 d,#0d1410,,body 2-6 #59675c,#0d1410,,body 7-89 d,#0d1410,,body +@10: 0-0 d,#608269,,body 1-1 d,#0d1410,,body 2-6 #59675c,#0d1410,,body 7-89 d,#0d1410,,body == style colors-on grid=90x15 -|2: 0-1 #000000,#adcc91, 2-60 #becfc4,#26362d, 61-89 d,#26362d, -|3: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-17 #b9e58f,#0d1410, 18-18 d,d, 19-89 d,#0d1410, -|4: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-6 #616f64,#0d1410,b 7-23 #e5eee5,#0d1410, 24-32 #b6ce94,#0d1410, 33-33 d,d, 34-36 #b6ce94,#0d1410, 37-37 #e5eee5,#0d1410, 38-89 d,#0d1410, -|5: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-89 d,#0d1410, -|6: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-10 #e5eee5,#0d1410, 11-12 #c9b0e4,#0d1410, 13-35 #e5eee5,#0d1410, 36-89 d,#0d1410, -|7: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-10 #e5eee5,#0d1410, 11-12 #c9b0e4,#0d1410, 13-18 #e5eee5,#0d1410, 19-24 #c9b0e4,#0d1410, 25-25 #e5eee5,#0d1410, 26-27 #e9bf91,#0d1410, 28-28 #e5eee5,#0d1410, 29-89 d,#0d1410, -|8: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-10 #e5eee5,#0d1410, 11-16 #c9b0e4,#0d1410, 17-17 #e5eee5,#0d1410, 18-18 #e9bf91,#0d1410, 19-19 #e5eee5,#0d1410, 20-89 d,#0d1410, -|9: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-7 #e5eee5,#0d1410, 8-89 d,#0d1410, -== 9p colors-on grid=90x15 cursor=7,4,block -|3: 1 // café λ 界 -+3: 13="é" 15="λ" 17="界" 18="" -@3: 0-0 d,#637f6a,,body 1-1 d,#0d1410,,body 2-6 #59675c,#0d1410,,body 7-18 #b9e58f,#0d1410,,body 19-89 d,#0d1410,,body -|4: 2 const greeting = "café λ 界 eÌ�"; -+4: 28="é" 30="λ" 32="界" 33="" 35="eÌ�" -@4: 0-0 d,#637f6a,,body 1-1 d,#0d1410,,body 2-6 #616f64,#0d1410,b,body 7-23 #e5eee5,#0d1410,,body 24-36 #b6ce94,#0d1410,,body 37-37 #e5eee5,#0d1410,,body 38-89 d,#0d1410,,body -|6: 4 pub fn choose(ok: bool) u32 { -@6: 0-0 d,#637f6a,,body 1-1 d,#0d1410,,body 2-6 #59675c,#0d1410,,body 7-10 #e5eee5,#0d1410,,body 11-12 #c9b0e4,#0d1410,,body 13-35 #e5eee5,#0d1410,,body 36-89 d,#0d1410,,body -|7: 5 if (ok) return 42; -@7: 0-0 d,#637f6a,,body 1-1 d,#0d1410,,body 2-6 #59675c,#0d1410,,body 7-10 #e5eee5,#0d1410,,body 11-12 #c9b0e4,#0d1410,,body 13-18 #e5eee5,#0d1410,,body 19-24 #c9b0e4,#0d1410,,body 25-25 #e5eee5,#0d1410,,body 26-27 #e9bf91,#0d1410,,body 28-28 #e5eee5,#0d1410,,body 29-89 d,#0d1410,,body -|8: 6 return 7; -@8: 0-0 d,#637f6a,,body 1-1 d,#0d1410,,body 2-6 #59675c,#0d1410,,body 7-10 #e5eee5,#0d1410,,body 11-16 #c9b0e4,#0d1410,,body 17-17 #e5eee5,#0d1410,,body 18-18 #e9bf91,#0d1410,,body 19-19 #e5eee5,#0d1410,,body 20-89 d,#0d1410,,body +|2: 0-1 #000000,#add38a, 2-2 d,#26362d, 3-29 #becfc4,#26362d, 30-37 #dfbce5,#26362d, 38-73 #becfc4,#26362d, 74-89 d,#26362d, +|4: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-17 #b9f480,#0d1410, 18-18 d,d, 19-89 d,#0d1410, +|5: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #616f64,#0d1410,b 7-23 #e5eee5,#0d1410, 24-32 #b8d88a,#0d1410, 33-33 d,d, 34-36 #b8d88a,#0d1410, 37-37 #e5eee5,#0d1410, 38-89 d,#0d1410, +|6: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-89 d,#0d1410, +|7: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-10 #e5eee5,#0d1410, 11-12 #c9a7ed,#0d1410, 13-35 #e5eee5,#0d1410, 36-89 d,#0d1410, +|8: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-10 #e5eee5,#0d1410, 11-12 #c9a7ed,#0d1410, 13-18 #e5eee5,#0d1410, 19-24 #c9a7ed,#0d1410, 25-25 #e5eee5,#0d1410, 26-27 #f8c082,#0d1410, 28-28 #e5eee5,#0d1410, 29-89 d,#0d1410, +|9: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-10 #e5eee5,#0d1410, 11-16 #c9a7ed,#0d1410, 17-17 #e5eee5,#0d1410, 18-18 #f8c082,#0d1410, 19-19 #e5eee5,#0d1410, 20-89 d,#0d1410, +|10: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-7 #e5eee5,#0d1410, 8-89 d,#0d1410, +== 9p colors-on grid=90x15 cursor=7,5,block +|3: Colors +@3: 0-0 d,#152019,,body 1-1 d,#0d1410,,body 2-83 d,#1d2824,,tagline 84-89 #b2c3b8,#1d2824,,tagline +|4: 1 // café λ 界 ++4: 13="é" 15="λ" 17="界" 18="" +@4: 0-0 d,#608269,,body 1-1 d,#0d1410,,body 2-6 #59675c,#0d1410,,body 7-18 #b9f480,#0d1410,,body 19-89 d,#0d1410,,body +|5: 2 const greeting = "café λ 界 eÌ�"; ++5: 28="é" 30="λ" 32="界" 33="" 35="eÌ�" +@5: 0-0 d,#608269,,body 1-1 d,#0d1410,,body 2-6 #616f64,#0d1410,b,body 7-23 #e5eee5,#0d1410,,body 24-36 #b8d88a,#0d1410,,body 37-37 #e5eee5,#0d1410,,body 38-89 d,#0d1410,,body +|6: 3 +@6: 0-0 d,#608269,,body 1-1 d,#0d1410,,body 2-6 #59675c,#0d1410,,body 7-89 d,#0d1410,,body +|7: 4 pub fn choose(ok: bool) u32 { +@7: 0-0 d,#608269,,body 1-1 d,#0d1410,,body 2-6 #59675c,#0d1410,,body 7-10 #e5eee5,#0d1410,,body 11-12 #c9a7ed,#0d1410,,body 13-35 #e5eee5,#0d1410,,body 36-89 d,#0d1410,,body +|8: 5 if (ok) return 42; +@8: 0-0 d,#608269,,body 1-1 d,#0d1410,,body 2-6 #59675c,#0d1410,,body 7-10 #e5eee5,#0d1410,,body 11-12 #c9a7ed,#0d1410,,body 13-18 #e5eee5,#0d1410,,body 19-24 #c9a7ed,#0d1410,,body 25-25 #e5eee5,#0d1410,,body 26-27 #f8c082,#0d1410,,body 28-28 #e5eee5,#0d1410,,body 29-89 d,#0d1410,,body +|9: 6 return 7; +@9: 0-0 d,#608269,,body 1-1 d,#0d1410,,body 2-6 #59675c,#0d1410,,body 7-10 #e5eee5,#0d1410,,body 11-16 #c9a7ed,#0d1410,,body 17-17 #e5eee5,#0d1410,,body 18-18 #f8c082,#0d1410,,body 19-19 #e5eee5,#0d1410,,body 20-89 d,#0d1410,,body +|10: 7 } +@10: 0-0 d,#608269,,body 1-1 d,#0d1410,,body 2-6 #59675c,#0d1410,,body 7-7 #e5eee5,#0d1410,,body 8-89 d,#0d1410,,body +|11: 8 +@11: 0-0 d,#608269,,body 1-1 d,#0d1410,,body 2-6 #59675c,#0d1410,,body 7-89 d,#0d1410,,body == style resized grid=105x20 |0: 0-70 #b2c3b8,#1d2824, 71-104 d,#1d2824, -|1: 0-24 #becfc4,#26362d, 25-104 d,#26362d, -|2: 0-1 #000000,#adcc91, 2-60 #becfc4,#26362d, 61-104 d,#26362d, -|3: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-17 #b9e58f,#0d1410, 18-18 d,d, 19-104 d,#0d1410, -|4: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-6 #616f64,#0d1410,b 7-23 #e5eee5,#0d1410, 24-32 #b6ce94,#0d1410, 33-33 d,d, 34-36 #b6ce94,#0d1410, 37-37 #e5eee5,#0d1410, 38-104 d,#0d1410, -|5: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-104 d,#0d1410, -|6: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-10 #e5eee5,#0d1410, 11-12 #c9b0e4,#0d1410, 13-35 #e5eee5,#0d1410, 36-104 d,#0d1410, -|7: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-10 #e5eee5,#0d1410, 11-12 #c9b0e4,#0d1410, 13-18 #e5eee5,#0d1410, 19-24 #c9b0e4,#0d1410, 25-25 #e5eee5,#0d1410, 26-27 #e9bf91,#0d1410, 28-28 #e5eee5,#0d1410, 29-104 d,#0d1410, -|8: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-10 #e5eee5,#0d1410, 11-16 #c9b0e4,#0d1410, 17-17 #e5eee5,#0d1410, 18-18 #e9bf91,#0d1410, 19-19 #e5eee5,#0d1410, 20-104 d,#0d1410, -|9: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-7 #e5eee5,#0d1410, 8-104 d,#0d1410, -|10: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-104 d,#0d1410, -|11: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-104 d,#0d1410, -|12: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-104 d,#0d1410, -|13: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-104 d,#0d1410, -|14: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-104 d,#0d1410, -|15: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-104 d,#0d1410, -|16: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-104 d,#0d1410, -|17: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-104 d,#0d1410, -|18: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-104 d,#0d1410, -|19: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-104 d,#0d1410, -== 9p resized grid=105x20 cursor=7,4,block +|1: 0-1 #ffffff,#887455, 2-2 d,#26362d, 3-34 #becfc4,#26362d, 35-104 d,#26362d, +|2: 0-1 #000000,#add38a, 2-2 d,#26362d, 3-29 #becfc4,#26362d, 30-37 #dfbce5,#26362d, 38-73 #becfc4,#26362d, 74-104 d,#26362d, +|3: 0-0 d,#152019, 1-1 d,#0d1410, 2-98 d,#1d2824, 99-104 #b2c3b8,#1d2824, +|4: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-17 #b9f480,#0d1410, 18-18 d,d, 19-104 d,#0d1410, +|5: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #616f64,#0d1410,b 7-23 #e5eee5,#0d1410, 24-32 #b8d88a,#0d1410, 33-33 d,d, 34-36 #b8d88a,#0d1410, 37-37 #e5eee5,#0d1410, 38-104 d,#0d1410, +|6: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-104 d,#0d1410, +|7: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-10 #e5eee5,#0d1410, 11-12 #c9a7ed,#0d1410, 13-35 #e5eee5,#0d1410, 36-104 d,#0d1410, +|8: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-10 #e5eee5,#0d1410, 11-12 #c9a7ed,#0d1410, 13-18 #e5eee5,#0d1410, 19-24 #c9a7ed,#0d1410, 25-25 #e5eee5,#0d1410, 26-27 #f8c082,#0d1410, 28-28 #e5eee5,#0d1410, 29-104 d,#0d1410, +|9: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-10 #e5eee5,#0d1410, 11-16 #c9a7ed,#0d1410, 17-17 #e5eee5,#0d1410, 18-18 #f8c082,#0d1410, 19-19 #e5eee5,#0d1410, 20-104 d,#0d1410, +|10: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-7 #e5eee5,#0d1410, 8-104 d,#0d1410, +|11: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-104 d,#0d1410, +|12: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-104 d,#0d1410, +|13: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-104 d,#0d1410, +|14: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-104 d,#0d1410, +|15: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-104 d,#0d1410, +|16: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-104 d,#0d1410, +|17: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-104 d,#0d1410, +|18: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-104 d,#0d1410, +|19: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-104 d,#0d1410, +== 9p resized grid=105x20 cursor=7,5,block |0: Newcol Joincol Find Grep Help Changelog Tutor Dump NextColor Debug Kill @0: 0-70 #b2c3b8,#1d2824,,tagline 71-104 d,#1d2824,,tagline -|1: New Tty Find Grep Joincol -@1: 0-24 #becfc4,#26362d,,tagline 25-104 d,#26362d,,tagline -|2: /tmp/pardes-snap/ninep/cwd/demo.zig * Save Tty Del Collapse -@2: 0-1 #000000,#adcc91,,tagline 2-60 #becfc4,#26362d,,tagline 61-104 d,#26362d,,tagline -|3: 1 // café λ 界 -+3: 13="é" 15="λ" 17="界" 18="" -@3: 0-0 d,#637f6a,,body 1-1 d,#0d1410,,body 2-6 #59675c,#0d1410,,body 7-18 #b9e58f,#0d1410,,body 19-104 d,#0d1410,,body -|4: 2 const greeting = "café λ 界 eÌ�"; -+4: 28="é" 30="λ" 32="界" 33="" 35="eÌ�" -@4: 0-0 d,#637f6a,,body 1-1 d,#0d1410,,body 2-6 #616f64,#0d1410,b,body 7-23 #e5eee5,#0d1410,,body 24-36 #b6ce94,#0d1410,,body 37-37 #e5eee5,#0d1410,,body 38-104 d,#0d1410,,body -|5: 3 -@5: 0-0 d,#637f6a,,body 1-1 d,#0d1410,,body 2-6 #59675c,#0d1410,,body 7-104 d,#0d1410,,body -|6: 4 pub fn choose(ok: bool) u32 { -@6: 0-0 d,#637f6a,,body 1-1 d,#0d1410,,body 2-6 #59675c,#0d1410,,body 7-10 #e5eee5,#0d1410,,body 11-12 #c9b0e4,#0d1410,,body 13-35 #e5eee5,#0d1410,,body 36-104 d,#0d1410,,body -|7: 5 if (ok) return 42; -@7: 0-0 d,#637f6a,,body 1-1 d,#0d1410,,body 2-6 #59675c,#0d1410,,body 7-10 #e5eee5,#0d1410,,body 11-12 #c9b0e4,#0d1410,,body 13-18 #e5eee5,#0d1410,,body 19-24 #c9b0e4,#0d1410,,body 25-25 #e5eee5,#0d1410,,body 26-27 #e9bf91,#0d1410,,body 28-28 #e5eee5,#0d1410,,body 29-104 d,#0d1410,,body -|8: 6 return 7; -@8: 0-0 d,#637f6a,,body 1-1 d,#0d1410,,body 2-6 #59675c,#0d1410,,body 7-10 #e5eee5,#0d1410,,body 11-16 #c9b0e4,#0d1410,,body 17-17 #e5eee5,#0d1410,,body 18-18 #e9bf91,#0d1410,,body 19-19 #e5eee5,#0d1410,,body 20-104 d,#0d1410,,body -|9: 7 } -@9: 0-0 d,#637f6a,,body 1-1 d,#0d1410,,body 2-6 #59675c,#0d1410,,body 7-7 #e5eee5,#0d1410,,body 8-104 d,#0d1410,,body -|10: 8 -@10: 0-0 d,#637f6a,,body 1-1 d,#0d1410,,body 2-6 #59675c,#0d1410,,body 7-104 d,#0d1410,,body -|11: -@11: 0-0 d,#637f6a,,body 1-1 d,#0d1410,,body 2-6 #59675c,#0d1410,,body 7-104 d,#0d1410,,body +|1: New Tty Find Grep Joincol Delcol +@1: 0-1 #ffffff,#887455,,tagline 2-2 d,#26362d,,tagline 3-34 #becfc4,#26362d,,tagline 35-104 d,#26362d,,tagline +|2: /tmp/pardes-snap/ninep/cwd/demo.zig * Save Tty Collapse Del TreeContext +@2: 0-1 #000000,#add38a,,tagline 2-2 d,#26362d,,tagline 3-29 #becfc4,#26362d,,tagline 30-37 #dfbce5,#26362d,,tagline 38-73 #becfc4,#26362d,,tagline 74-104 d,#26362d,,tagline +|3: Colors +@3: 0-0 d,#152019,,body 1-1 d,#0d1410,,body 2-98 d,#1d2824,,tagline 99-104 #b2c3b8,#1d2824,,tagline +|4: 1 // café λ 界 ++4: 13="é" 15="λ" 17="界" 18="" +@4: 0-0 d,#608269,,body 1-1 d,#0d1410,,body 2-6 #59675c,#0d1410,,body 7-18 #b9f480,#0d1410,,body 19-104 d,#0d1410,,body +|5: 2 const greeting = "café λ 界 eÌ�"; ++5: 28="é" 30="λ" 32="界" 33="" 35="eÌ�" +@5: 0-0 d,#608269,,body 1-1 d,#0d1410,,body 2-6 #616f64,#0d1410,b,body 7-23 #e5eee5,#0d1410,,body 24-36 #b8d88a,#0d1410,,body 37-37 #e5eee5,#0d1410,,body 38-104 d,#0d1410,,body +|6: 3 +@6: 0-0 d,#608269,,body 1-1 d,#0d1410,,body 2-6 #59675c,#0d1410,,body 7-104 d,#0d1410,,body +|7: 4 pub fn choose(ok: bool) u32 { +@7: 0-0 d,#608269,,body 1-1 d,#0d1410,,body 2-6 #59675c,#0d1410,,body 7-10 #e5eee5,#0d1410,,body 11-12 #c9a7ed,#0d1410,,body 13-35 #e5eee5,#0d1410,,body 36-104 d,#0d1410,,body +|8: 5 if (ok) return 42; +@8: 0-0 d,#608269,,body 1-1 d,#0d1410,,body 2-6 #59675c,#0d1410,,body 7-10 #e5eee5,#0d1410,,body 11-12 #c9a7ed,#0d1410,,body 13-18 #e5eee5,#0d1410,,body 19-24 #c9a7ed,#0d1410,,body 25-25 #e5eee5,#0d1410,,body 26-27 #f8c082,#0d1410,,body 28-28 #e5eee5,#0d1410,,body 29-104 d,#0d1410,,body +|9: 6 return 7; +@9: 0-0 d,#608269,,body 1-1 d,#0d1410,,body 2-6 #59675c,#0d1410,,body 7-10 #e5eee5,#0d1410,,body 11-16 #c9a7ed,#0d1410,,body 17-17 #e5eee5,#0d1410,,body 18-18 #f8c082,#0d1410,,body 19-19 #e5eee5,#0d1410,,body 20-104 d,#0d1410,,body +|10: 7 } +@10: 0-0 d,#608269,,body 1-1 d,#0d1410,,body 2-6 #59675c,#0d1410,,body 7-7 #e5eee5,#0d1410,,body 8-104 d,#0d1410,,body +|11: 8 +@11: 0-0 d,#608269,,body 1-1 d,#0d1410,,body 2-6 #59675c,#0d1410,,body 7-104 d,#0d1410,,body |12: -@12: 0-0 d,#637f6a,,body 1-1 d,#0d1410,,body 2-6 #59675c,#0d1410,,body 7-104 d,#0d1410,,body +@12: 0-0 d,#608269,,body 1-1 d,#0d1410,,body 2-6 #59675c,#0d1410,,body 7-104 d,#0d1410,,body |13: -@13: 0-0 d,#637f6a,,body 1-1 d,#0d1410,,body 2-6 #59675c,#0d1410,,body 7-104 d,#0d1410,,body +@13: 0-0 d,#608269,,body 1-1 d,#0d1410,,body 2-6 #59675c,#0d1410,,body 7-104 d,#0d1410,,body |14: -@14: 0-0 d,#637f6a,,body 1-1 d,#0d1410,,body 2-6 #59675c,#0d1410,,body 7-104 d,#0d1410,,body +@14: 0-0 d,#608269,,body 1-1 d,#0d1410,,body 2-6 #59675c,#0d1410,,body 7-104 d,#0d1410,,body |15: -@15: 0-0 d,#637f6a,,body 1-1 d,#0d1410,,body 2-6 #59675c,#0d1410,,body 7-104 d,#0d1410,,body +@15: 0-0 d,#608269,,body 1-1 d,#0d1410,,body 2-6 #59675c,#0d1410,,body 7-104 d,#0d1410,,body |16: -@16: 0-0 d,#637f6a,,body 1-1 d,#0d1410,,body 2-6 #59675c,#0d1410,,body 7-104 d,#0d1410,,body +@16: 0-0 d,#608269,,body 1-1 d,#0d1410,,body 2-6 #59675c,#0d1410,,body 7-104 d,#0d1410,,body |17: -@17: 0-0 d,#637f6a,,body 1-1 d,#0d1410,,body 2-6 #59675c,#0d1410,,body 7-104 d,#0d1410,,body +@17: 0-0 d,#608269,,body 1-1 d,#0d1410,,body 2-6 #59675c,#0d1410,,body 7-104 d,#0d1410,,body |18: -@18: 0-0 d,#637f6a,,body 1-1 d,#0d1410,,body 2-6 #59675c,#0d1410,,body 7-104 d,#0d1410,,body +@18: 0-0 d,#608269,,body 1-1 d,#0d1410,,body 2-6 #59675c,#0d1410,,body 7-104 d,#0d1410,,body |19: -@19: 0-0 d,#637f6a,,body 1-1 d,#0d1410,,body 2-6 #59675c,#0d1410,,body 7-104 d,#0d1410,,body -== snap resized grid=105x20 cursor=7,4 +@19: 0-0 d,#608269,,body 1-1 d,#0d1410,,body 2-6 #59675c,#0d1410,,body 7-104 d,#0d1410,,body +== snap resized grid=105x20 cursor=7,5 |Newcol Joincol Find Grep Help Changelog Tutor Dump NextColor Debug Kill -|New Tty Find Grep Joincol -| /tmp/pardes-snap/ninep/cwd/demo.zig * Save Tty Del Collapse +| New Tty Find Grep Joincol Delcol +| /tmp/pardes-snap/ninep/cwd/demo.zig * Save Tty Collapse Del TreeContext +| Colors | 1 // café λ 界 | 2 const greeting = "café λ 界 eÌ�"; | 3 @@ -201,4 +221,4 @@ | 6 return 7; | 7 } | 8 -== 9p unchanged grid=105x20 cursor=7,4,block +== 9p unchanged grid=105x20 cursor=7,5,block diff --git a/test/snapshots/pipe.golden b/test/snapshots/pipe.golden index e6d558a6..d3f6bbc2 100644 --- a/test/snapshots/pipe.golden +++ b/test/snapshots/pipe.golden @@ -1,20 +1,14 @@ -== snap prompt grid=180x13 cursor=14,12 +== snap prompt grid=180x13 cursor=179,3 |Newcol Joincol Find Grep Help Changelog Tutor Dump NextColor Debug Kill -|New Tty Find Grep Joincol -| /tmp/pardes-snap/pipe/cwd/pipe.txt Save Tty Del Collapse +| New Tty Find Grep Joincol Delcol +| /tmp/pardes-snap/pipe/cwd/pipe.txt Save Tty Collapse Del +| |tr a-z A-Z | 1 alpha beta | 2 gamma delta -| -| -| -| -| -| -| -| |tr a-z A-Z == snap filtered grid=180x13 cursor=17,3 -|2: /tmp/pardes-snap/pipe/cwd/pipe.txt * Save Tty Del Collapse +|2: /tmp/pardes-snap/pipe/cwd/pipe.txt * Save Tty Collapse Del |3: 1 ALPHA BETA -|12: +|4: 2 gamma delta +|5: == snap undone grid=180x13 cursor=17,3 |3: 1 alpha beta diff --git a/test/snapshots/psearch.golden b/test/snapshots/psearch.golden index d1a28996..b0827d7c 100644 --- a/test/snapshots/psearch.golden +++ b/test/snapshots/psearch.golden @@ -1,62 +1,104 @@ == snap output grid=140x31 cursor=4,9 |Newcol Joincol Find Grep Help Changelog Tutor Dump NextColor Debug Kill -|New Tty Find Grep Joincol -| /tmp/pardes-snap/psearch/cwd Save Tty Del Togglettymode Filter Collapse +| New Tty Find Grep Joincol Delcol +| /tmp/pardes-snap/psearch/cwd Tty Save Mode Filter Collapse Del | printf 'x MA''RK a\nzz\nx MA''RK b\nzz\nx MA''RK c\n' | x MARK a | zz | x MARK b | zz | x MARK c -== snap typing grid=140x31 cursor=8,30 -|30: /MARK +| +| +| +| +| +| +| +| +| +| +| +| +| /+New Save Tty Collapse Del +| 1 +== snap typing grid=140x31 cursor=139,3 +|3: /MARK +|4: printf 'x MA''RK a\nzz\nx MA''RK b\nzz\nx MA''RK c\n' +|5: x MARK a +|6: zz +|7: x MARK b +|8: zz +|9: x MARK c == snap results grid=140x31 cursor=7,4 -|27: /tmp/pardes-snap/psearch/cwd/+Search Save Tty Del Collapse -|28: 1 @p0:2:3-6 x MARK a -|29: 2 @p0:4:3-6 x MARK b -|30: 3 @p0:6:3-6 x MARK c +|3: printf 'x MA''RK a\nzz\nx MA''RK b\nzz\nx MA''RK c\n' +|4: x MARK a +|5: zz +|6: x MARK b +|7: zz +|8: x MARK c +|9: +|14: /tmp/pardes-snap/psearch/cwd/+Search Save Tty Collapse Del LocationsConfig +|15: Look +|16: 1 @p0:2:3-6 +|17: 2 x MARK a +|18: 3 @p0:4:3-6 +|19: 4 x MARK b +|20: 5 @p0:6:3-6 == style results grid=140x31 |0: 0-70 #b2c3b8,#1d2824, 71-139 d,#1d2824, -|1: 0-24 #becfc4,#26362d, 25-139 d,#26362d, -|2: 0-1 #000000,#adcc91, 2-72 #becfc4,#26362d, 73-139 d,#26362d, -|3: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-139 #e5eee5,#0d1410, -|4: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-3 #e5eee5,#0d1410, 4-7 #f5f7ee,#405d4b, 8-139 #e5eee5,#0d1410, -|5: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-139 #e5eee5,#0d1410, -|6: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-139 #e5eee5,#0d1410, -|7: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-139 #e5eee5,#0d1410, -|8: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-139 #e5eee5,#0d1410, -|9: 0-0 d,#637f6a, 1-139 d,#0d1410, -|10: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-139 #e5eee5,#0d1410, -|11: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-139 #e5eee5,#0d1410, -|12: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-139 #e5eee5,#0d1410, -|13: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-139 #e5eee5,#0d1410, -|14: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-139 #e5eee5,#0d1410, -|15: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-139 #e5eee5,#0d1410, -|16: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-139 #e5eee5,#0d1410, -|17: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-139 #e5eee5,#0d1410, -|18: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-139 #e5eee5,#0d1410, -|19: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-139 #e5eee5,#0d1410, -|20: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-139 #e5eee5,#0d1410, -|21: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-139 #e5eee5,#0d1410, -|22: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-139 #e5eee5,#0d1410, -|23: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-139 #e5eee5,#0d1410, -|24: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-139 #e5eee5,#0d1410, -|25: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-139 #e5eee5,#0d1410, -|26: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-139 #e5eee5,#0d1410, -|27: 0-1 #ffffff,#4c6356, 2-59 #b2c3b8,#1d2824, 60-139 d,#1d2824, -|28: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-15 #59675c,#0d1410, 16-18 #e5eee5,#0d1410, 19-22 #f7e4a5,#57472a, 23-24 #e5eee5,#0d1410, 25-139 d,#0d1410, -|29: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-15 #59675c,#0d1410, 16-18 #e5eee5,#0d1410, 19-22 #f7e4a5,#57472a, 23-24 #e5eee5,#0d1410, 25-139 d,#0d1410, -|30: 0-0 d,#152019, 1-1 d,#0d1410, 2-15 #59675c,#0d1410, 16-18 #e5eee5,#0d1410, 19-22 #f7e4a5,#57472a, 23-24 #e5eee5,#0d1410, 25-139 d,#0d1410, +|1: 0-1 #ffffff,#887455, 2-2 d,#26362d, 3-34 #becfc4,#26362d, 35-139 d,#26362d, +|2: 0-1 #000000,#add38a, 2-2 d,#26362d, 3-31 #becfc4,#26362d, 32-34 #dfbce5,#26362d, 35-64 #becfc4,#26362d, 65-139 d,#26362d, +|3: 0-0 d,#608269, 1-1 d,#0d1410, 2-139 #e5eee5,#0d1410, +|4: 0-0 d,#608269, 1-1 d,#0d1410, 2-3 #e5eee5,#0d1410, 4-7 #f5f7ee,#3c614a, 8-139 #e5eee5,#0d1410, +|5: 0-0 d,#608269, 1-1 d,#0d1410, 2-139 #e5eee5,#0d1410, +|6: 0-0 d,#608269, 1-1 d,#0d1410, 2-139 #e5eee5,#0d1410, +|7: 0-0 d,#608269, 1-1 d,#0d1410, 2-139 #e5eee5,#0d1410, +|8: 0-0 d,#608269, 1-1 d,#0d1410, 2-139 #e5eee5,#0d1410, +|9: 0-0 d,#608269, 1-139 d,#0d1410, +|10: 0-0 d,#608269, 1-1 d,#0d1410, 2-139 #e5eee5,#0d1410, +|11: 0-0 d,#608269, 1-1 d,#0d1410, 2-139 #e5eee5,#0d1410, +|12: 0-0 d,#608269, 1-1 d,#0d1410, 2-139 #e5eee5,#0d1410, +|13: 0-0 d,#608269, 1-1 d,#0d1410, 2-139 #e5eee5,#0d1410, +|14: 0-1 #ffffff,#496656, 2-2 d,#1d2824, 3-31 #b2c3b8,#1d2824, 32-38 #d3b0d9,#1d2824, 39-76 #b2c3b8,#1d2824, 77-139 d,#1d2824, +|15: 0-0 d,#152019, 1-1 d,#0d1410, 2-135 d,#1d2824, 136-139 #b2c3b8,#1d2824, +|16: 0-0 d,#608269, 1-1 d,#0d1410, 2-15 #59675c,#0d1410, 16-139 d,#0d1410, +|17: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-8 #e5eee5,#0d1410, 9-12 #f7e4a5,#5e4923, 13-14 #e5eee5,#0d1410, 15-139 d,#0d1410, +|18: 0-0 d,#608269, 1-1 d,#0d1410, 2-15 #59675c,#0d1410, 16-139 d,#0d1410, +|19: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-8 #e5eee5,#0d1410, 9-12 #f7e4a5,#5e4923, 13-14 #e5eee5,#0d1410, 15-139 d,#0d1410, +|20: 0-0 d,#152019, 1-1 d,#0d1410, 2-15 #59675c,#0d1410, 16-139 d,#0d1410, +|21: 0-1 #ffffff,#496656, 2-2 d,#1d2824, 3-3 #b2c3b8,#1d2824, 4-7 #d3b0d9,#1d2824, 8-29 #b2c3b8,#1d2824, 30-139 d,#1d2824, +|22: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-139 d,#0d1410, +|23: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-139 d,#0d1410, +|24: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-139 d,#0d1410, +|25: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-139 d,#0d1410, +|26: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-139 d,#0d1410, +|27: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-139 d,#0d1410, +|28: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-139 d,#0d1410, +|29: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-139 d,#0d1410, +|30: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-139 d,#0d1410, == snap second grid=140x31 cursor=7,6 == snap back grid=140x31 cursor=7,4 -== snap nomatch grid=140x31 cursor=7,29 -|25: /tmp/pardes-snap/psearch/cwd/+Search Save Tty Del Collapse -|26: 1 -== snap ttyinert grid=140x31 cursor=4,9 -|2: $ /tmp/pardes-snap/psearch/cwd Save Tty Del Togglettymode Filter Collapse -|3: $ printf 'x MA''RK a\nzz\nx MA''RK b\nzz\nx MA''RK c\n' -|9: $ -== snap rightsearch grid=140x31 cursor=7,6 -|2: /tmp/pardes-snap/psearch/cwd Save Tty Del Togglettymode Filter Collapse -|3: printf 'x MA''RK a\nzz\nx MA''RK b\nzz\nx MA''RK c\n' -|9: +== snap nomatch grid=140x31 cursor=7,17 +|12: /tmp/pardes-snap/psearch/cwd/+Search Save Tty Collapse Del LocationsConfig +|13: 1 +|15: 1 @p0:2:3-6 +|16: 2 x MARK a +|17: 3 @p0:4:3-6 +|18: 4 x MARK b +|19: 5 @p0:6:3-6 +|20: 6 x MARK c +== snap ttyinert grid=140x31 cursor=4,10 +|2: $ /tmp/pardes-snap/psearch/cwd Tty Save Mode Filter Collapse Del +|3: Look +|4: $ printf 'x MA''RK a\nzz\nx MA''RK b\nzz\nx MA''RK c\n' +|5: x MARK a +|6: zz +|7: x MARK b +|8: zz +|9: x MARK c +|10: $ +== snap rightsearch grid=140x31 cursor=7,7 +|2: /tmp/pardes-snap/psearch/cwd Tty Save Mode Filter Collapse Del +|4: printf 'x MA''RK a\nzz\nx MA''RK b\nzz\nx MA''RK c\n' +|10: diff --git a/test/snapshots/reflow.golden b/test/snapshots/reflow.golden index 3c2f5ff4..a13b5936 100644 --- a/test/snapshots/reflow.golden +++ b/test/snapshots/reflow.golden @@ -1,11 +1,7 @@ -== snap widened grid=200x25 cursor=4,20 +== snap widened grid=200x25 cursor=4,16 |Newcol Joincol Find Grep Help Changelog Tutor Dump NextColor Debug Kill -|New Tty Find Grep Joincol -|$ /tmp/pardes-snap/reflow/cwd Save Tty Del Togglettymode Filter Collapse -| $ printf 'y%.0s' $(seq 1 3000); echo do''ne -| yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy -| yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy -| yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy +| New Tty Find Grep Joincol Delcol +|$ /tmp/pardes-snap/reflow/cwd Tty Save Mode Filter Collapse Del | yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy | yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy | yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy @@ -20,3 +16,5 @@ | yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy | yyyyyyyyyyyyyyyyyyyyyyyyyyyyyydone | $ +| /+New Save Tty Collapse Del +| 1 diff --git a/test/snapshots/respawn.golden b/test/snapshots/respawn.golden index 9aa6b46b..e2b6a75c 100644 --- a/test/snapshots/respawn.golden +++ b/test/snapshots/respawn.golden @@ -1,10 +1,10 @@ -== snap respawn grid=100x31 cursor=4,9 +== snap respawn grid=140x31 cursor=4,9 |Newcol Joincol Find Grep Help Changelog Tutor Dump NextColor Debug Kill -|New Tty Find Grep Joincol New Tty Find Grep Joincol -| /tmp/pardes-snap/respawn/cwd Save Tty Del Toggle /tmp/pardes-snap/respawn/cwd Save Tty Del Toggle -| ls ls +| New Tty Find Grep Joincol Delcol New Tty Find Grep Joincol Delcol +| /tmp/pardes-snap/respawn/cwd Tty Save Mode Filter Collapse Del /tmp/pardes-snap/respawn/cwd Tty Save Mode Filter Collapse Del +| ls ls | -|$ /tmp/pardes-snap/respawn/cwd Save Tty Del Toggle +|$ /tmp/pardes-snap/respawn/cwd Tty Save Mode Filter Collapse Del | $ ls | $ echo RESP''AWNOK | RESPAWNOK diff --git a/test/snapshots/respawn.snap b/test/snapshots/respawn.snap index 66393da9..eac74267 100644 --- a/test/snapshots/respawn.snap +++ b/test/snapshots/respawn.snap @@ -1,7 +1,7 @@ # a deleted shell pane's pty lingers in its slot (there is no close effect); # a later spawn reusing the pane id must reap it instead of tripping the # drainEffects spawn assert — this exact sequence crashed pre-fix -start 31 100 -n 3 +start 31 140 -n 3 wait 8000 Newcol Joincol stable 700 20000 # middle-click Del on the lower-left pane's tag: the pane id is freed while diff --git a/test/snapshots/restore.golden b/test/snapshots/restore.golden index d2a60c4a..11d92288 100644 --- a/test/snapshots/restore.golden +++ b/test/snapshots/restore.golden @@ -1,14 +1,14 @@ == snap dumped grid=100x31 cursor=4,6 |Newcol Joincol Find Grep Help Changelog Tutor Dump NextColor Debug Kill Restore /tmp/pardes-snap/res -|New Tty Find Grep Joincol -|$ /tmp/pardes-snap/restore/cwd Save Tty Del Togglettymode Filter Collapse +| New Tty Find Grep Joincol Delcol +|$ /tmp/pardes-snap/restore/cwd Tty Save Mode Filter Collapse Del | $ ls | $ echo KEEP''ME | KEEPME | $ == snap restored grid=100x31 cursor=4,6 |0: Newcol Joincol Find Grep Help Changelog Tutor Dump NextColor Debug Kill -|2: /tmp/pardes-snap/restore/cwd Save Tty Del Togglettymode Filter Collapse +|2: /tmp/pardes-snap/restore/cwd Tty Save Mode Filter Collapse Del |3: ls |4: echo KEEP''ME |6: diff --git a/test/snapshots/rsearch.golden b/test/snapshots/rsearch.golden index f0bc0594..9b1f12d4 100644 --- a/test/snapshots/rsearch.golden +++ b/test/snapshots/rsearch.golden @@ -1,7 +1,7 @@ == snap opened grid=210x31 cursor=7,3 |Newcol Joincol Find Grep Help Changelog Tutor Dump NextColor Debug Kill -|New Tty Find Grep Joincol New Tty Find Grep Joincol -| /tmp/pardes-snap/rsearch/cwd/code.txt Save Tty Del Collapse /tmp/pardes-snap/rsearch/cwd Save Tty Del Togglettymode Filter Collapse +| New Tty Find Grep Joincol Delcol New Tty Find Grep Joincol Delcol +| /tmp/pardes-snap/rsearch/cwd/code.txt Save Tty Collapse Del /tmp/pardes-snap/rsearch/cwd Tty Save Mode Filter Collapse Del | 1 run count_x now ls | 2 open sub/dep.txt:3 here code.txt sub | 3 count_x again @@ -9,24 +9,28 @@ | | code.txt == snap search grid=210x31 cursor=13,5 -|28: /tmp/pardes-snap/rsearch/cwd/+Search Save Tty Del Collapse -|29: 1 code.txt:1:5-11 run count_x now -|30: 2 code.txt:3:1-7 count_x again +|26: /tmp/pardes-snap/rsearch/cwd/+Search Save Tty Collapse Del LocationsConfig +|27: 1 code.txt:1:5-11 +|28: 2 run count_x now +|29: 3 code.txt:3:1-7 +|30: 4 count_x again == snap select grid=210x31 cursor=14,6 -|26: /tmp/pardes-snap/rsearch/cwd/+Search Save Tty Del Collapse -|27: 1 code.txt:4:1-8 pick two words -== snap path-open grid=210x31 cursor=7,17 -|14: /tmp/pardes-snap/rsearch/cwd/sub/dep.txt Save Tty Del Collapse -|15: 1 d1 -|16: 2 d2 -|17: 3 DEPTARGET -|18: 4 d4 -|19: 5 d5 -|20: 6 d6 +|23: /tmp/pardes-snap/rsearch/cwd/+Search Save Tty Collapse Del LocationsConfig +|24: 1 code.txt:4:1-8 +|25: 2 pick two words +== snap path-open grid=210x31 cursor=7,16 +|13: /tmp/pardes-snap/rsearch/cwd/sub/dep.txt Save Tty Collapse Del +|14: 1 d1 +|15: 2 d2 +|16: 3 DEPTARGET +|17: 4 d4 +|18: 5 d5 +|19: 6 d6 == snap step1 grid=210x31 cursor=13,5 -== snap step2 grid=210x31 cursor=17,3 -== snap step3 grid=210x31 cursor=17,3 +== snap step2 grid=210x31 cursor=13,5 +== snap step3 grid=210x31 cursor=13,5 == snap selclick grid=210x31 cursor=14,6 == snap outside grid=210x31 cursor=20,6 -|12: /tmp/pardes-snap/rsearch/cwd/+Search Save Tty Del Collapse -|13: 1 code.txt:4:10-14 pick two words +|10: /tmp/pardes-snap/rsearch/cwd/+Search Save Tty Collapse Del LocationsConfig +|11: 1 code.txt:4:10-14 +|12: 2 pick two words diff --git a/test/snapshots/rsearch.snap b/test/snapshots/rsearch.snap index c413c559..30459488 100644 --- a/test/snapshots/rsearch.snap +++ b/test/snapshots/rsearch.snap @@ -7,6 +7,10 @@ dirmk sub file sub/dep.txt d1\nd2\nDEPTARGET\nd4\nd5\nd6 file code.txt run count_x now\nopen sub/dep.txt:3 here\ncount_x again\npick two words +# Builtins announce themselves by default, and an announcement is a band at +# the top of the body -- which moves every row this script clicks. What the +# verbs do is what is under test, not the announcement. +config Verbose off start 31 210 -n 1 wait 8000 code.txt stable 700 20000 @@ -28,7 +32,9 @@ snap opened # file, so the click searches for it: the results list both lines containing it. press right 15 4 release right 15 4 -wait 10000 code.txt:1:5-11 run count_x +# Locations stack the target under its line now: two rows, two waits. +wait 10000 code.txt:1:5-11 +wait 10000 run count_x now stable 700 15000 snap search # right-SELECT `pick two` (line 4, sweep cols 8..15): a multi-word span passes @@ -36,7 +42,8 @@ snap search press right 8 7 drag right 15 7 release right 15 7 -wait 10000 code.txt:4:1-8 pick two +wait 10000 code.txt:4:1-8 +wait 10000 pick two words stable 700 15000 snap select # right-CLICK the path `sub/dep.txt:3` (line 2, col 18): isFileChar keeps / . : diff --git a/test/snapshots/savepane.golden b/test/snapshots/savepane.golden index 070146d3..ab54ee3e 100644 --- a/test/snapshots/savepane.golden +++ b/test/snapshots/savepane.golden @@ -1,16 +1,20 @@ == snap scratch grid=100x31 cursor=20,6 |Newcol Joincol Find Grep Help Changelog Tutor Dump NextColor Debug Kill -|New Tty Find Grep Joincol -| /tmp/pardes-snap/savepane/cwd Save Tty Del Togglettymode Filter Collapse +| New Tty Find Grep Joincol Delcol +| /tmp/pardes-snap/savepane/cwd Tty Save Mode Filter Collapse Del | ls | -| /tmp/pardes-snap/savepane/cwd/+New * Save Tty Del Collapse +| /tmp/pardes-snap/savepane/cwd/+New * Save Tty Collapse Del | 1 scratch bytes -== snap prompt grid=100x31 cursor=38,30 -|30: Save /tmp/pardes-snap/savepane/cwd/ -== snap saved grid=100x31 cursor=20,6 -|5: /tmp/pardes-snap/savepane/cwd/saved.txt Save Tty Del Collapse -|30: --:--:-- saved /tmp/pardes-snap/savepane/cwd/saved.txt +== snap prompt grid=100x31 cursor=99,7 +|6: Save +|7: Save /tmp/pardes-snap/savepane/cwd/ +|8: 1 scratch bytes +== snap saved grid=100x31 cursor=20,7 +|5: /tmp/pardes-snap/savepane/cwd/saved.txt Save Tty Collapse Del +|6: --:--:-- saved /tmp/pardes-snap/savepane/cwd/saved.txt +|7: 1 scratch bytes +|8: == file bytes scratch bytes == end file diff --git a/test/snapshots/scroll.golden b/test/snapshots/scroll.golden index 46576f75..86bad0e5 100644 --- a/test/snapshots/scroll.golden +++ b/test/snapshots/scroll.golden @@ -1,7 +1,7 @@ == snap bottom grid=100x31 cursor=4,16 |Newcol Joincol Find Grep Help Changelog Tutor Dump NextColor Debug Kill -|New Tty Find Grep Joincol New Tty Find Grep Joincol -| /tmp/pardes-snap/scroll/cwd Save Tty Del Togglet /tmp/pardes-snap/scroll/cwd Save Tty Del Togglet +| New Tty Find Grep Joincol Delcol New Tty Find Grep Joincol Delcol +| /tmp/pardes-snap/scroll/cwd Tty Save Mode Filte /tmp/pardes-snap/scroll/cwd Tty Save Mode Filte | 188 ls | 189 s.txt | 190 @@ -16,7 +16,7 @@ | 199 | 200 | -| /tmp/pardes-snap/scroll/cwd Save Tty Del Togglet +| /tmp/pardes-snap/scroll/cwd Tty Save Mode Filte | ls | s.txt == snap wheel3 grid=100x31 cursor=4,16 @@ -81,33 +81,33 @@ |16: 194 == style wheel-down grid=100x31 |0: 0-70 #b2c3b8,#1d2824, 71-99 d,#1d2824, -|1: 0-24 #becfc4,#26362d, 25-49 d,#26362d, 50-74 #b2c3b8,#1d2824, 75-99 d,#1d2824, -|2: 0-1 #000000,#adcc91, 2-49 #becfc4,#26362d, 50-51 #ffffff,#4c6356, 52-99 #b2c3b8,#1d2824, -|3: 0-0 d,#152019, 1-1 d,#0d1410, 2-49 #e5eee5,#0d1410, 50-50 d,#637f6a, 51-51 d,#0d1410, 52-99 #e5eee5,#0d1410, -|4: 0-0 d,#152019, 1-1 d,#0d1410, 2-49 #e5eee5,#0d1410, 50-50 d,#637f6a, 51-51 d,#0d1410, 52-99 #e5eee5,#0d1410, -|5: 0-0 d,#152019, 1-1 d,#0d1410, 2-49 #e5eee5,#0d1410, 50-50 d,#637f6a, 51-99 d,#0d1410, -|6: 0-0 d,#152019, 1-1 d,#0d1410, 2-49 #e5eee5,#0d1410, 50-50 d,#637f6a, 51-51 d,#0d1410, 52-99 #e5eee5,#0d1410, -|7: 0-0 d,#152019, 1-1 d,#0d1410, 2-49 #e5eee5,#0d1410, 50-50 d,#637f6a, 51-51 d,#0d1410, 52-99 #e5eee5,#0d1410, -|8: 0-0 d,#152019, 1-1 d,#0d1410, 2-49 #e5eee5,#0d1410, 50-50 d,#637f6a, 51-51 d,#0d1410, 52-99 #e5eee5,#0d1410, -|9: 0-0 d,#152019, 1-1 d,#0d1410, 2-49 #e5eee5,#0d1410, 50-50 d,#637f6a, 51-51 d,#0d1410, 52-99 #e5eee5,#0d1410, -|10: 0-0 d,#152019, 1-1 d,#0d1410, 2-49 #e5eee5,#0d1410, 50-50 d,#637f6a, 51-51 d,#0d1410, 52-99 #e5eee5,#0d1410, -|11: 0-0 d,#152019, 1-1 d,#0d1410, 2-49 #e5eee5,#0d1410, 50-50 d,#637f6a, 51-51 d,#0d1410, 52-99 #e5eee5,#0d1410, -|12: 0-0 d,#152019, 1-1 d,#0d1410, 2-49 #e5eee5,#0d1410, 50-50 d,#637f6a, 51-51 d,#0d1410, 52-99 #e5eee5,#0d1410, -|13: 0-0 d,#152019, 1-1 d,#0d1410, 2-49 #e5eee5,#0d1410, 50-50 d,#637f6a, 51-51 d,#0d1410, 52-99 #e5eee5,#0d1410, -|14: 0-0 d,#152019, 1-1 d,#0d1410, 2-49 #e5eee5,#0d1410, 50-50 d,#637f6a, 51-51 d,#0d1410, 52-99 #e5eee5,#0d1410, -|15: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-49 #e5eee5,#0d1410, 50-50 d,#637f6a, 51-51 d,#0d1410, 52-99 #e5eee5,#0d1410, -|16: 0-0 d,#152019, 1-1 d,#0d1410, 2-49 #e5eee5,#0d1410, 50-50 d,#637f6a, 51-51 d,#0d1410, 52-99 #e5eee5,#0d1410, -|17: 0-1 #ffffff,#4c6356, 2-49 #b2c3b8,#1d2824, 50-50 d,#637f6a, 51-51 d,#0d1410, 52-99 #e5eee5,#0d1410, -|18: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-49 #e5eee5,#0d1410, 50-50 d,#637f6a, 51-51 d,#0d1410, 52-99 #e5eee5,#0d1410, -|19: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-49 #e5eee5,#0d1410, 50-50 d,#637f6a, 51-51 d,#0d1410, 52-99 #e5eee5,#0d1410, -|20: 0-0 d,#637f6a, 1-49 d,#0d1410, 50-50 d,#637f6a, 51-51 d,#0d1410, 52-99 #e5eee5,#0d1410, -|21: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-49 #e5eee5,#0d1410, 50-50 d,#637f6a, 51-51 d,#0d1410, 52-99 #e5eee5,#0d1410, -|22: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-49 #e5eee5,#0d1410, 50-50 d,#637f6a, 51-51 d,#0d1410, 52-99 #e5eee5,#0d1410, -|23: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-49 #e5eee5,#0d1410, 50-50 d,#637f6a, 51-51 d,#0d1410, 52-99 #e5eee5,#0d1410, -|24: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-49 #e5eee5,#0d1410, 50-50 d,#637f6a, 51-51 d,#0d1410, 52-99 #e5eee5,#0d1410, -|25: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-49 #e5eee5,#0d1410, 50-50 d,#637f6a, 51-51 d,#0d1410, 52-99 #e5eee5,#0d1410, -|26: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-49 #e5eee5,#0d1410, 50-50 d,#637f6a, 51-51 d,#0d1410, 52-99 #e5eee5,#0d1410, -|27: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-49 #e5eee5,#0d1410, 50-50 d,#637f6a, 51-51 d,#0d1410, 52-99 #e5eee5,#0d1410, -|28: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-49 #e5eee5,#0d1410, 50-50 d,#637f6a, 51-51 d,#0d1410, 52-99 #e5eee5,#0d1410, -|29: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-49 #e5eee5,#0d1410, 50-50 d,#637f6a, 51-51 d,#0d1410, 52-99 #e5eee5,#0d1410, -|30: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-49 #e5eee5,#0d1410, 50-50 d,#637f6a, 51-51 d,#0d1410, 52-99 #e5eee5,#0d1410, +|1: 0-1 #ffffff,#887455, 2-2 d,#26362d, 3-34 #becfc4,#26362d, 35-49 d,#26362d, 50-51 #ffffff,#887455, 52-52 d,#1d2824, 53-84 #b2c3b8,#1d2824, 85-99 d,#1d2824, +|2: 0-1 #000000,#add38a, 2-2 d,#26362d, 3-30 #becfc4,#26362d, 31-33 #dfbce5,#26362d, 34-49 #becfc4,#26362d, 50-51 #ffffff,#496656, 52-52 d,#1d2824, 53-80 #b2c3b8,#1d2824, 81-83 #d3b0d9,#1d2824, 84-99 #b2c3b8,#1d2824, +|3: 0-0 d,#152019, 1-1 d,#0d1410, 2-49 #e5eee5,#0d1410, 50-50 d,#608269, 51-51 d,#0d1410, 52-99 #e5eee5,#0d1410, +|4: 0-0 d,#152019, 1-1 d,#0d1410, 2-49 #e5eee5,#0d1410, 50-50 d,#608269, 51-51 d,#0d1410, 52-99 #e5eee5,#0d1410, +|5: 0-0 d,#152019, 1-1 d,#0d1410, 2-49 #e5eee5,#0d1410, 50-50 d,#608269, 51-99 d,#0d1410, +|6: 0-0 d,#152019, 1-1 d,#0d1410, 2-49 #e5eee5,#0d1410, 50-50 d,#608269, 51-51 d,#0d1410, 52-99 #e5eee5,#0d1410, +|7: 0-0 d,#152019, 1-1 d,#0d1410, 2-49 #e5eee5,#0d1410, 50-50 d,#608269, 51-51 d,#0d1410, 52-99 #e5eee5,#0d1410, +|8: 0-0 d,#152019, 1-1 d,#0d1410, 2-49 #e5eee5,#0d1410, 50-50 d,#608269, 51-51 d,#0d1410, 52-99 #e5eee5,#0d1410, +|9: 0-0 d,#152019, 1-1 d,#0d1410, 2-49 #e5eee5,#0d1410, 50-50 d,#608269, 51-51 d,#0d1410, 52-99 #e5eee5,#0d1410, +|10: 0-0 d,#152019, 1-1 d,#0d1410, 2-49 #e5eee5,#0d1410, 50-50 d,#608269, 51-51 d,#0d1410, 52-99 #e5eee5,#0d1410, +|11: 0-0 d,#152019, 1-1 d,#0d1410, 2-49 #e5eee5,#0d1410, 50-50 d,#608269, 51-51 d,#0d1410, 52-99 #e5eee5,#0d1410, +|12: 0-0 d,#152019, 1-1 d,#0d1410, 2-49 #e5eee5,#0d1410, 50-50 d,#608269, 51-51 d,#0d1410, 52-99 #e5eee5,#0d1410, +|13: 0-0 d,#152019, 1-1 d,#0d1410, 2-49 #e5eee5,#0d1410, 50-50 d,#608269, 51-51 d,#0d1410, 52-99 #e5eee5,#0d1410, +|14: 0-0 d,#152019, 1-1 d,#0d1410, 2-49 #e5eee5,#0d1410, 50-50 d,#608269, 51-51 d,#0d1410, 52-99 #e5eee5,#0d1410, +|15: 0-0 d,#608269, 1-1 d,#0d1410, 2-49 #e5eee5,#0d1410, 50-50 d,#608269, 51-51 d,#0d1410, 52-99 #e5eee5,#0d1410, +|16: 0-0 d,#152019, 1-1 d,#0d1410, 2-49 #e5eee5,#0d1410, 50-50 d,#608269, 51-51 d,#0d1410, 52-99 #e5eee5,#0d1410, +|17: 0-1 #ffffff,#496656, 2-2 d,#1d2824, 3-30 #b2c3b8,#1d2824, 31-33 #d3b0d9,#1d2824, 34-49 #b2c3b8,#1d2824, 50-50 d,#608269, 51-51 d,#0d1410, 52-99 #e5eee5,#0d1410, +|18: 0-0 d,#608269, 1-1 d,#0d1410, 2-49 #e5eee5,#0d1410, 50-50 d,#608269, 51-51 d,#0d1410, 52-99 #e5eee5,#0d1410, +|19: 0-0 d,#608269, 1-1 d,#0d1410, 2-49 #e5eee5,#0d1410, 50-50 d,#608269, 51-51 d,#0d1410, 52-99 #e5eee5,#0d1410, +|20: 0-0 d,#608269, 1-49 d,#0d1410, 50-50 d,#608269, 51-51 d,#0d1410, 52-99 #e5eee5,#0d1410, +|21: 0-0 d,#608269, 1-1 d,#0d1410, 2-49 #e5eee5,#0d1410, 50-50 d,#608269, 51-51 d,#0d1410, 52-99 #e5eee5,#0d1410, +|22: 0-0 d,#608269, 1-1 d,#0d1410, 2-49 #e5eee5,#0d1410, 50-50 d,#608269, 51-51 d,#0d1410, 52-99 #e5eee5,#0d1410, +|23: 0-0 d,#608269, 1-1 d,#0d1410, 2-49 #e5eee5,#0d1410, 50-50 d,#608269, 51-51 d,#0d1410, 52-99 #e5eee5,#0d1410, +|24: 0-0 d,#608269, 1-1 d,#0d1410, 2-49 #e5eee5,#0d1410, 50-50 d,#608269, 51-51 d,#0d1410, 52-99 #e5eee5,#0d1410, +|25: 0-0 d,#608269, 1-1 d,#0d1410, 2-49 #e5eee5,#0d1410, 50-50 d,#608269, 51-51 d,#0d1410, 52-99 #e5eee5,#0d1410, +|26: 0-0 d,#608269, 1-1 d,#0d1410, 2-49 #e5eee5,#0d1410, 50-50 d,#608269, 51-51 d,#0d1410, 52-99 #e5eee5,#0d1410, +|27: 0-0 d,#608269, 1-1 d,#0d1410, 2-49 #e5eee5,#0d1410, 50-50 d,#608269, 51-51 d,#0d1410, 52-99 #e5eee5,#0d1410, +|28: 0-0 d,#608269, 1-1 d,#0d1410, 2-49 #e5eee5,#0d1410, 50-50 d,#608269, 51-51 d,#0d1410, 52-99 #e5eee5,#0d1410, +|29: 0-0 d,#608269, 1-1 d,#0d1410, 2-49 #e5eee5,#0d1410, 50-50 d,#608269, 51-51 d,#0d1410, 52-99 #e5eee5,#0d1410, +|30: 0-0 d,#608269, 1-1 d,#0d1410, 2-49 #e5eee5,#0d1410, 50-50 d,#608269, 51-51 d,#0d1410, 52-99 #e5eee5,#0d1410, diff --git a/test/snapshots/scrolloff.golden b/test/snapshots/scrolloff.golden index 6054e8bc..5ab9fa55 100644 --- a/test/snapshots/scrolloff.golden +++ b/test/snapshots/scrolloff.golden @@ -1,7 +1,7 @@ == snap top grid=210x12 cursor=7,3 |Newcol Joincol Find Grep Help Changelog Tutor Dump NextColor Debug Kill -|New Tty Find Grep Joincol New Tty Find Grep Joincol -| /tmp/pardes-snap/scrolloff/cwd/g.txt Save Tty Del Collapse /tmp/pardes-snap/scrolloff/cwd Save Tty Del Togglettymode Filter Collapse +| New Tty Find Grep Joincol Delcol New Tty Find Grep Joincol Delcol +| /tmp/pardes-snap/scrolloff/cwd/g.txt Save Tty Collapse Del /tmp/pardes-snap/scrolloff/cwd Tty Save Mode Filter Collapse Del | 1 line 1 ls | 2 line 2 g.txt | 3 line 3 diff --git a/test/snapshots/selarg.golden b/test/snapshots/selarg.golden index b0a14b86..1a9fb86d 100644 --- a/test/snapshots/selarg.golden +++ b/test/snapshots/selarg.golden @@ -1,7 +1,7 @@ == snap kept grid=100x31 cursor=6,3 |Newcol Joincol Find Grep Help Changelog Tutor Dump NextColor Debug Kill -|New Tty Find Grep Joincol New Tty Find Grep Joincol -| /tmp/pardes-snap/selarg/cwd Save Tty Del Togglet /tmp/pardes-snap/selarg/cwd Save Tty Del Togglet +| New Tty Find Grep Joincol Delcol New Tty Find Grep Joincol Delcol +| /tmp/pardes-snap/selarg/cwd Tty Save Mode Filte /tmp/pardes-snap/selarg/cwd Tty Save Mode Filte | ZZARG ZZVEE ./c.sh | | @@ -16,7 +16,7 @@ | | | -| /tmp/pardes-snap/selarg/cwd Save Tty Del Togglet +| /tmp/pardes-snap/selarg/cwd Tty Save Mode Filte | ls | s.txt == snap crosspane grid=100x31 cursor=6,3 diff --git a/test/snapshots/selregex.golden b/test/snapshots/selregex.golden index 4f380f9b..f071fb15 100644 --- a/test/snapshots/selregex.golden +++ b/test/snapshots/selregex.golden @@ -1,78 +1,75 @@ -== snap prompt-armed grid=160x25 cursor=11,24 +== snap prompt-armed grid=160x25 cursor=159,3 |Newcol Joincol Find Grep Help Changelog Tutor Dump NextColor Debug Kill -|New Tty Find Grep Joincol -| /tmp/pardes-snap/selregex/cwd/m.zig Save Tty Del Collapse +| New Tty Find Grep Joincol Delcol +| /tmp/pardes-snap/selregex/cwd/m.zig Save Tty Collapse Del TreeContext +| Select / | 1 const one = 1; | 2 const two = 2; | 3 const three = 3; | 4 -| -| -| -| -| -| -| -| -| -| -| -| -| -| -| -| -| -| Select / -== snap preview grid=160x25 cursor=16,24 -|24: Select /const +== snap preview grid=160x25 cursor=159,3 +|3: Select /const == style preview grid=160x25 |0: 0-70 #b2c3b8,#1d2824, 71-159 d,#1d2824, -|1: 0-24 #becfc4,#26362d, 25-159 d,#26362d, -|2: 0-1 #000000,#adcc91, 2-58 #becfc4,#26362d, 59-159 d,#26362d, -|3: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-10 #f5f7ee,#405d4b, 11-11 #405d4b,#f5f7ee, 12-18 #e5eee5,#0d1410, 19-19 #e9bf91,#0d1410, 20-20 #e5eee5,#0d1410, 21-159 d,#0d1410, -|4: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-10 #f5f7ee,#26382d, 11-11 #405d4b,#f5f7ee, 12-18 #e5eee5,#0d1410, 19-19 #e9bf91,#0d1410, 20-20 #e5eee5,#0d1410, 21-159 d,#0d1410, -|5: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-10 #f5f7ee,#26382d, 11-11 #405d4b,#f5f7ee, 12-20 #e5eee5,#0d1410, 21-21 #e9bf91,#0d1410, 22-22 #e5eee5,#0d1410, 23-159 d,#0d1410, -|6: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-159 d,#0d1410, -|7: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-159 d,#0d1410, -|8: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-159 d,#0d1410, -|9: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-159 d,#0d1410, -|10: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-159 d,#0d1410, -|11: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-159 d,#0d1410, -|12: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-159 d,#0d1410, -|13: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-159 d,#0d1410, -|14: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-159 d,#0d1410, -|15: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-159 d,#0d1410, -|16: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-159 d,#0d1410, -|17: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-159 d,#0d1410, -|18: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-159 d,#0d1410, -|19: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-159 d,#0d1410, -|20: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-159 d,#0d1410, -|21: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-159 d,#0d1410, -|22: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-159 d,#0d1410, -|23: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-159 d,#0d1410, -|24: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-15 #e5eee5,#0d1410, 16-159 d,#0d1410, +|1: 0-1 #ffffff,#887455, 2-2 d,#26362d, 3-34 #becfc4,#26362d, 35-159 d,#26362d, +|2: 0-1 #000000,#add38a, 2-2 d,#26362d, 3-32 #becfc4,#26362d, 33-37 #dfbce5,#26362d, 38-71 #becfc4,#26362d, 72-159 d,#26362d, +|3: 0-0 d,#152019, 1-1 d,#0d1410, 2-144 d,#1d2824, 145-158 #b2c3b8,#1d2824, 159-159 d,#1d2824, +|4: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-10 #f5f7ee,#3c614a, 11-11 #3c614a,#f5f7ee, 12-18 #e5eee5,#0d1410, 19-19 #f8c082,#0d1410, 20-20 #e5eee5,#0d1410, 21-159 d,#0d1410, +|5: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-10 #f5f7ee,#243a2d, 11-11 #3c614a,#f5f7ee, 12-18 #e5eee5,#0d1410, 19-19 #f8c082,#0d1410, 20-20 #e5eee5,#0d1410, 21-159 d,#0d1410, +|6: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-10 #f5f7ee,#243a2d, 11-11 #3c614a,#f5f7ee, 12-20 #e5eee5,#0d1410, 21-21 #f8c082,#0d1410, 22-22 #e5eee5,#0d1410, 23-159 d,#0d1410, +|7: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-159 d,#0d1410, +|8: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-159 d,#0d1410, +|9: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-159 d,#0d1410, +|10: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-159 d,#0d1410, +|11: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-159 d,#0d1410, +|12: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-159 d,#0d1410, +|13: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-159 d,#0d1410, +|14: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-159 d,#0d1410, +|15: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-159 d,#0d1410, +|16: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-159 d,#0d1410, +|17: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-159 d,#0d1410, +|18: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-159 d,#0d1410, +|19: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-159 d,#0d1410, +|20: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-159 d,#0d1410, +|21: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-159 d,#0d1410, +|22: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-159 d,#0d1410, +|23: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-159 d,#0d1410, +|24: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-159 d,#0d1410, == snap three-selected grid=160x25 cursor=11,3 -|24: +|3: 1 const one = 1; +|4: 2 const two = 2; +|5: 3 const three = 3; +|6: 4 +|7: == style three-selected grid=160x25 -|3: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-6 #616f64,#0d1410,b 7-11 #f5f7ee,#405d4b, 12-18 #e5eee5,#0d1410, 19-19 #e9bf91,#0d1410, 20-20 #e5eee5,#0d1410, 21-159 d,#0d1410, -|24: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-159 d,#0d1410, -== snap narrowed grid=160x25 cursor=12,24 -|24: Select /t +|3: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #616f64,#0d1410,b 7-11 #f5f7ee,#3c614a, 12-18 #e5eee5,#0d1410, 19-19 #f8c082,#0d1410, 20-20 #e5eee5,#0d1410, 21-159 d,#0d1410, +|4: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-10 #f5f7ee,#243a2d, 11-11 #3c614a,#f5f7ee, 12-18 #e5eee5,#0d1410, 19-19 #f8c082,#0d1410, 20-20 #e5eee5,#0d1410, 21-159 d,#0d1410, +|5: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-10 #f5f7ee,#243a2d, 11-11 #3c614a,#f5f7ee, 12-20 #e5eee5,#0d1410, 21-21 #f8c082,#0d1410, 22-22 #e5eee5,#0d1410, 23-159 d,#0d1410, +|6: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-159 d,#0d1410, +== snap narrowed grid=160x25 cursor=159,3 +|3: Select /t +|4: 1 const one = 1; +|5: 2 const two = 2; +|6: 3 const three = 3; +|7: 4 == style narrowed grid=160x25 -|3: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-10 #e5eee5,#0d1410, 11-11 #405d4b,#f5f7ee, 12-18 #e5eee5,#0d1410, 19-19 #e9bf91,#0d1410, 20-20 #e5eee5,#0d1410, 21-159 d,#0d1410, -|4: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-10 #e5eee5,#0d1410, 11-11 #405d4b,#f5f7ee, 12-18 #e5eee5,#0d1410, 19-19 #e9bf91,#0d1410, 20-20 #e5eee5,#0d1410, 21-159 d,#0d1410, -|5: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-10 #e5eee5,#0d1410, 11-11 #405d4b,#f5f7ee, 12-20 #e5eee5,#0d1410, 21-21 #e9bf91,#0d1410, 22-22 #e5eee5,#0d1410, 23-159 d,#0d1410, -|24: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-11 #e5eee5,#0d1410, 12-159 d,#0d1410, +|3: 0-0 d,#152019, 1-1 d,#0d1410, 2-148 d,#1d2824, 149-158 #b2c3b8,#1d2824, 159-159 d,#1d2824, +|4: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-10 #e5eee5,#0d1410, 11-11 #3c614a,#f5f7ee, 12-18 #e5eee5,#0d1410, 19-19 #f8c082,#0d1410, 20-20 #e5eee5,#0d1410, 21-159 d,#0d1410, +|5: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-10 #e5eee5,#0d1410, 11-11 #3c614a,#f5f7ee, 12-18 #e5eee5,#0d1410, 19-19 #f8c082,#0d1410, 20-20 #e5eee5,#0d1410, 21-159 d,#0d1410, +|6: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-10 #e5eee5,#0d1410, 11-11 #3c614a,#f5f7ee, 12-20 #e5eee5,#0d1410, 21-21 #f8c082,#0d1410, 22-22 #e5eee5,#0d1410, 23-159 d,#0d1410, == snap esc-restores grid=160x25 cursor=11,3 -|24: +|3: 1 const one = 1; +|4: 2 const two = 2; +|5: 3 const three = 3; +|6: 4 +|7: == style esc-restores grid=160x25 -|3: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-6 #616f64,#0d1410,b 7-11 #f5f7ee,#405d4b, 12-18 #e5eee5,#0d1410, 19-19 #e9bf91,#0d1410, 20-20 #e5eee5,#0d1410, 21-159 d,#0d1410, -|4: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-10 #f5f7ee,#26382d, 11-11 #405d4b,#f5f7ee, 12-18 #e5eee5,#0d1410, 19-19 #e9bf91,#0d1410, 20-20 #e5eee5,#0d1410, 21-159 d,#0d1410, -|5: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-10 #f5f7ee,#26382d, 11-11 #405d4b,#f5f7ee, 12-20 #e5eee5,#0d1410, 21-21 #e9bf91,#0d1410, 22-22 #e5eee5,#0d1410, 23-159 d,#0d1410, -|24: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-159 d,#0d1410, +|3: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #616f64,#0d1410,b 7-11 #f5f7ee,#3c614a, 12-18 #e5eee5,#0d1410, 19-19 #f8c082,#0d1410, 20-20 #e5eee5,#0d1410, 21-159 d,#0d1410, +|4: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-10 #f5f7ee,#243a2d, 11-11 #3c614a,#f5f7ee, 12-18 #e5eee5,#0d1410, 19-19 #f8c082,#0d1410, 20-20 #e5eee5,#0d1410, 21-159 d,#0d1410, +|5: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-10 #f5f7ee,#243a2d, 11-11 #3c614a,#f5f7ee, 12-20 #e5eee5,#0d1410, 21-21 #f8c082,#0d1410, 22-22 #e5eee5,#0d1410, 23-159 d,#0d1410, +|6: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-159 d,#0d1410, == snap commented grid=160x25 cursor=14,3 -|2: /tmp/pardes-snap/selregex/cwd/m.zig * Save Tty Del Collapse +|2: /tmp/pardes-snap/selregex/cwd/m.zig * Save Tty Collapse Del TreeContext |3: 1 // const one = 1; |4: 2 // const two = 2; |5: 3 // const three = 3; diff --git a/test/snapshots/shellset.golden b/test/snapshots/shellset.golden index 33cbfb29..777bb102 100644 --- a/test/snapshots/shellset.golden +++ b/test/snapshots/shellset.golden @@ -1,11 +1,13 @@ == snap boot grid=90x21 cursor=7,3 |Newcol Joincol Find Grep Help Changelog Tutor Dump NextColor Debug Kill -|New Tty Find Grep Joincol -| /tmp/pardes-snap/shellset/cwd/cmd.txt Save Tty Del Collapse +| New Tty Find Grep Joincol Delcol +| /tmp/pardes-snap/shellset/cwd/cmd.txt Save Tty Collapse Del | 1 Shell zznosuchshell -== snap builtin-ran grid=90x21 cursor=25,3 +== snap builtin-ran grid=90x21 cursor=25,4 +|3: Shell +|4: 1 Shell zznosuchshell == snap fallback-shell grid=90x21 cursor=49,5 -|1: New Tty Find Grep Joincol New Tty Find Grep Joincol -|2: /tmp/pardes-snap/shellset/cwd/cmd.txt Save /tmp/pardes-snap/shellset/cwd Save Tty Del +|1: New Tty Find Grep Joincol Delcol New Tty Find Grep Joincol Delcol +|2: /tmp/pardes-snap/shellset/cwd/cmd.txt Save /tmp/pardes-snap/shellset/cwd Tty Save Mod |3: 1 Shell zznosuchshell ls |4: cmd.txt zmarkfile.txt diff --git a/test/snapshots/shrinktag.golden b/test/snapshots/shrinktag.golden index 41098ef1..8ff798fa 100644 --- a/test/snapshots/shrinktag.golden +++ b/test/snapshots/shrinktag.golden @@ -1,7 +1,7 @@ == snap before grid=100x31 cursor=2,9 |Newcol Joincol Find Grep Help Changelog Tutor Dump NextColor Debug Kill -|New Tty Find Grep Joincol New Tty Find Grep Joincol -| /tmp/pardes-snap/shrinktag/cwd Save Tty Del Togg /tmp/pardes-snap/shrinktag/cwd Save Tty Del Togg +| New Tty Find Grep Joincol Delcol New Tty Find Grep Joincol Delcol +| /tmp/pardes-snap/shrinktag/cwd Tty Save Mode Fi /tmp/pardes-snap/shrinktag/cwd Tty Save Mode Fi | ls ls | w.txt w.txt | @@ -16,11 +16,11 @@ | | | -| /tmp/pardes-snap/shrinktag/cwd Save Tty Del Togg +| /tmp/pardes-snap/shrinktag/cwd Tty Save Mode Fi | ls | w.txt == snap shrunk grid=100x31 cursor=2,9 -|3: /tmp/pardes-snap/shrinktag/cwd Save Tty Del Togg ls +|3: /tmp/pardes-snap/shrinktag/cwd Tty Save Mode Fi ls |4: ls w.txt |5: w.txt |8: @@ -34,11 +34,11 @@ |4: w.txt w.txt |5: |8: echo one; echo two -|17: /tmp/pardes-snap/shrinktag/cwd Save Tty Del Togg +|17: /tmp/pardes-snap/shrinktag/cwd Tty Save Mode Fi |18: ls |19: w.txt == snap bottom-shrunk grid=100x31 cursor=2,9 |17: |18: |19: -|30: /tmp/pardes-snap/shrinktag/cwd Save Tty Del Togg +|30: /tmp/pardes-snap/shrinktag/cwd Tty Save Mode Fi diff --git a/test/snapshots/splitparent.golden b/test/snapshots/splitparent.golden index 7382103d..aedbdb8a 100644 --- a/test/snapshots/splitparent.golden +++ b/test/snapshots/splitparent.golden @@ -1,26 +1,26 @@ == snap shrunk grid=100x31 cursor=4,4 |Newcol Joincol Find Grep Help Changelog Tutor Dump NextColor Debug Kill -|New Tty Find Grep Joincol New Tty Find Grep Joincol -| /tmp/pardes-snap/splitparent/cwd Save Tty Del To /tmp/pardes-snap/splitparent/cwd Save Tty Del To -| /tmp/pardes-snap/splitparent/cwd Save Tty Del To ls +| New Tty Find Grep Joincol Delcol New Tty Find Grep Joincol Delcol +| /tmp/pardes-snap/splitparent/cwd Tty Save Mode /tmp/pardes-snap/splitparent/cwd Tty Save Mode +| /tmp/pardes-snap/splitparent/cwd Tty Save Mode ls | ls == snap swap-parent grid=100x31 cursor=4,8 -|6: /tmp/pardes-snap/splitparent/cwd Save Tty Del To +|6: /tmp/pardes-snap/splitparent/cwd Tty Save Mode |7: ls == snap tallest grid=100x6 cursor=54,5 |Newcol Joincol Find Grep Help Changelog Tutor Dump NextColor Debug Kill -|New Tty Find Grep Joincol New Tty Find Grep Joincol -| /tmp/pardes-snap/splitparent/cwd Save Tty Del To /tmp/pardes-snap/splitparent/cwd Save Tty Del To -| /tmp/pardes-snap/splitparent/cwd Save Tty Del To -| /tmp/pardes-snap/splitparent/cwd Save Tty Del To /tmp/pardes-snap/splitparent/cwd Save Tty Del To +| New Tty Find Grep Joincol Delcol New Tty Find Grep Joincol Delcol +| /tmp/pardes-snap/splitparent/cwd Tty Save Mode /tmp/pardes-snap/splitparent/cwd Tty Save Mode +| /tmp/pardes-snap/splitparent/cwd Tty Save Mode +| /tmp/pardes-snap/splitparent/cwd Tty Save Mode /tmp/pardes-snap/splitparent/cwd Tty Save Mode == snap regrown grid=100x31 cursor=54,19 |Newcol Joincol Find Grep Help Changelog Tutor Dump NextColor Debug Kill -|New Tty Find Grep Joincol New Tty Find Grep Joincol -| /tmp/pardes-snap/splitparent/cwd Save Tty Del To /tmp/pardes-snap/splitparent/cwd Save Tty Del To -| /tmp/pardes-snap/splitparent/cwd Save Tty Del To ls +| New Tty Find Grep Joincol Delcol New Tty Find Grep Joincol Delcol +| /tmp/pardes-snap/splitparent/cwd Tty Save Mode /tmp/pardes-snap/splitparent/cwd Tty Save Mode +| /tmp/pardes-snap/splitparent/cwd Tty Save Mode ls | ls | -| /tmp/pardes-snap/splitparent/cwd Save Tty Del To +| /tmp/pardes-snap/splitparent/cwd Tty Save Mode | ls | | @@ -31,5 +31,5 @@ | | | -| /tmp/pardes-snap/splitparent/cwd Save Tty Del To +| /tmp/pardes-snap/splitparent/cwd Tty Save Mode | ls diff --git a/test/snapshots/stepgrain.golden b/test/snapshots/stepgrain.golden index 202a4f9a..b8b4dca2 100644 --- a/test/snapshots/stepgrain.golden +++ b/test/snapshots/stepgrain.golden @@ -1,7 +1,7 @@ == snap results grid=150x31 cursor=7,3 |Newcol Joincol Find Grep Help Changelog Tutor Dump NextColor Debug Kill -|New Tty Find Grep Joincol -| /tmp/pardes-snap/stepgrain/cwd/a.txt Save Tty Del Collapse +| New Tty Find Grep Joincol Delcol +| /tmp/pardes-snap/stepgrain/cwd/a.txt Save Tty Collapse Del | 1 hello ZQMARK one | 2 see also sub/b.txt for ZQMARK two | @@ -23,67 +23,74 @@ | | | -| -| -| -| /tmp/pardes-snap/stepgrain/cwd/+Search Save Tty Del Collapse -| 1 a.txt:1:7-12 hello ZQMARK one -| 2 a.txt:2:24-29 see also sub/b.txt for ZQMARK two -| 3 sub/b.txt:1:1-6 ZQMARK inside sub -== snap step-row1 grid=150x31 cursor=7,28 +| /tmp/pardes-snap/stepgrain/cwd/+Search Save Tty Collapse Del LocationsConfig +| 1 a.txt:1:7-12 +| 2 hello ZQMARK one +| 3 a.txt:2:24-29 +| 4 see also sub/b.txt for ZQMARK two +| 5 sub/b.txt:1:1-6 +| 6 ZQMARK inside sub +== snap step-row1 grid=150x31 cursor=7,25 == style step-row1 grid=150x31 |0: 0-70 #b2c3b8,#1d2824, 71-149 d,#1d2824, -|1: 0-24 #becfc4,#26362d, 25-149 d,#26362d, -|2: 0-1 #ffffff,#4c6356, 2-59 #b2c3b8,#1d2824, 60-149 d,#1d2824, -|3: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-22 #e5eee5,#0d1410, 23-149 d,#0d1410, -|4: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-39 #e5eee5,#0d1410, 40-149 d,#0d1410, -|5: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-149 d,#0d1410, -|6: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-149 d,#0d1410, -|7: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-149 d,#0d1410, -|8: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-149 d,#0d1410, -|9: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-149 d,#0d1410, -|10: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-149 d,#0d1410, -|11: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-149 d,#0d1410, -|12: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-149 d,#0d1410, -|13: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-149 d,#0d1410, -|14: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-149 d,#0d1410, -|15: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-149 d,#0d1410, -|16: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-149 d,#0d1410, -|17: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-149 d,#0d1410, -|18: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-149 d,#0d1410, -|19: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-149 d,#0d1410, -|20: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-149 d,#0d1410, -|21: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-149 d,#0d1410, -|22: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-149 d,#0d1410, -|23: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-149 d,#0d1410, -|24: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-149 d,#0d1410, -|25: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-149 d,#0d1410, -|26: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-149 d,#0d1410, -|27: 0-1 #000000,#adcc91, 2-61 #becfc4,#26362d, 62-149 d,#26362d, -|28: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-6 #616f64,#0d1410,b 7-18 #f5f7ee,#405d4b, 19-25 #e5eee5,#0d1410, 26-31 #f7e4a5,#57472a, 32-35 #e5eee5,#0d1410, 36-149 d,#0d1410, -|29: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-19 #59675c,#0d1410, 20-43 #e5eee5,#0d1410, 44-49 #f7e4a5,#57472a, 50-53 #e5eee5,#0d1410, 54-149 d,#0d1410, -|30: 0-0 d,#152019, 1-1 d,#0d1410, 2-21 #59675c,#0d1410, 22-22 #e5eee5,#0d1410, 23-28 #f7e4a5,#57472a, 29-39 #e5eee5,#0d1410, 40-149 d,#0d1410, -== snap step-row2 grid=150x31 cursor=7,29 +|1: 0-1 #ffffff,#887455, 2-2 d,#26362d, 3-34 #becfc4,#26362d, 35-149 d,#26362d, +|2: 0-1 #ffffff,#496656, 2-2 d,#1d2824, 3-33 #b2c3b8,#1d2824, 34-38 #d3b0d9,#1d2824, 39-60 #b2c3b8,#1d2824, 61-149 d,#1d2824, +|3: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-22 #e5eee5,#0d1410, 23-149 d,#0d1410, +|4: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-39 #e5eee5,#0d1410, 40-149 d,#0d1410, +|5: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-149 d,#0d1410, +|6: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-149 d,#0d1410, +|7: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-149 d,#0d1410, +|8: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-149 d,#0d1410, +|9: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-149 d,#0d1410, +|10: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-149 d,#0d1410, +|11: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-149 d,#0d1410, +|12: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-149 d,#0d1410, +|13: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-149 d,#0d1410, +|14: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-149 d,#0d1410, +|15: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-149 d,#0d1410, +|16: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-149 d,#0d1410, +|17: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-149 d,#0d1410, +|18: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-149 d,#0d1410, +|19: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-149 d,#0d1410, +|20: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-149 d,#0d1410, +|21: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-149 d,#0d1410, +|22: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-149 d,#0d1410, +|23: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-149 d,#0d1410, +|24: 0-1 #000000,#add38a, 2-2 d,#26362d, 3-33 #becfc4,#26362d, 34-40 #dfbce5,#26362d, 41-78 #becfc4,#26362d, 79-149 d,#26362d, +|25: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #616f64,#0d1410,b 7-18 #f5f7ee,#3c614a, 19-149 d,#0d1410, +|26: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-12 #e5eee5,#0d1410, 13-18 #f7e4a5,#5e4923, 19-22 #e5eee5,#0d1410, 23-149 d,#0d1410, +|27: 0-0 d,#608269, 1-1 d,#0d1410, 2-19 #59675c,#0d1410, 20-149 d,#0d1410, +|28: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-29 #e5eee5,#0d1410, 30-35 #f7e4a5,#5e4923, 36-39 #e5eee5,#0d1410, 40-149 d,#0d1410, +|29: 0-0 d,#608269, 1-1 d,#0d1410, 2-21 #59675c,#0d1410, 22-149 d,#0d1410, +|30: 0-0 d,#152019, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-12 #f7e4a5,#5e4923, 13-23 #e5eee5,#0d1410, 24-149 d,#0d1410, +== snap step-row2 grid=150x31 cursor=7,27 == style step-row2 grid=150x31 -|28: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-18 #59675c,#0d1410, 19-25 #e5eee5,#0d1410, 26-31 #f7e4a5,#57472a, 32-35 #e5eee5,#0d1410, 36-149 d,#0d1410, -|29: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-6 #616f64,#0d1410,b 7-19 #f5f7ee,#405d4b, 20-43 #e5eee5,#0d1410, 44-49 #f7e4a5,#57472a, 50-53 #e5eee5,#0d1410, 54-149 d,#0d1410, -== snap step-row3 grid=150x31 cursor=7,29 -|28: 2 a.txt:2:24-29 see also sub/b.txt for ZQMARK two -|29: 3 sub/b.txt:1:1-6 ZQMARK inside sub -|30: 4 -== snap step-wrap grid=150x31 cursor=7,28 -|28: 1 a.txt:1:7-12 hello ZQMARK one -|29: 2 a.txt:2:24-29 see also sub/b.txt for ZQMARK two -|30: 3 sub/b.txt:1:1-6 ZQMARK inside sub -== snap blank-in-path grid=150x31 cursor=7,26 -|25: /tmp/pardes-snap/stepgrain/cwd/+Search Save Tty Del Collapse -|26: 1 two words.txt +|25: 0-0 d,#608269, 1-1 d,#0d1410, 2-18 #59675c,#0d1410, 19-149 d,#0d1410, +|27: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #616f64,#0d1410,b 7-19 #f5f7ee,#3c614a, 20-149 d,#0d1410, +== snap step-row3 grid=150x31 cursor=7,28 +|25: 2 hello ZQMARK one +|26: 3 a.txt:2:24-29 +|27: 4 see also sub/b.txt for ZQMARK two +|28: 5 sub/b.txt:1:1-6 +|29: 6 ZQMARK inside sub +|30: 7 +== snap step-wrap grid=150x31 cursor=7,25 +|25: 1 a.txt:1:7-12 +|26: 2 hello ZQMARK one +|27: 3 a.txt:2:24-29 +|28: 4 see also sub/b.txt for ZQMARK two +|29: 5 sub/b.txt:1:1-6 +|30: 6 ZQMARK inside sub +== snap blank-in-path grid=150x31 cursor=7,23 +|22: /tmp/pardes-snap/stepgrain/cwd/+Search Save Tty Collapse Del +|23: 1 two words.txt == style blank-in-path grid=150x31 -|25: 0-1 #000000,#adcc91, 2-61 #becfc4,#26362d, 62-149 d,#26362d, -|26: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-6 #616f64,#0d1410,b 7-19 #f5f7ee,#405d4b, 20-149 d,#0d1410, -|27: 0-1 #ffffff,#4c6356, 2-61 #b2c3b8,#1d2824, 62-149 d,#1d2824, -|28: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-18 #f5f7ee,#405d4b, 19-25 #e5eee5,#0d1410, 26-31 #f7e4a5,#57472a, 32-35 #e5eee5,#0d1410, 36-149 d,#0d1410, -|29: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-19 #59675c,#0d1410, 20-43 #e5eee5,#0d1410, 44-49 #f7e4a5,#57472a, 50-53 #e5eee5,#0d1410, 54-149 d,#0d1410, -== snap blank-opened grid=150x31 cursor=7,15 -|14: /tmp/pardes-snap/stepgrain/cwd/two words.txt Save Tty Del Collapse -|15: 1 +|22: 0-1 #000000,#add38a, 2-2 d,#26362d, 3-33 #becfc4,#26362d, 34-40 #dfbce5,#26362d, 41-62 #becfc4,#26362d, 63-149 d,#26362d, +|23: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #616f64,#0d1410,b 7-19 #f5f7ee,#3c614a, 20-149 d,#0d1410, +|24: 0-1 #ffffff,#496656, 2-2 d,#1d2824, 3-33 #b2c3b8,#1d2824, 34-40 #d3b0d9,#1d2824, 41-78 #b2c3b8,#1d2824, 79-149 d,#1d2824, +|25: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-18 #f5f7ee,#3c614a, 19-149 d,#0d1410, +|27: 0-0 d,#608269, 1-1 d,#0d1410, 2-19 #59675c,#0d1410, 20-149 d,#0d1410, +== snap blank-opened grid=150x31 cursor=7,13 +|12: /tmp/pardes-snap/stepgrain/cwd/two words.txt Save Tty Collapse Del +|13: 1 +|23: Look diff --git a/test/snapshots/syntax.golden b/test/snapshots/syntax.golden index 3199f03a..5b2811f7 100644 --- a/test/snapshots/syntax.golden +++ b/test/snapshots/syntax.golden @@ -1,11 +1,11 @@ == snap zig-open grid=150x31 cursor=7,7 |Newcol Joincol Find Grep Help Changelog Tutor Dump NextColor Debug Kill -|New Tty Find Grep Joincol New Tty Find Grep Joincol -| /tmp/pardes-snap/syntax/cwd Save Tty Del Togglettymode Filter Collapse /tmp/pardes-snap/syntax/cwd Save Tty Del Togglettymode Filter Collapse -| ls ls -| demo.zig demo.zig -| -| /tmp/pardes-snap/syntax/cwd/demo.zig Save Tty Del Collapse +| New Tty Find Grep Joincol Delcol New Tty Find Grep Joincol Delcol +| /tmp/pardes-snap/syntax/cwd Tty Save Mode Filter Collapse Del /tmp/pardes-snap/syntax/cwd Tty Save Mode Filter Collapse Del +| Look ls +| ls demo.zig +| demo.zig +| /tmp/pardes-snap/syntax/cwd/demo.zig Save Tty Collapse Del TreeContext | 1 const std = @import("std"); // greet | 2 pub fn main() void { | 3 var x: u32 = 42; @@ -16,94 +16,95 @@ | | | -| /tmp/pardes-snap/syntax/cwd Save Tty Del Togglettymode Filter Collapse +| /tmp/pardes-snap/syntax/cwd Tty Save Mode Filter Collapse Del | ls | demo.zig == style zig-open grid=150x31 |0: 0-70 #b2c3b8,#1d2824, 71-149 d,#1d2824, -|1: 0-24 #becfc4,#26362d, 25-74 d,#26362d, 75-99 #b2c3b8,#1d2824, 100-149 d,#1d2824, -|2: 0-1 #ffffff,#4c6356, 2-71 #b2c3b8,#1d2824, 72-74 d,#1d2824, 75-76 #ffffff,#4c6356, 77-146 #b2c3b8,#1d2824, 147-149 d,#1d2824, -|3: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-74 #e5eee5,#0d1410, 75-75 d,#637f6a, 76-76 d,#0d1410, 77-149 #e5eee5,#0d1410, -|4: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-74 #e5eee5,#0d1410, 75-75 d,#637f6a, 76-76 d,#0d1410, 77-149 #e5eee5,#0d1410, -|5: 0-0 d,#637f6a, 1-74 d,#0d1410, 75-75 d,#637f6a, 76-149 d,#0d1410, -|6: 0-1 #000000,#adcc91, 2-59 #becfc4,#26362d, 60-74 d,#26362d, 75-75 d,#637f6a, 76-76 d,#0d1410, 77-149 #e5eee5,#0d1410, -|7: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-6 #616f64,#0d1410,b 7-18 #e5eee5,#0d1410, 19-25 #c9b0e4,#0d1410, 26-26 #e5eee5,#0d1410, 27-31 #b6ce94,#0d1410, 32-34 #e5eee5,#0d1410, 35-42 #b9e58f,#0d1410, 43-74 d,#0d1410, 75-75 d,#637f6a, 76-76 d,#0d1410, 77-149 #e5eee5,#0d1410, -|8: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-10 #e5eee5,#0d1410, 11-12 #c9b0e4,#0d1410, 13-26 #e5eee5,#0d1410, 27-74 d,#0d1410, 75-75 d,#637f6a, 76-76 d,#0d1410, 77-149 #e5eee5,#0d1410, -|9: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-23 #e5eee5,#0d1410, 24-25 #e9bf91,#0d1410, 26-26 #e5eee5,#0d1410, 27-74 d,#0d1410, 75-75 d,#637f6a, 76-76 d,#0d1410, 77-149 #e5eee5,#0d1410, -|10: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-16 #e5eee5,#0d1410, 17-74 d,#0d1410, 75-75 d,#637f6a, 76-76 d,#0d1410, 77-149 #e5eee5,#0d1410, -|11: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-7 #e5eee5,#0d1410, 8-74 d,#0d1410, 75-75 d,#637f6a, 76-76 d,#0d1410, 77-149 #e5eee5,#0d1410, -|12: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-74 d,#0d1410, 75-75 d,#637f6a, 76-76 d,#0d1410, 77-149 #e5eee5,#0d1410, -|13: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-74 d,#0d1410, 75-75 d,#637f6a, 76-76 d,#0d1410, 77-149 #e5eee5,#0d1410, -|14: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-74 d,#0d1410, 75-75 d,#637f6a, 76-76 d,#0d1410, 77-149 #e5eee5,#0d1410, -|15: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-74 d,#0d1410, 75-75 d,#637f6a, 76-76 d,#0d1410, 77-149 #e5eee5,#0d1410, -|16: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-74 d,#0d1410, 75-75 d,#637f6a, 76-76 d,#0d1410, 77-149 #e5eee5,#0d1410, -|17: 0-1 #ffffff,#4c6356, 2-71 #b2c3b8,#1d2824, 72-74 d,#1d2824, 75-75 d,#637f6a, 76-76 d,#0d1410, 77-149 #e5eee5,#0d1410, -|18: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-74 #e5eee5,#0d1410, 75-75 d,#637f6a, 76-76 d,#0d1410, 77-149 #e5eee5,#0d1410, -|19: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-74 #e5eee5,#0d1410, 75-75 d,#637f6a, 76-76 d,#0d1410, 77-149 #e5eee5,#0d1410, -|20: 0-0 d,#637f6a, 1-74 d,#0d1410, 75-75 d,#637f6a, 76-76 d,#0d1410, 77-149 #e5eee5,#0d1410, -|21: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-74 #e5eee5,#0d1410, 75-75 d,#637f6a, 76-76 d,#0d1410, 77-149 #e5eee5,#0d1410, -|22: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-74 #e5eee5,#0d1410, 75-75 d,#637f6a, 76-76 d,#0d1410, 77-149 #e5eee5,#0d1410, -|23: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-74 #e5eee5,#0d1410, 75-75 d,#637f6a, 76-76 d,#0d1410, 77-149 #e5eee5,#0d1410, -|24: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-74 #e5eee5,#0d1410, 75-75 d,#637f6a, 76-76 d,#0d1410, 77-149 #e5eee5,#0d1410, -|25: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-74 #e5eee5,#0d1410, 75-75 d,#637f6a, 76-76 d,#0d1410, 77-149 #e5eee5,#0d1410, -|26: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-74 #e5eee5,#0d1410, 75-75 d,#637f6a, 76-76 d,#0d1410, 77-149 #e5eee5,#0d1410, -|27: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-74 #e5eee5,#0d1410, 75-75 d,#637f6a, 76-76 d,#0d1410, 77-149 #e5eee5,#0d1410, -|28: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-74 #e5eee5,#0d1410, 75-75 d,#637f6a, 76-76 d,#0d1410, 77-149 #e5eee5,#0d1410, -|29: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-74 #e5eee5,#0d1410, 75-75 d,#637f6a, 76-76 d,#0d1410, 77-149 #e5eee5,#0d1410, -|30: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-74 #e5eee5,#0d1410, 75-75 d,#637f6a, 76-76 d,#0d1410, 77-149 #e5eee5,#0d1410, +|1: 0-1 #ffffff,#887455, 2-2 d,#26362d, 3-34 #becfc4,#26362d, 35-74 d,#26362d, 75-76 #ffffff,#887455, 77-77 d,#1d2824, 78-109 #b2c3b8,#1d2824, 110-149 d,#1d2824, +|2: 0-1 #ffffff,#496656, 2-2 d,#1d2824, 3-30 #b2c3b8,#1d2824, 31-33 #d3b0d9,#1d2824, 34-63 #b2c3b8,#1d2824, 64-74 d,#1d2824, 75-76 #ffffff,#496656, 77-77 d,#1d2824, 78-105 #b2c3b8,#1d2824, 106-108 #d3b0d9,#1d2824, 109-138 #b2c3b8,#1d2824, 139-149 d,#1d2824, +|3: 0-0 d,#152019, 1-1 d,#0d1410, 2-70 d,#1d2824, 71-74 #b2c3b8,#1d2824, 75-75 d,#608269, 76-76 d,#0d1410, 77-149 #e5eee5,#0d1410, +|4: 0-0 d,#608269, 1-1 d,#0d1410, 2-74 #e5eee5,#0d1410, 75-75 d,#608269, 76-76 d,#0d1410, 77-149 #e5eee5,#0d1410, +|5: 0-0 d,#608269, 1-1 d,#0d1410, 2-74 #e5eee5,#0d1410, 75-75 d,#608269, 76-149 d,#0d1410, +|6: 0-1 #000000,#add38a, 2-2 d,#26362d, 3-30 #becfc4,#26362d, 31-38 #dfbce5,#26362d, 39-72 #becfc4,#26362d, 73-74 d,#26362d, 75-75 d,#608269, 76-76 d,#0d1410, 77-149 #e5eee5,#0d1410, +|7: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #616f64,#0d1410,b 7-18 #e5eee5,#0d1410, 19-25 #c9a7ed,#0d1410, 26-26 #e5eee5,#0d1410, 27-31 #b8d88a,#0d1410, 32-34 #e5eee5,#0d1410, 35-42 #b9f480,#0d1410, 43-74 d,#0d1410, 75-75 d,#608269, 76-76 d,#0d1410, 77-149 #e5eee5,#0d1410, +|8: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-10 #e5eee5,#0d1410, 11-12 #c9a7ed,#0d1410, 13-26 #e5eee5,#0d1410, 27-74 d,#0d1410, 75-75 d,#608269, 76-76 d,#0d1410, 77-149 #e5eee5,#0d1410, +|9: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-23 #e5eee5,#0d1410, 24-25 #f8c082,#0d1410, 26-26 #e5eee5,#0d1410, 27-74 d,#0d1410, 75-75 d,#608269, 76-76 d,#0d1410, 77-149 #e5eee5,#0d1410, +|10: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-16 #e5eee5,#0d1410, 17-74 d,#0d1410, 75-75 d,#608269, 76-76 d,#0d1410, 77-149 #e5eee5,#0d1410, +|11: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-7 #e5eee5,#0d1410, 8-74 d,#0d1410, 75-75 d,#608269, 76-76 d,#0d1410, 77-149 #e5eee5,#0d1410, +|12: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-74 d,#0d1410, 75-75 d,#608269, 76-76 d,#0d1410, 77-149 #e5eee5,#0d1410, +|13: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-74 d,#0d1410, 75-75 d,#608269, 76-76 d,#0d1410, 77-149 #e5eee5,#0d1410, +|14: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-74 d,#0d1410, 75-75 d,#608269, 76-76 d,#0d1410, 77-149 #e5eee5,#0d1410, +|15: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-74 d,#0d1410, 75-75 d,#608269, 76-76 d,#0d1410, 77-149 #e5eee5,#0d1410, +|16: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-74 d,#0d1410, 75-75 d,#608269, 76-76 d,#0d1410, 77-149 #e5eee5,#0d1410, +|17: 0-1 #ffffff,#496656, 2-2 d,#1d2824, 3-30 #b2c3b8,#1d2824, 31-33 #d3b0d9,#1d2824, 34-63 #b2c3b8,#1d2824, 64-74 d,#1d2824, 75-75 d,#608269, 76-76 d,#0d1410, 77-149 #e5eee5,#0d1410, +|18: 0-0 d,#608269, 1-1 d,#0d1410, 2-74 #e5eee5,#0d1410, 75-75 d,#608269, 76-76 d,#0d1410, 77-149 #e5eee5,#0d1410, +|19: 0-0 d,#608269, 1-1 d,#0d1410, 2-74 #e5eee5,#0d1410, 75-75 d,#608269, 76-76 d,#0d1410, 77-149 #e5eee5,#0d1410, +|20: 0-0 d,#608269, 1-74 d,#0d1410, 75-75 d,#608269, 76-76 d,#0d1410, 77-149 #e5eee5,#0d1410, +|21: 0-0 d,#608269, 1-1 d,#0d1410, 2-74 #e5eee5,#0d1410, 75-75 d,#608269, 76-76 d,#0d1410, 77-149 #e5eee5,#0d1410, +|22: 0-0 d,#608269, 1-1 d,#0d1410, 2-74 #e5eee5,#0d1410, 75-75 d,#608269, 76-76 d,#0d1410, 77-149 #e5eee5,#0d1410, +|23: 0-0 d,#608269, 1-1 d,#0d1410, 2-74 #e5eee5,#0d1410, 75-75 d,#608269, 76-76 d,#0d1410, 77-149 #e5eee5,#0d1410, +|24: 0-0 d,#608269, 1-1 d,#0d1410, 2-74 #e5eee5,#0d1410, 75-75 d,#608269, 76-76 d,#0d1410, 77-149 #e5eee5,#0d1410, +|25: 0-0 d,#608269, 1-1 d,#0d1410, 2-74 #e5eee5,#0d1410, 75-75 d,#608269, 76-76 d,#0d1410, 77-149 #e5eee5,#0d1410, +|26: 0-0 d,#608269, 1-1 d,#0d1410, 2-74 #e5eee5,#0d1410, 75-75 d,#608269, 76-76 d,#0d1410, 77-149 #e5eee5,#0d1410, +|27: 0-0 d,#608269, 1-1 d,#0d1410, 2-74 #e5eee5,#0d1410, 75-75 d,#608269, 76-76 d,#0d1410, 77-149 #e5eee5,#0d1410, +|28: 0-0 d,#608269, 1-1 d,#0d1410, 2-74 #e5eee5,#0d1410, 75-75 d,#608269, 76-76 d,#0d1410, 77-149 #e5eee5,#0d1410, +|29: 0-0 d,#608269, 1-1 d,#0d1410, 2-74 #e5eee5,#0d1410, 75-75 d,#608269, 76-76 d,#0d1410, 77-149 #e5eee5,#0d1410, +|30: 0-0 d,#608269, 1-1 d,#0d1410, 2-74 #e5eee5,#0d1410, 75-75 d,#608269, 76-76 d,#0d1410, 77-149 #e5eee5,#0d1410, == style colors-off grid=150x31 -|3: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-3 #e5eee5,#0d1410, 4-74 d,#0d1410, 75-75 d,#637f6a, 76-76 d,#0d1410, 77-78 #e5eee5,#0d1410, 79-149 d,#0d1410, -|4: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-9 #e5eee5,#0d1410, 10-74 d,#0d1410, 75-75 d,#637f6a, 76-76 d,#0d1410, 77-84 #e5eee5,#0d1410, 85-149 d,#0d1410, -|6: 0-1 #000000,#adcc91, 2-59 #becfc4,#26362d, 60-74 d,#26362d, 75-75 d,#637f6a, 76-149 d,#0d1410, -|7: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-6 #616f64,#0d1410,b 7-42 #e5eee5,#0d1410, 43-74 d,#0d1410, 75-75 d,#637f6a, 76-149 d,#0d1410, -|8: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-26 #e5eee5,#0d1410, 27-74 d,#0d1410, 75-75 d,#637f6a, 76-149 d,#0d1410, -|9: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-26 #e5eee5,#0d1410, 27-74 d,#0d1410, 75-75 d,#637f6a, 76-149 d,#0d1410, -|10: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-16 #e5eee5,#0d1410, 17-74 d,#0d1410, 75-75 d,#637f6a, 76-149 d,#0d1410, -|11: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-7 #e5eee5,#0d1410, 8-74 d,#0d1410, 75-75 d,#637f6a, 76-149 d,#0d1410, -|12: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-74 d,#0d1410, 75-75 d,#637f6a, 76-149 d,#0d1410, -|13: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-74 d,#0d1410, 75-75 d,#637f6a, 76-149 d,#0d1410, -|14: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-74 d,#0d1410, 75-75 d,#637f6a, 76-149 d,#0d1410, -|15: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-74 d,#0d1410, 75-75 d,#637f6a, 76-149 d,#0d1410, -|16: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-74 d,#0d1410, 75-75 d,#637f6a, 76-149 d,#0d1410, -|17: 0-1 #ffffff,#4c6356, 2-71 #b2c3b8,#1d2824, 72-74 d,#1d2824, 75-75 d,#637f6a, 76-149 d,#0d1410, -|18: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-3 #e5eee5,#0d1410, 4-74 d,#0d1410, 75-75 d,#637f6a, 76-149 d,#0d1410, -|19: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-9 #e5eee5,#0d1410, 10-74 d,#0d1410, 75-75 d,#637f6a, 76-149 d,#0d1410, -|20: 0-0 d,#637f6a, 1-74 d,#0d1410, 75-75 d,#637f6a, 76-149 d,#0d1410, -|21: 0-0 d,#637f6a, 1-74 d,#0d1410, 75-75 d,#637f6a, 76-149 d,#0d1410, -|22: 0-0 d,#637f6a, 1-74 d,#0d1410, 75-75 d,#637f6a, 76-149 d,#0d1410, -|23: 0-0 d,#637f6a, 1-74 d,#0d1410, 75-75 d,#637f6a, 76-149 d,#0d1410, -|24: 0-0 d,#637f6a, 1-74 d,#0d1410, 75-75 d,#637f6a, 76-149 d,#0d1410, -|25: 0-0 d,#637f6a, 1-74 d,#0d1410, 75-75 d,#637f6a, 76-149 d,#0d1410, -|26: 0-0 d,#637f6a, 1-74 d,#0d1410, 75-75 d,#637f6a, 76-149 d,#0d1410, -|27: 0-0 d,#637f6a, 1-74 d,#0d1410, 75-75 d,#637f6a, 76-149 d,#0d1410, -|28: 0-0 d,#637f6a, 1-74 d,#0d1410, 75-75 d,#637f6a, 76-149 d,#0d1410, -|29: 0-0 d,#637f6a, 1-74 d,#0d1410, 75-75 d,#637f6a, 76-149 d,#0d1410, -|30: 0-0 d,#637f6a, 1-74 d,#0d1410, 75-75 d,#637f6a, 76-149 d,#0d1410, +|3: 0-0 d,#608269, 1-1 d,#0d1410, 2-3 #e5eee5,#0d1410, 4-74 d,#0d1410, 75-75 d,#608269, 76-76 d,#0d1410, 77-78 #e5eee5,#0d1410, 79-149 d,#0d1410, +|4: 0-0 d,#608269, 1-1 d,#0d1410, 2-9 #e5eee5,#0d1410, 10-74 d,#0d1410, 75-75 d,#608269, 76-76 d,#0d1410, 77-84 #e5eee5,#0d1410, 85-149 d,#0d1410, +|5: 0-0 d,#608269, 1-74 d,#0d1410, 75-75 d,#608269, 76-149 d,#0d1410, +|6: 0-1 #000000,#add38a, 2-2 d,#26362d, 3-30 #becfc4,#26362d, 31-38 #dfbce5,#26362d, 39-72 #becfc4,#26362d, 73-74 d,#26362d, 75-75 d,#608269, 76-149 d,#0d1410, +|7: 0-0 d,#152019, 1-1 d,#0d1410, 2-68 d,#1d2824, 69-74 #b2c3b8,#1d2824, 75-75 d,#608269, 76-149 d,#0d1410, +|8: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #616f64,#0d1410,b 7-42 #e5eee5,#0d1410, 43-74 d,#0d1410, 75-75 d,#608269, 76-149 d,#0d1410, +|9: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-26 #e5eee5,#0d1410, 27-74 d,#0d1410, 75-75 d,#608269, 76-149 d,#0d1410, +|10: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-26 #e5eee5,#0d1410, 27-74 d,#0d1410, 75-75 d,#608269, 76-149 d,#0d1410, +|11: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-16 #e5eee5,#0d1410, 17-74 d,#0d1410, 75-75 d,#608269, 76-149 d,#0d1410, +|12: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-7 #e5eee5,#0d1410, 8-74 d,#0d1410, 75-75 d,#608269, 76-149 d,#0d1410, +|13: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-74 d,#0d1410, 75-75 d,#608269, 76-149 d,#0d1410, +|14: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-74 d,#0d1410, 75-75 d,#608269, 76-149 d,#0d1410, +|15: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-74 d,#0d1410, 75-75 d,#608269, 76-149 d,#0d1410, +|16: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-74 d,#0d1410, 75-75 d,#608269, 76-149 d,#0d1410, +|17: 0-1 #ffffff,#496656, 2-2 d,#1d2824, 3-30 #b2c3b8,#1d2824, 31-33 #d3b0d9,#1d2824, 34-63 #b2c3b8,#1d2824, 64-74 d,#1d2824, 75-75 d,#608269, 76-149 d,#0d1410, +|18: 0-0 d,#608269, 1-1 d,#0d1410, 2-3 #e5eee5,#0d1410, 4-74 d,#0d1410, 75-75 d,#608269, 76-149 d,#0d1410, +|19: 0-0 d,#608269, 1-1 d,#0d1410, 2-9 #e5eee5,#0d1410, 10-74 d,#0d1410, 75-75 d,#608269, 76-149 d,#0d1410, +|20: 0-0 d,#608269, 1-74 d,#0d1410, 75-75 d,#608269, 76-149 d,#0d1410, +|21: 0-0 d,#608269, 1-74 d,#0d1410, 75-75 d,#608269, 76-149 d,#0d1410, +|22: 0-0 d,#608269, 1-74 d,#0d1410, 75-75 d,#608269, 76-149 d,#0d1410, +|23: 0-0 d,#608269, 1-74 d,#0d1410, 75-75 d,#608269, 76-149 d,#0d1410, +|24: 0-0 d,#608269, 1-74 d,#0d1410, 75-75 d,#608269, 76-149 d,#0d1410, +|25: 0-0 d,#608269, 1-74 d,#0d1410, 75-75 d,#608269, 76-149 d,#0d1410, +|26: 0-0 d,#608269, 1-74 d,#0d1410, 75-75 d,#608269, 76-149 d,#0d1410, +|27: 0-0 d,#608269, 1-74 d,#0d1410, 75-75 d,#608269, 76-149 d,#0d1410, +|28: 0-0 d,#608269, 1-74 d,#0d1410, 75-75 d,#608269, 76-149 d,#0d1410, +|29: 0-0 d,#608269, 1-74 d,#0d1410, 75-75 d,#608269, 76-149 d,#0d1410, +|30: 0-0 d,#608269, 1-74 d,#0d1410, 75-75 d,#608269, 76-149 d,#0d1410, == style colors-on grid=150x31 -|3: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-74 #e5eee5,#0d1410, 75-75 d,#637f6a, 76-76 d,#0d1410, 77-149 #e5eee5,#0d1410, -|4: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-74 #e5eee5,#0d1410, 75-75 d,#637f6a, 76-76 d,#0d1410, 77-149 #e5eee5,#0d1410, -|6: 0-1 #000000,#adcc91, 2-59 #becfc4,#26362d, 60-74 d,#26362d, 75-75 d,#637f6a, 76-76 d,#0d1410, 77-149 #e5eee5,#0d1410, -|7: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-6 #616f64,#0d1410,b 7-18 #e5eee5,#0d1410, 19-25 #c9b0e4,#0d1410, 26-26 #e5eee5,#0d1410, 27-31 #b6ce94,#0d1410, 32-34 #e5eee5,#0d1410, 35-42 #b9e58f,#0d1410, 43-74 d,#0d1410, 75-75 d,#637f6a, 76-76 d,#0d1410, 77-149 #e5eee5,#0d1410, -|8: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-10 #e5eee5,#0d1410, 11-12 #c9b0e4,#0d1410, 13-26 #e5eee5,#0d1410, 27-74 d,#0d1410, 75-75 d,#637f6a, 76-76 d,#0d1410, 77-149 #e5eee5,#0d1410, -|9: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-23 #e5eee5,#0d1410, 24-25 #e9bf91,#0d1410, 26-26 #e5eee5,#0d1410, 27-74 d,#0d1410, 75-75 d,#637f6a, 76-76 d,#0d1410, 77-149 #e5eee5,#0d1410, -|10: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-16 #e5eee5,#0d1410, 17-74 d,#0d1410, 75-75 d,#637f6a, 76-76 d,#0d1410, 77-149 #e5eee5,#0d1410, -|11: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-7 #e5eee5,#0d1410, 8-74 d,#0d1410, 75-75 d,#637f6a, 76-76 d,#0d1410, 77-149 #e5eee5,#0d1410, -|12: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-74 d,#0d1410, 75-75 d,#637f6a, 76-76 d,#0d1410, 77-149 #e5eee5,#0d1410, -|13: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-74 d,#0d1410, 75-75 d,#637f6a, 76-76 d,#0d1410, 77-149 #e5eee5,#0d1410, -|14: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-74 d,#0d1410, 75-75 d,#637f6a, 76-76 d,#0d1410, 77-149 #e5eee5,#0d1410, -|15: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-74 d,#0d1410, 75-75 d,#637f6a, 76-76 d,#0d1410, 77-149 #e5eee5,#0d1410, -|16: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-74 d,#0d1410, 75-75 d,#637f6a, 76-76 d,#0d1410, 77-149 #e5eee5,#0d1410, -|17: 0-1 #ffffff,#4c6356, 2-71 #b2c3b8,#1d2824, 72-74 d,#1d2824, 75-75 d,#637f6a, 76-76 d,#0d1410, 77-149 #e5eee5,#0d1410, -|18: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-74 #e5eee5,#0d1410, 75-75 d,#637f6a, 76-76 d,#0d1410, 77-149 #e5eee5,#0d1410, -|19: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-74 #e5eee5,#0d1410, 75-75 d,#637f6a, 76-76 d,#0d1410, 77-149 #e5eee5,#0d1410, -|20: 0-0 d,#637f6a, 1-74 d,#0d1410, 75-75 d,#637f6a, 76-76 d,#0d1410, 77-149 #e5eee5,#0d1410, -|21: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-74 #e5eee5,#0d1410, 75-75 d,#637f6a, 76-76 d,#0d1410, 77-149 #e5eee5,#0d1410, -|22: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-74 #e5eee5,#0d1410, 75-75 d,#637f6a, 76-76 d,#0d1410, 77-149 #e5eee5,#0d1410, -|23: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-74 #e5eee5,#0d1410, 75-75 d,#637f6a, 76-76 d,#0d1410, 77-149 #e5eee5,#0d1410, -|24: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-74 #e5eee5,#0d1410, 75-75 d,#637f6a, 76-76 d,#0d1410, 77-149 #e5eee5,#0d1410, -|25: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-74 #e5eee5,#0d1410, 75-75 d,#637f6a, 76-76 d,#0d1410, 77-149 #e5eee5,#0d1410, -|26: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-74 #e5eee5,#0d1410, 75-75 d,#637f6a, 76-76 d,#0d1410, 77-149 #e5eee5,#0d1410, -|27: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-74 #e5eee5,#0d1410, 75-75 d,#637f6a, 76-76 d,#0d1410, 77-149 #e5eee5,#0d1410, -|28: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-74 #e5eee5,#0d1410, 75-75 d,#637f6a, 76-76 d,#0d1410, 77-149 #e5eee5,#0d1410, -|29: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-74 #e5eee5,#0d1410, 75-75 d,#637f6a, 76-76 d,#0d1410, 77-149 #e5eee5,#0d1410, -|30: 0-0 d,#637f6a, 1-1 d,#0d1410, 2-74 #e5eee5,#0d1410, 75-75 d,#637f6a, 76-76 d,#0d1410, 77-149 #e5eee5,#0d1410, +|3: 0-0 d,#608269, 1-1 d,#0d1410, 2-74 #e5eee5,#0d1410, 75-75 d,#608269, 76-76 d,#0d1410, 77-149 #e5eee5,#0d1410, +|4: 0-0 d,#608269, 1-1 d,#0d1410, 2-74 #e5eee5,#0d1410, 75-75 d,#608269, 76-76 d,#0d1410, 77-149 #e5eee5,#0d1410, +|6: 0-1 #000000,#add38a, 2-2 d,#26362d, 3-30 #becfc4,#26362d, 31-38 #dfbce5,#26362d, 39-72 #becfc4,#26362d, 73-74 d,#26362d, 75-75 d,#608269, 76-76 d,#0d1410, 77-149 #e5eee5,#0d1410, +|7: 0-0 d,#152019, 1-1 d,#0d1410, 2-68 d,#1d2824, 69-74 #b2c3b8,#1d2824, 75-75 d,#608269, 76-76 d,#0d1410, 77-149 #e5eee5,#0d1410, +|8: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #616f64,#0d1410,b 7-18 #e5eee5,#0d1410, 19-25 #c9a7ed,#0d1410, 26-26 #e5eee5,#0d1410, 27-31 #b8d88a,#0d1410, 32-34 #e5eee5,#0d1410, 35-42 #b9f480,#0d1410, 43-74 d,#0d1410, 75-75 d,#608269, 76-76 d,#0d1410, 77-149 #e5eee5,#0d1410, +|9: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-10 #e5eee5,#0d1410, 11-12 #c9a7ed,#0d1410, 13-26 #e5eee5,#0d1410, 27-74 d,#0d1410, 75-75 d,#608269, 76-76 d,#0d1410, 77-149 #e5eee5,#0d1410, +|10: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-23 #e5eee5,#0d1410, 24-25 #f8c082,#0d1410, 26-26 #e5eee5,#0d1410, 27-74 d,#0d1410, 75-75 d,#608269, 76-76 d,#0d1410, 77-149 #e5eee5,#0d1410, +|11: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-16 #e5eee5,#0d1410, 17-74 d,#0d1410, 75-75 d,#608269, 76-76 d,#0d1410, 77-149 #e5eee5,#0d1410, +|12: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-7 #e5eee5,#0d1410, 8-74 d,#0d1410, 75-75 d,#608269, 76-76 d,#0d1410, 77-149 #e5eee5,#0d1410, +|13: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-74 d,#0d1410, 75-75 d,#608269, 76-76 d,#0d1410, 77-149 #e5eee5,#0d1410, +|14: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-74 d,#0d1410, 75-75 d,#608269, 76-76 d,#0d1410, 77-149 #e5eee5,#0d1410, +|15: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-74 d,#0d1410, 75-75 d,#608269, 76-76 d,#0d1410, 77-149 #e5eee5,#0d1410, +|16: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-74 d,#0d1410, 75-75 d,#608269, 76-76 d,#0d1410, 77-149 #e5eee5,#0d1410, +|17: 0-1 #ffffff,#496656, 2-2 d,#1d2824, 3-30 #b2c3b8,#1d2824, 31-33 #d3b0d9,#1d2824, 34-63 #b2c3b8,#1d2824, 64-74 d,#1d2824, 75-75 d,#608269, 76-76 d,#0d1410, 77-149 #e5eee5,#0d1410, +|18: 0-0 d,#608269, 1-1 d,#0d1410, 2-74 #e5eee5,#0d1410, 75-75 d,#608269, 76-76 d,#0d1410, 77-149 #e5eee5,#0d1410, +|19: 0-0 d,#608269, 1-1 d,#0d1410, 2-74 #e5eee5,#0d1410, 75-75 d,#608269, 76-76 d,#0d1410, 77-149 #e5eee5,#0d1410, +|20: 0-0 d,#608269, 1-74 d,#0d1410, 75-75 d,#608269, 76-76 d,#0d1410, 77-149 #e5eee5,#0d1410, +|21: 0-0 d,#608269, 1-1 d,#0d1410, 2-74 #e5eee5,#0d1410, 75-75 d,#608269, 76-76 d,#0d1410, 77-149 #e5eee5,#0d1410, +|22: 0-0 d,#608269, 1-1 d,#0d1410, 2-74 #e5eee5,#0d1410, 75-75 d,#608269, 76-76 d,#0d1410, 77-149 #e5eee5,#0d1410, +|23: 0-0 d,#608269, 1-1 d,#0d1410, 2-74 #e5eee5,#0d1410, 75-75 d,#608269, 76-76 d,#0d1410, 77-149 #e5eee5,#0d1410, +|24: 0-0 d,#608269, 1-1 d,#0d1410, 2-74 #e5eee5,#0d1410, 75-75 d,#608269, 76-76 d,#0d1410, 77-149 #e5eee5,#0d1410, +|25: 0-0 d,#608269, 1-1 d,#0d1410, 2-74 #e5eee5,#0d1410, 75-75 d,#608269, 76-76 d,#0d1410, 77-149 #e5eee5,#0d1410, +|26: 0-0 d,#608269, 1-1 d,#0d1410, 2-74 #e5eee5,#0d1410, 75-75 d,#608269, 76-76 d,#0d1410, 77-149 #e5eee5,#0d1410, +|27: 0-0 d,#608269, 1-1 d,#0d1410, 2-74 #e5eee5,#0d1410, 75-75 d,#608269, 76-76 d,#0d1410, 77-149 #e5eee5,#0d1410, +|28: 0-0 d,#608269, 1-1 d,#0d1410, 2-74 #e5eee5,#0d1410, 75-75 d,#608269, 76-76 d,#0d1410, 77-149 #e5eee5,#0d1410, +|29: 0-0 d,#608269, 1-1 d,#0d1410, 2-74 #e5eee5,#0d1410, 75-75 d,#608269, 76-76 d,#0d1410, 77-149 #e5eee5,#0d1410, +|30: 0-0 d,#608269, 1-1 d,#0d1410, 2-74 #e5eee5,#0d1410, 75-75 d,#608269, 76-76 d,#0d1410, 77-149 #e5eee5,#0d1410, diff --git a/test/snapshots/tag.golden b/test/snapshots/tag.golden index abc83b8f..5e4cb4d1 100644 --- a/test/snapshots/tag.golden +++ b/test/snapshots/tag.golden @@ -1,7 +1,7 @@ -== snap tag-focus grid=150x31 cursor=26,2 +== snap tag-focus grid=150x31 cursor=31,2 |Newcol Joincol Find Grep Help Changelog Tutor Dump NextColor Debug Kill -|New Tty Find Grep Joincol New Tty Find Grep Joincol -| /tmp/pardes-snap/tag/cwd Save Tty Del Togglettymode Filter Collapse /tmp/pardes-snap/tag/cwd Save Tty Del Togglettymode Filter Collapse +| New Tty Find Grep Joincol Delcol New Tty Find Grep Joincol Delcol +| /tmp/pardes-snap/tag/cwd Tty Save Mode Filter Collapse Del /tmp/pardes-snap/tag/cwd Tty Save Mode Filter Collapse Del | ls ls | t.txt t.txt | @@ -16,15 +16,18 @@ | | | -| /tmp/pardes-snap/tag/cwd Save Tty Del Togglettymode Filter Collapse +| /tmp/pardes-snap/tag/cwd Tty Save Mode Filter Collapse Del | ls | t.txt -== snap tag-typed grid=150x31 cursor=32,2 -|2: /tmp/pardes-snap/tag/cwd t.txt Save Tty Del Togglettymode Filter Collapse /tmp/pardes-snap/tag/cwd Save Tty Del Togglettymode Filter Collapse -== snap tag-del grid=150x31 cursor=28,2 -|2: /tmp/pardes-snap/tag/cwd t Save Tty Del Togglettymode Filter Collapse /tmp/pardes-snap/tag/cwd Save Tty Del Togglettymode Filter Collapse +== snap tag-typed grid=150x31 cursor=37,2 +|2: /tmp/pardes-snap/tag/cwd Tty t.txt Save Mode Filter Collapse Del /tmp/pardes-snap/tag/cwd Tty Save Mode Filter Collapse Del +== snap tag-del grid=150x31 cursor=33,2 +|2: /tmp/pardes-snap/tag/cwd Tty t Save Mode Filter Collapse Del /tmp/pardes-snap/tag/cwd Tty Save Mode Filter Collapse Del == snap tag-exit grid=150x31 cursor=4,5 -|2: /tmp/pardes-snap/tag/cwd t.txt Save Tty Del Togglettymode Filter Collapse /tmp/pardes-snap/tag/cwd Save Tty Del Togglettymode Filter Collapse +|2: /tmp/pardes-snap/tag/cwd Tty t.txt Save Mode Filter Collapse Del /tmp/pardes-snap/tag/cwd Tty Save Mode Filter Collapse Del == snap tag-look grid=150x31 cursor=7,7 -|6: /tmp/pardes-snap/tag/cwd/t.txt Save Tty Del Collapse +|3: Look ls +|4: ls t.txt +|5: t.txt +|6: /tmp/pardes-snap/tag/cwd/t.txt Save Tty Collapse Del |7: 1 ZZLOOKED diff --git a/test/snapshots/tagalign.golden b/test/snapshots/tagalign.golden index eaed8e2e..6d61ad2f 100644 --- a/test/snapshots/tagalign.golden +++ b/test/snapshots/tagalign.golden @@ -1,7 +1,7 @@ == snap aligned grid=100x31 cursor=4,20 |Newcol Joincol Find Grep Help Changelog Tutor Dump NextColor Debug Kill -|New Tty Find Grep Joincol -| /tmp/pardes-snap/tagalign/cwd/deep/nested-project-directory/document.txt Save Tty Del Collapse +| New Tty Find Grep Joincol Delcol +| /tmp/pardes-snap/tagalign/cwd/deep/nested-project-directory/document.txt Save Tty Collapse Del | 1 alpha | 2 beta | 3 gamma @@ -16,13 +16,13 @@ | | | -| /tmp/pardes-snap/tagalign/cwd Save Tty Del Togglettymode Filter Collapse +| /tmp/pardes-snap/tagalign/cwd Tty Save Mode Filter Collapse Del | ls | deep == snap fits grid=87x31 cursor=4,20 |Newcol Joincol Find Grep Help Changelog Tutor Dump NextColor Debug Kill -|New Tty Find Grep Joincol -| /tmp/pardes-snap/tagalign/cwd/deep/nested-project-directory/document.txt Save Tty Del +| New Tty Find Grep Joincol Delcol +| /tmp/pardes-snap/tagalign/cwd/deep/nested-project-directory/document.txt Save Tty Co | 1 alpha | 2 beta | 3 gamma @@ -37,13 +37,13 @@ | | | -| /tmp/pardes-snap/tagalign/cwd Save Tty Del Togglettymode Filter Collapse +| /tmp/pardes-snap/tagalign/cwd Tty Save Mode Filter Collapse Del | ls | deep == snap overby1 grid=86x31 cursor=4,20 |Newcol Joincol Find Grep Help Changelog Tutor Dump NextColor Debug Kill -|New Tty Find Grep Joincol -| /tmp/pardes-snap/tagalign/cwd/deep/nested-project-directory/document.txt Save Tty De +| New Tty Find Grep Joincol Delcol +| /tmp/pardes-snap/tagalign/cwd/deep/nested-project-directory/document.txt Save Tty C | 1 alpha | 2 beta | 3 gamma @@ -58,13 +58,13 @@ | | | -| /tmp/pardes-snap/tagalign/cwd Save Tty Del Togglettymode Filter Collapse +| /tmp/pardes-snap/tagalign/cwd Tty Save Mode Filter Collapse Del | ls | deep == snap clicked grid=100x31 cursor=11,2 |Newcol Joincol Find Grep Help Changelog Tutor Dump NextColor Debug Kill -|New Tty Find Grep Joincol -| /tmp/pardes-snap/tagalign/cwd/deep/nested-project-directory/document.txt Save Tty Del Collapse +| New Tty Find Grep Joincol Delcol +| /tmp/pardes-snap/tagalign/cwd/deep/nested-project-directory/document.txt Save Tty Collapse Del | 1 alpha | 2 beta | 3 gamma @@ -79,13 +79,13 @@ | | | -| /tmp/pardes-snap/tagalign/cwd Save Tty Del Togglettymode Filter Collapse +| /tmp/pardes-snap/tagalign/cwd Tty Save Mode Filter Collapse Del | ls | deep == snap revealed grid=70x31 cursor=69,2 |Newcol Joincol Find Grep Help Changelog Tutor Dump NextColor Debug Kil -|New Tty Find Grep Joincol -| wd/deep/nested-project-directory/document.txt Save Tty Del Collapse +| New Tty Find Grep Joincol Delcol +| d/deep/nested-project-directory/document.txt Save Tty Collapse Del | 1 alpha | 2 beta | 3 gamma @@ -100,11 +100,11 @@ | | | -| /tmp/pardes-snap/tagalign/cwd Save Tty Del Togglettymode Filter Coll +| /tmp/pardes-snap/tagalign/cwd Tty Save Mode Filter Collapse Del | ls | deep == snap alone grid=70x31 cursor=4,5 -|2: /tmp/pardes-snap/tagalign/cwd Save Tty Del Togglettymode Filter Coll +|2: /tmp/pardes-snap/tagalign/cwd Tty Save Mode Filter Collapse Del |3: ls |4: deep |5: diff --git a/test/snapshots/tagalign2col.golden b/test/snapshots/tagalign2col.golden index cef20c73..e703dbef 100644 --- a/test/snapshots/tagalign2col.golden +++ b/test/snapshots/tagalign2col.golden @@ -1,17 +1,20 @@ == snap onecol grid=160x31 cursor=7,3 |Newcol Joincol Find Grep Help Changelog Tutor Dump NextColor Debug Kill -|New Tty Find Grep Joincol New Tty Find Grep Joincol -| /tmp/pardes-snap/tagalign2col/cwd/deep/proj/document.txt Save Tty Del Collapse /tmp/pardes-snap/tagalign2col/cwd Save Tty Del Togglettymode Filter Collapse -| 1 alpha ls -| 2 beta deep -| 3 gamma +| New Tty Find Grep Joincol Delcol New Tty Find Grep Joincol Delcol +| /tmp/pardes-snap/tagalign2col/cwd/deep/proj/document.txt Save Tty Collapse De /tmp/pardes-snap/tagalign2col/cwd Tty Save Mode Filter Collapse Del +| 1 alpha Left +| 2 beta ls +| 3 gamma deep == snap aligned grid=160x31 cursor=4,20 -|17: /tmp/pardes-snap/tagalign2col/cwd Save Tty Del Togglettymode Filter Collapse +|3: 1 alpha ls +|4: 2 beta deep +|5: 3 gamma +|17: /tmp/pardes-snap/tagalign2col/cwd Tty Save Mode Filter Collapse Del |18: ls |19: deep == snap widened grid=160x31 cursor=4,20 -|1: New Tty Find Grep Joincol ╎New Tty Find Grep Joincol -|2: /tmp/pardes-snap/tagalign2col/cwd/deep/proj/document.txt Save Tty Del Collapse ╎ /tmp/pardes-snap/tagalign2col/cwd Save Tty Del Togglettymo +|1: New Tty Find Grep Joincol Delcol ╎ New Tty Find Grep Joincol Delcol +|2: /tmp/pardes-snap/tagalign2col/cwd/deep/proj/document.txt Save Tty Collapse Del ╎ /tmp/pardes-snap/tagalign2col/cwd Tty Save Mode Filter Co |3: 1 alpha ╎ ls |4: 2 beta ╎ deep |5: 3 gamma ╎ @@ -26,7 +29,7 @@ |14: ╎ |15: ╎ |16: ╎ -|17: /tmp/pardes-snap/tagalign2col/cwd Save Tty Del Togglettymode Filter Collapse ╎ +|17: /tmp/pardes-snap/tagalign2col/cwd Tty Save Mode Filter Collapse Del ╎ |18: ls ╎ |19: deep ╎ |20: ╎ diff --git a/test/snapshots/tagbottom.golden b/test/snapshots/tagbottom.golden index f455c425..eb1d67fd 100644 --- a/test/snapshots/tagbottom.golden +++ b/test/snapshots/tagbottom.golden @@ -1,7 +1,7 @@ == snap boot grid=100x31 cursor=7,3 |Newcol Joincol Find Grep Help Changelog Tutor Dump NextColor Debug Kill -|New Tty Find Grep Joincol -| /tmp/pardes-snap/tagbottom/cwd/top.txt Save Tty Del Collapse +| New Tty Find Grep Joincol Delcol +| /tmp/pardes-snap/tagbottom/cwd/top.txt Save Tty Collapse Del | 1 aaa | 2 bbb | 3 ccc @@ -56,9 +56,9 @@ |26: 25 yyy |27: 26 zzz |28: -|30: /tmp/pardes-snap/tagbottom/cwd/top.txt Save Tty Del Collapse +|30: /tmp/pardes-snap/tagbottom/cwd/top.txt Save Tty Collapse Del == snap off grid=100x31 cursor=7,3 -|2: /tmp/pardes-snap/tagbottom/cwd/top.txt Save Tty Del Collapse +|2: /tmp/pardes-snap/tagbottom/cwd/top.txt Save Tty Collapse Del |3: 1 aaa |4: 2 bbb |5: 3 ccc @@ -86,7 +86,7 @@ |27: 25 yyy |28: 26 zzz |30: -== snap tag-typed grid=100x31 cursor=60,30 +== snap tag-typed grid=100x31 cursor=74,30 |2: 1 aaa |3: 2 bbb |4: 3 ccc @@ -114,9 +114,9 @@ |26: 25 yyy |27: 26 zzz |28: -|30: /tmp/pardes-snap/tagbottom/cwd/top.txt Save Tty bottom.txt Del Collapse +|30: /tmp/pardes-snap/tagbottom/cwd/top.txt Save Tty Collapse Del bottom.txt == snap look-bottom-tag grid=100x31 cursor=7,17 -|16: /tmp/pardes-snap/tagbottom/cwd/top.txt Save Tty bottom.txt Del Collapse +|16: /tmp/pardes-snap/tagbottom/cwd/top.txt Save Tty Collapse Del bottom.txt |17: 1 ZZONE |18: 2 ZZTWO |19: @@ -128,11 +128,11 @@ |25: |26: |27: -|30: /tmp/pardes-snap/tagbottom/cwd/bottom.txt Save Tty Del Collapse +|30: /tmp/pardes-snap/tagbottom/cwd/bottom.txt Save Tty Collapse Del == snap body-cursor grid=100x31 cursor=9,6 == snap seam-noop grid=100x31 cursor=9,6 == snap seam-dragged grid=100x31 cursor=9,6 -|11: /tmp/pardes-snap/tagbottom/cwd/top.txt Save Tty bottom.txt Del Collapse +|11: /tmp/pardes-snap/tagbottom/cwd/top.txt Save Tty Collapse Del bottom.txt |12: 1 ZZONE |13: 2 ZZTWO |14: @@ -150,10 +150,12 @@ |8: 8 hhh |9: 9 iii |10: 10 jjj -== snap search-prompt grid=100x31 cursor=6,29 -|29: /ZZ +== snap search-prompt grid=100x31 cursor=99,12 +|12: /ZZ +|13: 1 ZZONE +|14: 2 ZZTWO == snap leader grid=100x31 cursor=9,14 -|29: SPC +|12: SPC == snap cut-down grid=100x31 cursor=7,5 |2: 1 aaa |3: 2 bbb @@ -164,8 +166,10 @@ |8: 7 mmm |9: 8 nnn |10: 9 ooo -|11: /tmp/pardes-snap/tagbottom/cwd/top.txt * Save Tty bottom.txt Del Collapse -|29: +|11: /tmp/pardes-snap/tagbottom/cwd/top.txt * Save Tty Collapse Del bottom.txt +|12: 1 ZZONE +|13: 2 ZZTWO +|14: == file cut-buffer aaa bbb @@ -200,9 +204,9 @@ zzz |19: 18 xxx |20: 19 yyy |21: 20 zzz -|30: /tmp/pardes-snap/tagbottom/cwd/top.txt Save Tty bottom.txt Del Collapse +|30: /tmp/pardes-snap/tagbottom/cwd/top.txt Save Tty Collapse Del bottom.txt == snap off-again grid=100x31 cursor=7,6 -|2: /tmp/pardes-snap/tagbottom/cwd/top.txt Save Tty bottom.txt Del Collapse +|2: /tmp/pardes-snap/tagbottom/cwd/top.txt Save Tty Collapse Del bottom.txt |3: 1 aaa |4: 2 bbb |5: 3 ccc diff --git a/test/snapshots/tagbottom.snap b/test/snapshots/tagbottom.snap index a6a7a882..67bb2ead 100644 --- a/test/snapshots/tagbottom.snap +++ b/test/snapshots/tagbottom.snap @@ -17,6 +17,10 @@ # exactly: `off` is byte-for-byte `boot`, cursor included. file top.txt aaa\nbbb\nccc\nddd\neee\nfff\nggg\nhhh\niii\njjj\nkkk\nlll\nmmm\nnnn\nooo\nppp\nqqq\nrrr\nsss\nttt\nuuu\nvvv\nwww\nxxx\nyyy\nzzz file bottom.txt ZZONE\nZZTWO +# Builtins announce themselves by default, and an announcement is a band at +# the top of the body -- which moves every row this script clicks. What the +# verbs do is what is under test, not the announcement. +config Verbose off start 31 100 top.txt wait 8000 Newcol Joincol wait 8000 top.txt @@ -38,8 +42,11 @@ stable 700 15000 # cursor is down on the tagline with it. Col 50 is past the end of the path, # which is read-only — a click inside it parks the cursor there and the typing # goes nowhere. -press left 50 31 -release left 50 31 +# Past the last word rather than at a counted column: the tagline's words +# have moved since (Del is last now), and a column that lands INSIDE one +# types the filename into the middle of a builtin's name. +press left 90 31 +release left 90 31 stable 400 5000 send \x20bottom.txt stable 600 8000 @@ -48,8 +55,8 @@ snap tag-typed # ...and LOOK the word just typed, from that same bottom tagline: bottom.txt # opens as a second pane below. It only can if the press was mapped to the tag # — mapped as a body row it lands on blank line 29 and looks nothing at all. -press right 55 31 -release right 55 31 +press right @bottom.txt 31 +release right @bottom.txt 31 wait 10000 ZZONE stable 700 15000 snap look-bottom-tag diff --git a/test/snapshots/tagbottomimage.golden b/test/snapshots/tagbottomimage.golden index 523dd27c..72352672 100644 --- a/test/snapshots/tagbottomimage.golden +++ b/test/snapshots/tagbottomimage.golden @@ -1,11 +1,11 @@ == snap img-top grid=150x31 cursor=11,8 |Newcol Joincol Find Grep Help Changelog Tutor Dump NextColor Debug Kill -|New Tty Find Grep Joincol -| /tmp/pardes-snap/tagbottomimage/cwd Save Tty Del Togglettymode Filter Collapse +| New Tty Find Grep Joincol Delcol +| /tmp/pardes-snap/tagbottomimage/cwd Tty Save Mode Filter Collapse Del +| Look | ls | pic.ppm -| -| img petscii:off palette:commodore ascii:on /tmp/pardes-snap/tagbottomimage/cwd/pic.ppm Tty Del Collapse +| img petscii:off palette:commodore ascii:on /tmp/pardes-snap/tagbottomimage/cwd/pic.ppm Tty Collapse Del | 4*🬹~F~N🬰|GðŸ¬�â–šY~KF🬴s>T&zZ/🬻iTY=`S~╳bkZR37v🬦🬵d4QHZ8X▛▟ | ^🬪🬛$}DrydNU&wsz=`*r🬒🬓🬳🬟*Y🬴G6🬧f🬮/>t🬧u🬲1Rg1tðŸ¬�🬻█ @@ -34,66 +34,66 @@ |2: ls |3: pic.ppm |4: -|5: /tmp/pardes-snap/tagbottomimage/cwd Save Tty Del Togglettymode Filter Collapse -|6: 4*🬹~F~N🬰|GðŸ¬�â–šY~KF🬴s>T&zZ/🬻iTY=`S~╳bkZR37v🬦🬵d4QHZ8X▛▟ -|8: ^🬪🬛$}DrydNU&wsz=`*r🬒🬓🬳🬟*Y🬴G6🬧f🬮/>t🬧u🬲1Rg1tðŸ¬�🬻█ -|9: â––#_{🬗X@🬢&$s'C%*=w@🬆▀wq%🬡d┼a┼m─>🬭🬜Aâ–€A🬲H]pðŸ¬�🬹 -|10: %?WX🬕f🬩*TA8n╱┼E▘🬭Y#qo~XVEâ–�(╳▀H4^[mj🬗=🬒🬕▟█ -|11: ]Z🬷eb~Oyl3=SLâ–™a🬱🬉~MPMz}FMu<ðŸ¬�â–š>3&▖🬷WSðŸ¬�~â–ˆ -|12: EF-🬑y🬔!r🬙ðŸ¬�╳O🬩â–�%Qj─4za/?/\a🬜"🬖🬈🬛🬟A🬙ðŸ¬�â–„ -|13: 🬃N@xzOnczIK=t0@🬖j5🬮🬧65â–Ÿ{🬮🬉🬄🬩zQ9/ðŸ¬�🬻 -|14: ╲${&%@"#cttâ–€Cr5F;ðŸ¬�ARM╱uej╳75🬹9▛🬻 -|15: h^🬜"🬈🬨▜╲|W🬊🬦k6^🬰🬶rZ─▄\z9🬎🬉4^🬎🬻 -|16: 🬆f│Q_V🬗wGx🬱=5â–›5*&V🬟🬄ZrXGz2ðŸ¬�🬻█ -|17: !🬷WðŸ¬�(🬭]7x_>â–—er🬯~â–šdi🬬4jY:ðŸ¬�â–Ÿ -|18: gU~🬧3â–™bjr\C#kKMpffAjpsðŸ¬�🬻 -|19: *🬯G"🬣▟d🬮▀zJ🬪EHV▟╳9}y▛▄ -|20: ``))~RyJ🬴jA~w=hLpXðŸ¬�🬻█ -|21: 4xâ–€J"TG7=y-QZ🬙╲~▛🬻 -|22: 🬯/+╳f9ZG🬕+{QN_ðŸ¬�🬹 -|23: E<'─🬫pS!"n4&ðŸ¬�~ -|24: m$dx"!2🬳&{ðŸ¬�🬻 -|25: *8f🬩▙Jb🬒ðŸ¬�🬻█ -|26: m🬩7CiN🬎🬹 -|27: pG╲LðŸ¬�🬻 -|28: 🬡LðŸ¬�â–„ -|29: ðŸ¬�~ -|30: img petscii:off palette:commodore ascii:on /tmp/pardes-snap/tagbottomimage/cwd/pic.ppm Tty Del Collapse +|5: /tmp/pardes-snap/tagbottomimage/cwd Tty Save Mode Filter Collapse Del +|6: Tagbottom +|7: {DbgY🬲sâ–œM^#â–�FUJ[zNq=ðŸ¬�g/y╱?V@🬱🬙▌UK╱ðŸ¬�("🬕KJ8hSoðŸ¬�🬻 +|8: tX🬆s>🬌`🬵 Date: Tue, 22 Sep 2026 09:31:11 -0300 Subject: Notices become chips that float over the body, not rows taken from it A notice is an overlay now, which is the one place it is NOT like the tree-sitter context: it takes no row from the body and moves no text. Each one is a chip as wide as its own message plus a blank cell either side, anchored to the pane right edge on the body top rows. The rest of each of those rows is ordinary body text that still reads and still answers a click -- Notices.left records where each chip starts, and the hit test refuses only the cells it covers rather than the whole row. The width is counted in GRID columns rather than scaled into the tagline face the chip is drawn in, because the canonical grid is what a terminal client draws and a chip narrower than its own text there would clip it; the narrower tagline face simply leaves a little more room inside the chip. The tag layer takes the geometry the grid pass already chose, so the two cannot disagree and the GUI skipping the cells a tag layer covers leaves no stub behind. Pane.body_offset is gone with the reservation it existed for, and bodyTop takes only a rect. The body layer keeps every row it had, the scrollbar runs the full body again, and the GUI smooth-scroll extents go back to the pane. Co-Authored-By: Claude Opus 5 (1M context) --- features.txt | 13 +- src/gui/gui.zig | 25 +- src/panes.zig | 46 ++- src/pardes.zig | 302 +++++++------- test/output.zig | 4 +- test/panes.zig | 26 +- test/snapshots/builtins.golden | 8 +- test/snapshots/chordcut.golden | 34 +- test/snapshots/collapse.golden | 17 +- test/snapshots/exec.golden | 24 +- test/snapshots/filewatch.golden | 18 +- test/snapshots/find.golden | 47 +-- test/snapshots/fsearch.golden | 15 +- test/snapshots/grep.golden | 8 +- test/snapshots/hscroll.golden | 21 +- test/snapshots/images.golden | 53 ++- test/snapshots/jumps.golden | 160 ++------ test/snapshots/layout-open.golden | 6 +- test/snapshots/leader.golden | 24 +- test/snapshots/look-center.golden | 31 +- test/snapshots/look-dir.golden | 6 +- test/snapshots/look-file-1col.golden | 4 +- test/snapshots/look-file.golden | 10 +- test/snapshots/lookloaded.golden | 18 +- test/snapshots/lsp-client-edit.golden | 26 +- test/snapshots/lsp-client.golden | 23 +- test/snapshots/lsp-rename.golden | 18 +- test/snapshots/lsp.golden | 40 +- test/snapshots/lspcomplete.golden | 3 +- test/snapshots/lsprelpath.golden | 16 +- test/snapshots/mini.golden | 87 ++-- test/snapshots/msg.golden | 67 +--- test/snapshots/ninep.golden | 150 +++---- test/snapshots/pipe.golden | 5 +- test/snapshots/psearch.golden | 61 +-- test/snapshots/savepane.golden | 10 +- test/snapshots/selregex.golden | 36 +- test/snapshots/shellset.golden | 5 +- test/snapshots/stepgrain.golden | 2 +- test/snapshots/syntax.golden | 33 +- test/snapshots/tag.golden | 4 +- test/snapshots/tagalign2col.golden | 8 +- test/snapshots/tagbottom.golden | 10 +- test/snapshots/tagbottomimage.golden | 102 ++--- test/snapshots/tagbottomshort.golden | 16 +- test/snapshots/tagcmd.golden | 18 +- test/snapshots/tagnav.golden | 34 +- test/snapshots/theme.golden | 14 +- test/snapshots/themesel.golden | 726 ++++++++++++++++------------------ test/snapshots/tty.golden | 12 +- test/snapshots/ttylook.golden | 10 +- test/snapshots/ttytaken.golden | 16 +- test/snapshots/wheeldrift.golden | 14 +- test/snapshots/windownav.golden | 63 +-- test/snapshots/windowops.golden | 6 +- test/snapshots/wrap.golden | 27 +- 56 files changed, 1046 insertions(+), 1536 deletions(-) (limited to 'src/pardes.zig') diff --git a/features.txt b/features.txt index d035648a..fa1c0f6b 100644 --- a/features.txt +++ b/features.txt @@ -173,10 +173,15 @@ renderHeaderLayer the pane and column tags use, as a TagLayer of the new `.notic offset and its border for free -- none of which a body-grid row can have just by wearing a tagline font. The text is right aligned. The prompt stays on the canonical grid because it owns a cursor, which has to sit on a real cell. -The body starts BELOW the bands rather than under them: Pane.body_offset is the number of rows they take, and every painter and hit test derives the body's -first row from Pardes.bodyTop(pane, rect). That replaced fifteen copies of `if (tag_bottom) r.y else r.y + BOX_H` scattered across the paint and pointer paths, -which is what let the bands and the text they sit over come adrift in the first place. renderBodyLayer zeroes the offset around its own render, because it -paints into a surface of its own that carries no bands. +A notice is an OVERLAY, which is the one place it is NOT like the tree-sitter context: it takes no row from the body and moves no text. It is a chip as wide +as its own message plus a blank cell either side, anchored to the pane's right edge on the body's top rows, and the rest of each of those rows is ordinary +body text that still reads and still answers a click -- Notices.left records where each chip starts and the hit test refuses only the cells it covers. The +chip is measured in GRID columns rather than scaled into the tagline face it is drawn in, because the canonical grid is what a terminal client draws and a +chip narrower than its own text there would clip it; the narrower tagline face simply leaves a little more room inside the chip. The tag layer takes the +geometry the grid pass already chose, so the two cannot disagree and the GUI's "skip the cells a tag layer covers" leaves no stub behind. + +Pardes.bodyTop(rect) is now the single answer to "where does the body begin", replacing fifteen copies of `if (tag_bottom) r.y else r.y + BOX_H` scattered +across the paint, hit-test, scroll, PDF and image paths -- which is what let the bands and the text under them come adrift in the first place. Every notice is ALSO painted on the canonical grid, because the grid is what a terminal client draws and a band it cannot see is a message it never gets. The GUI skips grid cells a tag layer covers, so nothing is drawn twice there. diff --git a/src/gui/gui.zig b/src/gui/gui.zig index c26629ab..3c2fd693 100644 --- a/src/gui/gui.zig +++ b/src/gui/gui.zig @@ -1788,7 +1788,6 @@ const Gui = struct { scroll_pane: ?usize = null, scroll_rect: pardes.Rect = .{ .x = 0, .y = 0, .w = 0, .h = 0 }, scroll_body_y: u16 = 0, // that rect's first BODY row (Tagbottom moves it) - scroll_body_h: u16 = 0, // and how many rows it has, notice bands taken off scroll_col: u16 = 0, // where the wheel turned: crossed rows are delivered scroll_row: u16 = 0, // THERE, not wherever the pointer has drifted to since scroll_delta: f32 = 0, // finite raw distance waiting for the render batch @@ -4293,15 +4292,14 @@ fn stepScroll(g: *Gui, core: *pardes.Pardes, gpa: std.mem.Allocator) void { } g.scroll_lag = st.lag; g.scroll_rect = r; - const body_y = core.bodyTop(pane, r); + const body_y = core.bodyTop(r); g.scroll_body_y = body_y; - g.scroll_body_h = (r.h -| pardes.BOX_H) -| pane.body_offset; if (st.rows != 0) { const s = &core.surface; g.scroll_edge_len = 0; - if (r.w > config.GUTTER and r.h > pardes.BOX_H + pane.body_offset and r.x + r.w <= s.cols) { + if (r.w > config.GUTTER and r.h > pardes.BOX_H and r.x + r.w <= s.cols) { const bw = r.w - config.GUTTER; - const bh = (r.h - pardes.BOX_H) - pane.body_offset; + const bh = r.h - pardes.BOX_H; const k: u16 = @intCast(@min(@abs(st.rows), @as(i32, bh))); const srow = body_y + (if (st.rows > 0) k - 1 else bh - k); if (srow < s.rows) { @@ -4329,11 +4327,7 @@ fn emitScrollRows(g: *Gui, instances: [*]CellInstance, base: u32, surface: *pard const x0 = r.x + config.GUTTER; const y0 = g.scroll_body_y; const bw = r.w - config.GUTTER; - // The body the editor actually painted: measuring it from the rect while - // the origin comes from bodyTop reads past the pane by the band rows, and - // for the bottom-most pane past the surface, which drops the animation. - const bh = g.scroll_body_h; - if (bh == 0) return 0; + const bh = r.h - pardes.BOX_H; if (x0 + bw > surface.cols or y0 + bh > surface.rows) return 0; // resized under us var shifted = layout; shifted.y_off -= g.scroll_lag * layout.h; @@ -4365,7 +4359,7 @@ fn scrollScissor(g: *const Gui, layout: CellLayout, sw: u32, sh: u32) c.SDL_Rect const px = layout.x_off + @as(f32, @floatFromInt(r.x + config.GUTTER)) * layout.w; const py = layout.y_off + @as(f32, @floatFromInt(g.scroll_body_y)) * layout.h; const pw = @as(f32, @floatFromInt(r.w - config.GUTTER)) * layout.w; - const ph = @as(f32, @floatFromInt(g.scroll_body_h)) * layout.h; + const ph = @as(f32, @floatFromInt(r.h - pardes.BOX_H)) * layout.h; const x0 = std.math.clamp(@as(i32, @intFromFloat(@floor(px))), 0, @as(i32, @intCast(sw))); const y0 = std.math.clamp(@as(i32, @intFromFloat(@floor(py))), 0, @as(i32, @intCast(sh))); const x1 = std.math.clamp(@as(i32, @intFromFloat(@ceil(px + pw))), x0, @as(i32, @intCast(sw))); @@ -6691,14 +6685,11 @@ fn appendPaneChrome( const chrome = core.chromeTheme(); const page = overlayRgb(core.theme().bg orelse bg_default); for (core.panes, core.rects) |slot, r| { - const pane = slot orelse continue; - if (r.w <= config.GUTTER or r.h <= pardes.BOX_H) continue; + if (slot == null or r.w <= config.GUTTER or r.h <= pardes.BOX_H) continue; if (@as(u32, r.x) + r.w > surface.cols or @as(u32, r.y) + r.h > surface.rows) continue; const tag_y = if (core.settings.tag_bottom) r.y + r.h - pardes.BOX_H else r.y; - // The rail the editor painted, notice bands included -- overlaying the - // rows above it would tint the bands instead of the scrollbar. - const body_y = core.bodyTop(pane, r); - const body_end = body_y + ((r.h -| pardes.BOX_H) -| pane.body_offset); + const body_y = core.bodyTop(r); + const body_end = body_y + (r.h -| pardes.BOX_H); const x0 = @as(f32, @floatFromInt(r.x)) * layout.w; const x1 = x0 + @as(f32, @floatFromInt(r.w)) * layout.w; const tag_cells = surface.cells[@as(usize, tag_y) * surface.cols + r.x + pardes.TAG_TEXT_INSET ..][0 .. r.w - pardes.TAG_TEXT_INSET]; diff --git a/src/panes.zig b/src/panes.zig index 4b5c6721..f995986b 100644 --- a/src/panes.zig +++ b/src/panes.zig @@ -191,11 +191,6 @@ pub const Pane = struct { /// body layer reserves exactly `len` rows for them, the way it already /// reserves rows for sticky context headers. notices: Notices = .{}, - /// Rows the notice bands take off the TOP of the body, the way tree-sitter - /// context rows do: the body starts below them rather than being painted - /// under them. Zero while the body LAYER renders, which paints into a - /// surface of its own that carries no bands. - body_offset: u16 = 0, pub const Notices = struct { /// Painted bottom-up in this order, so a prompt keeps the row nearest @@ -204,14 +199,25 @@ pub const Pane = struct { pub const max = @typeInfo(Kind).@"enum".fields.len; kinds: [max]Kind = undefined, + /// Where each band's chip starts, as an absolute grid column. A chip + /// is only as wide as its own text, so the rest of the row underneath + /// is ordinary body text and a click there has to reach it. + left: [max]u16 = @splat(std.math.maxInt(u16)), len: u8 = 0, pub fn push(n: *Notices, kind: Kind) void { if (n.len >= max) return; n.kinds[n.len] = kind; + n.left[n.len] = std.math.maxInt(u16); n.len += 1; } + /// Is this cell inside the chip drawn for band `i`? Nothing else on + /// that row belongs to the notice. + pub fn covers(n: *const Notices, i: usize, col: u16) bool { + return i < n.len and col >= n.left[i]; + } + pub fn slice(n: *const Notices) []const Kind { return n.kinds[0..n.len]; } @@ -2041,7 +2047,7 @@ pub const File = struct { const gcrow = if (pane.cur_pinned) pane.cur_row else @as(i32, gcur.y) + goff; const cur_line: i32 = if (active and !pane.tag_edit) gcrow else std.math.minInt(i32); // the body's first row, the way renderPane derives it (Tagbottom) - const body_y = p.bodyTop(pane, r); + const body_y = p.bodyTop(r); const context_bg = p.theme().tag_bg; for (0..@min(pane.context_rows, body_h)) |context_row| { for (0..tw) |col| { @@ -2095,7 +2101,7 @@ pub const File = struct { // indexed start, same as bodyText — an empty tail simply paints nothing var flines = std.mem.splitScalar(u8, f.content[lineStart(p.gpa, f, f.scroll)..], '\n'); const total = nlines(p.gpa, f); - const body_y = p.bodyTop(pane, r); + const body_y = p.bodyTop(r); var vr: u16 = 0; while (vr < body_h) : (vr += 1) { var base: usize = undefined; @@ -2171,7 +2177,7 @@ pub const File = struct { pane_bg: pardes.Color, ) void { if (tw <= gutterWidth(pane) + 1) return; - const body_y = p.bodyTop(pane, r); + const body_y = p.bodyTop(r); const marker_fg = p.chromeTheme().lineno; var row: u16 = 0; while (row + 1 < pane.wrap_n and row + 1 < body_h) : (row += 1) { @@ -2195,9 +2201,9 @@ pub const File = struct { const tx = r.x + config.GUTTER; const tw = r.w - config.GUTTER; const prefix_width = gutterWidth(pane); - const body_y = p.bodyTop(pane, r); + const body_y = p.bodyTop(r); var vr: i32 = 0; - while (vr + @as(i32, pardes.BOX_H) < @as(i32, r.h -| pane.body_offset)) : (vr += 1) { + while (vr + @as(i32, pardes.BOX_H) < @as(i32, r.h)) : (vr += 1) { const here = pane.wrapAt(vr); if (here.line != row) continue; var hi = word_hi; @@ -5482,7 +5488,7 @@ pub const Pdf = struct { if (slot == pane) break core.rects[id]; } else return null; const cols = rect.w -| config.GUTTER; - const rows = (rect.h -| pardes.BOX_H) -| pane.body_offset; + const rows = rect.h -| pardes.BOX_H; if (cols == 0 or rows == 0) return null; return .{ .pixel_w = @as(u32, cols) * @as(u32, core.cell_pixels.w), @@ -5520,8 +5526,8 @@ pub const Pdf = struct { const rect = for (core.panes, 0..) |slot, id| { if (slot == pane) break core.rects[id]; } else return null; - const body_y = core.bodyTop(pane, rect); - if (row < body_y or row >= body_y + ((rect.h -| pardes.BOX_H) -| pane.body_offset)) return null; + const body_y = core.bodyTop(rect); + if (row < body_y or row >= body_y + (rect.h -| pardes.BOX_H)) return null; const local_y = @as(f64, @floatFromInt( @as(u32, row - body_y) * core.cell_pixels.h + core.cell_pixels.h / 2, )); @@ -5577,7 +5583,7 @@ pub const Pdf = struct { if (slot == pane) break core.rects[id]; } else return null; const body_x = @as(i64, rect.x + config.GUTTER); - const body_y = @as(i64, core.bodyTop(pane, rect)); + const body_y = @as(i64, core.bodyTop(rect)); const px = (@as(i64, col) - body_x) * core.cell_pixels.w + core.cell_pixels.w / 2; const py = (@as(i64, row) - body_y) * core.cell_pixels.h + core.cell_pixels.h / 2; return pointAtPage(state, view, page, px, py, clamp_to_page); @@ -5860,7 +5866,7 @@ pub const Pdf = struct { text_width: u16, ) bool { if (comptime !enabled) return false; - if (!core.native_images or rect.h <= pardes.BOX_H + pane.body_offset) return false; + if (!core.native_images or rect.h <= pardes.BOX_H) return false; const state = &(pane.pdf orelse return false); const view = paneViewport(core, pane) orelse return false; const key = TintKey{ .mode = state.tint, .colors = tintColors(core) }; @@ -5897,9 +5903,9 @@ pub const Pdf = struct { null, }, .x = text_x, - .y = core.bodyTop(pane, rect), + .y = core.bodyTop(rect), .w = text_width, - .h = (rect.h -| pardes.BOX_H) -| pane.body_offset, + .h = rect.h -| pardes.BOX_H, .rgba = placed.rgba, .iw = placed.width, // The texture contains the retained band, not the full page. @@ -5911,8 +5917,8 @@ pub const Pdf = struct { // This frame has spent the motion used to choose its raster band. state.scroll_travel = 0; - const body_y = core.bodyTop(pane, rect); - const body_h = (rect.h -| pardes.BOX_H) -| pane.body_offset; + const body_y = core.bodyTop(rect); + const body_h = rect.h -| pardes.BOX_H; const chrome = core.chromeTheme(); const theme = core.theme(); const pane_bg: pardes.Color = if (theme.bg) |color| .{ .rgb = color } else .default; @@ -7579,7 +7585,7 @@ pub const Terminal = struct { if (comptime !enabled) return; const s = &p.surface; if (pane.terminal == null) return; - const body_y = p.bodyTop(pane, r); + const body_y = p.bodyTop(r); var filtered_storage: FilteredColors = undefined; const filtered: ?*FilteredColors = if (pane.tty_filter) blk: { const tz_filter = tracy.zone(@src(), "filterInit"); diff --git a/src/pardes.zig b/src/pardes.zig index c271a16f..0ac16162 100644 --- a/src/pardes.zig +++ b/src/pardes.zig @@ -1168,29 +1168,30 @@ test "TreeContext tag style preserves message rows and its opt-out survives rest pane.msg[0] = '!'; pane.msg_len = 1; _ = try p.render(p.scratch.allocator()); - try std.testing.expectEqual(full_height - 1, p.surface.body_layers[0].viewport.h); + // An overlay takes nothing: the message is a chip OVER the body's first + // row, so the viewport keeps every row it had. + try std.testing.expectEqual(full_height, p.surface.body_layers[0].viewport.h); const r = p.rects[0]; - // The message is a tagline band at the top of the body now, not a body row - // at the bottom: same reservation, different carrier. const band = for (p.surface.tagLayers()) |*layer| { if (layer.cols != 0 and layer.kind == .notice) break layer; } else return error.NoNoticeBand; - try std.testing.expectEqual(r.y + BOX_H, band.viewport.y); - // Right aligned: the text sits in the last cell the viewport actually - // shows, which is a column short of the layer's cursor slack. - try std.testing.expectEqualStrings("!", band.cells[p.tagCapacity(band.viewport.w) - 1].grapheme()); - // ...and the body starts below it rather than under it. - try std.testing.expectEqual(band.viewport.y + 1, p.surface.body_layers[0].viewport.y); + try std.testing.expectEqual(p.bodyTop(r), band.viewport.y); + try std.testing.expectEqual(p.surface.body_layers[0].viewport.y, band.viewport.y); + // Sized to its message, flush with the pane's right edge, and the text + // right aligned a cell short of that edge. + try std.testing.expectEqual(r.x + r.w, band.viewport.x + band.viewport.w); + try std.testing.expect(band.viewport.w < r.w - config.GUTTER); + try std.testing.expectEqualStrings("!", band.cells[p.tagCapacity(band.viewport.w) - 2].grapheme()); pane.msg_len = 0; p.leader_on = true; _ = try p.render(p.scratch.allocator()); - try std.testing.expectEqual(full_height - 1, p.surface.body_layers[0].viewport.h); + try std.testing.expectEqual(full_height, p.surface.body_layers[0].viewport.h); p.leader_on = false; try std.testing.expect(p.executeBuiltinLine(0, "TreeContextTagStyle")); _ = try p.render(p.scratch.allocator()); try std.testing.expectEqual(@as(u16, 0), p.surface.body_layers[0].rows); try std.testing.expectEqual(@as(u16, 0), pane.body_rows); - try std.testing.expectEqual(FontRole.body, p.surface.at(r.x + config.GUTTER, p.bodyTop(pane, r)).style.font_role); + try std.testing.expectEqual(FontRole.body, p.surface.at(r.x + config.GUTTER, p.bodyTop(r)).style.font_role); try p.dumpState(); const restored = try Pardes.initFromDump(p.gpa, .{ .tty_only = true }, p.dump_out.?); defer restored.deinit(); @@ -6282,6 +6283,33 @@ pub const Pardes = struct { return p; } + /// `SPC` plus the chord keys typed so far, spaced out the way the help + /// index spells a leader path. + fn leaderText(p: *const Pardes, buf: *[16]u8) []const u8 { + buf.* = @splat(' '); + @memcpy(buf[0..3], "SPC"); + var at: usize = 3; + for (p.leader_keys[0..p.leader_n]) |ch| { + if (at + 2 > buf.len) break; + buf[at + 1] = ch; + at += 2; + } + return buf[0..at]; + } + + /// How wide a notice chip is, in grid columns: its own text plus a blank + /// cell either side. A notice is an OVERLAY over the body's top rows, not + /// a row taken from them, so it is sized to its message and never to the + /// pane. Counted in GRID columns rather than scaled into the tagline face + /// it is drawn in, because the canonical grid is what a terminal client + /// draws and a chip narrower than its own text there would clip it; the + /// tagline face simply leaves a little more room inside the chip. + fn noticeCols(p: *const Pardes, text: []const u8, limit: u16) u16 { + _ = p; + if (limit == 0) return 0; + return @intCast(std.math.clamp(panes.File.displayWidth(text) + 2, 1, @as(usize, limit))); + } + /// Prints `text` flush with the right edge of the band, and answers the /// column it started at so a cursor can follow it. fn printRight(s: *Surface, x: u16, row: u16, w: u16, text: []const u8, style: CellStyle) u16 { @@ -11264,13 +11292,14 @@ pub const Pardes = struct { const r = p.rects[id]; if (col < r.x + config.GUTTER or col >= r.x + r.w or row < r.y or row >= r.y + r.h) return null; const tag_y = if (p.settings.tag_bottom) r.y + r.h -| BOX_H else r.y; - const body_y = p.bodyTop(p.panes[id].?, r); + const body_y = p.bodyTop(r); const on_tag = row >= tag_y and row < tag_y + BOX_H; if (on_tag and col < r.x + TAG_TEXT_INSET) return null; - // A notice band is chrome. Without this it maps to Sel row 0 or less, - // which is the TAG row -- so a click on a leader band would expand a - // word out of the tag text and run it as a builtin. - if (!on_tag and row >= body_y -| p.panes[id].?.body_offset and row < body_y) return null; + // A notice chip is chrome: it sits OVER the body's top rows, so a + // click inside one belongs to nobody. The rest of those rows is + // ordinary body text and still answers normally. + if (!on_tag and row >= body_y and row - body_y < p.panes[id].?.notices.len and + p.panes[id].?.notices.covers(row - body_y, col)) return null; if (!on_tag) if (body_hit) |supplied| { const mapped_hit = p.bodyHitForPane(id, supplied, false) orelse return null; const c = @as(i32, mapped_hit.col) - config.GUTTER; @@ -11657,7 +11686,7 @@ pub const Pardes = struct { if (previous.tag_edit) exitTagEdit(previous); }; const tag_y = if (p.settings.tag_bottom) r.y + r.h -| BOX_H else r.y; - const body_y = p.bodyTop(pane, r); + const body_y = p.bodyTop(r); if (mcol < r.x + config.GUTTER) { // gutter scrollbar: a left click scrolls UP to that row p.active = id; @@ -11721,7 +11750,7 @@ pub const Pardes = struct { // the tag row and the body's first, exactly as the select // arm above derives them const tag_y = if (p.settings.tag_bottom) r.y + r.h -| BOX_H else r.y; - const body_y = p.bodyTop(pane, r); + const body_y = p.bodyTop(r); const on_tag = mrow >= tag_y and mrow < tag_y + BOX_H; if (mcol < r.x + config.GUTTER and !on_tag) { const local = @as(i32, mrow) - @as(i32, body_y); @@ -11818,8 +11847,8 @@ pub const Pardes = struct { // measure from the body's top, notice bands included, or a // selection made while a message is up lands rows away // from the pointer. - const body_y = p.bodyTop(pane, r); - const body_h = (r.h -| BOX_H) -| pane.body_offset; + const body_y = p.bodyTop(r); + const body_h = r.h -| BOX_H; pane.sel[b].r1 = if (pane.sel[b].r0 < BOX_H or body_h == 0) 0 else @@ -13370,12 +13399,11 @@ pub const Pardes = struct { return null; } - /// The pane's first body row: under the tag when it is on top, and under - /// whatever notice bands `collectNotices` stacked above the body. Every - /// painter and hit test derives the body from here so the bands cannot - /// come adrift from the text they sit over. - pub fn bodyTop(p: *const Pardes, pane: *const Pane, r: Rect) u16 { - return (if (p.settings.tag_bottom) r.y else r.y + BOX_H) + pane.body_offset; + /// The pane's first body row: under the tag when it is on top, over it + /// when it is at the bottom. Notice bands do NOT move it -- they are an + /// overlay, drawn over the top rows rather than taking them. + pub fn bodyTop(p: *const Pardes, r: Rect) u16 { + return if (p.settings.tag_bottom) r.y else r.y + BOX_H; } fn tagCapacity(p: *const Pardes, physical_width: u16) u16 { @@ -13461,12 +13489,13 @@ pub const Pardes = struct { .bg = .{ .rgb = chrome.tag_bg }, .font_role = .tagline, }; - // Sticky at the TOP of the body, where the tree-sitter context - // headers sit, one line to a row in the order collectNotices chose. - // Text is right aligned: the left edge is where the body's own text - // begins, and a notice that shared it would read as a line of the - // file rather than as chrome over it. - const first = if (p.settings.tag_bottom) r.y else r.y + BOX_H; + // An OVERLAY over the body's top rows, at the right edge, one + // chip to a row in the order collectNotices chose -- not a row + // taken out of the body the way a tree-sitter context header is. + // The chip is as wide as its own message and no wider, so the text + // beneath the rest of the row keeps reading as the file it is. + const first = p.bodyTop(r); + var leader_buf: [16]u8 = undefined; for (pane.notices.slice(), 0..) |kind, i| { const row = first + @as(u16, @intCast(i)); // Every notice is painted on the canonical grid as well as @@ -13474,39 +13503,34 @@ pub const Pardes = struct { // draws, and a band it cannot see is a message it never gets. // The GUI skips grid cells a tag layer covers, so nothing is // drawn twice there. - s.fill(tx, row, tw, 1, .{ .bg = msg_style.bg, .font_role = .tagline }); - switch (kind) { - .message => _ = printRight(s, tx, row, tw, pane.msg[0..pane.msg_len], msg_style), - .leader => { - var ibuf: [16]u8 = @splat(' '); - @memcpy(ibuf[0..3], "SPC"); - var iw: usize = 3; - for (p.leader_keys[0..p.leader_n]) |ch| { - ibuf[iw + 1] = ch; - iw += 2; - } - _ = printRight(s, tx, row, tw, ibuf[0..iw], msg_style); - }, - .prompt => { + const text = switch (kind) { + .message => pane.msg[0..pane.msg_len], + .leader => p.leaderText(&leader_buf), + .prompt => blk: { const at = pane.promptAt() orelse continue; - const text = pane.tagSlice()[@min(at, pane.tag_tail_len)..]; - // One column short of the edge: the caret sits AFTER - // the last character the moment a prompt opens, and - // flush right would put it at r.x + r.w -- off the - // pane, off the grid, and past what the detached wire - // will encode, which drops every frame while it is up. - const left = printRight(s, tx, row, tw -| 1, text, msg_style); - if (id != p.active) continue; - const prompt0 = (p.tagPrefix(pane) catch continue).len + at; - const col = @as(usize, pane.tag_col); - if (col >= prompt0) { - // The cursor follows the text to wherever it landed. - const prompt_col = panes.File.displayWidth(text[0..@min(col - prompt0, text.len)]); - if (prompt_col < tw) - s.cursor = .{ .x = left + @as(u16, @intCast(prompt_col)), .y = row, .bar = pane.mode == .insert }; - } + break :blk pane.tagSlice()[@min(at, pane.tag_tail_len)..]; }, - } + }; + const chip = p.noticeCols(text, tw); + if (chip == 0) continue; + const cx = tx + tw - chip; + pane.notices.left[i] = cx; + s.fill(cx, row, chip, 1, .{ .bg = msg_style.bg, .font_role = .tagline }); + // One column short of the chip's right edge: a prompt's caret + // sits AFTER its last character the moment it opens, and flush + // right would put it past the pane, off the grid, and past what + // the detached wire will encode -- which drops every frame for + // as long as the prompt is up. + const left = printRight(s, cx, row, chip -| 1, text, msg_style); + if (kind != .prompt or id != p.active) continue; + const at = pane.promptAt() orelse continue; + const prompt0 = (p.tagPrefix(pane) catch continue).len + at; + const col = @as(usize, pane.tag_col); + if (col < prompt0) continue; + // The cursor follows the text to wherever it landed. + const prompt_col = panes.File.displayWidth(text[0..@min(col - prompt0, text.len)]); + if (left + prompt_col < tx + tw) + s.cursor = .{ .x = left + @as(u16, @intCast(prompt_col)), .y = row, .bar = pane.mode == .insert }; } } @@ -13829,11 +13853,11 @@ pub const Pardes = struct { const raw = pane.mode == .tty; const tx = r.x + config.GUTTER; const width = r.w -| config.GUTTER; - const body_y = p.bodyTop(pane, r); + const body_y = p.bodyTop(r); var lines = std.mem.splitScalar(u8, body, '\n'); var visible: i32 = 0; while (lines.next()) |line| : (visible += 1) { - if (visible >= (r.h -| BOX_H) -| pane.body_offset) break; + if (visible >= r.h -| BOX_H) break; const source_row = if (raw) panes.Terminal.gridOffset(pane) + visible else pane.wrapAt(visible).line; for (rows) |row| { const target = if (row.raw_terminal) @@ -13871,10 +13895,10 @@ pub const Pardes = struct { const terminal_lines = if (pane.file == null) panes.Terminal.cursorLines(p, pane) catch return else &.{}; const tx = r.x + config.GUTTER; const width = r.w -| config.GUTTER; - const body_y = p.bodyTop(pane, r); + const body_y = p.bodyTop(r); const prefix: i32 = if (pane.file != null) panes.File.gutterWidth(pane) else 0; var visible: i32 = 0; - while (visible < @as(i32, (r.h -| BOX_H) -| pane.body_offset)) : (visible += 1) { + while (visible < @as(i32, r.h -| BOX_H)) : (visible += 1) { const source = pane.wrapAt(visible); const line = pointerSourceLine(pane, terminal_lines, source.line); const start = @min(line.len, @as(usize, @intCast(@max(0, source.at)))); @@ -13919,11 +13943,6 @@ pub const Pardes = struct { while (row < r.h) : (row += 1) { if (@as(i32, row) < r0 or @as(i32, row) > r1) continue; const sy = if (row < BOX_H) tag_y else body_y + row - BOX_H; - // The body sits `body_offset` rows lower than it used to, so the - // last rows of Sel space now fall past the pane. Bounding the loop - // instead would break the caller that paints a tag into a - // one-row surface of its own, where the offset means nothing. - if (row >= BOX_H and sy >= r.y + r.h) break; // File line numbers occupy a gutter only in the body. The tag is // row zero in Sel space and starts at its real first text cell. const scroll: i32 = if (row < BOX_H) pane.tag_scroll else 0; @@ -13972,48 +13991,45 @@ pub const Pardes = struct { // workspace layer to render; the menu bar carries its commands. if (p.settings.workspace_tag) try p.renderHeaderLayer(arena, MAX_PANES + MAX_COLS, .workspace, 0, .{ .x = 0, .y = 0, .w = p.screen_w, .h = TOPBAR_H }, p.topbar(&text_buf), chrome.tag_bg, chrome.tag_fg); - // Each notice is its own tagline-shaped band at the top of the body. + // Each notice is its own tagline-shaped chip over the top of the body. // Going through the same layer machinery the pane and column tags use // is what gives it the tagline's height, its small-font metrics, the // band offset and the border -- none of which a body-grid row can have - // just by wearing a tagline font. + // just by wearing a tagline font. The geometry is the one the grid + // pass already chose and recorded, so the two cannot disagree and the + // GUI's "skip the cells a tag layer covers" leaves no stub behind. for (p.panes, 0..) |slot, id| { const pane = slot orelse continue; const r = p.rects[id]; if (r.w <= TAG_TEXT_INSET or r.h <= BOX_H) continue; - const first = if (p.settings.tag_bottom) r.y else r.y + BOX_H; - var band: u16 = 0; - for (pane.notices.slice()) |kind| { + const first = p.bodyTop(r); + var leader_buf: [16]u8 = undefined; + for (pane.notices.slice(), 0..) |kind, i| { const text = switch (kind) { .message => pane.msg[0..pane.msg_len], - .leader => blk: { - var ibuf: [16]u8 = @splat(' '); - @memcpy(ibuf[0..3], "SPC"); - var iw: usize = 3; - for (p.leader_keys[0..p.leader_n]) |ch| { - ibuf[iw + 1] = ch; - iw += 2; - } - break :blk try arena.dupe(u8, ibuf[0..iw]); - }, + .leader => p.leaderText(&leader_buf), // A prompt is an editing line with a cursor in it, so it // stays on the grid where the cursor can sit on a cell. .prompt => continue, }; if (text.len == 0) continue; - const room = p.tagCapacity(r.w -| TAG_TEXT_INSET); + const cx = pane.notices.left[i]; + if (cx == std.math.maxInt(u16) or cx >= r.x + r.w) continue; + const chip = r.x + r.w - cx; + // Right aligned inside the chip, a blank cell short of its + // edge: the same one the grid pass leaves for a prompt caret. + const room = p.tagCapacity(chip) -| 1; const shown = panes.File.displayWidth(text); const pad = room -| shown; const line = try arena.alloc(u8, pad + text.len); @memset(line[0..pad], ' '); @memcpy(line[pad..], text); - try p.renderHeaderLayer(arena, NOTICE_LAYER_BASE + id * Pane.Notices.max + band, .notice, @intCast(id), .{ - .x = r.x + TAG_TEXT_INSET, - .y = first + band, - .w = r.w -| TAG_TEXT_INSET, + try p.renderHeaderLayer(arena, NOTICE_LAYER_BASE + id * Pane.Notices.max + i, .notice, @intCast(id), .{ + .x = cx, + .y = first + @as(u16, @intCast(i)), + .w = chip, .h = BOX_H, }, line, chrome.tag_bg, chrome.tag_fg); - band += 1; } } if (p.columnBarHeight() > 0) for (0..p.ncol) |column| { @@ -14087,7 +14103,6 @@ pub const Pardes = struct { /// them instead of letting the last one win the row. fn collectNotices(p: *Pardes, pane: *Pane, r: Rect, id: usize) void { pane.notices.len = 0; - pane.body_offset = 0; if (r.w <= config.GUTTER or r.h <= BOX_H) return; if (pane.msg_len > 0) pane.notices.push(.message); if (id == p.active and p.leader_on) pane.notices.push(.leader); @@ -14105,13 +14120,12 @@ pub const Pardes = struct { for (0..room) |i| pane.notices.kinds[i] = pane.notices.kinds[i + drop]; pane.notices.len = room; } - pane.body_offset = pane.notices.len; } fn renderBodyLayer(p: *Pardes, arena: std.mem.Allocator, pane: *Pane, r: Rect, id: usize) !void { if (!p.settings.tree_context_tag_style or pane.context_rows == 0 or pane.file == null or pane.collapsed) return; if (r.w <= config.GUTTER or r.h <= BOX_H) return; - const viewport_rows = r.h - BOX_H -| @as(u16, pane.notices.len); + const viewport_rows = r.h - BOX_H; if (viewport_rows == 0) return; // The canonical fixed grid remains available to terminal clients. The // separate body layer reserves enough rows for any compact font size. @@ -14132,9 +14146,6 @@ pub const Pardes = struct { @memset(temporary_cells, .{}); var temporary: Surface = .{ .cols = r.w, .rows = @intCast(logical_rows + BOX_H), .cells = temporary_cells }; std.mem.swap(Surface, &p.surface, &temporary); - // This surface carries no notice bands, so the body starts at its top. - pane.body_offset = 0; - defer pane.body_offset = pane.notices.len; const synthetic: Rect = .{ .x = 0, .y = 0, .w = r.w, .h = @intCast(logical_rows + BOX_H) }; p.renderBody(arena, pane, synthetic, id, id == p.active, false) catch |err| { std.mem.swap(Surface, &p.surface, &temporary); @@ -14148,11 +14159,7 @@ pub const Pardes = struct { } layer.pane = @intCast(id); layer.serial = pane.serial; - // Below the notice bands, which are stacked at the TOP of the body - // now: the rows they took came off this viewport, so its origin has to - // move with them or the first context header renders under a band. - const body_top = (if (p.settings.tag_bottom) r.y else r.y + BOX_H) + @as(u16, pane.notices.len); - layer.viewport = .{ .x = r.x + config.GUTTER, .y = body_top, .w = width, .h = viewport_rows }; + layer.viewport = .{ .x = r.x + config.GUTTER, .y = p.bodyTop(r), .w = width, .h = viewport_rows }; layer.cols = width; layer.rows = @intCast(logical_rows); layer.context_rows = pane.context_rows; @@ -14174,7 +14181,7 @@ pub const Pardes = struct { const tx = r.x + config.GUTTER; // text area (tag + body), right of the gutter const tw = r.w - config.GUTTER; const tag_y = if (p.settings.tag_bottom) r.y + r.h -| BOX_H else r.y; - const body_y = p.bodyTop(pane, r); + const body_y = p.bodyTop(r); const pane_bg: Color = if (th.bg) |c| .{ .rgb = c } else .default; // text area resets to terminal-default cells (vaxis clear semantics); @@ -14214,7 +14221,7 @@ pub const Pardes = struct { if (pane.hasPdf() and panes.Pdf.draw(p, pane, r, id, tx, tw)) return; if (pane.image) |*iv| { - const image_h = (r.h -| BOX_H) -| pane.body_offset; + const image_h = r.h -| BOX_H; panes.Image.draw(p, iv, @intCast(id), pane.serial, tx, body_y, tw, image_h); // thumbless, but the same one column as the real scrollbar below — // that is the whole point of drawing it, and like that one it runs @@ -14235,7 +14242,7 @@ pub const Pardes = struct { const tx = r.x + @min(TAG_TEXT_INSET, r.w); const tw = r.w -| TAG_TEXT_INSET; const tag_y = if (p.settings.tag_bottom) r.y + r.h -| BOX_H else r.y; - const body_y = p.bodyTop(pane, r); + const body_y = p.bodyTop(r); const page_rgb = th.bg orelse th.tag_bg; // Focus is visible along the tag without changing its live text grid. const tag_bg = if (active and p.settings.focus_tint) chrome.tag_active_bg else chrome.tag_bg; @@ -14322,12 +14329,12 @@ pub const Pardes = struct { // Below the notice bands: they are stacked at the top of the body the // way tree-sitter context rows are, so the body starts under them // rather than being painted over by them. - const body_y = p.bodyTop(pane, r); + const body_y = p.bodyTop(r); const pane_bg: Color = if (th.bg) |c| .{ .rgb = c } else .default; const page_rgb = th.bg orelse th.tag_bg; // body: emulator rows, prompt rows hidden outside tty mode - const body_h = (r.h -| BOX_H) -| pane.body_offset; - const body_bottom = r.h -| pane.body_offset; + const body_h = r.h -| BOX_H; + const body_bottom = r.h; const body_style: CellStyle = .{ .fg = if (th.fg) |c| .{ .rgb = c } else .default, .bg = pane_bg, @@ -14820,7 +14827,7 @@ test "a builtin announces itself on the message row, and Verbose silences it" { try std.testing.expectEqual(@as(u16, 0), pane.msg_len); } -test "notices stack downward from the top of the body, which starts below them" { +test "notices stack over the body's top rows without moving them" { if (platform == .web) return; const p = try Pardes.init(std.testing.allocator, .{ .tty_only = true, .cols = 80, .rows = 24 }); defer p.deinit(); @@ -14831,44 +14838,45 @@ test "notices stack downward from the top of the body, which starts below them" defer frame.deinit(); const r = p.rects[id]; - const plain = p.bodyTop(pane, r); - try std.testing.expectEqual(@as(u16, 0), pane.body_offset); + const top = p.bodyTop(r); - // A message and a leader prefix at once: two bands, stacked in the order + // A message and a leader prefix at once: two chips, in the order // collectNotices chose, each one row tall and each one row further down. try std.testing.expect(p.executeBuiltinLine(id, "Msg first")); p.leader_on = true; p.leader_n = 0; _ = frame.reset(.retain_capacity); _ = try p.render(frame.allocator()); - try std.testing.expectEqual(@as(u16, 2), pane.body_offset); - try std.testing.expectEqual(plain + 2, p.bodyTop(pane, r)); + try std.testing.expectEqual(@as(u8, 2), pane.notices.len); + // An overlay, not a reservation: the body still starts where it did. + try std.testing.expectEqual(top, p.bodyTop(r)); - var rows: [Pane.Notices.max]u16 = @splat(0); - var found: usize = 0; + var seen: usize = 0; for (p.surface.tagLayers()) |*layer| { if (layer.cols == 0 or layer.kind != .notice) continue; try std.testing.expectEqual(@as(u16, 1), layer.viewport.h); - rows[found] = layer.viewport.y; - found += 1; - } - try std.testing.expectEqual(@as(usize, 2), found); - std.mem.sort(u16, rows[0..2], {}, std.sort.asc(u16)); - try std.testing.expectEqual(plain, rows[0]); - try std.testing.expectEqual(plain + 1, rows[1]); - - // Gone with the notices: no stale band, and the body back at the top. + // Sized to its own message, right up against the pane's right edge -- + // not the width of the pane. + try std.testing.expectEqual(r.x + r.w, layer.viewport.x + layer.viewport.w); + try std.testing.expect(layer.viewport.w < r.w - config.GUTTER); + try std.testing.expect(layer.viewport.y == top or layer.viewport.y == top + 1); + try std.testing.expectEqual(pane.notices.left[layer.viewport.y - top], layer.viewport.x); + seen += 1; + } + try std.testing.expectEqual(@as(usize, 2), seen); + // "first" is longer than "SPC", so its chip is wider. + try std.testing.expect(pane.notices.left[0] < pane.notices.left[1]); + + // Gone with the notices: no stale chip left behind. p.leader_on = false; pane.msg_len = 0; _ = frame.reset(.retain_capacity); _ = try p.render(frame.allocator()); - try std.testing.expectEqual(@as(u16, 0), pane.body_offset); - try std.testing.expectEqual(plain, p.bodyTop(pane, r)); for (p.surface.tagLayers()) |*layer| try std.testing.expect(layer.cols == 0 or layer.kind != .notice); } -test "a prompt band keeps its caret on the grid, and a band is not a click target" { +test "a prompt chip keeps its caret on the grid, and only the chip swallows a click" { if (platform == .web) return; const p = try Pardes.init(std.testing.allocator, .{ .tty_only = true, .cols = 80, .rows = 24 }); defer p.deinit(); @@ -14879,24 +14887,36 @@ test "a prompt band keeps its caret on the grid, and a band is not a click targe defer frame.deinit(); // The caret sits AFTER the prompt text the moment the prompt opens, and - // the band is flush with the pane's right edge -- so this is the frame - // that used to put it one column past the pane, off the grid and past - // what the detached wire will encode. + // the chip ends at the pane's right edge -- so this is the frame that + // used to put it one column past the pane, off the grid and past what the + // detached wire will encode. p.startPrompt(pane, .{ .search = "/" }); _ = try p.render(frame.allocator()); const r = p.rects[id]; const cursor = p.surface.cursor orelse return error.MissingPromptCursor; - try std.testing.expect(pane.body_offset > 0); - try std.testing.expectEqual(p.bodyTop(pane, r) - 1, cursor.y); + const row = p.bodyTop(r); + try std.testing.expectEqual(@as(u8, 1), pane.notices.len); + try std.testing.expectEqual(row, cursor.y); try std.testing.expect(cursor.x < r.x + r.w); try std.testing.expect(cursor.x < p.surface.cols); - // The band is chrome. Mapped as body it would land on Sel row 0, which is - // the TAG row, so a click on it would run a word out of the tag as a - // builtin. - const band_row = p.bodyTop(pane, r) - 1; - p.update(.{ .mouse = .{ .button = .left, .kind = .press, .col = r.x + r.w - 4, .row = band_row } }); - p.update(.{ .mouse = .{ .button = .left, .kind = .release, .col = r.x + r.w - 4, .row = band_row } }); + // The chip covers only its own columns. Left of it is ordinary body, and + // a sweep there still selects. + const left = pane.notices.left[0]; + try std.testing.expect(left > r.x + config.GUTTER + 2); + p.update(.{ .mouse = .{ .button = .left, .kind = .press, .col = left - 3, .row = row } }); + p.update(.{ .mouse = .{ .button = .left, .kind = .drag, .col = left - 1, .row = row } }); + p.update(.{ .mouse = .{ .button = .left, .kind = .release, .col = left - 1, .row = row } }); + try std.testing.expect(pane.sel[0].state != .none); + try std.testing.expect(pane.sel[0].r0 >= BOX_H); // the body, not the tag + + // Inside it is chrome: mapped as body it would land on Sel row 0, which is + // the TAG row, so a sweep there would highlight the tagline instead. + pane.clearPointerSelection(0); + pane.sel[0] = .{}; + p.update(.{ .mouse = .{ .button = .left, .kind = .press, .col = r.x + r.w - 3, .row = row } }); + p.update(.{ .mouse = .{ .button = .left, .kind = .drag, .col = r.x + r.w - 2, .row = row } }); + p.update(.{ .mouse = .{ .button = .left, .kind = .release, .col = r.x + r.w - 2, .row = row } }); for (pane.sel) |selection| try std.testing.expect(selection.state == .none); } diff --git a/test/output.zig b/test/output.zig index 8afbf4d2..ad33954f 100644 --- a/test/output.zig +++ b/test/output.zig @@ -77,7 +77,7 @@ fn outputCell(p: *Pardes, surface: *pardes.Surface, id: usize, byte: usize) *par const line = modal.lineSlice(pane.file.?.content, 0); const rect = p.rects[id]; const x = rect.x + config.GUTTER + panes.File.gutterWidth(pane) + @as(u16, @intCast(panes.File.displayWidth(line[0..byte]))); - const y = p.bodyTop(pane, rect); + const y = p.bodyTop(rect); return surface.at(x, y); } @@ -490,7 +490,7 @@ test "Mini syntax colors survive toggles themes and rendering without source acc const surface = try p.render(frame.allocator()); const rect = p.rects[id]; const x = rect.x + config.GUTTER + panes.File.gutterWidth(mini) + @as(u16, @intCast(column)); - const y = p.bodyTop(mini, rect) + @as(u16, @intCast(position.row)); + const y = p.bodyTop(rect) + @as(u16, @intCast(position.row)); if (enabled) try std.testing.expectEqualDeep(pardes.Color{ .rgb = p.theme().kw }, surface.at(x, y).style.fg); try std.testing.expectEqual(colors, mini.file.?.mini.?.colors.ptr); try std.testing.expectEqual(@as(usize, 0), mini.file.?.highlights.len); diff --git a/test/panes.zig b/test/panes.zig index 69628cd9..8e71e69d 100644 --- a/test/panes.zig +++ b/test/panes.zig @@ -468,7 +468,7 @@ const TreeContextTests = struct { try std.testing.expectEqual(@as(i32, 59), pane.wrapAt(visible.row).line); const cursor = surface.cursor orelse return error.MissingLookCursor; const rect = p.rects[0]; - const y = p.bodyTop(pane, rect); + const y = p.bodyTop(rect); try std.testing.expectEqual(y + @as(u16, @intCast(visible.row)), cursor.y); } } @@ -490,7 +490,7 @@ const TreeContextTests = struct { try std.testing.expectEqual(@as(i32, 7), pane.wrapAt(pane.context_rows).line); const rect = p.rects[0]; const x = rect.x + config.GUTTER + panes.File.gutterWidth(pane); - const y = p.bodyTop(pane, rect); + const y = p.bodyTop(rect); ClickCursorTests.click(p, .left, x + 6, y); try std.testing.expectEqual(@as(i32, 0), pane.cur_row); try std.testing.expectEqual(@as(i32, 6), pane.cur_col); @@ -499,7 +499,7 @@ const TreeContextTests = struct { try std.testing.expectEqual(x + 6, cursor.x); // Read the body top again: the click cleared the announcement band the // builtin above put up, and the body moved back up with it. - try std.testing.expectEqual(p.bodyTop(pane, p.rects[0]), cursor.y); + try std.testing.expectEqual(p.bodyTop(p.rects[0]), cursor.y); p.update(.{ .key = .{ .cp = 'i' } }); p.update(.{ .key = .{ .cp = 'Z', .text = "Z" } }); try std.testing.expect(std.mem.startsWith(u8, pane.file.?.content, "const ZBox = struct {")); @@ -538,7 +538,7 @@ const TreeContextTests = struct { const surface = try p.render(frame.allocator()); try std.testing.expectEqual(@as(u16, 3), pane.context_rows); const rect = p.rects[0]; - const y = p.bodyTop(pane, rect); + const y = p.bodyTop(rect); var glyph_x: ?u16 = null; for (0..surface.cols) |col| { if (std.mem.eql(u8, surface.at(@intCast(col), y).grapheme(), "界")) glyph_x = @intCast(col); @@ -552,7 +552,7 @@ const TreeContextTests = struct { try std.testing.expectEqual(x, cursor.x); // Read the body top again: the click cleared the announcement band the // builtin above put up, so the body moved with it. - try std.testing.expectEqual(p.bodyTop(pane, p.rects[0]), cursor.y); + try std.testing.expectEqual(p.bodyTop(p.rects[0]), cursor.y); panes.File.setContent(p, &pane.file.?, try p.gpa.dupe(u8, "// no enclosing declaration\n" ** 18)); _ = try p.render(frame.allocator()); try std.testing.expectEqual(@as(u16, 0), pane.context_rows); @@ -580,16 +580,12 @@ const TreeContextTests = struct { target = .{ .x = @intCast(col), .y = @intCast(row) }; }; const glyph = target orelse return error.MissingWrappedContextBody; - const offset = pane.body_offset; ClickCursorTests.click(p, .left, glyph.x + 1, glyph.y); try std.testing.expectEqual(@as(i32, 2), pane.cur_row); try std.testing.expectEqual(@as(i32, @intCast(std.mem.indexOf(u8, body, "界").?)), pane.cur_col); const cursor = (try p.render(frame.allocator())).cursor orelse return error.MissingContextBodyCursor; try std.testing.expectEqual(glyph.x, cursor.x); - // The scan above ran with the builtin's announcement band up; the click - // cleared it, so the row the glyph was found on has moved up with the - // body it belongs to. - try std.testing.expectEqual(glyph.y - offset, cursor.y); + try std.testing.expectEqual(glyph.y, cursor.y); } }; @@ -615,7 +611,7 @@ const TtySelectionTests = struct { _ = try p.render(frame.allocator()); const rect = p.rects[0]; const x = rect.x + config.GUTTER; - const y = p.bodyTop(pane, rect); + const y = p.bodyTop(rect); JumpSelectionTests.drag(p, x + 1, y, x + 3, y); try std.testing.expectEqualStrings("lph", p.yank orelse return error.MissingAutomaticTtyYank); p.update(.{ .key = .{ .cp = p.opts.tty_toggle, .ctrl = true } }); @@ -645,7 +641,7 @@ const TtySelectionTests = struct { _ = try p.render(frame.allocator()); const rect = p.rects[0]; const x = rect.x + config.GUTTER; - const y = p.bodyTop(pane, rect); + const y = p.bodyTop(rect); JumpSelectionTests.drag(p, x + @as(u16, if (prompt) 0 else 1), y, x + 3, y + @as(u16, if (prompt) 0 else 1)); const expected = if (prompt) "$ ab" else "lph\nrav"; try std.testing.expectEqual(Pane.Mode.tty, pane.mode); @@ -960,7 +956,7 @@ const JumpSelectionTests = struct { if (wrap) try std.testing.expectEqual(pane.wrap_line[0], pane.wrap_line[1]); const rect = p.rects[0]; const x = rect.x + config.GUTTER + panes.File.gutterWidth(pane); - const y = p.bodyTop(pane, rect); + const y = p.bodyTop(rect); if (reverse) drag(p, x + last_col, y + 1, x + first_col, y) else @@ -991,7 +987,7 @@ const JumpSelectionTests = struct { // A selection created after Back must also disappear on Forward. // Back announces itself, so the body sits under a notice band now. - const y2 = p.bodyTop(pane, p.rects[0]); + const y2 = p.bodyTop(p.rects[0]); drag(p, x + 1, y2, x + 3, y2 + 1); try std.testing.expect(pardes.test_api.heldSelection(p, 0) != null); p.update(.{ .key = .{ .cp = 'i', .ctrl = true } }); @@ -4127,7 +4123,7 @@ test "cancelled normal gestures leave no count or subprefix after mouse and focu .body, .tag => { const rect = p.rects[0]; const tag_y = if (p.settings.tag_bottom) rect.y + rect.h - pardes.BOX_H else rect.y; - const body_y = p.bodyTop(pane, rect); + const body_y = p.bodyTop(rect); const x = rect.x + config.GUTTER + @as(u16, @intCast(panes.File.gutterWidth(pane))) + 3; const y = if (gesture == .tag) tag_y else body_y; p.update(.{ .mouse = .{ .button = config.select_button, .kind = .press, .col = x, .row = y } }); diff --git a/test/snapshots/builtins.golden b/test/snapshots/builtins.golden index 96dabb54..a36092f7 100644 --- a/test/snapshots/builtins.golden +++ b/test/snapshots/builtins.golden @@ -42,10 +42,4 @@ |32: 13 |33: 14 A pane is just text on screen. There is no separate "buffer" type — |34: 15 what you see is what you edit. Some panes happen to be live terminals; -|36: Tutor -|37: 1 pardes builtins under SPC h -|38: 2 -|39: 3 SPC h c Changelog topbar -|40: 4 SPC h m Messages -|41: 5 SPC h t Tutor topbar -|42: 6 +|36: 1 pardes builtins under SPC h Tutor diff --git a/test/snapshots/chordcut.golden b/test/snapshots/chordcut.golden index a9586983..8e83e584 100644 --- a/test/snapshots/chordcut.golden +++ b/test/snapshots/chordcut.golden @@ -2,9 +2,9 @@ |Newcol Joincol Find Grep Help Changelog Tutor Dump NextColor Debug Kill | New Tty Find Grep Joincol Delcol New Tty Find Grep Joincol Delcol | /tmp/pardes-snap/chordcut/cwd Tty Save Mode Filter Collap /tmp/pardes-snap/chordcut/cwd Tty Save Mode Filter Collap -| Look ls -| ls f.txt g.txt -| f.txt g.txt +| ls Look ls +| f.txt g.txt f.txt g.txt +| | /tmp/pardes-snap/chordcut/cwd/f.txt Save Tty Collapse Del | 1 line 1 | 2 line 2 @@ -21,8 +21,6 @@ | f.txt g.txt == snap cut grid=120x31 cursor=7,8 |3: ls ls -|4: f.txt g.txt f.txt g.txt -|5: |6: /tmp/pardes-snap/chordcut/cwd/f.txt * Save Tty Collapse D |8: 2 2 == snap copied grid=120x31 cursor=10,9 @@ -32,30 +30,14 @@ |11: 5 lline 5 == snap cancelexec grid=120x31 cursor=25,8 |8: 2 2echo B''OO g.txt -== snap execafter grid=120x31 cursor=25,9 +== snap execafter grid=120x31 cursor=25,8 |3: f.txt ls |4: BOO f.txt g.txt -|7: Exec -|8: 1 line 1 -|9: 2 2echo B''OO g.txt -|10: 3 line 3 -|11: 4 line 4line -|12: 5 lline 5 -|13: 6 +|7: 1 line 1 Exec == snap cancellook grid=120x31 cursor=25,8 |7: 1 line 1 -|8: 2 2echo B''OO g.txt -|9: 3 line 3 -|10: 4 line 4line -|11: 5 lline 5 -|12: 6 -|13: == snap lookafter grid=120x31 cursor=7,13 -|7: Look -|8: 1 line 1 -|9: 2 2echo B''OO g.txt -|10: 3 line 3 -|11: 4 line 4line +|7: 1 line 1 Look |12: /tmp/pardes-snap/chordcut/cwd/g.txt Save Tty Collapse Del |13: 1 line 1 |14: 2 line 2 @@ -97,10 +79,6 @@ |14: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #616f64,#0d1410,b 7-12 #e5eee5,#0d1410, 13-59 d,#0d1410, 60-60 d,#608269, 61-61 d,#0d1410, 62-119 #e5eee5,#0d1410, == snap ttyprobe grid=120x31 cursor=42,22 |7: 1 line 1 -|8: 2 2echo B''OO g.txt -|9: 3 line 3 -|10: 4 line 4line -|11: 5 lline 5 |12: /tmp/pardes-snap/chordcut/cwd/g.txt * Save Tty Collapse D |17: $ /tmp/pardes-snap/chordcut/cwd Tty Save Mode Filter Collap |18: $ ls diff --git a/test/snapshots/collapse.golden b/test/snapshots/collapse.golden index d356fd02..18d24d6b 100644 --- a/test/snapshots/collapse.golden +++ b/test/snapshots/collapse.golden @@ -60,22 +60,19 @@ @23: 0-159 d,#486152,,body |24: @24: 0-159 d,#486152,,body -== snap middle-restored grid=160x25 cursor=7,4 -|3: Collapse -|4: 1 KEEP-FIRST -|5: 2 KEEP-SECOND -|6: 3 KEEP-THIRD +== snap middle-restored grid=160x25 cursor=7,3 +|3: 1 KEEP-FIRST Collapse +|4: 2 KEEP-SECOND +|5: 3 KEEP-THIRD == snap tab-collapsed grid=160x25 cursor=51,2 |3: |4: |5: -|6: == 9p tab-collapsed-cursor grid=160x25 cursor=51,2,bar == snap tab-restored grid=160x25 cursor=51,2 -|3: Collapse -|4: 1 KEEP-FIRST -|5: 2 KEEP-SECOND -|6: 3 KEEP-THIRD +|3: 1 KEEP-FIRST Collapse +|4: 2 KEEP-SECOND +|5: 3 KEEP-THIRD == file unchanged KEEP-FIRST KEEP-SECOND diff --git a/test/snapshots/exec.golden b/test/snapshots/exec.golden index 6ec18f46..2ddd7eec 100644 --- a/test/snapshots/exec.golden +++ b/test/snapshots/exec.golden @@ -1,10 +1,9 @@ -== snap exec grid=140x31 cursor=16,9 +== snap exec grid=140x31 cursor=16,8 |Newcol Joincol Find Grep Help Changelog Tutor Dump NextColor Debug Kill | New Tty Find Grep Joincol Delcol New Tty Find Grep Joincol Delcol | /tmp/pardes-snap/exec/cwd Tty Save Mode Filter Collapse Del /tmp/pardes-snap/exec/cwd Tty Save Mode Filter Collapse Del -| Exec ls -| ls e.txt -| e.txt +| ls Exec ls +| e.txt e.txt | | | @@ -16,29 +15,22 @@ | | | +| | /tmp/pardes-snap/exec/cwd Tty Save Mode Filter Collapse Del | ls | e.txt == snap kept grid=140x31 cursor=6,3 |3: ZZARG ls |4: ./c.sh e.txt -|5: -|8: echo MID''OK |9: -|10: -== snap chord grid=140x31 cursor=6,4 -|3: Exec ls -|4: ZZARG e.txt -|5: ./c.sh -|8: -|9: echo MID''OK -|10: CHORDARG:ZZARG +== snap chord grid=140x31 cursor=6,3 +|3: ZZARG Exec ls +|9: CHORDARG:ZZARG == snap deleted grid=140x31 cursor=4,5 |3: ls ls |4: e.txt e.txt -|5: +|8: |9: -|10: |17: |18: |19: diff --git a/test/snapshots/filewatch.golden b/test/snapshots/filewatch.golden index 6e535d45..74bce6f3 100644 --- a/test/snapshots/filewatch.golden +++ b/test/snapshots/filewatch.golden @@ -26,11 +26,11 @@ | 7 line 7 | 8 line 8 | 9 -== snap reloaded grid=210x31 cursor=15,4 +== snap reloaded grid=210x31 cursor=15,3 |2: /tmp/pardes-snap/filewatch/cwd/w.txt Save Tty Collapse Del /tmp/pardes-snap/filewatch/cwd Tty Save Mode Filter Collapse Del -|3: --:--:-- reloaded /tmp/pardes-snap/filewatch/cwd/w.txt ls -|4: 1 EXTERNAL sub w.txt -|5: 2 +|3: 1 EXTERNAL --:--:-- reloaded /tmp/pardes-snap/filewatch/cwd/w.txt ls +|4: 2 sub w.txt +|5: |6: |7: |8: w.txt @@ -41,10 +41,10 @@ |13: |14: |15: -== snap reloaded_sub grid=210x31 cursor=15,4 -|18: --:--:-- reloaded /tmp/pardes-snap/filewatch/cwd/sub/s.txt -|19: 1 RENAMED -|20: 2 +== snap reloaded_sub grid=210x31 cursor=15,3 +|18: 1 RENAMED --:--:-- reloaded /tmp/pardes-snap/filewatch/cwd/sub/s.txt +|19: 2 +|20: |21: |22: |23: @@ -67,5 +67,3 @@ |14: 12 line 12 |15: 13 |18: 1 RENAMED -|19: 2 -|20: diff --git a/test/snapshots/find.golden b/test/snapshots/find.golden index b076d419..8038c2b5 100644 --- a/test/snapshots/find.golden +++ b/test/snapshots/find.golden @@ -1,20 +1,16 @@ -== snap group grid=120x41 cursor=7,4 +== snap group grid=120x41 cursor=7,3 |Newcol Joincol Find Grep Help Changelog Tutor Dump NextColor Debug Kill | New Tty Find Grep Joincol Delcol | /tmp/pardes-snap/find/cwd/here.txt Save Tty Collapse Del -| SPC f -| 1 Find +| 1 Find SPC f == snap armed grid=120x41 cursor=119,4 -|3: Find +|3: 1 Find Find |4: Find / -|5: 1 Find == snap typing grid=120x41 cursor=119,3 -|3: Find /zqm -|4: 1 Find -|5: +|3: 1 Find Find /zqm +|4: == snap results grid=120x41 cursor=7,3 |3: 1 Find -|4: |37: /tmp/pardes-snap/find/cwd/+Search Save Tty Collapse Del |38: 1 sub/ZQMARK-beta.txt |39: 2 sub/nest/zqmark-gamma.txt @@ -22,9 +18,7 @@ == snap first grid=120x41 cursor=7,21 |20: /tmp/pardes-snap/find/cwd/sub/ZQMARK-beta.txt Save Tty Collapse Del |21: 1 beta body -|38: Look -|39: 1 sub/ZQMARK-beta.txt -|40: 2 sub/nest/zqmark-gamma.txt +|38: 1 sub/ZQMARK-beta.txt Look == style first grid=120x41 |0: 0-70 #b2c3b8,#1d2824, 71-119 d,#1d2824, |1: 0-1 #ffffff,#887455, 2-2 d,#26362d, 3-34 #becfc4,#26362d, 35-119 d,#26362d, @@ -64,41 +58,36 @@ |35: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-119 d,#0d1410, |36: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-119 d,#0d1410, |37: 0-1 #ffffff,#496656, 2-2 d,#1d2824, 3-28 #b2c3b8,#1d2824, 29-35 #d3b0d9,#1d2824, 36-57 #b2c3b8,#1d2824, 58-119 d,#1d2824, -|38: 0-0 d,#152019, 1-1 d,#0d1410, 2-115 d,#1d2824, 116-119 #b2c3b8,#1d2824, -|39: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-25 #e5eee5,#0d1410, 26-119 d,#0d1410, -|40: 0-0 d,#152019, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-31 #e5eee5,#0d1410, 32-119 d,#0d1410, +|38: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-25 #e5eee5,#0d1410, 26-113 d,#0d1410, 114-114 d,#1d2824, 115-118 #b2c3b8,#1d2824, 119-119 d,#1d2824, +|39: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-31 #e5eee5,#0d1410, 32-119 d,#0d1410, +|40: 0-0 d,#152019, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-22 #e5eee5,#0d1410, 23-119 d,#0d1410, == snap second grid=120x41 cursor=7,30 |29: /tmp/pardes-snap/find/cwd/sub/nest/zqmark-gamma.txt Save Tty Collapse Del |30: 1 gamma body == snap third grid=120x41 cursor=7,34 |33: /tmp/pardes-snap/find/cwd/zqmark-alpha.txt Save Tty Collapse Del |34: 1 alpha body +|38: 2 sub/nest/zqmark-gamma.txt Look +|39: 3 zqmark-alpha.txt +|40: 4 +== snap back grid=120x41 cursor=7,30 +|38: 1 sub/ZQMARK-beta.txt Look |39: 2 sub/nest/zqmark-gamma.txt |40: 3 zqmark-alpha.txt -== snap back grid=120x41 cursor=7,30 -|39: 1 sub/ZQMARK-beta.txt -|40: 2 sub/nest/zqmark-gamma.txt == snap word grid=120x41 cursor=7,30 -|3: Find +|3: 1 Find Find |4: Find / -|5: 1 Find |38: 1 sub/ZQMARK-beta.txt -|39: 2 sub/nest/zqmark-gamma.txt -|40: 3 zqmark-alpha.txt == snap cancel grid=120x41 cursor=7,39 -|3: Find / -|4: 1 Find -|5: -|30: Last -|31: 1 gamma body +|3: 1 Find Find / +|4: +|30: 1 gamma body Last == snap nomatch grid=120x41 cursor=7,39 |2: /tmp/pardes-snap/find/cwd/here.txt Save Tty Collapse Del Find / |3: 1 Find -|4: |18: /tmp/pardes-snap/find/cwd/+Search Save Tty Collapse Del |19: 1 |30: 1 gamma body -|31: |38: 2 sub/nest/zqmark-gamma.txt |39: 3 zqmark-alpha.txt |40: 4 diff --git a/test/snapshots/fsearch.golden b/test/snapshots/fsearch.golden index ccc25503..eba3237f 100644 --- a/test/snapshots/fsearch.golden +++ b/test/snapshots/fsearch.golden @@ -20,22 +20,9 @@ | ls | g.txt == snap typing grid=180x31 cursor=89,7 -|7: /MARK -|8: 1 l1 -|9: 2 MARK a -|10: 3 l3 -|11: 4 l4 -|12: 5 l5 -|13: 6 MARK b -|14: 7 l7 -|15: 8 l8 -|16: 9 l9 +|7: 1 l1 /MARK == snap results grid=180x31 cursor=10,8 |7: 1 l1 -|8: 2 MARK a -|9: 3 l3 -|10: 4 l4 -|11: 5 l5 |12: /tmp/pardes-snap/fsearch/cwd/+Search Save Tty Collapse Del LocationsConfig |13: 1 g.txt:2:1-4 |14: 2 MARK a diff --git a/test/snapshots/grep.golden b/test/snapshots/grep.golden index 8f498e05..a371bfb6 100644 --- a/test/snapshots/grep.golden +++ b/test/snapshots/grep.golden @@ -20,15 +20,9 @@ | ls | a.txt noise.txt sub == snap typing grid=180x31 cursor=89,7 -|7: Grep /TARGET -|8: 1 hello TARGET one -|9: 2 nothing here -|10: 3 last TARGET line +|7: 1 hello TARGET one Grep /TARGET == snap results grid=180x31 cursor=7,7 |7: 1 hello TARGET one -|8: 2 nothing here -|9: 3 last TARGET line -|10: |13: /tmp/pardes-snap/grep/cwd/+Search Save Tty Collapse Del LocationsConfig |14: 1 a.txt:1:7-12 hello TARGET one |15: 2 a.txt:3:6-11 last TARGET line diff --git a/test/snapshots/hscroll.golden b/test/snapshots/hscroll.golden index 407d0f82..6a932152 100644 --- a/test/snapshots/hscroll.golden +++ b/test/snapshots/hscroll.golden @@ -1,12 +1,12 @@ -== snap opened grid=90x31 cursor=6,8 +== snap opened grid=90x31 cursor=7,7 |Newcol Joincol Find Grep Help Changelog Tutor Dump NextColor Debug Kill | New Tty Find Grep Joincol Delcol New Tty Find Grep Joincol Delcol | /tmp/pardes-snap/hscroll/cwd Tty Save Mode /tmp/pardes-snap/hscroll/cwd Tty Save Mode -| ls ls +| ls Look ls | wide.txt wide.txt | -| -| wide.txt +| /tmp/pardes-snap/hscroll/cwd/wide.txt Save +| 1 short1 END_A_MARKER_WAY_OUT_RIGHT_padp | | | @@ -19,7 +19,12 @@ | /tmp/pardes-snap/hscroll/cwd Tty Save Mode | ls | wide.txt -== snap wheeled grid=90x31 cursor=6,8 -== snap clamped grid=90x31 cursor=6,8 -== snap dollar grid=90x31 cursor=3,3 -== snap zero grid=90x31 cursor=2,3 +== snap wheeled grid=90x31 cursor=7,7 +|3: ls ls +|7: 1 ND_A_MARKER_WAY_OUT_RIGHT_padpadpadpad +== snap clamped grid=90x31 cursor=7,7 +|7: 1 short1 END_A_MARKER_WAY_OUT_RIGHT_padp +== snap dollar grid=90x31 cursor=41,7 +|7: 1 padpadpadpadpadpadpadpadpadpad_TAIL +== snap zero grid=90x31 cursor=7,7 +|7: 1 short1 END_A_MARKER_WAY_OUT_RIGHT_padp diff --git a/test/snapshots/images.golden b/test/snapshots/images.golden index 95c56d9f..a1b78556 100644 --- a/test/snapshots/images.golden +++ b/test/snapshots/images.golden @@ -2,9 +2,9 @@ |Newcol Joincol Find Grep Help Changelog Tutor Dump NextColor Debug Kill | New Tty Find Grep Joincol Delcol New Tty Find Grep Joincol Delcol | /tmp/pardes-snap/images/cwd Tty Save Mode Filter Collapse Del /tmp/pardes-snap/images/cwd Tty Save Mode Filter Collapse Del -| Look ls -| ls pic.ppm -| pic.ppm +| ls Look ls +| pic.ppm pic.ppm +| | img petscii:off palette:commodore ascii:on /tmp/pardes-snap/images/cwd/p | 92@7%5Gm$D4▘🬵%🬨3'🬥🬆🬻 | 🬥3▖╱{=CY,â–Œ*)^M<▀🬎🬻 @@ -23,9 +23,9 @@ |0: 0-70 #b2c3b8,#1d2824, 71-149 d,#1d2824, |1: 0-1 #ffffff,#887455, 2-2 d,#26362d, 3-34 #becfc4,#26362d, 35-74 d,#26362d, 75-76 #ffffff,#887455, 77-77 d,#1d2824, 78-109 #b2c3b8,#1d2824, 110-149 d,#1d2824, |2: 0-1 #ffffff,#496656, 2-2 d,#1d2824, 3-30 #b2c3b8,#1d2824, 31-33 #d3b0d9,#1d2824, 34-63 #b2c3b8,#1d2824, 64-74 d,#1d2824, 75-76 #ffffff,#496656, 77-77 d,#1d2824, 78-105 #b2c3b8,#1d2824, 106-108 #d3b0d9,#1d2824, 109-138 #b2c3b8,#1d2824, 139-149 d,#1d2824, -|3: 0-0 d,#152019, 1-1 d,#0d1410, 2-70 d,#1d2824, 71-74 #b2c3b8,#1d2824, 75-75 d,#608269, 76-76 d,#0d1410, 77-149 #e5eee5,#0d1410, +|3: 0-0 d,#608269, 1-1 d,#0d1410, 2-68 #e5eee5,#0d1410, 69-69 d,#1d2824, 70-73 #b2c3b8,#1d2824, 74-74 d,#1d2824, 75-75 d,#608269, 76-76 d,#0d1410, 77-149 #e5eee5,#0d1410, |4: 0-0 d,#608269, 1-1 d,#0d1410, 2-74 #e5eee5,#0d1410, 75-75 d,#608269, 76-76 d,#0d1410, 77-149 #e5eee5,#0d1410, -|5: 0-0 d,#608269, 1-1 d,#0d1410, 2-74 #e5eee5,#0d1410, 75-75 d,#608269, 76-149 d,#0d1410, +|5: 0-0 d,#608269, 1-74 d,#0d1410, 75-75 d,#608269, 76-149 d,#0d1410, |6: 0-1 #000000,#add38a, 2-2 d,#26362d, 3-73 #becfc4,#26362d, 74-74 #dfbce5,#26362d, 75-75 d,#608269, 76-76 d,#0d1410, 77-149 #e5eee5,#0d1410, |7: 0-0 d,#152019, 1-27 d,#0d1410, 28-29 #959595,#6c6c6c, 30-30 #6c6c6c,#959595, 31-34 #959595,#6c6c6c, 35-35 #6c6c6c,#959595, 36-37 #959595,#6c6c6c, 38-38 #6c6c6c,#959595, 39-39 #959595,#6c6c6c, 40-40 #6c6c6c,#959595, 41-41 #959595,#6c6c6c, 42-42 #6c6c6c,#959595, 43-44 #959595,#6c6c6c, 45-45 #6c6c6c,#959595, 46-46 #959595,#6c5eb5, 47-47 #352879,#6c6c6c, 48-74 d,#0d1410, 75-75 d,#608269, 76-76 d,#0d1410, 77-149 #e5eee5,#0d1410, |8: 0-0 d,#152019, 1-27 d,#0d1410, 28-28 #6c6c6c,#959595, 29-29 #959595,#6c6c6c, 30-30 #6c6c6c,#959595, 31-34 #959595,#6c6c6c, 35-38 #6c6c6c,#959595, 39-42 #959595,#6c6c6c, 43-43 #6c6c6c,#959595, 44-44 #6c6c6c,#352879, 45-45 #352879,#959595, 46-47 #352879,#352879, 48-74 d,#0d1410, 75-75 d,#608269, 76-76 d,#0d1410, 77-149 #e5eee5,#0d1410, @@ -53,33 +53,30 @@ |30: 0-0 d,#608269, 1-1 d,#0d1410, 2-74 #e5eee5,#0d1410, 75-75 d,#608269, 76-76 d,#0d1410, 77-149 #e5eee5,#0d1410, == style term-palette grid=150x31 |3: 0-0 d,#608269, 1-1 d,#0d1410, 2-74 #e5eee5,#0d1410, 75-75 d,#608269, 76-76 d,#0d1410, 77-149 #e5eee5,#0d1410, -|5: 0-0 d,#608269, 1-74 d,#0d1410, 75-75 d,#608269, 76-149 d,#0d1410, |6: 0-1 #000000,#add38a, 2-2 d,#26362d, 3-72 #becfc4,#26362d, 73-74 #dfbce5,#26362d, 75-75 d,#608269, 76-76 d,#0d1410, 77-149 #e5eee5,#0d1410, -|7: 0-0 d,#152019, 1-1 d,#0d1410, 2-67 d,#1d2824, 68-74 #b2c3b8,#1d2824, 75-75 d,#608269, 76-76 d,#0d1410, 77-149 #e5eee5,#0d1410, -|8: 0-0 d,#152019, 1-28 d,#0d1410, 29-31 p8,p4, 32-33 p4,p8, 34-37 p8,p4, 38-38 p4,p8, 39-44 p8,p4, 45-45 p8,p12, 46-46 p12,p8, 47-74 d,#0d1410, 75-75 d,#608269, 76-76 d,#0d1410, 77-149 #e5eee5,#0d1410, -|9: 0-0 d,#152019, 1-28 d,#0d1410, 29-29 p8,p4, 30-30 p4,p8, 31-35 p8,p4, 36-36 p5,p8, 37-37 p8,p4, 38-38 p4,p8, 39-41 p8,p4, 42-42 p4,p8, 43-43 p8,p12, 44-45 p12,p8, 46-46 p12,p12, 47-74 d,#0d1410, 75-75 d,#608269, 76-76 d,#0d1410, 77-149 #e5eee5,#0d1410, -|10: 0-0 d,#152019, 1-28 d,#0d1410, 29-30 p8,p4, 31-32 p4,p8, 33-40 p8,p4, 41-41 p8,p12, 42-43 p12,p8, 44-46 p12,p12, 47-74 d,#0d1410, 75-75 d,#608269, 76-76 d,#0d1410, 77-149 #e5eee5,#0d1410, -|11: 0-0 d,#152019, 1-28 d,#0d1410, 29-31 p8,p4, 32-32 p4,p8, 33-34 p8,p4, 35-37 p4,p8, 38-38 p8,p4, 39-39 p8,p12, 40-41 p12,p8, 42-46 p12,p12, 47-74 d,#0d1410, 75-75 d,#608269, 76-76 d,#0d1410, 77-149 #e5eee5,#0d1410, -|12: 0-0 d,#152019, 1-28 d,#0d1410, 29-36 p8,p4, 37-37 p8,p12, 38-39 p12,p8, 40-46 p12,p12, 47-74 d,#0d1410, 75-75 d,#608269, 76-76 d,#0d1410, 77-149 #e5eee5,#0d1410, -|13: 0-0 d,#152019, 1-28 d,#0d1410, 29-30 p4,p8, 31-34 p8,p4, 35-35 p8,p12, 36-36 p12,p8, 37-46 p12,p12, 47-74 d,#0d1410, 75-75 d,#608269, 76-76 d,#0d1410, 77-149 #e5eee5,#0d1410, -|14: 0-0 d,#152019, 1-28 d,#0d1410, 29-29 p4,p8, 30-31 p8,p4, 32-32 p4,p8, 33-33 p8,p12, 34-35 p12,p8, 36-46 p12,p12, 47-74 d,#0d1410, 75-75 d,#608269, 76-76 d,#0d1410, 77-149 #e5eee5,#0d1410, -|15: 0-0 d,#152019, 1-28 d,#0d1410, 29-29 p4,p8, 30-30 p8,p4, 31-31 p8,p12, 32-32 p12,p8, 33-46 p12,p12, 47-74 d,#0d1410, 75-75 d,#608269, 76-76 d,#0d1410, 77-149 #e5eee5,#0d1410, -|16: 0-0 d,#152019, 1-28 d,#0d1410, 29-29 p8,p12, 30-30 p12,p8, 31-46 p12,p12, 47-74 d,#0d1410, 75-75 d,#608269, 76-76 d,#0d1410, 77-149 #e5eee5,#0d1410, +|7: 0-0 d,#152019, 1-27 d,#0d1410, 28-28 p8,p5, 29-30 p8,p4, 31-31 p4,p8, 32-35 p8,p4, 36-37 p4,p8, 38-39 p8,p4, 40-40 p4,p8, 41-42 p8,p4, 43-43 p4,p8, 44-46 p8,p4, 47-47 p12,p8, 48-65 d,#0d1410, 66-66 d,#1d2824, 67-73 #b2c3b8,#1d2824, 74-74 d,#1d2824, 75-75 d,#608269, 76-76 d,#0d1410, 77-149 #e5eee5,#0d1410, +|8: 0-0 d,#152019, 1-27 d,#0d1410, 28-30 p8,p4, 31-33 p4,p8, 34-34 p8,p4, 35-36 p4,p8, 37-37 p8,p4, 38-41 p4,p8, 42-42 p8,p4, 43-43 p4,p8, 44-44 p8,p12, 45-46 p12,p8, 47-47 p12,p12, 48-74 d,#0d1410, 75-75 d,#608269, 76-76 d,#0d1410, 77-149 #e5eee5,#0d1410, +|9: 0-0 d,#152019, 1-27 d,#0d1410, 28-28 p8,p4, 29-29 p4,p8, 30-30 p8,p4, 31-31 p4,p8, 32-32 p8,p4, 33-33 p4,p8, 34-35 p8,p4, 36-37 p4,p8, 38-38 p8,p5, 39-41 p8,p4, 42-42 p4,p8, 43-44 p12,p8, 45-47 p12,p12, 48-74 d,#0d1410, 75-75 d,#608269, 76-76 d,#0d1410, 77-149 #e5eee5,#0d1410, +|10: 0-0 d,#152019, 1-27 d,#0d1410, 28-29 p8,p4, 30-34 p4,p8, 35-36 p8,p4, 37-38 p4,p8, 39-39 p8,p4, 40-40 p4,p8, 41-41 p12,p8, 42-47 p12,p12, 48-74 d,#0d1410, 75-75 d,#608269, 76-76 d,#0d1410, 77-149 #e5eee5,#0d1410, +|11: 0-0 d,#152019, 1-27 d,#0d1410, 28-28 p4,p8, 29-29 p8,p4, 30-31 p4,p8, 32-32 p8,p4, 33-33 p4,p8, 34-34 p8,p4, 35-36 p4,p8, 37-37 p8,p4, 38-38 p8,p12, 39-39 p12,p8, 40-47 p12,p12, 48-74 d,#0d1410, 75-75 d,#608269, 76-76 d,#0d1410, 77-149 #e5eee5,#0d1410, +|12: 0-0 d,#152019, 1-27 d,#0d1410, 28-28 p8,p4, 29-31 p4,p8, 32-35 p8,p4, 36-36 p4,p8, 37-37 p12,p8, 38-47 p12,p12, 48-74 d,#0d1410, 75-75 d,#608269, 76-76 d,#0d1410, 77-149 #e5eee5,#0d1410, +|13: 0-0 d,#152019, 1-27 d,#0d1410, 28-32 p8,p4, 33-33 p4,p8, 34-34 p8,p12, 35-36 p12,p8, 37-47 p12,p12, 48-74 d,#0d1410, 75-75 d,#608269, 76-76 d,#0d1410, 77-149 #e5eee5,#0d1410, +|14: 0-0 d,#152019, 1-27 d,#0d1410, 28-28 p8,p4, 29-29 p4,p8, 30-30 p8,p4, 31-32 p4,p8, 33-33 p12,p8, 34-34 p8,p12, 35-47 p12,p12, 48-74 d,#0d1410, 75-75 d,#608269, 76-76 d,#0d1410, 77-149 #e5eee5,#0d1410, +|15: 0-0 d,#152019, 1-27 d,#0d1410, 28-29 p4,p8, 30-30 p8,p12, 31-32 p12,p8, 33-47 p12,p12, 48-74 d,#0d1410, 75-75 d,#608269, 76-76 d,#0d1410, 77-149 #e5eee5,#0d1410, +|16: 0-0 d,#152019, 1-27 d,#0d1410, 28-28 p8,p12, 29-29 p12,p8, 30-47 p12,p12, 48-74 d,#0d1410, 75-75 d,#608269, 76-76 d,#0d1410, 77-149 #e5eee5,#0d1410, == snap no-ascii grid=150x31 cursor=11,8 |3: ls ls -|4: pic.ppm pic.ppm -|5: |6: img petscii:off palette:terminal ascii:off /tmp/pardes-snap/images/cwd/p -|7: Ascii -|8: â–ˆðŸ¬�█╲███▙🬸🬬🬻█████ðŸ¬�🬵 -|9: ███████🬻██🬸█ðŸ¬�â–ˆðŸ¬�â–„â–ˆ -|10: ████████████ðŸ¬�â–„â–ˆ -|11: ███🬸██████ðŸ¬�â–„â–ˆ -|12: ████████ðŸ¬�🬵█ -|13: ╱█████ðŸ¬�â–„ -|14: █🬬█╲ðŸ¬�🬵█ -|15: 🬺█ðŸ¬�🬵 -|16: ðŸ¬�â–„ +|7: ███╱█🬻██🬺██🬻███╱██🬴▄ Ascii +|8: 🬬██╱███╱🬻ðŸ¬�🬻🬬████ðŸ¬�🬵█ +|9: █╲█🬴████╲╱█ðŸ¬�██▟▄█ +|10: ██╲╱╲█ðŸ¬�█████╱🬵 +|11: ╱█████████ðŸ¬�â–„ +|12: █│█████ðŸ¬�ðŸ¬�🬹 +|13: ██████ðŸ¬�â–„â–ˆ +|14: 🬜🬬██🬸▄╲ +|15: 🬺█ðŸ¬�🬵█ +|16: ðŸ¬�â–„ == snap tag-edit grid=400x31 cursor=87,6 |Newcol Joincol Find Grep Help Changelog Tutor Dump NextColor Debug Kill | New Tty Find Grep Joincol Delcol New Tty Find Grep Joincol Delcol diff --git a/test/snapshots/jumps.golden b/test/snapshots/jumps.golden index 9800ca4c..8d4dc36e 100644 --- a/test/snapshots/jumps.golden +++ b/test/snapshots/jumps.golden @@ -36,9 +36,7 @@ |3: 1 line 1 ls |4: 2 line 2 big.txt == snap to-file grid=150x31 cursor=7,3 -|3: 1 line 1 Left -|4: 2 line 2 ls -|5: 3 line 3 big.txt +|3: 1 line 1 ls Left == snap goto-100 grid=150x31 cursor=7,27 |3: 76 line 76 ls |4: 77 line 77 big.txt @@ -68,40 +66,10 @@ |28: 101 line 101 |29: 102 line 102 |30: 103 line 103 -== snap back-in-file grid=150x31 cursor=7,4 -|3: Back ls -|4: 1 line 1 big.txt -|5: 2 line 2 -|6: 3 line 3 -|7: 4 line 4 -|8: 5 line 5 -|9: 6 line 6 -|10: 7 line 7 -|11: 8 line 8 -|12: 9 line 9 -|13: 10 line 10 -|14: 11 line 11 -|15: 12 line 12 -|16: 13 line 13 -|17: 14 line 14 -|18: 15 line 15 -|19: 16 line 16 -|20: 17 line 17 -|21: 18 line 18 -|22: 19 line 19 -|23: 20 line 20 -|24: 21 line 21 -|25: 22 line 22 -|26: 23 line 23 -|27: 24 line 24 -|28: 25 line 25 -|29: 26 line 26 -|30: 27 line 27 -== snap back-to-shell grid=150x31 cursor=79,5 -== snap forward-file grid=150x31 cursor=7,3 -|3: 1 line 1 Forward -|4: 2 line 2 ls -|5: 3 line 3 big.txt +== snap back-in-file grid=150x31 cursor=7,3 +|3: 1 line 1 Back ls +|4: 2 line 2 big.txt +|5: 3 line 3 |6: 4 line 4 |7: 5 line 5 |8: 6 line 6 @@ -127,41 +95,13 @@ |28: 26 line 26 |29: 27 line 27 |30: 28 line 28 -== snap forward-100 grid=150x31 cursor=7,18 -|3: Forward ls -|4: 86 line 86 big.txt -|5: 87 line 87 -|6: 88 line 88 -|7: 89 line 89 -|8: 90 line 90 -|9: 91 line 91 -|10: 92 line 92 -|11: 93 line 93 -|12: 94 line 94 -|13: 95 line 95 -|14: 96 line 96 -|15: 97 line 97 -|16: 98 line 98 -|17: 99 line 99 -|18: 100 line 100 -|19: 101 line 101 -|20: 102 line 102 -|21: 103 line 103 -|22: 104 line 104 -|23: 105 line 105 -|24: 106 line 106 -|25: 107 line 107 -|26: 108 line 108 -|27: 109 line 109 -|28: 110 line 110 -|29: 111 line 111 -|30: 112 line 112 -== snap last grid=150x31 cursor=79,5 -|3: Last ls -== snap last-back grid=150x31 cursor=7,17 -|3: 86 line 86 Last -|4: 87 line 87 ls -|5: 88 line 88 big.txt +== snap back-to-shell grid=150x31 cursor=79,5 +== snap forward-file grid=150x31 cursor=7,3 +|3: 1 line 1 ls Forward +== snap forward-100 grid=150x31 cursor=7,17 +|3: 86 line 86 Forward ls +|4: 87 line 87 big.txt +|5: 88 line 88 |6: 89 line 89 |7: 90 line 90 |8: 91 line 91 @@ -187,30 +127,12 @@ |28: 111 line 111 |29: 112 line 112 |30: 113 line 113 -== snap jumplist grid=150x31 cursor=7,18 -|3: Jumplist ls -|4: 86 line 86 big.txt -|5: 87 line 87 -|6: 88 line 88 -|7: 89 line 89 -|8: 90 line 90 -|9: 91 line 91 -|10: 92 line 92 -|11: 93 line 93 -|12: 94 line 94 -|13: 95 line 95 -|14: 96 line 96 -|15: 97 line 97 -|16: 98 line 98 -|17: 99 line 99 -|18: 100 line 100 -|19: 101 line 101 -|20: 102 line 102 -|21: 103 line 103 -|22: 104 line 104 -|23: 105 line 105 -|24: 106 line 106 -|25: 107 line 107 +== snap last grid=150x31 cursor=79,5 +|3: 86 line 86 Last ls +== snap last-back grid=150x31 cursor=7,17 +|3: 86 line 86 ls Last +== snap jumplist grid=150x31 cursor=7,17 +|3: 86 line 86 Jumplist ls |26: /tmp/pardes-snap/jumps/cwd/+Jumps Save Tty Collapse Del LocationsConfig |27: 1 @p1:3:3 /tmp/pardes-snap/jumps/cwd |28: 2 /tmp/pardes-snap/jumps/cwd/big.txt:1:1 line 1 @@ -218,32 +140,7 @@ |30: 4 /tmp/pardes-snap/jumps/cwd/big.txt:100:1 line 100 == snap step1-shell grid=150x31 cursor=79,5 |3: 86 line 86 ls -|4: 87 line 87 big.txt -|5: 88 line 88 -|6: 89 line 89 -|7: 90 line 90 -|8: 91 line 91 -|9: 92 line 92 -|10: 93 line 93 -|11: 94 line 94 -|12: 95 line 95 -|13: 96 line 96 -|14: 97 line 97 -|15: 98 line 98 -|16: 99 line 99 -|17: 100 line 100 -|18: 101 line 101 -|19: 102 line 102 -|20: 103 line 103 -|21: 104 line 104 -|22: 105 line 105 -|23: 106 line 106 -|24: 107 line 107 -|25: 108 line 108 -|27: Look -|28: 1 @p1:3:3 /tmp/pardes-snap/jumps/cwd -|29: 2 /tmp/pardes-snap/jumps/cwd/big.txt:1:1 line 1 -|30: 3 @p1:3:3 /tmp/pardes-snap/jumps/cwd +|27: 1 @p1:3:3 /tmp/pardes-snap/jumps/cwd Look == style step1-shell grid=150x31 |0: 0-70 #b2c3b8,#1d2824, 71-149 d,#1d2824, |1: 0-1 #ffffff,#887455, 2-2 d,#1d2824, 3-34 #b2c3b8,#1d2824, 35-74 d,#1d2824, 75-76 #ffffff,#887455, 77-77 d,#26362d, 78-109 #becfc4,#26362d, 110-149 d,#26362d, @@ -272,10 +169,10 @@ |24: 0-0 d,#152019, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-14 #e5eee5,#0d1410, 15-74 d,#0d1410, 75-75 d,#608269, 76-76 d,#0d1410, 77-149 #e5eee5,#0d1410, |25: 0-0 d,#152019, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-14 #e5eee5,#0d1410, 15-74 d,#0d1410, 75-75 d,#608269, 76-76 d,#0d1410, 77-149 #e5eee5,#0d1410, |26: 0-1 #ffffff,#496656, 2-2 d,#1d2824, 3-29 #b2c3b8,#1d2824, 30-35 #d3b0d9,#1d2824, 36-73 #b2c3b8,#1d2824, 74-74 d,#1d2824, 75-75 d,#608269, 76-76 d,#0d1410, 77-149 #e5eee5,#0d1410, -|27: 0-0 d,#152019, 1-1 d,#0d1410, 2-70 d,#1d2824, 71-74 #b2c3b8,#1d2824, 75-75 d,#608269, 76-76 d,#0d1410, 77-149 #e5eee5,#0d1410, -|28: 0-0 d,#608269, 1-1 d,#0d1410, 2-13 #59675c,#0d1410, 14-40 #e5eee5,#0d1410, 41-74 d,#0d1410, 75-75 d,#608269, 76-76 d,#0d1410, 77-149 #e5eee5,#0d1410, -|29: 0-0 d,#608269, 1-1 d,#0d1410, 2-44 #59675c,#0d1410, 45-51 #e5eee5,#0d1410, 52-74 d,#0d1410, 75-75 d,#608269, 76-76 d,#0d1410, 77-149 #e5eee5,#0d1410, -|30: 0-0 d,#152019, 1-1 d,#0d1410, 2-13 #59675c,#0d1410, 14-40 #e5eee5,#0d1410, 41-74 d,#0d1410, 75-75 d,#608269, 76-76 d,#0d1410, 77-149 #e5eee5,#0d1410, +|27: 0-0 d,#608269, 1-1 d,#0d1410, 2-13 #59675c,#0d1410, 14-40 #e5eee5,#0d1410, 41-68 d,#0d1410, 69-69 d,#1d2824, 70-73 #b2c3b8,#1d2824, 74-74 d,#1d2824, 75-75 d,#608269, 76-76 d,#0d1410, 77-149 #e5eee5,#0d1410, +|28: 0-0 d,#608269, 1-1 d,#0d1410, 2-44 #59675c,#0d1410, 45-51 #e5eee5,#0d1410, 52-74 d,#0d1410, 75-75 d,#608269, 76-76 d,#0d1410, 77-149 #e5eee5,#0d1410, +|29: 0-0 d,#608269, 1-1 d,#0d1410, 2-13 #59675c,#0d1410, 14-40 #e5eee5,#0d1410, 41-74 d,#0d1410, 75-75 d,#608269, 76-76 d,#0d1410, 77-149 #e5eee5,#0d1410, +|30: 0-0 d,#152019, 1-1 d,#0d1410, 2-46 #59675c,#0d1410, 47-55 #e5eee5,#0d1410, 56-74 d,#0d1410, 75-75 d,#608269, 76-76 d,#0d1410, 77-149 #e5eee5,#0d1410, == snap step2-file grid=150x31 cursor=7,3 |3: 1 line 1 ls |4: 2 line 2 big.txt @@ -324,10 +221,9 @@ |23: 109 line 109 |24: 110 line 110 |25: 111 line 111 -|28: 2 /tmp/pardes-snap/jumps/cwd/big.txt:1:1 line 1 -|29: 3 @p1:3:3 /tmp/pardes-snap/jumps/cwd -|30: 4 /tmp/pardes-snap/jumps/cwd/big.txt:100:1 line 100 +|27: 2 /tmp/pardes-snap/jumps/cwd/big.txt:1:1 line 1 Look +|28: 3 @p1:3:3 /tmp/pardes-snap/jumps/cwd +|29: 4 /tmp/pardes-snap/jumps/cwd/big.txt:100:1 line 100 +|30: 5 == snap step-back grid=150x31 cursor=79,5 -== snap look-row grid=150x31 cursor=79,5 -|5: 91 line 91 ls -|6: 92 line 92 big.txt +== snap look-row grid=150x31 cursor=7,14 diff --git a/test/snapshots/layout-open.golden b/test/snapshots/layout-open.golden index 47eea036..d5783a9a 100644 --- a/test/snapshots/layout-open.golden +++ b/test/snapshots/layout-open.golden @@ -28,9 +28,7 @@ |7: ls ls |8: sub sub == snap file-open grid=100x31 cursor=7,22 -|18: Look -|19: ls -|20: sub +|18: ls Look |21: /tmp/pardes-snap/layout-open/cwd/sub/f.txt Save |22: 1 echo 'TTY'OK == snap ttydir grid=100x31 cursor=7,22 @@ -38,5 +36,3 @@ |11: echo 'TTY'OK |12: TTYOK |18: ls -|19: sub -|20: diff --git a/test/snapshots/leader.golden b/test/snapshots/leader.golden index 81d9e3cb..3be0846b 100644 --- a/test/snapshots/leader.golden +++ b/test/snapshots/leader.golden @@ -1,14 +1,12 @@ -== snap spc grid=100x41 cursor=7,4 +== snap spc grid=100x41 cursor=7,3 |Newcol Joincol Find Grep Help Changelog Tutor Dump NextColor Debug Kill | New Tty Find Grep Joincol Delcol | /tmp/pardes-snap/leader/cwd/cmds.txt Save Tty Collapse Del -| SPC -| 1 Help -== snap spc-h grid=100x41 cursor=7,4 -|3: SPC h +| 1 Help SPC +== snap spc-h grid=100x41 cursor=7,3 +|3: 1 Help SPC h == snap abandoned grid=100x41 cursor=7,3 |3: 1 Help -|4: == snap unmapped grid=100x41 cursor=7,3 == snap help-group grid=100x41 cursor=7,23 |22: /tmp/pardes-snap/leader/cwd/+Help Save Tty Collapse Del @@ -29,13 +27,7 @@ |19: 7 Press j until you reach the introduction. |20: 8 |21: 9 -|23: Tutor -|24: 1 pardes builtins under SPC h -|25: 2 -|26: 3 SPC h c Changelog topbar -|27: 4 SPC h m Messages -|28: 5 SPC h t Tutor topbar -|29: 6 +|23: 1 pardes builtins under SPC h Tutor == snap deleted grid=100x41 cursor=7,23 |12: |13: @@ -48,12 +40,6 @@ |20: |21: |23: 1 pardes builtins under SPC h -|24: 2 -|25: 3 SPC h c Changelog topbar -|26: 4 SPC h m Messages -|27: 5 SPC h t Tutor topbar -|28: 6 -|29: == snap help-window grid=100x41 cursor=7,23 |23: 1 pardes builtins under SPC w |25: 3 SPC w h Left C-w h, C-w left diff --git a/test/snapshots/look-center.golden b/test/snapshots/look-center.golden index e13a7886..c876f58c 100644 --- a/test/snapshots/look-center.golden +++ b/test/snapshots/look-center.golden @@ -2,9 +2,9 @@ |Newcol Joincol Find Grep Help Changelog Tutor Dump NextColor Debug Kill | New Tty Find Grep Joincol Delcol New Tty Find Grep Joincol Delcol | /tmp/pardes-snap/look-center/cwd Tty Save Mode Filter Collapse Del /tmp/pardes-snap/look-center/cwd Tty Save Mode Filter Collapse Del -| Look ls -| ls big.txt -| big.txt +| ls Look ls +| big.txt big.txt +| | /tmp/pardes-snap/look-center/cwd/big.txt Save Tty Collapse Del | 95 line 95 | 96 line 96 @@ -20,12 +20,10 @@ | ls | big.txt == snap center-dedup grid=150x31 cursor=7,12 -|3: ls Look -|4: big.txt ls -|5: big.txt +|3: ls ls Look |7: 145 line 145 -|8: 146 line 146 -|9: 147 line 147 big.txt:150 big.txt:2 +|8: 146 line 146 big.txt:150 big.txt:2 +|9: 147 line 147 |10: 148 line 148 |11: 149 line 149 |12: 150 line 150 @@ -33,9 +31,14 @@ |14: 152 line 152 |15: 153 line 153 |16: 154 line 154 -== snap center-clamp grid=150x31 cursor=93,7 -|3: ls ls -|4: big.txt big.txt -|5: -|8: 146 line 146 big.txt:150 big.txt:2 -|9: 147 line 147 +== snap center-clamp grid=150x31 cursor=7,8 +|7: 1 line 1 +|8: 2 line 2 big.txt:150 big.txt:2 +|9: 3 line 3 +|10: 4 line 4 +|11: 5 line 5 +|12: 6 line 6 +|13: 7 line 7 +|14: 8 line 8 +|15: 9 line 9 +|16: 10 line 10 diff --git a/test/snapshots/look-dir.golden b/test/snapshots/look-dir.golden index 8f90d604..5301223e 100644 --- a/test/snapshots/look-dir.golden +++ b/test/snapshots/look-dir.golden @@ -2,9 +2,9 @@ |Newcol Joincol Find Grep Help Changelog Tutor Dump NextColor Debug Kill | New Tty Find Grep Joincol Delcol New Tty Find Grep Joincol Delcol | /tmp/pardes-snap/look-dir/cwd Tty Save Mode Fil /tmp/pardes-snap/look-dir/cwd Tty Save Mode Fil -| Look ls -| ls sub top.txt -| sub top.txt +| ls Look ls +| sub top.txt sub top.txt +| | /tmp/pardes-snap/look-dir/cwd/sub Tty Save Mode | ls | inner.txt diff --git a/test/snapshots/look-file-1col.golden b/test/snapshots/look-file-1col.golden index abe1fcbb..1a5ee5ce 100644 --- a/test/snapshots/look-file-1col.golden +++ b/test/snapshots/look-file-1col.golden @@ -2,9 +2,9 @@ |Newcol Joincol Find Grep Help Changelog Tutor Dump NextColor Debug Kill | New Tty Find Grep Joincol Delcol | /tmp/pardes-snap/look-file-1col/cwd Tty Save Mode Filter Collapse Del -| Look -| ls +| ls Look | big.txt +| | /tmp/pardes-snap/look-file-1col/cwd/big.txt Save Tty Collapse Del | 28 line 28 | 29 line 29 diff --git a/test/snapshots/look-file.golden b/test/snapshots/look-file.golden index 13919c3d..de8225a3 100644 --- a/test/snapshots/look-file.golden +++ b/test/snapshots/look-file.golden @@ -2,9 +2,9 @@ |Newcol Joincol Find Grep Help Changelog Tutor Dump NextColor Debug Kill | New Tty Find Grep Joincol Delcol New Tty Find Grep Joincol Delcol | /tmp/pardes-snap/look-file/cwd Tty Save Mode Filter Collapse Del /tmp/pardes-snap/look-file/cwd Tty Save Mode Filter Collapse Del -| Look ls -| ls big.txt -| big.txt +| ls Look ls +| big.txt big.txt +| | /tmp/pardes-snap/look-file/cwd/big.txt Save Tty Collapse Del | 35 line 35 | 36 line 36 @@ -23,9 +23,9 @@ |0: 0-70 #b2c3b8,#1d2824, 71-149 d,#1d2824, |1: 0-1 #ffffff,#887455, 2-2 d,#26362d, 3-34 #becfc4,#26362d, 35-74 d,#26362d, 75-76 #ffffff,#887455, 77-77 d,#1d2824, 78-109 #b2c3b8,#1d2824, 110-149 d,#1d2824, |2: 0-1 #ffffff,#496656, 2-2 d,#1d2824, 3-33 #b2c3b8,#1d2824, 34-36 #d3b0d9,#1d2824, 37-66 #b2c3b8,#1d2824, 67-74 d,#1d2824, 75-76 #ffffff,#496656, 77-77 d,#1d2824, 78-108 #b2c3b8,#1d2824, 109-111 #d3b0d9,#1d2824, 112-141 #b2c3b8,#1d2824, 142-149 d,#1d2824, -|3: 0-0 d,#152019, 1-1 d,#0d1410, 2-70 d,#1d2824, 71-74 #b2c3b8,#1d2824, 75-75 d,#608269, 76-76 d,#0d1410, 77-149 #e5eee5,#0d1410, +|3: 0-0 d,#608269, 1-1 d,#0d1410, 2-68 #e5eee5,#0d1410, 69-69 d,#1d2824, 70-73 #b2c3b8,#1d2824, 74-74 d,#1d2824, 75-75 d,#608269, 76-76 d,#0d1410, 77-149 #e5eee5,#0d1410, |4: 0-0 d,#608269, 1-1 d,#0d1410, 2-74 #e5eee5,#0d1410, 75-75 d,#608269, 76-76 d,#0d1410, 77-149 #e5eee5,#0d1410, -|5: 0-0 d,#608269, 1-1 d,#0d1410, 2-74 #e5eee5,#0d1410, 75-75 d,#608269, 76-149 d,#0d1410, +|5: 0-0 d,#608269, 1-74 d,#0d1410, 75-75 d,#608269, 76-149 d,#0d1410, |6: 0-1 #000000,#add38a, 2-2 d,#26362d, 3-33 #becfc4,#26362d, 34-40 #dfbce5,#26362d, 41-62 #becfc4,#26362d, 63-74 d,#26362d, 75-75 d,#608269, 76-76 d,#0d1410, 77-149 #e5eee5,#0d1410, |7: 0-0 d,#152019, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-13 #e5eee5,#0d1410, 14-74 d,#0d1410, 75-75 d,#608269, 76-76 d,#0d1410, 77-149 #e5eee5,#0d1410, |8: 0-0 d,#152019, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-13 #e5eee5,#0d1410, 14-74 d,#0d1410, 75-75 d,#608269, 76-76 d,#0d1410, 77-149 #e5eee5,#0d1410, diff --git a/test/snapshots/lookloaded.golden b/test/snapshots/lookloaded.golden index a55151f4..a9e08392 100644 --- a/test/snapshots/lookloaded.golden +++ b/test/snapshots/lookloaded.golden @@ -2,9 +2,9 @@ |Newcol Joincol Find Grep Help Changelog Tutor Dump NextColor Debug Kill | New Tty Find Grep Joincol Delcol New Tty Find Grep Joincol Delcol | /tmp/pardes-snap/lookloaded/cwd Tty Save Mode F /tmp/pardes-snap/lookloaded/cwd Tty Save Mode F -| Look ls -| ls big.txt -| big.txt +| ls Look ls +| big.txt big.txt +| | /tmp/pardes-snap/lookloaded/cwd/big.txt Save Tt | 35 line 35 | 36 line 36 @@ -21,17 +21,13 @@ | big.txt == snap removed grid=100x31 cursor=54,7 |3: ls ls -|4: big.txt big.txt |5: rm big.txt; echo GO''NE |6: /tmp/pardes-snap/lookloaded/cwd/big.txt Save Tt GONE == snap look-noFS grid=100x31 cursor=7,12 -|3: ls Look -|4: big.txt ls -|5: big.txt -|6: /tmp/pardes-snap/lookloaded/cwd/big.txt Save Tt rm big.txt; echo GO''NE -|7: 5 line 5 GONE -|8: 6 line 6 -|9: 7 line 7 big.txt:10 +|3: ls ls Look +|7: 5 line 5 +|8: 6 line 6 big.txt:10 +|9: 7 line 7 |10: 8 line 8 |11: 9 line 9 |12: 10 line 10 diff --git a/test/snapshots/lsp-client-edit.golden b/test/snapshots/lsp-client-edit.golden index 54c6e083..18138dd7 100644 --- a/test/snapshots/lsp-client-edit.golden +++ b/test/snapshots/lsp-client-edit.golden @@ -1,9 +1,8 @@ -== snap formatted grid=100x25 cursor=7,5 +== snap formatted grid=100x25 cursor=7,4 |Newcol Joincol Find Grep Help Changelog Tutor Dump NextColor Debug Kill | New Tty Find Grep Joincol Delcol | /tmp/pardes-snap/lsp-client-edit/cwd/main.rs * Save Tty Collapse Del TreeContext -| formatted 1 range(s) -| 1 // formatted by mock +| 1 // formatted by mock formatted 1 range(s) | 2 mod lib; | 3 | 4 fn main() { @@ -22,24 +21,11 @@ |9: 7 } |10: 8 |11: -|12: -== snap renamed grid=100x25 cursor=12,6 -|3: renamed 2 range(s) -|4: 1 mod lib; -|5: 2 -|6: 3 fn main() { -|7: 4 let x = sum(1, 2); -|8: 5 let y = sum(3, 4); -|9: 6 let _ = x + y; -|10: 7 } -|11: 8 +== snap renamed grid=100x25 cursor=12,5 +|3: 1 mod lib; renamed 2 range(s) +|6: 4 let x = sum(1, 2); +|7: 5 let y = sum(3, 4); == snap unrenamed grid=100x25 cursor=12,5 |3: 1 mod lib; -|4: 2 -|5: 3 fn main() { |6: 4 let x = add(1, 2); |7: 5 let y = add(3, 4); -|8: 6 let _ = x + y; -|9: 7 } -|10: 8 -|11: diff --git a/test/snapshots/lsp-client.golden b/test/snapshots/lsp-client.golden index 6d4a0c0f..52a91d61 100644 --- a/test/snapshots/lsp-client.golden +++ b/test/snapshots/lsp-client.golden @@ -2,8 +2,7 @@ |Newcol Joincol Find Grep Help Changelog Tutor Dump NextColor Debug Kill | New Tty Find Grep Joincol Delcol | /tmp/pardes-snap/lsp-client/cwd/main.rs Save Tty Collapse Del TreeContext -| --:--:-- lsp rust-analyzer: ready -| 1 mod lib; +| 1 mod lib; --:--:-- lsp rust-analyzer: ready | 2 | 3 fn main() { | 4 let x = add(1, 2); @@ -13,6 +12,7 @@ | 8 | | +| | /tmp/pardes-snap/lsp-client/cwd/lib.rs Save Tty Collapse Del TreeContext | 1 // mock fixture | 2 pub fn add(a: i32, b: i32) -> i32 { @@ -21,25 +21,18 @@ | 5 == snap gr-list grid=100x25 cursor=21,6 |3: 1 mod lib; -|4: 2 -|5: 3 fn main() { -|6: 4 let x = add(1, 2); -|7: 5 let y = add(3, 4); -|8: 6 let _ = x + y; -|9: 7 } -|10: 8 -|11: |20: /tmp/pardes-snap/lsp-client/cwd/+Search Save Tty Collapse Del LocationsConfig |21: 1 lib.rs:2:8-10 |22: 2 pub fn add(a: i32, b: i32) -> i32 { |23: 3 main.rs:4:13-15 |24: 4 let x = add(1, 2); == snap gr-opened grid=100x25 cursor=21,7 -|21: Look +|21: 3 main.rs:4:13-15 Look +|22: 4 let x = add(1, 2); +|23: 5 main.rs:5:13-15 +|24: 6 let y = add(3, 4); +== snap gr-back grid=100x25 cursor=21,6 +|21: 2 pub fn add(a: i32, b: i32) -> i32 { Look |22: 3 main.rs:4:13-15 |23: 4 let x = add(1, 2); |24: 5 main.rs:5:13-15 -== snap gr-back grid=100x25 cursor=21,6 -|22: 2 pub fn add(a: i32, b: i32) -> i32 { -|23: 3 main.rs:4:13-15 -|24: 4 let x = add(1, 2); diff --git a/test/snapshots/lsp-rename.golden b/test/snapshots/lsp-rename.golden index d18e6566..75d87879 100644 --- a/test/snapshots/lsp-rename.golden +++ b/test/snapshots/lsp-rename.golden @@ -1,9 +1,8 @@ -== snap renamed grid=110x25 cursor=17,11 +== snap renamed grid=110x25 cursor=17,10 |Newcol Joincol Find Grep Help Changelog Tutor Dump NextColor Debug Kill | New Tty Find Grep Joincol Delcol | /tmp/pardes-snap/lsp-rename/cwd/rename.zig * Save Tty Collapse Del TreeContext -| renamed 2 range(s) -| 1 const std = @import("std"); +| 1 const std = @import("std"); renamed 2 range(s) | 2 | 3 fn renamed_helper(x: u32) u32 { | 4 return x + 1; @@ -20,21 +19,8 @@ | 15 == snap undone grid=110x25 cursor=17,10 |3: 1 const std = @import("std"); -|4: 2 |5: 3 fn helper(x: u32) u32 { -|6: 4 return x + 1; -|7: 5 } -|8: 6 -|9: 7 pub fn main() void { |10: 8 _ = helper(41); -|11: 9 } -|12: 10 -|13: 11 fn shadowed() void { -|14: 12 const helper: u32 = 7; -|15: 13 _ = helper; -|16: 14 } -|17: 15 -|18: == snap redone grid=110x25 cursor=17,10 |5: 3 fn renamed_helper(x: u32) u32 { |10: 8 _ = renamed_helper(41); diff --git a/test/snapshots/lsp.golden b/test/snapshots/lsp.golden index 7baf7716..34078a38 100644 --- a/test/snapshots/lsp.golden +++ b/test/snapshots/lsp.golden @@ -14,23 +14,13 @@ | 10 == snap cursor grid=120x41 cursor=17,10 == snap definition grid=120x41 cursor=15,5 -== snap hover grid=120x41 cursor=15,6 -|3: Hover -|4: 1 const std = @import("std"); -|5: 2 -|6: 3 fn helper(x: u32) u32 { -|7: 4 return x + 1; -|8: 5 } -|9: 6 -|10: 7 pub fn main() void { -|11: 8 _ = helper(41); -|12: 9 } -|13: 10 +== snap hover grid=120x41 cursor=15,5 +|3: 1 const std = @import("std"); Hover |38: /tmp/pardes-snap/lsp/cwd/+Hover Save Tty Collapse Del |39: 1 fn helper(x: u32) u32 |40: 2 (fn (u32) u32) -== snap symbols grid=120x41 cursor=15,6 -|3: Symbols +== snap symbols grid=120x41 cursor=15,5 +|3: 1 const std = @import("std"); Symbols |31: /tmp/pardes-snap/lsp/cwd/+Search Save Tty Collapse Del LocationsConfig |32: 1 a.zig:1:7-9 |33: 2 std @@ -40,26 +30,6 @@ |37: 6 main fn main() void == snap step grid=120x41 cursor=15,3 |3: 1 const std = @import("std"); -|4: 2 -|5: 3 fn helper(x: u32) u32 { -|6: 4 return x + 1; -|7: 5 } -|8: 6 -|9: 7 pub fn main() void { -|10: 8 _ = helper(41); -|11: 9 } -|12: 10 -|13: -|32: Look -|33: 1 a.zig:1:7-9 -|34: 2 std -|35: 3 a.zig:3:4-9 -|36: 4 helper fn helper(x: u32) u32 -|37: 5 a.zig:7:8-11 +|32: 1 a.zig:1:7-9 Look == snap nothing grid=120x41 cursor=7,5 |32: 1 a.zig:1:7-9 -|33: 2 std -|34: 3 a.zig:3:4-9 -|35: 4 helper fn helper(x: u32) u32 -|36: 5 a.zig:7:8-11 -|37: 6 main fn main() void diff --git a/test/snapshots/lspcomplete.golden b/test/snapshots/lspcomplete.golden index 4a9ff8b5..5a08f5ec 100644 --- a/test/snapshots/lspcomplete.golden +++ b/test/snapshots/lspcomplete.golden @@ -29,8 +29,7 @@ == snap refill grid=120x41 cursor=16,10 == snap step grid=120x41 cursor=19,4 |2: /tmp/pardes-snap/lspcomplete/cwd/a.zig * Save Tty Collapse Del TreeContext -|39: Look -|40: 1 a.zig:2:5-13 verdigris verdigris, +|39: 1 a.zig:2:5-13 verdigris verdigris, Look == snap txtindent grid=120x41 cursor=15,3 |Newcol Joincol Find Grep Help Changelog Tutor Dump NextColor Debug Kill | New Tty Find Grep Joincol Delcol diff --git a/test/snapshots/lsprelpath.golden b/test/snapshots/lsprelpath.golden index 58de860b..110d4440 100644 --- a/test/snapshots/lsprelpath.golden +++ b/test/snapshots/lsprelpath.golden @@ -42,8 +42,7 @@ |20: 3 cinnabar, |21: 4 }; |22: 5 -|33: Look -|34: 1 /tmp/pardes-snap/lsprelpath/cwd/shade.zig:2:5-13 verdigris verdigris, +|33: 1 /tmp/pardes-snap/lsprelpath/cwd/shade.zig:2:5-13 verdigris verdigris, Look == style abslook grid=100x35 |0: 0-70 #b2c3b8,#1d2824, 71-99 d,#1d2824, |1: 0-1 #ffffff,#887455, 2-2 d,#26362d, 3-34 #becfc4,#26362d, 35-99 d,#26362d, @@ -78,8 +77,8 @@ |30: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-99 d,#0d1410, |31: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-99 d,#0d1410, |32: 0-1 #ffffff,#496656, 2-2 d,#1d2824, 3-38 #b2c3b8,#1d2824, 39-45 #d3b0d9,#1d2824, 46-67 #b2c3b8,#1d2824, 68-99 d,#1d2824, -|33: 0-0 d,#152019, 1-1 d,#0d1410, 2-95 d,#1d2824, 96-99 #b2c3b8,#1d2824, -|34: 0-0 d,#608269, 1-1 d,#0d1410, 2-54 #59675c,#0d1410, 55-76 #e5eee5,#0d1410, 77-99 d,#0d1410, +|33: 0-0 d,#608269, 1-1 d,#0d1410, 2-54 #59675c,#0d1410, 55-76 #e5eee5,#0d1410, 77-93 d,#0d1410, 94-94 d,#1d2824, 95-98 #b2c3b8,#1d2824, 99-99 d,#1d2824, +|34: 0-0 d,#152019, 1-1 d,#0d1410, 2-54 #59675c,#0d1410, 55-74 #e5eee5,#0d1410, 75-99 d,#0d1410, == snap subrow grid=100x35 cursor=16,7 |Newcol Joincol Find Grep Help Changelog Tutor Dump NextColor Debug Kill | New Tty Find Grep Joincol Delcol @@ -124,8 +123,7 @@ |20: 3 indigo, |21: 4 }; |22: 5 -|33: Look -|34: 1 inner/tint.zig:2:5-9 ochre ochre, +|33: 1 inner/tint.zig:2:5-9 ochre ochre, Look == style sublook grid=100x35 |0: 0-70 #b2c3b8,#1d2824, 71-99 d,#1d2824, |1: 0-1 #ffffff,#887455, 2-2 d,#26362d, 3-34 #becfc4,#26362d, 35-99 d,#26362d, @@ -160,6 +158,6 @@ |30: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-99 d,#0d1410, |31: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-99 d,#0d1410, |32: 0-1 #ffffff,#496656, 2-2 d,#1d2824, 3-38 #b2c3b8,#1d2824, 39-45 #d3b0d9,#1d2824, 46-67 #b2c3b8,#1d2824, 68-99 d,#1d2824, -|33: 0-0 d,#152019, 1-1 d,#0d1410, 2-95 d,#1d2824, 96-99 #b2c3b8,#1d2824, -|34: 0-0 d,#608269, 1-1 d,#0d1410, 2-26 #59675c,#0d1410, 27-40 #e5eee5,#0d1410, 41-99 d,#0d1410, -== snap clicked grid=100x35 cursor=15,19 +|33: 0-0 d,#608269, 1-1 d,#0d1410, 2-26 #59675c,#0d1410, 27-40 #e5eee5,#0d1410, 41-93 d,#0d1410, 94-94 d,#1d2824, 95-98 #b2c3b8,#1d2824, 99-99 d,#1d2824, +|34: 0-0 d,#152019, 1-1 d,#0d1410, 2-27 #59675c,#0d1410, 28-43 #e5eee5,#0d1410, 44-99 d,#0d1410, +== snap clicked grid=100x35 cursor=16,20 diff --git a/test/snapshots/mini.golden b/test/snapshots/mini.golden index b915c60b..3f4e2889 100644 --- a/test/snapshots/mini.golden +++ b/test/snapshots/mini.golden @@ -2,8 +2,8 @@ |Newcol Joincol Find Grep Help Changelog Tutor Dump NextColor Debug Kill | New Tty Find Grep Joincol Delcol | /tmp/pardes-snap/mini/cwd/commands.txt Save Tty Collapse Del -| Mini -| 1 @`Mini demo.zig` +| 1 @`Mini demo.zig` Mini +| | | | @@ -21,8 +21,8 @@ |0: 0-70 #b2c3b8,#1d2824, 71-89 d,#1d2824, |1: 0-1 #ffffff,#887455, 2-2 d,#26362d, 3-34 #becfc4,#26362d, 35-89 d,#26362d, |2: 0-1 #ffffff,#496656, 2-2 d,#1d2824, 3-28 #b2c3b8,#1d2824, 29-40 #d3b0d9,#1d2824, 41-62 #b2c3b8,#1d2824, 63-89 d,#1d2824, -|3: 0-0 d,#152019, 1-1 d,#0d1410, 2-85 d,#1d2824, 86-89 #b2c3b8,#1d2824, -|4: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-22 #e5eee5,#0d1410, 23-89 d,#0d1410, +|3: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-22 #e5eee5,#0d1410, 23-83 d,#0d1410, 84-84 d,#1d2824, 85-88 #b2c3b8,#1d2824, 89-89 d,#1d2824, +|4: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-89 d,#0d1410, |5: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-89 d,#0d1410, |6: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-89 d,#0d1410, |7: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-89 d,#0d1410, @@ -48,10 +48,10 @@ @1: 0-1 #ffffff,#887455,,tagline 2-2 d,#26362d,,tagline 3-34 #becfc4,#26362d,,tagline 35-89 d,#26362d,,tagline |2: /tmp/pardes-snap/mini/cwd/commands.txt Save Tty Collapse Del @2: 0-1 #ffffff,#496656,,tagline 2-2 d,#1d2824,,tagline 3-28 #b2c3b8,#1d2824,,tagline 29-40 #d3b0d9,#1d2824,,tagline 41-62 #b2c3b8,#1d2824,,tagline 63-89 d,#1d2824,,tagline -|3: Mini -@3: 0-0 d,#152019,,body 1-1 d,#0d1410,,body 2-85 d,#1d2824,,tagline 86-89 #b2c3b8,#1d2824,,tagline -|4: 1 @`Mini demo.zig` -@4: 0-0 d,#608269,,body 1-1 d,#0d1410,,body 2-6 #59675c,#0d1410,,body 7-22 #e5eee5,#0d1410,,body 23-89 d,#0d1410,,body +|3: 1 @`Mini demo.zig` Mini +@3: 0-0 d,#608269,,body 1-1 d,#0d1410,,body 2-6 #59675c,#0d1410,,body 7-22 #e5eee5,#0d1410,,body 23-83 d,#0d1410,,body 84-84 d,#1d2824,,tagline 85-88 #b2c3b8,#1d2824,,tagline 89-89 d,#1d2824,,tagline +|4: +@4: 0-0 d,#608269,,body 1-1 d,#0d1410,,body 2-6 #59675c,#0d1410,,body 7-89 d,#0d1410,,body |5: @5: 0-0 d,#608269,,body 1-1 d,#0d1410,,body 2-6 #59675c,#0d1410,,body 7-89 d,#0d1410,,body |6: @@ -93,34 +93,26 @@ @22: 0-0 d,#608269,,body 1-1 d,#0d1410,,body 2-6 #59675c,#0d1410,,body 7-89 d,#0d1410,,body == style colors-off grid=90x23 |3: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-22 #e5eee5,#0d1410, 23-89 d,#0d1410, -|4: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-89 d,#0d1410, -|14: 0-0 d,#152019, 1-1 d,#0d1410, 2-83 d,#1d2824, 84-89 #b2c3b8,#1d2824, -|15: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #616f64,#0d1410,b 7-22 #e5eee5,#0d1410, 23-89 d,#0d1410, -|16: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-25 #e5eee5,#0d1410, 26-89 d,#0d1410, -|17: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-20 #e5eee5,#0d1410, 21-89 d,#0d1410, -== 9p colors-off grid=90x23 cursor=7,15,block +|14: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #616f64,#0d1410,b 7-22 #e5eee5,#0d1410, 23-81 d,#0d1410, 82-82 d,#1d2824, 83-88 #b2c3b8,#1d2824, 89-89 d,#1d2824, +|15: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-25 #e5eee5,#0d1410, 26-89 d,#0d1410, +|16: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-20 #e5eee5,#0d1410, 21-89 d,#0d1410, +== 9p colors-off grid=90x23 cursor=7,14,block |3: 1 @`Mini demo.zig` @3: 0-0 d,#608269,,body 1-1 d,#0d1410,,body 2-6 #59675c,#0d1410,,body 7-22 #e5eee5,#0d1410,,body 23-89 d,#0d1410,,body -|4: -@4: 0-0 d,#608269,,body 1-1 d,#0d1410,,body 2-6 #59675c,#0d1410,,body 7-89 d,#0d1410,,body -|14: Colors -@14: 0-0 d,#152019,,body 1-1 d,#0d1410,,body 2-83 d,#1d2824,,tagline 84-89 #b2c3b8,#1d2824,,tagline -|15: 1 â ­â �⣥⢩⣭⡭⣭⣬⣌⢭⣭⠌⠬⠅â �â � -+15: 7="â ­" 8="â �" 9="⣥" 10="⢩" 11="⣭" 12="â¡­" 13="⣭" 14="⣬" 15="⣌" 16="⢭" 17="⣭" 18="â Œ" 19="â ¬" 20="â …" 21="â �" 22="â �" -@15: 0-0 d,#608269,,body 1-1 d,#0d1410,,body 2-6 #616f64,#0d1410,b,body 7-22 #e5eee5,#0d1410,,body 23-89 d,#0d1410,,body -|16: 2 ⣂⢀⣉⣉⢉⣈â¢�⣀⣀⢀⣀⣀⣀⢀⣀⣀⣀⣀⣀ -+16: 7="⣂" 8="⢀" 9="⣉" 10="⣉" 11="⢉" 12="⣈" 13="â¢�" 14="⣀" 15="⣀" 16="⢀" 17="⣀" 18="⣀" 19="⣀" 20="⢀" 21="⣀" 22="⣀" 23="⣀" 24="⣀" 25="⣀" -@16: 0-0 d,#608269,,body 1-1 d,#0d1410,,body 2-6 #59675c,#0d1410,,body 7-25 #e5eee5,#0d1410,,body 26-89 d,#0d1410,,body -|17: 3 ⠉⠉â �⠉⠉⠉⠈⠈⠉⠉⠉⠉⠉⠉ -+17: 7="â ‰" 8="â ‰" 9="â �" 10="â ‰" 11="â ‰" 12="â ‰" 13="â ˆ" 14="â ˆ" 15="â ‰" 16="â ‰" 17="â ‰" 18="â ‰" 19="â ‰" 20="â ‰" -@17: 0-0 d,#608269,,body 1-1 d,#0d1410,,body 2-6 #59675c,#0d1410,,body 7-20 #e5eee5,#0d1410,,body 21-89 d,#0d1410,,body -|18: 4 -@18: 0-0 d,#608269,,body 1-1 d,#0d1410,,body 2-6 #59675c,#0d1410,,body 7-89 d,#0d1410,,body +|14: 1 â ­â �⣥⢩⣭⡭⣭⣬⣌⢭⣭⠌⠬⠅â �â � Colors ++14: 7="â ­" 8="â �" 9="⣥" 10="⢩" 11="⣭" 12="â¡­" 13="⣭" 14="⣬" 15="⣌" 16="⢭" 17="⣭" 18="â Œ" 19="â ¬" 20="â …" 21="â �" 22="â �" +@14: 0-0 d,#608269,,body 1-1 d,#0d1410,,body 2-6 #616f64,#0d1410,b,body 7-22 #e5eee5,#0d1410,,body 23-81 d,#0d1410,,body 82-82 d,#1d2824,,tagline 83-88 #b2c3b8,#1d2824,,tagline 89-89 d,#1d2824,,tagline +|15: 2 ⣂⢀⣉⣉⢉⣈â¢�⣀⣀⢀⣀⣀⣀⢀⣀⣀⣀⣀⣀ ++15: 7="⣂" 8="⢀" 9="⣉" 10="⣉" 11="⢉" 12="⣈" 13="â¢�" 14="⣀" 15="⣀" 16="⢀" 17="⣀" 18="⣀" 19="⣀" 20="⢀" 21="⣀" 22="⣀" 23="⣀" 24="⣀" 25="⣀" +@15: 0-0 d,#608269,,body 1-1 d,#0d1410,,body 2-6 #59675c,#0d1410,,body 7-25 #e5eee5,#0d1410,,body 26-89 d,#0d1410,,body +|16: 3 ⠉⠉â �⠉⠉⠉⠈⠈⠉⠉⠉⠉⠉⠉ ++16: 7="â ‰" 8="â ‰" 9="â �" 10="â ‰" 11="â ‰" 12="â ‰" 13="â ˆ" 14="â ˆ" 15="â ‰" 16="â ‰" 17="â ‰" 18="â ‰" 19="â ‰" 20="â ‰" +@16: 0-0 d,#608269,,body 1-1 d,#0d1410,,body 2-6 #59675c,#0d1410,,body 7-20 #e5eee5,#0d1410,,body 21-89 d,#0d1410,,body == style colors-on grid=90x23 -|15: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #616f64,#0d1410,b 7-8 #e5eee5,#0d1410, 9-9 #c9a7ed,#0d1410, 10-12 #e5eee5,#0d1410, 13-15 #c9a7ed,#0d1410, 16-21 #b8d88a,#0d1410, 22-22 #e5eee5,#0d1410, 23-89 d,#0d1410, -|16: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-8 #b9f480,#0d1410, 9-11 #c9a7ed,#0d1410, 12-25 #b9f480,#0d1410, 26-89 d,#0d1410, -|17: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-17 #e5eee5,#0d1410, 18-19 #f8c082,#0d1410, 20-20 #e5eee5,#0d1410, 21-89 d,#0d1410, -== snap resized grid=105x27 cursor=7,17 +|14: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #616f64,#0d1410,b 7-8 #e5eee5,#0d1410, 9-9 #c9a7ed,#0d1410, 10-12 #e5eee5,#0d1410, 13-15 #c9a7ed,#0d1410, 16-21 #b8d88a,#0d1410, 22-22 #e5eee5,#0d1410, 23-81 d,#0d1410, 82-82 d,#1d2824, 83-88 #b2c3b8,#1d2824, 89-89 d,#1d2824, +|15: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-8 #b9f480,#0d1410, 9-11 #c9a7ed,#0d1410, 12-25 #b9f480,#0d1410, 26-89 d,#0d1410, +|16: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-17 #e5eee5,#0d1410, 18-19 #f8c082,#0d1410, 20-20 #e5eee5,#0d1410, 21-89 d,#0d1410, +== snap resized grid=105x27 cursor=7,16 |Newcol Joincol Find Grep Help Changelog Tutor Dump NextColor Debug Kill | New Tty Find Grep Joincol Delcol | /tmp/pardes-snap/mini/cwd/commands.txt Save Tty Collapse Del @@ -137,12 +129,11 @@ | | | /tmp/pardes-snap/mini/cwd/Mini demo.zig Save Tty Collapse Del -| Colors -| 1 â ­â �⣥⢩⣭⡭⣭⣬⣌⢭⣭⠌⠬⠅â �â � +| 1 â ­â �⣥⢩⣭⡭⣭⣬⣌⢭⣭⠌⠬⠅â �â � Colors | 2 ⣂⢀⣉⣉⢉⣈â¢�⣀⣀⢀⣀⣀⣀⢀⣀⣀⣀⣀⣀ | 3 ⠉⠉â �⠉⠉⠉⠈⠈⠉⠉⠉⠉⠉⠉ | 4 -== 9p resized grid=105x27 cursor=7,17,block +== 9p resized grid=105x27 cursor=7,16,block |0: Newcol Joincol Find Grep Help Changelog Tutor Dump NextColor Debug Kill @0: 0-70 #b2c3b8,#1d2824,,tagline 71-104 d,#1d2824,,tagline |1: New Tty Find Grep Joincol Delcol @@ -175,18 +166,18 @@ @14: 0-0 d,#608269,,body 1-1 d,#0d1410,,body 2-6 #59675c,#0d1410,,body 7-104 d,#0d1410,,body |15: /tmp/pardes-snap/mini/cwd/Mini demo.zig Save Tty Collapse Del @15: 0-1 #000000,#add38a,,tagline 2-2 d,#26362d,,tagline 3-28 #becfc4,#26362d,,tagline 29-41 #dfbce5,#26362d,,tagline 42-63 #becfc4,#26362d,,tagline 64-104 d,#26362d,,tagline -|16: Colors -@16: 0-0 d,#152019,,body 1-1 d,#0d1410,,body 2-98 d,#1d2824,,tagline 99-104 #b2c3b8,#1d2824,,tagline -|17: 1 â ­â �⣥⢩⣭⡭⣭⣬⣌⢭⣭⠌⠬⠅â �â � -+17: 7="â ­" 8="â �" 9="⣥" 10="⢩" 11="⣭" 12="â¡­" 13="⣭" 14="⣬" 15="⣌" 16="⢭" 17="⣭" 18="â Œ" 19="â ¬" 20="â …" 21="â �" 22="â �" -@17: 0-0 d,#608269,,body 1-1 d,#0d1410,,body 2-6 #616f64,#0d1410,b,body 7-8 #e5eee5,#0d1410,,body 9-9 #c9a7ed,#0d1410,,body 10-12 #e5eee5,#0d1410,,body 13-15 #c9a7ed,#0d1410,,body 16-21 #b8d88a,#0d1410,,body 22-22 #e5eee5,#0d1410,,body 23-104 d,#0d1410,,body -|18: 2 ⣂⢀⣉⣉⢉⣈â¢�⣀⣀⢀⣀⣀⣀⢀⣀⣀⣀⣀⣀ -+18: 7="⣂" 8="⢀" 9="⣉" 10="⣉" 11="⢉" 12="⣈" 13="â¢�" 14="⣀" 15="⣀" 16="⢀" 17="⣀" 18="⣀" 19="⣀" 20="⢀" 21="⣀" 22="⣀" 23="⣀" 24="⣀" 25="⣀" -@18: 0-0 d,#608269,,body 1-1 d,#0d1410,,body 2-6 #59675c,#0d1410,,body 7-8 #b9f480,#0d1410,,body 9-11 #c9a7ed,#0d1410,,body 12-25 #b9f480,#0d1410,,body 26-104 d,#0d1410,,body -|19: 3 ⠉⠉â �⠉⠉⠉⠈⠈⠉⠉⠉⠉⠉⠉ -+19: 7="â ‰" 8="â ‰" 9="â �" 10="â ‰" 11="â ‰" 12="â ‰" 13="â ˆ" 14="â ˆ" 15="â ‰" 16="â ‰" 17="â ‰" 18="â ‰" 19="â ‰" 20="â ‰" -@19: 0-0 d,#608269,,body 1-1 d,#0d1410,,body 2-6 #59675c,#0d1410,,body 7-17 #e5eee5,#0d1410,,body 18-19 #f8c082,#0d1410,,body 20-20 #e5eee5,#0d1410,,body 21-104 d,#0d1410,,body -|20: 4 +|16: 1 â ­â �⣥⢩⣭⡭⣭⣬⣌⢭⣭⠌⠬⠅â �â � Colors ++16: 7="â ­" 8="â �" 9="⣥" 10="⢩" 11="⣭" 12="â¡­" 13="⣭" 14="⣬" 15="⣌" 16="⢭" 17="⣭" 18="â Œ" 19="â ¬" 20="â …" 21="â �" 22="â �" +@16: 0-0 d,#608269,,body 1-1 d,#0d1410,,body 2-6 #616f64,#0d1410,b,body 7-8 #e5eee5,#0d1410,,body 9-9 #c9a7ed,#0d1410,,body 10-12 #e5eee5,#0d1410,,body 13-15 #c9a7ed,#0d1410,,body 16-21 #b8d88a,#0d1410,,body 22-22 #e5eee5,#0d1410,,body 23-96 d,#0d1410,,body 97-97 d,#1d2824,,tagline 98-103 #b2c3b8,#1d2824,,tagline 104-104 d,#1d2824,,tagline +|17: 2 ⣂⢀⣉⣉⢉⣈â¢�⣀⣀⢀⣀⣀⣀⢀⣀⣀⣀⣀⣀ ++17: 7="⣂" 8="⢀" 9="⣉" 10="⣉" 11="⢉" 12="⣈" 13="â¢�" 14="⣀" 15="⣀" 16="⢀" 17="⣀" 18="⣀" 19="⣀" 20="⢀" 21="⣀" 22="⣀" 23="⣀" 24="⣀" 25="⣀" +@17: 0-0 d,#608269,,body 1-1 d,#0d1410,,body 2-6 #59675c,#0d1410,,body 7-8 #b9f480,#0d1410,,body 9-11 #c9a7ed,#0d1410,,body 12-25 #b9f480,#0d1410,,body 26-104 d,#0d1410,,body +|18: 3 ⠉⠉â �⠉⠉⠉⠈⠈⠉⠉⠉⠉⠉⠉ ++18: 7="â ‰" 8="â ‰" 9="â �" 10="â ‰" 11="â ‰" 12="â ‰" 13="â ˆ" 14="â ˆ" 15="â ‰" 16="â ‰" 17="â ‰" 18="â ‰" 19="â ‰" 20="â ‰" +@18: 0-0 d,#608269,,body 1-1 d,#0d1410,,body 2-6 #59675c,#0d1410,,body 7-17 #e5eee5,#0d1410,,body 18-19 #f8c082,#0d1410,,body 20-20 #e5eee5,#0d1410,,body 21-104 d,#0d1410,,body +|19: 4 +@19: 0-0 d,#608269,,body 1-1 d,#0d1410,,body 2-6 #59675c,#0d1410,,body 7-104 d,#0d1410,,body +|20: @20: 0-0 d,#608269,,body 1-1 d,#0d1410,,body 2-6 #59675c,#0d1410,,body 7-104 d,#0d1410,,body |21: @21: 0-0 d,#608269,,body 1-1 d,#0d1410,,body 2-6 #59675c,#0d1410,,body 7-104 d,#0d1410,,body diff --git a/test/snapshots/msg.golden b/test/snapshots/msg.golden index 197d01d9..653e9772 100644 --- a/test/snapshots/msg.golden +++ b/test/snapshots/msg.golden @@ -9,21 +9,13 @@ | 5 line 5 | 6 line 6 | 7 -== snap saved grid=70x15 cursor=7,4 -|3: --:--:-- saved /tmp/pardes-snap/msg/cwd/a.txt -|4: 1 line 1 -|5: 2 line 2 -|6: 3 line 3 -|7: 4 line 4 -|8: 5 line 5 -|9: 6 line 6 -|10: 7 -== snap repainted grid=70x17 cursor=7,4 +== snap saved grid=70x15 cursor=7,3 +|3: 1 line 1 --:--:-- saved /tmp/pardes-snap/msg/cwd/a.txt +== snap repainted grid=70x17 cursor=7,3 |Newcol Joincol Find Grep Help Changelog Tutor Dump NextColor Debug Kil | New Tty Find Grep Joincol Delcol | /tmp/pardes-snap/msg/cwd/a.txt Save Tty Collapse Del -| --:--:-- saved /tmp/pardes-snap/msg/cwd/a.txt -| 1 line 1 +| 1 line 1 --:--:-- saved /tmp/pardes-snap/msg/cwd/a.txt | 2 line 2 | 3 line 3 | 4 line 4 @@ -32,54 +24,27 @@ | 7 == snap keycleared grid=70x17 cursor=7,4 |3: 1 line 1 -|4: 2 line 2 -|5: 3 line 3 -|6: 4 line 4 -|7: 5 line 5 -|8: 6 line 6 -|9: 7 -|10: -== snap saved-again grid=70x17 cursor=7,5 -|3: --:--:-- saved /tmp/pardes-snap/msg/cwd/a.txt -|4: 1 line 1 -|5: 2 line 2 -|6: 3 line 3 -|7: 4 line 4 -|8: 5 line 5 -|9: 6 line 6 -|10: 7 +== snap saved-again grid=70x17 cursor=7,4 +|3: 1 line 1 --:--:-- saved /tmp/pardes-snap/msg/cwd/a.txt == snap mousecleared grid=70x17 cursor=7,4 |3: 1 line 1 -|4: 2 line 2 -|5: 3 line 3 -|6: 4 line 4 -|7: 5 line 5 -|8: 6 line 6 -|9: 7 -|10: -== snap reloaded grid=70x17 cursor=7,5 -|3: --:--:-- reloaded /tmp/pardes-snap/msg/cwd/a.txt -|4: 1 EXTERNAL -|5: 2 +== snap reloaded grid=70x17 cursor=7,4 +|3: 1 EXTERNAL --:--:-- reloaded /tmp/pardes-snap/msg/cwd/a.txt +|4: 2 +|5: |6: |7: |8: |9: == snap prompt grid=70x17 cursor=69,3 -|3: /EXT +|3: 1 EXTERNAL /EXT == snap prompt-wins grid=70x17 cursor=69,4 -|3: --:--:-- reloaded /tmp/pardes-snap/msg/cwd/a.txt -|4: /EXT -|5: 1 AGAIN -|6: 2 +|3: 1 AGAIN --:--:-- reloaded /tmp/pardes-snap/msg/cwd/a.txt +|4: 2 /EXT == snap esc grid=70x17 cursor=7,4 |3: 1 AGAIN |4: 2 -|5: -|6: -== snap msgbuiltin grid=70x17 cursor=29,6 +== snap msgbuiltin grid=70x17 cursor=29,5 |2: /tmp/pardes-snap/msg/cwd/a.txt * Save Tty Collapse Del -|3: hand-written report -|4: 1 AGAIN -|5: 2 -|6: 3 Msg hand-written report +|3: 1 AGAIN hand-written report +|5: 3 Msg hand-written report diff --git a/test/snapshots/ninep.golden b/test/snapshots/ninep.golden index b501004e..d4cb2a27 100644 --- a/test/snapshots/ninep.golden +++ b/test/snapshots/ninep.golden @@ -58,31 +58,20 @@ |14: @14: 0-0 d,#608269,,body 1-1 d,#0d1410,,body 2-6 #59675c,#0d1410,,body 7-89 d,#0d1410,,body == style colors-off grid=90x15 -|3: 0-0 d,#152019, 1-1 d,#0d1410, 2-83 d,#1d2824, 84-89 #b2c3b8,#1d2824, -|4: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #616f64,#0d1410,b 7-32 #e5eee5,#0d1410, 33-33 d,d, 34-37 #e5eee5,#0d1410, 38-89 d,#0d1410, -|5: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-89 d,#0d1410, -|6: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-35 #e5eee5,#0d1410, 36-89 d,#0d1410, -|7: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-28 #e5eee5,#0d1410, 29-89 d,#0d1410, -|8: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-19 #e5eee5,#0d1410, 20-89 d,#0d1410, -|9: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-7 #e5eee5,#0d1410, 8-89 d,#0d1410, -== 9p colors-off grid=90x15 cursor=7,4,block -|3: Colors -@3: 0-0 d,#152019,,body 1-1 d,#0d1410,,body 2-83 d,#1d2824,,tagline 84-89 #b2c3b8,#1d2824,,tagline -|4: 1 const greeting = "café λ 界 eÌ�"; -+4: 28="é" 30="λ" 32="界" 33="" 35="eÌ�" -@4: 0-0 d,#608269,,body 1-1 d,#0d1410,,body 2-6 #616f64,#0d1410,b,body 7-37 #e5eee5,#0d1410,,body 38-89 d,#0d1410,,body -|5: 2 -@5: 0-0 d,#608269,,body 1-1 d,#0d1410,,body 2-6 #59675c,#0d1410,,body 7-89 d,#0d1410,,body -|6: 3 pub fn choose(ok: bool) u32 { -@6: 0-0 d,#608269,,body 1-1 d,#0d1410,,body 2-6 #59675c,#0d1410,,body 7-35 #e5eee5,#0d1410,,body 36-89 d,#0d1410,,body -|7: 4 if (ok) return 42; -@7: 0-0 d,#608269,,body 1-1 d,#0d1410,,body 2-6 #59675c,#0d1410,,body 7-28 #e5eee5,#0d1410,,body 29-89 d,#0d1410,,body -|8: 5 return 7; -@8: 0-0 d,#608269,,body 1-1 d,#0d1410,,body 2-6 #59675c,#0d1410,,body 7-19 #e5eee5,#0d1410,,body 20-89 d,#0d1410,,body -|9: 6 } -@9: 0-0 d,#608269,,body 1-1 d,#0d1410,,body 2-6 #59675c,#0d1410,,body 7-7 #e5eee5,#0d1410,,body 8-89 d,#0d1410,,body -|10: 7 -@10: 0-0 d,#608269,,body 1-1 d,#0d1410,,body 2-6 #59675c,#0d1410,,body 7-89 d,#0d1410,,body +|3: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #616f64,#0d1410,b 7-32 #e5eee5,#0d1410, 33-33 d,d, 34-37 #e5eee5,#0d1410, 38-81 d,#0d1410, 82-82 d,#1d2824, 83-88 #b2c3b8,#1d2824, 89-89 d,#1d2824, +|5: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-35 #e5eee5,#0d1410, 36-89 d,#0d1410, +|6: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-28 #e5eee5,#0d1410, 29-89 d,#0d1410, +|7: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-19 #e5eee5,#0d1410, 20-89 d,#0d1410, +== 9p colors-off grid=90x15 cursor=7,3,block +|3: 1 const greeting = "café λ 界 eÌ�"; Colors ++3: 28="é" 30="λ" 32="界" 33="" 35="eÌ�" +@3: 0-0 d,#608269,,body 1-1 d,#0d1410,,body 2-6 #616f64,#0d1410,b,body 7-37 #e5eee5,#0d1410,,body 38-81 d,#0d1410,,body 82-82 d,#1d2824,,tagline 83-88 #b2c3b8,#1d2824,,tagline 89-89 d,#1d2824,,tagline +|5: 3 pub fn choose(ok: bool) u32 { +@5: 0-0 d,#608269,,body 1-1 d,#0d1410,,body 2-6 #59675c,#0d1410,,body 7-35 #e5eee5,#0d1410,,body 36-89 d,#0d1410,,body +|6: 4 if (ok) return 42; +@6: 0-0 d,#608269,,body 1-1 d,#0d1410,,body 2-6 #59675c,#0d1410,,body 7-28 #e5eee5,#0d1410,,body 29-89 d,#0d1410,,body +|7: 5 return 7; +@7: 0-0 d,#608269,,body 1-1 d,#0d1410,,body 2-6 #59675c,#0d1410,,body 7-19 #e5eee5,#0d1410,,body 20-89 d,#0d1410,,body == snap edited-with-colors-off grid=90x15 cursor=7,4 |2: /tmp/pardes-snap/ninep/cwd/demo.zig * Save Tty Collapse Del TreeContext |3: 1 // café λ 界 @@ -116,46 +105,38 @@ @10: 0-0 d,#608269,,body 1-1 d,#0d1410,,body 2-6 #59675c,#0d1410,,body 7-89 d,#0d1410,,body == style colors-on grid=90x15 |2: 0-1 #000000,#add38a, 2-2 d,#26362d, 3-29 #becfc4,#26362d, 30-37 #dfbce5,#26362d, 38-73 #becfc4,#26362d, 74-89 d,#26362d, -|4: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-17 #b9f480,#0d1410, 18-18 d,d, 19-89 d,#0d1410, -|5: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #616f64,#0d1410,b 7-23 #e5eee5,#0d1410, 24-32 #b8d88a,#0d1410, 33-33 d,d, 34-36 #b8d88a,#0d1410, 37-37 #e5eee5,#0d1410, 38-89 d,#0d1410, -|6: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-89 d,#0d1410, -|7: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-10 #e5eee5,#0d1410, 11-12 #c9a7ed,#0d1410, 13-35 #e5eee5,#0d1410, 36-89 d,#0d1410, -|8: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-10 #e5eee5,#0d1410, 11-12 #c9a7ed,#0d1410, 13-18 #e5eee5,#0d1410, 19-24 #c9a7ed,#0d1410, 25-25 #e5eee5,#0d1410, 26-27 #f8c082,#0d1410, 28-28 #e5eee5,#0d1410, 29-89 d,#0d1410, -|9: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-10 #e5eee5,#0d1410, 11-16 #c9a7ed,#0d1410, 17-17 #e5eee5,#0d1410, 18-18 #f8c082,#0d1410, 19-19 #e5eee5,#0d1410, 20-89 d,#0d1410, -|10: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-7 #e5eee5,#0d1410, 8-89 d,#0d1410, -== 9p colors-on grid=90x15 cursor=7,5,block -|3: Colors -@3: 0-0 d,#152019,,body 1-1 d,#0d1410,,body 2-83 d,#1d2824,,tagline 84-89 #b2c3b8,#1d2824,,tagline -|4: 1 // café λ 界 -+4: 13="é" 15="λ" 17="界" 18="" -@4: 0-0 d,#608269,,body 1-1 d,#0d1410,,body 2-6 #59675c,#0d1410,,body 7-18 #b9f480,#0d1410,,body 19-89 d,#0d1410,,body -|5: 2 const greeting = "café λ 界 eÌ�"; -+5: 28="é" 30="λ" 32="界" 33="" 35="eÌ�" -@5: 0-0 d,#608269,,body 1-1 d,#0d1410,,body 2-6 #616f64,#0d1410,b,body 7-23 #e5eee5,#0d1410,,body 24-36 #b8d88a,#0d1410,,body 37-37 #e5eee5,#0d1410,,body 38-89 d,#0d1410,,body -|6: 3 -@6: 0-0 d,#608269,,body 1-1 d,#0d1410,,body 2-6 #59675c,#0d1410,,body 7-89 d,#0d1410,,body -|7: 4 pub fn choose(ok: bool) u32 { -@7: 0-0 d,#608269,,body 1-1 d,#0d1410,,body 2-6 #59675c,#0d1410,,body 7-10 #e5eee5,#0d1410,,body 11-12 #c9a7ed,#0d1410,,body 13-35 #e5eee5,#0d1410,,body 36-89 d,#0d1410,,body -|8: 5 if (ok) return 42; -@8: 0-0 d,#608269,,body 1-1 d,#0d1410,,body 2-6 #59675c,#0d1410,,body 7-10 #e5eee5,#0d1410,,body 11-12 #c9a7ed,#0d1410,,body 13-18 #e5eee5,#0d1410,,body 19-24 #c9a7ed,#0d1410,,body 25-25 #e5eee5,#0d1410,,body 26-27 #f8c082,#0d1410,,body 28-28 #e5eee5,#0d1410,,body 29-89 d,#0d1410,,body -|9: 6 return 7; -@9: 0-0 d,#608269,,body 1-1 d,#0d1410,,body 2-6 #59675c,#0d1410,,body 7-10 #e5eee5,#0d1410,,body 11-16 #c9a7ed,#0d1410,,body 17-17 #e5eee5,#0d1410,,body 18-18 #f8c082,#0d1410,,body 19-19 #e5eee5,#0d1410,,body 20-89 d,#0d1410,,body -|10: 7 } -@10: 0-0 d,#608269,,body 1-1 d,#0d1410,,body 2-6 #59675c,#0d1410,,body 7-7 #e5eee5,#0d1410,,body 8-89 d,#0d1410,,body -|11: 8 -@11: 0-0 d,#608269,,body 1-1 d,#0d1410,,body 2-6 #59675c,#0d1410,,body 7-89 d,#0d1410,,body +|3: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-17 #b9f480,#0d1410, 18-18 d,d, 19-81 d,#0d1410, 82-82 d,#1d2824, 83-88 #b2c3b8,#1d2824, 89-89 d,#1d2824, +|4: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #616f64,#0d1410,b 7-23 #e5eee5,#0d1410, 24-32 #b8d88a,#0d1410, 33-33 d,d, 34-36 #b8d88a,#0d1410, 37-37 #e5eee5,#0d1410, 38-89 d,#0d1410, +|5: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-89 d,#0d1410, +|6: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-10 #e5eee5,#0d1410, 11-12 #c9a7ed,#0d1410, 13-35 #e5eee5,#0d1410, 36-89 d,#0d1410, +|7: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-10 #e5eee5,#0d1410, 11-12 #c9a7ed,#0d1410, 13-18 #e5eee5,#0d1410, 19-24 #c9a7ed,#0d1410, 25-25 #e5eee5,#0d1410, 26-27 #f8c082,#0d1410, 28-28 #e5eee5,#0d1410, 29-89 d,#0d1410, +|8: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-10 #e5eee5,#0d1410, 11-16 #c9a7ed,#0d1410, 17-17 #e5eee5,#0d1410, 18-18 #f8c082,#0d1410, 19-19 #e5eee5,#0d1410, 20-89 d,#0d1410, +|9: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-7 #e5eee5,#0d1410, 8-89 d,#0d1410, +== 9p colors-on grid=90x15 cursor=7,4,block +|3: 1 // café λ 界 Colors ++3: 13="é" 15="λ" 17="界" 18="" +@3: 0-0 d,#608269,,body 1-1 d,#0d1410,,body 2-6 #59675c,#0d1410,,body 7-18 #b9f480,#0d1410,,body 19-81 d,#0d1410,,body 82-82 d,#1d2824,,tagline 83-88 #b2c3b8,#1d2824,,tagline 89-89 d,#1d2824,,tagline +|4: 2 const greeting = "café λ 界 eÌ�"; ++4: 28="é" 30="λ" 32="界" 33="" 35="eÌ�" +@4: 0-0 d,#608269,,body 1-1 d,#0d1410,,body 2-6 #616f64,#0d1410,b,body 7-23 #e5eee5,#0d1410,,body 24-36 #b8d88a,#0d1410,,body 37-37 #e5eee5,#0d1410,,body 38-89 d,#0d1410,,body +|6: 4 pub fn choose(ok: bool) u32 { +@6: 0-0 d,#608269,,body 1-1 d,#0d1410,,body 2-6 #59675c,#0d1410,,body 7-10 #e5eee5,#0d1410,,body 11-12 #c9a7ed,#0d1410,,body 13-35 #e5eee5,#0d1410,,body 36-89 d,#0d1410,,body +|7: 5 if (ok) return 42; +@7: 0-0 d,#608269,,body 1-1 d,#0d1410,,body 2-6 #59675c,#0d1410,,body 7-10 #e5eee5,#0d1410,,body 11-12 #c9a7ed,#0d1410,,body 13-18 #e5eee5,#0d1410,,body 19-24 #c9a7ed,#0d1410,,body 25-25 #e5eee5,#0d1410,,body 26-27 #f8c082,#0d1410,,body 28-28 #e5eee5,#0d1410,,body 29-89 d,#0d1410,,body +|8: 6 return 7; +@8: 0-0 d,#608269,,body 1-1 d,#0d1410,,body 2-6 #59675c,#0d1410,,body 7-10 #e5eee5,#0d1410,,body 11-16 #c9a7ed,#0d1410,,body 17-17 #e5eee5,#0d1410,,body 18-18 #f8c082,#0d1410,,body 19-19 #e5eee5,#0d1410,,body 20-89 d,#0d1410,,body == style resized grid=105x20 |0: 0-70 #b2c3b8,#1d2824, 71-104 d,#1d2824, |1: 0-1 #ffffff,#887455, 2-2 d,#26362d, 3-34 #becfc4,#26362d, 35-104 d,#26362d, |2: 0-1 #000000,#add38a, 2-2 d,#26362d, 3-29 #becfc4,#26362d, 30-37 #dfbce5,#26362d, 38-73 #becfc4,#26362d, 74-104 d,#26362d, -|3: 0-0 d,#152019, 1-1 d,#0d1410, 2-98 d,#1d2824, 99-104 #b2c3b8,#1d2824, -|4: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-17 #b9f480,#0d1410, 18-18 d,d, 19-104 d,#0d1410, -|5: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #616f64,#0d1410,b 7-23 #e5eee5,#0d1410, 24-32 #b8d88a,#0d1410, 33-33 d,d, 34-36 #b8d88a,#0d1410, 37-37 #e5eee5,#0d1410, 38-104 d,#0d1410, -|6: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-104 d,#0d1410, -|7: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-10 #e5eee5,#0d1410, 11-12 #c9a7ed,#0d1410, 13-35 #e5eee5,#0d1410, 36-104 d,#0d1410, -|8: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-10 #e5eee5,#0d1410, 11-12 #c9a7ed,#0d1410, 13-18 #e5eee5,#0d1410, 19-24 #c9a7ed,#0d1410, 25-25 #e5eee5,#0d1410, 26-27 #f8c082,#0d1410, 28-28 #e5eee5,#0d1410, 29-104 d,#0d1410, -|9: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-10 #e5eee5,#0d1410, 11-16 #c9a7ed,#0d1410, 17-17 #e5eee5,#0d1410, 18-18 #f8c082,#0d1410, 19-19 #e5eee5,#0d1410, 20-104 d,#0d1410, -|10: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-7 #e5eee5,#0d1410, 8-104 d,#0d1410, +|3: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-17 #b9f480,#0d1410, 18-18 d,d, 19-96 d,#0d1410, 97-97 d,#1d2824, 98-103 #b2c3b8,#1d2824, 104-104 d,#1d2824, +|4: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #616f64,#0d1410,b 7-23 #e5eee5,#0d1410, 24-32 #b8d88a,#0d1410, 33-33 d,d, 34-36 #b8d88a,#0d1410, 37-37 #e5eee5,#0d1410, 38-104 d,#0d1410, +|5: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-104 d,#0d1410, +|6: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-10 #e5eee5,#0d1410, 11-12 #c9a7ed,#0d1410, 13-35 #e5eee5,#0d1410, 36-104 d,#0d1410, +|7: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-10 #e5eee5,#0d1410, 11-12 #c9a7ed,#0d1410, 13-18 #e5eee5,#0d1410, 19-24 #c9a7ed,#0d1410, 25-25 #e5eee5,#0d1410, 26-27 #f8c082,#0d1410, 28-28 #e5eee5,#0d1410, 29-104 d,#0d1410, +|8: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-10 #e5eee5,#0d1410, 11-16 #c9a7ed,#0d1410, 17-17 #e5eee5,#0d1410, 18-18 #f8c082,#0d1410, 19-19 #e5eee5,#0d1410, 20-104 d,#0d1410, +|9: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-7 #e5eee5,#0d1410, 8-104 d,#0d1410, +|10: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-104 d,#0d1410, |11: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-104 d,#0d1410, |12: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-104 d,#0d1410, |13: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-104 d,#0d1410, @@ -165,32 +146,32 @@ |17: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-104 d,#0d1410, |18: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-104 d,#0d1410, |19: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-104 d,#0d1410, -== 9p resized grid=105x20 cursor=7,5,block +== 9p resized grid=105x20 cursor=7,4,block |0: Newcol Joincol Find Grep Help Changelog Tutor Dump NextColor Debug Kill @0: 0-70 #b2c3b8,#1d2824,,tagline 71-104 d,#1d2824,,tagline |1: New Tty Find Grep Joincol Delcol @1: 0-1 #ffffff,#887455,,tagline 2-2 d,#26362d,,tagline 3-34 #becfc4,#26362d,,tagline 35-104 d,#26362d,,tagline |2: /tmp/pardes-snap/ninep/cwd/demo.zig * Save Tty Collapse Del TreeContext @2: 0-1 #000000,#add38a,,tagline 2-2 d,#26362d,,tagline 3-29 #becfc4,#26362d,,tagline 30-37 #dfbce5,#26362d,,tagline 38-73 #becfc4,#26362d,,tagline 74-104 d,#26362d,,tagline -|3: Colors -@3: 0-0 d,#152019,,body 1-1 d,#0d1410,,body 2-98 d,#1d2824,,tagline 99-104 #b2c3b8,#1d2824,,tagline -|4: 1 // café λ 界 -+4: 13="é" 15="λ" 17="界" 18="" -@4: 0-0 d,#608269,,body 1-1 d,#0d1410,,body 2-6 #59675c,#0d1410,,body 7-18 #b9f480,#0d1410,,body 19-104 d,#0d1410,,body -|5: 2 const greeting = "café λ 界 eÌ�"; -+5: 28="é" 30="λ" 32="界" 33="" 35="eÌ�" -@5: 0-0 d,#608269,,body 1-1 d,#0d1410,,body 2-6 #616f64,#0d1410,b,body 7-23 #e5eee5,#0d1410,,body 24-36 #b8d88a,#0d1410,,body 37-37 #e5eee5,#0d1410,,body 38-104 d,#0d1410,,body -|6: 3 -@6: 0-0 d,#608269,,body 1-1 d,#0d1410,,body 2-6 #59675c,#0d1410,,body 7-104 d,#0d1410,,body -|7: 4 pub fn choose(ok: bool) u32 { -@7: 0-0 d,#608269,,body 1-1 d,#0d1410,,body 2-6 #59675c,#0d1410,,body 7-10 #e5eee5,#0d1410,,body 11-12 #c9a7ed,#0d1410,,body 13-35 #e5eee5,#0d1410,,body 36-104 d,#0d1410,,body -|8: 5 if (ok) return 42; -@8: 0-0 d,#608269,,body 1-1 d,#0d1410,,body 2-6 #59675c,#0d1410,,body 7-10 #e5eee5,#0d1410,,body 11-12 #c9a7ed,#0d1410,,body 13-18 #e5eee5,#0d1410,,body 19-24 #c9a7ed,#0d1410,,body 25-25 #e5eee5,#0d1410,,body 26-27 #f8c082,#0d1410,,body 28-28 #e5eee5,#0d1410,,body 29-104 d,#0d1410,,body -|9: 6 return 7; -@9: 0-0 d,#608269,,body 1-1 d,#0d1410,,body 2-6 #59675c,#0d1410,,body 7-10 #e5eee5,#0d1410,,body 11-16 #c9a7ed,#0d1410,,body 17-17 #e5eee5,#0d1410,,body 18-18 #f8c082,#0d1410,,body 19-19 #e5eee5,#0d1410,,body 20-104 d,#0d1410,,body -|10: 7 } -@10: 0-0 d,#608269,,body 1-1 d,#0d1410,,body 2-6 #59675c,#0d1410,,body 7-7 #e5eee5,#0d1410,,body 8-104 d,#0d1410,,body -|11: 8 +|3: 1 // café λ 界 Colors ++3: 13="é" 15="λ" 17="界" 18="" +@3: 0-0 d,#608269,,body 1-1 d,#0d1410,,body 2-6 #59675c,#0d1410,,body 7-18 #b9f480,#0d1410,,body 19-96 d,#0d1410,,body 97-97 d,#1d2824,,tagline 98-103 #b2c3b8,#1d2824,,tagline 104-104 d,#1d2824,,tagline +|4: 2 const greeting = "café λ 界 eÌ�"; ++4: 28="é" 30="λ" 32="界" 33="" 35="eÌ�" +@4: 0-0 d,#608269,,body 1-1 d,#0d1410,,body 2-6 #616f64,#0d1410,b,body 7-23 #e5eee5,#0d1410,,body 24-36 #b8d88a,#0d1410,,body 37-37 #e5eee5,#0d1410,,body 38-104 d,#0d1410,,body +|5: 3 +@5: 0-0 d,#608269,,body 1-1 d,#0d1410,,body 2-6 #59675c,#0d1410,,body 7-104 d,#0d1410,,body +|6: 4 pub fn choose(ok: bool) u32 { +@6: 0-0 d,#608269,,body 1-1 d,#0d1410,,body 2-6 #59675c,#0d1410,,body 7-10 #e5eee5,#0d1410,,body 11-12 #c9a7ed,#0d1410,,body 13-35 #e5eee5,#0d1410,,body 36-104 d,#0d1410,,body +|7: 5 if (ok) return 42; +@7: 0-0 d,#608269,,body 1-1 d,#0d1410,,body 2-6 #59675c,#0d1410,,body 7-10 #e5eee5,#0d1410,,body 11-12 #c9a7ed,#0d1410,,body 13-18 #e5eee5,#0d1410,,body 19-24 #c9a7ed,#0d1410,,body 25-25 #e5eee5,#0d1410,,body 26-27 #f8c082,#0d1410,,body 28-28 #e5eee5,#0d1410,,body 29-104 d,#0d1410,,body +|8: 6 return 7; +@8: 0-0 d,#608269,,body 1-1 d,#0d1410,,body 2-6 #59675c,#0d1410,,body 7-10 #e5eee5,#0d1410,,body 11-16 #c9a7ed,#0d1410,,body 17-17 #e5eee5,#0d1410,,body 18-18 #f8c082,#0d1410,,body 19-19 #e5eee5,#0d1410,,body 20-104 d,#0d1410,,body +|9: 7 } +@9: 0-0 d,#608269,,body 1-1 d,#0d1410,,body 2-6 #59675c,#0d1410,,body 7-7 #e5eee5,#0d1410,,body 8-104 d,#0d1410,,body +|10: 8 +@10: 0-0 d,#608269,,body 1-1 d,#0d1410,,body 2-6 #59675c,#0d1410,,body 7-104 d,#0d1410,,body +|11: @11: 0-0 d,#608269,,body 1-1 d,#0d1410,,body 2-6 #59675c,#0d1410,,body 7-104 d,#0d1410,,body |12: @12: 0-0 d,#608269,,body 1-1 d,#0d1410,,body 2-6 #59675c,#0d1410,,body 7-104 d,#0d1410,,body @@ -208,12 +189,11 @@ @18: 0-0 d,#608269,,body 1-1 d,#0d1410,,body 2-6 #59675c,#0d1410,,body 7-104 d,#0d1410,,body |19: @19: 0-0 d,#608269,,body 1-1 d,#0d1410,,body 2-6 #59675c,#0d1410,,body 7-104 d,#0d1410,,body -== snap resized grid=105x20 cursor=7,5 +== snap resized grid=105x20 cursor=7,4 |Newcol Joincol Find Grep Help Changelog Tutor Dump NextColor Debug Kill | New Tty Find Grep Joincol Delcol | /tmp/pardes-snap/ninep/cwd/demo.zig * Save Tty Collapse Del TreeContext -| Colors -| 1 // café λ 界 +| 1 // café λ 界 Colors | 2 const greeting = "café λ 界 eÌ�"; | 3 | 4 pub fn choose(ok: bool) u32 { @@ -221,4 +201,4 @@ | 6 return 7; | 7 } | 8 -== 9p unchanged grid=105x20 cursor=7,5,block +== 9p unchanged grid=105x20 cursor=7,4,block diff --git a/test/snapshots/pipe.golden b/test/snapshots/pipe.golden index d3f6bbc2..2e0b3fa6 100644 --- a/test/snapshots/pipe.golden +++ b/test/snapshots/pipe.golden @@ -2,13 +2,10 @@ |Newcol Joincol Find Grep Help Changelog Tutor Dump NextColor Debug Kill | New Tty Find Grep Joincol Delcol | /tmp/pardes-snap/pipe/cwd/pipe.txt Save Tty Collapse Del -| |tr a-z A-Z -| 1 alpha beta +| 1 alpha beta |tr a-z A-Z | 2 gamma delta == snap filtered grid=180x13 cursor=17,3 |2: /tmp/pardes-snap/pipe/cwd/pipe.txt * Save Tty Collapse Del |3: 1 ALPHA BETA -|4: 2 gamma delta -|5: == snap undone grid=180x13 cursor=17,3 |3: 1 alpha beta diff --git a/test/snapshots/psearch.golden b/test/snapshots/psearch.golden index b0827d7c..b3d91b7a 100644 --- a/test/snapshots/psearch.golden +++ b/test/snapshots/psearch.golden @@ -23,28 +23,16 @@ | /+New Save Tty Collapse Del | 1 == snap typing grid=140x31 cursor=139,3 -|3: /MARK -|4: printf 'x MA''RK a\nzz\nx MA''RK b\nzz\nx MA''RK c\n' -|5: x MARK a -|6: zz -|7: x MARK b -|8: zz -|9: x MARK c +|3: printf 'x MA''RK a\nzz\nx MA''RK b\nzz\nx MA''RK c\n' /MARK == snap results grid=140x31 cursor=7,4 |3: printf 'x MA''RK a\nzz\nx MA''RK b\nzz\nx MA''RK c\n' -|4: x MARK a -|5: zz -|6: x MARK b -|7: zz -|8: x MARK c -|9: |14: /tmp/pardes-snap/psearch/cwd/+Search Save Tty Collapse Del LocationsConfig -|15: Look -|16: 1 @p0:2:3-6 -|17: 2 x MARK a -|18: 3 @p0:4:3-6 -|19: 4 x MARK b -|20: 5 @p0:6:3-6 +|15: 1 @p0:2:3-6 Look +|16: 2 x MARK a +|17: 3 @p0:4:3-6 +|18: 4 x MARK b +|19: 5 @p0:6:3-6 +|20: 6 x MARK c == style results grid=140x31 |0: 0-70 #b2c3b8,#1d2824, 71-139 d,#1d2824, |1: 0-1 #ffffff,#887455, 2-2 d,#26362d, 3-34 #becfc4,#26362d, 35-139 d,#26362d, @@ -61,12 +49,12 @@ |12: 0-0 d,#608269, 1-1 d,#0d1410, 2-139 #e5eee5,#0d1410, |13: 0-0 d,#608269, 1-1 d,#0d1410, 2-139 #e5eee5,#0d1410, |14: 0-1 #ffffff,#496656, 2-2 d,#1d2824, 3-31 #b2c3b8,#1d2824, 32-38 #d3b0d9,#1d2824, 39-76 #b2c3b8,#1d2824, 77-139 d,#1d2824, -|15: 0-0 d,#152019, 1-1 d,#0d1410, 2-135 d,#1d2824, 136-139 #b2c3b8,#1d2824, -|16: 0-0 d,#608269, 1-1 d,#0d1410, 2-15 #59675c,#0d1410, 16-139 d,#0d1410, -|17: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-8 #e5eee5,#0d1410, 9-12 #f7e4a5,#5e4923, 13-14 #e5eee5,#0d1410, 15-139 d,#0d1410, -|18: 0-0 d,#608269, 1-1 d,#0d1410, 2-15 #59675c,#0d1410, 16-139 d,#0d1410, -|19: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-8 #e5eee5,#0d1410, 9-12 #f7e4a5,#5e4923, 13-14 #e5eee5,#0d1410, 15-139 d,#0d1410, -|20: 0-0 d,#152019, 1-1 d,#0d1410, 2-15 #59675c,#0d1410, 16-139 d,#0d1410, +|15: 0-0 d,#608269, 1-1 d,#0d1410, 2-15 #59675c,#0d1410, 16-133 d,#0d1410, 134-134 d,#1d2824, 135-138 #b2c3b8,#1d2824, 139-139 d,#1d2824, +|16: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-8 #e5eee5,#0d1410, 9-12 #f7e4a5,#5e4923, 13-14 #e5eee5,#0d1410, 15-139 d,#0d1410, +|17: 0-0 d,#608269, 1-1 d,#0d1410, 2-15 #59675c,#0d1410, 16-139 d,#0d1410, +|18: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-8 #e5eee5,#0d1410, 9-12 #f7e4a5,#5e4923, 13-14 #e5eee5,#0d1410, 15-139 d,#0d1410, +|19: 0-0 d,#608269, 1-1 d,#0d1410, 2-15 #59675c,#0d1410, 16-139 d,#0d1410, +|20: 0-0 d,#152019, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-8 #e5eee5,#0d1410, 9-12 #f7e4a5,#5e4923, 13-14 #e5eee5,#0d1410, 15-139 d,#0d1410, |21: 0-1 #ffffff,#496656, 2-2 d,#1d2824, 3-3 #b2c3b8,#1d2824, 4-7 #d3b0d9,#1d2824, 8-29 #b2c3b8,#1d2824, 30-139 d,#1d2824, |22: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-139 d,#0d1410, |23: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-139 d,#0d1410, @@ -83,22 +71,11 @@ |12: /tmp/pardes-snap/psearch/cwd/+Search Save Tty Collapse Del LocationsConfig |13: 1 |15: 1 @p0:2:3-6 -|16: 2 x MARK a -|17: 3 @p0:4:3-6 -|18: 4 x MARK b -|19: 5 @p0:6:3-6 -|20: 6 x MARK c -== snap ttyinert grid=140x31 cursor=4,10 +== snap ttyinert grid=140x31 cursor=4,9 |2: $ /tmp/pardes-snap/psearch/cwd Tty Save Mode Filter Collapse Del -|3: Look -|4: $ printf 'x MA''RK a\nzz\nx MA''RK b\nzz\nx MA''RK c\n' -|5: x MARK a -|6: zz -|7: x MARK b -|8: zz -|9: x MARK c -|10: $ -== snap rightsearch grid=140x31 cursor=7,7 +|3: $ printf 'x MA''RK a\nzz\nx MA''RK b\nzz\nx MA''RK c\n' Look +|9: $ +== snap rightsearch grid=140x31 cursor=7,6 |2: /tmp/pardes-snap/psearch/cwd Tty Save Mode Filter Collapse Del -|4: printf 'x MA''RK a\nzz\nx MA''RK b\nzz\nx MA''RK c\n' -|10: +|3: printf 'x MA''RK a\nzz\nx MA''RK b\nzz\nx MA''RK c\n' Look +|9: diff --git a/test/snapshots/savepane.golden b/test/snapshots/savepane.golden index ab54ee3e..23af2bd5 100644 --- a/test/snapshots/savepane.golden +++ b/test/snapshots/savepane.golden @@ -7,14 +7,12 @@ | /tmp/pardes-snap/savepane/cwd/+New * Save Tty Collapse Del | 1 scratch bytes == snap prompt grid=100x31 cursor=99,7 -|6: Save +|6: 1 scratch bytes Save |7: Save /tmp/pardes-snap/savepane/cwd/ -|8: 1 scratch bytes -== snap saved grid=100x31 cursor=20,7 +== snap saved grid=100x31 cursor=20,6 |5: /tmp/pardes-snap/savepane/cwd/saved.txt Save Tty Collapse Del -|6: --:--:-- saved /tmp/pardes-snap/savepane/cwd/saved.txt -|7: 1 scratch bytes -|8: +|6: 1 scratch bytes --:--:-- saved /tmp/pardes-snap/savepane/cwd/saved.txt +|7: == file bytes scratch bytes == end file diff --git a/test/snapshots/selregex.golden b/test/snapshots/selregex.golden index f071fb15..e28d47a5 100644 --- a/test/snapshots/selregex.golden +++ b/test/snapshots/selregex.golden @@ -2,21 +2,20 @@ |Newcol Joincol Find Grep Help Changelog Tutor Dump NextColor Debug Kill | New Tty Find Grep Joincol Delcol | /tmp/pardes-snap/selregex/cwd/m.zig Save Tty Collapse Del TreeContext -| Select / -| 1 const one = 1; +| 1 const one = 1; Select / | 2 const two = 2; | 3 const three = 3; | 4 == snap preview grid=160x25 cursor=159,3 -|3: Select /const +|3: 1 const one = 1; Select /const == style preview grid=160x25 |0: 0-70 #b2c3b8,#1d2824, 71-159 d,#1d2824, |1: 0-1 #ffffff,#887455, 2-2 d,#26362d, 3-34 #becfc4,#26362d, 35-159 d,#26362d, |2: 0-1 #000000,#add38a, 2-2 d,#26362d, 3-32 #becfc4,#26362d, 33-37 #dfbce5,#26362d, 38-71 #becfc4,#26362d, 72-159 d,#26362d, -|3: 0-0 d,#152019, 1-1 d,#0d1410, 2-144 d,#1d2824, 145-158 #b2c3b8,#1d2824, 159-159 d,#1d2824, -|4: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-10 #f5f7ee,#3c614a, 11-11 #3c614a,#f5f7ee, 12-18 #e5eee5,#0d1410, 19-19 #f8c082,#0d1410, 20-20 #e5eee5,#0d1410, 21-159 d,#0d1410, -|5: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-10 #f5f7ee,#243a2d, 11-11 #3c614a,#f5f7ee, 12-18 #e5eee5,#0d1410, 19-19 #f8c082,#0d1410, 20-20 #e5eee5,#0d1410, 21-159 d,#0d1410, -|6: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-10 #f5f7ee,#243a2d, 11-11 #3c614a,#f5f7ee, 12-20 #e5eee5,#0d1410, 21-21 #f8c082,#0d1410, 22-22 #e5eee5,#0d1410, 23-159 d,#0d1410, +|3: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-10 #f5f7ee,#3c614a, 11-11 #3c614a,#f5f7ee, 12-18 #e5eee5,#0d1410, 19-19 #f8c082,#0d1410, 20-20 #e5eee5,#0d1410, 21-143 d,#0d1410, 144-144 d,#1d2824, 145-158 #b2c3b8,#1d2824, 159-159 d,#1d2824, +|4: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-10 #f5f7ee,#243a2d, 11-11 #3c614a,#f5f7ee, 12-18 #e5eee5,#0d1410, 19-19 #f8c082,#0d1410, 20-20 #e5eee5,#0d1410, 21-159 d,#0d1410, +|5: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-10 #f5f7ee,#243a2d, 11-11 #3c614a,#f5f7ee, 12-20 #e5eee5,#0d1410, 21-21 #f8c082,#0d1410, 22-22 #e5eee5,#0d1410, 23-159 d,#0d1410, +|6: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-159 d,#0d1410, |7: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-159 d,#0d1410, |8: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-159 d,#0d1410, |9: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-159 d,#0d1410, @@ -37,37 +36,20 @@ |24: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-159 d,#0d1410, == snap three-selected grid=160x25 cursor=11,3 |3: 1 const one = 1; -|4: 2 const two = 2; -|5: 3 const three = 3; -|6: 4 -|7: == style three-selected grid=160x25 |3: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #616f64,#0d1410,b 7-11 #f5f7ee,#3c614a, 12-18 #e5eee5,#0d1410, 19-19 #f8c082,#0d1410, 20-20 #e5eee5,#0d1410, 21-159 d,#0d1410, -|4: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-10 #f5f7ee,#243a2d, 11-11 #3c614a,#f5f7ee, 12-18 #e5eee5,#0d1410, 19-19 #f8c082,#0d1410, 20-20 #e5eee5,#0d1410, 21-159 d,#0d1410, -|5: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-10 #f5f7ee,#243a2d, 11-11 #3c614a,#f5f7ee, 12-20 #e5eee5,#0d1410, 21-21 #f8c082,#0d1410, 22-22 #e5eee5,#0d1410, 23-159 d,#0d1410, -|6: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-159 d,#0d1410, == snap narrowed grid=160x25 cursor=159,3 -|3: Select /t -|4: 1 const one = 1; -|5: 2 const two = 2; -|6: 3 const three = 3; -|7: 4 +|3: 1 const one = 1; Select /t == style narrowed grid=160x25 -|3: 0-0 d,#152019, 1-1 d,#0d1410, 2-148 d,#1d2824, 149-158 #b2c3b8,#1d2824, 159-159 d,#1d2824, +|3: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-10 #e5eee5,#0d1410, 11-11 #3c614a,#f5f7ee, 12-18 #e5eee5,#0d1410, 19-19 #f8c082,#0d1410, 20-20 #e5eee5,#0d1410, 21-147 d,#0d1410, 148-148 d,#1d2824, 149-158 #b2c3b8,#1d2824, 159-159 d,#1d2824, |4: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-10 #e5eee5,#0d1410, 11-11 #3c614a,#f5f7ee, 12-18 #e5eee5,#0d1410, 19-19 #f8c082,#0d1410, 20-20 #e5eee5,#0d1410, 21-159 d,#0d1410, -|5: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-10 #e5eee5,#0d1410, 11-11 #3c614a,#f5f7ee, 12-18 #e5eee5,#0d1410, 19-19 #f8c082,#0d1410, 20-20 #e5eee5,#0d1410, 21-159 d,#0d1410, -|6: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-10 #e5eee5,#0d1410, 11-11 #3c614a,#f5f7ee, 12-20 #e5eee5,#0d1410, 21-21 #f8c082,#0d1410, 22-22 #e5eee5,#0d1410, 23-159 d,#0d1410, +|5: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-10 #e5eee5,#0d1410, 11-11 #3c614a,#f5f7ee, 12-20 #e5eee5,#0d1410, 21-21 #f8c082,#0d1410, 22-22 #e5eee5,#0d1410, 23-159 d,#0d1410, == snap esc-restores grid=160x25 cursor=11,3 |3: 1 const one = 1; -|4: 2 const two = 2; -|5: 3 const three = 3; -|6: 4 -|7: == style esc-restores grid=160x25 |3: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #616f64,#0d1410,b 7-11 #f5f7ee,#3c614a, 12-18 #e5eee5,#0d1410, 19-19 #f8c082,#0d1410, 20-20 #e5eee5,#0d1410, 21-159 d,#0d1410, |4: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-10 #f5f7ee,#243a2d, 11-11 #3c614a,#f5f7ee, 12-18 #e5eee5,#0d1410, 19-19 #f8c082,#0d1410, 20-20 #e5eee5,#0d1410, 21-159 d,#0d1410, |5: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-10 #f5f7ee,#243a2d, 11-11 #3c614a,#f5f7ee, 12-20 #e5eee5,#0d1410, 21-21 #f8c082,#0d1410, 22-22 #e5eee5,#0d1410, 23-159 d,#0d1410, -|6: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-159 d,#0d1410, == snap commented grid=160x25 cursor=14,3 |2: /tmp/pardes-snap/selregex/cwd/m.zig * Save Tty Collapse Del TreeContext |3: 1 // const one = 1; diff --git a/test/snapshots/shellset.golden b/test/snapshots/shellset.golden index 777bb102..d4ab24d9 100644 --- a/test/snapshots/shellset.golden +++ b/test/snapshots/shellset.golden @@ -3,9 +3,8 @@ | New Tty Find Grep Joincol Delcol | /tmp/pardes-snap/shellset/cwd/cmd.txt Save Tty Collapse Del | 1 Shell zznosuchshell -== snap builtin-ran grid=90x21 cursor=25,4 -|3: Shell -|4: 1 Shell zznosuchshell +== snap builtin-ran grid=90x21 cursor=25,3 +|3: 1 Shell zznosuchshell Shell == snap fallback-shell grid=90x21 cursor=49,5 |1: New Tty Find Grep Joincol Delcol New Tty Find Grep Joincol Delcol |2: /tmp/pardes-snap/shellset/cwd/cmd.txt Save /tmp/pardes-snap/shellset/cwd Tty Save Mod diff --git a/test/snapshots/stepgrain.golden b/test/snapshots/stepgrain.golden index b8b4dca2..ff39676d 100644 --- a/test/snapshots/stepgrain.golden +++ b/test/snapshots/stepgrain.golden @@ -93,4 +93,4 @@ == snap blank-opened grid=150x31 cursor=7,13 |12: /tmp/pardes-snap/stepgrain/cwd/two words.txt Save Tty Collapse Del |13: 1 -|23: Look +|23: 1 two words.txt Look diff --git a/test/snapshots/syntax.golden b/test/snapshots/syntax.golden index 5b2811f7..ab14a815 100644 --- a/test/snapshots/syntax.golden +++ b/test/snapshots/syntax.golden @@ -2,9 +2,9 @@ |Newcol Joincol Find Grep Help Changelog Tutor Dump NextColor Debug Kill | New Tty Find Grep Joincol Delcol New Tty Find Grep Joincol Delcol | /tmp/pardes-snap/syntax/cwd Tty Save Mode Filter Collapse Del /tmp/pardes-snap/syntax/cwd Tty Save Mode Filter Collapse Del -| Look ls -| ls demo.zig -| demo.zig +| ls Look ls +| demo.zig demo.zig +| | /tmp/pardes-snap/syntax/cwd/demo.zig Save Tty Collapse Del TreeContext | 1 const std = @import("std"); // greet | 2 pub fn main() void { @@ -23,9 +23,9 @@ |0: 0-70 #b2c3b8,#1d2824, 71-149 d,#1d2824, |1: 0-1 #ffffff,#887455, 2-2 d,#26362d, 3-34 #becfc4,#26362d, 35-74 d,#26362d, 75-76 #ffffff,#887455, 77-77 d,#1d2824, 78-109 #b2c3b8,#1d2824, 110-149 d,#1d2824, |2: 0-1 #ffffff,#496656, 2-2 d,#1d2824, 3-30 #b2c3b8,#1d2824, 31-33 #d3b0d9,#1d2824, 34-63 #b2c3b8,#1d2824, 64-74 d,#1d2824, 75-76 #ffffff,#496656, 77-77 d,#1d2824, 78-105 #b2c3b8,#1d2824, 106-108 #d3b0d9,#1d2824, 109-138 #b2c3b8,#1d2824, 139-149 d,#1d2824, -|3: 0-0 d,#152019, 1-1 d,#0d1410, 2-70 d,#1d2824, 71-74 #b2c3b8,#1d2824, 75-75 d,#608269, 76-76 d,#0d1410, 77-149 #e5eee5,#0d1410, +|3: 0-0 d,#608269, 1-1 d,#0d1410, 2-68 #e5eee5,#0d1410, 69-69 d,#1d2824, 70-73 #b2c3b8,#1d2824, 74-74 d,#1d2824, 75-75 d,#608269, 76-76 d,#0d1410, 77-149 #e5eee5,#0d1410, |4: 0-0 d,#608269, 1-1 d,#0d1410, 2-74 #e5eee5,#0d1410, 75-75 d,#608269, 76-76 d,#0d1410, 77-149 #e5eee5,#0d1410, -|5: 0-0 d,#608269, 1-1 d,#0d1410, 2-74 #e5eee5,#0d1410, 75-75 d,#608269, 76-149 d,#0d1410, +|5: 0-0 d,#608269, 1-74 d,#0d1410, 75-75 d,#608269, 76-149 d,#0d1410, |6: 0-1 #000000,#add38a, 2-2 d,#26362d, 3-30 #becfc4,#26362d, 31-38 #dfbce5,#26362d, 39-72 #becfc4,#26362d, 73-74 d,#26362d, 75-75 d,#608269, 76-76 d,#0d1410, 77-149 #e5eee5,#0d1410, |7: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #616f64,#0d1410,b 7-18 #e5eee5,#0d1410, 19-25 #c9a7ed,#0d1410, 26-26 #e5eee5,#0d1410, 27-31 #b8d88a,#0d1410, 32-34 #e5eee5,#0d1410, 35-42 #b9f480,#0d1410, 43-74 d,#0d1410, 75-75 d,#608269, 76-76 d,#0d1410, 77-149 #e5eee5,#0d1410, |8: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-10 #e5eee5,#0d1410, 11-12 #c9a7ed,#0d1410, 13-26 #e5eee5,#0d1410, 27-74 d,#0d1410, 75-75 d,#608269, 76-76 d,#0d1410, 77-149 #e5eee5,#0d1410, @@ -54,14 +54,13 @@ == style colors-off grid=150x31 |3: 0-0 d,#608269, 1-1 d,#0d1410, 2-3 #e5eee5,#0d1410, 4-74 d,#0d1410, 75-75 d,#608269, 76-76 d,#0d1410, 77-78 #e5eee5,#0d1410, 79-149 d,#0d1410, |4: 0-0 d,#608269, 1-1 d,#0d1410, 2-9 #e5eee5,#0d1410, 10-74 d,#0d1410, 75-75 d,#608269, 76-76 d,#0d1410, 77-84 #e5eee5,#0d1410, 85-149 d,#0d1410, -|5: 0-0 d,#608269, 1-74 d,#0d1410, 75-75 d,#608269, 76-149 d,#0d1410, |6: 0-1 #000000,#add38a, 2-2 d,#26362d, 3-30 #becfc4,#26362d, 31-38 #dfbce5,#26362d, 39-72 #becfc4,#26362d, 73-74 d,#26362d, 75-75 d,#608269, 76-149 d,#0d1410, -|7: 0-0 d,#152019, 1-1 d,#0d1410, 2-68 d,#1d2824, 69-74 #b2c3b8,#1d2824, 75-75 d,#608269, 76-149 d,#0d1410, -|8: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #616f64,#0d1410,b 7-42 #e5eee5,#0d1410, 43-74 d,#0d1410, 75-75 d,#608269, 76-149 d,#0d1410, +|7: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #616f64,#0d1410,b 7-42 #e5eee5,#0d1410, 43-66 d,#0d1410, 67-67 d,#1d2824, 68-73 #b2c3b8,#1d2824, 74-74 d,#1d2824, 75-75 d,#608269, 76-149 d,#0d1410, +|8: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-26 #e5eee5,#0d1410, 27-74 d,#0d1410, 75-75 d,#608269, 76-149 d,#0d1410, |9: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-26 #e5eee5,#0d1410, 27-74 d,#0d1410, 75-75 d,#608269, 76-149 d,#0d1410, -|10: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-26 #e5eee5,#0d1410, 27-74 d,#0d1410, 75-75 d,#608269, 76-149 d,#0d1410, -|11: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-16 #e5eee5,#0d1410, 17-74 d,#0d1410, 75-75 d,#608269, 76-149 d,#0d1410, -|12: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-7 #e5eee5,#0d1410, 8-74 d,#0d1410, 75-75 d,#608269, 76-149 d,#0d1410, +|10: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-16 #e5eee5,#0d1410, 17-74 d,#0d1410, 75-75 d,#608269, 76-149 d,#0d1410, +|11: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-7 #e5eee5,#0d1410, 8-74 d,#0d1410, 75-75 d,#608269, 76-149 d,#0d1410, +|12: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-74 d,#0d1410, 75-75 d,#608269, 76-149 d,#0d1410, |13: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-74 d,#0d1410, 75-75 d,#608269, 76-149 d,#0d1410, |14: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-74 d,#0d1410, 75-75 d,#608269, 76-149 d,#0d1410, |15: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-74 d,#0d1410, 75-75 d,#608269, 76-149 d,#0d1410, @@ -84,12 +83,12 @@ |3: 0-0 d,#608269, 1-1 d,#0d1410, 2-74 #e5eee5,#0d1410, 75-75 d,#608269, 76-76 d,#0d1410, 77-149 #e5eee5,#0d1410, |4: 0-0 d,#608269, 1-1 d,#0d1410, 2-74 #e5eee5,#0d1410, 75-75 d,#608269, 76-76 d,#0d1410, 77-149 #e5eee5,#0d1410, |6: 0-1 #000000,#add38a, 2-2 d,#26362d, 3-30 #becfc4,#26362d, 31-38 #dfbce5,#26362d, 39-72 #becfc4,#26362d, 73-74 d,#26362d, 75-75 d,#608269, 76-76 d,#0d1410, 77-149 #e5eee5,#0d1410, -|7: 0-0 d,#152019, 1-1 d,#0d1410, 2-68 d,#1d2824, 69-74 #b2c3b8,#1d2824, 75-75 d,#608269, 76-76 d,#0d1410, 77-149 #e5eee5,#0d1410, -|8: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #616f64,#0d1410,b 7-18 #e5eee5,#0d1410, 19-25 #c9a7ed,#0d1410, 26-26 #e5eee5,#0d1410, 27-31 #b8d88a,#0d1410, 32-34 #e5eee5,#0d1410, 35-42 #b9f480,#0d1410, 43-74 d,#0d1410, 75-75 d,#608269, 76-76 d,#0d1410, 77-149 #e5eee5,#0d1410, -|9: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-10 #e5eee5,#0d1410, 11-12 #c9a7ed,#0d1410, 13-26 #e5eee5,#0d1410, 27-74 d,#0d1410, 75-75 d,#608269, 76-76 d,#0d1410, 77-149 #e5eee5,#0d1410, -|10: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-23 #e5eee5,#0d1410, 24-25 #f8c082,#0d1410, 26-26 #e5eee5,#0d1410, 27-74 d,#0d1410, 75-75 d,#608269, 76-76 d,#0d1410, 77-149 #e5eee5,#0d1410, -|11: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-16 #e5eee5,#0d1410, 17-74 d,#0d1410, 75-75 d,#608269, 76-76 d,#0d1410, 77-149 #e5eee5,#0d1410, -|12: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-7 #e5eee5,#0d1410, 8-74 d,#0d1410, 75-75 d,#608269, 76-76 d,#0d1410, 77-149 #e5eee5,#0d1410, +|7: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #616f64,#0d1410,b 7-18 #e5eee5,#0d1410, 19-25 #c9a7ed,#0d1410, 26-26 #e5eee5,#0d1410, 27-31 #b8d88a,#0d1410, 32-34 #e5eee5,#0d1410, 35-42 #b9f480,#0d1410, 43-66 d,#0d1410, 67-67 d,#1d2824, 68-73 #b2c3b8,#1d2824, 74-74 d,#1d2824, 75-75 d,#608269, 76-76 d,#0d1410, 77-149 #e5eee5,#0d1410, +|8: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-10 #e5eee5,#0d1410, 11-12 #c9a7ed,#0d1410, 13-26 #e5eee5,#0d1410, 27-74 d,#0d1410, 75-75 d,#608269, 76-76 d,#0d1410, 77-149 #e5eee5,#0d1410, +|9: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-23 #e5eee5,#0d1410, 24-25 #f8c082,#0d1410, 26-26 #e5eee5,#0d1410, 27-74 d,#0d1410, 75-75 d,#608269, 76-76 d,#0d1410, 77-149 #e5eee5,#0d1410, +|10: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-16 #e5eee5,#0d1410, 17-74 d,#0d1410, 75-75 d,#608269, 76-76 d,#0d1410, 77-149 #e5eee5,#0d1410, +|11: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-7 #e5eee5,#0d1410, 8-74 d,#0d1410, 75-75 d,#608269, 76-76 d,#0d1410, 77-149 #e5eee5,#0d1410, +|12: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-74 d,#0d1410, 75-75 d,#608269, 76-76 d,#0d1410, 77-149 #e5eee5,#0d1410, |13: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-74 d,#0d1410, 75-75 d,#608269, 76-76 d,#0d1410, 77-149 #e5eee5,#0d1410, |14: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-74 d,#0d1410, 75-75 d,#608269, 76-76 d,#0d1410, 77-149 #e5eee5,#0d1410, |15: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-74 d,#0d1410, 75-75 d,#608269, 76-76 d,#0d1410, 77-149 #e5eee5,#0d1410, diff --git a/test/snapshots/tag.golden b/test/snapshots/tag.golden index 5e4cb4d1..a07f7a0f 100644 --- a/test/snapshots/tag.golden +++ b/test/snapshots/tag.golden @@ -26,8 +26,6 @@ == snap tag-exit grid=150x31 cursor=4,5 |2: /tmp/pardes-snap/tag/cwd Tty t.txt Save Mode Filter Collapse Del /tmp/pardes-snap/tag/cwd Tty Save Mode Filter Collapse Del == snap tag-look grid=150x31 cursor=7,7 -|3: Look ls -|4: ls t.txt -|5: t.txt +|3: ls Look ls |6: /tmp/pardes-snap/tag/cwd/t.txt Save Tty Collapse Del |7: 1 ZZLOOKED diff --git a/test/snapshots/tagalign2col.golden b/test/snapshots/tagalign2col.golden index e703dbef..afa1c1ec 100644 --- a/test/snapshots/tagalign2col.golden +++ b/test/snapshots/tagalign2col.golden @@ -2,13 +2,11 @@ |Newcol Joincol Find Grep Help Changelog Tutor Dump NextColor Debug Kill | New Tty Find Grep Joincol Delcol New Tty Find Grep Joincol Delcol | /tmp/pardes-snap/tagalign2col/cwd/deep/proj/document.txt Save Tty Collapse De /tmp/pardes-snap/tagalign2col/cwd Tty Save Mode Filter Collapse Del -| 1 alpha Left -| 2 beta ls -| 3 gamma deep +| 1 alpha ls Left +| 2 beta deep +| 3 gamma == snap aligned grid=160x31 cursor=4,20 |3: 1 alpha ls -|4: 2 beta deep -|5: 3 gamma |17: /tmp/pardes-snap/tagalign2col/cwd Tty Save Mode Filter Collapse Del |18: ls |19: deep diff --git a/test/snapshots/tagbottom.golden b/test/snapshots/tagbottom.golden index eb1d67fd..95ef0529 100644 --- a/test/snapshots/tagbottom.golden +++ b/test/snapshots/tagbottom.golden @@ -151,11 +151,9 @@ |9: 9 iii |10: 10 jjj == snap search-prompt grid=100x31 cursor=99,12 -|12: /ZZ -|13: 1 ZZONE -|14: 2 ZZTWO -== snap leader grid=100x31 cursor=9,14 -|12: SPC +|12: 1 ZZONE /ZZ +== snap leader grid=100x31 cursor=9,13 +|12: 1 ZZONE SPC == snap cut-down grid=100x31 cursor=7,5 |2: 1 aaa |3: 2 bbb @@ -168,8 +166,6 @@ |10: 9 ooo |11: /tmp/pardes-snap/tagbottom/cwd/top.txt * Save Tty Collapse Del bottom.txt |12: 1 ZZONE -|13: 2 ZZTWO -|14: == file cut-buffer aaa bbb diff --git a/test/snapshots/tagbottomimage.golden b/test/snapshots/tagbottomimage.golden index 72352672..e7100114 100644 --- a/test/snapshots/tagbottomimage.golden +++ b/test/snapshots/tagbottomimage.golden @@ -2,9 +2,9 @@ |Newcol Joincol Find Grep Help Changelog Tutor Dump NextColor Debug Kill | New Tty Find Grep Joincol Delcol | /tmp/pardes-snap/tagbottomimage/cwd Tty Save Mode Filter Collapse Del -| Look -| ls +| ls Look | pic.ppm +| | img petscii:off palette:commodore ascii:on /tmp/pardes-snap/tagbottomimage/cwd/pic.ppm Tty Collapse Del | 4*🬹~F~N🬰|GðŸ¬�â–šY~KF🬴s>T&zZ/🬻iTY=`S~╳bkZR37v🬦🬵d4QHZ8X▛▟ @@ -35,30 +35,30 @@ |3: pic.ppm |4: |5: /tmp/pardes-snap/tagbottomimage/cwd Tty Save Mode Filter Collapse Del -|6: Tagbottom -|7: {DbgY🬲sâ–œM^#â–�FUJ[zNq=ðŸ¬�g/y╱?V@🬱🬙▌UK╱ðŸ¬�("🬕KJ8hSoðŸ¬�🬻 -|8: tX🬆s>🬌`🬵>T&zZ/🬻iTY=`S~╳bkZR37v🬦🬵d4QHZ8X▛▟ +|8: ^🬪🬛$}DrydNU&wsz=`*r🬒🬓🬳🬟*Y🬴G6🬧f🬮/>t🬧u🬲1Rg1tðŸ¬�🬻█ +|9: â––#_{🬗X@🬢&$s'C%*=w@🬆▀wq%🬡d┼a┼m─>🬭🬜Aâ–€A🬲H]pðŸ¬�🬹 +|10: %?WX🬕f🬩*TA8n╱┼E▘🬭Y#qo~XVEâ–�(╳▀H4^[mj🬗=🬒🬕▟█ +|11: ]Z🬷eb~Oyl3=SLâ–™a🬱🬉~MPMz}FMu<ðŸ¬�â–š>3&▖🬷WSðŸ¬�~â–ˆ +|12: EF-🬑y🬔!r🬙ðŸ¬�╳O🬩â–�%Qj─4za/?/\a🬜"🬖🬈🬛🬟A🬙ðŸ¬�â–„ +|13: 🬃N@xzOnczIK=t0@🬖j5🬮🬧65â–Ÿ{🬮🬉🬄🬩zQ9/ðŸ¬�🬻 +|14: ╲${&%@"#cttâ–€Cr5F;ðŸ¬�ARM╱uej╳75🬹9▛🬻 +|15: h^🬜"🬈🬨▜╲|W🬊🬦k6^🬰🬶rZ─▄\z9🬎🬉4^🬎🬻 +|16: 🬆f│Q_V🬗wGx🬱=5â–›5*&V🬟🬄ZrXGz2ðŸ¬�🬻█ +|17: !🬷WðŸ¬�(🬭]7x_>â–—er🬯~â–šdi🬬4jY:ðŸ¬�â–Ÿ +|18: gU~🬧3â–™bjr\C#kKMpffAjpsðŸ¬�🬻 +|19: *🬯G"🬣▟d🬮▀zJ🬪EHV▟╳9}y▛▄ +|20: ``))~RyJ🬴jA~w=hLpXðŸ¬�🬻█ +|21: 4xâ–€J"TG7=y-QZ🬙╲~▛🬻 +|22: 🬯/+╳f9ZG🬕+{QN_ðŸ¬�🬹 +|23: E<'─🬫pS!"n4&ðŸ¬�~ +|24: m$dx"!2🬳&{ðŸ¬�🬻 +|25: *8f🬩▙Jb🬒ðŸ¬�🬻█ +|26: m🬩7CiN🬎🬹 +|27: pG╲LðŸ¬�🬻 +|28: 🬡LðŸ¬�â–„ +|29: ðŸ¬�~ |30: img petscii:off palette:commodore ascii:on /tmp/pardes-snap/tagbottomimage/cwd/pic.ppm Tty Collapse Del == style img-bottom grid=150x31 |0: 0-70 #b2c3b8,#1d2824, 71-149 d,#1d2824, @@ -67,33 +67,33 @@ |3: 0-0 d,#608269, 1-1 d,#0d1410, 2-149 #e5eee5,#0d1410, |4: 0-0 d,#608269, 1-149 d,#0d1410, |5: 0-1 #ffffff,#496656, 2-2 d,#1d2824, 3-38 #b2c3b8,#1d2824, 39-41 #d3b0d9,#1d2824, 42-71 #b2c3b8,#1d2824, 72-149 d,#1d2824, -|6: 0-0 d,#152019, 1-1 d,#0d1410, 2-140 d,#1d2824, 141-149 #b2c3b8,#1d2824, -|7: 0-0 d,#152019, 1-52 d,#0d1410, 53-55 #959595,#6c6c6c, 56-56 #6c6c6c,#959595, 57-57 #959595,#6c6c6c, 58-58 #6c6c6c,#959595, 59-60 #959595,#6c6c6c, 61-63 #6c6c6c,#959595, 64-65 #959595,#6c6c6c, 66-66 #6c6c6c,#959595, 67-71 #959595,#6c6c6c, 72-72 #6c6c6c,#959595, 73-73 #959595,#6c6c6c, 74-76 #6c6c6c,#959595, 77-77 #959595,#6c6c6c, 78-81 #6c6c6c,#959595, 82-84 #959595,#6c6c6c, 85-85 #6c6c6c,#959595, 86-87 #959595,#6c6c6c, 88-88 #6c6c6c,#959595, 89-89 #959595,#6c6c6c, 90-90 #6c6c6c,#959595, 91-92 #959595,#6c6c6c, 93-96 #6c6c6c,#959595, 97-97 #6c6c6c,#352879, 98-98 #352879,#959595, 99-149 d,#0d1410, -|8: 0-0 d,#152019, 1-52 d,#0d1410, 53-58 #959595,#6c6c6c, 59-59 #444444,#959595, 60-64 #959595,#6c6c6c, 65-66 #6c6c6c,#959595, 67-71 #959595,#6c6c6c, 72-72 #444444,#959595, 73-73 #959595,#6c6c6c, 74-74 #6c6c6c,#959595, 75-75 #959595,#6c6c6c, 76-76 #444444,#959595, 77-81 #6c6c6c,#959595, 82-82 #959595,#6c6c6c, 83-85 #6c6c6c,#959595, 86-87 #959595,#6c6c6c, 88-89 #6c6c6c,#959595, 90-90 #959595,#6c6c6c, 91-92 #6c6c6c,#959595, 93-93 #959595,#6c6c6c, 94-94 #6c6c6c,#959595, 95-95 #6c6c6c,#352879, 96-96 #352879,#959595, 97-97 #352879,#6c5eb5, 98-98 #352879,#352879, 99-149 d,#0d1410, -|9: 0-0 d,#152019, 1-52 d,#0d1410, 53-57 #959595,#6c6c6c, 58-58 #6c6c6c,#959595, 59-59 #959595,#6c6c6c, 60-60 #6c6c6c,#959595, 61-62 #959595,#6c6c6c, 63-63 #6c6c6c,#959595, 64-67 #959595,#6c6c6c, 68-68 #6c6c6c,#959595, 69-70 #959595,#6c6c6c, 71-71 #6c6c6c,#959595, 72-73 #959595,#6c6c6c, 74-75 #6c6c6c,#959595, 76-77 #959595,#6c6c6c, 78-79 #6c6c6c,#959595, 80-82 #959595,#6c6c6c, 83-86 #6c6c6c,#959595, 87-90 #959595,#6c6c6c, 91-91 #6c6c6c,#959595, 92-92 #959595,#6c6c6c, 93-93 #6c6c6c,#352879, 94-94 #352879,#6c6c6c, 95-98 #352879,#352879, 99-149 d,#0d1410, -|10: 0-0 d,#152019, 1-52 d,#0d1410, 53-53 #6c6c6c,#959595, 54-54 #959595,#6c6c6c, 55-55 #6c6c6c,#959595, 56-59 #959595,#6c6c6c, 60-60 #6c6c6c,#959595, 61-61 #959595,#6c6c6c, 62-63 #6c6c6c,#959595, 64-64 #959595,#6c6c6c, 65-65 #6c6c6c,#959595, 66-67 #959595,#6c6c6c, 68-71 #6c6c6c,#959595, 72-75 #959595,#6c6c6c, 76-77 #6c6c6c,#959595, 78-78 #959595,#6c6c6c, 79-79 #6c6c6c,#959595, 80-81 #959595,#6c6c6c, 82-83 #6c6c6c,#959595, 84-86 #959595,#6c6c6c, 87-87 #6c6c6c,#959595, 88-90 #959595,#6c6c6c, 91-92 #6c6c6c,#352879, 93-93 #352879,#6c5eb5, 94-98 #352879,#352879, 99-149 d,#0d1410, -|11: 0-0 d,#152019, 1-52 d,#0d1410, 53-54 #6c6c6c,#959595, 55-55 #959595,#6c6c6c, 56-56 #6c6c6c,#959595, 57-57 #959595,#6c6c6c, 58-59 #6c6c6c,#959595, 60-62 #959595,#6c6c6c, 63-63 #6c6c6c,#959595, 64-64 #959595,#6c6c6c, 65-65 #6c6c6c,#959595, 66-66 #959595,#6c6c6c, 67-70 #6c6c6c,#959595, 71-73 #959595,#6c6c6c, 74-74 #6c6c6c,#959595, 75-77 #959595,#6c6c6c, 78-80 #6c6c6c,#959595, 81-82 #959595,#6c6c6c, 83-83 #6c6c6c,#959595, 84-85 #959595,#6c6c6c, 86-86 #6c6c6c,#959595, 87-88 #959595,#6c6c6c, 89-89 #959595,#352879, 90-90 #352879,#6c6c6c, 91-98 #352879,#352879, 99-149 d,#0d1410, -|12: 0-0 d,#152019, 1-52 d,#0d1410, 53-54 #6c6c6c,#959595, 55-55 #959595,#6c6c6c, 56-56 #6c6c6c,#959595, 57-58 #959595,#6c6c6c, 59-59 #6c6c6c,#959595, 60-60 #959595,#6c6c6c, 61-61 #6c6c6c,#959595, 62-64 #959595,#6c6c6c, 65-66 #6c6c6c,#959595, 67-69 #959595,#6c6c6c, 70-70 #6c6c6c,#959595, 71-72 #959595,#6c6c6c, 73-74 #6c6c6c,#959595, 75-75 #959595,#6c6c6c, 76-77 #6c6c6c,#959595, 78-83 #959595,#6c6c6c, 84-86 #6c6c6c,#959595, 87-87 #959595,#352879, 88-88 #352879,#6c6c6c, 89-98 #352879,#352879, 99-149 d,#0d1410, -|13: 0-0 d,#152019, 1-52 d,#0d1410, 53-58 #959595,#6c6c6c, 59-59 #6c6c6c,#959595, 60-62 #959595,#6c6c6c, 63-64 #6c6c6c,#959595, 65-68 #959595,#6c6c6c, 69-69 #6c6c6c,#959595, 70-72 #959595,#6c6c6c, 73-73 #6c6c6c,#959595, 74-77 #959595,#6c6c6c, 78-79 #6c6c6c,#959595, 80-81 #959595,#6c6c6c, 82-83 #6c6c6c,#959595, 84-84 #959595,#6c6c6c, 85-85 #6c6c6c,#352879, 86-86 #959595,#352879, 87-87 #352879,#6c5eb5, 88-98 #352879,#352879, 99-149 d,#0d1410, -|14: 0-0 d,#152019, 1-52 d,#0d1410, 53-53 #959595,#6c6c6c, 54-54 #6c6c6c,#959595, 55-55 #959595,#6c6c6c, 56-56 #6c6c6c,#959595, 57-58 #959595,#6c6c6c, 59-59 #6c6c6c,#959595, 60-60 #959595,#6c6c6c, 61-61 #6c6c6c,#959595, 62-62 #959595,#6c6c6c, 63-64 #6c6c6c,#959595, 65-71 #959595,#6c6c6c, 72-73 #6c6c6c,#959595, 74-76 #959595,#6c6c6c, 77-77 #6c6c6c,#959595, 78-79 #959595,#6c6c6c, 80-80 #6c6c6c,#959595, 81-82 #959595,#6c6c6c, 83-83 #6c6c6c,#352879, 84-84 #959595,#352879, 85-85 #352879,#6c5eb5, 86-98 #352879,#352879, 99-149 d,#0d1410, -|15: 0-0 d,#152019, 1-52 d,#0d1410, 53-53 #6c6c6c,#959595, 54-55 #959595,#6c6c6c, 56-56 #6c6c6c,#959595, 57-60 #959595,#6c6c6c, 61-63 #6c6c6c,#959595, 64-64 #959595,#6c6c6c, 65-65 #6c6c6c,#959595, 66-66 #959595,#6c6c6c, 67-67 #6c6c6c,#959595, 68-70 #959595,#6c6c6c, 71-72 #6c6c6c,#959595, 73-75 #959595,#6c6c6c, 76-77 #6c6c6c,#959595, 78-79 #959595,#6c6c6c, 80-80 #6c6c6c,#959595, 81-81 #959595,#352879, 82-82 #352879,#6c5eb5, 83-98 #352879,#352879, 99-149 d,#0d1410, -|16: 0-0 d,#152019, 1-52 d,#0d1410, 53-57 #959595,#6c6c6c, 58-58 #6c6c6c,#959595, 59-60 #959595,#6c6c6c, 61-61 #6c6c6c,#959595, 62-63 #959595,#6c6c6c, 64-64 #6c6c6c,#959595, 65-66 #959595,#6c6c6c, 67-67 #6c6c6c,#959595, 68-68 #959595,#6c6c6c, 69-69 #6c6c6c,#959595, 70-70 #959595,#6c6c6c, 71-72 #6c6c6c,#959595, 73-78 #959595,#6c6c6c, 79-79 #6c6c6c,#352879, 80-80 #959595,#352879, 81-81 #352879,#6c5eb5, 82-98 #352879,#352879, 99-149 d,#0d1410, -|17: 0-0 d,#152019, 1-52 d,#0d1410, 53-54 #959595,#6c6c6c, 55-56 #6c6c6c,#959595, 57-58 #959595,#6c6c6c, 59-60 #6c6c6c,#959595, 61-62 #959595,#6c6c6c, 63-63 #6c6c6c,#959595, 64-64 #959595,#6c6c6c, 65-67 #6c6c6c,#959595, 68-68 #959595,#6c6c6c, 69-72 #6c6c6c,#959595, 73-74 #959595,#6c6c6c, 75-75 #6c6c6c,#959595, 76-76 #959595,#6c6c6c, 77-77 #6c6c6c,#352879, 78-78 #352879,#959595, 79-98 #352879,#352879, 99-149 d,#0d1410, -|18: 0-0 d,#152019, 1-52 d,#0d1410, 53-54 #959595,#6c6c6c, 55-55 #6c6c6c,#959595, 56-60 #959595,#6c6c6c, 61-61 #6c6c6c,#959595, 62-62 #959595,#6c6c6c, 63-63 #444444,#6c6c6c, 64-66 #959595,#6c6c6c, 67-68 #6c6c6c,#959595, 69-71 #959595,#6c6c6c, 72-73 #6c6c6c,#959595, 74-74 #959595,#6c6c6c, 75-76 #6c6c6c,#352879, 77-98 #352879,#352879, 99-149 d,#0d1410, -|19: 0-0 d,#152019, 1-52 d,#0d1410, 53-53 #6c6c6c,#959595, 54-55 #959595,#6c6c6c, 56-56 #6c6c6c,#959595, 57-59 #959595,#6c6c6c, 60-60 #6c6c6c,#959595, 61-61 #959595,#6c6c6c, 62-64 #6c6c6c,#959595, 65-68 #959595,#6c6c6c, 69-69 #6c6c6c,#959595, 70-72 #959595,#6c6c6c, 73-73 #6c6c6c,#352879, 74-74 #352879,#6c6c6c, 75-98 #352879,#352879, 99-149 d,#0d1410, -|20: 0-0 d,#152019, 1-52 d,#0d1410, 53-53 #6c6c6c,#959595, 54-56 #959595,#6c6c6c, 57-57 #6c6c6c,#959595, 58-58 #959595,#6c6c6c, 59-59 #6c6c6c,#959595, 60-60 #959595,#6c6c6c, 61-61 #6c6c6c,#959595, 62-63 #959595,#6c6c6c, 64-64 #6c6c6c,#959595, 65-70 #959595,#6c6c6c, 71-71 #959595,#352879, 72-72 #352879,#6c6c6c, 73-98 #352879,#352879, 99-149 d,#0d1410, -|21: 0-0 d,#152019, 1-52 d,#0d1410, 53-53 #6c6c6c,#959595, 54-55 #959595,#6c6c6c, 56-56 #6c6c6c,#959595, 57-59 #959595,#6c6c6c, 60-60 #6c6c6c,#959595, 61-63 #959595,#6c6c6c, 64-65 #6c6c6c,#959595, 66-68 #959595,#6c6c6c, 69-69 #959595,#352879, 70-70 #352879,#6c6c6c, 71-71 #352879,#6c5eb5, 72-98 #352879,#352879, 99-149 d,#0d1410, -|22: 0-0 d,#152019, 1-52 d,#0d1410, 53-55 #6c6c6c,#959595, 56-58 #959595,#6c6c6c, 59-59 #6c6c6c,#959595, 60-60 #959595,#6c6c6c, 61-61 #6c6c6c,#959595, 62-65 #959595,#6c6c6c, 66-66 #6c6c6c,#959595, 67-67 #6c6c6c,#352879, 68-68 #352879,#6c6c6c, 69-98 #352879,#352879, 99-149 d,#0d1410, -|23: 0-0 d,#152019, 1-52 d,#0d1410, 53-53 #6c6c6c,#959595, 54-57 #959595,#6c6c6c, 58-59 #6c6c6c,#959595, 60-61 #959595,#6c6c6c, 62-62 #6c6c6c,#959595, 63-64 #959595,#6c6c6c, 65-65 #6c6c6c,#352879, 66-66 #959595,#352879, 67-98 #352879,#352879, 99-149 d,#0d1410, -|24: 0-0 d,#152019, 1-52 d,#0d1410, 53-60 #959595,#6c6c6c, 61-61 #6c6c6c,#959595, 62-62 #959595,#6c6c6c, 63-64 #959595,#352879, 65-98 #352879,#352879, 99-149 d,#0d1410, -|25: 0-0 d,#152019, 1-52 d,#0d1410, 53-56 #959595,#6c6c6c, 57-60 #6c6c6c,#959595, 61-61 #6c6c6c,#352879, 62-63 #352879,#6c5eb5, 64-98 #352879,#352879, 99-149 d,#0d1410, -|26: 0-0 d,#152019, 1-52 d,#0d1410, 53-57 #959595,#6c6c6c, 58-58 #6c6c6c,#959595, 59-59 #6c6c6c,#352879, 60-60 #352879,#6c5eb5, 61-98 #352879,#352879, 99-149 d,#0d1410, -|27: 0-0 d,#152019, 1-52 d,#0d1410, 53-54 #959595,#6c6c6c, 55-56 #6c6c6c,#959595, 57-57 #6c6c6c,#352879, 58-58 #959595,#352879, 59-59 #352879,#6c5eb5, 60-98 #352879,#352879, 99-149 d,#0d1410, -|28: 0-0 d,#152019, 1-52 d,#0d1410, 53-54 #959595,#6c6c6c, 55-55 #6c6c6c,#352879, 56-56 #352879,#6c6c6c, 57-98 #352879,#352879, 99-149 d,#0d1410, -|29: 0-0 d,#152019, 1-52 d,#0d1410, 53-53 #352879,#6c6c6c, 54-54 #352879,#959595, 55-55 #352879,#6c5eb5, 56-98 #352879,#352879, 99-149 d,#0d1410, +|6: 0-0 d,#152019, 1-51 d,#0d1410, 52-59 #959595,#6c6c6c, 60-60 #6c6c6c,#959595, 61-65 #959595,#6c6c6c, 66-66 #6c6c6c,#959595, 67-70 #959595,#6c6c6c, 71-73 #6c6c6c,#959595, 74-75 #959595,#6c6c6c, 76-76 #6c6c6c,#959595, 77-84 #959595,#6c6c6c, 85-85 #6c6c6c,#959595, 86-90 #959595,#6c6c6c, 91-91 #6c6c6c,#959595, 92-95 #959595,#6c6c6c, 96-97 #6c6c6c,#959595, 98-98 #959595,#352879, 99-99 #352879,#959595, 100-138 d,#0d1410, 139-139 d,#1d2824, 140-148 #b2c3b8,#1d2824, 149-149 d,#1d2824, +|7: 0-0 d,#152019, 1-51 d,#0d1410, 52-52 #6c6c6c,#959595, 53-54 #959595,#6c6c6c, 55-55 #6c6c6c,#959595, 56-56 #959595,#6c6c6c, 57-57 #6c6c6c,#959595, 58-58 #959595,#6c6c6c, 59-59 #6c6c6c,#959595, 60-60 #959595,#6c6c6c, 61-61 #6c6c6c,#959595, 62-66 #959595,#6c6c6c, 67-67 #6c6c6c,#959595, 68-70 #959595,#6c6c6c, 71-72 #6c6c6c,#959595, 73-73 #959595,#6c6c6c, 74-74 #6c6c6c,#959595, 75-75 #959595,#6c6c6c, 76-76 #444444,#959595, 77-77 #6c6c6c,#959595, 78-81 #959595,#6c6c6c, 82-84 #6c6c6c,#959595, 85-85 #959595,#6c6c6c, 86-86 #6c6c6c,#959595, 87-89 #959595,#6c6c6c, 90-90 #6c6c6c,#959595, 91-92 #959595,#6c6c6c, 93-94 #6c6c6c,#959595, 95-95 #959595,#6c6c6c, 96-96 #959595,#352879, 97-97 #352879,#959595, 98-99 #352879,#352879, 100-149 d,#0d1410, +|8: 0-0 d,#152019, 1-51 d,#0d1410, 52-55 #959595,#6c6c6c, 56-56 #6c6c6c,#959595, 57-57 #959595,#6c6c6c, 58-58 #6c6c6c,#959595, 59-59 #959595,#6c6c6c, 60-60 #6c6c6c,#959595, 61-61 #959595,#6c6c6c, 62-62 #6c6c6c,#959595, 63-64 #959595,#6c6c6c, 65-65 #6c6c6c,#959595, 66-66 #959595,#6c6c6c, 67-67 #6c6c6c,#959595, 68-68 #959595,#6c6c6c, 69-69 #6c6c6c,#959595, 70-70 #959595,#6c6c6c, 71-71 #6c6c6c,#959595, 72-75 #959595,#6c6c6c, 76-78 #6c6c6c,#959595, 79-80 #959595,#6c6c6c, 81-81 #6c6c6c,#959595, 82-83 #959595,#6c6c6c, 84-86 #6c6c6c,#959595, 87-88 #959595,#6c6c6c, 89-91 #6c6c6c,#959595, 92-92 #959595,#6c6c6c, 93-93 #6c6c6c,#959595, 94-94 #6c6c6c,#352879, 95-95 #352879,#959595, 96-96 #352879,#6c5eb5, 97-99 #352879,#352879, 100-149 d,#0d1410, +|9: 0-0 d,#152019, 1-51 d,#0d1410, 52-56 #959595,#6c6c6c, 57-57 #6c6c6c,#959595, 58-60 #959595,#6c6c6c, 61-61 #6c6c6c,#959595, 62-66 #959595,#6c6c6c, 67-67 #444444,#6c6c6c, 68-68 #959595,#6c6c6c, 69-70 #6c6c6c,#959595, 71-71 #959595,#6c6c6c, 72-72 #6c6c6c,#959595, 73-73 #959595,#6c6c6c, 74-74 #6c6c6c,#959595, 75-75 #959595,#6c6c6c, 76-79 #6c6c6c,#959595, 80-82 #959595,#6c6c6c, 83-83 #6c6c6c,#959595, 84-84 #959595,#6c6c6c, 85-85 #6c6c6c,#959595, 86-86 #959595,#6c6c6c, 87-87 #6c6c6c,#959595, 88-88 #959595,#6c6c6c, 89-89 #6c6c6c,#959595, 90-91 #959595,#6c6c6c, 92-92 #6c6c6c,#352879, 93-93 #352879,#6c5eb5, 94-99 #352879,#352879, 100-149 d,#0d1410, +|10: 0-0 d,#152019, 1-51 d,#0d1410, 52-55 #6c6c6c,#959595, 56-57 #959595,#6c6c6c, 58-59 #6c6c6c,#959595, 60-62 #959595,#6c6c6c, 63-63 #6c6c6c,#959595, 64-64 #959595,#6c6c6c, 65-66 #6c6c6c,#959595, 67-68 #959595,#6c6c6c, 69-72 #6c6c6c,#959595, 73-75 #959595,#6c6c6c, 76-76 #6c6c6c,#959595, 77-77 #959595,#6c6c6c, 78-80 #6c6c6c,#959595, 81-89 #959595,#6c6c6c, 90-90 #959595,#352879, 91-91 #352879,#6c6c6c, 92-92 #352879,#6c5eb5, 93-99 #352879,#352879, 100-149 d,#0d1410, +|11: 0-0 d,#152019, 1-51 d,#0d1410, 52-55 #959595,#6c6c6c, 56-56 #6c6c6c,#959595, 57-57 #959595,#6c6c6c, 58-59 #6c6c6c,#959595, 60-60 #959595,#6c6c6c, 61-61 #6c6c6c,#959595, 62-62 #959595,#6c6c6c, 63-64 #6c6c6c,#959595, 65-66 #959595,#6c6c6c, 67-67 #6c6c6c,#959595, 68-70 #959595,#6c6c6c, 71-72 #6c6c6c,#959595, 73-78 #959595,#6c6c6c, 79-80 #6c6c6c,#959595, 81-85 #959595,#6c6c6c, 86-86 #6c6c6c,#959595, 87-87 #959595,#6c6c6c, 88-89 #959595,#352879, 90-90 #352879,#6c5eb5, 91-99 #352879,#352879, 100-149 d,#0d1410, +|12: 0-0 d,#152019, 1-51 d,#0d1410, 52-52 #959595,#6c6c6c, 53-53 #6c6c6c,#959595, 54-56 #959595,#6c6c6c, 57-57 #6c6c6c,#959595, 58-58 #959595,#6c6c6c, 59-59 #6c6c6c,#959595, 60-66 #959595,#6c6c6c, 67-67 #6c6c6c,#959595, 68-71 #959595,#6c6c6c, 72-72 #6c6c6c,#959595, 73-73 #959595,#6c6c6c, 74-74 #6c6c6c,#959595, 75-76 #959595,#6c6c6c, 77-78 #6c6c6c,#959595, 79-81 #959595,#6c6c6c, 82-82 #6c6c6c,#959595, 83-83 #959595,#6c6c6c, 84-84 #6c6c6c,#959595, 85-85 #959595,#6c6c6c, 86-86 #959595,#352879, 87-87 #352879,#6c5eb5, 88-99 #352879,#352879, 100-149 d,#0d1410, +|13: 0-0 d,#152019, 1-51 d,#0d1410, 52-52 #959595,#6c6c6c, 53-54 #6c6c6c,#959595, 55-55 #959595,#6c6c6c, 56-58 #6c6c6c,#959595, 59-61 #959595,#6c6c6c, 62-62 #6c6c6c,#959595, 63-65 #959595,#6c6c6c, 66-66 #6c6c6c,#959595, 67-67 #959595,#6c6c6c, 68-68 #6c6c6c,#959595, 69-72 #959595,#6c6c6c, 73-74 #6c6c6c,#959595, 75-75 #959595,#6c6c6c, 76-76 #6c6c6c,#959595, 77-77 #959595,#6c6c6c, 78-78 #6c6c6c,#959595, 79-79 #959595,#6c6c6c, 80-80 #6c6c6c,#959595, 81-81 #959595,#6c6c6c, 82-82 #6c6c6c,#959595, 83-83 #959595,#6c6c6c, 84-84 #6c6c6c,#352879, 85-85 #352879,#6c6c6c, 86-99 #352879,#352879, 100-149 d,#0d1410, +|14: 0-0 d,#152019, 1-51 d,#0d1410, 52-52 #444444,#959595, 53-55 #959595,#6c6c6c, 56-56 #6c6c6c,#959595, 57-57 #959595,#6c6c6c, 58-58 #444444,#959595, 59-61 #959595,#6c6c6c, 62-63 #6c6c6c,#959595, 64-64 #959595,#6c6c6c, 65-66 #6c6c6c,#959595, 67-67 #959595,#6c6c6c, 68-68 #6c6c6c,#959595, 69-70 #959595,#6c6c6c, 71-71 #6c6c6c,#959595, 72-73 #959595,#6c6c6c, 74-74 #6c6c6c,#959595, 75-75 #959595,#6c6c6c, 76-76 #6c6c6c,#959595, 77-78 #959595,#6c6c6c, 79-80 #6c6c6c,#959595, 81-81 #959595,#6c6c6c, 82-82 #959595,#352879, 83-83 #352879,#6c6c6c, 84-99 #352879,#352879, 100-149 d,#0d1410, +|15: 0-0 d,#152019, 1-51 d,#0d1410, 52-56 #959595,#6c6c6c, 57-57 #6c6c6c,#959595, 58-59 #959595,#6c6c6c, 60-61 #6c6c6c,#959595, 62-63 #959595,#6c6c6c, 64-64 #6c6c6c,#959595, 65-65 #959595,#6c6c6c, 66-66 #6c6c6c,#959595, 67-68 #959595,#6c6c6c, 69-69 #6c6c6c,#959595, 70-74 #959595,#6c6c6c, 75-76 #6c6c6c,#959595, 77-78 #959595,#6c6c6c, 79-79 #6c6c6c,#959595, 80-80 #959595,#352879, 81-81 #352879,#959595, 82-99 #352879,#352879, 100-149 d,#0d1410, +|16: 0-0 d,#152019, 1-51 d,#0d1410, 52-52 #6c6c6c,#959595, 53-53 #959595,#6c6c6c, 54-54 #6c6c6c,#959595, 55-59 #959595,#6c6c6c, 60-61 #6c6c6c,#959595, 62-64 #959595,#6c6c6c, 65-65 #6c6c6c,#959595, 66-67 #959595,#6c6c6c, 68-69 #6c6c6c,#959595, 70-71 #959595,#6c6c6c, 72-75 #6c6c6c,#959595, 76-77 #959595,#6c6c6c, 78-78 #6c6c6c,#352879, 79-79 #352879,#959595, 80-80 #352879,#6c5eb5, 81-99 #352879,#352879, 100-149 d,#0d1410, +|17: 0-0 d,#152019, 1-51 d,#0d1410, 52-52 #959595,#6c6c6c, 53-53 #6c6c6c,#959595, 54-63 #959595,#6c6c6c, 64-65 #6c6c6c,#959595, 66-68 #959595,#6c6c6c, 69-71 #6c6c6c,#959595, 72-73 #959595,#6c6c6c, 74-75 #6c6c6c,#959595, 76-76 #6c6c6c,#352879, 77-77 #352879,#6c6c6c, 78-99 #352879,#352879, 100-149 d,#0d1410, +|18: 0-0 d,#152019, 1-51 d,#0d1410, 52-52 #959595,#6c6c6c, 53-55 #6c6c6c,#959595, 56-60 #959595,#6c6c6c, 61-61 #444444,#959595, 62-62 #959595,#6c6c6c, 63-63 #6c6c6c,#959595, 64-64 #959595,#6c6c6c, 65-66 #6c6c6c,#959595, 67-69 #959595,#6c6c6c, 70-71 #6c6c6c,#959595, 72-72 #959595,#6c6c6c, 73-73 #6c6c6c,#959595, 74-74 #6c6c6c,#352879, 75-75 #352879,#6c6c6c, 76-99 #352879,#352879, 100-149 d,#0d1410, +|19: 0-0 d,#152019, 1-51 d,#0d1410, 52-52 #959595,#6c6c6c, 53-55 #6c6c6c,#959595, 56-63 #959595,#6c6c6c, 64-64 #6c6c6c,#959595, 65-66 #959595,#6c6c6c, 67-67 #6c6c6c,#959595, 68-69 #959595,#6c6c6c, 70-70 #6c6c6c,#959595, 71-71 #959595,#6c6c6c, 72-72 #959595,#352879, 73-73 #352879,#6c5eb5, 74-99 #352879,#352879, 100-149 d,#0d1410, +|20: 0-0 d,#152019, 1-51 d,#0d1410, 52-56 #959595,#6c6c6c, 57-59 #6c6c6c,#959595, 60-62 #959595,#6c6c6c, 63-63 #6c6c6c,#959595, 64-66 #959595,#6c6c6c, 67-69 #6c6c6c,#959595, 70-70 #6c6c6c,#352879, 71-71 #352879,#6c6c6c, 72-72 #352879,#6c5eb5, 73-99 #352879,#352879, 100-149 d,#0d1410, +|21: 0-0 d,#152019, 1-51 d,#0d1410, 52-52 #6c6c6c,#959595, 53-56 #959595,#6c6c6c, 57-57 #6c6c6c,#959595, 58-67 #959595,#6c6c6c, 68-68 #6c6c6c,#352879, 69-69 #352879,#6c6c6c, 70-99 #352879,#352879, 100-149 d,#0d1410, +|22: 0-0 d,#152019, 1-51 d,#0d1410, 52-52 #959595,#6c6c6c, 53-53 #6c6c6c,#959595, 54-54 #959595,#6c6c6c, 55-55 #6c6c6c,#959595, 56-58 #959595,#6c6c6c, 59-62 #6c6c6c,#959595, 63-65 #959595,#6c6c6c, 66-66 #6c6c6c,#352879, 67-67 #352879,#6c5eb5, 68-99 #352879,#352879, 100-149 d,#0d1410, +|23: 0-0 d,#152019, 1-51 d,#0d1410, 52-52 #959595,#6c6c6c, 53-53 #6c6c6c,#959595, 54-55 #959595,#6c6c6c, 56-56 #6c6c6c,#959595, 57-60 #959595,#6c6c6c, 61-62 #6c6c6c,#959595, 63-63 #959595,#6c6c6c, 64-64 #6c6c6c,#352879, 65-65 #959595,#352879, 66-99 #352879,#352879, 100-149 d,#0d1410, +|24: 0-0 d,#152019, 1-51 d,#0d1410, 52-53 #959595,#6c6c6c, 54-55 #6c6c6c,#959595, 56-56 #959595,#6c6c6c, 57-57 #6c6c6c,#959595, 58-58 #959595,#6c6c6c, 59-61 #6c6c6c,#959595, 62-62 #6c6c6c,#352879, 63-63 #352879,#959595, 64-99 #352879,#352879, 100-149 d,#0d1410, +|25: 0-0 d,#152019, 1-51 d,#0d1410, 52-52 #959595,#6c6c6c, 53-53 #6c6c6c,#959595, 54-55 #959595,#6c6c6c, 56-56 #6c6c6c,#959595, 57-57 #959595,#6c6c6c, 58-58 #6c6c6c,#959595, 59-59 #959595,#6c6c6c, 60-60 #6c6c6c,#352879, 61-61 #352879,#959595, 62-62 #352879,#6c5eb5, 63-99 #352879,#352879, 100-149 d,#0d1410, +|26: 0-0 d,#152019, 1-51 d,#0d1410, 52-53 #959595,#6c6c6c, 54-57 #6c6c6c,#959595, 58-58 #959595,#352879, 59-59 #352879,#6c6c6c, 60-99 #352879,#352879, 100-149 d,#0d1410, +|27: 0-0 d,#152019, 1-51 d,#0d1410, 52-52 #959595,#6c6c6c, 53-53 #6c6c6c,#959595, 54-55 #959595,#6c6c6c, 56-56 #6c6c6c,#352879, 57-57 #352879,#959595, 58-99 #352879,#352879, 100-149 d,#0d1410, +|28: 0-0 d,#152019, 1-51 d,#0d1410, 52-53 #959595,#6c6c6c, 54-54 #6c6c6c,#352879, 55-55 #352879,#6c5eb5, 56-99 #352879,#352879, 100-149 d,#0d1410, +|29: 0-0 d,#152019, 1-51 d,#0d1410, 52-52 #6c6c6c,#352879, 53-53 #959595,#352879, 54-99 #352879,#352879, 100-149 d,#0d1410, |30: 0-1 #000000,#add38a, 2-2 d,#26362d, 3-81 #becfc4,#26362d, 82-88 #dfbce5,#26362d, 89-105 #becfc4,#26362d, 106-149 d,#26362d, == snap search-prompt grid=150x31 cursor=149,6 -|6: /ZZ +|6: 4*🬹~F~N🬰|GðŸ¬�â–šY~KF🬴s Date: Tue, 22 Sep 2026 11:15:46 -0300 Subject: Answer 9P on the connection's task, so a session can open its own tree The editor's loop was the only thing that could answer a 9P request, which made the editor's own syscalls through a mount of its own tree -- a Look at /mnt/9p/pardes//anything under a `9ns --mntgen` view, a Save into it -- requests only the blocked loop could serve. The name-based refusal that followed (ownMountSuffix) and the in-process routing of a mount of oneself (Client.sameSession) were patches over that, and both are gone, with the mailbox that shipped every request to the editor's thread. One rule replaces them, `pardes.turn`: the core is single-threaded, the editor's thread has the turn by default and gives it up in two kinds of gap -- while it waits for input and while a step of it is out in a host syscall -- and a cloud9 connection task takes it in those gaps to answer. `out` counts the steps that are out, from any thread: while one is, the core reads consistently but that step still holds pointers into it, so a request that would change a pane (a write, a truncation, an rmdir) is parked in the engine and retried when the turn is next given up with nothing out, and the editor's own wake waits for the count to reach zero. It is never a write of its own that a step waits on out there -- writes come from a shell performing a save between steps -- so a parked request is never the syscall's own, and making a pane or rendering a screen need not park: every yield sits before its step's mutation, so the layout and the surface are whole under it. A changing request that queued effects is answered once the editor has performed them (`echo Save > exec` returns with the file written, as acme's `put` does), and it settles the way a step does, because without that a /log reader waited for the user's next keystroke. Every host syscall on a user path has to give the turn up, not fs.zig's alone: the first end-to-end run hung in `inotify_add_watch` performing the new pane's watch effect. PDFs and images are read whole at open, so no draw goes out into the host. The core's allocator takes its fixed buffer through the lock-free interface, since a connection task allocates while the editor's thread is out in a syscall that allocates too. A Restore puts the replacement in first and releases every task waiting on the old core. cloud9 (pinned at eb1a104) parks an open, a truncating wstat, a clunk and a remove on `again`, not only reads and writes, and answers a parked job whose fid was clunked without asking the backend. Verified: test/selfmount.py runs the editor under `9ns --mntgen` and Looks at, reads and Saves its own tree through the mount; a unit test pins that a change parks while the editor is out mid-step and lands when it rests, while a read is answered in the window. 9P over the Unix socket against a tty session, same machine, Debug builds: a read of /index 278us -> 61us, a truncating body write 1184us -> 609us, exec Save 718us -> 583us; the gesture benchmark is unchanged (geometric mean 0.997 over 53 cells). Also from the reviews: a notice chip over an image or PDF pane was painted out by the picture drawn after the cells, so pictures give up the rows; in the GUI a tree-sitter context band painted over the chip, so body layers are emitted first; a message is one row of printable text, its 256-byte cut never leaves half a glyph, and one wider than its pane keeps its tail (the file name, the reason) rather than its head. Co-Authored-By: Claude Fable 5.1 --- .agents/skills/pardes-9p/SKILL.md | 7 +- build.zig.zon | 4 +- docs/cloud9.md | 13 +- docs/fs.md | 27 +- docs/v9fs.md | 6 +- features.txt | 56 ++++ src/9p.zig | 19 +- src/9p_io.zig | 511 +++++++++++++++-------------------- src/CHANGELOG.md | 13 + src/detached/server.zig | 27 +- src/detached/wire.zig | 8 +- src/file_watch.zig | 6 + src/fs.zig | 444 ++++++++++-------------------- src/gui/gui.zig | 30 +- src/host_io.zig | 3 + src/macos.zig | 125 ++++++++- src/memory.zig | 50 +++- src/ninep/testing.zig | 7 +- src/ninep/tree.zig | 16 ++ src/panes.zig | 45 ++- src/pardes.zig | 282 +++++++++++++++---- src/tty/tty.zig | 11 +- test/fs_namespace.zig | 24 -- test/selfmount.py | 126 +++++++++ test/snapshots/images.golden | 40 +-- test/snapshots/msg.golden | 4 + test/snapshots/msg.snap | 12 + test/snapshots/tagbottomimage.golden | 98 +++---- 28 files changed, 1205 insertions(+), 809 deletions(-) create mode 100644 test/selfmount.py (limited to 'src/pardes.zig') diff --git a/.agents/skills/pardes-9p/SKILL.md b/.agents/skills/pardes-9p/SKILL.md index b776e407..2e065819 100644 --- a/.agents/skills/pardes-9p/SKILL.md +++ b/.agents/skills/pardes-9p/SKILL.md @@ -69,9 +69,10 @@ echo "/etc/hosts:3" > "$m/look"; cat "$m/look" # open a file, see where it land rmdir "$m/pane/$n" # close it, dirty or not ``` -Do not open a session's own mount from inside that session -- a Look at -`$m/anything` in the editor that serves `$m` would deadlock it, so such paths -are refused. Use `/n/self/...` from inside; `$m/...` is for everyone else. +A session may open its own mount from inside itself: a Look at `$m/anything` +in the editor that serves `$m` is answered on the connection's task while the +editor's own syscall waits. `/n/self/...` names the same tree without leaving +the process. **Opening** `$m/pane/new` is what makes a pane, and reading the open file answers its serial — `/net/tcp/clone`'s mechanism. Each open makes another one, diff --git a/build.zig.zon b/build.zig.zon index 3a172f3b..8f1b8068 100644 --- a/build.zig.zon +++ b/build.zig.zon @@ -9,8 +9,8 @@ // read-only HTTPS URL is what a manifest can carry. Re-pin with // `zig fetch --save=cloud9 git+https://git.sr.ht/~gbrls/cloud9#`. .cloud9 = .{ - .url = "git+https://git.sr.ht/~gbrls/cloud9#9c4d668c926e2d9eae6ef87cd9b391d8185605f9", - .hash = "cloud9-0.1.0-yt86qjAoGgBEPMJl2t4CZn7iWPMZUw4sMHAL54tq7spP", + .url = "git+https://git.sr.ht/~gbrls/cloud9#eb1a104f385f375a74319695e1a59f6f82e6384e", + .hash = "cloud9-0.1.0-yt86qiixGgCCjOhSDJ6tijGR7zj_zLT8mjvuUqrkeG9_", }, // ZLS as a LIBRARY, not a language server: src/lsp_zls.zig imports the // `zls` module its build.zig publishes and calls the analyser in diff --git a/docs/cloud9.md b/docs/cloud9.md index d030db1d..6eb76238 100644 --- a/docs/cloud9.md +++ b/docs/cloud9.md @@ -16,11 +16,14 @@ Mounting, Unix namespace discovery and permissions, the editor event loop, connection limits, and exported tree policy remain here. The Unix and TCP listeners run on cloud9's `serve.Runner` (`std.Io`: an accept task per listener, a reader and a writer task per connection, four slots); its handler -queues every backend request for the editor's thread, which answers them all -in `Listener.tick` after each editor update, retries parked reads there, and -has the runner ship the replies. `src/9p_quic.zig` selects the existing -`pardes-9p` ALPN for cloud9's optional OpenSSL transport; QUIC still runs on -the poll loop in `src/9p_io.zig`, since cloud9's QUIC adapter is +answers every backend request on the connection's task, taking the editor's +turn with the core (`pardes.turn`) while the editor waits for input or is out +in a syscall. A request that would change a pane while the editor is mid-step +is parked with `Status.again` -- the engine parks reads, writes, opens, +truncations, clunks and removes -- and retried by `Runner.wakeAll` when the +editor next rests. `src/9p_quic.zig` selects the existing `pardes-9p` ALPN for +cloud9's optional OpenSSL transport; QUIC still runs on the poll loop in +`src/9p_io.zig` on the editor's thread, since cloud9's QUIC adapter is nonblocking-descriptor based rather than `std.Io` based. The standalone protocol/GPIO tests import the same module. The separate `05-zig-p4` build also supplies cloud9 for the GPIO firmware entry. diff --git a/docs/fs.md b/docs/fs.md index 6d2891e0..335ee4e6 100644 --- a/docs/fs.md +++ b/docs/fs.md @@ -106,15 +106,24 @@ at the cost of acme's one-step `new/body`. Nothing in the tree is created by list, stat, walk or read; only that one open. Every other name in `/pane` is a serial. -A session cannot open its own tree through a mount. Looking at -`/mnt/9p/pardes//anything` from inside that very editor used to hang it -outright: the realpath, the stat and the read all leave through the mount and -come back as 9P requests only that editor's loop can answer, while the loop is -blocked making them, and the filesystem then stops answering anybody. Such a -path is now refused by name before any syscall runs, because the syscall is the -thing that never returns. Address your own tree as `/n/self/...`, which the -editor serves from memory without leaving the process. Another session's mount -is perfectly fine to open. +A session can open its own tree through a mount: a Look at +`/mnt/9p/pardes//pane/2/body` from inside that very editor opens it, and +a Save of that pane writes back through the mount into pane 2. Requests on +the Unix and TCP listeners are answered on the 9P connection's own task, not +by the editor's loop, so the realpath, the stat and the read the editor makes +out through the mount come back while it waits for them. The one rule is +whose turn it is with the core (`pardes.turn`): the editor has it, and gives +it up while it waits for input and while a step of it is out in a syscall. A +step of a connection task's own -- a Look written to `look` -- goes out the +same way, and the editor waits for it to return before it takes a step of +its own. While any step is out, a request that would change a pane (a write, +a truncation, an rmdir) parks in the engine until none is; everything else, +opening `pane/new` and `screen` included, is answered at once, which is why a +Look at any path in the tree comes back. A write into the tree from the +editor itself only ever happens between steps (a Save), so nothing it waits +on out there is a request that has to park. QUIC is still served on the +editor's loop, so through QUIC the old hang remains. `/n/self/...` names the +same tree without leaving the process. `/look` and `/exec` are the editor's two clicks, one per line of a write: diff --git a/docs/v9fs.md b/docs/v9fs.md index cfbbd35b..a105fe06 100644 --- a/docs/v9fs.md +++ b/docs/v9fs.md @@ -72,9 +72,9 @@ remain available for subsequent explicit authentication. The launcher waits for forwards termination signals, and removes its empty temporary directory on exit. Namespace destruction releases the mount when its last process exits. -The core stays outside the mount namespace because its event loop serves 9P. -A blocking filesystem operation through its own mount could wait for a request -that the blocked event loop must service. Even pathname resolution may do this. +The core stays outside the mount namespace, which is the helper's private +one: a path under `$PARDES_MOUNT` names nothing in the editor's own namespace, +so a Look on one from that shell opens nothing. Each `Tty9p` currently creates its own mount and consumes a server connection; the session has four application connection slots across all transports. This diff --git a/features.txt b/features.txt index fa1c0f6b..0db7c497 100644 --- a/features.txt +++ b/features.txt @@ -202,3 +202,59 @@ means what it says when fed back as configuration -- the symmetry the report was Left failing, deliberately: `nested-optout`. See docs/divergences.md -- two levels of nesting prepend U+E016 (vaxis's F3) to typed lines, which is a real bug in the key-forwarding path and not a stale expectation. + +9P is answered on the connection's task now, not by the editor's loop. The loop used to be the only thing that could answer a +request, which made the editor's own syscalls through a mount of its own tree -- a Look at /mnt/9p/pardes//anything under a +`9ns --mntgen` view, a Save into it -- a request only the blocked loop could serve. The name-based refusal that followed +(ownMountSuffix) and the in-process routing of a mount of oneself (Client.sameSession) were patches over that, and both are gone. +What replaced them is one rule, `pardes.turn`: the core is single-threaded, the editor's thread has the turn by default and gives it +up in two kinds of gap -- while it waits for input (`rest`/`wake`, one site per shell) and while a step is out in a host syscall +(`yield`/`back`, inside the leaf calls in fs.zig and the few host-side ones: the file watcher's marks, a shell's cwd stat) -- and a +cloud9 connection task takes it in those gaps to answer. Which gap it is matters: waiting, anything goes; out in a syscall +mid-step, the core reads consistently but the step still holds pointers into it, so a request that would change a pane +(tree.needsQuiet: writes, truncations, /pane/new, rmdir, and the screen open because it renders) is parked in the engine with +Status.again and retried when the turn is next given up quiet. That needed cloud9's engine to park an open, a truncating wstat, a +clunk and a remove, not only reads and writes -- a parked job goes back into the job slot on retry, and a walk still cannot park +because its names live in the input frame. A changing request that queued effects waits (`awaitSettled`) until the editor's pump has +performed them before it is answered, so `echo Save > exec` still returns with the file written, the way `put` does in acme; and a +request settles the way a step does (`sync`, `fsReport`, `events.announce`), because without that a `/log` reader waited for the +user's next keystroke to hear about the pane the request made. + +Two traps that cost real time. The first end-to-end run hung anyway: the Look completed on the connection task, then the editor woke +to perform the new pane's watch effect, and `inotify_add_watch` on a FUSE path is itself a request -- made while holding the turn. +The rule is therefore every host syscall on a user path, not fs.zig's alone; PDFs are read whole and opened from memory for the same +reason (MuPDF reads a file lazily at every page). The second: a parked write one byte longer than `park_data_max` fails EAGAIN, and +the client's largest write is msize less the 23-byte Twrite header, not less iohdrsz; a large Save to a peer's /os path came back +"save: Remote" until the engine's room was sized from a client. test/selfmount.py runs the editor under `9ns --mntgen` and Looks at, +reads and Saves its own tree through the mount; a unit test in 9p_io.zig pins that a change parks while the editor is out mid-step +and lands when it rests, while a read is answered in the window. + +Performance, same machine, Debug builds, 9P over the Unix socket against a tty session: a read of /index 278us -> 61us and a pane +body 283us -> 64us, because a read no longer waits for the editor to wake; a truncating body write 1184us -> 609us; exec Msg 696us +-> 543us; pane/new + rmdir 1535us -> 1295us; exec Save 718us -> 583us. A change still costs one editor frame, since the editor +draws it before it rests again. + +Left as they are: QUIC still runs on the editor's thread (cloud9's QUIC adapter is not std.Io based), so a QUIC client of a session +that Looks at its own QUIC-mounted tree would still wait on the loop; the Tty9p kernel mount lives in the helper's private +namespace, so a Look on `$PARDES_MOUNT/...` from that shell opens nothing in the editor -- no longer a deadlock, only a namespace +the editor is not in; and a message wider than its pane now keeps its tail rather than its head (msg.snap `msgtail`). + +Two adversarial reviews of that design. The concurrency one found the lost wake for real: a connection task's own yield saved the +editor's mid-step "not quiet" and restored it after the editor had rested, so a resting editor looked busy forever and every change +parked with nobody to wake it -- `quiet` is now `out`, a count of steps out in a syscall from any thread, and nothing saves or +restores it. Behind it, three more: the editor could take its turn back while a connection task's step was still out (that step's +pointers dangling when it returned) -- `wake` now waits for the count to reach zero; the core's allocator was a stack-fallback +over a FixedBufferAllocator, thread-safe only in Debug where the DebugAllocator wrapped it -- the fixed buffer is taken through +its lock-free interface now; and a Restore let a task waiting on the old core wake after that core was freed -- `reset` swaps the +listener's core first and releases every waiter, which then finds the core changed and answers nothing. It also showed that +parking `pane/new` and `screen` would have hung a Look at exactly those two paths in one's own mount (the editor's own open would +park, waiting for a rest that cannot come), so those are answered mid-step: every yield sits before its step's mutation, so the +layout and the surface are whole under it. Images are read at open for the same reason PDFs are. + +The rendering one found the chips drawn out from under: a placed image or PDF page is drawn after the cells (the GUI's image pass, +kitty's z-order), so a chip over a picture was painted over -- pictures give up the rows now, text keeps the overlay -- and in the +GUI a tree-sitter context band was emitted after the tag layers and painted over the chip, so body layers go first. A message is +one row of printable text (a language server's multi-line report read as one line with U+FFFD per newline), the 256-byte cut +never leaves half a glyph, and an over-wide message cut inside a wide glyph now drops that glyph rather than clipping its last. +The simplicity one cut the vestiges: `ninep_identity`, the restore's copy of listener addresses, `setWake`, the mailbox's +`Drained` name, the 64K read buffer, and the two macOS entry points whose multi-line signatures the wrapping had missed. diff --git a/src/9p.zig b/src/9p.zig index c0e7f61e..5ffe9058 100644 --- a/src/9p.zig +++ b/src/9p.zig @@ -52,9 +52,16 @@ pub const msize_min = cloud9.fs.msize_min; /// The smallest msize a native listener offers (src/9p_io.zig). pub const min_msize: u32 = 4096; +/// What a native listener negotiates. +pub const msize: u32 = 8192; -/// The editor's engine: native fid count, native file names. -pub const editor: cloud9.fs.Options = .{ .fid_capacity = max_fids, .name_capacity = 255 }; +/// The editor's engine: native fid count, native file names, and room to +/// park a write of any size a frame can carry -- a request that would change +/// a pane while the editor is out in a syscall waits in the engine +/// (src/9p_io.zig, `serve`), and a write it cannot keep would fail instead. +/// The largest write is msize less the Twrite header, 23 bytes (the test +/// below asks a client), one byte more than `iohdrsz` allows for. +pub const editor: cloud9.fs.Options = .{ .fid_capacity = max_fids, .name_capacity = 255, .park_data_max = msize - 23 }; /// The board's engine: the GPIO firmware's budget (src/esp32p4_9p.zig). pub const board: cloud9.fs.Options = .{ .fid_capacity = board_fids, .name_capacity = board_name_capacity }; @@ -70,6 +77,14 @@ const Stub = struct { pub const Reply = cloud9.fs.Reply; }; +test "9p server: the editor's engine can park the largest write a client sends" { + var in: [4096]u8 = undefined; + var out: [4096]u8 = undefined; + var client: Client = .init(.{ .in = &in, .out = &out }); + client.msize = msize; + try testing.expect(editor.park_data_max >= client.maxWrite()); +} + test "9p server: board and native capacities size the actual fid storage" { const Board = Server(Stub, board); const Native = Server(Stub, editor); diff --git a/src/9p_io.zig b/src/9p_io.zig index 08deae7a..7e09fb27 100644 --- a/src/9p_io.zig +++ b/src/9p_io.zig @@ -62,7 +62,7 @@ pub fn ensureSocketDir(dir: [:0]const u8) bool { const prefix = "pardes-9p-"; -pub const msize: u32 = 8192; +pub const msize = ninep.msize; pub const max_conns = 4; @@ -143,76 +143,17 @@ const Srv = ninep.Server(pardes.ctlfs, ninep.editor); /// The Unix and TCP listeners run on cloud9's `std.Io` runner: it accepts, /// reads frames, steps each connection's engine and writes replies on its -/// own tasks, and hands every backend request to the editor's thread -/// through `Slot` (see `tick`). QUIC keeps the poll loop below. +/// own tasks, and every backend request is answered right there, on the +/// connection's task, by taking the editor's turn (`pardes.turn`): while the +/// editor waits for input, or while a step of it is out in a syscall -- +/// which is what lets the editor read its own tree through a mount. QUIC +/// keeps the poll loop below, on the editor's thread. const Runner = if (supported) cloud9.serve.Runner(pardes.ctlfs, ninep.editor, .{ .msize = msize, .connections = max_conns, .listeners = 2, }) else void; -/// Answers one backend request on the editor's thread. -fn step(core: *pardes.Pardes, srv: *Srv, req: pardes.ctlfs.Req) void { - core.update(.{ .fs_req = req }); - var answered = false; - while (core.nextEffect()) |effect| { - if (effect == .fs_reply) { - const reply = effect.fs_reply; - if (reply.tag == req.tag) answered = true; - srv.reply(&reply, core.fsPayload(reply)); - } else core.perform(effect); - } - if (!answered) { - const reply = pardes.ctlfs.Reply.fail(req.tag, pardes.ctlfs.E.IO); - srv.reply(&reply, ""); - } -} - -/// Pays the backend a request whose connection is gone; replies go nowhere. -fn pay(core: *pardes.Pardes, req: pardes.ctlfs.Req) void { - core.update(.{ .fs_req = req }); - while (core.nextEffect()) |effect| if (effect != .fs_reply) core.perform(effect); -} - -/// One runner slot's mailbox: the requests its connection task handed over, -/// answered by the editor's thread in `tick`. A hangup's releases (at most -/// one per fid) and one outstanding request are the most it ever holds, -/// because a closing connection waits for its entries to be paid before -/// the slot is reused. -const Slot = struct { - const capacity = ninep.editor.fid_capacity + 2; - const Entry = struct { gen: u32, req: pardes.ctlfs.Req }; - - mutex: std.Io.Mutex = .init, - queue: [capacity]Entry = undefined, - head: usize = 0, - len: usize = 0, - /// Bumped when a connection takes the slot; entries carry the value. - gen: u32 = 0, - closing: bool = false, - drained: std.Io.Event = .unset, - /// Requests refused for want of room; never expected. - refused: u32 = 0, - - fn push(s: *Slot, req: pardes.ctlfs.Req) bool { - if (s.len == s.queue.len) { - s.refused += 1; - return false; - } - s.queue[(s.head + s.len) % capacity] = .{ .gen = s.gen, .req = req }; - s.len += 1; - return true; - } - - fn pop(s: *Slot) ?Entry { - if (s.len == 0) return null; - const e = s.queue[s.head]; - s.head = (s.head + 1) % capacity; - s.len -= 1; - return e; - } -}; - const quic_slots = if (quic_enabled) max_conns else 0; /// A QUIC connection on the poll path. @@ -229,12 +170,10 @@ const accept_pause_ms: i64 = 100; pub const Listener = struct { io: std.Io, + /// The core that answers; `reset` puts a replacement in. + core: *pardes.Pardes, runner: Runner = undefined, - slots: [max_conns]Slot = @splat(.{}), stopping: std.atomic.Value(bool) = .init(false), - /// While `reset` runs: the generation each slot is paying off; anything - /// newer waits for the replacement core. - resetting: ?[max_conns]u32 = null, tcp_address: ?std.Io.net.IpAddress = null, quic: if (quic_enabled) ?quic.Listener else void = if (quic_enabled) null else {}, quic_address: ?std.Io.net.IpAddress = null, @@ -264,47 +203,59 @@ pub const Listener = struct { return @ptrCast(@alignCast(ctx.?)); } - /// The runner's handler: on the connection's task. - fn onOpened(ctx: ?*anyopaque, conn: *Runner.Conn) void { - const l = of(ctx); - const s = &l.slots[conn.index]; - s.mutex.lockUncancelable(l.io); - s.gen +%= 1; - s.mutex.unlock(l.io); - } - + /// The runner's handler, on the connection's task: takes the turn and + /// answers. A request that would change a pane while the editor is out + /// in a syscall mid-step is parked in the engine instead, and retried + /// when the turn is next given up between steps (`wakeParked`). fn onServe(ctx: ?*anyopaque, conn: *Runner.Conn, req: pardes.ctlfs.Req) void { const l = of(ctx); - const s = &l.slots[conn.index]; - s.mutex.lockUncancelable(l.io); - const queued = s.push(req); - s.mutex.unlock(l.io); - if (!queued) { - const reply = pardes.ctlfs.Reply.fail(req.tag, pardes.ctlfs.E.IO); - conn.reply(&reply, ""); - return; + // Once `stop` has begun the editor is tearing down and may never + // rest again: answer without waiting on it. + if (l.stopping.load(.acquire)) { + const refused = pardes.ctlfs.Reply.fail(req.tag, pardes.ctlfs.E.IO); + return conn.reply(&refused, ""); + } + const quiet = pardes.turn.take(); + defer pardes.turn.give(); + if (!quiet and pardes.ctlfs.needsQuiet(req)) { + pardes.turn.parked = true; + const later: pardes.ctlfs.Reply = .{ .tag = req.tag, .status = .again }; + return conn.reply(&later, ""); } + const core = l.core; + const epoch = pardes.turn.epoch; + const restores = pardes.turn.restores; + const reply = core.serveFs(req); + if (req.op == .release and quiet) l.collectOs(); + if (!pardes.ctlfs.changesPane(req)) return conn.reply(&reply, core.fsPayload(reply)); + // The editor draws the change and performs what it asked for; when + // it asked for something -- a save, a shell, a watch -- the answer + // waits until that is done, so `echo Save > exec` returns with the + // file written. A change carries no payload, so the reply is still + // whole after the wait. l.kick(); - } - - /// Holds the slot until the editor's thread has paid what the - /// connection still owes, so a successor never inherits its entries. - fn onClosed(ctx: ?*anyopaque, conn: *Runner.Conn) void { + const restoring = core.restore_req != null; + if (core.effects_len != 0) pardes.turn.awaitSettled(epoch); + // Once a wait returns `core` may be gone: a Restore meanwhile put a + // replacement in (`reset`) and is hanging this connection up, which + // is a Restore's answer. Only one that failed leaves this connection + // here to answer. + if (l.core != core) return; + if (restoring) pardes.turn.awaitRestored(restores); + if (l.core != core) return; + conn.reply(&reply, ""); + } + + /// The turn was given up quiet with a request parked: every connection + /// retries what it parked. + fn wakeParked(ctx: ?*anyopaque) void { const l = of(ctx); - const s = &l.slots[conn.index]; if (l.stopping.load(.acquire)) return; - s.mutex.lockUncancelable(l.io); - if (s.len == 0) { - s.mutex.unlock(l.io); - return; - } - s.closing = true; - s.drained.reset(); - s.mutex.unlock(l.io); - l.kick(); - s.drained.wait(l.io) catch {}; + if (comptime supported) l.runner.wakeAll(); } + /// A request changed the core: the editor wakes to draw it and perform + /// what it asked for. fn kick(l: *Listener) void { if (l.stopping.load(.acquire)) return; if (l.wake) |f| f(l.wake_ctx); @@ -411,68 +362,46 @@ pub const Listener = struct { c.draining = true; } - pub const Drained = struct { count: usize = 0, pending: bool = false }; - - /// Answers what every connection has asked since the last call, retries - /// their parked reads against the editor's current state and has the - /// runner send the replies. Call it after each editor update, on the - /// editor's thread; `pending` says QUIC has more to do right away. - pub fn drain(l: *Listener, core: *pardes.Pardes) Drained { - core.fs.socket_path = l.path(); - core.fs.tcp_address = l.tcp_address; - core.fs.quic_address = l.quic_address; - l.expire(); - var result: Drained = .{}; - if (comptime supported) { - for (&l.slots, 0..) |*s, i| { - const conn = &l.runner.conns[i]; - s.mutex.lockUncancelable(l.io); - const only: ?u32 = if (l.resetting) |gens| gens[i] else null; - var count: usize = 0; - if (s.len != 0 or conn.live()) { - conn.lock(); - while (s.len != 0) { - if (only) |gen| if (s.queue[s.head].gen != gen) break; - const e = s.pop().?; - if (e.gen == s.gen) step(core, &conn.engine, e.req) else if (e.req.op == .release) pay(core, e.req); - count += 1; - } - if (conn.live() and (only == null or only.? == s.gen)) { - while (conn.engine.retry()) |req| { - step(core, &conn.engine, req); - count += 1; - } - while (conn.engine.next()) |req| { - step(core, &conn.engine, req); - count += 1; - } - } - const owed = conn.engine.output().len != 0; - conn.unlock(); - if (owed) conn.flush(); - } - if (s.closing and s.len == 0) { - s.closing = false; - s.drained.set(l.io); - } - s.mutex.unlock(l.io); - result.count += count; - if (count != 0) l.collectOs(core); - } - } + /// What one QUIC poll pass did: `pending` says there is more to do at + /// once. + pub const Polled = struct { count: usize = 0, pending: bool = false }; + + /// Answers one QUIC request, on the editor's thread. + fn step(l: *Listener, srv: *Srv, req: pardes.ctlfs.Req) void { + const reply = l.core.serveFs(req); + srv.reply(&reply, l.core.fsPayload(reply)); + if (req.op == .release) l.collectOs(); + } + + /// QUIC's events, accepts, reads, requests and replies, on the editor's + /// thread after each of its steps; `pending` says there is more to do + /// right away. Unix and TCP need none of this. + pub fn tick(l: *Listener) Polled { + var result: Polled = .{}; + // Between the editor's steps, which is when the table may be swept: + // the editor's own directory listings leave nodes in it too. + l.collectOs(); if (comptime quic_enabled) { + if (l.quic) |*listener| listener.events() catch |err| { + log.warn("QUIC listener stopped: {s}", .{@errorName(err)}); + for (&l.conns, 0..) |*conn, i| if (conn.quic != null) l.drop(@intCast(i)); + listener.deinit(); + l.quic = null; + l.quic_address = null; + }; + l.accept(); + for (0..quic_slots) |i| if (l.live(@intCast(i))) l.fill(@intCast(i)); + l.expire(); for (&l.conns, 0..) |*conn, i| { if (!l.live(@intCast(i)) and !conn.draining) continue; var count: usize = 0; while (conn.srv.retry()) |req| { - step(core, &conn.srv, req); - l.collectOs(core); + l.step(&conn.srv, req); count += 1; } while (count < 64) { const req = conn.srv.next() orelse break; - step(core, &conn.srv, req); - l.collectOs(core); + l.step(&conn.srv, req); count += 1; } result.count += count; @@ -482,64 +411,44 @@ pub const Listener = struct { } else l.flush(@intCast(i)); if (conn.quic) |*connection| result.pending = result.pending or connection.pending(); } + l.arm(); } return result; } - /// `drain` plus the QUIC listener's events, accepts and reads. - pub fn tick(l: *Listener, core: *pardes.Pardes) Drained { - if (comptime quic_enabled) { - if (l.quic) |*listener| listener.events() catch |err| { - log.warn("QUIC listener stopped: {s}", .{@errorName(err)}); - for (&l.conns, 0..) |*conn, i| if (conn.quic != null) l.drop(@intCast(i)); - listener.deinit(); - l.quic = null; - l.quic_address = null; - }; - l.accept(); - for (0..quic_slots) |i| if (l.live(@intCast(i))) l.fill(@intCast(i)); - } - const result = l.drain(core); - l.arm(); - return result; - } - - /// Hangs every connection up and pays `core` what they owed, so that a - /// replacement core starts with no client holding anything. A client - /// that connects meanwhile is not answered until the caller has put - /// the replacement in and calls `tick` again. - pub fn reset(l: *Listener, core: *pardes.Pardes) void { + /// Hangs every connection up, so that `replacement` starts with no + /// client holding anything. From here requests are answered from the + /// replacement -- a client that connects meanwhile is a client of the + /// replacement -- and every task waiting on the old core is let go: it + /// finds the core changed and answers nothing, its connection being + /// hung up. The connections pay their releases on their own tasks, so + /// the editor rests while they do. + pub fn reset(l: *Listener, replacement: *pardes.Pardes) void { for (0..quic_slots) |i| l.drop(@intCast(i)); + if (comptime quic_enabled) while (l.tick().pending) {}; + l.core = replacement; + replacement.fs.socket_path = l.path(); + replacement.fs.tcp_address = l.tcp_address; + replacement.fs.quic_address = l.quic_address; if (comptime supported) { - var gens: [max_conns]u32 = undefined; - for (&l.slots, &gens) |*s, *gen| { - s.mutex.lockUncancelable(l.io); - gen.* = s.gen; - s.mutex.unlock(l.io); - } - l.resetting = gens; - defer l.resetting = null; l.runner.closeAll(); + pardes.turn.settle(); + pardes.turn.restoreSettled(); + pardes.turn.rest(); const deadline = nowMs() +| 2000; - while (true) { - const drained = l.drain(core); - var idle = !drained.pending; - for (&l.slots, &gens, 0..) |*s, gen, i| { - s.mutex.lockUncancelable(l.io); - if (s.len != 0 and s.queue[s.head].gen == gen) idle = false; - if (s.gen == gen and l.runner.conns[i].live()) idle = false; - s.mutex.unlock(l.io); - } - if (idle or nowMs() >= deadline) break; - Client.nap(1); - } - } else while (l.drain(core).pending) {} - l.collectOs(core); + while (l.runner.count() != 0 and nowMs() < deadline) Client.nap(1); + pardes.turn.wake(); + } + l.collectOs(); for (&l.conns) |*conn| conn.accepted_ms = 0; l.arm(); } - fn collectOs(l: *Listener, core: *pardes.Pardes) void { + /// Forgets the host paths no connection names any more. With the turn, + /// and only between the editor's steps: a step out in a syscall may be + /// reading one of these entries. + fn collectOs(l: *Listener) void { + const core = l.core; var i: usize = 0; while (i < core.fs.os_paths.items.len) { const entry = core.fs.os_paths.items[i]; @@ -552,17 +461,10 @@ pub const Listener = struct { } } - /// Whether any connection, or a release still to be paid, names `node`. + /// Whether any connection names `node`. fn references(l: *Listener, node: u64) bool { if (comptime supported) { - for (&l.slots, 0..) |*s, i| { - const conn = &l.runner.conns[i]; - s.mutex.lockUncancelable(l.io); - defer s.mutex.unlock(l.io); - var k: usize = 0; - while (k < s.len) : (k += 1) { - if (s.queue[(s.head + k) % Slot.capacity].req.node == node) return true; - } + for (&l.runner.conns) |*conn| { if (!conn.live()) continue; conn.lock(); defer conn.unlock(); @@ -576,16 +478,12 @@ pub const Listener = struct { return false; } - /// Where the runner's tasks report that a request waits for `tick`. - pub fn setWake(l: *Listener, ctx: ?*anyopaque, wake: *const fn (?*anyopaque) void) void { + /// Where the runner's tasks report that a request changed the core, + /// and for QUIC a thread that watches its socket and calls `wake` when + /// `tick` has something to read. + pub fn watch(l: *Listener, ctx: ?*anyopaque, wake: *const fn (?*anyopaque) void) !void { l.wake_ctx = ctx; l.wake = wake; - } - - /// `setWake`, and for QUIC a thread that watches its socket and calls - /// `wake` when `tick` has something to read. - pub fn watch(l: *Listener, ctx: ?*anyopaque, wake: *const fn (?*anyopaque) void) !void { - l.setWake(ctx, wake); if (comptime !quic_enabled) return; if (l.quic == null or l.watcher != null) return; if (libc.pipe(&l.control) != 0) return error.PipeFailed; @@ -735,7 +633,15 @@ pub const Listener = struct { if (comptime quic_enabled) { if (l.quic) |*listener| listener.deinit(); } - if (comptime supported) l.runner.stop(); + if (comptime supported) { + // A connection task may be waiting for the turn; it answers + // nothing more once stopping, but the wait itself must end. + pardes.turn.rest(); + l.runner.stop(); + pardes.turn.wake(); + } + pardes.turn.wake_parked = null; + pardes.turn.stop(); if (l.path_len != 0) { var z: [sun_path_len:0]u8 = undefined; @memcpy(z[0..l.path_len], l.path_buf[0..l.path_len]); @@ -752,7 +658,9 @@ pub fn socketPath(buf: *[sun_path_len]u8, dir: []const u8, name: []const u8) ?[: return std.fmt.bufPrintSentinel(buf, "{s}/" ++ prefix ++ "{s}.sock", .{ dir, name }, 0) catch null; } -pub fn listen(io: std.Io, gpa: std.mem.Allocator, named: []const u8, fallback: []const u8, tcp_dial: ?[]const u8, quic_dial: ?[]const u8) ?*Listener { +/// Serves `core`. From here on the calling thread has the editor's turn +/// (`pardes.turn`) and must give it up while it waits. +pub fn listen(io: std.Io, gpa: std.mem.Allocator, core: *pardes.Pardes, named: []const u8, fallback: []const u8, tcp_dial: ?[]const u8, quic_dial: ?[]const u8) ?*Listener { if (comptime !supported) return null; var dir_buf: [sun_path_len:0]u8 = undefined; const dir = socketDir(&dir_buf) orelse { @@ -761,11 +669,14 @@ pub fn listen(io: std.Io, gpa: std.mem.Allocator, named: []const u8, fallback: [ }; if (!ensureSocketDir(dir)) return null; const l = gpa.create(Listener) catch return null; - l.* = .{ .io = io }; + l.* = .{ .io = io, .core = core }; + pardes.turn.start(io); + pardes.turn.wake_parked = Listener.wakeParked; + pardes.turn.wake_ctx = l; l.runner.init(.{ .io = io, .root = pardes.ctlfs.root, - .handler = .{ .ctx = l, .serve = Listener.onServe, .opened = Listener.onOpened, .closed = Listener.onClosed }, + .handler = .{ .ctx = l, .serve = Listener.onServe }, .greet_timeout_ms = Listener.greet_deadline_ms, }); const entry_name = if (named.len != 0) named else fallback; @@ -838,6 +749,9 @@ pub fn listen(io: std.Io, gpa: std.mem.Allocator, named: []const u8, fallback: [ } } log.info("serving 9P2000 on {s}", .{p}); + core.fs.socket_path = l.path(); + core.fs.tcp_address = l.tcp_address; + core.fs.quic_address = l.quic_address; return l; } @@ -1160,33 +1074,6 @@ test "TCP addresses are numeric and normalize mapped IPv4" { } else try testing.expectError(error.QuicUnavailable, Client.validateDial("quic!127.0.0.1!5640")); } -test "same-session TCP mounts compare canonical endpoints and local wildcard destinations" { - if (comptime !supported) return error.SkipZigTest; - const Case = struct { bound: []const u8, dial: []const u8, same: bool }; - for ([_]Case{ - .{ .bound = "tcp!127.0.0.1!5640", .dial = "tcp!::ffff:127.0.0.1!5640", .same = true }, - .{ .bound = "tcp!::ffff:127.0.0.1!5640", .dial = "tcp!127.0.0.1!5640", .same = true }, - .{ .bound = "tcp!::1!5640", .dial = "tcp!0:0:0:0:0:0:0:1!5640", .same = true }, - .{ .bound = "tcp!127.0.0.1!5640", .dial = "tcp!0.0.0.0!5640", .same = true }, - .{ .bound = "tcp!::1!5640", .dial = "tcp!::!5640", .same = true }, - .{ .bound = "tcp!0.0.0.0!5640", .dial = "tcp!127.0.0.2!5640", .same = true }, - .{ .bound = "tcp!::!5640", .dial = "tcp!::1!5640", .same = true }, - .{ .bound = "tcp!127.0.0.1!5640", .dial = "tcp!127.0.0.1!5641", .same = false }, - .{ .bound = "tcp!0.0.0.0!5640", .dial = "tcp!192.0.2.1!5640", .same = false }, - .{ .bound = "tcp!::!5640", .dial = "tcp!2001:db8::1!5640", .same = false }, - .{ .bound = "tcp!::!5640", .dial = "tcp!127.0.0.1!5640", .same = false }, - }) |c| try testing.expectEqual(c.same, Client.sameSession(c.dial, "", try networkAddress(c.bound, true), null)); - try testing.expect(Client.sameSession("/tmp/pardes-owned.sock", "/tmp/pardes-owned.sock", null, null)); - try testing.expect(Client.sameSession("unix!/tmp/pardes-owned.sock", "/tmp/pardes-owned.sock", null, null)); - try testing.expect(!Client.sameSession("tcp!127.0.0.1!5640", "/tmp/pardes-owned.sock", null, null)); - if (quic_enabled) { - const endpoint = try networkAddress("quic!127.0.0.1!5640", false); - try testing.expect(Client.sameSession("quic!::ffff:127.0.0.1!5640", "", null, endpoint)); - try testing.expect(!Client.sameSession("tcp!127.0.0.1!5640", "", null, endpoint)); - try testing.expect(!Client.sameSession("quic!127.0.0.1!5640", "", endpoint, null)); - } -} - extern "c" fn mkdtemp(template: [*:0]u8) ?[*:0]u8; extern "c" fn rmdir(path: [*:0]const u8) c_int; @@ -1225,7 +1112,9 @@ test "a listening editor posts itself into the 9P registry and unposts on stop" var link: [sun_path_len]u8 = undefined; { - const l = listen(testing.io, gpa, "unit", "", null, null) orelse return error.ListenFailed; + const p = try pardes.Pardes.init(gpa, .{ .tty_only = true, .cols = 40, .rows = 12 }); + defer p.deinit(); + const l = listen(testing.io, gpa, p, "unit", "", null, null) orelse return error.ListenFailed; defer l.deinit(gpa); // The socket stays exactly where pardes has always bound it: // adopting the registry moves nothing, it only advertises. @@ -1312,7 +1201,7 @@ test "Unix TCP and QUIC share one listener through reads writes reconnects and r var bind_buf: [64]u8 = undefined; const bind = try std.fmt.bufPrint(&bind_buf, "{s}!{s}!0", .{ protocol, host }); const tcp = std.mem.eql(u8, protocol, "tcp"); - const l = listen(testing.io, gpa, "roundtrip", "", if (tcp) bind else null, if (tcp) null else bind) orelse return error.ListenFailed; + const l = listen(testing.io, gpa, p, "roundtrip", "", if (tcp) bind else null, if (tcp) null else bind) orelse return error.ListenFailed; defer { l.reset(p); l.deinit(gpa); @@ -1331,39 +1220,108 @@ test "Unix TCP and QUIC share one listener through reads writes reconnects and r var worker: Worker = .{ .dial = dial, .body_path = body, .expected = if (attempt == 0) "initial\n" else replacement, .replacement = replacement }; const thread = try std.Thread.spawn(.{}, Worker.run, .{&worker}); defer thread.join(); + // The editor rests while the client works: its requests are + // answered on the runner's tasks, not by this thread. const deadline = Client.nowMs() + 3 * Client.budget_ms; + pardes.turn.rest(); while (!worker.done.load(.acquire) and Client.nowMs() < deadline) { - _ = l.tick(p); + if (quic_enabled) { + pardes.turn.wake(); + _ = l.tick(); + pardes.turn.rest(); + } Client.nap(1); } + pardes.turn.wake(); try testing.expect(worker.done.load(.acquire)); if (worker.failure) |err| return err; l.reset(p); try testing.expectEqual(@as(usize, 0), l.runner.count()); - for (&l.slots) |*slot| try testing.expectEqual(@as(usize, 0), slot.len); for (&l.conns, 0..) |conn, i| try testing.expect(!l.live(@intCast(i)) and !conn.draining); for (p.fs.snapshots) |snapshot| try testing.expect(snapshot.node == 0); } }; } +test "a change waits while the editor is out mid-step, a read does not, and the change lands when the editor rests" { + if (comptime !supported) return error.SkipZigTest; + const gpa = testing.allocator; + var directory: [64:0]u8 = undefined; + _ = try std.fmt.bufPrintSentinel(&directory, "/tmp/pardes-park-XXXXXX", .{}, 0); + if (mkdtemp(&directory) == null) return error.TempDirectoryFailed; + defer _ = rmdir(&directory); + const old_runtime = if (libc.getenv("XDG_RUNTIME_DIR")) |v| try gpa.dupeZ(u8, std.mem.span(v)) else null; + defer { + if (old_runtime) |v| { + _ = setenv("XDG_RUNTIME_DIR", v, 1); + gpa.free(v); + } else _ = unsetenv("XDG_RUNTIME_DIR"); + } + try testing.expectEqual(@as(c_int, 0), setenv("XDG_RUNTIME_DIR", &directory, 1)); + + const p = try pardes.Pardes.init(gpa, .{ .tty_only = true, .cols = 40, .rows = 12 }); + defer p.deinit(); + const pane = try p.setTestFile("before\n"); + while (p.nextEffect()) |_| {} + // This thread is the editor's: it has the turn from here on. + const l = listen(testing.io, gpa, p, "park", "", null, null) orelse return error.ListenFailed; + defer { + l.reset(p); + l.deinit(gpa); + } + var body_buf: [64]u8 = undefined; + const body = try std.fmt.bufPrint(&body_buf, "/pane/{d}/body", .{pane.serial}); + + const Writer = struct { + dial: []const u8, + path: []const u8, + done: std.atomic.Value(bool) = .init(false), + failure: ?anyerror = null, + fn run(w: *@This()) void { + defer w.done.store(true, .release); + Client.write(testing.allocator, w.dial, w.path, "after\n") catch |err| { + w.failure = err; + }; + } + }; + var writer: Writer = .{ .dial = l.path(), .path = body }; + + // The editor goes out mid-step -- a Look resolving a path, say -- and a + // write arrives meanwhile. It must not land: the step still holds + // pointers into the pane. A read is answered all the same. + pardes.turn.yield(); + const thread = try std.Thread.spawn(.{}, Writer.run, .{&writer}); + defer thread.join(); + Client.nap(150); + try testing.expect(!writer.done.load(.acquire)); + const seen = try Client.readLimit(gpa, l.path(), body, body, 64); + defer gpa.free(seen); + try testing.expectEqualStrings("before\n", seen); + try testing.expect(!writer.done.load(.acquire)); + pardes.turn.back(); + try testing.expectEqualStrings("before\n", pane.file.?.content); + + // Resting is what lets it in: the parked write is retried, served, and + // the client hears back. + pardes.turn.rest(); + const deadline = Client.nowMs() + Client.budget_ms; + while (!writer.done.load(.acquire) and Client.nowMs() < deadline) Client.nap(1); + pardes.turn.wake(); + try testing.expect(writer.done.load(.acquire)); + if (writer.failure) |err| return err; + try testing.expectEqualStrings("after\n", pane.file.?.content); +} + extern "c" fn setenv(name: [*:0]const u8, value: [*:0]const u8, overwrite: c_int) c_int; extern "c" fn unsetenv(name: [*:0]const u8) c_int; pub fn start(io: std.Io, gpa: std.mem.Allocator, core: *pardes.Pardes) ?*Listener { var name: [16]u8 = undefined; const fallback = std.fmt.bufPrint(&name, "{d}", .{@as(u32, @intCast(libc.getpid()))}) catch unreachable; - const listener = listen(io, gpa, core.opts.ninep_name, fallback, core.opts.ninep_tcp, core.opts.ninep_quic) orelse { + return listen(io, gpa, core, core.opts.ninep_name, fallback, core.opts.ninep_tcp, core.opts.ninep_quic) orelse { core.reportError(0, "9p listener", error.ListenFailed); return null; }; - core.fs.socket_path = listener.path(); - // So the editor can recognise its own tree by name and refuse to walk into - // it through the mount, which would deadlock the loop that serves it. - pardes.filesystem.noteOwnSocket(listener.path()); - core.fs.tcp_address = listener.tcp_address; - core.fs.quic_address = listener.quic_address; - return listener; } /// What a pane shell is told about the editor above it, set into this @@ -1423,7 +1381,7 @@ test "9P shell environment states being inside pardes apart from how to reach it const listener = try testing.allocator.create(Listener); defer testing.allocator.destroy(listener); - listener.* = .{ .io = testing.io }; + listener.* = .{ .io = testing.io, .core = undefined }; // only its path is read const path = "/tmp/pardes-example.sock"; @memcpy(listener.path_buf[0..path.len], path); listener.path_len = path.len; @@ -1549,35 +1507,6 @@ pub const Client = struct { _ = try resolve(&buf, dial); } - pub fn sameSession(dial: []const u8, socket_path: []const u8, tcp_address: ?std.Io.net.IpAddress, quic_address: ?std.Io.net.IpAddress) bool { - if (comptime !supported) return false; - var buf: [sun_path_len]u8 = undefined; - const address = resolve(&buf, dial) catch return false; - switch (address) { - .unix => |path| return socket_path.len != 0 and std.mem.eql(u8, path, socket_path), - .tcp, .quic => |destination| { - var ip = destination; - switch (ip) { - .ip4 => |v4| if (std.mem.allEqual(u8, &v4.bytes, 0)) { - ip = .{ .ip4 = .loopback(v4.port) }; - }, - .ip6 => |v6| if (std.mem.allEqual(u8, &v6.bytes, 0)) { - ip = .{ .ip6 = .loopback(v6.port) }; - }, - } - const bound = canonicalIp((if (address == .tcp) tcp_address else quic_address) orelse return false); - if (ip.getPort() != bound.getPort() or @as(std.Io.net.IpAddress.Family, ip) != @as(std.Io.net.IpAddress.Family, bound)) return false; - if (ip.eql(&bound)) return true; - const wildcard = switch (bound) { - .ip4 => |v4| std.mem.allEqual(u8, &v4.bytes, 0), - .ip6 => |v6| std.mem.allEqual(u8, &v6.bytes, 0), - }; - if (wildcard) return localIp(ip); - return false; - }, - } - } - const Session = struct { fd: c_int, quic: if (quic_enabled) ?quic.Connection else void = if (quic_enabled) null else {}, diff --git a/src/CHANGELOG.md b/src/CHANGELOG.md index e518f97a..0083f97f 100644 --- a/src/CHANGELOG.md +++ b/src/CHANGELOG.md @@ -2,6 +2,19 @@ ## 0.0.3 +- Answer 9P on the connection's task instead of the editor's loop. The core + is single-threaded and `pardes.turn` says whose turn it is with it: the + editor's by default, given up while it waits for input and while a step of + it is out in a syscall, and taken by a connection task to answer a request. + A request that would change a pane while a step is out parks in the engine + and is retried when the editor rests. So a session can open, read and save + its own tree through a mount -- which used to hang it outright, and was + then refused by name -- and the name-based refusal, the in-process routing + of a mount of oneself and the mailbox that shipped every request to the + editor's thread are gone. +- A notice wider than its pane keeps its tail rather than its head: the end + of a message is the file name or the reason. + - Give pty children their own terminal identity. `TERM`, `COLORTERM` and `TERM_PROGRAM` are now written by pardes rather than inherited from whatever launched it, and the child is exec'd with that environment. A macOS `.app` diff --git a/src/detached/server.zig b/src/detached/server.zig index ac9af2ee..3e98fc9d 100644 --- a/src/detached/server.zig +++ b/src/detached/server.zig @@ -156,7 +156,8 @@ pub const Session = struct { inotify_fd: c_int = -1, ninep: ?*ninep_io.Listener = null, ninep_pending: bool = false, - /// Set by the 9P runner's tasks: a request waits for `tick`. + /// A 9P request changed the core since the wake byte was last drained: + /// the next poll returns at once, to draw it. ninep_wake: std.atomic.Value(bool) = .init(false), watches: file_watch.Table = @splat(null), check_files: bool = false, @@ -240,7 +241,7 @@ pub const Session = struct { file_watch.watchPane(s.inotify_fd, &s.watches, @intCast(pane), null, 0, .{ .text = 0 }); _ = file_watch.applyThemeEffect(s.core, s.gpa, s.inotify_fd, &s.watches, 0, false, false); s.check_files = false; - if (s.ninep) |listener| listener.reset(s.core); + if (s.ninep) |listener| listener.reset(replacement); s.ninep_pending = false; replacement.host = s.host(); s.core.deinit(); @@ -587,7 +588,7 @@ pub const Session = struct { if (s.origins()) |c| s.send(c, .detach); } - /// The 9P runner has a request for `tick`: wake the poll loop. + /// A 9P request changed the core: wake the poll loop to draw it. fn wakeNinep(ctx: ?*anyopaque) void { const s = of(ctx); s.ninep_wake.store(true, .release); @@ -596,7 +597,7 @@ pub const Session = struct { fn pollFrame(ctx: ?*anyopaque) void { const s = of(ctx); - if (s.ninep) |l| s.ninep_pending = l.tick(s.core).pending; + if (s.ninep) |l| s.ninep_pending = l.tick().pending; for (&s.ptys, 0..) |*pt, pane| { if (pt.fd < 0) continue; var lbuf: [pardes.memory.limits.host_path_cap + 1]u8 = undefined; @@ -805,11 +806,18 @@ pub const Session = struct { } } } - if (n == 0) return nap(if (timeout_ms == 0) 16 else timeout_ms); + // The wait is the 9P connections' turn with the core. + if (n == 0) { + pardes.turn.rest(); + defer pardes.turn.wake(); + return nap(if (timeout_ms == 0) 16 else timeout_ms); + } var timeout: c_int = if (timeout_ms == 0) -1 else @intCast(@min(timeout_ms, std.math.maxInt(c_int))); if (s.nextWake(now)) |due| timeout = if (timeout < 0) due else @min(timeout, due); if (completed or s.check_files or regridded or s.ninep_pending) timeout = 0; + pardes.turn.rest(); const ready = libc.poll(&fds, @intCast(n), timeout); + pardes.turn.wake(); if (ready > 0) s.dispatch(fds[0..n], src[0..n]); _ = s.drainCompletions(true); s.expire(monotonicMs()); @@ -1134,18 +1142,17 @@ pub fn run(init: std.process.Init, opts: pardes.Options, name: []const u8) !void return error.NoSocket; } - session.ninep = ninep_io.listen(init.io, gpa, opts.ninep_name, name, opts.ninep_tcp, opts.ninep_quic); + session.ninep = ninep_io.listen(init.io, gpa, core, opts.ninep_name, name, opts.ninep_tcp, opts.ninep_quic); if (session.ninep == null) return error.ListenFailed; - session.ninep.?.setWake(&session, Session.wakeNinep); - core.fs.socket_path = session.ninep.?.path(); - core.fs.tcp_address = session.ninep.?.tcp_address; - core.fs.quic_address = session.ninep.?.quic_address; + session.ninep.?.wake_ctx = &session; + session.ninep.?.wake = Session.wakeNinep; const h = session.host(); core.host = h; while (core.nextEffect()) |effect| core.perform(effect); session.in_loop = true; while (!session.core.quit) { + pardes.turn.restoreSettled(); try session.core.pump(h); if (session.core.quit) break; if (session.core.takeRestore()) |path| restore: { diff --git a/src/detached/wire.zig b/src/detached/wire.zig index 6805d980..20b5c093 100644 --- a/src/detached/wire.zig +++ b/src/detached/wire.zig @@ -509,7 +509,7 @@ const Ul = @FieldType(pardes.CellStyle, "ul"); /// which is the whole property the six hand-written switches this replaced /// existed for, in a form that cannot fall out of step. A variant that has to /// travel under a DIFFERENT name than the core's gets an arm of its own before -/// the `inline else`, exactly as `clientTag` keeps `.fs_req`. +/// the `inline else`, exactly as `clientTag` keeps the machine-local reports. fn putUl(w: *Writer, u: Ul) Error!void { try w.putByte(switch (u) { inline else => |t| @intFromEnum(@field(UlTag, @tagName(t))), @@ -819,7 +819,7 @@ fn clientTag(msg: ClientMsg) ClientTag { return switch (msg) { .event => |ev| switch (ev) { // Machine-local reports and 9P requests belong to the session owner. - .output, .eof, .lsp_resp, .pipe_resp, .file_changed, .tick, .fs_req => unreachable, + .output, .eof, .lsp_resp, .pipe_resp, .file_changed, .tick => unreachable, inline else => |_, t| @field(ClientTag, @tagName(t)), }, inline else => |_, t| @field(ClientTag, @tagName(t)), @@ -946,7 +946,7 @@ pub fn encodeClient(out: []u8, msg: ClientMsg) Error![]const u8 { .touch_scroll => |v| try w.putF32(v), .pointer_leave => {}, // See `clientTag`: no tag, so nothing to encode. - .output, .eof, .lsp_resp, .pipe_resp, .file_changed, .tick, .fs_req => unreachable, + .output, .eof, .lsp_resp, .pipe_resp, .file_changed, .tick => unreachable, }, } try finishMessage(&w, at); @@ -1076,7 +1076,7 @@ pub fn clientBound(msg: ClientMsg) usize { .paste => |b| b.len, .command => |line| line.len, // See `clientTag`: not on this wire in this direction. - .output, .eof, .lsp_resp, .pipe_resp, .file_changed, .tick, .fs_req => unreachable, + .output, .eof, .lsp_resp, .pipe_resp, .file_changed, .tick => unreachable, }, }; } diff --git a/src/file_watch.zig b/src/file_watch.zig index b2908eb7..dfcce65f 100644 --- a/src/file_watch.zig +++ b/src/file_watch.zig @@ -382,6 +382,10 @@ fn watchPath( } const declared_path = path orelse return; const watched_path = filesystem.localPath(declared_path) orelse return; + // The path may lie in a mount this editor serves, and marking it is a + // stat and a lookup out there: the turn goes out with them. + pardes.turn.yield(); + defer pardes.turn.back(); const stat = std.Io.Dir.cwd().statFile(std.Io.Threaded.global_single_threaded.io(), watched_path, .{}) catch null; const dir = if (stat != null and stat.?.kind == .directory) watched_path else std.fs.path.dirname(watched_path) orelse "."; var dir_buf: [4096:0]u8 = undefined; @@ -601,6 +605,8 @@ pub fn reloadTheme( pub fn identify(io: std.Io, path: []const u8) !Identity { const native = filesystem.localPath(path) orelse return error.NonLocalPath; + pardes.turn.yield(); + defer pardes.turn.back(); const stat = try std.Io.Dir.cwd().statFile(io, native, .{}); if (stat.kind != .file) return error.NotFile; return .{ diff --git a/src/fs.zig b/src/fs.zig index 9200236d..85eae825 100644 --- a/src/fs.zig +++ b/src/fs.zig @@ -64,10 +64,9 @@ pub const WriteError = error{ WriteFailed, }; +/// The host takes the bytes. The caller has given the turn up (`write`), +/// because the path may be a mount this editor serves. pub fn writeFile(path: []const u8, bytes: []const u8) WriteError!void { - // No core here to answer from, so the only safe answer is no answer: an - // open(2) into our own mount is the call that never returns. - if (isOwnMount(path)) return error.OpenFailed; var pathbuf: [4096:0]u8 = undefined; if (path.len >= pathbuf.len) return error.PathTooLong; if (std.mem.indexOfScalar(u8, path, 0) != null) return error.OpenFailed; @@ -124,12 +123,21 @@ fn osNode(p: *pardes.Pardes, path: []const u8) !u64 { return node; } +/// The host filesystem under /os. Every syscall here may go out through a +/// mount this editor serves, so the turn is given up around each and taken +/// back before the core is touched; `path` is the table entry's own copy and +/// outlives the yield, and nothing is staged into the shared reply buffer +/// until the turn is back. pub fn osHandle(p: *pardes.Pardes, req: Req) Reply { if (comptime !platform_has_fs) return Reply.fail(req.tag, E.NOENT); const path = osPath(p, req.node) orelse return Reply.fail(req.tag, E.NOENT); if (req.op == .release) return .{ .tag = req.tag }; const io = std.Io.Threaded.global_single_threaded.io(); - const stat = std.Io.Dir.cwd().statFile(io, path, .{}) catch return Reply.fail(req.tag, E.NOENT); + const stat = stat: { + pardes.turn.yield(); + defer pardes.turn.back(); + break :stat std.Io.Dir.cwd().statFile(io, path, .{}) catch return Reply.fail(req.tag, E.NOENT); + }; const attr: Reply.Attr = .{ .name = if (req.node == os_root) "os" else std.fs.path.basename(path), .node = req.node, .dir = stat.kind == .directory, .size = stat.size, .mode = if (stat.kind == .directory) 0o755 else 0o644, .mtime = std.math.cast(u32, stat.mtime.toSeconds()) orelse 0 }; switch (req.op) { .getattr => return .{ .tag = req.tag, .attr = attr }, @@ -150,52 +158,67 @@ pub fn osHandle(p: *pardes.Pardes, req: Req) Reply { return osHandle(p, .{ .tag = req.tag, .op = .getattr, .node = node }); }, .readdir => { - var dir = std.Io.Dir.cwd().openDir(io, path, .{ .iterate = true }) catch return Reply.fail(req.tag, E.NOTDIR); - defer dir.close(io); - var it = dir.iterate(); - const out = p.fs.stage(p.gpa); - var skip = req.off; - while (it.next(io) catch return Reply.fail(req.tag, E.IO)) |entry| { - var buf: [4096]u8 = undefined; - const joined = std.fmt.bufPrint(&buf, "{s}/{s}", .{ std.mem.trimEnd(u8, path, "/"), entry.name }) catch continue; - var normalized_buf: [4096]u8 = undefined; - const normalized = resolveOs(joined, &normalized_buf) orelse continue; - const child = dir.statFile(io, entry.name, .{}) catch continue; - if (skip > 0) { - skip -= 1; - continue; + // Listed into a buffer of this request's own first; the shared + // reply buffer is another request's to use while the turn is out. + var listing: [16 * 1024]u8 = undefined; + var fixed: std.heap.FixedBufferAllocator = .init(&listing); + var listed: std.ArrayList(u8) = .empty; + { + pardes.turn.yield(); + defer pardes.turn.back(); + var dir = std.Io.Dir.cwd().openDir(io, path, .{ .iterate = true }) catch return Reply.fail(req.tag, E.NOTDIR); + defer dir.close(io); + var it = dir.iterate(); + var skip = req.off; + while (it.next(io) catch return Reply.fail(req.tag, E.IO)) |entry| { + var buf: [4096]u8 = undefined; + const joined = std.fmt.bufPrint(&buf, "{s}/{s}", .{ std.mem.trimEnd(u8, path, "/"), entry.name }) catch continue; + var normalized_buf: [4096]u8 = undefined; + const normalized = resolveOs(joined, &normalized_buf) orelse continue; + const child = dir.statFile(io, entry.name, .{}) catch continue; + if (skip > 0) { + skip -= 1; + continue; + } + const node = if (std.mem.eql(u8, normalized.path, "/")) os_root else os_node | (std.hash.Wyhash.hash(0, normalized.path) & (os_node - 1)); + tree.stageDirent(&listed, fixed.allocator(), node, child.kind == .directory, entry.name); + if (listed.items.len >= @max(req.size, 512)) break; } - const node = if (std.mem.eql(u8, normalized.path, "/")) os_root else os_node | (std.hash.Wyhash.hash(0, normalized.path) & (os_node - 1)); - tree.stageDirent(out, p.gpa, node, child.kind == .directory, entry.name); - if (out.items.len >= @max(req.size, 512)) break; } + const out = p.fs.stage(p.gpa); + out.appendSlice(p.gpa, listed.items) catch return Reply.fail(req.tag, E.NOMEM); return .{ .tag = req.tag, .payload = .{ .staged = @intCast(out.items.len) } }; }, .read, .write, .setattr => { if (stat.kind != .file) return Reply.fail(req.tag, E.PERM); var z: [4096]u8 = undefined; const path_z = std.fmt.bufPrintSentinel(&z, "{s}", .{path}, 0) catch return Reply.fail(req.tag, E.NOENT); - const fd = libc.open(path_z, .{ .ACCMODE = if (req.op == .read) .RDONLY else .WRONLY, .NONBLOCK = true, .CLOEXEC = true }); - if (fd < 0) return Reply.fail(req.tag, E.PERM); - defer _ = libc.close(fd); - if (req.op == .setattr) { - if (!req.truncate or req.off != 0 or libc.ftruncate(fd, 0) != 0) return Reply.fail(req.tag, E.INVAL); - var truncated = attr; - truncated.size = 0; - return .{ .tag = req.tag, .attr = truncated }; - } - if (req.off > std.math.maxInt(i64)) return Reply.fail(req.tag, E.INVAL); - if (libc.lseek(fd, @intCast(req.off), libc.SEEK.SET) < 0) return Reply.fail(req.tag, E.IO); - if (req.op == .write) { - const written = libc.write(fd, req.data.ptr, req.data.len); - if (written < 0) return Reply.fail(req.tag, E.IO); - return .{ .tag = req.tag, .written = @intCast(written) }; - } + var buf: [ninep_io.msize]u8 = undefined; // a read never asks for more than a frame + const got = io: { + pardes.turn.yield(); + defer pardes.turn.back(); + const fd = libc.open(path_z, .{ .ACCMODE = if (req.op == .read) .RDONLY else .WRONLY, .NONBLOCK = true, .CLOEXEC = true }); + if (fd < 0) return Reply.fail(req.tag, E.PERM); + defer _ = libc.close(fd); + if (req.op == .setattr) { + if (!req.truncate or req.off != 0 or libc.ftruncate(fd, 0) != 0) return Reply.fail(req.tag, E.INVAL); + var truncated = attr; + truncated.size = 0; + return .{ .tag = req.tag, .attr = truncated }; + } + if (req.off > std.math.maxInt(i64)) return Reply.fail(req.tag, E.INVAL); + if (libc.lseek(fd, @intCast(req.off), libc.SEEK.SET) < 0) return Reply.fail(req.tag, E.IO); + if (req.op == .write) { + const written = libc.write(fd, req.data.ptr, req.data.len); + if (written < 0) return Reply.fail(req.tag, E.IO); + return .{ .tag = req.tag, .written = @intCast(written) }; + } + const got = libc.read(fd, &buf, @min(req.size, buf.len)); + if (got < 0) return Reply.fail(req.tag, E.IO); + break :io @as(usize, @intCast(got)); + }; const out = p.fs.stage(p.gpa); - out.resize(p.gpa, @min(req.size, 65536)) catch return Reply.fail(req.tag, E.NOMEM); - const got = libc.read(fd, out.items.ptr, out.items.len); - if (got < 0) return Reply.fail(req.tag, E.IO); - out.shrinkRetainingCapacity(@intCast(got)); + out.appendSlice(p.gpa, buf[0..got]) catch return Reply.fail(req.tag, E.NOMEM); return .{ .tag = req.tag, .payload = .{ .staged = @intCast(got) } }; }, else => return Reply.fail(req.tag, E.PERM), @@ -378,21 +401,22 @@ test "bounded reads accept exact OS file lengths and empty files" { const empty = try readLimit(p, explicit, 0); defer gpa.free(empty); try std.testing.expectEqual(@as(usize, 0), empty.len); - try std.testing.expectEqual(@as(usize, 0), p.fs.os_paths.items.len); + // The directory's node stays in the table for the listener to collect + // once no connection names it (src/9p_io.zig, collectOs): a client may + // have walked to the same directory meanwhile and hold it by that node. + try std.testing.expectEqual(@as(usize, 1), p.fs.os_paths.items.len); + try std.testing.expectEqualStrings(native, p.fs.os_paths.items[0].path); } test "bounded reads apply the same limits to self bodies and embedded sources" { const gpa = std.testing.allocator; const p = try Pardes.init(gpa, .{ .tty_only = true }); defer p.deinit(); - p.fs.socket_path = "/tmp/pardes-limited-in-process.sock"; - try p.fs.mount(gpa, "own", p.fs.socket_path); var contents: [8209]u8 = @splat('x'); contents[contents.len - 1] = '\n'; for ([_][]const u8{ &contents, "" }) |expected| { const pane = try p.setTestFile(expected); - for ([_][]const u8{ "/virtual", "/n/self", "/n/own" }) |prefix| { - if (!platform_has_fs and std.mem.eql(u8, prefix, "/n/own")) continue; + for ([_][]const u8{ "/virtual", "/n/self" }) |prefix| { var path_buf: [128]u8 = undefined; const path = try std.fmt.bufPrint(&path_buf, "{s}/pane/{d}/body", .{ prefix, pane.serial }); const bytes = try readLimit(p, path, expected.len); @@ -407,8 +431,7 @@ test "bounded reads apply the same limits to self bodies and embedded sources" { } if (limits.embedded_sources) { const source = findEmbeddedSource("src/look.zig", false).?; - for ([_][]const u8{ "/virtual/src/look.zig", "/n/self/src/look.zig", "/n/own/src/look.zig" }) |path| { - if (!platform_has_fs and std.mem.startsWith(u8, path, "/n/own/")) continue; + for ([_][]const u8{ "/virtual/src/look.zig", "/n/self/src/look.zig" }) |path| { const bytes = try readLimit(p, path, source.contents.len); defer gpa.free(bytes); try std.testing.expectEqualStrings(source.contents, bytes); @@ -425,10 +448,8 @@ test "bounded reads count rendered directory paths and unknown self lengths" { const gpa = std.testing.allocator; const p = try Pardes.init(gpa, .{ .tty_only = true }); defer p.deinit(); - p.fs.socket_path = "/tmp/pardes-limited-in-process.sock"; - try p.fs.mount(gpa, "own", p.fs.socket_path); - for ([_][]const u8{ "/n", "/virtual", "/n/self", "/n/own", "/n/own/pane", "/virtual/listeners", "/virtual/README" }) |path| { - if (!platform_has_fs and std.mem.startsWith(u8, path, "/n/own")) continue; + p.fs.socket_path = "/tmp/pardes-limited-in-process.sock"; // so listeners has a line + for ([_][]const u8{ "/n", "/virtual", "/n/self", "/virtual/pane", "/virtual/listeners", "/virtual/README" }) |path| { const expected = try read(p, path); defer gpa.free(expected); try std.testing.expect(expected.len > 0); @@ -573,49 +594,6 @@ test "virtual body writes can read their input from the same pane" { try std.testing.expectEqualStrings("pane contents\n", pane.file.?.content); } -test "same-core mount directories preserve their mount prefix across reads" { - if (!platform_has_fs) return error.SkipZigTest; - const gpa = std.testing.allocator; - const p = try pardes.Pardes.init(gpa, .{ .tty_only = true }); - defer p.deinit(); - const socket_path = "/tmp/pardes-in-process-mount.sock"; - p.fs.socket_path = socket_path; - try p.fs.mount(gpa, "own", socket_path); - const roots = try read(p, "/n/own"); - defer gpa.free(roots); - try std.testing.expect(std.mem.startsWith(u8, roots, "/n/own/README\n/n/own/index\n")); - try std.testing.expect(std.mem.indexOf(u8, roots, "/n/own/pane/\n/n/own/os/\n") != null); - try std.testing.expectError(error.NotADirectory, read(p, "/n/own/index/..")); - try std.testing.expectError(error.FileNotFound, read(p, "/n/own/self/index")); - - var tmp = std.testing.tmpDir(.{}); - defer tmp.cleanup(); - for (0..520) |i| { - var name: [32]u8 = undefined; - try tmp.dir.writeFile(std.testing.io, .{ .sub_path = try std.fmt.bufPrint(&name, "entry-{d:0>4}.txt", .{i}), .data = "child\n" }); - } - var directory_buffer: [4096]u8 = undefined; - const directory = directory_buffer[0..try tmp.dir.realPath(std.testing.io, &directory_buffer)]; - const held_node = try osNode(p, directory); - const path = try std.fmt.allocPrint(gpa, "/n/own/os{s}", .{directory}); - defer gpa.free(path); - const listing = try read(p, path); - defer gpa.free(listing); - var entries = std.mem.tokenizeScalar(u8, listing, '\n'); - var count: usize = 0; - while (entries.next()) |entry| { - try std.testing.expect(std.mem.startsWith(u8, entry, path)); - const child = try read(p, entry); - defer gpa.free(child); - try std.testing.expectEqualStrings("child\n", child); - try std.testing.expectEqual(@as(usize, 1), p.fs.os_paths.items.len); - count += 1; - } - try std.testing.expectEqual(@as(usize, 520), count); - try std.testing.expectEqual(held_node, p.fs.os_paths.items[0].node); - try std.testing.expectEqualStrings(directory, p.fs.os_paths.items[0].path); -} - pub fn isVirtual(path: []const u8) bool { return std.mem.eql(u8, path, "/virtual") or std.mem.startsWith(u8, path, "/virtual/") or std.mem.eql(u8, path, "/n") or std.mem.startsWith(u8, path, "/n/"); @@ -674,9 +652,6 @@ pub fn resolve(p: ?*pardes.Pardes, word: []const u8, cwd: []const u8, out: *[409 } if (std.mem.eql(u8, joined, "/virtual")) return resolveVirtual(p, "/", out); if (std.mem.startsWith(u8, joined, "/virtual/")) return resolveVirtual(p, joined[8..], out); - // This editor's own tree, seen through a mount: answer from the tree - // instead of walking out into the view and back in. - if (ownMountSuffix(joined)) |inner| return resolveVirtual(p, inner, out); if (resolveOs(joined, out)) |found| return found; if (resolveVirtual(p, joined, out)) |found| return found; if (resolveVirtual(p, word, out)) |found| return found; @@ -687,116 +662,15 @@ pub fn resolve(p: ?*pardes.Pardes, word: []const u8, cwd: []const u8, out: *[409 return null; } -/// The name this session is posted under, taken from its socket path. -/// As wide as a name a listener will accept, so there is no session whose -/// name is too long to recognise and therefore too long to protect. -var own_name_buf: [108]u8 = undefined; -var own_name_len: usize = 0; - -pub fn noteOwnSocket(socket_path: []const u8) void { - own_name_len = 0; - const base = std.fs.path.basename(socket_path); - const head = "pardes-9p-"; - const tail = ".sock"; - if (!std.mem.startsWith(u8, base, head) or !std.mem.endsWith(u8, base, tail)) return; - const name = base[head.len .. base.len - tail.len]; - if (name.len == 0 or name.len > own_name_buf.len) return; - @memcpy(own_name_buf[0..name.len], name); - own_name_len = name.len; -} - -/// What this path names inside this editor's OWN 9P tree, if it does: -/// `/mnt/9p/pardes//pane/3/body` -> `pane/3/body`, and the mount root -/// itself -> `/`. -/// -/// A mount is a VIEW of a tree this editor already holds. Going out through -/// the view to reach it deadlocks the session outright -- the realpath, the -/// stat and the read all leave through the mount and come back as 9P requests -/// only this editor's loop can answer, while that loop is blocked making them, -/// and the filesystem then stops answering anybody. So the view is recognised -/// by NAME, before any syscall (the syscall is the thing that never returns), -/// and the request is served from the tree directly. Same answer, no round -/// trip, and a session can drive itself through its own 9P namespace. -pub fn ownMountSuffix(path: []const u8) ?[]const u8 { - if (own_name_len == 0 or path.len == 0 or path[0] != '/') return null; - // Whole components, and the registry's own layout: a session is posted at - // `/9p/pardes/` and mounts group under `/mnt/9p/pardes/`. - // Matching a bare `/pardes/` anywhere in the string would claim - // `~/src/pardes//README` -- an ordinary directory that happens to - // read like a mount -- and serve the tree's README over the real file. - var buf: [own_name_buf.len + 16]u8 = undefined; - const stem = std.fmt.bufPrint(&buf, "/9p/pardes/{s}", .{own_name_buf[0..own_name_len]}) catch return null; - var at: usize = 0; - while (std.mem.indexOfPos(u8, path, at, stem)) |found| : (at = found + 1) { - const rest = path[found + stem.len ..]; - if (rest.len != 0 and rest[0] != '/') continue; // a longer name that merely starts the same - if (rest.len <= 1) return "/"; - return rest[1..]; - } - return null; -} - -pub fn isOwnMount(path: []const u8) bool { - return ownMountSuffix(path) != null; -} - -test "a path inside this session's own mount is answered from the tree, not through the mount" { - noteOwnSocket("/run/user/1000/pardes-9p-demo.sock"); - defer own_name_len = 0; - // What the path names inside the tree, with the mount prefix taken off. - try std.testing.expectEqualStrings("index", ownMountSuffix("/mnt/9p/pardes/demo/index").?); - try std.testing.expectEqualStrings("pane/new", ownMountSuffix("/mnt/9p/pardes/demo/pane/new").?); - try std.testing.expectEqualStrings("/", ownMountSuffix("/mnt/9p/pardes/demo").?); - try std.testing.expectEqualStrings("/", ownMountSuffix("/mnt/9p/pardes/demo/").?); - // The registry posts the session there too, so that spelling counts. - try std.testing.expectEqualStrings("index", ownMountSuffix("/run/user/1000/9p/pardes/demo/index").?); - // Another session's mount is somebody else's to answer, and a name that - // merely STARTS with ours is a different name. - try std.testing.expect(ownMountSuffix("/mnt/9p/pardes/other/index") == null); - try std.testing.expect(ownMountSuffix("/mnt/9p/pardes/demo2/index") == null); - // An ordinary directory that reads like a mount is an ordinary directory. - // Serving the tree here would hand back the tree's README for the file on - // disk, and -- before `write` learned the same trick -- write the tree's - // bytes over it. - try std.testing.expect(ownMountSuffix("/home/goblin/src/pardes/demo/README") == null); - try std.testing.expect(ownMountSuffix("/home/goblin/src/pardes/demo.zig") == null); - // Relative paths never name a mount: they are resolved against a cwd first. - try std.testing.expect(ownMountSuffix("mnt/9p/pardes/demo/index") == null); - - // The syscall is the thing that never returns, so it is never made. - var out: [4096]u8 = undefined; - try std.testing.expect(resolveOs("/mnt/9p/pardes/demo/index", &out) == null); - - // A session with no listener has no name, so nothing is redirected. - noteOwnSocket("/tmp/not-a-pardes-socket"); - try std.testing.expect(ownMountSuffix("/mnt/9p/pardes/demo/index") == null); -} - -test "reading this session's own mount returns what the tree holds" { - const p = try pardes.Pardes.init(std.testing.allocator, .{ .tty_only = true, .cols = 80, .rows = 24 }); - defer p.deinit(); - noteOwnSocket("/run/user/1000/pardes-9p-selfread.sock"); - defer own_name_len = 0; - - const direct = try read(p, "/n/self/index"); - defer p.gpa.free(direct); - const mounted = try read(p, "/mnt/9p/pardes/selfread/index"); - defer p.gpa.free(mounted); - try std.testing.expectEqualStrings(direct, mounted); - try std.testing.expect(direct.len > 0); - - // A write goes to the same tree the read came from, not out through the - // mount: `/index` is 0400 there, and an OS write would instead try to - // create a file under a directory that does not exist. - try std.testing.expectError(error.ReadOnlyFilesystem, write(p, "/mnt/9p/pardes/selfread/index", "nope\n")); - try std.testing.expectError(error.ReadOnlyFilesystem, write(p, "/n/self/index", "nope\n")); -} - +/// Where a path really is on the host, and whether it is a directory. The +/// path may lie in a mount this editor serves, so the turn is given up for +/// the syscalls: another thread answers them. pub fn resolveOs(path: []const u8, out: *[4096]u8) ?Resolved { if (comptime !platform_has_fs) return null; - if (isOwnMount(path)) return null; var z: [4096]u8 = undefined; const path_z = std.fmt.bufPrintSentinel(&z, "{s}", .{path}, 0) catch return null; + pardes.turn.yield(); + defer pardes.turn.back(); const resolved = realpath(path_z, out) orelse return null; return .{ .path = std.mem.span(resolved), .dir = isDir(resolved) }; } @@ -818,13 +692,6 @@ pub fn read(p: *pardes.Pardes, path: []const u8) ![]u8 { } pub fn readLimit(p: *pardes.Pardes, path: []const u8, max_bytes: usize) ![]u8 { - // The same view, reached by a reader that never went through `resolve`. - // The rewritten path cannot contain the mount stem, so this recurses once. - if (ownMountSuffix(path)) |inner| { - var self_buf: [4096]u8 = undefined; - const internal = std.fmt.bufPrint(&self_buf, "/n/self/{s}", .{inner}) catch return error.FileTooLarge; - return readLimit(p, internal, max_bytes); - } const limit = @min(max_bytes, limits.max_file_bytes); if (std.mem.eql(u8, std.mem.trimEnd(u8, path, "/"), "/n")) { var out: std.Io.Writer.Allocating = .init(p.gpa); @@ -847,11 +714,8 @@ pub fn readLimit(p: *pardes.Pardes, path: []const u8, max_bytes: usize) ![]u8 { var native_buf: [4096]u8 = undefined; const native = resolveOs(remote_path, &native_buf) orelse return readFileLimit(p.gpa, path, limit); if (!native.dir) return readFileLimit(p.gpa, path, limit); - const saved_paths = p.fs.os_paths.items.len; - defer { - for (p.fs.os_paths.items[saved_paths..]) |temporary| p.gpa.free(temporary.path); - p.fs.os_paths.shrinkRetainingCapacity(saved_paths); - } + // The node stays in the table until no connection names it either + // (src/9p_io.zig, collectOs): a client may have walked to it too. const node = try osNode(p, native.path); return readNode(p, node, path, limit); } @@ -861,25 +725,10 @@ pub fn readLimit(p: *pardes.Pardes, path: []const u8, max_bytes: usize) ![]u8 { } for (p.fs.mounts.items) |mount| { if (!std.mem.eql(u8, name, mount.name)) continue; - if (ninep_io.Client.sameSession(mount.dial, p.fs.socket_path, p.fs.tcp_address, p.fs.quic_address)) { - const saved_paths = p.fs.os_paths.items.len; - defer { - for (p.fs.os_paths.items[saved_paths..]) |temporary| p.gpa.free(temporary.path); - p.fs.os_paths.shrinkRetainingCapacity(saved_paths); - } - var node = tree.root; - var directory = true; - var parts = std.mem.tokenizeScalar(u8, remote_path, '/'); - while (parts.next()) |part| { - if (!directory) return error.NotADirectory; - if (std.mem.eql(u8, part, ".")) continue; - const reply = tree.handle(p, .{ .tag = 0, .op = .lookup, .node = node, .data = part }); - if (reply.status != .ok) return error.FileNotFound; - node = reply.attr.node; - directory = reply.attr.dir; - } - return readNode(p, node, path, limit); - } + // A peer answers on its own time, and the peer may be this very + // editor: the turn goes out with the request. + pardes.turn.yield(); + defer pardes.turn.back(); return ninep_io.Client.readLimit(p.gpa, mount.dial, remote_path, path, limit); } return error.FileNotFound; @@ -940,68 +789,64 @@ fn readNode(p: *pardes.Pardes, initial_node: u64, path: []const u8, limit: usize } } +/// The editor's, between steps: a save or a dump the shell is performing, +/// never a step of the core. pub fn write(p: *pardes.Pardes, path: []const u8, bytes: []const u8) !void { - // The same view `readLimit` answers from the tree, so a write lands where - // the matching read came from -- and, just as importantly, never becomes - // an open(2) through a mount this loop is the one that answers. - if (ownMountSuffix(path)) |inner| { - var self_buf: [4096]u8 = undefined; - const internal = std.fmt.bufPrint(&self_buf, "/n/self/{s}", .{inner}) catch return error.PathTooLong; - return write(p, internal, bytes); - } if (std.mem.eql(u8, std.mem.trimEnd(u8, path, "/"), "/n")) return error.IsDirectory; - var self_path: ?[]const u8 = null; - if (std.mem.eql(u8, path, "/virtual")) self_path = ""; - if (std.mem.startsWith(u8, path, "/virtual/")) self_path = path[9..]; - if (std.mem.startsWith(u8, path, "/n/")) { - const explicit = path[3..]; - const cut = std.mem.indexOfScalar(u8, explicit, '/') orelse explicit.len; - const name = explicit[0..cut]; - const remote_path = if (cut < explicit.len) explicit[cut..] else "/"; - if (std.mem.eql(u8, name, "os")) return writeFile(remote_path, bytes); - if (std.mem.eql(u8, name, "self")) { - self_path = remote_path; - } else { - for (p.fs.mounts.items) |mount| { - if (!std.mem.eql(u8, name, mount.name)) continue; - if (ninep_io.Client.sameSession(mount.dial, p.fs.socket_path, p.fs.tcp_address, p.fs.quic_address)) { - var buf: [4096]u8 = undefined; - const local = try std.fmt.bufPrint(&buf, "/n{s}", .{remote_path}); - return write(p, local, bytes); - } - return ninep_io.Client.write(p.gpa, mount.dial, remote_path, bytes); - } - return error.FileNotFound; - } + if (std.mem.eql(u8, path, "/virtual")) return writeSelf(p, "", bytes); + if (std.mem.startsWith(u8, path, "/virtual/")) return writeSelf(p, path[9..], bytes); + if (!std.mem.startsWith(u8, path, "/n/")) return writeOut(p, null, path, bytes); + const explicit = path[3..]; + const cut = std.mem.indexOfScalar(u8, explicit, '/') orelse explicit.len; + const name = explicit[0..cut]; + const remote_path = if (cut < explicit.len) explicit[cut..] else "/"; + if (std.mem.eql(u8, name, "os")) return writeOut(p, null, remote_path, bytes); + if (std.mem.eql(u8, name, "self")) return writeSelf(p, remote_path, bytes); + for (p.fs.mounts.items) |mount| { + if (std.mem.eql(u8, name, mount.name)) return writeOut(p, mount.dial, remote_path, bytes); } - if (self_path) |name| { - var node = tree.resolveSelf(p, name) orelse return error.FileNotFound; - const attributes = tree.handle(p, .{ .tag = 0, .op = .getattr, .node = node }); - if (attributes.status != .ok) return error.FileNotFound; - if (attributes.attr.dir) return error.IsDirectory; - if (attributes.attr.mode & 0o200 == 0) return error.ReadOnlyFilesystem; - const opened = tree.handle(p, .{ .tag = 0, .op = .open, .node = node }); - if (opened.status != .ok) return error.OpenFailed; - if (opened.attr.node != 0) node = opened.attr.node; - defer _ = tree.handle(p, .{ .tag = 0, .op = .release, .node = node, .handle = opened.handle }); - var preserved: ?[]u8 = null; - defer if (preserved) |copy| p.gpa.free(copy); - const target = tree.Node.target(node); - if (target != null and target.? == .pane and target.?.pane.file == .body) { - preserved = try p.gpa.dupe(u8, bytes); - const trunc = tree.handle(p, .{ .tag = 0, .op = .setattr, .node = node, .truncate = true }); - if (trunc.status != .ok) return error.WriteFailed; - } - const contents = preserved orelse bytes; - var off: usize = 0; - while (off < contents.len) { - const reply = tree.handle(p, .{ .tag = 0, .op = .write, .node = node, .off = off, .data = contents[off..] }); - if (reply.status != .ok or reply.written == 0) return error.WriteFailed; - off += reply.written; - } - return; + return error.FileNotFound; +} + +/// The host, or the peer at `dial`, takes the bytes with the turn given up +/// entirely -- the peer may be this very editor, and a write it serves may +/// change any pane -- so they are copied first: `bytes` is usually a pane's +/// own text. +fn writeOut(p: *pardes.Pardes, dial: ?[]const u8, path: []const u8, bytes: []const u8) !void { + const copy = try p.gpa.dupe(u8, bytes); + defer p.gpa.free(copy); + pardes.turn.rest(); + defer pardes.turn.wake(); + if (dial) |d| return ninep_io.Client.write(p.gpa, d, path, copy); + return writeFile(path, copy); +} + +/// This editor's own tree, written in place. +fn writeSelf(p: *pardes.Pardes, name: []const u8, bytes: []const u8) !void { + var node = tree.resolveSelf(p, name) orelse return error.FileNotFound; + const attributes = tree.handle(p, .{ .tag = 0, .op = .getattr, .node = node }); + if (attributes.status != .ok) return error.FileNotFound; + if (attributes.attr.dir) return error.IsDirectory; + if (attributes.attr.mode & 0o200 == 0) return error.ReadOnlyFilesystem; + const opened = tree.handle(p, .{ .tag = 0, .op = .open, .node = node }); + if (opened.status != .ok) return error.OpenFailed; + if (opened.attr.node != 0) node = opened.attr.node; + defer _ = tree.handle(p, .{ .tag = 0, .op = .release, .node = node, .handle = opened.handle }); + var preserved: ?[]u8 = null; + defer if (preserved) |copy| p.gpa.free(copy); + const target = tree.Node.target(node); + if (target != null and target.? == .pane and target.?.pane.file == .body) { + preserved = try p.gpa.dupe(u8, bytes); + const trunc = tree.handle(p, .{ .tag = 0, .op = .setattr, .node = node, .truncate = true }); + if (trunc.status != .ok) return error.WriteFailed; + } + const contents = preserved orelse bytes; + var off: usize = 0; + while (off < contents.len) { + const reply = tree.handle(p, .{ .tag = 0, .op = .write, .node = node, .off = off, .data = contents[off..] }); + if (reply.status != .ok or reply.written == 0) return error.WriteFailed; + off += reply.written; } - return writeFile(path, bytes); } fn resolveEmbedded(word: []const u8, cwd: []const u8, scratch: *[4096]u8) ?Source { @@ -1069,6 +914,8 @@ pub fn find(arena: std.mem.Allocator, dir: []const u8, pat: []const u8, out: []u var hits: [find_max_hits][]const u8 = undefined; var hits_len: usize = 0; if (platform_has_fs) { + pardes.turn.yield(); + defer pardes.turn.back(); const io = std.Io.Threaded.global_single_threaded.io(); var root = try std.Io.Dir.cwd().openDir(io, dir, .{ .iterate = true }); defer root.close(io); @@ -1152,6 +999,9 @@ pub fn grep(arena: std.mem.Allocator, gpa: std.mem.Allocator, dir: []const u8, b const home = std.mem.trimEnd(u8, base, "/"); const files = try arena.alloc([]const u8, grep_max_files); var files_len: usize = 0; + // A walk and thousands of reads: the turn goes out for all of it. + pardes.turn.yield(); + defer pardes.turn.back(); { const io = std.Io.Threaded.global_single_threaded.io(); var root = try std.Io.Dir.cwd().openDir(io, dir, .{ .iterate = true }); @@ -1311,10 +1161,6 @@ test "Restore prefers default directory then falls back to original path" { fn readFileLimit(gpa: std.mem.Allocator, path: []const u8, limit: usize) ![]u8 { if (std.mem.indexOfScalar(u8, path, 0) != null) return error.OpenFailed; - // Same reason as `writeFile`: no core to answer from here, and the open is - // the call that never returns. Callers holding one use `readLimit`, which - // serves the tree instead. - if (isOwnMount(path)) return error.FileNotFound; if (!platform_has_fs or std.mem.startsWith(u8, path, "/virtual/")) { const archive_path = if (std.mem.startsWith(u8, path, "/virtual/")) path[9..] else path; var normalized_buf: [4096]u8 = undefined; @@ -1326,6 +1172,10 @@ fn readFileLimit(gpa: std.mem.Allocator, path: []const u8, limit: usize) ![]u8 { var pathbuf: [4096]u8 = undefined; const native = localPath(path) orelse return error.OpenFailed; const path_z = std.fmt.bufPrintSentinel(&pathbuf, "{s}", .{native}, 0) catch return error.PathTooLong; + // The path may be a mount this editor serves: the turn goes out with the + // syscalls, and the bytes come back into memory of the caller's own. + pardes.turn.yield(); + defer pardes.turn.back(); const fd = libc.open(path_z, .{ .ACCMODE = .RDONLY, .NONBLOCK = true }); if (fd < 0) return switch (libc.errno(fd)) { .ACCES, .PERM => error.PermissionDenied, diff --git a/src/gui/gui.zig b/src/gui/gui.zig index 3c2fd693..8da6f933 100644 --- a/src/gui/gui.zig +++ b/src/gui/gui.zig @@ -2422,6 +2422,7 @@ fn localSession( defer pardes.lsp.setStatusSink(null, null); while (!core.quit) { + pardes.turn.restoreSettled(); try core.pump(host); if (core.quit) break; // a session that ended does not restore into one if (core.takeAttach()) |req| { @@ -2465,7 +2466,7 @@ fn localSession( g.prepared_images.clearRetainingCapacity(); nc.native_images = true; nc.host = host; - if (fs) |f| f.reset(core); + if (fs) |f| f.reset(nc); core.deinit(); core = nc; shell.core = nc; @@ -2758,7 +2759,10 @@ const StdinFeed = struct { } var fds = [_]posix.pollfd{.{ .fd = 0, .events = posix.POLL.IN, .revents = 0 }}; - _ = posix.poll(&fds, 16) catch return out; + pardes.turn.rest(); + const polled = posix.poll(&fds, 16); + pardes.turn.wake(); + _ = polled catch return out; if ((fds[0].revents & posix.POLL.IN) == 0) { if ((fds[0].revents & (posix.POLL.HUP | posix.POLL.ERR)) != 0) out.eof = true; return out; @@ -3762,7 +3766,11 @@ fn waitInput(ctx: ?*anyopaque, timeout_ms: u32) void { if (s.gui) |g| { var sev = std.mem.zeroes(c.SDL_Event); const ms: c_int = if (timeout_ms != 0) @intCast(timeout_ms) else 16; - if (c.SDL_WaitEventTimeout(&sev, ms)) { + // The wait is the 9P connections' turn with the core. + pardes.turn.rest(); + const got = c.SDL_WaitEventTimeout(&sev, ms); + pardes.turn.wake(); + if (got) { dispatch(g, &in, &sev); while (c.SDL_PollEvent(&sev)) dispatch(g, &in, &sev); } @@ -3785,7 +3793,7 @@ fn pollFrame(ctx: ?*anyopaque) void { const s = shellOf(ctx); s.reconcilePtys(); const core = s.core; - if (s.fs) |f| if (f.tick(core).pending) s.queue.push(.fs_ready); + if (s.fs) |f| if (f.tick().pending) s.queue.push(.fs_ready); const g = s.gui orelse { if (core.settings.window_opacity_pending) { var unchanged_opacity: u8 = 100; @@ -3923,7 +3931,7 @@ fn gridPollFrame(ctx: ?*anyopaque) void { const s = shellOf(ctx); s.reconcilePtys(); if (s.fs) |f| { - if (f.tick(s.core).count != 0) s.saw_event = true; + if (f.tick().count != 0) s.saw_event = true; } pollCwds(s.core, s.ptys); if (s.core.animationActive()) { @@ -5077,6 +5085,13 @@ fn renderFrame( ); } } + // Body layers first: a notice chip over a tree-sitter context band + // is a tag layer, and instances paint in emission order. + for (surface.bodyLayers()) |*layer| { + if (layer.rows == 0) continue; + const batch_index = paintBatchAt(&paint_plan, layer.viewport.x, layer.viewport.y); + emitBodyLayer(g, instances, &cell_next[batch_index], layer, win_w, win_h, paint_plan.batches[batch_index].track, page, paint_plan.len == 1, false, topbar_pane_border_rgb); + } for (surface.tagLayers()) |*layer| { if (layer.cols == 0) continue; const batch_index = paintBatchAt(&paint_plan, layer.viewport.x, layer.viewport.y); @@ -5092,11 +5107,6 @@ fn renderFrame( emitTagLayer(g, instances, &cell_next[destination], layer, win_w, win_h, if (under) null else track, page, false, track.effect == .dissolve); } } - for (surface.bodyLayers()) |*layer| { - if (layer.rows == 0) continue; - const batch_index = paintBatchAt(&paint_plan, layer.viewport.x, layer.viewport.y); - emitBodyLayer(g, instances, &cell_next[batch_index], layer, win_w, win_h, paint_plan.batches[batch_index].track, page, paint_plan.len == 1, false, topbar_pane_border_rgb); - } for (paint_plan.batches[1..paint_plan.len], 1..) |batch, batch_index| { const track = batch.track.?; const under = track.effect == .vertical and track.phase == .opening; diff --git a/src/host_io.zig b/src/host_io.zig index a7babc74..72e149c9 100644 --- a/src/host_io.zig +++ b/src/host_io.zig @@ -955,6 +955,9 @@ pub fn forkShell( var cwd_buf: [4096]u8 = undefined; const cwd_z: ?[:0]const u8 = if (native_cwd.len == 0) null else dir: { const path = std.fmt.bufPrintSentinel(&cwd_buf, "{s}", .{native_cwd}, 0) catch return error.NameTooLong; + // A shell's directory may be inside a mount this editor serves. + pardes.turn.yield(); + defer pardes.turn.back(); const stat = try std.Io.Dir.cwd().statFile(std.Io.Threaded.global_single_threaded.io(), path, .{}); if (stat.kind != .directory) return error.NotDir; break :dir path; diff --git a/src/macos.zig b/src/macos.zig index d3b33c55..a7ee3164 100644 --- a/src/macos.zig +++ b/src/macos.zig @@ -773,6 +773,10 @@ fn initCore(runtime: ?*const Runtime, cols_arg: u16, rows_arg: u16) !void { for (&st.ptys, 0..) |*slot, id| if (slot.*) |*pt| startReader(st, pt, @intCast(id)); pardes.lsp.setStatusSink(st, lspStatusSink); + // From here the core is touched only inside the entry points above, + // each of which takes the turn for its own duration; between them the + // 9P connections have it. + pardes.turn.rest(); } fn wakeNinep(ctx: ?*anyopaque) void { @@ -781,6 +785,7 @@ fn wakeNinep(ctx: ?*anyopaque) void { } export fn pardes_deinit() void { + pardes.turn.wake(); const st = &(state orelse return); if (st.ninep) |listener| { listener.deinit(st.gpa); @@ -823,6 +828,8 @@ export fn pardes_deinit() void { } export fn pardes_should_quit() bool { + pardes.turn.wake(); + defer pardes.turn.rest(); const st = &(state orelse return true); return st.core.quit; } @@ -890,11 +897,15 @@ test "the animation clock spends real time, not callbacks" { } export fn pardes_animating() bool { + pardes.turn.wake(); + defer pardes.turn.rest(); const st = &(state orelse return false); return st.core.animationActive() or st.rotate_coasting or st.scroll_coasting; } export fn pardes_theme_bg() u32 { + pardes.turn.wake(); + defer pardes.turn.rest(); const th = if (state) |*st| st.core.theme() else &pardes.themes[0]; const bg = th.bg orelse return color_default; return @as(u32, bg[0]) << 16 | @as(u32, bg[1]) << 8 | bg[2]; @@ -913,6 +924,8 @@ export fn pardes_theme_bg() u32 { /// own (pardes_theme_bg == PARDES_COLOR_DEFAULT) drops the ground entirely, /// whatever percentage is set here. export fn pardes_window_opacity() u8 { + pardes.turn.wake(); + defer pardes.turn.rest(); const st = &(state orelse return 100); st.core.settings.window_opacity_pending = false; return st.core.settings.window_opacity; @@ -920,6 +933,8 @@ export fn pardes_window_opacity() u8 { /// Public AppKit backdrop strength, independent of background paint opacity. export fn pardes_window_blur() u8 { + pardes.turn.wake(); + defer pardes.turn.rest(); return if (state) |st| st.core.settings.window_blur else 0; } @@ -928,10 +943,14 @@ fn taglineFontPercent(core: ?*const pardes.Pardes) u8 { } export fn pardes_gui_tagline_font_percent() u8 { + pardes.turn.wake(); + defer pardes.turn.rest(); return taglineFontPercent(if (state) |*st| st.core else null); } export fn pardes_tagline_band_offset(row: u16, canvas_h: f32, cell_h: u32, tagline_h: u32) u32 { + pardes.turn.wake(); + defer pardes.turn.rest(); return pardes.taglineBandOffset(row, canvas_h, cell_h, tagline_h, if (state) |*st| st.core.settings.workspace_tag else true); } @@ -940,16 +959,22 @@ export fn pardes_topbar_pane_border_px(cell_h: u32, tagline_h: u32) u32 { } export fn pardes_tagline_origin_col(col: u16, row: u16) f32 { + pardes.turn.wake(); + defer pardes.turn.rest(); const st = &(state orelse return @floatFromInt(col)); return pardes.taglineOriginColForFrame(st.core, col, row); } export fn pardes_grid_col_at(x: f32, row: u16, body_w: f32, tagline_w: f32) u16 { + pardes.turn.wake(); + defer pardes.turn.rest(); const st = &(state orelse return pardes.gridColAt(null, x, row, body_w, tagline_w)); return pardes.gridColAt(st.core, x, row, body_w, tagline_w); } export fn pardes_topbar_pane_border_rgb() u32 { + pardes.turn.wake(); + defer pardes.turn.rest(); const rgb = pardes.config.gui_topbar_pane_border_rgb orelse fromTheme: { const st = state orelse return color_default; break :fromTheme st.core.chromeTheme().border; @@ -958,11 +983,15 @@ export fn pardes_topbar_pane_border_rgb() u32 { } export fn pardes_tag_active_bg() u32 { + pardes.turn.wake(); + defer pardes.turn.rest(); const st = state orelse return color_default; const rgb = st.core.chromeTheme().tag_active_bg; return @as(u32, rgb[0]) << 16 | @as(u32, rgb[1]) << 8 | rgb[2]; } export fn pardes_tagline_bg() u32 { + pardes.turn.wake(); + defer pardes.turn.rest(); const st = state orelse return color_default; const rgb = st.core.chromeTheme().tag_bg; return @as(u32, rgb[0]) << 16 | @as(u32, rgb[1]) << 8 | rgb[2]; @@ -1008,6 +1037,8 @@ test "the fallback preference order crosses the ABI intact and ends at the bound } export fn pardes_scene() Scene { + pardes.turn.wake(); + defer pardes.turn.rest(); const st = &(state orelse return .{}); const seconds = @as(f64, @floatFromInt(st.scene_ns)) / @as(f64, std.time.ns_per_s); return .{ @@ -1018,6 +1049,8 @@ export fn pardes_scene() Scene { } export fn pardes_postprocessor_unavailable() void { + pardes.turn.wake(); + defer pardes.turn.rest(); const st = &(state orelse return); st.core.disableSceneEffects(); st.core.settings.panel_transition = .off; @@ -1026,6 +1059,8 @@ export fn pardes_postprocessor_unavailable() void { } export fn pardes_panel_animation_failed() void { + pardes.turn.wake(); + defer pardes.turn.rest(); const st = &(state orelse return); st.core.abandonPanelAnimations(); } @@ -1210,6 +1245,8 @@ fn reloadWatchedFile(st: *State, pane: u8, announce: bool) bool { } export fn pardes_watch_changed(pane: u8, generation: u32) void { + pardes.turn.wake(); + defer pardes.turn.rest(); const st = &(state orelse return); if (pane >= watch_slot_count) return; if (st.file_watches.notify(pane, generation)) wake(st); @@ -1265,11 +1302,13 @@ fn drainInbox(st: *State) bool { } export fn pardes_tick() bool { + pardes.turn.wake(); + defer pardes.turn.rest(); const st = &(state orelse return false); st.inbox.wake_pending.store(false, .release); var did = drainInbox(st); if (st.ninep) |listener| { - const drained = listener.tick(st.core); + const drained = listener.tick(); did = did or drained.count != 0; if (drained.pending) wake(st); } @@ -1277,7 +1316,9 @@ export fn pardes_tick() bool { did = true; st.core.perform(effect); } + pardes.turn.settle(); if (restoreCore(st)) did = true; + pardes.turn.restoreSettled(); return did; } @@ -1309,7 +1350,7 @@ fn restoreCore(st: *State) bool { const generation = st.file_watches.stop(st.gpa, id); hostWatchFile(id, generation, null, 0); }; - if (st.ninep) |listener| listener.reset(st.core); + if (st.ninep) |listener| listener.reset(replacement); replacement.host = hostFor(st); st.core.deinit(); st.core = replacement; @@ -1485,6 +1526,8 @@ test "mac Restore cancels a PTY reader waiting for output capacity" { } export fn pardes_animation_tick() bool { + pardes.turn.wake(); + defer pardes.turn.rest(); const st = &(state orelse return false); const now: u64 = @intCast(@max(0, monotonicNs())); @@ -1546,6 +1589,8 @@ export fn pardes_animation_tick() bool { } export fn pardes_key(cp_arg: u32, text_ptr: ?[*]const u8, len: usize, mods: u32) void { + pardes.turn.wake(); + defer pardes.turn.rest(); const st = &(state orelse return); if (cp_arg > std.math.maxInt(u21)) return; const text: []const u8 = if (text_ptr) |p| p[0..len] else ""; @@ -1559,16 +1604,22 @@ export fn pardes_key(cp_arg: u32, text_ptr: ?[*]const u8, len: usize, mods: u32) } export fn pardes_paste(text_ptr: ?[*]const u8, len: usize) void { + pardes.turn.wake(); + defer pardes.turn.rest(); const st = &(state orelse return); const text: []const u8 = if (text_ptr) |p| p[0..len] else ""; st.core.update(.{ .paste = text }); } export fn pardes_mouse(button_arg: c_int, kind_arg: c_int, col: u16, row: u16, mods: u32) void { + pardes.turn.wake(); + defer pardes.turn.rest(); mouseWithHit(button_arg, kind_arg, col, row, mods, null, null); } export fn pardes_mouse_pixel(button_arg: c_int, kind_arg: c_int, col: u16, row: u16, mods: u32, x: f32, y: f32, bw: f32, bh: f32, tw: f32, th: f32) void { + pardes.turn.wake(); + defer pardes.turn.rest(); const st = &(state orelse return); const source = st.core.presentation.pointerFractional(st.core.screen_w, st.core.screen_h, x / @max(1, bw), y / @max(1, bh)); var hit: ?pardes.Mouse.BodyHit = null; @@ -1620,11 +1671,15 @@ fn mouseWithHit(button_arg: c_int, kind_arg: c_int, col: u16, row: u16, mods: u3 } export fn pardes_pointer_leave() void { + pardes.turn.wake(); + defer pardes.turn.rest(); const st = &(state orelse return); st.core.update(.pointer_leave); } export fn pardes_scroll(delta_rows: f32, delta_cols: f32, col: u16, row: u16) void { + pardes.turn.wake(); + defer pardes.turn.rest(); const st = &(state orelse return); st.scroll_col = col; st.scroll_row = row; @@ -1636,6 +1691,8 @@ export fn pardes_scroll(delta_rows: f32, delta_cols: f32, col: u16, row: u16) vo /// spinning dial. Also drops whatever the last gesture left banked, so the /// first millimetre of a new swipe cannot inherit a nearly-complete row. export fn pardes_scroll_begin() void { + pardes.turn.wake(); + defer pardes.turn.rest(); const st = &(state orelse return); st.scroll_lag = 0; st.scroll_lag_x = 0; @@ -1655,6 +1712,8 @@ export fn pardes_scroll_begin() void { /// momentum simply takes the gesture over, and the tail of that momentum is /// below the fling floor, so its end arms nothing. export fn pardes_scroll_end() void { + pardes.turn.wake(); + defer pardes.turn.rest(); const st = &(state orelse return); const last = st.scroll_last_ns; st.scroll_last_ns = 0; @@ -1671,6 +1730,8 @@ export fn pardes_scroll_end() void { } export fn pardes_rotate(degrees: f32) void { + pardes.turn.wake(); + defer pardes.turn.rest(); const st = &(state orelse return); if (degrees == 0) { st.rotate_lag = 0; @@ -1684,6 +1745,8 @@ export fn pardes_rotate(degrees: f32) void { } export fn pardes_rotate_end() void { + pardes.turn.wake(); + defer pardes.turn.rest(); const st = &(state orelse return); const last = st.rotate_last_ns; st.rotate_last_ns = 0; @@ -1726,6 +1789,8 @@ fn spendRotation(st: *State, degrees: f32) void { } export fn pardes_command(text_ptr: ?[*]const u8, len: usize) void { + pardes.turn.wake(); + defer pardes.turn.rest(); const st = &(state orelse return); const text: []const u8 = if (text_ptr) |p| p[0..len] else ""; if (text.len == 0) return; @@ -1733,6 +1798,8 @@ export fn pardes_command(text_ptr: ?[*]const u8, len: usize) void { } export fn pardes_resize(cols_arg: u16, rows_arg: u16, cell_w: u16, cell_h: u16) void { + pardes.turn.wake(); + defer pardes.turn.rest(); const st = &(state orelse return); const cols = @max(1, cols_arg); const rows = @max(1, rows_arg); @@ -1747,6 +1814,8 @@ export fn pardes_resize(cols_arg: u16, rows_arg: u16, cell_w: u16, cell_h: u16) } export fn pardes_frame() u32 { + pardes.turn.wake(); + defer pardes.turn.rest(); const st = &(state orelse return 0); const tz = tracy.zone(@src(), "pardes_frame"); defer tz.end(); @@ -1921,26 +1990,36 @@ fn collectImages(st: *State, surface: *const pardes.Surface) void { } export fn pardes_frame_images() u32 { + pardes.turn.wake(); + defer pardes.turn.rest(); const st = &(state orelse return 0); return @intCast(st.images_len); } export fn pardes_frame_image_list() ?[*]const Image { + pardes.turn.wake(); + defer pardes.turn.rest(); const st = &(state orelse return null); return if (st.images_len == 0) null else st.images.ptr; } export fn pardes_frame_panel_tracks() u32 { + pardes.turn.wake(); + defer pardes.turn.rest(); const st = &(state orelse return 0); return @intCast(st.panel_tracks_len); } export fn pardes_frame_panel_track_list() ?[*]const PanelTrack { + pardes.turn.wake(); + defer pardes.turn.rest(); const st = &(state orelse return null); return if (st.panel_tracks_len == 0) null else st.panel_tracks[0..].ptr; } export fn pardes_frame_presented(animated_panels: bool) bool { + pardes.turn.wake(); + defer pardes.turn.rest(); const st = &(state orelse return false); const was_animating = st.core.animationActive(); if (animated_panels) @@ -1951,11 +2030,15 @@ export fn pardes_frame_presented(animated_panels: bool) bool { } export fn pardes_frame_cells() ?[*]const Cell { + pardes.turn.wake(); + defer pardes.turn.rest(); const st = &(state orelse return null); return if (st.frame_len == 0) null else st.cells.ptr; } export fn pardes_frame_previous_cells() ?[*]const Cell { + pardes.turn.wake(); + defer pardes.turn.rest(); const st = &(state orelse return null); return if (st.panel_diff_len != st.frame_len or st.panel_diff_len == 0) null @@ -1964,6 +2047,8 @@ export fn pardes_frame_previous_cells() ?[*]const Cell { } export fn pardes_frame_changed_cells() ?[*]const u8 { + pardes.turn.wake(); + defer pardes.turn.rest(); const st = &(state orelse return null); return if (st.panel_diff_len != st.frame_len or st.panel_diff_len == 0) null @@ -1972,16 +2057,22 @@ export fn pardes_frame_changed_cells() ?[*]const u8 { } export fn pardes_frame_cols() u16 { + pardes.turn.wake(); + defer pardes.turn.rest(); const st = &(state orelse return 0); return st.frame_cols; } export fn pardes_frame_rows() u16 { + pardes.turn.wake(); + defer pardes.turn.rest(); const st = &(state orelse return 0); return st.frame_rows; } export fn pardes_cursor_x() i32 { + pardes.turn.wake(); + defer pardes.turn.rest(); const st = &(state orelse return -1); if (tagCursorCovered(st.core)) return -1; return if (st.core.surface.cursor) |c| c.x else -1; @@ -2000,6 +2091,8 @@ export fn pardes_tag_layer_limit() u32 { } export fn pardes_tag_layer_value(index: u32, field: u32) u32 { + pardes.turn.wake(); + defer pardes.turn.rest(); const st = &(state orelse return 0); if (index >= pardes.MAX_TAG_LAYERS) return 0; const layer = &st.core.surface.tag_layers[index]; @@ -2025,6 +2118,8 @@ export fn pardes_tag_layer_value(index: u32, field: u32) u32 { } export fn pardes_tag_layer_cells(index: u32) ?[*]const Cell { + pardes.turn.wake(); + defer pardes.turn.rest(); const st = &(state orelse return null); if (index >= pardes.MAX_TAG_LAYERS) return null; const layer = &st.core.surface.tag_layers[index]; @@ -2036,6 +2131,8 @@ export fn pardes_tag_layer_cells(index: u32) ?[*]const Cell { } export fn pardes_body_layer_value(index: u32, field: u32) u32 { + pardes.turn.wake(); + defer pardes.turn.rest(); const st = &(state orelse return 0); if (index >= pardes.MAX_PANES) return 0; const layer = &st.core.surface.body_layers[index]; @@ -2056,6 +2153,8 @@ export fn pardes_body_layer_value(index: u32, field: u32) u32 { } export fn pardes_body_layer_cells(index: u32) ?[*]const Cell { + pardes.turn.wake(); + defer pardes.turn.rest(); const st = &(state orelse return null); if (index >= pardes.MAX_PANES) return null; const layer = &st.core.surface.body_layers[index]; @@ -2071,27 +2170,37 @@ export fn pardes_body_layer_limit() u32 { } export fn pardes_row_metrics(body_w: u16, body_h: u16, tagline_w: u16, tagline_h: u16) void { + pardes.turn.wake(); + defer pardes.turn.rest(); const st = &(state orelse return); st.core.update(.{ .resize = .{ .cols = st.core.screen_w, .rows = st.core.screen_h, .cell_pixels = st.core.cell_pixels, .row_metrics = .{ .body_w = @max(1, body_w), .body_h = @max(1, body_h), .tagline_w = @max(1, tagline_w), .tagline_h = @max(1, tagline_h) } } }); } export fn pardes_pointer_shape() u32 { + pardes.turn.wake(); + defer pardes.turn.rest(); const st = &(state orelse return 0); return @intFromEnum(st.core.surface.pointer_shape); } export fn pardes_cursor_y() i32 { + pardes.turn.wake(); + defer pardes.turn.rest(); const st = &(state orelse return -1); if (tagCursorCovered(st.core)) return -1; return if (st.core.surface.cursor) |c| c.y else -1; } export fn pardes_cursor_bar() bool { + pardes.turn.wake(); + defer pardes.turn.rest(); const st = &(state orelse return false); return if (st.core.surface.cursor) |c| c.bar else false; } export fn pardes_take_haptic() c_int { + pardes.turn.wake(); + defer pardes.turn.rest(); const st = &(state orelse return 0); return switch (st.core.takeHaptic()) { .none => 0, @@ -2103,6 +2212,8 @@ export fn pardes_take_haptic() c_int { var font_path_z: [4096:0]u8 = undefined; export fn pardes_font_take(size_hundredths: *u16) ?[*:0]const u8 { + pardes.turn.wake(); + defer pardes.turn.rest(); const st = &(state orelse return null); if (comptime !pardes.font_picker) return null; const want = st.core.takeFontRequest() orelse return null; @@ -2118,6 +2229,8 @@ export fn pardes_font_observe( len: usize, point_hundredths: u16, ) bool { + pardes.turn.wake(); + defer pardes.turn.rest(); const st = &(state orelse return false); const ptr = effective_name orelse return false; if (len == 0 or len > 255 or point_hundredths == 0) return false; @@ -2129,6 +2242,8 @@ export fn pardes_font_ack( len: usize, point_hundredths: u16, ) bool { + pardes.turn.wake(); + defer pardes.turn.rest(); const st = &(state orelse return false); const ptr = effective_name orelse return false; if (len == 0 or len > 255 or point_hundredths == 0) return false; @@ -2136,6 +2251,8 @@ export fn pardes_font_ack( } export fn pardes_font_reject() void { + pardes.turn.wake(); + defer pardes.turn.rest(); const st = &(state orelse return); st.core.rejectFont(); } @@ -2143,6 +2260,8 @@ export fn pardes_font_reject() void { var active_path_z: [4096:0]u8 = undefined; export fn pardes_active_path() ?[*:0]const u8 { + pardes.turn.wake(); + defer pardes.turn.rest(); const st = &(state orelse return null); const path = activeFilePath(st) orelse return null; if (path.len == 0 or path.len >= active_path_z.len) return null; @@ -2152,6 +2271,8 @@ export fn pardes_active_path() ?[*:0]const u8 { } export fn pardes_active_dirty() bool { + pardes.turn.wake(); + defer pardes.turn.rest(); const st = &(state orelse return false); const pane = st.core.panes[st.core.active] orelse return false; const f = if (pane.file) |*x| x else return false; diff --git a/src/memory.zig b/src/memory.zig index f30e4392..e5394b4f 100644 --- a/src/memory.zig +++ b/src/memory.zig @@ -44,7 +44,48 @@ pub const Allocators = struct { pdf: Allocator, }; -var pardes_fallback: std.heap.StackFallbackAllocator(limits.arena.pardes) = undefined; +/// `std.heap.StackFallbackAllocator` with the buffer taken through its +/// lock-free interface. The core's allocator is used from two threads: a 9P +/// connection task answers a request while the editor's own thread is out +/// in a syscall that allocates (`readFileLimit`, `grep`; see `pardes.turn`). +fn SharedStackFallback(comptime size: usize) type { + return struct { + buffer: [size]u8 = undefined, + fallback_allocator: Allocator = undefined, + fixed: std.heap.FixedBufferAllocator = undefined, + + fn get(self: *@This()) Allocator { + self.fixed = .init(self.buffer[0..]); + return .{ .ptr = self, .vtable = &.{ .alloc = alloc, .resize = resize, .remap = remap, .free = free } }; + } + + fn alloc(ctx: *anyopaque, len: usize, alignment: std.mem.Alignment, ra: usize) ?[*]u8 { + const self: *@This() = @ptrCast(@alignCast(ctx)); + return self.fixed.threadSafeAllocator().rawAlloc(len, alignment, ra) orelse + self.fallback_allocator.rawAlloc(len, alignment, ra); + } + + fn resize(ctx: *anyopaque, buf: []u8, alignment: std.mem.Alignment, new_len: usize, ra: usize) bool { + const self: *@This() = @ptrCast(@alignCast(ctx)); + if (self.fixed.ownsPtr(buf.ptr)) return self.fixed.threadSafeAllocator().rawResize(buf, alignment, new_len, ra); + return self.fallback_allocator.rawResize(buf, alignment, new_len, ra); + } + + fn remap(ctx: *anyopaque, buf: []u8, alignment: std.mem.Alignment, new_len: usize, ra: usize) ?[*]u8 { + const self: *@This() = @ptrCast(@alignCast(ctx)); + if (self.fixed.ownsPtr(buf.ptr)) return self.fixed.threadSafeAllocator().rawRemap(buf, alignment, new_len, ra); + return self.fallback_allocator.rawRemap(buf, alignment, new_len, ra); + } + + fn free(ctx: *anyopaque, buf: []u8, alignment: std.mem.Alignment, ra: usize) void { + const self: *@This() = @ptrCast(@alignCast(ctx)); + if (self.fixed.ownsPtr(buf.ptr)) return self.fixed.threadSafeAllocator().rawFree(buf, alignment, ra); + return self.fallback_allocator.rawFree(buf, alignment, ra); + } + }; +} + +var pardes_fallback: SharedStackFallback(limits.arena.pardes) = .{}; var frame_fallback: std.heap.StackFallbackAllocator(limits.arena.frame) = undefined; var tree_sitter_fallback: std.heap.StackFallbackAllocator(limits.arena.tree_sitter) = undefined; var image_fallback: std.heap.StackFallbackAllocator(limits.arena.image) = undefined; @@ -61,7 +102,6 @@ var pdf_debug: Debug = .init; // One session at a time; free its allocations before deinit. Concurrent LSP workers use the caller's allocator. pub fn init(fallback: Allocator) Allocators { pardes_fallback.fallback_allocator = fallback; - pardes_fallback.get_called = if (std.debug.runtime_safety) false else {}; frame_fallback.fallback_allocator = fallback; frame_fallback.get_called = if (std.debug.runtime_safety) false else {}; tree_sitter_fallback.fallback_allocator = fallback; @@ -112,12 +152,12 @@ test "fixed allocators are separate, spill, and restart" { var allocs = init(std.testing.allocator); const core = try allocs.pardes.alloc(u8, 32); const frame = try allocs.frame.alloc(u8, 32); - try std.testing.expect(pardes_fallback.fixed_buffer_allocator.ownsPtr(core.ptr)); + try std.testing.expect(pardes_fallback.fixed.ownsPtr(core.ptr)); try std.testing.expect(frame_fallback.fixed_buffer_allocator.ownsPtr(frame.ptr)); try std.testing.expect(core.ptr != frame.ptr); const spill = try allocs.pardes.alloc(u8, limits.arena.pardes + 1); - try std.testing.expect(!pardes_fallback.fixed_buffer_allocator.ownsPtr(spill.ptr)); + try std.testing.expect(!pardes_fallback.fixed.ownsPtr(spill.ptr)); allocs.pardes.free(spill); allocs.frame.free(frame); allocs.pardes.free(core); @@ -127,7 +167,7 @@ test "fixed allocators are separate, spill, and restart" { defer deinit(); const restarted = try allocs.pardes.alloc(u8, 32); defer allocs.pardes.free(restarted); - try std.testing.expect(pardes_fallback.fixed_buffer_allocator.ownsPtr(restarted.ptr)); + try std.testing.expect(pardes_fallback.fixed.ownsPtr(restarted.ptr)); } test "memory limits preserve desktop capacities" { diff --git a/src/ninep/testing.zig b/src/ninep/testing.zig index 44329eee..6ea40956 100644 --- a/src/ninep/testing.zig +++ b/src/ninep/testing.zig @@ -30,13 +30,10 @@ pub const Answer = struct { }; pub fn call(p: *Pardes, req: Req) Answer { - p.update(.{ .fs_req = req }); var ans: Answer = .{}; + ans.reply = p.serveFs(req); + ans.bytes = p.fsPayload(ans.reply); while (p.nextEffect()) |e| switch (e) { - .fs_reply => |r| { - ans.reply = r; - ans.bytes = p.fsPayload(r); - }, .save_file, .save_text => ans.saved = true, .watch => |w| ans.watch = w.on, .write => |w| { diff --git a/src/ninep/tree.zig b/src/ninep/tree.zig index 5a0c1e11..b13b1472 100644 --- a/src/ninep/tree.zig +++ b/src/ninep/tree.zig @@ -68,6 +68,22 @@ pub const e_bad_event = "bad event syntax"; /// everywhere, as it is in acme (editors/acme/fsys.c, fsyscreate). pub const features: cloud9.fs.Features = .{ .remove = true }; +/// Whether a request must wait until no step is out in a syscall +/// (`pardes.turn`): what would change a pane such a step still points into. +/// Making a pane and rendering a screen do not -- every yield sits before +/// the mutation of its own step, so the layout and the surface are whole +/// under it -- and a step out there is never waiting on a write of its own, +/// so what parks here is never the syscall's own request. +pub fn needsQuiet(req: Req) bool { + return switch (req.op) { + .write, .setattr => true, + .release => req.remove, + else => false, + }; +} + +/// `needsQuiet`, plus the open that makes a pane: what costs a frame and a +/// wake of the editor. pub fn changesPane(req: Req) bool { return switch (req.op) { .write, .setattr => true, diff --git a/src/panes.zig b/src/panes.zig index f995986b..b3424385 100644 --- a/src/panes.zig +++ b/src/panes.zig @@ -3324,11 +3324,28 @@ pub const Image = struct { /// Construct an image pane from a path and optionally transferred dump bytes. /// `raw` must be image_gpa-owned and ownership transfers only on success. + /// Without them the file is read here, not at the first draw: a draw + /// must not go out into the host (`pardes.turn`), and the path may be a + /// mount this editor serves. A file that cannot be read draws blank. pub fn create(p: *pardes.Pardes, id: usize, path: []const u8, raw: []u8) !*pardes.Pane { + var bytes = raw; + var read_here = false; + if (bytes.len == 0) { + // The slot stays ours across the read: another request may + // make a pane meanwhile. + p.reserved_slots[id] = true; + defer p.reserved_slots[id] = false; + if (filesystem.read(p, path)) |from_disk| { + defer p.gpa.free(from_disk); + bytes = try p.image_gpa.dupe(u8, from_disk); + read_here = true; + } else |_| {} + } + errdefer if (read_here) p.image_gpa.free(bytes); const path_copy = try p.image_gpa.dupe(u8, path); errdefer p.image_gpa.free(path_copy); const pane = try p.newDocPane(id); - pane.image = .{ .path = path_copy, .raw = raw }; + pane.image = .{ .path = path_copy, .raw = bytes }; return pane; } @@ -3427,12 +3444,8 @@ pub const Image = struct { fn ensureDecoded(p: *pardes.Pardes, state: *State) void { if (state.tried) return; state.tried = true; - const bytes: []const u8 = if (state.raw.len > 0) - state.raw - else - filesystem.read(p, state.path) catch &.{}; - defer if (state.raw.len == 0) p.gpa.free(bytes); - if (image.decode(p.image_gpa, bytes)) |decoded| { + if (state.raw.len == 0) return; // nothing was readable at open + if (image.decode(p.image_gpa, state.raw)) |decoded| { state.rgba = decoded.rgba; state.iw = decoded.w; state.ih = decoded.h; @@ -3771,9 +3784,15 @@ pub const Pdf = struct { sections_output: ?SectionsOutput = null, outline_reveal_pending: ?pdf.OutlineInternalDestination = null, + /// Read whole and opened from memory (the bridge copies), never from + /// the file itself: MuPDF reads a file lazily at every page, and the + /// path may be a mount this editor serves, which only a read that + /// gives the turn up can come back from (`filesystem.readFile`). pub fn open(gpa: std.mem.Allocator, path: []const u8, page_one_based: usize) !@This() { const local = filesystem.localPath(path) orelse return error.NonLocalPath; - return initDocument(gpa, path, try Document.open(local), page_one_based); + const bytes = try filesystem.readFile(gpa, local); + defer gpa.free(bytes); + return initDocument(gpa, path, try Document.openBytes(bytes), page_one_based); } pub fn openBytes(gpa: std.mem.Allocator, path: []const u8, bytes: []const u8, page_one_based: usize) !@This() { @@ -5219,6 +5238,10 @@ pub const Pdf = struct { page_one_based: usize, ) !*pardes.Pane { if (comptime !enabled) return error.PdfDisabled; + // The slot stays ours across the read: another request may make a + // pane meanwhile. + core.reserved_slots[id] = true; + defer core.reserved_slots[id] = false; var state = if (filesystem.localPath(path) != null) try State.open(core.pdf_gpa, path, page_one_based) else virtual: { @@ -5903,9 +5926,11 @@ pub const Pdf = struct { null, }, .x = text_x, - .y = core.bodyTop(rect), + // Below the notice chips, like an image: a placed page is + // drawn after the cells and would paint a chip out. + .y = core.bodyTop(rect) + pane.notices.len, .w = text_width, - .h = rect.h -| pardes.BOX_H, + .h = (rect.h -| pardes.BOX_H) -| pane.notices.len, .rgba = placed.rgba, .iw = placed.width, // The texture contains the retained band, not the full page. diff --git a/src/pardes.zig b/src/pardes.zig index 0ac16162..cc57127f 100644 --- a/src/pardes.zig +++ b/src/pardes.zig @@ -39,6 +39,148 @@ pub const font_picker = platform == .gui or platform == .macos; pub const hosted = platform == .tty or platform == .gui or platform == .macos; +/// Whose turn it is with the core. The core is single-threaded: the editor's +/// thread has it, and lets go of it in two kinds of gap -- while it waits for +/// input (`rest`, `wake`), and while it is out in the host filesystem in the +/// middle of a step (`yield`, `back`). A 9P connection task takes the turn +/// in those gaps to answer a request (`take`, `give`), which is what lets the +/// editor read its own tree through a mount: the syscall goes out, another +/// thread answers it, the syscall comes back. A step of a connection task's +/// own -- a Look written to `look` -- goes out the same way. +/// +/// `out` counts the steps that are out. While one is, the core reads +/// consistently but that step still holds pointers into it, so nothing may +/// change it: a request that would is parked in the engine (src/9p_io.zig) +/// and retried when the turn is next given up with nothing out, which +/// `parked` remembers to arrange; and the editor's own wake waits for the +/// count to reach zero, since a step of the editor's may change anything. +/// It is never a write of its own that a step waits on out there -- writes +/// come from a shell performing a save between steps -- so a parked request +/// is never the syscall's own. +/// +/// One per process, like the editor it belongs to. A process that never +/// starts it -- a test, the board, the browser -- has no second thread, and +/// every yield is a no-op. +pub var turn: Turn = .{}; + +pub const Turn = struct { + mutex: std.Io.Mutex = .init, + /// Set by `start`; a process that never starts the turn has none. + io: ?std.Io = null, + /// Steps out in a host syscall, from any thread. + out: u32 = 0, + /// A request that changes a pane was parked for want of quiet. + parked: bool = false, + wake_parked: ?*const fn (?*anyopaque) void = null, + wake_ctx: ?*anyopaque = null, + /// Bumped each time the editor has performed what the core asked of it, + /// so a request that asked for something -- a save, a shell -- can be + /// answered once it is done rather than merely queued, the way writing + /// `put` to acme's ctl returns after the file is written. + epoch: u64 = 0, + /// Bumped each time a shell has attempted the Restore the core asked for + /// (`takeRestore`), which lives after `pump` because it swaps the core + /// out from under it; a request that asked for one waits for this. + restores: u64 = 0, + /// Both of the above, and `out` reaching zero. + settled: std.Io.Condition = .init, + + /// The editor's thread takes the turn for good; it has it until `stop`. + pub fn start(t: *Turn, io: std.Io) void { + t.io = io; + t.mutex.lockUncancelable(io); + } + + pub fn stop(t: *Turn) void { + const io = t.io orelse return; + t.io = null; + t.parked = false; + t.mutex.unlock(io); + } + + /// The editor is about to wait for input: anyone may have the core. + pub fn rest(t: *Turn) void { + if (t.io == null) return; + t.release(); + } + + /// The editor takes the turn back -- once every step that is out in a + /// syscall has returned, since a step of the editor's may change what + /// those still point into. + pub fn wake(t: *Turn) void { + const io = t.io orelse return; + t.mutex.lockUncancelable(io); + while (t.out != 0) t.settled.waitUncancelable(io, &t.mutex); + } + + /// Whoever has the turn is about to block in the host in the middle of + /// a step. Nests: a directory listing that resolves each entry yields + /// inside a yield, and only the outermost one lets go. + pub fn yield(t: *Turn) void { + const io = t.io orelse return; + yield_depth += 1; + if (yield_depth != 1) return; + t.out += 1; + t.mutex.unlock(io); + } + + pub fn back(t: *Turn) void { + const io = t.io orelse return; + yield_depth -= 1; + if (yield_depth != 0) return; + t.mutex.lockUncancelable(io); + t.out -= 1; + if (t.out == 0) t.settled.broadcast(io); + } + + /// How many yields this thread is inside of. + threadlocal var yield_depth: u32 = 0; + + /// A connection task takes the turn; answers whether nothing is out + /// mid-step, which is what a request that changes a pane needs. + pub fn take(t: *Turn) bool { + t.mutex.lockUncancelable(t.io.?); + return t.out == 0; + } + + pub fn give(t: *Turn) void { + t.release(); + } + + /// The editor performed the core's effects. + pub fn settle(t: *Turn) void { + const io = t.io orelse return; + t.epoch +%= 1; + t.settled.broadcast(io); + } + + /// With the turn: waits, turn given up meanwhile, until the editor has + /// performed past `epoch`; stopping ends the wait early. + pub fn awaitSettled(t: *Turn, epoch: u64) void { + while (t.epoch == epoch) t.settled.wait(t.io.?, &t.mutex) catch return; + } + + /// The shell attempted the Restore the core asked for, whichever way it + /// went; called at the top of each loop step, when the previous step's + /// attempt is over. + pub fn restoreSettled(t: *Turn) void { + const io = t.io orelse return; + t.restores +%= 1; + t.settled.broadcast(io); + } + + pub fn awaitRestored(t: *Turn, restores: u64) void { + while (t.restores == restores) t.settled.wait(t.io.?, &t.mutex) catch return; + } + + fn release(t: *Turn) void { + const woken = t.out == 0 and t.parked; + if (woken) t.parked = false; + t.mutex.unlock(t.io.?); + if (woken) if (t.wake_parked) |f| f(t.wake_ctx); + } +}; + pub const can_attach = platform == .tty or platform == .gui; pub const terminal_panes = platform != .esp32p4; @@ -4754,7 +4896,6 @@ pub const Event = union(enum) { /// this must not clamp onto and preview the final grid cell. pointer_leave, tick, - fs_req: ctlfs.Req, }; pub const attach_name_max = 256; @@ -4792,7 +4933,6 @@ pub const Effect = union(enum) { /// Write the build-time theme ring below the per-user config directory. /// The pane receives the completion/error message from the native host. dump_themes: struct { pane: u8 }, - fs_reply: ctlfs.Reply, attach: struct { pane: u8, name: Buf(attach_name_max) }, detach: struct { pane: u8 }, quit, @@ -5910,11 +6050,6 @@ pub const Options = struct { ninep_name: []const u8 = "", ninep_tcp: ?[]const u8 = null, ninep_quic: ?[]const u8 = null, - ninep_identity: struct { - socket_path: []const u8 = "", - tcp_address: ?std.Io.net.IpAddress = null, - quic_address: ?std.Io.net.IpAddress = null, - } = .{}, mounts: []const filesystem.Mount = &.{}, config_dir: ?[]const u8 = null, startup_config_path: ?[]const u8 = null, @@ -6182,11 +6317,7 @@ pub const Pardes = struct { .pdf_gpa = pdf_gpa, .tree_sitter_gpa = tree_sitter_gpa, .opts = opts, - .fs = .{ - .socket_path = opts.ninep_identity.socket_path, - .tcp_address = opts.ninep_identity.tcp_address, - .quic_address = opts.ninep_identity.quic_address, - }, + .fs = .{}, .screen_w = opts.cols, .screen_h = opts.rows, .scratch = .init(gpa), @@ -6197,7 +6328,6 @@ pub const Pardes = struct { p.fs.started = ctlfs.events.now(); for (opts.mounts) |mount| try p.fs.mount(gpa, mount.name, mount.dial); p.opts.mounts = &.{}; - p.opts.ninep_identity = .{}; p.boot = Boot.of(opts); switch (p.boot) { .document => { @@ -6310,13 +6440,31 @@ pub const Pardes = struct { return @intCast(std.math.clamp(panes.File.displayWidth(text) + 2, 1, @as(usize, limit))); } + const Printed = struct { left: u16, dropped: usize }; + /// Prints `text` flush with the right edge of the band, and answers the - /// column it started at so a cursor can follow it. - fn printRight(s: *Surface, x: u16, row: u16, w: u16, text: []const u8, style: CellStyle) u16 { - const shown: u16 = @intCast(@min(@as(usize, w), panes.File.displayWidth(text))); - const left = x + w - shown; - _ = s.print(left, row, shown, text, style); - return left; + /// column it started at so a cursor can follow it. Text wider than the + /// band loses its HEAD: the end is the part that says something -- a + /// path's file name, an error's reason -- and `dropped` is how many + /// columns of it went. + fn printRight(s: *Surface, x: u16, row: u16, w: u16, text: []const u8, style: CellStyle) Printed { + const width = panes.File.displayWidth(text); + if (width <= w) { + const left: u16 = @intCast(x + w - width); + _ = s.print(left, row, @intCast(width), text, style); + return .{ .left = left, .dropped = 0 }; + } + // Whole glyphs only: a cut inside a wide one would leave the rest a + // column too wide and clip its LAST glyph instead of the first. + var dropped = width - w; + var start = panes.File.rawAtDisplay(text, dropped); + if (panes.File.rawDisplayCol(text, start) < dropped) { + dropped += 1; + start = panes.File.rawAtDisplay(text, dropped); + } + const left: u16 = @intCast(x + w - (width - dropped)); + _ = s.print(left, row, @intCast(width - dropped), text[start..], style); + return .{ .left = left, .dropped = dropped }; } /// The layout every single-pane boot starts from. @@ -6904,8 +7052,14 @@ pub const Pardes = struct { fn showMessage(p: *Pardes, id: usize, text: []const u8) void { if (id >= MAX_PANES) return; const pane = p.panes[id] orelse return; - pane.msg_len = @intCast(@min(text.len, pane.msg.len)); - @memcpy(pane.msg[0..pane.msg_len], text[0..pane.msg_len]); + // One row of printable text: a language server's multi-line report + // reads as one line, and the cut never leaves half a glyph behind. + var n: usize = @min(text.len, pane.msg.len); + if (n < text.len) { + while (n > 0 and text[n] & 0xC0 == 0x80) n -= 1; + } + for (text[0..n], pane.msg[0..n]) |c, *cell| cell.* = if (c < 0x20 or c == 0x7f) ' ' else c; + pane.msg_len = @intCast(n); } fn logMessage(p: *Pardes, id: usize, text: []const u8) void { @@ -7040,7 +7194,7 @@ pub const Pardes = struct { pub fn postEvent(p: *Pardes, ev: Event) void { switch (ev) { .key => |k| std.debug.assert(k.text.len == 0), - .output, .paste, .lsp_resp, .pipe_resp, .file_changed, .command, .fs_req => unreachable, + .output, .paste, .lsp_resp, .pipe_resp, .file_changed, .command => unreachable, else => {}, } if (p.in_len == p.in_q.len) return; @@ -7173,7 +7327,6 @@ pub const Pardes = struct { }, .theme_file => |t| if (v.watch_theme) |f| f(p.host.ctx, t.generation, t.on), .dump_themes => |d| if (v.dump_themes) |f| f(p.host.ctx, d.pane), - .fs_reply => {}, .attach => |a| { const name = a.name.slice(); @memcpy(p.attach_buf[0..name.len], name); @@ -7194,6 +7347,7 @@ pub const Pardes = struct { if (v.wait_input) |f| f(h.ctx, if (p.animationActive()) layout.Animation.frame_ms else 0); while (p.nextQueued()) |ev| p.update(ev); while (p.nextEffect()) |e| p.perform(e); + turn.settle(); // A quitting frame has already freed what it would draw. if (p.quit) return; if (v.poll_frame) |f| f(h.ctx); @@ -7208,24 +7362,35 @@ pub const Pardes = struct { p.needs_frame = false; } + /// One request of the control filesystem, from whichever thread has the + /// turn (`pardes.turn`). Not an event: it neither sweeps nor resets + /// anything the editor's own step may be in the middle of using, so it + /// can be answered while that step is out in a syscall. Only a request + /// that changes a pane costs a frame, which is why a round trip on a + /// local socket costs microseconds and not a vsync. + pub fn serveFs(p: *Pardes, req: ctlfs.Req) ctlfs.Reply { + if (!ctlfs.changesPane(req)) return ctlfs.handle(p, req); + p.needs_frame = true; + p.raw_hover_intent = false; + p.cancelLookHover(); + const reply = ctlfs.handle(p, req); + // The request was a whole step of its own, so it settles the way a + // step does: the cursor and scroll reconciled, the scripted panes + // told, and the panes it made announced to /log now rather than at + // the end of whatever the editor does next. + p.sync(); + p.fsReport(); + ctlfs.events.announce(p); + return reply; + } + pub fn update(p: *Pardes, ev: Event) void { - // Only two events cannot change the screen: a tick with nothing - // animating, and a filesystem request that only reads. The second is - // what 9P traffic overwhelmingly is, and answering it used to drag a - // whole vsync-blocked frame behind it -- which is why a round trip on - // a local socket cost a frame instead of a few microseconds. - p.needs_frame = p.needs_frame or switch (ev) { - .tick => false, - .fs_req => |req| ctlfs.changesPane(req), - else => true, - }; + // A tick with nothing animating is the one event that cannot change + // the screen. + p.needs_frame = p.needs_frame or ev != .tick; p.shell_rows.sweep(p.gpa); switch (ev) { .tick => {}, - .fs_req => |req| if (ctlfs.changesPane(req)) { - p.raw_hover_intent = false; - p.cancelLookHover(); - }, .mouse => |m| if (!(m.button == .none and m.kind == .motion)) { p.raw_hover_intent = false; p.cancelLookHover(); @@ -7324,7 +7489,6 @@ pub const Pardes = struct { }, .paste => |bytes| p.applyPaste(bytes), .command => |line| _ = p.executeBuiltinLine(p.active, line), - .fs_req => |r| p.emit(.{ .fs_reply = ctlfs.handle(p, r) }), .pinch => |scale| p.ov_pinch_scale = scale, .touch_scroll => |delta| p.ov_touch_scroll_delta = delta, .pointer_leave => { @@ -12915,11 +13079,7 @@ pub const Pardes = struct { .pdf_gpa = pdf_gpa, .tree_sitter_gpa = tree_sitter_gpa, .opts = opts, - .fs = .{ - .socket_path = opts.ninep_identity.socket_path, - .tcp_address = opts.ninep_identity.tcp_address, - .quic_address = opts.ninep_identity.quic_address, - }, + .fs = .{}, .screen_w = opts.cols, .screen_h = opts.rows, .scratch = .init(gpa), @@ -12934,13 +13094,9 @@ pub const Pardes = struct { p.cell_pixels = old.cell_pixels; p.row_metrics = old.row_metrics; p.native_images = old.native_images; - p.fs.socket_path = old.fs.socket_path; - p.fs.tcp_address = old.fs.tcp_address; - p.fs.quic_address = old.fs.quic_address; } for (opts.mounts) |mount| try p.fs.mount(gpa, mount.name, mount.dial); p.opts.mounts = &.{}; - p.opts.ninep_identity = .{}; var parsed = try dump.readZon(gpa, zon_bytes, "load"); defer parsed.deinit(); const st = parsed.value; @@ -13521,16 +13677,19 @@ pub const Pardes = struct { // right would put it past the pane, off the grid, and past what // the detached wire will encode -- which drops every frame for // as long as the prompt is up. - const left = printRight(s, cx, row, chip -| 1, text, msg_style); + const printed = printRight(s, cx, row, chip -| 1, text, msg_style); if (kind != .prompt or id != p.active) continue; const at = pane.promptAt() orelse continue; const prompt0 = (p.tagPrefix(pane) catch continue).len + at; const col = @as(usize, pane.tag_col); if (col < prompt0) continue; - // The cursor follows the text to wherever it landed. + // The cursor follows the text to wherever it landed; a caret + // in the part a narrow band dropped has nowhere to be. const prompt_col = panes.File.displayWidth(text[0..@min(col - prompt0, text.len)]); - if (left + prompt_col < tx + tw) - s.cursor = .{ .x = left + @as(u16, @intCast(prompt_col)), .y = row, .bar = pane.mode == .insert }; + if (prompt_col < printed.dropped) continue; + const caret = printed.left + (prompt_col - printed.dropped); + if (caret < tx + tw) + s.cursor = .{ .x = @intCast(caret), .y = row, .bar = pane.mode == .insert }; } } @@ -14018,12 +14177,19 @@ pub const Pardes = struct { const chip = r.x + r.w - cx; // Right aligned inside the chip, a blank cell short of its // edge: the same one the grid pass leaves for a prompt caret. + // Wider than the chip, the text loses its head, as on the grid. const room = p.tagCapacity(chip) -| 1; const shown = panes.File.displayWidth(text); - const pad = room -| shown; - const line = try arena.alloc(u8, pad + text.len); + var kept = text; + if (shown > room) { + var start = panes.File.rawAtDisplay(text, shown - room); + if (panes.File.rawDisplayCol(text, start) < shown - room) start = panes.File.rawAtDisplay(text, shown - room + 1); + kept = text[start..]; + } + const pad = room -| panes.File.displayWidth(kept); + const line = try arena.alloc(u8, pad + kept.len); @memset(line[0..pad], ' '); - @memcpy(line[pad..], text); + @memcpy(line[pad..], kept); try p.renderHeaderLayer(arena, NOTICE_LAYER_BASE + id * Pane.Notices.max + i, .notice, @intCast(id), .{ .x = cx, .y = first + @as(u16, @intCast(i)), @@ -14221,8 +14387,12 @@ pub const Pardes = struct { if (pane.hasPdf() and panes.Pdf.draw(p, pane, r, id, tx, tw)) return; if (pane.image) |*iv| { - const image_h = r.h -| BOX_H; - panes.Image.draw(p, iv, @intCast(id), pane.serial, tx, body_y, tw, image_h); + // Below the notice chips: a picture is drawn after the cells (the + // GUI's image pass, kitty's z-order), so a chip over it would be + // painted out. Text gets the overlay; a picture gives up the rows. + const shown = pane.notices.len; + const image_h = (r.h -| BOX_H) -| shown; + panes.Image.draw(p, iv, @intCast(id), pane.serial, tx, body_y + shown, tw, image_h); // thumbless, but the same one column as the real scrollbar below — // that is the whole point of drawing it, and like that one it runs // past the notice bands so the gutter has no notch in it diff --git a/src/tty/tty.zig b/src/tty/tty.zig index 23b7c09b..03ccd3e2 100644 --- a/src/tty/tty.zig +++ b/src/tty/tty.zig @@ -727,6 +727,7 @@ fn localSession( if (sh.inotify_fd >= 0) sh.watch_task = io.concurrent(watchFiles, .{ io, sh.inotify_fd, loop }) catch null; frames: while (!core.quit) { + pardes.turn.restoreSettled(); try core.pump(host); if (core.takeRestore()) |rp| blk: { const bytes = filesystem.readRestore(gpa, rp) catch |err| { @@ -760,7 +761,7 @@ fn localSession( _ = file_watch.applyThemeEffect(core, gpa, sh.inotify_fd, &sh.watches, 0, false, false); clearNativeImages(kitty_handles, vx, tty); nc.native_images = vx.caps.kitty_graphics; - if (fs) |f| f.reset(core); + if (fs) |f| f.reset(nc); core.deinit(); core = nc; sh.core = nc; @@ -871,15 +872,21 @@ const Shell = struct { fn waitInput(ctx: ?*anyopaque, timeout_ms: u32) void { const s = of(ctx); var batch: usize = 0; + // The wait is the 9P connections' turn with the core. if (timeout_ms == 0) { + pardes.turn.rest(); const first = s.loop.nextEvent() catch { + pardes.turn.wake(); s.core.quit = true; return s.reloadWatched(); }; + pardes.turn.wake(); batch = 1; if (s.apply(first)) return s.reloadWatched(); } else { + pardes.turn.rest(); std.Io.sleep(s.io, .fromMilliseconds(timeout_ms), .awake) catch {}; + pardes.turn.wake(); _ = s.apply(.tick); batch = 1; } @@ -994,7 +1001,7 @@ const Shell = struct { fn pollFrame(ctx: ?*anyopaque) void { const s = of(ctx); - if (s.fs) |f| if (f.tick(s.core).pending) { + if (s.fs) |f| if (f.tick().pending) { _ = s.loop.tryPostEvent(.fs_ready) catch {}; }; for (&s.ptys, 0..) |*slot, id| if (slot.*) |pt| { diff --git a/test/fs_namespace.zig b/test/fs_namespace.zig index 3eba6639..ec94b509 100644 --- a/test/fs_namespace.zig +++ b/test/fs_namespace.zig @@ -98,9 +98,6 @@ test "transactional restore preserves host capabilities and advances pane identi try std.testing.expect(restored.paneBySerial(pane.serial) == null); try std.testing.expectEqual(p.screen_w, restored.screen_w); try std.testing.expectEqual(p.screen_h, restored.screen_h); - try std.testing.expectEqualStrings(p.fs.socket_path, restored.fs.socket_path); - try std.testing.expectEqualDeep(p.fs.tcp_address, restored.fs.tcp_address); - try std.testing.expectEqualDeep(p.fs.quic_address, restored.fs.quic_address); try std.testing.expect(p.panes[0] == pane); try std.testing.expectEqualStrings("before\n", pane.file.?.content); try std.testing.expectError(error.BadDumpMagic, p.restore( @@ -112,27 +109,6 @@ test "transactional restore preserves host capabilities and advances pane identi try std.testing.expectEqualStrings("/tmp/session.sock", p.fs.socket_path); } -test "same-session identity is available before an initial mounted file is opened" { - if (!filesystem.platform_has_fs) return error.SkipZigTest; - const gpa = std.testing.allocator; - var tmp = std.testing.tmpDir(.{}); - defer tmp.cleanup(); - try tmp.dir.writeFile(std.testing.io, .{ .sub_path = "file.txt", .data = "no socket required\n" }); - var buf: [4096]u8 = undefined; - const len = try tmp.dir.realPathFile(std.testing.io, "file.txt", &buf); - const path = try std.fmt.allocPrint(gpa, "/n/own/os{s}", .{buf[0..len]}); - defer gpa.free(path); - const p = try pardes.Pardes.init(gpa, .{ - .file = path, - .mounts = &.{.{ .name = "own", .dial = "/tmp/not-listening.sock" }}, - .ninep_identity = .{ .socket_path = "/tmp/not-listening.sock" }, - }); - defer p.deinit(); - try std.testing.expectEqualStrings(path, p.panes[0].?.file.?.path); - try std.testing.expectEqualStrings("no socket required\n", p.panes[0].?.file.?.content); - try std.testing.expectEqualStrings("", p.opts.ninep_identity.socket_path); -} - test "filesystem resolves OS first then virtual with explicit mounts and parent paths" { if (!filesystem.platform_has_fs) return error.SkipZigTest; const gpa = std.testing.allocator; diff --git a/test/selfmount.py b/test/selfmount.py new file mode 100644 index 00000000..cc889a93 --- /dev/null +++ b/test/selfmount.py @@ -0,0 +1,126 @@ +#!/usr/bin/env python3 +"""A session that opens, reads and saves its own 9P tree through a mount. + +The editor runs under `9ns --mntgen`, so /mnt/9p/pardes/ inside its +namespace is its own tree, and is driven over its socket from outside. This +used to hang the editor outright: the realpath, the stat and the read went +out through the mount and came back as 9P requests only the editor's loop +could answer, while that loop was blocked making them. Now the connection's +task answers them while the editor waits (pardes.turn). + +Needs 9ns (cloud9) on PATH or in ~/.local/bin, and a runtime directory; it +skips, loudly, without them. +""" +import fcntl +import os +from pathlib import Path +import pty +import shutil +import signal +import struct +import sys +import termios +import time + +sys.path.insert(0, str(Path(__file__).resolve().parent)) +from ninep import Client + + +def run(binary): + ns = shutil.which('9ns') or str(Path.home() / '.local/bin/9ns') + runtime = os.environ.get('XDG_RUNTIME_DIR') + if not os.path.exists(ns) or not runtime: + print('selfmount: skipped (needs 9ns and XDG_RUNTIME_DIR)') + return 0 + name = 'selfmount%d' % os.getpid() + sock = f'{runtime}/pardes-9p-{name}.sock' + fixture = Path(f'/tmp/{name}.txt') + fixture.write_bytes(b'initial\n') + env = {k: v for k, v in os.environ.items() if not k.startswith('PARDES_')} + env.update(PARDES_NOTIME='1', TERM='xterm-256color', PARDES_DUMP=f'/tmp/{name}.dump.zon') + for language in ['RS', 'C', 'GO', 'TS', 'PY']: + env['PARDES_LSP_' + language] = '' + pid, master = pty.fork() + if pid == 0: + os.execve(ns, ['9ns', '--mntgen', '--', binary, '--tty', '--9p=' + name, str(fixture)], env) + fcntl.ioctl(master, termios.TIOCSWINSZ, struct.pack('HHHH', 30, 100, 0, 0)) + os.set_blocking(master, False) + tail = bytearray() + + def drain(): + try: + while True: + chunk = os.read(master, 65536) + if not chunk: + return + tail.extend(chunk[-2000:]) + except OSError: + pass + + failures = [] + + def check(condition, what): + print(('ok ' if condition else 'FAIL ') + what) + if not condition: + failures.append(what) + + try: + deadline = time.monotonic() + 15 + while not os.path.exists(sock): + drain() + if time.monotonic() > deadline: + raise TimeoutError('socket never appeared: ' + tail.decode(errors='replace')[-400:]) + time.sleep(.02) + time.sleep(.3) + mount = f'/mnt/9p/pardes/{name}' + with Client(sock) as client: + index = client.read('/index').decode() + rows = [row.split(maxsplit=3) for row in index.splitlines()] + first = rows[0][0] + # A Look at the tree's own index: realpath, stat and read all go + # out through 9ns and back in, and the write returns when the + # pane is open. + started = time.monotonic() + client.write('/look', (mount + '/index\n').encode()) + took = time.monotonic() - started + check(took < 5, f'look at the mounted index returned ({took:.2f}s)') + rows = [row.split(maxsplit=3) for row in client.read('/index').decode().splitlines()] + opened = [row for row in rows if len(row) == 4 and row[3] == mount + '/index'] + check(len(opened) == 1, 'a pane opened on the mounted index') + if opened: + body = client.read(f'/pane/{opened[0][0]}/body').decode() + check(body.startswith(index.splitlines()[0]), 'its body is the index as served') + # A Look at pane 1's body through the mount, an edit of the copy, + # and a Save: the save writes back through the mount into pane 1, + # and the exec returns once it has. + client.write('/look', f'{mount}/pane/{first}/body\n'.encode()) + rows = [row.split(maxsplit=3) for row in client.read('/index').decode().splitlines()] + mirror = [row for row in rows if len(row) == 4 and row[3] == f'{mount}/pane/{first}/body'] + check(len(mirror) == 1, 'a pane opened on the mounted body') + if mirror: + pane = mirror[0][0] + client.write(f'/pane/{pane}/addr', b'#0,#0') + client.write(f'/pane/{pane}/data', b'HELLO ') + client.write(f'/pane/{pane}/exec', b'Save\n') + check(client.read(f'/pane/{first}/body') == b'HELLO initial\n', f'Save wrote back through the mount into pane {first}') + text = ''.join(cell[0] for cell in client.screen()['cells']) + check('saved ' + mount in text, 'the editor reported the save') + client.write('/exec', b'Msg still here\n') + text = ''.join(cell[0] for cell in client.screen()['cells']) + check('still here' in text, 'the editor answers after all of that') + finally: + os.kill(pid, signal.SIGTERM) + time.sleep(.2) + try: + os.kill(pid, signal.SIGKILL) + except ProcessLookupError: + pass + os.waitpid(pid, 0) + for path in (fixture, Path(f'/tmp/{name}.dump.zon')): + path.unlink(missing_ok=True) + print('selfmount: ' + ('ok' if not failures else f'{len(failures)} failed')) + return 0 if not failures else 1 + + +if __name__ == '__main__': + sys.exit(run(str(Path(sys.argv[1]).resolve()))) diff --git a/test/snapshots/images.golden b/test/snapshots/images.golden index a1b78556..74b5f873 100644 --- a/test/snapshots/images.golden +++ b/test/snapshots/images.golden @@ -54,29 +54,29 @@ == style term-palette grid=150x31 |3: 0-0 d,#608269, 1-1 d,#0d1410, 2-74 #e5eee5,#0d1410, 75-75 d,#608269, 76-76 d,#0d1410, 77-149 #e5eee5,#0d1410, |6: 0-1 #000000,#add38a, 2-2 d,#26362d, 3-72 #becfc4,#26362d, 73-74 #dfbce5,#26362d, 75-75 d,#608269, 76-76 d,#0d1410, 77-149 #e5eee5,#0d1410, -|7: 0-0 d,#152019, 1-27 d,#0d1410, 28-28 p8,p5, 29-30 p8,p4, 31-31 p4,p8, 32-35 p8,p4, 36-37 p4,p8, 38-39 p8,p4, 40-40 p4,p8, 41-42 p8,p4, 43-43 p4,p8, 44-46 p8,p4, 47-47 p12,p8, 48-65 d,#0d1410, 66-66 d,#1d2824, 67-73 #b2c3b8,#1d2824, 74-74 d,#1d2824, 75-75 d,#608269, 76-76 d,#0d1410, 77-149 #e5eee5,#0d1410, -|8: 0-0 d,#152019, 1-27 d,#0d1410, 28-30 p8,p4, 31-33 p4,p8, 34-34 p8,p4, 35-36 p4,p8, 37-37 p8,p4, 38-41 p4,p8, 42-42 p8,p4, 43-43 p4,p8, 44-44 p8,p12, 45-46 p12,p8, 47-47 p12,p12, 48-74 d,#0d1410, 75-75 d,#608269, 76-76 d,#0d1410, 77-149 #e5eee5,#0d1410, -|9: 0-0 d,#152019, 1-27 d,#0d1410, 28-28 p8,p4, 29-29 p4,p8, 30-30 p8,p4, 31-31 p4,p8, 32-32 p8,p4, 33-33 p4,p8, 34-35 p8,p4, 36-37 p4,p8, 38-38 p8,p5, 39-41 p8,p4, 42-42 p4,p8, 43-44 p12,p8, 45-47 p12,p12, 48-74 d,#0d1410, 75-75 d,#608269, 76-76 d,#0d1410, 77-149 #e5eee5,#0d1410, -|10: 0-0 d,#152019, 1-27 d,#0d1410, 28-29 p8,p4, 30-34 p4,p8, 35-36 p8,p4, 37-38 p4,p8, 39-39 p8,p4, 40-40 p4,p8, 41-41 p12,p8, 42-47 p12,p12, 48-74 d,#0d1410, 75-75 d,#608269, 76-76 d,#0d1410, 77-149 #e5eee5,#0d1410, -|11: 0-0 d,#152019, 1-27 d,#0d1410, 28-28 p4,p8, 29-29 p8,p4, 30-31 p4,p8, 32-32 p8,p4, 33-33 p4,p8, 34-34 p8,p4, 35-36 p4,p8, 37-37 p8,p4, 38-38 p8,p12, 39-39 p12,p8, 40-47 p12,p12, 48-74 d,#0d1410, 75-75 d,#608269, 76-76 d,#0d1410, 77-149 #e5eee5,#0d1410, -|12: 0-0 d,#152019, 1-27 d,#0d1410, 28-28 p8,p4, 29-31 p4,p8, 32-35 p8,p4, 36-36 p4,p8, 37-37 p12,p8, 38-47 p12,p12, 48-74 d,#0d1410, 75-75 d,#608269, 76-76 d,#0d1410, 77-149 #e5eee5,#0d1410, -|13: 0-0 d,#152019, 1-27 d,#0d1410, 28-32 p8,p4, 33-33 p4,p8, 34-34 p8,p12, 35-36 p12,p8, 37-47 p12,p12, 48-74 d,#0d1410, 75-75 d,#608269, 76-76 d,#0d1410, 77-149 #e5eee5,#0d1410, -|14: 0-0 d,#152019, 1-27 d,#0d1410, 28-28 p8,p4, 29-29 p4,p8, 30-30 p8,p4, 31-32 p4,p8, 33-33 p12,p8, 34-34 p8,p12, 35-47 p12,p12, 48-74 d,#0d1410, 75-75 d,#608269, 76-76 d,#0d1410, 77-149 #e5eee5,#0d1410, -|15: 0-0 d,#152019, 1-27 d,#0d1410, 28-29 p4,p8, 30-30 p8,p12, 31-32 p12,p8, 33-47 p12,p12, 48-74 d,#0d1410, 75-75 d,#608269, 76-76 d,#0d1410, 77-149 #e5eee5,#0d1410, -|16: 0-0 d,#152019, 1-27 d,#0d1410, 28-28 p8,p12, 29-29 p12,p8, 30-47 p12,p12, 48-74 d,#0d1410, 75-75 d,#608269, 76-76 d,#0d1410, 77-149 #e5eee5,#0d1410, +|7: 0-0 d,#152019, 1-65 d,#0d1410, 66-66 d,#1d2824, 67-73 #b2c3b8,#1d2824, 74-74 d,#1d2824, 75-75 d,#608269, 76-76 d,#0d1410, 77-149 #e5eee5,#0d1410, +|8: 0-0 d,#152019, 1-28 d,#0d1410, 29-31 p8,p4, 32-33 p4,p8, 34-37 p8,p4, 38-38 p4,p8, 39-44 p8,p4, 45-45 p8,p12, 46-46 p12,p8, 47-74 d,#0d1410, 75-75 d,#608269, 76-76 d,#0d1410, 77-149 #e5eee5,#0d1410, +|9: 0-0 d,#152019, 1-28 d,#0d1410, 29-29 p8,p4, 30-30 p4,p8, 31-35 p8,p4, 36-36 p5,p8, 37-37 p8,p4, 38-38 p4,p8, 39-41 p8,p4, 42-42 p4,p8, 43-43 p8,p12, 44-45 p12,p8, 46-46 p12,p12, 47-74 d,#0d1410, 75-75 d,#608269, 76-76 d,#0d1410, 77-149 #e5eee5,#0d1410, +|10: 0-0 d,#152019, 1-28 d,#0d1410, 29-30 p8,p4, 31-32 p4,p8, 33-40 p8,p4, 41-41 p8,p12, 42-43 p12,p8, 44-46 p12,p12, 47-74 d,#0d1410, 75-75 d,#608269, 76-76 d,#0d1410, 77-149 #e5eee5,#0d1410, +|11: 0-0 d,#152019, 1-28 d,#0d1410, 29-31 p8,p4, 32-32 p4,p8, 33-34 p8,p4, 35-37 p4,p8, 38-38 p8,p4, 39-39 p8,p12, 40-41 p12,p8, 42-46 p12,p12, 47-74 d,#0d1410, 75-75 d,#608269, 76-76 d,#0d1410, 77-149 #e5eee5,#0d1410, +|12: 0-0 d,#152019, 1-28 d,#0d1410, 29-36 p8,p4, 37-37 p8,p12, 38-39 p12,p8, 40-46 p12,p12, 47-74 d,#0d1410, 75-75 d,#608269, 76-76 d,#0d1410, 77-149 #e5eee5,#0d1410, +|13: 0-0 d,#152019, 1-28 d,#0d1410, 29-30 p4,p8, 31-34 p8,p4, 35-35 p8,p12, 36-36 p12,p8, 37-46 p12,p12, 47-74 d,#0d1410, 75-75 d,#608269, 76-76 d,#0d1410, 77-149 #e5eee5,#0d1410, +|14: 0-0 d,#152019, 1-28 d,#0d1410, 29-29 p4,p8, 30-31 p8,p4, 32-32 p4,p8, 33-33 p8,p12, 34-35 p12,p8, 36-46 p12,p12, 47-74 d,#0d1410, 75-75 d,#608269, 76-76 d,#0d1410, 77-149 #e5eee5,#0d1410, +|15: 0-0 d,#152019, 1-28 d,#0d1410, 29-29 p4,p8, 30-30 p8,p4, 31-31 p8,p12, 32-32 p12,p8, 33-46 p12,p12, 47-74 d,#0d1410, 75-75 d,#608269, 76-76 d,#0d1410, 77-149 #e5eee5,#0d1410, +|16: 0-0 d,#152019, 1-28 d,#0d1410, 29-29 p8,p12, 30-30 p12,p8, 31-46 p12,p12, 47-74 d,#0d1410, 75-75 d,#608269, 76-76 d,#0d1410, 77-149 #e5eee5,#0d1410, == snap no-ascii grid=150x31 cursor=11,8 |3: ls ls |6: img petscii:off palette:terminal ascii:off /tmp/pardes-snap/images/cwd/p -|7: ███╱█🬻██🬺██🬻███╱██🬴▄ Ascii -|8: 🬬██╱███╱🬻ðŸ¬�🬻🬬████ðŸ¬�🬵█ -|9: █╲█🬴████╲╱█ðŸ¬�██▟▄█ -|10: ██╲╱╲█ðŸ¬�█████╱🬵 -|11: ╱█████████ðŸ¬�â–„ -|12: █│█████ðŸ¬�ðŸ¬�🬹 -|13: ██████ðŸ¬�â–„â–ˆ -|14: 🬜🬬██🬸▄╲ -|15: 🬺█ðŸ¬�🬵█ -|16: ðŸ¬�â–„ +|7: Ascii +|8: â–ˆðŸ¬�█╲███▙🬸🬬🬻█████ðŸ¬�🬵 +|9: ███████🬻██🬸█ðŸ¬�â–ˆðŸ¬�â–„â–ˆ +|10: ████████████ðŸ¬�â–„â–ˆ +|11: ███🬸██████ðŸ¬�â–„â–ˆ +|12: ████████ðŸ¬�🬵█ +|13: ╱█████ðŸ¬�â–„ +|14: █🬬█╲ðŸ¬�🬵█ +|15: 🬺█ðŸ¬�🬵 +|16: ðŸ¬�â–„ == snap tag-edit grid=400x31 cursor=87,6 |Newcol Joincol Find Grep Help Changelog Tutor Dump NextColor Debug Kill | New Tty Find Grep Joincol Delcol New Tty Find Grep Joincol Delcol diff --git a/test/snapshots/msg.golden b/test/snapshots/msg.golden index 653e9772..1d5b4cc2 100644 --- a/test/snapshots/msg.golden +++ b/test/snapshots/msg.golden @@ -48,3 +48,7 @@ |2: /tmp/pardes-snap/msg/cwd/a.txt * Save Tty Collapse Del |3: 1 AGAIN hand-written report |5: 3 Msg hand-written report +== snap msgtail grid=70x17 cursor=32,7 +|3: 6789 0123456789 0123456789 0123456789 0123456789 0123456789 THE-END +|6: 4 Msg 0123456789 0123456789 0123456789 0123456789 0123456789 012↩ +|7: 3456789 0123456789 THE-END diff --git a/test/snapshots/msg.snap b/test/snapshots/msg.snap index c8a0a265..5252508a 100644 --- a/test/snapshots/msg.snap +++ b/test/snapshots/msg.snap @@ -89,3 +89,15 @@ key x key tab stable 700 15000 snap msgbuiltin +# A message wider than the pane keeps its TAIL, not its head: the end of a +# message is the part that says something -- a path's file name, an error's +# reason -- so the head is what a narrow pane goes without. +key j +key o +text Msg 0123456789 0123456789 0123456789 0123456789 0123456789 0123456789 0123456789 THE-END +key esc +settle 100 +key x +key tab +stable 700 15000 +snap msgtail diff --git a/test/snapshots/tagbottomimage.golden b/test/snapshots/tagbottomimage.golden index e7100114..0136e1a0 100644 --- a/test/snapshots/tagbottomimage.golden +++ b/test/snapshots/tagbottomimage.golden @@ -35,30 +35,30 @@ |3: pic.ppm |4: |5: /tmp/pardes-snap/tagbottomimage/cwd Tty Save Mode Filter Collapse Del -|6: 4*🬹~F~N🬰|GðŸ¬�â–šY~KF🬴s>T&zZ/🬻iTY=`S~╳bkZR37v🬦🬵d4QHZ8X▛▟ -|8: ^🬪🬛$}DrydNU&wsz=`*r🬒🬓🬳🬟*Y🬴G6🬧f🬮/>t🬧u🬲1Rg1tðŸ¬�🬻█ -|9: â––#_{🬗X@🬢&$s'C%*=w@🬆▀wq%🬡d┼a┼m─>🬭🬜Aâ–€A🬲H]pðŸ¬�🬹 -|10: %?WX🬕f🬩*TA8n╱┼E▘🬭Y#qo~XVEâ–�(╳▀H4^[mj🬗=🬒🬕▟█ -|11: ]Z🬷eb~Oyl3=SLâ–™a🬱🬉~MPMz}FMu<ðŸ¬�â–š>3&▖🬷WSðŸ¬�~â–ˆ -|12: EF-🬑y🬔!r🬙ðŸ¬�╳O🬩â–�%Qj─4za/?/\a🬜"🬖🬈🬛🬟A🬙ðŸ¬�â–„ -|13: 🬃N@xzOnczIK=t0@🬖j5🬮🬧65â–Ÿ{🬮🬉🬄🬩zQ9/ðŸ¬�🬻 -|14: ╲${&%@"#cttâ–€Cr5F;ðŸ¬�ARM╱uej╳75🬹9▛🬻 -|15: h^🬜"🬈🬨▜╲|W🬊🬦k6^🬰🬶rZ─▄\z9🬎🬉4^🬎🬻 -|16: 🬆f│Q_V🬗wGx🬱=5â–›5*&V🬟🬄ZrXGz2ðŸ¬�🬻█ -|17: !🬷WðŸ¬�(🬭]7x_>â–—er🬯~â–šdi🬬4jY:ðŸ¬�â–Ÿ -|18: gU~🬧3â–™bjr\C#kKMpffAjpsðŸ¬�🬻 -|19: *🬯G"🬣▟d🬮▀zJ🬪EHV▟╳9}y▛▄ -|20: ``))~RyJ🬴jA~w=hLpXðŸ¬�🬻█ -|21: 4xâ–€J"TG7=y-QZ🬙╲~▛🬻 -|22: 🬯/+╳f9ZG🬕+{QN_ðŸ¬�🬹 -|23: E<'─🬫pS!"n4&ðŸ¬�~ -|24: m$dx"!2🬳&{ðŸ¬�🬻 -|25: *8f🬩▙Jb🬒ðŸ¬�🬻█ -|26: m🬩7CiN🬎🬹 -|27: pG╲LðŸ¬�🬻 -|28: 🬡LðŸ¬�â–„ -|29: ðŸ¬�~ +|6: Tagbottom +|7: {DbgY🬲sâ–œM^#â–�FUJ[zNq=ðŸ¬�g/y╱?V@🬱🬙▌UK╱ðŸ¬�("🬕KJ8hSoðŸ¬�🬻 +|8: tX🬆s>🬌`🬵 Date: Tue, 22 Sep 2026 17:43:57 -0300 Subject: Repaint PDF highlights by row, send rasters by shared memory, and animate messages PDF highlights (hover preview, search, selection) are baked into page rasters, and any change re-rendered the whole page with MuPDF; the TTY then re-sent it as base64 (4.7 MB a page), the GUI as a new texture. Worse, a pointer motion over a PDF invalidated the page even when no preview was shown, so every motion paid that. Now: - A raster whose baked highlight set equals the wanted one is left alone. - A highlighted page keeps its clean rows (before highlights and tint); a change repaints only the rows of quads that differ, running MuPDF's highlight pass (pardes_pdf_paint_highlights) over those clean rows and tinting them: the operations a full render performs, so the pixels are identical. MuPDF band renders are NOT bit-identical to a whole page (edge rows, resampled images), so they are never used to patch; the comment claiming otherwise is corrected. - ImagePlace.patch hands shells the changed rows; the GUI uploads just those rows into the texture it holds. - The TTY probes kitty shared memory (t=s) with an id vaxis never reaches and sends rasters as a /dev/shm name when the terminal reads it; direct base64 otherwise (ssh). - Shells that take row patches (GUI, TTY with shm) repaint a selection while it is dragged instead of only on release. Latency elsewhere: - TTY: an animating frame no longer sleeps 16 ms blind; a tick thread posts into the input queue, so input inside the frame is handled at once. - TTY and GUI: queued pointer motions coalesce to the last. - GUI: a skipped swapchain image re-arms the frame (3 retries); animations still tick while nothing presents. - Editing: the line index is carried across an edit instead of rebuilt from a scan of the whole file per keystroke. Messages fall into their row (ease-in; the GUI slides the band out from under the tagline, a terminal fades it), stay until the next input as before, linger MessageLinger ms (default 800), and dissolve (ease-out). MessageAnimation toggles it; both are settings, in Config and startup files. The snapshot harness pins the old behaviour. The detached server now ticks animations. A restored terminal comes back live: the old screen and scrollback (dumped as clean VT by ghostty's formatter, replayed at the new size; older dumps fall back to their rendered text), a dim "restored history" marker, then a new shell in the directory it was in. Right-click on a line number in a file pane looks at that line (a sticky context header's number included). Measured with an external pty driver (TTY), an in-process fence trace (GUI, PARDES_TEST_LATENCY), and test/pdf_pointer_bench.zig (pixel identity against the baseline and a whole-page oracle); balanced A/A/B rounds, paired per-round statistics. Messages stack: each event gets its own row and its own fall, linger and dissolve; a line keeps its row until it leaves and a new one fills the first free row. Announcements and statuses are replaced in place, not stacked. MessageFall, MessageDissolve and DumpDir are settings Config reports. Co-Authored-By: Claude Opus 5.5 (1M context) --- build.zig | 19 ++ docs/config.md | 24 ++- src/config.zig | 66 +++++- src/detached/server.zig | 14 +- src/dump.zig | 19 +- src/fs.zig | 4 +- src/gui/gui.zig | 110 ++++++++-- src/macos.zig | 4 +- src/panes.zig | 484 ++++++++++++++++++++++++++++++++++++++++-- src/pardes.zig | 433 +++++++++++++++++++++++++++++++++++-- src/pdf.zig | 67 ++++++ src/pdf_bridge.c | 228 ++++++++++++++++---- src/pdf_bridge.h | 46 +++- src/tag_layer.zig | 4 + src/tty/tty.zig | 148 +++++++++++-- test/output.zig | 3 +- test/panes.zig | 37 ++++ test/pdf_pointer_bench.zig | 224 +++++++++++++++++++ test/snapshot.zig | 4 +- test/snapshots/builtins.snap | 4 + test/snapshots/dump.golden | 3 + test/snapshots/load.golden | 18 +- test/snapshots/restore.golden | 6 +- 23 files changed, 1815 insertions(+), 154 deletions(-) create mode 100644 test/pdf_pointer_bench.zig (limited to 'src/pardes.zig') diff --git a/build.zig b/build.zig index 562ed89f..7010c863 100644 --- a/build.zig +++ b/build.zig @@ -142,6 +142,7 @@ pub fn build(b: *std.Build) void { const mupdf_check = b.step("mupdf-check", "compile, link, render, and search docs/design.pdf with MuPDF"); const pdf_bench_step = b.step("pdf-bench", "benchmark real MuPDF page rendering (-- [--json] [--reps N] [--warmup N] [--path FILE] [--page N] [--pages N])"); const pdf_sections_bench_step = b.step("pdf-sections-bench", "benchmark PDF outline/sections paths in ReleaseFast (-Doptimize=ReleaseFast -- [--json] [--reps N] [--warmup N])"); + const pdf_pointer_bench_step = b.step("pdf-pointer-bench", "time PDF hover and selection gestures and prove their pixels (-Doptimize=ReleaseFast -- [--label L] [--reps N] [--path FILE] [--cell WxH])"); const pdf_scroll_bench_step = b.step("pdf-scroll-bench", "benchmark fast continuous-strip PDF scrolling in ReleaseFast (-Doptimize=ReleaseFast -- [--json] [--reps N] [--warmup N] [--path FILE])"); if (!enable_mupdf) mupdf_check.dependOn(&b.addFail("mupdf-check is unavailable with -Dmupdf=false").step); @@ -151,6 +152,8 @@ pub fn build(b: *std.Build) void { pdf_sections_bench_step.dependOn(&b.addFail("pdf-sections-bench is unavailable with -Dmupdf=false").step); if (!enable_mupdf) pdf_scroll_bench_step.dependOn(&b.addFail("pdf-scroll-bench is unavailable with -Dmupdf=false").step); + if (!enable_mupdf) + pdf_pointer_bench_step.dependOn(&b.addFail("pdf-pointer-bench is unavailable with -Dmupdf=false").step); const shaders_step = b.step("shaders", "refresh paired shaders/prebuilt/*.spv + *.glsl snapshots (glslc)"); const update_shaders = b.addUpdateSourceFiles(); @@ -482,6 +485,22 @@ pub fn build(b: *std.Build) void { run_pdf_sections_bench.setCwd(b.path(".")); pdf_sections_bench_step.dependOn(&run_pdf_sections_bench.step); + const pdf_pointer_bench = b.addExecutable(.{ + .name = "pardes-pdf-pointer-bench", + .root_module = b.createModule(.{ + .target = target, + .optimize = .ReleaseFast, + .root_source_file = b.path("test/pdf_pointer_bench.zig"), + .link_libc = true, + }), + }); + pdf_pointer_bench.root_module.addImport("pardes", core_module); + pdf_pointer_bench.root_module.addImport("mupdf", mupdf_mod); + const run_pdf_pointer_bench = b.addRunArtifact(pdf_pointer_bench); + if (b.args) |args| run_pdf_pointer_bench.addArgs(args); + run_pdf_pointer_bench.setCwd(b.path(".")); + pdf_pointer_bench_step.dependOn(&run_pdf_pointer_bench.step); + const pdf_scroll_bench = b.addExecutable(.{ .name = "pardes-pdf-scroll-bench", .root_module = b.createModule(.{ diff --git a/docs/config.md b/docs/config.md index 8eff79a8..27818b5b 100644 --- a/docs/config.md +++ b/docs/config.md @@ -115,6 +115,16 @@ compact screen. Hiding it preserves your custom column commands. name before it runs; it is on by default, and the builtins that own the message row themselves (`Msg`) never announce. Turning it off leaves the row to the messages a builtin chooses to write. +`MessageAnimation` toggles how a message comes and goes; it is on by default. +A message eases down into its row (graphical frontends slide it out from under +the tagline; a terminal fades it in), stays until the next key or click as it +always has, then lingers for `MessageLinger` milliseconds (default 800) before +it dissolves into the page. `MessageFall` (default 180) and `MessageDissolve` +(default 300) set how long the fall and the dissolve take, also in +milliseconds; each timing is at most 60000, and `Config` reports all three. `MessageLinger 0` with +`MessageAnimation off` restores the old behaviour, a message cleared by the +very input that follows it. An updated line on a row already showing one swaps +its text in place rather than falling again. `SyntaxBold` toggles bold syntax keywords; it is off by default. These settings are shared by GUI and TTY, and `Config` reports their current states. Like `Colors` and `Wrap`, these commands take no argument and invert @@ -573,8 +583,18 @@ control all yield null, and the flag has to work anyway. Neither is a question asked at runtime — a binary that shelled out to `git` would describe whatever tree it was standing in rather than the one it came from. -`Restore a.dump` first looks for the relative path in the default dump directory -(`$XDG_DATA_HOME/pardes`, or `~/.local/share/pardes`). If it is absent, Restore +`Restore a.dump` first looks for the relative path in the dump directory: +`DumpDir ` when set (a leading `~/` is your home; bare `DumpDir` returns +to the default), else `$XDG_DATA_HOME/pardes` or `~/.local/share/pardes`. +`Config` reports the directory in effect as `DumpDir `, so the line can +be fed back as configuration. If it is absent, Restore uses the argument as a path as before. Absolute paths and argument-free Restore retain their existing behavior. `Dump` still honors `$PARDES_DUMP` and otherwise writes a timestamped file in the default directory. + +A restored terminal comes back live: its recorded output (the last MiB of it) +is replayed as history, a dim `── restored history ──` line marks where it +ends, and a new shell starts below it in the directory the old one was in. A +view left scrolled back stays where it was. Only the shell is new; nothing the +old one was running is restarted. The web shell, which has no ptys, still +shows the history alone. diff --git a/src/config.zig b/src/config.zig index 98bbf3f4..527c3752 100644 --- a/src/config.zig +++ b/src/config.zig @@ -102,6 +102,11 @@ pub const leader_path = paths: { table.set(.TaglineSize, null); } if (pardes.platform == .gui) table.set(.Pet, null); + table.set(.MessageAnimation, null); + table.set(.MessageLinger, null); + table.set(.MessageFall, null); + table.set(.MessageDissolve, null); + table.set(.DumpDir, null); if (builtins.capabilities.window_opacity) table.set(.WindowOpacity, null); if (builtins.capabilities.window_blur) table.set(.WindowBlur, null); if (builtins.capabilities.panel_transitions) { @@ -269,6 +274,10 @@ pub const wheel_cols: i32 = 4; pub const look_preview_delay_frames: ?u16 = 2; +/// The longest any message timing (MessageLinger, MessageFall, +/// MessageDissolve) may be set to, in milliseconds. +pub const message_ms_max: u16 = 60_000; + // Tag fonts keep body-cell geometry; valid sizes are 1...100 percent. pub const gui_tagline_font_percent: u8 = 82; comptime { @@ -558,6 +567,17 @@ pub const Runtime = struct { syntax_bold: bool = false, /// Builtins announce themselves on the message row. verbose: bool = true, + /// A message falls into its row and dissolves out of it. + message_animation: bool = true, + /// How long a message stays after the key or click that dismisses it. + message_linger_ms: u16 = 800, + /// How long its ease-in fall into the row takes. + message_fall_ms: u16 = 180, + /// How long its ease-out dissolve takes. + message_dissolve_ms: u16 = 300, + /// Where Dump writes and a relative Restore looks; empty is the default + /// ($XDG_DATA_HOME/pardes, else ~/.local/share/pardes). + dump_dir: Text(limits.host_path_cap) = .{}, window_opacity: u8 = 100, window_blur: u8 = 0, window_opacity_pending: bool = true, @@ -655,7 +675,10 @@ pub const Runtime = struct { pub const Capability = std.meta.FieldEnum(Capabilities); - pub const Toggle = enum { colors, wrap, tree_context_tag_style, tag_bottom, debug, focus_tint, column_tags, syntax_bold, verbose }; + /// The message timings a setting word sets, each in milliseconds. + pub const MessageTime = enum { linger, fall, dissolve }; + + pub const Toggle = enum { colors, wrap, tree_context_tag_style, tag_bottom, debug, focus_tint, column_tags, syntax_bold, verbose, message_animation }; pub const Scene = std.meta.FieldEnum(layout.SceneEffect); pub const Action = union(enum) { @@ -666,6 +689,8 @@ pub const Runtime = struct { tagline_size, window_opacity, window_blur, + message_ms: MessageTime, + dump_dir, transition: layout.Transition, scene: Scene, }; @@ -679,7 +704,7 @@ pub const Runtime = struct { return switch (setting.action) { // A toggle flips when it is a bare tagline word and SETS when // it is given `on` or `off`, so the report is configuration. - .shell, .theme, .font, .tagline_size, .window_opacity, .window_blur, .toggle => true, + .shell, .theme, .font, .tagline_size, .window_opacity, .window_blur, .message_ms, .dump_dir, .toggle => true, else => false, }; } @@ -703,6 +728,11 @@ pub const Runtime = struct { .{ .word = "ColumnTags", .action = .{ .toggle = .column_tags } }, .{ .word = "SyntaxBold", .action = .{ .toggle = .syntax_bold } }, .{ .word = "Verbose", .action = .{ .toggle = .verbose } }, + .{ .word = "MessageAnimation", .action = .{ .toggle = .message_animation } }, + .{ .word = "MessageLinger", .action = .{ .message_ms = .linger } }, + .{ .word = "MessageFall", .action = .{ .message_ms = .fall } }, + .{ .word = "MessageDissolve", .action = .{ .message_ms = .dissolve } }, + .{ .word = "DumpDir", .action = .dump_dir }, .{ .word = "Theme", .action = .theme }, .{ .word = "Shell", .action = .shell }, .{ .word = "Font", .action = .font, .availability = .font_picker }, @@ -827,6 +857,17 @@ pub const Runtime = struct { if (percent > 100) return false; state.window_blur = percent; }, + // Bare, it returns to the default directory. + .dump_dir => if (!state.dump_dir.set(std.mem.trim(u8, argument orelse "", " \t\r\n"))) return false, + .message_ms => |which| { + const text = std.mem.trim(u8, argument orelse return false, " \t\r\n"); + for (text) |byte| if (!std.ascii.isDigit(byte)) return false; + const ms = std.fmt.parseInt(u16, text, 10) catch return false; + if (ms > message_ms_max) return false; + switch (which) { + inline else => |w| @field(state, "message_" ++ @tagName(w) ++ "_ms") = ms, + } + }, .transition => |effect| state.toggleTransition(effect), .scene => |effect| switch (effect) { inline else => |field| { @@ -847,6 +888,9 @@ pub const Runtime = struct { compiled_default_shell: []const u8, gui_shader_source_mode: ?[]const u8 = null, hover_delay_frames: ?u16, + /// Where dumps go when `DumpDir` is unset; empty without a host + /// filesystem. + default_dump_dir: []const u8 = "", native_images: bool, capabilities: Capabilities, state: *const Runtime, @@ -895,6 +939,13 @@ pub const Runtime = struct { else try out.print("{s} unsupported\n", .{setting.word}); }, + .dump_dir => { + const dir = if (state.dump_dir.len > 0) state.dump_dir.get() else context.default_dump_dir; + try out.print("{s} {s}\n", .{ setting.word, if (dir.len > 0) dir else "(none)" }); + }, + .message_ms => |which| try out.print("{s} {d}\n", .{ setting.word, switch (which) { + inline else => |w| @field(state, "message_" ++ @tagName(w) ++ "_ms"), + } }), .shell => { const chosen = state.shell.requested.get(); try out.print( @@ -993,7 +1044,7 @@ pub const Runtime = struct { for (settings[i + 1 ..]) |later| try std.testing.expect(!std.mem.eql(u8, setting.word, later.word)); try std.testing.expectEqual(switch (setting.action) { - .shell, .theme, .font, .tagline_size, .window_opacity, .window_blur, .toggle => true, + .shell, .theme, .font, .tagline_size, .window_opacity, .window_blur, .message_ms, .dump_dir, .toggle => true, else => false, }, setting.takesArg()); } @@ -1152,6 +1203,8 @@ pub const Runtime = struct { .tagline_size => "73", .window_opacity => "85", .window_blur => "40", + .message_ms => "1500", + .dump_dir => "~/dumps", else => null, }; try std.testing.expect(apply(&state, setting, argument)); @@ -1170,11 +1223,18 @@ pub const Runtime = struct { .column_tags => "ColumnTags off\n", .syntax_bold => "SyntaxBold on\n", .verbose => "Verbose off\n", + .message_animation => "MessageAnimation off\n", }, .shell => "Shell requested (new panes) fish\n", .tagline_size => "TaglineSize 73\n", .window_opacity => "WindowOpacity 85 (pending)\n", .window_blur => "WindowBlur 40\n", + .dump_dir => "DumpDir ~/dumps\n", + .message_ms => |which| switch (which) { + .linger => "MessageLinger 1500\n", + .fall => "MessageFall 1500\n", + .dissolve => "MessageDissolve 1500\n", + }, .transition => |transition| switch (transition) { .off => unreachable, .slide => "Panel transition PanelSlide\n", diff --git a/src/detached/server.zig b/src/detached/server.zig index 3e98fc9d..6959e577 100644 --- a/src/detached/server.zig +++ b/src/detached/server.zig @@ -536,7 +536,7 @@ pub const Session = struct { fn writeDump(ctx: ?*anyopaque, bytes: []const u8) void { const s = of(ctx); var pbuf: [1024:0]u8 = undefined; - const path = pardes.dump.outPath(&pbuf) orelse return; + const path = pardes.dump.outPath(&pbuf, s.core.settings.dump_dir.get()) orelse return; filesystem.write(s.core, path, bytes) catch |err| return s.core.reportError(0, "dump", err); s.core.setLastDump(path); } @@ -809,8 +809,11 @@ pub const Session = struct { // The wait is the 9P connections' turn with the core. if (n == 0) { pardes.turn.rest(); - defer pardes.turn.wake(); - return nap(if (timeout_ms == 0) 16 else timeout_ms); + nap(if (timeout_ms == 0) 16 else timeout_ms); + pardes.turn.wake(); + // An animating frame's wait is the frame: tick it. + if (timeout_ms != 0) s.core.update(.tick); + return; } var timeout: c_int = if (timeout_ms == 0) -1 else @intCast(@min(timeout_ms, std.math.maxInt(c_int))); if (s.nextWake(now)) |due| timeout = if (timeout < 0) due else @min(timeout, due); @@ -819,6 +822,9 @@ pub const Session = struct { const ready = libc.poll(&fds, @intCast(n), timeout); pardes.turn.wake(); if (ready > 0) s.dispatch(fds[0..n], src[0..n]); + // Animating, the frame's time is up: advance it. There is no other + // tick in a detached session, and without it an animation never ends. + if (timeout_ms != 0 and monotonicMs() -| now >= timeout_ms) s.core.update(.tick); _ = s.drainCompletions(true); s.expire(monotonicMs()); s.harvest(); @@ -1156,7 +1162,7 @@ pub fn run(init: std.process.Init, opts: pardes.Options, name: []const u8) !void try session.core.pump(h); if (session.core.quit) break; if (session.core.takeRestore()) |path| restore: { - const bytes = filesystem.readRestore(gpa, path) catch |err| { + const bytes = filesystem.readRestore(gpa, path, session.core.settings.dump_dir.get()) catch |err| { session.core.reportError(session.core.active, "Restore", err); break :restore; }; diff --git a/src/dump.zig b/src/dump.zig index 89abd995..ff5d2166 100644 --- a/src/dump.zig +++ b/src/dump.zig @@ -11,11 +11,11 @@ const log = std.log.scoped(.dump); /// pins it for deterministic goldens); else $XDG_DATA_HOME|~/.local/share /// /pardes/pardes-.zon — timestamped so dumps never overwrite each other. /// Creates the pardes dir (parents assumed; a failure surfaces at open). -pub fn outPath(buf: *[1024:0]u8) ?[:0]const u8 { +pub fn outPath(buf: *[1024:0]u8, dir_setting: []const u8) ?[:0]const u8 { if (std.c.getenv("PARDES_DUMP")) |p| return std.fmt.bufPrintSentinel(buf, "{s}", .{std.mem.span(p)}, 0) catch null; var dir_buf: [900]u8 = undefined; - const dir = defaultDirectory(&dir_buf) orelse return null; + const dir = directory(&dir_buf, dir_setting) orelse return null; var dz: [901:0]u8 = undefined; @memcpy(dz[0..dir.len], dir); dz[dir.len] = 0; @@ -32,6 +32,15 @@ pub fn outPath(buf: *[1024:0]u8) ?[:0]const u8 { ds.getSecondsIntoMinute(), }, 0) catch null; } +/// Where dumps go and relative Restore names are looked up: the `DumpDir` +/// setting when set (a leading `~/` is the home directory), else the default. +pub fn directory(buf: []u8, dir_setting: []const u8) ?[]const u8 { + if (dir_setting.len == 0) return defaultDirectory(buf); + if (std.mem.startsWith(u8, dir_setting, "~/")) if (std.c.getenv("HOME")) |h| + return std.fmt.bufPrint(buf, "{s}/{s}", .{ std.mem.span(h), dir_setting[2..] }) catch null; + return std.fmt.bufPrint(buf, "{s}", .{dir_setting}) catch null; +} + /// The standard dump directory, without creating it or generating a filename. pub fn defaultDirectory(buf: []u8) ?[]const u8 { if (std.c.getenv("XDG_DATA_HOME")) |x| @@ -69,8 +78,14 @@ pub const PaneKind = enum { pub const Terminal = struct { cwd: []const u8 = "", + /// The rendered scrollback and screen as plain text, one row per line. stream: []const u8 = "", stream_b64: []const u8 = "", + /// `stream_b64` is the emulator's primary screen and scrollback as clean + /// VT (ghostty's formatter), which replays to what the screen showed. + /// Absent (older dumps), it is the raw tail of the pty's output, which + /// replays faithfully only if it holds the whole session at one size. + stream_is_screen: bool = false, cursor: Cursor = .{}, }; diff --git a/src/fs.zig b/src/fs.zig index 85eae825..84ab3b95 100644 --- a/src/fs.zig +++ b/src/fs.zig @@ -1104,9 +1104,9 @@ pub fn readFile(gpa: std.mem.Allocator, path: []const u8) ![]u8 { /// Restore first tries a relative argument under the default dump directory, /// then preserves the ordinary file lookup. Absolute paths remain verbatim. -pub fn readRestore(gpa: std.mem.Allocator, path: []const u8) ![]u8 { +pub fn readRestore(gpa: std.mem.Allocator, path: []const u8, dir_setting: []const u8) ![]u8 { var dir_buf: [4096]u8 = undefined; - const dir = @import("dump.zig").defaultDirectory(&dir_buf); + const dir = @import("dump.zig").directory(&dir_buf, dir_setting); return readRestoreIn(gpa, path, dir); } diff --git a/src/gui/gui.zig b/src/gui/gui.zig index 17bdb46f..7f28124c 100644 --- a/src/gui/gui.zig +++ b/src/gui/gui.zig @@ -2111,8 +2111,8 @@ fn runNative(init: std.process.Init, opts_in: pardes.Options, attach: ?[]const u } var win_flags: c.SDL_WindowFlags = c.SDL_WINDOW_RESIZABLE; if (!test_mode) win_flags |= c.SDL_WINDOW_HIGH_PIXEL_DENSITY; - // A latency run renders to the capture texture; keep it off the desktop. - if (latency_fd >= 0) win_flags |= c.SDL_WINDOW_HIDDEN; + // A test run renders to the capture texture; keep it off the desktop. + if (test_mode) win_flags |= c.SDL_WINDOW_HIDDEN; const native_wayland = !test_mode and std.mem.eql(u8, std.mem.span(c.SDL_GetCurrentVideoDriver()), "wayland"); // Background-only opacity needs per-pixel alpha; whole-window compositor // opacity would dim the text as well. SDL requires this flag at creation. @@ -2353,6 +2353,7 @@ fn localSession( } else try pardes.Pardes.init(allocs.pardes, opts); defer core.deinit(); core.native_images = true; + core.native_image_patches = true; observeGuiFont(g, core); syncTaglineFont(g, core); @@ -2448,7 +2449,7 @@ fn localSession( } } if (core.takeRestore()) |rp| blk: { - const bytes = filesystem.readRestore(gpa, rp) catch |err| { + const bytes = filesystem.readRestore(gpa, rp, core.settings.dump_dir.get()) catch |err| { core.reportError(core.active, "Restore", err); break :blk; }; @@ -2473,6 +2474,7 @@ fn localSession( g.presented_images.clearRetainingCapacity(); g.prepared_images.clearRetainingCapacity(); nc.native_images = true; + nc.native_image_patches = true; nc.host = host; if (fs) |f| f.reset(nc); core.deinit(); @@ -3591,6 +3593,7 @@ const Shell = struct { test_mode: bool = false, feed: StdinFeed = .{}, presented: bool = false, + skipped_presents: u8 = 0, surface: ?*pardes.Surface = null, animation_clock: AnimationClock = .{}, saw_event: bool = false, @@ -3774,14 +3777,29 @@ fn waitInput(ctx: ?*anyopaque, timeout_ms: u32) void { var in: Input = .{ .core = core }; if (s.gui) |g| { var sev = std.mem.zeroes(c.SDL_Event); - const ms: c_int = if (timeout_ms != 0) @intCast(timeout_ms) else 16; + // A latency trace is fed on stdin, whose poll below paces the loop: + // waiting here too would make every tick cost two frames. + const ms: c_int = if (latency_fd >= 0) 0 else if (timeout_ms != 0) @intCast(timeout_ms) else 16; // The wait is the 9P connections' turn with the core. pardes.turn.rest(); const got = c.SDL_WaitEventTimeout(&sev, ms); pardes.turn.wake(); if (got) { - dispatch(g, &in, &sev); - while (c.SDL_PollEvent(&sev)) dispatch(g, &in, &sev); + // A run of queued motions is one move to its last position (the + // handler reads only absolute x/y and held buttons): acting on + // each would repeat hover and selection work the next undoes. + var motion: ?c.SDL_Event = null; + while (true) { + if (sev.type == c.SDL_EVENT_MOUSE_MOTION) { + motion = sev; + } else { + if (motion) |*m| dispatch(g, &in, m); + motion = null; + dispatch(g, &in, &sev); + } + if (!c.SDL_PollEvent(&sev)) break; + } + if (motion) |*m| dispatch(g, &in, m); } } if (s.test_mode) { @@ -3913,6 +3931,10 @@ fn present(ctx: ?*anyopaque, surface: *const pardes.Surface) void { log.err("render: {t}", .{err}); break :blk false; }; + // A skipped swapchain image would otherwise hide this input's frame until + // the next event. A few retries only: a minimized window never gets one. + s.skipped_presents = if (s.presented) 0 else s.skipped_presents +| 1; + if (!s.presented and s.skipped_presents <= 3) core.present_skipped = true; if (g.scene_target_failed) { g.scene_failures +|= 1; log.err("scene target unavailable (attempt {d}/3)", .{g.scene_failures}); @@ -3926,7 +3948,12 @@ fn present(ctx: ?*anyopaque, surface: *const pardes.Surface) void { fn postPresent(ctx: ?*anyopaque) void { const s = shellOf(ctx); const g = s.gui orelse return; - if (!s.presented) return; + if (!s.presented) { + // No image (a minimized window): time still passes, so a lingering + // message or a hover wait runs out instead of redrawing forever. + if (s.animation_clock.due(s.core.animationActive(), c.SDL_GetTicksNS())) s.core.update(.tick); + return; + } const frame = s.surface orelse return; refreshPresentedPointer(g, s.core); finishPresentedAnimationFrame( @@ -4030,7 +4057,7 @@ fn writeFile(ctx: ?*anyopaque, pane: u8, path: []const u8, bytes: []const u8) vo fn writeDump(ctx: ?*anyopaque, bytes: []const u8) void { const s = shellOf(ctx); var pbuf: [1024:0]u8 = undefined; - const path = pardes.dump.outPath(&pbuf) orelse return; + const path = pardes.dump.outPath(&pbuf, s.core.settings.dump_dir.get()) orelse return; filesystem.write(s.core, path, bytes) catch |err| return s.core.reportError(0, "dump", err); s.core.setLastDump(path); } @@ -4533,6 +4560,23 @@ fn uploadNativeTexture( const byte_len = validImageBytes(place) orelse return error.BadImage; const key = place.cacheKey(); if (g.native_images.contains(key)) return; + if (comptime pardes.pdf_enabled) if (place.patch) |patch| patch: { + // The core changed only these rows since a revision we still hold: + // write them into that texture rather than sending the whole page. + var base = key; + base.revision = patch.from; + if (patch.y + patch.h > place.ih) break :patch; + const texture = g.native_images.get(base) orelse break :patch; + const row = place.iw * 4; + try uploadTextureRows(g, cmd, texture, place.rgba[patch.y * row ..][0 .. patch.h * row], place.iw, patch.y, patch.h); + try g.native_images.put(gpa, key, texture); + _ = g.native_images.remove(base); + // A transition snapshot of the last frame follows its texture. + for (g.presented_images.items) |*saved| if (saved.key.eql(base)) { + saved.key = key; + }; + return; + }; var tex_info = std.mem.zeroes(c.SDL_GPUTextureCreateInfo); tex_info.type = c.SDL_GPU_TEXTURETYPE_2D; @@ -4545,39 +4589,51 @@ fn uploadNativeTexture( tex_info.sample_count = c.SDL_GPU_SAMPLECOUNT_1; const texture = c.SDL_CreateGPUTexture(g.device, &tex_info) orelse return error.GpuCreate; errdefer c.SDL_ReleaseGPUTexture(g.device, texture); + try uploadTextureRows(g, cmd, texture, place.rgba[0..byte_len], place.iw, 0, place.ih); + try g.native_images.put(gpa, key, texture); +} +/// Copy `rows` rows of RGBA, `width` pixels each, into `texture` at row `y`. +fn uploadTextureRows( + g: *Gui, + cmd: *c.SDL_GPUCommandBuffer, + texture: *c.SDL_GPUTexture, + rgba: []const u8, + width: usize, + y: usize, + rows: usize, +) !void { var xf_info = c.SDL_GPUTransferBufferCreateInfo{ .usage = c.SDL_GPU_TRANSFERBUFFERUSAGE_UPLOAD, - .size = byte_len, + .size = @intCast(rgba.len), .props = 0, }; const transfer = c.SDL_CreateGPUTransferBuffer(g.device, &xf_info) orelse return error.GpuCreate; defer c.SDL_ReleaseGPUTransferBuffer(g.device, transfer); const mapped: [*]u8 = @ptrCast(c.SDL_MapGPUTransferBuffer(g.device, transfer, false) orelse return error.GpuMap); - @memcpy(mapped[0..byte_len], place.rgba); + @memcpy(mapped[0..rgba.len], rgba); c.SDL_UnmapGPUTransferBuffer(g.device, transfer); const copy = c.SDL_BeginGPUCopyPass(cmd); const src = c.SDL_GPUTextureTransferInfo{ .transfer_buffer = transfer, .offset = 0, - .pixels_per_row = @intCast(place.iw), - .rows_per_layer = @intCast(place.ih), + .pixels_per_row = @intCast(width), + .rows_per_layer = @intCast(rows), }; const dst = c.SDL_GPUTextureRegion{ .texture = texture, .mip_level = 0, .layer = 0, .x = 0, - .y = 0, + .y = @intCast(y), .z = 0, - .w = @intCast(place.iw), - .h = @intCast(place.ih), + .w = @intCast(width), + .h = @intCast(rows), .d = 1, }; c.SDL_UploadToGPUTexture(copy, &src, &dst, false); c.SDL_EndGPUCopyPass(copy); - try g.native_images.put(gpa, key, texture); } fn appendPreparedImage( @@ -5442,16 +5498,30 @@ fn emitTagLayer(g: *Gui, instances: [*]CellInstance, next: *u32, layer: *const p const left = @as(f32, @floatFromInt(layer.viewport.x)) * bw; const right = left + @as(f32, @floatFromInt(layer.viewport.w)) * bw; const background: pardes.Cell = .{ .default = false, .style = .{ .bg = .{ .rgb = layer.bg } } }; - emitInstance(g, instances, next.*, 0, layer.viewport.y, .{ .w = right - left, .h = bh, .x_off = left, .y_off = 0 }, win_w, win_h, track, .body, &background, old_layer, false, page); + // A band sliding into place is drawn offset and cut at its row's top, so + // it comes out from under whatever is above it. + const slide = layer.slide * bh; + const top = @as(f32, @floatFromInt(layer.viewport.y)) * bh; + emitInstance(g, instances, next.*, 0, layer.viewport.y, .{ .w = right - left, .h = bh, .x_off = left, .y_off = slide }, win_w, win_h, track, .body, &background, old_layer, false, page); + if (slide != 0) clipInstanceTop(&instances[next.*], top, win_h); next.* += 1; for (0..tagLayerCellCount(g, layer)) |col| { const cursor = if (layer.cursor) |cu| show_cursor and !cu.bar and cu.col == col else false; - emitInstance(g, instances, next.*, @intCast(col), layer.viewport.y, .{ .w = tw, .h = bh, .x_off = left, .y_off = 0 }, win_w, win_h, track, .tagline, &layer.cells[col], old_layer, cursor, page); + emitInstance(g, instances, next.*, @intCast(col), layer.viewport.y, .{ .w = tw, .h = bh, .x_off = left, .y_off = slide }, win_w, win_h, track, .tagline, &layer.cells[col], old_layer, cursor, page); clipInstanceRight(&instances[next.*], right, win_w); + if (slide != 0) clipInstanceTop(&instances[next.*], top, win_h); next.* += 1; } } +fn clipInstanceTop(instance: *CellInstance, top: f32, win_h: f32) void { + const limit = 1 - top / win_h * 2; + if (instance.y0 <= limit) return; + const fraction = std.math.clamp((limit - instance.y1) / (instance.y0 - instance.y1), 0, 1); + instance.v0 = instance.v1 + (instance.v0 - instance.v1) * fraction; + instance.y0 = @max(instance.y1, limit); +} + fn bodyLayerAt(surface: *const pardes.Surface, col: u16, row: u16) ?*const pardes.BodyLayer { return bodyLayerIn(surface.bodyLayers(), col, row); } @@ -6436,7 +6506,9 @@ fn captureFrame(g: *Gui, gpa: std.mem.Allocator, cmd: *c.SDL_GPUCommandBuffer, t } fn writeCapturePpm(g: *Gui, gpa: std.mem.Allocator, pixels: []const u8, width: u32, height: u32) !void { - if (g.capture_dir.len == 0) return; + // A latency trace times frames, and an 8 MB file write per frame would + // stall the loop it is timing. + if (g.capture_dir.len == 0 or latency_fd >= 0) return; const bpp = c.SDL_GPUTextureFormatTexelBlockSize(g.swapchain_format); if (bpp != 4) return error.UnsupportedCaptureFormat; const bgr = switch (g.swapchain_format) { diff --git a/src/macos.zig b/src/macos.zig index a7ee3164..c359eb3f 100644 --- a/src/macos.zig +++ b/src/macos.zig @@ -1325,7 +1325,7 @@ export fn pardes_tick() bool { fn restoreCore(st: *State) bool { if (st.core.quit) return false; const path = st.core.takeRestore() orelse return false; - const bytes = filesystem.readRestore(st.gpa, path) catch |err| { + const bytes = filesystem.readRestore(st.gpa, path, st.core.settings.dump_dir.get()) catch |err| { st.core.reportError(st.core.active, "Restore", err); return false; }; @@ -2431,7 +2431,7 @@ fn writeFile(ctx: ?*anyopaque, pane: u8, path: []const u8, bytes: []const u8) vo fn writeDump(ctx: ?*anyopaque, bytes: []const u8) void { const st = hostState(ctx); var pbuf: [1024:0]u8 = undefined; - const path = pardes.dump.outPath(&pbuf) orelse return; + const path = pardes.dump.outPath(&pbuf, st.core.settings.dump_dir.get()) orelse return; filesystem.write(st.core, path, bytes) catch |err| return st.core.reportError(0, "dump", err); st.core.setLastDump(path); } diff --git a/src/panes.zig b/src/panes.zig index b3424385..8d4330e9 100644 --- a/src/panes.zig +++ b/src/panes.zig @@ -183,6 +183,20 @@ pub const Pane = struct { tty_filter: bool = false, msg: [256]u8 = undefined, msg_len: u16 = 0, + /// Where the newest message line is in its life. + msg_life: MessageLife = .{}, + /// The row (among the notice rows) the newest line holds for its life. + msg_slot: u8 = 0, + /// Earlier message lines still on screen, oldest first, each running its + /// own life: a new message stacks under them instead of replacing them. + msg_older: [message_stack]OlderMessage = undefined, + msg_older_len: u8 = 0, + /// The newest line is a builtin announcing itself in this step: what + /// the step says next replaces it rather than stacking under it. + msg_announcement: bool = false, + /// The newest line is a status (progress, a server's state): the next + /// line replaces it rather than stacking under it. + msg_status: bool = false, /// The transient lines this pane shows between its body and its tagline: /// a builtin's message, the pending leader chord, a prompt waiting for /// input. Rebuilt every frame from the state that owns each one, so a @@ -192,30 +206,102 @@ pub const Pane = struct { /// reserves rows for sticky context headers. notices: Notices = .{}, + pub const MessagePhase = enum { entering, shown, lingering, leaving }; + /// One message line's animation: falling in, shown, lingering after the + /// key or click that dismissed it, dissolving. `frame` counts animation + /// frames within the phase. + pub const MessageLife = struct { + phase: MessagePhase = .shown, + frame: u16 = 0, + /// Dismissed while still falling: it lingers once it has landed. + dismissed: bool = false, + }; + /// Older message lines kept on screen under a new one. + pub const message_stack = 3; + pub const OlderMessage = struct { + text: [256]u8 = undefined, + len: u16 = 0, + life: MessageLife = .{}, + slot: u8 = 0, + + pub fn slice(line: *const OlderMessage) []const u8 { + return line.text[0..line.len]; + } + }; + + /// Move the newest line onto the stack of older ones, dropping the oldest + /// when it is full; the newest slot is left empty for what arrives. + pub fn pushOlderMessage(pane: *Pane) void { + if (pane.msg_older_len == message_stack) { + std.mem.copyForwards(OlderMessage, pane.msg_older[0 .. message_stack - 1], pane.msg_older[1..]); + pane.msg_older_len -= 1; + } + pane.msg_older[pane.msg_older_len] = .{ .text = pane.msg, .len = pane.msg_len, .life = pane.msg_life, .slot = pane.msg_slot }; + pane.msg_older_len += 1; + pane.msg_len = 0; + pane.msg_life = .{}; + } + + /// The first row no older line holds. A line keeps its row until it + /// leaves, and a new one fills the first gap: nothing on screen moves. + pub fn freeMessageSlot(pane: *const Pane) u8 { + var used: u8 = 0; + for (pane.msg_older[0..pane.msg_older_len]) |line| used |= @as(u8, 1) << @intCast(line.slot); + var slot: u8 = 0; + while (used & (@as(u8, 1) << @intCast(slot)) != 0) slot += 1; + return slot; + } + + pub fn removeOlderMessage(pane: *Pane, i: usize) void { + std.mem.copyForwards(OlderMessage, pane.msg_older[i .. pane.msg_older_len - 1], pane.msg_older[i + 1 .. pane.msg_older_len]); + pane.msg_older_len -= 1; + } + pub const Notices = struct { /// Painted bottom-up in this order, so a prompt keeps the row nearest /// the tagline that it has always had, and its cursor with it. - pub const Kind = enum { message, leader, prompt }; - pub const max = @typeInfo(Kind).@"enum".fields.len; + /// `older` is an earlier message line still on screen; `index` says + /// which (`Pane.msg_older`). + pub const Kind = enum { older, message, leader, prompt }; + pub const max = @typeInfo(Kind).@"enum".fields.len - 1 + message_stack; kinds: [max]Kind = undefined, + index: [max]u8 = @splat(0), + /// Each band's row below the body's top: message lines keep theirs, + /// so a band that leaves leaves a gap rather than moving the rest. + row: [max]u8 = @splat(0), /// Where each band's chip starts, as an absolute grid column. A chip /// is only as wide as its own text, so the rest of the row underneath /// is ordinary body text and a click there has to reach it. left: [max]u16 = @splat(std.math.maxInt(u16)), len: u8 = 0, + /// A band on the next row after every band so far. pub fn push(n: *Notices, kind: Kind) void { + n.pushAt(kind, 0, n.span()); + } + + pub fn pushAt(n: *Notices, kind: Kind, index: u8, row: u8) void { if (n.len >= max) return; n.kinds[n.len] = kind; + n.index[n.len] = index; + n.row[n.len] = row; n.left[n.len] = std.math.maxInt(u16); n.len += 1; } /// Is this cell inside the chip drawn for band `i`? Nothing else on /// that row belongs to the notice. - pub fn covers(n: *const Notices, i: usize, col: u16) bool { - return i < n.len and col >= n.left[i]; + pub fn covers(n: *const Notices, row: usize, col: u16) bool { + for (0..n.len) |i| if (n.row[i] == row) return col >= n.left[i]; + return false; + } + + /// Rows from the body's top down to the last band's. + pub fn span(n: *const Notices) u8 { + var rows: u8 = 0; + for (n.row[0..n.len]) |row| rows = @max(rows, row + 1); + return rows; } pub fn slice(n: *const Notices) []const Kind { @@ -1327,7 +1413,15 @@ pub const File = struct { const file = &pane.file.?; for ([_][]const u8{ "", "one", "one\n", "a\r\nλ界\nlast", "\n\n", "\tλ e\u{301}\n\r\n" }) |content| { setContent(p, file, try p.gpa.dupe(u8, content)); - try std.testing.expectEqual(@as(usize, 0), file.line_starts.len); + // An edit carries a built index forward; it must equal a fresh one. + if (file.line_starts.len > 0) { + const carried = file.line_starts; + defer p.gpa.free(carried); + file.line_starts = &.{}; + try std.testing.expectEqualSlices(usize, try lineIndex(p.gpa, file), carried); + p.gpa.free(file.line_starts); + file.line_starts = &.{}; + } const rows = lineCount(content) + 2; for ([_]bool{ false, true }) |indexed| { if (indexed) _ = try lineIndex(p.gpa, file); @@ -1546,6 +1640,80 @@ pub const File = struct { return starts; } + /// The line index of `new` from `old`'s: an edit replaces one span, so + /// line starts before it stand, starts after it shift, and only the span + /// is scanned. Rebuilding scanned the whole file on every keystroke. + fn editedLineStarts(gpa: std.mem.Allocator, starts: []const usize, old: []const u8, new: []const u8) ![]usize { + const n = @min(old.len, new.len); + var head: usize = 0; + while (head + 64 <= n and std.mem.eql(u8, old[head..][0..64], new[head..][0..64])) head += 64; + while (head < n and old[head] == new[head]) head += 1; + var tail: usize = 0; + while (tail + 64 <= n - head and std.mem.eql(u8, old[old.len - tail - 64 ..][0..64], new[new.len - tail - 64 ..][0..64])) tail += 64; + while (tail < n - head and old[old.len - tail - 1] == new[new.len - tail - 1]) tail += 1; + // A start s follows the newline at s-1: kept while that newline is in + // the common head, shifted while it is in the common tail. + const kept = std.sort.upperBound(usize, starts, head, struct { + fn order(key: usize, item: usize) std.math.Order { + return std.math.order(key, item); + } + }.order); + const old_tail_at = old.len - tail; + const moved = starts.len - std.sort.upperBound(usize, starts, old_tail_at, struct { + fn order(key: usize, item: usize) std.math.Order { + return std.math.order(key, item); + } + }.order); + const middle = new[head .. new.len - tail]; + const out = try gpa.alloc(usize, kept + std.mem.count(u8, middle, "\n") + moved); + @memcpy(out[0..kept], starts[0..kept]); + var i = kept; + var off: usize = 0; + while (std.mem.indexOfScalarPos(u8, middle, off, '\n')) |nl| { + off = nl + 1; + out[i] = head + off; + i += 1; + } + for (starts[starts.len - moved ..]) |start| { + out[i] = start + new.len - old.len; + i += 1; + } + return out; + } + + test "edited line index equals a rebuilt one" { + const gpa = std.testing.allocator; + var prng = std.Random.DefaultPrng.init(7); + const r = prng.random(); + var text: std.ArrayList(u8) = .empty; + defer text.deinit(gpa); + for (0..300) |_| try text.append(gpa, "ab\n"[r.uintLessThan(usize, 3)]); + for (0..2000) |_| { + var old_state: State = undefined; + old_state.content = text.items; + old_state.line_starts = &.{}; + const starts = try lineIndex(gpa, &old_state); + defer gpa.free(starts); + // one random replace, like any edit through setContent + const at = r.uintAtMost(usize, text.items.len); + const del = r.uintAtMost(usize, @min(8, text.items.len - at)); + var ins: [8]u8 = undefined; + const ins_len = r.uintAtMost(usize, 8); + for (ins[0..ins_len]) |*c| c.* = "ab\n"[r.uintLessThan(usize, 3)]; + const old = try gpa.dupe(u8, text.items); + defer gpa.free(old); + try text.replaceRange(gpa, at, del, ins[0..ins_len]); + const edited = try editedLineStarts(gpa, starts, old, text.items); + defer gpa.free(edited); + var fresh_state: State = undefined; + fresh_state.content = text.items; + fresh_state.line_starts = &.{}; + const fresh = try lineIndex(gpa, &fresh_state); + defer gpa.free(fresh); + try std.testing.expectEqualSlices(usize, fresh, edited); + } + } + /// line count, O(1) once the index is warm pub fn nlines(gpa: std.mem.Allocator, f: *State) usize { const idx = lineIndex(gpa, f) catch return lineCount(f.content); @@ -1760,12 +1928,13 @@ pub const File = struct { reportEdit(p, f, new); if (f.mini) |*mini| mini.deinit(p.gpa); f.mini = null; + const starts: []usize = if (f.line_starts.len > 0) editedLineStarts(p.gpa, f.line_starts, f.content, new) catch &.{} else &.{}; p.gpa.free(f.content); f.content = new; f.revision +%= 1; f.mtime = pardes.ctlfs.events.now(); if (f.line_starts.len > 0) p.gpa.free(f.line_starts); - f.line_starts = &.{}; + f.line_starts = starts; if (f.highlights.len > 0) p.tree_sitter_gpa.free(f.highlights); f.highlights = &.{}; f.highlight_start = 0; @@ -2864,7 +3033,10 @@ pub const Output = struct { pub fn openConfig(p: *Pardes, id: usize) !void { var out: std.Io.Writer.Allocating = .init(p.gpa); errdefer out.deinit(); + var dir_buf: [1024]u8 = undefined; + const host_fs = comptime (pardes.platform != .web and pardes.platform != .esp32p4); try config.Runtime.writeReport(&out.writer, .{ + .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), .theme_name = p.theme().name, @@ -3599,6 +3771,9 @@ pub const Pdf = struct { const Page = struct { page: usize, items: []const Highlight }; pages: [3]Page = undefined, len: usize = 0, + /// Repaint whenever the set changes, not only when a page's raster was + /// invalidated (`HighlightInput.live`). + live: bool = false, pub fn forPage(highlights: @This(), page: usize) []const Highlight { for (highlights.pages[0..highlights.len]) |group| @@ -3612,6 +3787,7 @@ pub const Pdf = struct { hover_page: ?usize = null, hover_color: [3]u8, selection_color: [3]u8, + live: bool = false, } else void; pub fn buildHighlights( @@ -3623,7 +3799,7 @@ pub const Pdf = struct { const search_len = if (state.search_results) |results| results.quads.len else 0; const selection_len = if (state.selection) |selection| selection.quads.len else 0; const items = try arena.alloc(Highlight, input.hover_quads.len + search_len + selection_len); - var result: Highlights = .{}; + var result: Highlights = .{ .live = input.live }; var n: usize = 0; // Hover, search and selection can belong to three different pages. // Group them once so raster rendering can borrow a contiguous slice. @@ -3721,6 +3897,19 @@ pub const Pdf = struct { decorated: bool = false, tint_key: ?TintKey = null, revision: u32 = 0, + /// `rgba` before its highlights and tint, kept once the page has been + /// highlighted: a highlight change repaints rows from it instead of + /// rendering the page again. + clean: []u8 = &.{}, + /// The highlights baked into `rgba` (gpa-owned), so a change repaints + /// only the rows of the quads that differ. + baked: []Highlight = &.{}, + /// `baked` is a true record (false after a render could not copy it). + baked_valid: bool = false, + /// Page rows changed since revision `patch_from`, the one last handed + /// to a shell; 0 when the pixels were replaced wholesale since. + patch_from: u32 = 0, + patch_rows: pdf.Document.Rows = .{ .start = 0, .end = 0 }, } else void; pub const SectionsOutput = if (enabled) struct { @@ -3894,6 +4083,8 @@ pub const Pdf = struct { } fn retireRaster(state: *@This(), gpa: std.mem.Allocator, raster: *Raster) void { + if (raster.clean.len > 0) gpa.free(raster.clean); + gpa.free(raster.baked); state.retireRgba(gpa, raster.rgba); raster.* = .{}; } @@ -4138,8 +4329,11 @@ pub const Pdf = struct { pub fn deinit(state: *@This(), gpa: std.mem.Allocator) void { gpa.free(state.path); - for (state.rasters[0..state.rasters_len]) |raster| + for (state.rasters[0..state.rasters_len]) |raster| { if (raster.rgba.len > 0) gpa.free(raster.rgba); + if (raster.clean.len > 0) gpa.free(raster.clean); + gpa.free(raster.baked); + } for (state.spare[0..state.spare_len]) |rgba| gpa.free(rgba); gpa.free(state.page_sizes); gpa.free(state.page_starts); @@ -4614,16 +4808,27 @@ pub const Pdf = struct { const slot = raster.?; const page_highlights = highlights.forPage(page); const decorated = page_highlights.len > 0; - const stale = !slot.tried or !slot.request_valid or - !slot.request.eql(request) or slot.decorated != decorated or + const base_stale = !slot.request_valid or !slot.request.eql(request) or slot.tint_key == null or !slot.tint_key.?.eql(tint_key) or slot.rgba.len == 0 or slot.band_h == 0; - const uncovered = !stale and uncovered: { + const uncovered = !base_stale and uncovered: { const want = wantedBand(state, viewport, page, slotShape(slot), is_flinging); break :uncovered slot.band_y > want.y or slot.band_y + slot.band_h < want.y + want.height; }; - if (!stale and !uncovered) continue; + if (!base_stale and !uncovered) { + if (slot.tried and slot.decorated == decorated and + !(highlights.live and !sameHighlights(slot.baked, page_highlights))) continue; + // Invalidated, but it already shows exactly these highlights + // (a preview withdrawn that was never drawn, on every pointer + // move over a page): nothing to render. + if (slot.baked_valid and sameHighlights(slot.baked, page_highlights)) { + slot.tried = true; + continue; + } + // Only the highlights moved: repaint their rows in place. + if (repaintHighlights(state, gpa, slot, request, tint_key, page_highlights)) continue; + } slot.tried = true; slot.request = request; @@ -4640,15 +4845,27 @@ pub const Pdf = struct { { const tz_render = tracy.zone(@src(), "pdf.render_into"); defer tz_render.end(); + // A highlighted page keeps its clean rows for repaints. + const keep_clean = pardes.platform != .macos and (decorated or slot.clean.len > 0); state.document.renderIntoAtWithPaper( page, request, shape, want, - page_highlights, + if (keep_clean) &.{} else page_highlights, fresh, pardes.platform == .macos, ) catch break :filled false; + if (slot.clean.len != 0 and (!keep_clean or slot.clean.len != fresh.len)) { + gpa.free(slot.clean); + slot.clean = &.{}; + } + if (keep_clean) { + if (slot.clean.len == 0) slot.clean = gpa.alloc(u8, fresh.len) catch &.{}; + if (slot.clean.len == fresh.len) @memcpy(slot.clean, fresh); + state.document.paintHighlightsAt(page, request, shape, want, page_highlights, fresh) catch + break :filled false; + } } const tz_tint = tracy.zone(@src(), "pdf.tint"); defer tz_tint.end(); @@ -4658,6 +4875,9 @@ pub const Pdf = struct { }; if (!filled) { state.retireRgba(gpa, fresh); + // `clean` may already hold the band that failed. + if (slot.clean.len > 0) gpa.free(slot.clean); + slot.clean = &.{}; continue; } @@ -4669,6 +4889,18 @@ pub const Pdf = struct { slot.band_h = want.height; slot.decorated = decorated; slot.tint_key = tint_key; + if (gpa.dupe(Highlight, page_highlights)) |copy| { + gpa.free(slot.baked); + slot.baked = copy; + slot.baked_valid = true; + } else |_| { + // Unrecorded highlights cannot be compared or diffed. + slot.baked_valid = false; + if (slot.clean.len > 0) gpa.free(slot.clean); + slot.clean = &.{}; + } + slot.patch_from = 0; + slot.patch_rows = .{ .start = 0, .end = 0 }; state.next_raster_revision +%= 1; if (state.next_raster_revision == 0) state.next_raster_revision = 1; slot.revision = state.next_raster_revision; @@ -4676,6 +4908,114 @@ pub const Pdf = struct { state.trimSpares(gpa); } + /// Repaint only the rows where the old and new highlights differ: the + /// clean rows kept from the page's last render, MuPDF's highlight pass + /// (the whole new set) over them, the per-pixel tint — the operations a + /// full render performs, in its order, on fewer rows and without running + /// the page again. False leaves the slot for the full path. + fn repaintHighlights( + state: *State, + gpa: std.mem.Allocator, + slot: *Raster, + request: RenderRequest, + tint_key: TintKey, + page_highlights: []const Highlight, + ) bool { + const tz = tracy.zone(@src(), "pdf.repaint_highlights"); + defer tz.end(); + if (slot.clean.len != slot.rgba.len or !slot.baked_valid) return false; + if (sameHighlights(slot.baked, page_highlights)) { + slot.tried = true; + return true; + } + const baked = gpa.dupe(Highlight, page_highlights) catch return false; + const changed = changedHighlights(gpa, slot.baked, page_highlights) catch { + gpa.free(baked); + return false; + }; + defer gpa.free(changed); + var dirty = state.document.highlightRows(slot.page, request, changed) catch { + gpa.free(baked); + return false; + }; + slot.tried = true; + dirty.start = @max(dirty.start, slot.band_y); + dirty.end = @min(dirty.end, slot.band_y + slot.band_h); + if (dirty.start < dirty.end) { + const shape = slotShape(slot); + const band = shape.band(dirty.start, dirty.end - dirty.start); + const offset = (dirty.start - slot.band_y) * shape.stride; + const out = slot.rgba[offset..][0..band.len]; + @memcpy(out, slot.clean[offset..][0..band.len]); + // On failure the rows are half-made: let the full path redo them. + state.document.paintHighlightsAt(slot.page, request, shape, band, page_highlights, out) catch { + gpa.free(baked); + slot.tried = false; + return false; + }; + pdf.tintRgba(out, tint_key.mode, tint_key.colors) catch { + gpa.free(baked); + slot.tried = false; + return false; + }; + slot.patch_rows = unionRows(slot.patch_rows, dirty); + state.next_raster_revision +%= 1; + if (state.next_raster_revision == 0) state.next_raster_revision = 1; + slot.revision = state.next_raster_revision; + } + gpa.free(slot.baked); + slot.baked = baked; + slot.decorated = page_highlights.len > 0; + return true; + } + + fn sameHighlights(a: []const Highlight, b: []const Highlight) bool { + return std.mem.eql(u8, std.mem.sliceAsBytes(a), std.mem.sliceAsBytes(b)); + } + + /// The highlights in one set and not the other, as multisets (a quad + /// painted twice blends twice). When only the order changed, blending + /// order did, so everything counts. + // ponytail: quadratic match; past 64k comparisons every quad counts. + fn changedHighlights(gpa: std.mem.Allocator, old: []const Highlight, new: []const Highlight) ![]Highlight { + const out = try gpa.alloc(Highlight, old.len + new.len); + errdefer gpa.free(out); + var n: usize = 0; + if (old.len * new.len <= 1 << 16) { + const matched = try gpa.alloc(bool, new.len); + defer gpa.free(matched); + @memset(matched, false); + for (old) |h| { + for (new, matched) |candidate, *used| { + if (!used.* and std.mem.eql(u8, std.mem.asBytes(&h), std.mem.asBytes(&candidate))) { + used.* = true; + break; + } + } else { + out[n] = h; + n += 1; + } + } + for (new, matched) |h, used| if (!used) { + out[n] = h; + n += 1; + }; + } + if (n == 0) { + @memcpy(out[0..old.len], old); + @memcpy(out[old.len..], new); + return out; + } + // Freed by length: hand back exactly what the caller will free. + return gpa.realloc(out, n); + } + + fn unionRows(a: pdf.Document.Rows, b: pdf.Document.Rows) pdf.Document.Rows { + if (a.start >= a.end) return b; + if (b.start >= b.end) return a; + return .{ .start = @min(a.start, b.start), .end = @max(a.end, b.end) }; + } + pub fn renderFrame( state: *State, gpa: std.mem.Allocator, @@ -5837,6 +6177,7 @@ pub const Pdf = struct { .hover_page = hover_page, .hover_color = if (link_hover) core.theme().box else selection_color, .selection_color = selection_color, + .live = core.native_image_patches, }; } @@ -5907,6 +6248,16 @@ pub const Pdf = struct { const visible_end = visible.first + visible.len; while (page < visible_end) : (page += 1) { const placed = placedRaster(state, view, page) orelse continue; + const slot = rasterForPage(state, page).?; + const patch: ?pardes.ImagePatch = if (slot.patch_from != 0 and + slot.patch_rows.start < slot.patch_rows.end) + .{ + .from = slot.patch_from, + .y = @intCast(slot.patch_rows.start - slot.band_y), + .h = @intCast(slot.patch_rows.end - slot.patch_rows.start), + } + else + null; if (!core.appendImagePlace(.{ .pane = @intCast(pane_id), .serial = pane.serial, @@ -5928,14 +6279,18 @@ pub const Pdf = struct { .x = text_x, // Below the notice chips, like an image: a placed page is // drawn after the cells and would paint a chip out. - .y = core.bodyTop(rect) + pane.notices.len, + .y = core.bodyTop(rect) + pane.notices.span(), .w = text_width, - .h = (rect.h -| pardes.BOX_H) -| pane.notices.len, + .h = (rect.h -| pardes.BOX_H) -| pane.notices.span(), .rgba = placed.rgba, .iw = placed.width, // The texture contains the retained band, not the full page. .ih = placed.band_height, + .patch = patch, })) break; + // A shell now holds (or will fetch whole) this revision. + slot.patch_from = slot.revision; + slot.patch_rows = .{ .start = 0, .end = 0 }; placed_any = true; } if (!placed_any) return false; @@ -6439,9 +6794,15 @@ pub const Terminal = struct { return pane; } - /// Rebuild a dump's dead terminal emulator. Registration and tag/cwd policy - /// stay with the core; raw VT replay and viewport restoration belong here. - pub fn restore(p: *Pardes, src: dump.Pane) !*Pane { + /// Where a restored terminal's history ends and its new shell begins. + pub const restored_banner = "\x1b[0m\r\n\x1b[2m\u{2500}\u{2500} restored history \u{2500}\u{2500}\x1b[0m\r\n"; + + /// Rebuild a dump's terminal emulator from its recorded output. `live`: a + /// shell will be spawned into it, so the history is marked off from what + /// that shell prints and the pane waits for it like any new terminal. + /// Registration and tag/cwd policy stay with the core; raw VT replay and + /// viewport restoration belong here. + pub fn restore(p: *Pardes, src: dump.Pane, live: bool) !*Pane { const terminal = src.terminal.?; if (comptime !enabled) { const pane = try create(p.gpa, @max(1, src.cols), @max(1, src.rows)); @@ -6450,12 +6811,28 @@ pub const Terminal = struct { pane.ovl = .{ .row = 0, .rows = 1, .text = try p.gpa.dupe(u8, terminal.stream) }; return pane; } - const bytes = if (terminal.stream_b64.len > 0) + // An older dump's raw output tail cannot come back live: cut off mid + // redraw, or written at sizes the pane no longer has, it replays as + // garbage. Its rendered text can. + const legacy_text = live and !terminal.stream_is_screen and terminal.stream.len > 0; + const bytes = if (legacy_text) + try std.mem.replaceOwned(u8, p.scratch.allocator(), terminal.stream, "\n", "\r\n") + else if (terminal.stream_b64.len > 0) try dump.decodeBytes(p.scratch.allocator(), terminal.stream_b64) else &.{}; const pane = try create(p.gpa, @max(1, src.cols), @max(1, src.rows)); - if (bytes.len > 0) { + if (live) { + if (bytes.len > 0) { + ingest(pane, bytes); + ingest(pane, restored_banner); + } + followOutput(pane); + // A view left scrolled back stays on what it was showing: the + // banner's line breaks scrolled a full screen by that many more. + if (src.scroll > 0) scrollGrid(pane, -@as(i32, @intCast(src.scroll + comptime std.mem.count(u8, restored_banner, "\n")))); + armShellSpawn(pane); + } else if (bytes.len > 0) { ingest(pane, bytes); followOutput(pane); if (src.scroll > 0) @@ -6613,7 +6990,7 @@ pub const Terminal = struct { .cols = pane.cols, .rows = pane.rows, .terminal = .{ .stream_b64 = encoded }, - }); + }, false); defer gpa.destroy(restored); defer deinitEmulator(restored, gpa); const before = try screenTextAlloc(pane, gpa); @@ -6624,6 +7001,58 @@ pub const Terminal = struct { try std.testing.expectEqualSlices(u8, try replayBytes(pane, gpa), try replayBytes(restored, gpa)); } + test "a restored terminal keeps its history above a marker and gets a shell where it was" { + if (comptime !enabled or pardes.isolated) return error.SkipZigTest; + const gpa = std.testing.allocator; + const p = try Pardes.init(gpa, .{ .tty_only = true, .cols = 40, .rows = 12 }); + defer p.deinit(); + while (p.nextEffect()) |_| {} + const pane = p.panes[0].?; + feedOutput(p, pane, "old output\r\n$ ls\r\n"); + try pane.setOwnedCwd("/tmp"); + try p.dumpState(); + const restored = try Pardes.initFromDump(gpa, .{ .tty_only = true, .cols = 40, .rows = 12 }, p.dump_out.?); + defer restored.deinit(); + var spawned = false; + while (restored.nextEffect()) |effect| switch (effect) { + .spawn => |sp| spawned = sp.pane == 0 and std.mem.eql(u8, sp.cwd.slice(), "/tmp"), + else => {}, + }; + try std.testing.expect(spawned); + const again = restored.panes[0].?; + try std.testing.expectEqual(.spawn, again.pending_command.wait); + const text = try screenTextAlloc(again, gpa); + defer gpa.free(text); + const old_at = std.mem.indexOf(u8, text, "old output") orelse return error.HistoryLost; + const mark_at = std.mem.indexOf(u8, text, "restored history") orelse return error.NoMarker; + try std.testing.expect(old_at < mark_at); + } + + test "an older dump comes back live from its rendered text, not its raw output tail" { + if (comptime !enabled) return error.SkipZigTest; + const gpa = std.testing.allocator; + const p = try Pardes.init(gpa, .{ .tty_only = true, .cols = 40, .rows = 12 }); + defer p.deinit(); + // A tail cut mid-redraw: relative moves from a cursor it never set. + const tail = try dump.encodeBytes(gpa, "\x1b[7A\x1b[2Kgarbage\x1b[3B\x1b[9Gmore"); + defer gpa.free(tail); + const restored = try restore(p, .{ + .kind = .terminal, + .tag = "", + .body = "", + .cols = 40, + .rows = 12, + .terminal = .{ .stream = "$ ls\na.txt b.txt\n$ ", .stream_b64 = tail }, + }, true); + defer gpa.destroy(restored); + defer deinitEmulator(restored, gpa); + defer deinitPendingCommand(restored); + const text = try screenTextAlloc(restored, gpa); + defer gpa.free(text); + try std.testing.expect(std.mem.indexOf(u8, text, "$ ls\na.txt b.txt") != null); + try std.testing.expect(std.mem.indexOf(u8, text, "garbage") == null); + } + /// Record and parse one live pty read, invalidate its motion surface, and /// follow it only when the body (possibly parked under a tag edit) is raw. pub fn feedOutput(p: *Pardes, pane: *Pane, bytes: []const u8) void { @@ -7247,6 +7676,16 @@ pub const Terminal = struct { overlay.text = new; } + /// The shell's screen and scrollback (the primary screen, even under a + /// full-screen program) as VT that replays to what was shown: styled + /// text, soft-wrapped lines rejoined so they reflow at another width. + fn screenVt(pane: *const Pane, arena: std.mem.Allocator) ![]const u8 { + const screen = pane.terminal.?.vt.screens.get(.primary) orelse return &.{}; + var out: std.Io.Writer.Allocating = .init(arena); + try ghostty_vt.formatter.ScreenFormatter.init(screen, .{ .emit = .vt, .unwrap = true }).format(&out.writer); + return out.written(); + } + /// Serialize terminal-only state; the core supplies shared pane metadata. pub fn dumpPane( pane: *Pane, @@ -7318,7 +7757,8 @@ pub const Terminal = struct { .terminal = .{ .cwd = try arena.dupe(u8, pane.cwdSlice()), .stream = stream[0..len], - .stream_b64 = try dump.encodeBytes(arena, try replayBytes(pane, arena)), + .stream_b64 = try dump.encodeBytes(arena, try screenVt(pane, arena)), + .stream_is_screen = true, .cursor = .{ .col = pane.terminal.?.vt.screens.active.cursor.x, .row = pane.terminal.?.vt.screens.active.cursor.y, diff --git a/src/pardes.zig b/src/pardes.zig index cc57127f..fae14f47 100644 --- a/src/pardes.zig +++ b/src/pardes.zig @@ -2722,8 +2722,16 @@ test "Msg writes the transient row by hand, bare or with text, and input ends it try std.testing.expect(p.executeBuiltinLine(2, "Msg")); try std.testing.expectEqualStrings("Msg: NoMessage", row(p, 2)); - // A message is exactly as old as your last input. + // Input starts its exit: it lingers, dissolves, and is gone. p.update(.{ .key = .{ .cp = Key.escape } }); + try std.testing.expectEqualStrings("Msg: NoMessage", row(p, 2)); + for (0..200) |_| p.update(.tick); + try std.testing.expectEqualStrings("", row(p, 2)); + // ...and with neither linger nor animation it is as old as your last input. + try std.testing.expect(p.executeBuiltinLine(2, "MessageAnimation off")); + try std.testing.expect(p.executeBuiltinLine(2, "MessageLinger 0")); + try std.testing.expect(p.executeBuiltinLine(2, "Msg gone")); + p.update(.{ .key = .{ .cp = 'h' } }); try std.testing.expectEqualStrings("", row(p, 2)); // Longer than the row's buffer is CUT, never refused and never overrun: @@ -2735,6 +2743,151 @@ test "Msg writes the transient row by hand, bare or with text, and input ends it try std.testing.expectEqual(p.panes[2].?.msg.len, row(p, 2).len); } +test "a message falls in, lingers past the input that dismisses it, and dissolves" { + const p = try Pardes.init(std.testing.allocator, .{ .tty_only = true, .cols = 80, .rows = 24 }); + defer p.deinit(); + while (p.nextEffect()) |_| {} + const pane = p.panes[p.active].?; + try std.testing.expect(p.settings.message_animation); + try std.testing.expect(p.executeBuiltinLine(p.active, "MessageLinger 160")); + try std.testing.expect(p.executeBuiltinLine(p.active, "Msg hello")); + try std.testing.expectEqual(Pane.MessagePhase.entering, pane.msg_life.phase); + try std.testing.expect(p.animationActive()); + // An ease-in fall: starts a whole row up, lands exactly on it. + const start = p.messageMotion(pane.msg_life); + try std.testing.expectEqual(@as(f32, -1), start.slide); + var last = start.slide; + for (0..Pardes.messageFrames(p.settings.message_fall_ms)) |_| { + p.needs_frame = false; + p.update(.tick); + // Every tick that moves it owes a frame, the landing one included. + try std.testing.expect(p.needs_frame); + const now = p.messageMotion(pane.msg_life); + try std.testing.expect(now.slide >= last); + last = now.slide; + } + try std.testing.expectEqual(Pane.MessagePhase.shown, pane.msg_life.phase); + try std.testing.expectEqual(@as(f32, 0), p.messageMotion(pane.msg_life).slide); + try std.testing.expect(!p.animationActive()); + // Shown until input, like always; the same line again does not re-enter. + for (0..100) |_| p.update(.tick); + try std.testing.expectEqual(Pane.MessagePhase.shown, pane.msg_life.phase); + try std.testing.expect(p.executeBuiltinLine(p.active, "Msg hello")); + try std.testing.expectEqual(Pane.MessagePhase.shown, pane.msg_life.phase); + // Input (a key that announces nothing): 160 ms of lingering (ten frames), unaffected by more input... + p.update(.{ .key = .{ .cp = 'h' } }); + try std.testing.expectEqual(Pane.MessagePhase.lingering, pane.msg_life.phase); + for (0..9) |_| { + p.update(.tick); + p.update(.{ .key = .{ .cp = 'h' } }); + } + try std.testing.expectEqual(Pane.MessagePhase.lingering, pane.msg_life.phase); + p.update(.tick); + // ...then an ease-out dissolve toward nothing, and gone. + try std.testing.expectEqual(Pane.MessagePhase.leaving, pane.msg_life.phase); + var alpha: f32 = 1; + for (0..Pardes.messageFrames(p.settings.message_dissolve_ms)) |_| { + const now = p.messageMotion(pane.msg_life).alpha; + try std.testing.expect(now <= alpha); + alpha = now; + p.needs_frame = false; + p.update(.tick); + } + try std.testing.expectEqual(@as(u16, 0), pane.msg_len); + try std.testing.expect(!p.animationActive()); + // The tick that clears it still owes the frame that shows it gone. + try std.testing.expect(p.needs_frame); + + // Dismissed mid-fall: it lands, then lingers. + try std.testing.expect(p.executeBuiltinLine(p.active, "Msg again")); + try std.testing.expectEqual(Pane.MessagePhase.entering, pane.msg_life.phase); + p.update(.tick); + p.update(.{ .key = .{ .cp = 'h' } }); + try std.testing.expectEqual(Pane.MessagePhase.entering, pane.msg_life.phase); + for (0..Pardes.messageFrames(p.settings.message_fall_ms)) |_| p.update(.tick); + try std.testing.expectEqual(Pane.MessagePhase.lingering, pane.msg_life.phase); + // Shown again while lingering: fresh, so it stays; a status update to a + // line on screen swaps its text in place instead of falling again. + try std.testing.expect(p.executeBuiltinLine(p.active, "Msg again")); + try std.testing.expectEqual(Pane.MessagePhase.shown, pane.msg_life.phase); + p.setStatus(p.active, "progress 50%"); + try std.testing.expectEqual(Pane.MessagePhase.shown, pane.msg_life.phase); + try std.testing.expectEqualStrings("progress 50%", pane.msg[0..pane.msg_len]); + try std.testing.expectEqual(@as(u8, 0), pane.msg_older_len); + // The fall and the dissolve are timings of their own, in milliseconds. + try std.testing.expect(p.executeBuiltinLine(p.active, "MessageFall 48")); + try std.testing.expect(p.executeBuiltinLine(p.active, "MessageDissolve 0")); + try std.testing.expectEqual(@as(u16, 3), Pardes.messageFrames(p.settings.message_fall_ms)); + try std.testing.expectEqual(@as(u16, 1), Pardes.messageFrames(p.settings.message_dissolve_ms)); + // The Config report reads back as configuration. + try std.testing.expect(p.executeBuiltinLine(p.active, "MessageAnimation")); + try std.testing.expect(!p.settings.message_animation); + try std.testing.expect(p.executeBuiltinLine(p.active, "Msg plain")); + try std.testing.expectEqual(Pane.MessagePhase.shown, pane.msg_life.phase); +} + +test "messages stack, oldest on top, each on its own timing" { + const p = try Pardes.init(std.testing.allocator, .{ .tty_only = true, .cols = 80, .rows = 24 }); + defer p.deinit(); + while (p.nextEffect()) |_| {} + const pane = p.panes[p.active].?; + try std.testing.expect(p.executeBuiltinLine(p.active, "Verbose off")); + try std.testing.expect(p.executeBuiltinLine(p.active, "MessageLinger 160")); + // `Verbose off` announced itself before it took effect. + pane.msg_len = 0; + pane.msg_life = .{}; + const fall = Pardes.messageFrames(p.settings.message_fall_ms); + p.setMessage(p.active, "first"); + for (0..fall) |_| p.update(.tick); + try std.testing.expectEqual(Pane.MessagePhase.shown, pane.msg_life.phase); + // A second message stacks under the first instead of replacing it. + p.setMessage(p.active, "second"); + try std.testing.expectEqual(@as(u8, 1), pane.msg_older_len); + try std.testing.expectEqualStrings("first", pane.msg_older[0].slice()); + try std.testing.expectEqualStrings("second", pane.msg[0..pane.msg_len]); + try std.testing.expectEqual(Pane.MessagePhase.entering, pane.msg_life.phase); + p.collectNotices(pane, p.rects[p.active], p.active); + try std.testing.expectEqual(Pane.Notices.Kind.older, pane.notices.kinds[0]); + try std.testing.expectEqual(Pane.Notices.Kind.message, pane.notices.kinds[1]); + // One key dismisses both, but each runs its own clock: the first starts + // lingering now, the second only once it has landed. + p.update(.{ .key = .{ .cp = 'h' } }); + try std.testing.expectEqual(Pane.MessagePhase.lingering, pane.msg_older[0].life.phase); + try std.testing.expectEqual(Pane.MessagePhase.entering, pane.msg_life.phase); + const linger = Pardes.messageFrames(p.settings.message_linger_ms); + const dissolve = Pardes.messageFrames(p.settings.message_dissolve_ms); + for (0..linger + dissolve) |_| p.update(.tick); + // The first is gone; the second, a fall later, is still dissolving. + try std.testing.expectEqual(@as(u8, 0), pane.msg_older_len); + try std.testing.expectEqualStrings("second", pane.msg[0..pane.msg_len]); + try std.testing.expectEqual(Pane.MessagePhase.leaving, pane.msg_life.phase); + for (0..fall) |_| p.update(.tick); + try std.testing.expectEqual(@as(u16, 0), pane.msg_len); + try std.testing.expect(!p.animationActive()); + // A status ticking in place does not pile up. + p.setStatus(p.active, "lsp 10%"); + p.setStatus(p.active, "lsp 20%"); + try std.testing.expectEqual(@as(u8, 0), pane.msg_older_len); + // Lines keep their rows: when the top one leaves, the one under it does + // not move up, and the next message fills the gap instead. + p.setMessage(p.active, "top"); + p.setMessage(p.active, "under"); + try std.testing.expectEqual(@as(u8, 0), pane.msg_older[0].slot); + try std.testing.expectEqual(@as(u8, 1), pane.msg_slot); + pane.removeOlderMessage(0); + p.collectNotices(pane, p.rects[p.active], p.active); + try std.testing.expectEqual(@as(u8, 1), pane.notices.row[0]); + try std.testing.expectEqual(@as(u8, 2), pane.notices.span()); + p.setMessage(p.active, "fills"); + try std.testing.expectEqual(@as(u8, 0), pane.msg_slot); + try std.testing.expectEqual(@as(u8, 1), pane.msg_older[0].slot); + // The stack keeps the newest few. + for ([_][]const u8{ "a", "b", "c", "d", "e" }) |text| p.setMessage(p.active, text); + try std.testing.expectEqual(@as(u8, Pane.message_stack), pane.msg_older_len); + try std.testing.expectEqualStrings("b", pane.msg_older[0].slice()); + try std.testing.expectEqualStrings("e", pane.msg[0..pane.msg_len]); +} + test "Font keeps requested and acknowledged faces as separate plain state" { if (comptime !font_picker) return; // there is no Font builtin on tty or web const p = try Pardes.init(std.testing.allocator, .{ .cols = 80, .rows = 24 }); @@ -3774,6 +3927,8 @@ pub const NativePlacement = if (pdf_enabled) struct { paper_bg: ?[3]u8 = null, } else struct {}; +pub const ImagePatch = struct { from: u32, y: u32, h: u32 }; + pub const ImagePlace = struct { pane: u8, /// Pane slots are reused. This identity makes a cached GPU texture or @@ -3787,6 +3942,10 @@ pub const ImagePlace = struct { rgba: []const u8, iw: usize, ih: usize, + /// Rows [y, y+h) of `rgba` are the only ones that differ from the + /// same pane page at revision `from`: a shell still holding that one may + /// update just these rows instead of taking the whole image again. + patch: ?ImagePatch = null, pub fn cacheKey(place: ImagePlace) ImageCacheKey { if (comptime pdf_enabled) @@ -6194,6 +6353,10 @@ pub const Pardes = struct { chrome_animation: ChromeAnimation = ChromeAnimation.init(initial_chrome), animate_theme_changes: bool = false, native_images: bool = false, + /// The shell can take a changed image a few rows at a time (a texture row + /// upload, a shared-memory hand-off), so a PDF selection is repainted as + /// it is dragged instead of once on release. + native_image_patches: bool = false, quit: bool = false, haptic: HapticSlot = if (platform == .macos) .none else {}, drag: Drag = .none, @@ -6250,6 +6413,9 @@ pub const Pardes = struct { /// Is there a frame worth drawing? Cleared once one is presented, set by /// anything that can change what is on screen. The first frame always is. needs_frame: bool = true, + /// Set by a shell whose present was skipped (no swapchain image): the + /// frame is still owed, and the next pump draws it again. + present_skipped: bool = false, /// Builtins announce themselves on the message row. Off while startup /// configuration is applied: those lines are nobody clicking, and should /// not leave the row holding the name of the last one. @@ -7040,16 +7206,18 @@ pub const Pardes = struct { } }; + /// A status updates the message line in place (a progress count does not + /// pile up); a message is an event, and stacks. pub fn setStatus(p: *Pardes, id: usize, text: []const u8) void { - p.showMessage(id, text); + p.showMessage(id, text, false); } pub fn setMessage(p: *Pardes, id: usize, text: []const u8) void { p.logMessage(id, text); - p.showMessage(id, text); + p.showMessage(id, text, true); } - fn showMessage(p: *Pardes, id: usize, text: []const u8) void { + fn showMessage(p: *Pardes, id: usize, text: []const u8, stack: bool) void { if (id >= MAX_PANES) return; const pane = p.panes[id] orelse return; // One row of printable text: a language server's multi-line report @@ -7058,8 +7226,158 @@ pub const Pardes = struct { if (n < text.len) { while (n > 0 and text[n] & 0xC0 == 0x80) n -= 1; } + const same = pane.msg_len == n and for (text[0..n], pane.msg[0..n]) |c, have| { + if ((if (c < 0x20 or c == 0x7f) ' ' else c) != have) break false; + } else true; + // A new event moves the line on screen up the stack, where it keeps + // its own timing, and falls in below it. + // Only an event stacks on an event: an announcement or a status + // stands in for whatever comes next. + if (stack and pane.msg_len > 0 and !same and !pane.msg_announcement and !pane.msg_status) + pane.pushOlderMessage(); + if (pane.msg_len == 0) pane.msg_slot = pane.freeMessageSlot(); + pane.msg_announcement = false; + pane.msg_status = !stack; + const arrives = pane.msg_len == 0 or pane.msg_life.phase == .leaving; for (text[0..n], pane.msg[0..n]) |c, *cell| cell.* = if (c < 0x20 or c == 0x7f) ' ' else c; pane.msg_len = @intCast(n); + p.needs_frame = true; + if (arrives) { + pane.msg_life = .{ .phase = if (p.settings.message_animation and n > 0) .entering else .shown }; + } else if (pane.msg_life.phase == .lingering or + (pane.msg_life.phase == .entering and !p.settings.message_animation)) + { + // The same line again, or a status update: fresh, so it stays. + pane.msg_life = .{}; + } else { + pane.msg_life.dismissed = false; + } + } + + /// The key or click that used to clear the message row now starts each + /// line's exit: it stays `message_linger_ms`, then dissolves. A line + /// already on its way out keeps its own timing. + fn dismissMessage(p: *Pardes, pane: *Pane) void { + if (pane.msg_len > 0 and p.dismissLine(&pane.msg_life)) { + pane.msg_len = 0; + pane.msg_life = .{}; + } + var i: usize = 0; + while (i < pane.msg_older_len) { + if (p.dismissLine(&pane.msg_older[i].life)) pane.removeOlderMessage(i) else i += 1; + } + } + + /// Start one line's exit; true when it is gone at once (no linger, no + /// animation). + fn dismissLine(p: *const Pardes, life: *Pane.MessageLife) bool { + switch (life.phase) { + .lingering, .leaving => return false, + // A falling line lands first, then lingers -- unless falling was + // just turned off, and nothing will land it. + .entering => if (p.settings.message_animation) { + life.dismissed = true; + return false; + }, + .shown => {}, + } + life.frame = 0; + if (p.settings.message_linger_ms > 0) { + life.phase = .lingering; + } else if (p.settings.message_animation) { + life.phase = .leaving; + } else return true; + return false; + } + + /// One animation frame of every message line. Each one that moves owes + /// a frame, the one that finishes included: a tick asks for none itself. + fn advanceMessages(p: *Pardes) void { + for (p.panes) |slot| { + const pane = slot orelse continue; + if (pane.msg_len > 0 and pane.msg_life.phase != .shown) { + p.needs_frame = true; + if (p.advanceLine(&pane.msg_life)) { + pane.msg_len = 0; + pane.msg_life = .{}; + } + } + var i: usize = 0; + while (i < pane.msg_older_len) { + if (pane.msg_older[i].life.phase != .shown) p.needs_frame = true; + if (p.advanceLine(&pane.msg_older[i].life)) pane.removeOlderMessage(i) else i += 1; + } + } + } + + /// One frame of one line's life; true once it has left. + fn advanceLine(p: *const Pardes, life: *Pane.MessageLife) bool { + if (life.phase == .shown) return false; + life.frame +|= 1; + switch (life.phase) { + .shown => {}, + .entering => if (life.frame >= messageFrames(p.settings.message_fall_ms)) { + life.* = .{ .phase = if (life.dismissed) .lingering else .shown }; + }, + .lingering => if (life.frame >= messageFrames(p.settings.message_linger_ms)) { + if (!p.settings.message_animation) return true; + life.* = .{ .phase = .leaving }; + }, + .leaving => if (life.frame >= messageFrames(p.settings.message_dissolve_ms)) return true, + } + return false; + } + + /// Is any message line moving (and so owed ticks)? + fn messagesAnimating(pane: *const Pane) bool { + if (pane.msg_len > 0 and pane.msg_life.phase != .shown) return true; + for (pane.msg_older[0..pane.msg_older_len]) |line| if (line.life.phase != .shown) return true; + return false; + } + + /// How present a message is (1 = fully) and how far above its row it + /// still is (rows), eased: an ease-in fall, an ease-out dissolve. + const MessageMotion = struct { alpha: f32 = 1, slide: f32 = 0 }; + + /// Animation frames a message timing lasts; at least one. + pub fn messageFrames(ms: u16) u16 { + return @intCast(@max(1, (@as(u32, ms) + layout.Animation.frame_ms - 1) / layout.Animation.frame_ms)); + } + + fn messageMotion(p: *const Pardes, life: Pane.MessageLife) MessageMotion { + const fall_frames = messageFrames(p.settings.message_fall_ms); + const dissolve_frames = messageFrames(p.settings.message_dissolve_ms); + return switch (life.phase) { + .shown, .lingering => .{ .alpha = 1, .slide = 0 }, + .entering => blk: { + const t = @as(f32, @floatFromInt(@min(life.frame, fall_frames))) / @as(f32, @floatFromInt(fall_frames)); + const eased = t * t; + break :blk .{ .alpha = eased, .slide = eased - 1 }; + }, + .leaving => blk: { + const t = @as(f32, @floatFromInt(@min(life.frame, dissolve_frames))) / @as(f32, @floatFromInt(dissolve_frames)); + break :blk .{ .alpha = (1 - t) * (1 - t), .slide = 0 }; + }, + }; + } + + /// The life of the message line notice `i` shows, if it shows one. + fn noticeLife(pane: *const Pane, i: usize) ?Pane.MessageLife { + return switch (pane.notices.kinds[i]) { + .message => pane.msg_life, + .older => pane.msg_older[pane.notices.index[i]].life, + .leader, .prompt => null, + }; + } + + fn blendRgb(from: [3]u8, to: [3]u8, amount: f32) [3]u8 { + var out: [3]u8 = undefined; + for (&out, from, to) |*o, a, b| { + const af: f32 = @floatFromInt(a); + const bf: f32 = @floatFromInt(b); + o.* = @intFromFloat(@round(bf + (af - bf) * std.math.clamp(amount, 0, 1))); + } + return out; } fn logMessage(p: *Pardes, id: usize, text: []const u8) void { @@ -7358,8 +7676,11 @@ pub const Pardes = struct { _ = p.frame_arena.reset(.retain_capacity); const surface = try p.render(p.frame_arena.allocator()); if (v.present) |f| f(h.ctx, surface); + // Settled before post_present: a shell ticks there, and what that + // tick moves owes the next frame. + p.needs_frame = p.present_skipped; + p.present_skipped = false; if (v.post_present) |f| f(h.ctx); - p.needs_frame = false; } /// One request of the control filesystem, from whichever thread has the @@ -7389,6 +7710,10 @@ pub const Pardes = struct { // the screen. p.needs_frame = p.needs_frame or ev != .tick; p.shell_rows.sweep(p.gpa); + // An announcement stands in only until its own step says more. + for (p.panes) |slot| if (slot) |pane| { + pane.msg_announcement = false; + }; switch (ev) { .tick => {}, .mouse => |m| if (!(m.button == .none and m.kind == .motion)) { @@ -7415,10 +7740,11 @@ pub const Pardes = struct { switch (ev) { .key, .mouse => { for (p.panes) |slot| { - if (slot) |pane| pane.msg_len = 0; + if (slot) |pane| p.dismissMessage(pane); } p.clip_pending = null; }, + .tick => p.advanceMessages(), else => {}, } if (p.fs.listeners != 0) p.fs.origin = switch (ev) { @@ -11462,7 +11788,7 @@ pub const Pardes = struct { // A notice chip is chrome: it sits OVER the body's top rows, so a // click inside one belongs to nobody. The rest of those rows is // ordinary body text and still answers normally. - if (!on_tag and row >= body_y and row - body_y < p.panes[id].?.notices.len and + if (!on_tag and row >= body_y and row - body_y < p.panes[id].?.notices.span() and p.panes[id].?.notices.covers(row - body_y, col)) return null; if (!on_tag) if (body_hit) |supplied| { const mapped_hit = p.bodyHitForPane(id, supplied, false) orelse return null; @@ -12252,6 +12578,21 @@ pub const Pardes = struct { } } else { const clk = pane.sel[b]; + // A right-click on a line NUMBER looks at that line of + // this file -- a sticky context header's number included, + // since the row map holds each header's own source line. + if (s.button == config.look_button and clk.r0 >= BOX_H and clk.r0 == clk.r1 and + clk.c0 == clk.c1 and clk.c0 >= 0 and pane.mode != .tty) + if (pane.file) |f| if (f.output == null and clk.c0 < panes.File.gutterWidth(pane)) { + const line = pane.wrapAt(clk.r0 - BOX_H).line; + if (line >= 0) { + pane.sel[b].state = .none; + var buf: [48]u8 = undefined; + const target = std.fmt.bufPrint(&buf, "@p{d}:{d}", .{ s.id, @as(usize, @intCast(line)) + 1 }) catch return; + p.runBuiltin(config.look_cmd, s.id, "", target); + return; + } + }; var operand = p.pointerOperand(pane, clk); if (operand.expanded) |expanded| pane.sel[b] = expanded @@ -12876,8 +13217,10 @@ pub const Pardes = struct { // A builtin says its own name before it runs, so a tagline click is // legible even when what it did is invisible. Whatever the builtin // then says for itself replaces the announcement. - if (p.announce and p.settings.verbose and builtins.registry.announces(b)) + if (p.announce and p.settings.verbose and builtins.registry.announces(b)) { p.setMessage(id, @tagName(b)); + pane.msg_announcement = true; + } const c: builtins.Ctx = .{ .p = p, .pane = pane, .id = id, .txt = txt, .arg = arg }; builtins.registry.dispatch(b, c); } @@ -13121,10 +13464,16 @@ pub const Pardes = struct { const pane: *Pane = switch (src.kind) { .terminal => terminal: { const t = src.terminal.?; - const restored = try panes.Terminal.restore(p, src); + // A host that runs shells gets them back: the old history + // above a new shell in the directory it was in. The web + // shell and an isolated build only ever replay it. + const live = comptime (terminal_panes and platform != .web and !isolated); + const revive = live and t.cwd.len <= effect_path_cap; + const restored = try panes.Terminal.restore(p, src, revive); p.installPane(i, restored); try restored.setOwnedCwd(t.cwd); if (std.mem.startsWith(u8, src.tag, "TTY ")) restored.mode = .tty; + if (revive) p.emit(.{ .spawn = .{ .pane = @intCast(i), .cwd = .from(t.cwd) } }); break :terminal restored; }, .file => try panes.File.restore(p, i, src), @@ -13487,6 +13836,9 @@ pub const Pardes = struct { /// core work belongs in this one predicate so TTY and GUI mature it alike. pub fn animationActive(p: *const Pardes) bool { if (p.chrome_animation.isActive() or p.look_hover_wait != null) return true; + for (p.panes) |slot| if (slot) |pane| { + if (messagesAnimating(pane)) return true; + }; const scene = p.settings.scene_effects; if (scene.crt or scene.ripple or scene.glitch) return true; return p.presentation.animating(); @@ -13653,7 +14005,7 @@ pub const Pardes = struct { const first = p.bodyTop(r); var leader_buf: [16]u8 = undefined; for (pane.notices.slice(), 0..) |kind, i| { - const row = first + @as(u16, @intCast(i)); + const row = first + @as(u16, pane.notices.row[i]); // Every notice is painted on the canonical grid as well as // emitted as a tag layer: the grid is what a terminal client // draws, and a band it cannot see is a message it never gets. @@ -13661,6 +14013,7 @@ pub const Pardes = struct { // drawn twice there. const text = switch (kind) { .message => pane.msg[0..pane.msg_len], + .older => pane.msg_older[pane.notices.index[i]].slice(), .leader => p.leaderText(&leader_buf), .prompt => blk: { const at = pane.promptAt() orelse continue; @@ -13671,13 +14024,24 @@ pub const Pardes = struct { if (chip == 0) continue; const cx = tx + tw - chip; pane.notices.left[i] = cx; - s.fill(cx, row, chip, 1, .{ .bg = msg_style.bg, .font_role = .tagline }); + // A message coming or going blends toward the page it sits + // on; a grid cannot move it by less than a row. + var style = msg_style; + if (noticeLife(pane, i)) |life| { + // No page colour to fade to (a terminal's own default): + // the text dissolves into its chip instead. + const alpha = p.messageMotion(life).alpha; + const page = th.bg orelse chrome.tag_bg; + style.fg = .{ .rgb = blendRgb(chrome.tag_fg, page, alpha) }; + style.bg = .{ .rgb = blendRgb(chrome.tag_bg, page, alpha) }; + } + s.fill(cx, row, chip, 1, .{ .bg = style.bg, .font_role = .tagline }); // One column short of the chip's right edge: a prompt's caret // sits AFTER its last character the moment it opens, and flush // right would put it past the pane, off the grid, and past what // the detached wire will encode -- which drops every frame for // as long as the prompt is up. - const printed = printRight(s, cx, row, chip -| 1, text, msg_style); + const printed = printRight(s, cx, row, chip -| 1, text, style); if (kind != .prompt or id != p.active) continue; const at = pane.promptAt() orelse continue; const prompt0 = (p.tagPrefix(pane) catch continue).len + at; @@ -14166,6 +14530,7 @@ pub const Pardes = struct { for (pane.notices.slice(), 0..) |kind, i| { const text = switch (kind) { .message => pane.msg[0..pane.msg_len], + .older => pane.msg_older[pane.notices.index[i]].slice(), .leader => p.leaderText(&leader_buf), // A prompt is an editing line with a cursor in it, so it // stays on the grid where the cursor can sit on a cell. @@ -14190,12 +14555,19 @@ pub const Pardes = struct { const line = try arena.alloc(u8, pad + kept.len); @memset(line[0..pad], ' '); @memcpy(line[pad..], kept); - try p.renderHeaderLayer(arena, NOTICE_LAYER_BASE + id * Pane.Notices.max + i, .notice, @intCast(id), .{ + // A pixel shell slides the message in whole and only fades + // it on the way out. + const motion: MessageMotion = if (noticeLife(pane, i)) |life| p.messageMotion(life) else .{}; + const fade = if (motion.slide == 0) motion.alpha else 1; + const page = p.theme().bg orelse chrome.tag_bg; + const layer_index = NOTICE_LAYER_BASE + id * Pane.Notices.max + i; + try p.renderHeaderLayer(arena, layer_index, .notice, @intCast(id), .{ .x = cx, - .y = first + @as(u16, @intCast(i)), + .y = first + @as(u16, pane.notices.row[i]), .w = chip, .h = BOX_H, - }, line, chrome.tag_bg, chrome.tag_fg); + }, line, blendRgb(chrome.tag_bg, page, fade), blendRgb(chrome.tag_fg, page, fade)); + p.surface.tag_layers[layer_index].slide = motion.slide; } } if (p.columnBarHeight() > 0) for (0..p.ncol) |column| { @@ -14221,6 +14593,7 @@ pub const Pardes = struct { layer.cols = columns; layer.bg = bg; layer.cursor = null; + layer.slide = 0; var surface: Surface = .{ .cols = columns, .rows = 1, .cells = layer.cells }; // A notice band carries a PANE id, not a column index, so it must not // answer to the column being edited -- that would scroll and select @@ -14270,7 +14643,10 @@ pub const Pardes = struct { fn collectNotices(p: *Pardes, pane: *Pane, r: Rect, id: usize) void { pane.notices.len = 0; if (r.w <= config.GUTTER or r.h <= BOX_H) return; - if (pane.msg_len > 0) pane.notices.push(.message); + // Oldest message line on top, so lines already up do not move when a + // new one lands under them; when rows run out the oldest go first. + for (pane.msg_older[0..pane.msg_older_len], 0..) |line, i| pane.notices.pushAt(.older, @intCast(i), line.slot); + if (pane.msg_len > 0) pane.notices.pushAt(.message, 0, pane.msg_slot); if (id == p.active and p.leader_on) pane.notices.push(.leader); if (pane.promptAt()) |at| { if (pane.tagSlice()[@min(at, pane.tag_tail_len)..].len > 0) pane.notices.push(.prompt); @@ -14281,11 +14657,26 @@ pub const Pardes = struct { // into blind. A two-row pane spends its only body row on one notice, // which is what the single shared row used to do anyway. const room: u8 = @intCast(@min(@as(u16, Pane.Notices.max), r.h - BOX_H)); - if (pane.notices.len > room) { - const drop = pane.notices.len - room; - for (0..room) |i| pane.notices.kinds[i] = pane.notices.kinds[i + drop]; - pane.notices.len = room; + const n = &pane.notices; + if (n.span() <= room) return; + // Too short for the gaps: close them up in screen order, and if even + // that does not fit, the top bands go. + var i: usize = 1; + while (i < n.len) : (i += 1) { + var j = i; + while (j > 0 and n.row[j - 1] > n.row[j]) : (j -= 1) { + std.mem.swap(Pane.Notices.Kind, &n.kinds[j - 1], &n.kinds[j]); + std.mem.swap(u8, &n.index[j - 1], &n.index[j]); + std.mem.swap(u8, &n.row[j - 1], &n.row[j]); + } + } + const drop = n.len -| room; + for (0..n.len - drop) |k| { + n.kinds[k] = n.kinds[k + drop]; + n.index[k] = n.index[k + drop]; + n.row[k] = @intCast(k); } + n.len -= @intCast(drop); } fn renderBodyLayer(p: *Pardes, arena: std.mem.Allocator, pane: *Pane, r: Rect, id: usize) !void { @@ -14390,7 +14781,7 @@ pub const Pardes = struct { // Below the notice chips: a picture is drawn after the cells (the // GUI's image pass, kitty's z-order), so a chip over it would be // painted out. Text gets the overlay; a picture gives up the rows. - const shown = pane.notices.len; + const shown = pane.notices.span(); const image_h = (r.h -| BOX_H) -| shown; panes.Image.draw(p, iv, @intCast(id), pane.serial, tx, body_y + shown, tw, image_h); // thumbless, but the same one column as the real scrollbar below — diff --git a/src/pdf.zig b/src/pdf.zig index 712750dc..de5e6d86 100644 --- a/src/pdf.zig +++ b/src/pdf.zig @@ -1017,6 +1017,73 @@ pub const Document = struct { ) != c.PARDES_PDF_OK) return error.RenderFailed; } + /// Only the highlight pass of `renderIntoAtWithPaper`, over `rgba`, which + /// holds `band` of this page as that render left it before highlighting + /// (opaque paper). Rendering with highlights equals rendering without and + /// then this, row for row: the render draws highlights over the finished + /// page, and so does this. + pub fn paintHighlightsAt( + document: *Document, + page: usize, + request: RenderRequest, + raster: Raster, + band: Raster.Band, + highlights: []const Highlight, + rgba: []u8, + ) !void { + if (rgba.len != band.len) return error.BadPixmap; + if (band.height == 0 or band.y + band.height > raster.height) + return error.BadPixmap; + const bounded = try boundedRequest(document, page, request); + if (highlights.len > c.PARDES_PDF_MAX_RESULT_QUADS) return error.RenderFailed; + if (c.pardes_pdf_paint_highlights( + document.handle, + @intCast(page), + bounded.dpi, + bounded.minimum_width, + bounded.minimum_height, + bounded.max_dimension, + if (highlights.len == 0) null else @ptrCast(highlights.ptr), + highlights.len, + rgba.ptr, + rgba.len, + @intCast(raster.width), + @intCast(raster.height), + @intCast(raster.stride), + @intCast(band.y), + @intCast(band.height), + ) != c.PARDES_PDF_OK) return error.RenderFailed; + } + + pub const Rows = struct { start: usize, end: usize }; + + /// The rows of `request`'s raster that painting `highlights` can touch, + /// by the transform the render itself uses (rotation included). Empty + /// when nothing would paint. + pub fn highlightRows( + document: *Document, + page: usize, + request: RenderRequest, + highlights: []const Highlight, + ) !Rows { + const bounded = try boundedRequest(document, page, request); + var row_start: c_int = 0; + var row_end: c_int = 0; + if (c.pardes_pdf_highlight_rows( + document.handle, + @intCast(page), + bounded.dpi, + bounded.minimum_width, + bounded.minimum_height, + bounded.max_dimension, + if (highlights.len == 0) null else @ptrCast(highlights.ptr), + highlights.len, + &row_start, + &row_end, + ) != c.PARDES_PDF_OK) return error.RenderFailed; + return .{ .start = @intCast(row_start), .end = @intCast(row_end) }; + } + const BoundedRequest = struct { dpi: c_int, minimum_width: c_int, diff --git a/src/pdf_bridge.c b/src/pdf_bridge.c index 976ed838..2c723dbb 100644 --- a/src/pdf_bridge.c +++ b/src/pdf_bridge.c @@ -572,6 +572,55 @@ pardes_pdf_measure_render( return PARDES_PDF_OK; } +/* The highlight pass of a render: fills over whatever the pixmap holds. */ +static void +pardes_pdf_fill_highlights(fz_context *ctx, pardes_pdf_document *document, + fz_device *device, const pardes_pdf_highlight *highlights, size_t highlight_count) +{ + fz_path *path = NULL; + size_t i; + + fz_var(path); + fz_try(ctx) + { + for (i = 0; i < highlight_count; ++i) { + fz_quad quad; + float color[3]; + float alpha; + + if (!pardes_pdf_valid_quad(highlights[i].quad)) + fz_throw(ctx, FZ_ERROR_ARGUMENT, + "PDF highlight contains a non-finite point"); + if (highlights[i].rgba[3] == 0) + continue; + + /* Kind is semantic metadata; caller-supplied RGBA is final. */ + (void)highlights[i].kind; + quad = pardes_pdf_quad_to_page(document, highlights[i].quad); + color[0] = highlights[i].rgba[0] / 255.0f; + color[1] = highlights[i].rgba[1] / 255.0f; + color[2] = highlights[i].rgba[2] / 255.0f; + alpha = highlights[i].rgba[3] / 255.0f; + + path = fz_new_path(ctx); + fz_moveto(ctx, path, quad.ul.x, quad.ul.y); + fz_lineto(ctx, path, quad.ur.x, quad.ur.y); + fz_lineto(ctx, path, quad.lr.x, quad.lr.y); + fz_lineto(ctx, path, quad.ll.x, quad.ll.y); + fz_closepath(ctx, path); + fz_fill_path(ctx, device, path, 0, fz_identity, + fz_device_rgb(ctx), color, alpha, + fz_default_color_params); + fz_drop_path(ctx, path); + path = NULL; + } + } + fz_always(ctx) + fz_drop_path(ctx, path); + fz_catch(ctx) + fz_rethrow(ctx); +} + int pardes_pdf_render_into( pardes_pdf_document *document, @@ -594,10 +643,8 @@ pardes_pdf_render_into( fz_context *ctx; fz_pixmap *pixmap = NULL; fz_device *device = NULL; - fz_path *path = NULL; fz_matrix ctm; fz_irect bbox; - size_t i; if (document == NULL || page_number < 0 || page_number >= document->page_count || dpi < 1 || @@ -614,7 +661,6 @@ pardes_pdf_render_into( ctx = document->ctx; fz_var(pixmap); fz_var(device); - fz_var(path); fz_try(ctx) { pardes_pdf_render_geometry(document, page_number, dpi, @@ -627,10 +673,12 @@ pardes_pdf_render_into( * The BAND: rows [band_y, band_y + band_height) of the page raster, * and nothing else. A pixmap's bbox IS the draw device's clip, so the * page runs under the same CTM it would for a full raster and MuPDF - * discards everything outside these rows. Every row inside them is - * therefore bit-identical to the same row of the full-page raster — - * "band rows equal full-page rows" in pdf.zig proves it, because the - * whole point of a band is that the reader cannot tell. + * discards everything outside these rows. The rows are NOT always + * bit-identical to the full page's: rows at the band's edges, and a + * resampled image anywhere in it, can differ (measured on + * docs/registry.pdf and docs/design.pdf). Good enough for a band that + * is only shown while flinging; never use a band to patch rows into a + * whole-page raster -- `pardes_pdf_paint_highlights` exists for that. */ bbox.y0 += band_y; bbox.y1 = bbox.y0 + band_height; @@ -674,43 +722,12 @@ pardes_pdf_render_into( if (highlight_count != 0) { device = fz_new_draw_device(ctx, ctm, pixmap); - for (i = 0; i < highlight_count; ++i) { - fz_quad quad; - float color[3]; - float alpha; - - if (!pardes_pdf_valid_quad(highlights[i].quad)) - fz_throw(ctx, FZ_ERROR_ARGUMENT, - "PDF highlight contains a non-finite point"); - if (highlights[i].rgba[3] == 0) - continue; - - /* Kind is semantic metadata; caller-supplied RGBA is final. */ - (void)highlights[i].kind; - quad = pardes_pdf_quad_to_page(document, highlights[i].quad); - color[0] = highlights[i].rgba[0] / 255.0f; - color[1] = highlights[i].rgba[1] / 255.0f; - color[2] = highlights[i].rgba[2] / 255.0f; - alpha = highlights[i].rgba[3] / 255.0f; - - path = fz_new_path(ctx); - fz_moveto(ctx, path, quad.ul.x, quad.ul.y); - fz_lineto(ctx, path, quad.ur.x, quad.ur.y); - fz_lineto(ctx, path, quad.lr.x, quad.lr.y); - fz_lineto(ctx, path, quad.ll.x, quad.ll.y); - fz_closepath(ctx, path); - fz_fill_path(ctx, device, path, 0, fz_identity, - fz_device_rgb(ctx), color, alpha, - fz_default_color_params); - fz_drop_path(ctx, path); - path = NULL; - } + pardes_pdf_fill_highlights(ctx, document, device, highlights, highlight_count); fz_close_device(ctx, device); } } fz_always(ctx) { - fz_drop_path(ctx, path); fz_drop_device(ctx, device); /* Drops only the wrapper: caller-owned samples remain untouched. */ fz_drop_pixmap(ctx, pixmap); @@ -742,6 +759,139 @@ pardes_pdf_render_into( return PARDES_PDF_OK; } +int +pardes_pdf_paint_highlights( + pardes_pdf_document *document, + int page_number, + int dpi, + int minimum_width, + int minimum_height, + int max_dimension, + const pardes_pdf_highlight *highlights, + size_t highlight_count, + unsigned char *samples, + size_t samples_len, + int width, + int height, + int stride, + int band_y, + int band_height) +{ + fz_context *ctx; + fz_pixmap *pixmap = NULL; + fz_device *device = NULL; + fz_matrix ctm; + fz_irect bbox; + + if (document == NULL || page_number < 0 || + page_number >= document->page_count || dpi < 1 || + minimum_width < 0 || minimum_height < 0 || max_dimension < 1 || + (highlight_count != 0 && highlights == NULL) || + highlight_count > PARDES_PDF_MAX_RESULT_QUADS || samples == NULL || + width < 1 || height < 1 || width > INT_MAX / 4 || stride != width * 4 || + band_y < 0 || band_height < 1 || band_y > height - band_height || + (size_t)band_height > SIZE_MAX / (size_t)stride || + samples_len != (size_t)stride * (size_t)band_height) + return PARDES_PDF_ERROR; + if (highlight_count == 0) + return PARDES_PDF_OK; + + ctx = document->ctx; + fz_var(pixmap); + fz_var(device); + fz_try(ctx) + { + pardes_pdf_render_geometry(document, page_number, dpi, + minimum_width, minimum_height, max_dimension, &ctm, &bbox); + if (fz_irect_width(bbox) != width || fz_irect_height(bbox) != height) + fz_throw(ctx, FZ_ERROR_ARGUMENT, + "PDF raster layout changed between measure and paint"); + bbox.y0 += band_y; + bbox.y1 = bbox.y0 + band_height; + pixmap = fz_new_pixmap_with_bbox_and_data( + ctx, fz_device_rgb(ctx), bbox, NULL, 1, samples); + device = fz_new_draw_device(ctx, ctm, pixmap); + pardes_pdf_fill_highlights(ctx, document, device, highlights, highlight_count); + fz_close_device(ctx, device); + } + fz_always(ctx) + { + fz_drop_device(ctx, device); + fz_drop_pixmap(ctx, pixmap); + } + fz_catch(ctx) + { + fz_report_error(ctx); + return PARDES_PDF_ERROR; + } + return PARDES_PDF_OK; +} + +int +pardes_pdf_highlight_rows( + pardes_pdf_document *document, + int page_number, + int dpi, + int minimum_width, + int minimum_height, + int max_dimension, + const pardes_pdf_highlight *highlights, + size_t highlight_count, + int *row_start, + int *row_end) +{ + fz_context *ctx; + fz_matrix ctm; + fz_irect bbox; + float y0 = 0, y1 = 0; + int any = 0; + size_t i; + + if (row_start == NULL || row_end == NULL) + return PARDES_PDF_ERROR; + *row_start = *row_end = 0; + if (document == NULL || page_number < 0 || + page_number >= document->page_count || dpi < 1 || + minimum_width < 0 || minimum_height < 0 || max_dimension < 1 || + (highlight_count != 0 && highlights == NULL)) + return PARDES_PDF_ERROR; + + ctx = document->ctx; + fz_try(ctx) + { + pardes_pdf_render_geometry(document, page_number, dpi, + minimum_width, minimum_height, max_dimension, &ctm, &bbox); + for (i = 0; i < highlight_count; ++i) { + fz_rect r; + if (highlights[i].rgba[3] == 0 || + !pardes_pdf_valid_quad(highlights[i].quad)) + continue; + r = fz_rect_from_quad(fz_transform_quad( + pardes_pdf_quad_to_page(document, highlights[i].quad), ctm)); + if (!any || r.y0 < y0) y0 = r.y0; + if (!any || r.y1 > y1) y1 = r.y1; + any = 1; + } + } + fz_catch(ctx) + { + fz_report_error(ctx); + return PARDES_PDF_ERROR; + } + if (any) { + /* + * Antialiasing covers the pixel a fractional edge falls in, and the + * rasterizer paints row floor(y1) even for a zero-height quad. + */ + int lo = (int)floorf(y0) - bbox.y0; + int hi = (int)floorf(y1) + 1 - bbox.y0; + int h = fz_irect_height(bbox); + *row_start = lo < 0 ? 0 : (lo > h ? h : lo); + *row_end = hi < *row_start ? *row_start : (hi > h ? h : hi); + } + return PARDES_PDF_OK; +} + int pardes_pdf_page_text( pardes_pdf_document *document, diff --git a/src/pdf_bridge.h b/src/pdf_bridge.h index cda426aa..e3514437 100644 --- a/src/pdf_bridge.h +++ b/src/pdf_bridge.h @@ -222,8 +222,9 @@ int pardes_pdf_measure_render( * MuPDF wraps but never owns or frees samples. Every successful pixel is * opaque unless transparent_paper is nonzero. That mode preserves content * coverage and returns straight-alpha RGBA over an unpainted page. - * The CTM does not depend on the band, so a band's rows are bit-identical to - * the same rows of the whole page: it is a clip, not a different rendering. + * The CTM does not depend on the band, so a band is a clip of the same + * rendering -- but not a bit-exact one: its edge rows and resampled images can + * differ from the whole page's (see pardes_pdf_render_into). */ int pardes_pdf_render_into( pardes_pdf_document *document, @@ -244,6 +245,47 @@ int pardes_pdf_render_into( int transparent_paper ); +/* + * The highlight pass of `pardes_pdf_render_into` alone, over caller-supplied + * rows of that page's opaque raster: render_into(h) == paint(render_into({}), h) + * row for row, because a render draws its highlights over the finished page. + */ +int pardes_pdf_paint_highlights( + pardes_pdf_document *document, + int page, + int dpi, + int minimum_width, + int minimum_height, + int max_dimension, + const pardes_pdf_highlight *highlights, + size_t highlight_count, + unsigned char *samples, + size_t samples_len, + int width, + int height, + int stride, + int band_y, + int band_height +); + +/* + * The raster rows [*row_start, *row_end) that painting `highlights` can touch + * under the same request, in the coordinates `pardes_pdf_render_into` bands + * use. An empty set (or only transparent ones) yields start == end == 0. + */ +int pardes_pdf_highlight_rows( + pardes_pdf_document *document, + int page, + int dpi, + int minimum_width, + int minimum_height, + int max_dimension, + const pardes_pdf_highlight *highlights, + size_t highlight_count, + int *row_start, + int *row_end +); + int pardes_pdf_page_text( pardes_pdf_document *document, int page, diff --git a/src/tag_layer.zig b/src/tag_layer.zig index 0fb2297d..f8cc6eca 100644 --- a/src/tag_layer.zig +++ b/src/tag_layer.zig @@ -26,6 +26,10 @@ pub const Layer = struct { bg: [3]u8 = .{ 0, 0, 0 }, cells: []pardes.Cell = &.{}, cursor: ?struct { col: u16, bar: bool = false } = null, + /// Vertical offset in rows (negative: above its viewport), for a band + /// that is moving into place. A pixel shell draws it offset and clipped + /// to the rows below the viewport's top; the grid has no such thing. + slide: f32 = 0, pub fn capacity(layer: *const Layer, metrics: pardes.RowMetrics) u16 { return @intCast(@min(std.math.maxInt(u16), @max(1, @as(u32, layer.viewport.w) * @max(1, metrics.body_w) / @max(1, metrics.tagline_w)))); diff --git a/src/tty/tty.zig b/src/tty/tty.zig index 03ccd3e2..5976852f 100644 --- a/src/tty/tty.zig +++ b/src/tty/tty.zig @@ -21,6 +21,56 @@ extern "c" fn setenv(name: [*:0]const u8, value: [*:0]const u8, overwrite: c_int const TIOCSWINSZ: c_int = @bitCast(@as(u32, if (@hasDecl(posix.T, "IOCSWINSZ")) posix.T.IOCSWINSZ else 0x80087467)); +/// The terminal answered the shared-memory probe (`kittyShmProbe`): it can +/// read a raster from a POSIX shm object, so a page costs a name on the wire +/// instead of its whole base64 body. Set by the input reader, which sees the +/// reply before vaxis' parser swallows every graphics APC alike. +var kitty_shm = std.atomic.Value(bool).init(false); +/// Only a reply that arrives while the probe is out counts. The id is one +/// vaxis' own image numbering (1, 2, ...) never reaches, because a terminal +/// answers every transmission `i=;OK` and one of those must not pass. +var kitty_shm_probing = std.atomic.Value(bool).init(false); +const kitty_shm_probe_id = 0x7fff_fff1; +var kitty_shm_serial: u32 = 0; + +fn kittyShmName(buf: []u8, n: u32) ![:0]const u8 { + return std.fmt.bufPrintSentinel(buf, "/pardes-{d}-{d}", .{ libc.getpid(), n }, 0); +} + +/// Write `bytes` to a fresh shm object; the terminal unlinks it after reading. +fn kittyShmWrite(name: [:0]const u8, bytes: []const u8) bool { + const fd = libc.shm_open(name, @bitCast(libc.O{ .ACCMODE = .RDWR, .CREAT = true, .EXCL = true }), @as(c_uint, 0o600)); + if (fd < 0) return false; + defer _ = libc.close(fd); + if (libc.ftruncate(fd, @intCast(bytes.len)) != 0) { + _ = libc.shm_unlink(name); + return false; + } + var off: usize = 0; + while (off < bytes.len) { + const n = libc.write(fd, bytes[off..].ptr, bytes.len - off); + if (n <= 0) { + _ = libc.shm_unlink(name); + return false; + } + off += @intCast(n); + } + return true; +} + +/// Ask with a 1x1 RGB image in shm whether the terminal reads that medium. A +/// remote terminal cannot see our shm and answers an error (or nothing). +fn kittyShmProbe(w: *std.Io.Writer) void { + var buf: [64]u8 = undefined; + const name = kittyShmName(&buf, 0) catch return; + if (!kittyShmWrite(name, &.{ 0, 0, 0 })) return; + var b64: [64]u8 = undefined; + const enc = std.base64.standard.Encoder.encode(&b64, name); + kitty_shm_probing.store(true, .release); + w.print("\x1b_Gi={d},s=1,v=1,a=q,t=s,f=24;{s}\x1b\\", .{ kitty_shm_probe_id, enc }) catch return; + w.flush() catch {}; +} + pub const Command = struct { pub var value: union(enum) { nop, @@ -81,6 +131,13 @@ fn readInput(loop: *Loop, tty: anytype, cache: *vaxis.GraphemeCache) !void { const received = try tty.read(buf[carried..]); if (received == 0) return; const end = carried + received; + if (kitty_shm_probing.load(.acquire)) if (std.mem.indexOf(u8, buf[0..end], std.fmt.comptimePrint("\x1b_Gi={d};", .{kitty_shm_probe_id}))) |at| { + kitty_shm_probing.store(false, .release); + kitty_shm.store(std.mem.startsWith(u8, buf[at..end], std.fmt.comptimePrint("\x1b_Gi={d};OK", .{kitty_shm_probe_id})), .release); + // Answered either way: a terminal that could not read it left it. + var name_buf: [64]u8 = undefined; + if (kittyShmName(&name_buf, 0)) |name| _ = libc.shm_unlink(name) else |_| {} + }; var parse_end = end; var lead = end; while (lead > 0 and buf[lead - 1] & 0xc0 == 0x80) lead -= 1; @@ -717,6 +774,7 @@ fn localSession( try startInput(loop, input_cache); defer if (attached.* == null) stopInput(loop); (try std.Thread.spawn(.{}, winchWatch, .{ loop, vx, tty })).detach(); + (try std.Thread.spawn(.{}, tickWatch, .{ io, loop })).detach(); if (fs) |f| try f.watch(loop, wakeFs); try vx.queryTerminalSend(tty.writer()); @@ -726,11 +784,20 @@ fn localSession( }; if (sh.inotify_fd >= 0) sh.watch_task = io.concurrent(watchFiles, .{ io, sh.inotify_fd, loop }) catch null; + // A terminal unlinks what it reads; whatever it never read (the probe + // unanswered, a transmission lost with the terminal) is ours to remove. + defer { + var name_buf: [64]u8 = undefined; + var n: u32 = 0; + while (n <= kitty_shm_serial) : (n += 1) { + if (kittyShmName(&name_buf, n)) |name| _ = libc.shm_unlink(name) else |_| {} + } + } frames: while (!core.quit) { pardes.turn.restoreSettled(); try core.pump(host); if (core.takeRestore()) |rp| blk: { - const bytes = filesystem.readRestore(gpa, rp) catch |err| { + const bytes = filesystem.readRestore(gpa, rp, core.settings.dump_dir.get()) catch |err| { core.reportError(core.active, "Restore", err); break :blk; }; @@ -872,29 +939,39 @@ const Shell = struct { fn waitInput(ctx: ?*anyopaque, timeout_ms: u32) void { const s = of(ctx); var batch: usize = 0; - // The wait is the 9P connections' turn with the core. - if (timeout_ms == 0) { - pardes.turn.rest(); - const first = s.loop.nextEvent() catch { - pardes.turn.wake(); - s.core.quit = true; - return s.reloadWatched(); - }; - pardes.turn.wake(); - batch = 1; - if (s.apply(first)) return s.reloadWatched(); - } else { - pardes.turn.rest(); - std.Io.sleep(s.io, .fromMilliseconds(timeout_ms), .awake) catch {}; + // The wait is the 9P connections' turn with the core. Animating, the + // frame's tick arrives through the same queue (`tickWatch`). + if (timeout_ms != 0) tick_request.set(s.io); + pardes.turn.rest(); + const first = s.loop.nextEvent() catch { pardes.turn.wake(); - _ = s.apply(.tick); - batch = 1; - } - while (s.in_paste or batch < 64) { - const ev = (s.loop.tryEvent() catch null) orelse break; + s.core.quit = true; + return s.reloadWatched(); + }; + pardes.turn.wake(); + batch = 1; + // A run of queued motions is one move to its last cell: each would + // otherwise redo hover and selection work the next one undoes. + var motion: ?@TypeOf(Command.value) = null; + var ev = first; + while (true) { + if (ev == .mouse and (ev.mouse.type == .motion or ev.mouse.type == .drag)) { + if (motion) |m| if (m.mouse.button != ev.mouse.button or m.mouse.type != ev.mouse.type or + @as(u3, @bitCast(m.mouse.mods)) != @as(u3, @bitCast(ev.mouse.mods))) + { + _ = s.apply(m); + }; + motion = ev; + } else { + if (motion) |m| _ = s.apply(m); + motion = null; + if (s.apply(ev)) break; + } + if (!s.in_paste and batch >= 64) break; + ev = (s.loop.tryEvent() catch null) orelse break; batch += 1; - if (s.apply(ev)) break; } + if (motion) |m| _ = s.apply(m); s.reloadWatched(); } @@ -1001,6 +1078,7 @@ const Shell = struct { fn pollFrame(ctx: ?*anyopaque) void { const s = of(ctx); + s.core.native_image_patches = kitty_shm.load(.acquire); if (s.fs) |f| if (f.tick().pending) { _ = s.loop.tryPostEvent(.fs_ready) catch {}; }; @@ -1013,6 +1091,7 @@ const Shell = struct { s.caps_pending = false; s.vx.enableDetectedFeatures(s.tty.writer()) catch {}; s.core.native_images = s.vx.caps.kitty_graphics; + if (s.vx.caps.kitty_graphics) kittyShmProbe(s.tty.writer()); s.vx.queueRefresh(); } } @@ -1039,6 +1118,16 @@ const Shell = struct { if (!kittyImageRepresentable(place)) continue; } const key = place.cacheKey(); + if (!s.kitty.contains(key) and vx.caps.kitty_graphics and kitty_shm.load(.acquire)) shm: { + var buf: [64]u8 = undefined; + kitty_shm_serial +%= 1; + const name = kittyShmName(&buf, kitty_shm_serial) catch break :shm; + if (!kittyShmWrite(name, place.rgba)) break :shm; + if (vx.transmitLocalImagePath(s.gpa, s.tty.writer(), name, @intCast(place.iw), @intCast(place.ih), .shared_mem, .rgba) catch null) |handle| + s.kitty.put(key, handle) catch vx.freeImage(s.tty.writer(), handle.id) + else + _ = libc.shm_unlink(name); + } if (!s.kitty.contains(key) and vx.caps.kitty_graphics) { const enc = std.base64.standard.Encoder; if (s.gpa.alloc(u8, enc.calcSize(place.rgba.len))) |b64| { @@ -1160,7 +1249,7 @@ const Shell = struct { fn writeDump(ctx: ?*anyopaque, bytes: []const u8) void { const s = of(ctx); var pbuf: [1024:0]u8 = undefined; - const path = pardes.dump.outPath(&pbuf) orelse return; + const path = pardes.dump.outPath(&pbuf, s.core.settings.dump_dir.get()) orelse return; filesystem.write(s.core, path, bytes) catch |err| return s.core.reportError(0, "dump", err); s.core.setLastDump(path); } @@ -1415,6 +1504,21 @@ fn winchWatch(loop: *Loop, vx: *vaxis.Vaxis, tty: *vaxis.Tty) void { } } +/// Set by an animating frame's wait: post one `.tick` a frame from now. The +/// tick joins the input queue, so a key or a click that lands inside the +/// frame is handled at once instead of after a blind sleep. +var tick_request: std.Io.Event = .unset; + +fn tickWatch(io: std.Io, loop: *Loop) void { + while (true) { + tick_request.waitUncancelable(io); + tick_request.reset(); + var ts: libc.timespec = .{ .sec = 0, .nsec = @as(isize, pardes.layout.Animation.frame_ms) * std.time.ns_per_ms }; + _ = libc.nanosleep(&ts, null); + loop.postEvent(.tick) catch {}; + } +} + fn wakeFs(ctx: ?*anyopaque) void { const loop: *Loop = @ptrCast(@alignCast(ctx.?)); _ = loop.tryPostEvent(.fs_ready) catch {}; diff --git a/test/output.zig b/test/output.zig index ad33954f..7c80e105 100644 --- a/test/output.zig +++ b/test/output.zig @@ -1089,7 +1089,8 @@ test "identical result refresh keeps warm content caches without allocation" { try std.testing.expectEqual(revision + 1, file.revision); try std.testing.expectEqualStrings("short\n", file.content); try std.testing.expectEqualStrings("changed", file.output.?.arg()); - try std.testing.expectEqual(@as(usize, 0), file.line_starts.len); + // The warm index is carried through the edit, not dropped. + try std.testing.expectEqualSlices(usize, &.{ 0, 6 }, file.line_starts); try std.testing.expectEqual(@as(usize, 0), file.highlights.len); try std.testing.expect(file.syntax_dirty); try std.testing.expect(!result.vsel.active and !result.select); diff --git a/test/panes.zig b/test/panes.zig index 8e71e69d..2d3aed43 100644 --- a/test/panes.zig +++ b/test/panes.zig @@ -394,6 +394,42 @@ const BodyHitTests = struct { } }; +const LineNumberLookTests = struct { + test "right-click on a line number looks at that line, sticky context headers included" { + if (!syntax.enabled) return error.SkipZigTest; + const p = try Pardes.init(std.testing.allocator, .{ .tty_only = true, .cols = 64, .rows = 18 }); + defer p.deinit(); + p.row_metrics = .{ .body_w = 10, .body_h = 20, .tagline_w = 8, .tagline_h = 10 }; + const pane = try TreeContextTests.setZigFile(p, "const Box = struct {\n pub fn work(\n value: usize,\n ) void {\n" ++ " // body\n" ** 60 ++ " }\n};\n"); + try std.testing.expect(p.executeBuiltinLine(0, "TreeContext")); + pane.scrollBy(30); + var frame = std.heap.ArenaAllocator.init(p.gpa); + defer frame.deinit(); + _ = try p.render(frame.allocator()); + const layer = &p.surface.body_layers[0]; + try std.testing.expect(layer.context_rows >= 2); + // A header row's number is its declaration's own source line, not the + // body line it sits over (`pub fn work(` is line 1); a body row's is + // its own. + try std.testing.expectEqual(@as(i32, 1), pane.wrapAt(1).line); + const rows = [_]u16{ 1, pane.context_rows + 3 }; + for (rows) |row| { + // Each Look recentres the view; come back under the headers. + pane.scrollBy(30 - pane.scroll()); + _ = frame.reset(.retain_capacity); + _ = try p.render(frame.allocator()); + const expected = pane.wrapAt(row).line; + var press = BodyHitTests.mouse(&p.surface.body_layers[0], row, 1, .press); + press.button = .right; + var release = BodyHitTests.mouse(&p.surface.body_layers[0], row, 1, .release); + release.button = .right; + p.update(.{ .mouse = press }); + p.update(.{ .mouse = release }); + try std.testing.expectEqual(expected, pane.cur_row); + } + } +}; + const TreeContextTests = struct { const source = "const Box = struct {\n" ++ " pub fn work(\n" ++ @@ -4069,6 +4105,7 @@ test { _ = TagNameTintTests; _ = TreeContextTests; _ = BodyHitTests; + _ = LineNumberLookTests; _ = TtySelectionTests; _ = ClickCursorTests; _ = JumpSelectionTests; diff --git a/test/pdf_pointer_bench.zig b/test/pdf_pointer_bench.zig new file mode 100644 index 00000000..f1d61229 --- /dev/null +++ b/test/pdf_pointer_bench.zig @@ -0,0 +1,224 @@ +//! Pointer gestures over a native PDF pane: hovering words (the Look preview +//! highlight), and dragging a selection to its release. +//! +//! zig build pdf-pointer-bench -Doptimize=ReleaseFast -- [--label L] [--reps N] [--path FILE] +//! [--cell WxH] [--scroll NOTCHES] [--verify 1] [--live 1] +//! +//! Every frame is timed the way a shell pump spends it: the event through +//! `Pardes.update`, one `render()` into a reset arena, the effect drain. A +//! hover step is its motion frame plus every tick frame the preview animates +//! before settling, which is when the highlight lands. Stdout is CSV, +//! `label,scenario:kind,round,ns`, one row per frame and one per step +//! (`kind=step`), for an external statistics pass. +//! +//! `visual` hashes every presented raster in full, with its placement, on the +//! frame each step settles on. It is the no-regression proof: a change to how highlights +//! are painted may change what it costs, never one presented pixel. +const std = @import("std"); +const pardes = @import("pardes"); +const pdf = @import("mupdf"); + +pub const std_options: std.Options = .{ .log_level = .err }; + +const gpa = std.heap.smp_allocator; +const cols: u16 = 120; +const rows: u16 = 40; + +const Config = struct { + path: []const u8 = "docs/design.pdf", + label: []const u8 = "run", + reps: usize = 5, + /// Wheel notches before the gestures, off the sparse title page. + scroll: usize = 40, + /// 8x16 is the Kitty policy's cell; the SDL shell's is closer to 16x35. + cell_w: u16 = 8, + cell_h: u16 = 16, + /// Re-render every raster that claims to hold the current highlights and + /// compare it row by row: exactness without a baseline build. + verify: bool = false, + /// A shell that takes row patches: selections repaint while dragged. + live: bool = false, +}; + +pub fn main(init: std.process.Init) !void { + const args = try init.minimal.args.toSlice(init.arena.allocator()); + var config: Config = .{}; + var i: usize = 1; + while (i + 1 < args.len) : (i += 2) { + const value = args[i + 1]; + if (std.mem.eql(u8, args[i], "--path")) config.path = value else if (std.mem.eql(u8, args[i], "--label")) config.label = value else if (std.mem.eql(u8, args[i], "--reps")) config.reps = try std.fmt.parseUnsigned(usize, value, 10) else if (std.mem.eql(u8, args[i], "--scroll")) config.scroll = try std.fmt.parseUnsigned(usize, value, 10) else if (std.mem.eql(u8, args[i], "--verify")) config.verify = std.mem.eql(u8, value, "1") else if (std.mem.eql(u8, args[i], "--live")) config.live = std.mem.eql(u8, value, "1") else if (std.mem.eql(u8, args[i], "--cell")) { + var it = std.mem.splitScalar(u8, value, 'x'); + config.cell_w = try std.fmt.parseUnsigned(u16, it.next() orelse "", 10); + config.cell_h = try std.fmt.parseUnsigned(u16, it.next() orelse "", 10); + } else return error.UnknownOption; + } + if (i != args.len) return error.MissingValue; + + var visual: ?u64 = null; + for (0..config.reps) |round| { + const got = try measure(config, round); + if (visual) |want| if (want != got) { + std.debug.print("pdf-pointer-bench: visual changed between rounds: {x} vs {x}\n", .{ want, got }); + return error.Unstable; + }; + visual = got; + } + std.debug.print("pdf-pointer-bench {s}: visual={x:0>16}\n", .{ config.label, visual.? }); +} + +const Run = struct { + core: *pardes.Pardes, + arena: std.heap.ArenaAllocator, + config: Config, + round: usize, + visual: u64 = 0x7061_7264_6573_5050, + step_ns: u64 = 0, + frames: usize = 0, + steps: usize = 0, + last: ?*const pardes.Surface = null, + + fn frame(run: *Run, scenario: []const u8, kind: []const u8, event: pardes.Event) !void { + const started = nowNs(); + run.core.update(event); + while (run.core.nextEffect()) |_| {} + _ = run.arena.reset(.retain_capacity); + const surface = try run.core.render(run.arena.allocator()); + while (run.core.nextEffect()) |_| {} + const elapsed = nowNs() - started; + run.step_ns += elapsed; + run.frames += 1; + print("{s},{s}:{s},{d},{d}\n", .{ run.config.label, scenario, kind, run.round, elapsed }); + run.last = surface; + if (run.config.verify) try verify(run.core, run.arena.allocator()); + } + + /// The step, then the tick frames its animation asks for (a hover's + /// preview arrives on one of them), as a pump with nothing else queued. + fn step(run: *Run, scenario: []const u8, kind: []const u8, event: pardes.Event) !void { + run.step_ns = 0; + try run.frame(scenario, kind, event); + var ticks: usize = 0; + while (run.core.animationActive() and ticks < 32) : (ticks += 1) + try run.frame(scenario, "tick", .tick); + print("{s},{s}:step,{d},{d}\n", .{ run.config.label, scenario, run.round, run.step_ns }); + // Only the settled frame is the invariant: how many frames a preview + // takes to arrive is a setting (look_preview_delay_frames). + run.observe(run.last.?); + run.steps += 1; + } + + fn observe(run: *Run, surface: *const pardes.Surface) void { + for (surface.images[0..surface.nimages]) |maybe| { + const place = maybe orelse continue; + run.visual = mix(run.visual, [_]u64{ place.pane, place.x, place.y, place.w, place.h, place.native.page, place.iw, place.ih }); + if (place.native.geometry) |g| run.visual = mix(run.visual, [_]u64{ g.src.x, g.src.y, g.src.w, g.src.h, g.dst.x, g.dst.y, g.dst.w, g.dst.h }); + run.visual = std.hash.Wyhash.hash(run.visual, place.rgba); + } + } +}; + +var verify_failures: usize = 0; + +fn verify(core: *pardes.Pardes, arena: std.mem.Allocator) !void { + const Pdf = pardes.panes.Pdf; + const pane = core.panes[0] orelse return; + const state = &(pane.pdf orelse return); + const highlights = try Pdf.buildHighlights(state, arena, Pdf.highlightInput(core, 0, pane)); + for (state.rasters[0..state.rasters_len]) |*r| { + if (!r.valid or r.rgba.len == 0 or r.tint_key == null) continue; + const want = highlights.forPage(r.page); + if (comptime !@hasField(@TypeOf(r.*), "baked")) return else if (!std.mem.eql(u8, std.mem.sliceAsBytes(want), std.mem.sliceAsBytes(r.baked))) continue; + const shape = try state.document.measureRenderAt(r.page, r.request); + // The oracle is the WHOLE page: a band's own edge rows can differ. + const whole = try arena.alloc(u8, shape.len); + try state.document.renderIntoAtWithPaper(r.page, r.request, shape, shape.wholePage(), want, whole, false); + try pdf.tintRgba(whole, r.tint_key.?.mode, r.tint_key.?.colors); + const fresh = whole[r.band_y * shape.stride ..][0 .. r.band_h * shape.stride]; + var first: ?usize = null; + var last: usize = 0; + var count: usize = 0; + for (0..r.band_h) |y| { + const row = fresh[y * shape.stride ..][0..shape.stride]; + if (std.mem.eql(u8, row, r.rgba[y * shape.stride ..][0..shape.stride])) continue; + if (first == null) first = y; + last = y; + count += 1; + } + if (first) |f| { + verify_failures += 1; + if (verify_failures <= 20) std.debug.print("verify: page {d} rows {d}..{d} ({d} differ), highlights {d}, band {d}+{d}\n", .{ r.page, f + r.band_y, last + r.band_y, count, want.len, r.band_y, r.band_h }); + } + } +} + +fn measure(config: Config, round: usize) !u64 { + const core = try pardes.Pardes.init(gpa, .{ .file = config.path, .cols = cols, .rows = rows }); + defer core.deinit(); + core.native_images = true; + if (comptime @hasField(pardes.Pardes, "native_image_patches")) core.native_image_patches = config.live; + var run: Run = .{ .core = core, .arena = .init(gpa), .config = config, .round = round }; + defer run.arena.deinit(); + const cell: pardes.CellPixels = .{ .w = config.cell_w, .h = config.cell_h }; + core.update(.{ .resize = .{ .cols = cols, .rows = rows, .cell_pixels = cell } }); + _ = try core.render(run.arena.allocator()); + const pane = core.panes[0] orelse return error.NoPane; + if (pane.pdf == null) return error.NotPdf; + const rect = core.rects[0]; + const mid_col = rect.x + rect.w / 2; + const mid_row = rect.y + rect.h / 2; + for (0..config.scroll) |_| { + core.update(.{ .mouse = .{ .button = .wheel_down, .kind = .press, .col = mid_col, .row = mid_row } }); + _ = run.arena.reset(.retain_capacity); + _ = try core.render(run.arena.allocator()); + while (core.nextEffect()) |_| {} + } + + const top = rect.y + 4; + const bottom = rect.y + rect.h -| 3; + const left = rect.x + 4; + const right = rect.x + rect.w -| 4; + + // Hover: walk four rows of the body, a word-ish stride at a time. + var row: u16 = top; + while (row < bottom) : (row += (bottom - top) / 4) { + var col: u16 = left; + while (col < right) : (col += 3) + try run.step("hover", "motion", .{ .mouse = .{ .button = .none, .kind = .motion, .col = col, .row = row } }); + } + // Leave the page so the last preview is withdrawn like a real exit. + try run.step("hover", "leave", .pointer_leave); + + // Select: press, drag across three lines, release; five times down the page. + row = top; + while (row + 3 < bottom) : (row += (bottom - top) / 5) { + try run.step("select", "press", .{ .mouse = .{ .button = .left, .kind = .press, .col = left, .row = row } }); + var n: u16 = 1; + while (n <= 24) : (n += 1) { + const col = left + (right - left) * (n % 8) / 8; + try run.step("select", "drag", .{ .mouse = .{ .button = .left, .kind = .drag, .col = col, .row = row + n / 8 } }); + } + try run.step("select", "release", .{ .mouse = .{ .button = .left, .kind = .release, .col = right, .row = row + 3 } }); + } + return mix(run.visual, @as(u64, run.steps)); +} + +fn print(comptime format: []const u8, args: anytype) void { + var buf: [256]u8 = undefined; + const line = std.fmt.bufPrint(&buf, format, args) catch return; + _ = std.c.write(1, line.ptr, line.len); +} + +fn mix(seed: u64, value: anytype) u64 { + var copy = value; + return std.hash.Wyhash.hash(seed, std.mem.asBytes(©)); +} + +fn nowNs() u64 { + var ts: std.c.timespec = undefined; + _ = std.c.clock_gettime(.MONOTONIC, &ts); + return @as(u64, @intCast(ts.sec)) * 1_000_000_000 + @as(u64, @intCast(ts.nsec)); +} + +comptime { + _ = pdf.Document; +} diff --git a/test/snapshot.zig b/test/snapshot.zig index 7cc5eb91..bdabb56e 100644 --- a/test/snapshot.zig +++ b/test/snapshot.zig @@ -569,7 +569,9 @@ fn runScript(arena: std.mem.Allocator, exe_z: [:0]const u8, script_path: []const try mkdir(arena, config_home, false); const pardes_config = try std.fmt.allocPrint(arena, "{s}/pardes", .{config_home}); try mkdir(arena, pardes_config, false); - try eh.writeFile(try std.fmt.allocPrintSentinel(arena, "{s}/init", .{pardes_config}, 0), "Shell bash\n"); + // Messages leave the moment they are dismissed, as goldens have always + // recorded: a linger or a dissolve is time, and time cannot be a golden. + try eh.writeFile(try std.fmt.allocPrintSentinel(arena, "{s}/init", .{pardes_config}, 0), "Shell bash\nMessageAnimation off\nMessageLinger 0\n"); _ = setenv("TERM", "xterm-256color", 1); _ = setenv("LC_ALL", "C", 1); // a wall clock cannot live in a golden; everything that would print one diff --git a/test/snapshots/builtins.snap b/test/snapshots/builtins.snap index cd47209f..02547b91 100644 --- a/test/snapshots/builtins.snap +++ b/test/snapshots/builtins.snap @@ -19,6 +19,10 @@ wheel up 110 50 wheel up 110 50 wheel up 110 50 wheel up 110 50 +wheel up 110 50 +wheel up 110 50 +wheel up 110 50 +wheel up 110 50 wait 10000 Look enter, right-click wait 10000 Exec tab, middle-click wait 10000 Filter diff --git a/test/snapshots/dump.golden b/test/snapshots/dump.golden index 8f920136..e466dbf1 100644 --- a/test/snapshots/dump.golden +++ b/test/snapshots/dump.golden @@ -38,6 +38,7 @@ .cwd = "/tmp/pardes-snap/dump/cwd", .stream = "ls\nd.txt\n", .stream_b64 = + .stream_is_screen = true, .cursor = .{ .col = 2, .row = 2 }, }, .file = null, @@ -57,6 +58,7 @@ .cwd = "/tmp/pardes-snap/dump/cwd", .stream = "ls\nd.txt\n", .stream_b64 = + .stream_is_screen = true, .cursor = .{ .col = 2, .row = 2 }, }, .file = null, @@ -76,6 +78,7 @@ .cwd = "/tmp/pardes-snap/dump/cwd", .stream = "ls\nd.txt\n", .stream_b64 = + .stream_is_screen = true, .cursor = .{ .col = 2, .row = 2 }, }, .file = null, diff --git a/test/snapshots/load.golden b/test/snapshots/load.golden index 994ab83e..32024cec 100644 --- a/test/snapshots/load.golden +++ b/test/snapshots/load.golden @@ -2,10 +2,10 @@ |Newcol Joincol Find Grep Help Changelog Tutor Dump NextColor Debug Kill | New Tty Find Grep Joincol Delcol New Tty Find Grep Joincol Delcol | /tmp/pardes-snap/load/cwd Tty Save Mode Filter /tmp/pardes-snap/load/cwd Tty Save Mode Filter -| echo LOAD''MARK; seq 1 40; echo E''ND ls +| $ echo LOAD''MARK; seq 1 40; echo E''ND $ ls | LOADMARK d.txt -| 1 -| 2 +| 1 $ +| 2 ── restored history ── | 3 | 4 | 5 @@ -17,8 +17,10 @@ | 11 | 12 | /tmp/pardes-snap/load/cwd Tty Save Mode Filter -| ls +| $ ls | d.txt +| $ +| ── restored history ── == style loaded grid=100x31 |0: 0-70 #b2c3b8,#1d2824, 71-99 d,#1d2824, |1: 0-1 #ffffff,#887455, 2-2 d,#26362d, 3-34 #becfc4,#26362d, 35-49 d,#26362d, 50-51 #ffffff,#887455, 52-52 d,#1d2824, 53-84 #b2c3b8,#1d2824, 85-99 d,#1d2824, @@ -26,8 +28,8 @@ |3: 0-0 d,#608269, 1-1 d,#0d1410, 2-49 #e5eee5,#0d1410, 50-50 d,#608269, 51-51 d,#0d1410, 52-99 #e5eee5,#0d1410, |4: 0-0 d,#608269, 1-1 d,#0d1410, 2-49 #e5eee5,#0d1410, 50-50 d,#608269, 51-51 d,#0d1410, 52-99 #e5eee5,#0d1410, |5: 0-0 d,#608269, 1-1 d,#0d1410, 2-49 #e5eee5,#0d1410, 50-50 d,#608269, 51-51 d,#0d1410, 52-99 #e5eee5,#0d1410, -|6: 0-0 d,#608269, 1-1 d,#0d1410, 2-49 #e5eee5,#0d1410, 50-50 d,#608269, 51-51 d,#0d1410, 52-99 #e5eee5,#0d1410, -|7: 0-0 d,#152019, 1-1 d,#0d1410, 2-49 #e5eee5,#0d1410, 50-50 d,#608269, 51-51 d,#0d1410, 52-99 #e5eee5,#0d1410, +|6: 0-0 d,#608269, 1-1 d,#0d1410, 2-49 #e5eee5,#0d1410, 50-50 d,#608269, 51-51 d,#0d1410, 52-73 #e5eee5,#0d1410,f 74-99 #e5eee5,#0d1410, +|7: 0-0 d,#152019, 1-1 d,#0d1410, 2-49 #e5eee5,#0d1410, 50-50 d,#608269, 51-99 d,#0d1410, |8: 0-0 d,#152019, 1-1 d,#0d1410, 2-49 #e5eee5,#0d1410, 50-50 d,#608269, 51-51 d,#0d1410, 52-99 #e5eee5,#0d1410, |9: 0-0 d,#152019, 1-1 d,#0d1410, 2-49 #e5eee5,#0d1410, 50-50 d,#608269, 51-51 d,#0d1410, 52-99 #e5eee5,#0d1410, |10: 0-0 d,#152019, 1-1 d,#0d1410, 2-49 #e5eee5,#0d1410, 50-50 d,#608269, 51-51 d,#0d1410, 52-99 #e5eee5,#0d1410, @@ -41,8 +43,8 @@ |18: 0-0 d,#608269, 1-1 d,#0d1410, 2-49 #e5eee5,#0d1410, 50-50 d,#608269, 51-51 d,#0d1410, 52-99 #e5eee5,#0d1410, |19: 0-0 d,#608269, 1-1 d,#0d1410, 2-49 #e5eee5,#0d1410, 50-50 d,#608269, 51-51 d,#0d1410, 52-99 #e5eee5,#0d1410, |20: 0-0 d,#608269, 1-1 d,#0d1410, 2-49 #e5eee5,#0d1410, 50-50 d,#608269, 51-51 d,#0d1410, 52-99 #e5eee5,#0d1410, -|21: 0-0 d,#608269, 1-1 d,#0d1410, 2-49 #e5eee5,#0d1410, 50-50 d,#608269, 51-51 d,#0d1410, 52-99 #e5eee5,#0d1410, -|22: 0-0 d,#608269, 1-1 d,#0d1410, 2-49 #e5eee5,#0d1410, 50-50 d,#608269, 51-51 d,#0d1410, 52-99 #e5eee5,#0d1410, +|21: 0-0 d,#608269, 1-1 d,#0d1410, 2-23 #e5eee5,#0d1410,f 24-49 #e5eee5,#0d1410, 50-50 d,#608269, 51-51 d,#0d1410, 52-99 #e5eee5,#0d1410, +|22: 0-0 d,#608269, 1-49 d,#0d1410, 50-50 d,#608269, 51-51 d,#0d1410, 52-99 #e5eee5,#0d1410, |23: 0-0 d,#608269, 1-1 d,#0d1410, 2-49 #e5eee5,#0d1410, 50-50 d,#608269, 51-51 d,#0d1410, 52-99 #e5eee5,#0d1410, |24: 0-0 d,#608269, 1-1 d,#0d1410, 2-49 #e5eee5,#0d1410, 50-50 d,#608269, 51-51 d,#0d1410, 52-99 #e5eee5,#0d1410, |25: 0-0 d,#608269, 1-1 d,#0d1410, 2-49 #e5eee5,#0d1410, 50-50 d,#608269, 51-51 d,#0d1410, 52-99 #e5eee5,#0d1410, diff --git a/test/snapshots/restore.golden b/test/snapshots/restore.golden index 11d92288..01b52984 100644 --- a/test/snapshots/restore.golden +++ b/test/snapshots/restore.golden @@ -6,9 +6,7 @@ | $ echo KEEP''ME | KEEPME | $ -== snap restored grid=100x31 cursor=4,6 +== snap restored grid=100x31 cursor=4,8 |0: Newcol Joincol Find Grep Help Changelog Tutor Dump NextColor Debug Kill |2: /tmp/pardes-snap/restore/cwd Tty Save Mode Filter Collapse Del -|3: ls -|4: echo KEEP''ME -|6: +|7: ── restored history ── -- cgit v1.3 From f6738c7edfff2249e0b13f2a76962f45d02c86bb Mon Sep 17 00:00:00 2001 From: Gabriel Schneider Date: Wed, 23 Sep 2026 02:00:00 -0300 Subject: Center tagline bands, frame anchors evenly, fill to the window edge, and resize columns from their grip Every tag band (workspace, column, pane) is centred in its row, so text sits at one baseline offset. Anchors are inset from the column rule by that same margin, so they are square and the band frames them on the left, top and bottom; the pane mark moves to stay centred. When the window is not a whole number of cells, the bands, rules, spines and scroll thumbs at the right and bottom edges run on through the leftover pixels. A column grip dropped short of another column's place now moves the column's left edge, with a dashed rail preview, sharing setColumnPairWidth with the border drag. A release still on the grip changes nothing, and a pair too narrow for two MINW columns is left alone. PARDES_TEST_PAD adds leftover pixels to a test-mode window and capture. --- docs/config.md | 16 ++++--- features.txt | 2 +- src/gui/gui.zig | 88 ++++++++++++++++++++++++++------------ src/layout.zig | 17 ++++++++ src/macos.zig | 2 +- src/macos/Sources/PardesView.swift | 5 +-- src/pardes.zig | 60 +++++++++++++------------- src/web.zig | 2 +- test/column_drag.zig | 40 +++++++++++++++++ 9 files changed, 161 insertions(+), 71 deletions(-) (limited to 'src/pardes.zig') diff --git a/docs/config.md b/docs/config.md index 27818b5b..ab5e5617 100644 --- a/docs/config.md +++ b/docs/config.md @@ -398,16 +398,18 @@ band would overlap its pane body or a neighbour instead of leaving the body grid stable. `Config` reports the active percentage. The browser applies the same compiled percentage to its DOM glyphs but has no runtime setter. -Both native GUIs join the reduced-height global and pane tagline bands with -`gui_topbar_pane_border_px` physical pixels. Set it to zero for a direct join. +Both native GUIs separate the reduced-height global and pane tagline bands with +a `gui_topbar_pane_border_px` physical-pixel rule. Set it to zero to leave it out. `gui_topbar_pane_border_rgb` can pin an RGB color; its default `null` follows the theme's `border` role in SDL (falling back to `scroll_track` for older -themes), and `scroll_track` in the macOS shell. With `Tagbottom` enabled, a tagline -on the final grid row is bottom-aligned so the same unused half-band does not -show beneath it. The rule itself lives in the core +themes), and `scroll_track` in the macOS shell. Every band is centred in its +row, so the workspace, column and pane tag text share one baseline offset and +the anchors get the same margin above, below and to the left. With `Tagbottom` +enabled, a tagline on the final grid row is bottom-aligned so the unused +half-band does not show beneath it. The rule lives in the core (`pardes.taglineBandOffset`), and the macOS shell reaches it over the C ABI -rather than keeping its own copy — it had one, it only ever centred, and the -seam that leaves between the two bands is what this setting exists to close. +rather than keeping its own copy. When the window is not a whole number of cells, +bands and rules at the right and bottom edges run on through the leftover pixels. What happens to a codepoint the chosen face has no glyph for differs by shell. The SDL GUI falls back through a chain it builds itself: embedded Adwaita diff --git a/features.txt b/features.txt index 0db7c497..86b2a834 100644 --- a/features.txt +++ b/features.txt @@ -162,7 +162,7 @@ Found by adversarial review and NOT fixed, because they are upstream or macOS-on contributes 0, and PardesView's liquid-glass affordance never draws. The tests pass only because they set the flag by hand. The comment in the look_hover_preview paint block claims it carries those cells out to the hosts; it does not. - -Dworkspace-tag is read only in src/macos.zig, and core.settings.workspace_tag is assigned only there, so the option builds cleanly for gui/tty/web and is - silently ignored. gui.zig hard-codes `true` at six taglineBandOffset call sites and still uses raw TOPBAR_H at five more. + silently ignored. (taglineBandOffset no longer takes it: every band is centred since 2026-09-23.) gui.zig still uses raw TOPBAR_H at five sites. - The detached wire encodes the pointer shape in the frame header variant (full_link/diff_link), so the newer `.target` shape collapses to `.arrow` for an attached frontend. Fixing it means a new header variant, i.e. a protocol change. - A shell that outlives its editor keeps PARDES_PID; if that pid is reused, `pardes ` now exits 1 instead of falling back to starting an editor. Exiting 1 diff --git a/src/gui/gui.zig b/src/gui/gui.zig index 7f28124c..48087d0b 100644 --- a/src/gui/gui.zig +++ b/src/gui/gui.zig @@ -1809,6 +1809,8 @@ const Gui = struct { pointer_cell: ?MouseCell = null, capture: bool = false, + /// Pixels the capture holds past the grid (PARDES_TEST_PAD). + capture_pad: u32 = 0, capture_dir: []const u8 = "", capture_tex: ?*c.SDL_GPUTexture = null, capture_tex_w: u32 = 0, @@ -2196,7 +2198,9 @@ fn runNative(init: std.process.Init, opts_in: pardes.Options, attach: ?[]const u if (test_mode) { const cols = envU16(env, "PARDES_TEST_COLS") orelse 80; const rows = envU16(env, "PARDES_TEST_ROWS") orelse 24; - _ = c.SDL_SetWindowSize(window, @intCast(cols * cell_w), @intCast(rows * cell_h)); + // PARDES_TEST_PAD: extra pixels past the grid, as a real window has. + const pad = envU16(env, "PARDES_TEST_PAD") orelse 0; + _ = c.SDL_SetWindowSize(window, @intCast(cols * cell_w + pad), @intCast(rows * cell_h + pad)); _ = c.SDL_SyncWindow(window); } @@ -2284,6 +2288,7 @@ fn runNative(init: std.process.Init, opts_in: pardes.Options, attach: ?[]const u .atlas_stage = atlas_stage, .glyphs = std.AutoHashMap(GlyphKey, Slot).init(gpa), .capture = test_mode, + .capture_pad = if (test_mode) envU16(env, "PARDES_TEST_PAD") orelse 0 else 0, .capture_dir = capture_dir orelse "", .soft_present = soft_present, .transparent = config.gui_transparent, @@ -4909,8 +4914,8 @@ fn renderFrame( var sh: u32 = 0; var target: *c.SDL_GPUTexture = undefined; if (g.capture) { - sw = @as(u32, surface.cols) * g.cell_w; - sh = @as(u32, surface.rows) * g.cell_h; + sw = @as(u32, surface.cols) * g.cell_w + g.capture_pad; + sh = @as(u32, surface.rows) * g.cell_h + g.capture_pad; if (sw == 0 or sh == 0) { command_consumed = true; _ = c.SDL_SubmitGPUCommandBuffer(cmd); @@ -5360,18 +5365,14 @@ fn bottomTaglinePresent(surface: *const pardes.Surface) bool { return false; } -test "tagline bands face the topbar rule and Tagbottom faces the window edge" { +test "tagline bands center in their cells and Tagbottom faces the window edge" { const cell_h: u32 = 20; const tagline_h: u32 = 16; const canvas_h: f32 = 200; - const border = topbarPaneBorderPixels(cell_h, tagline_h); - try std.testing.expectEqual(@as(u32, 1), border); - try std.testing.expectEqual(@as(u32, 4), taglineBandOffset(0, canvas_h, cell_h, tagline_h, true)); - try std.testing.expectEqual(@as(u32, 2), taglineBandOffset(0, canvas_h, cell_h, tagline_h, false)); - try std.testing.expectEqual(@as(u32, 1), taglineBandOffset(1, canvas_h, cell_h, tagline_h, true)); - try std.testing.expectEqual(@as(u32, 2), taglineBandOffset(1, canvas_h, cell_h, tagline_h, false)); - try std.testing.expectEqual(@as(u32, 2), taglineBandOffset(5, canvas_h, cell_h, tagline_h, true)); - try std.testing.expectEqual(@as(u32, 4), taglineBandOffset(9, canvas_h, cell_h, tagline_h, true)); + // Workspace, column and pane rows alike: text lines up across bands. + for ([_]u16{ 0, 1, 2, 5, 8 }) |row| + try std.testing.expectEqual(@as(u32, 2), taglineBandOffset(row, canvas_h, cell_h, tagline_h)); + try std.testing.expectEqual(@as(u32, 4), taglineBandOffset(9, canvas_h, cell_h, tagline_h)); } fn resolveCell(g: *Gui, cell: *const pardes.Cell, role: pardes.FontRole, is_cursor: bool, page: Ground) ResolvedCell { @@ -5502,7 +5503,10 @@ fn emitTagLayer(g: *Gui, instances: [*]CellInstance, next: *u32, layer: *const p // it comes out from under whatever is above it. const slide = layer.slide * bh; const top = @as(f32, @floatFromInt(layer.viewport.y)) * bh; - emitInstance(g, instances, next.*, 0, layer.viewport.y, .{ .w = right - left, .h = bh, .x_off = left, .y_off = slide }, win_w, win_h, track, .body, &background, old_layer, false, page); + // A window is rarely a whole number of cells wide: a band that ends at + // the last column runs on through the leftover pixels to the edge. + const band_right = if (win_w - right < bw) @max(right, win_w) else right; + emitInstance(g, instances, next.*, 0, layer.viewport.y, .{ .w = band_right - left, .h = bh, .x_off = left, .y_off = slide }, win_w, win_h, track, .body, &background, old_layer, false, page); if (slide != 0) clipInstanceTop(&instances[next.*], top, win_h); next.* += 1; for (0..tagLayerCellCount(g, layer)) |col| { @@ -5578,7 +5582,7 @@ fn emitBodyLayer(g: *Gui, instances: [*]CellInstance, next: *u32, layer: *const if (left + @as(f32, @floatFromInt(col)) * width >= right) break; const cell = &layer.cells[index * layer.cols + col]; const cursor = if (layer.cursor) |cu| show_cursor and !cu.bar and cu.x == col and cu.y == row else false; - const glyph_top = top - (if (header) @as(f32, @floatFromInt(taglineBandOffset(0, win_h, g.cell_h, g.tagline_height, true))) else 0); + const glyph_top = top - (if (header) @as(f32, @floatFromInt(taglineBandOffset(0, win_h, g.cell_h, g.tagline_height))) else 0); emitInstance(g, instances, next.*, 0, 0, .{ .w = width, .h = height, .x_off = left + @as(f32, @floatFromInt(col)) * width, .y_off = glyph_top }, win_w, win_h, track, role, cell, old_layer, cursor, page); clipBodyInstance(&instances[next.*], bottom, win_h); clipInstanceRight(&instances[next.*], right, win_w); @@ -5628,6 +5632,10 @@ fn paneGripCell(layers: []const pardes.TagLayer, cells: []const pardes.Cell, col return null; } +fn anchorInset(g: *const Gui, row: u16, win_h: f32) u32 { + return taglineBandOffset(row, win_h, g.cell_h, g.tagline_height); +} + fn emitSurfaceCell( g: *Gui, core: ?*const pardes.Pardes, @@ -5657,19 +5665,27 @@ fn emitSurfaceCell( next.* += 1; // Tag glyphs keep their font size inside a full physical-width grip. emitInstance(g, instances, next.*, col, row, body_layout, win_w, win_h, track, .tagline, cell, old_layer, is_cursor, page); + // An anchor starts at its column's rule: its left edge is inset by + // its top margin so the band frames it on the left as above and + // below, and its mark moves right by half that to stay centered. + const inset: u32 = if (core) |p| if (std.mem.indexOfScalar(u16, p.col_x[0..p.ncol], col -| (if (grip) |indicator| indicator.offset else 0)) != null) anchorInset(g, row, win_h) else 0 else 0; if (grip) |indicator| { const cached = cachedGlyph(g, cellCodepoint(indicator.cell), .tagline, GlyphDecoration.fromCell(indicator.cell), true); const slot = cached orelse g.space_slot; - const offset: u32 = if (cached != null) @as(u32, indicator.offset) * g.cell_w else 0; + const offset: f32 = if (cached != null) @as(f32, @floatFromInt(@as(u32, indicator.offset) * g.cell_w)) - @as(f32, @floatFromInt(inset / 2)) else 0; const resolved = resolveCell(g, indicator.cell, .tagline, false, page); instances[next.*].fr = @as(f32, @floatFromInt(resolved.fg[0])) / 255; instances[next.*].fg = @as(f32, @floatFromInt(resolved.fg[1])) / 255; instances[next.*].fb = @as(f32, @floatFromInt(resolved.fg[2])) / 255; - instances[next.*].u0 = @as(f32, @floatFromInt(slot.u + offset)) / atlas_w; + instances[next.*].u0 = (@as(f32, @floatFromInt(slot.u)) + offset) / atlas_w; instances[next.*].v0 = @as(f32, @floatFromInt(slot.v)) / atlas_h; instances[next.*].v1 = @as(f32, @floatFromInt(slot.v + g.tagline_height)) / atlas_h; } instances[next.*].u1 = instances[next.*].u0 + @as(f32, @floatFromInt(g.cell_w)) / atlas_w; + if (inset > 0 and (grip == null or grip.?.offset == 0)) { + instances[next.*].x0 += @as(f32, @floatFromInt(inset)) / win_w * 2; + instances[next.*].u0 += @as(f32, @floatFromInt(inset)) / atlas_w; + } next.* += 1; return; } @@ -5690,7 +5706,8 @@ test "small tagline fonts leave no background gutters between adjacent tags" { var instances: [6]CellInstance = undefined; var next: u32 = 0; for (0..3) |row| { - emitSurfaceCell(&g, core, &instances, &next, 0, @intCast(row), fixedCellLayout(&g), 800, 480, null, &cell, &cell, null, false, false, Ground.opaqueRgb(bg_default)); + // Column 1: past the anchor's inset edge at the column's left. + emitSurfaceCell(&g, core, &instances, &next, 1, @intCast(row), fixedCellLayout(&g), 800, 480, null, &cell, &cell, null, false, false, Ground.opaqueRgb(bg_default)); const base = instances[row * 2]; const ink = instances[row * 2 + 1]; try std.testing.expectApproxEqAbs(@as(f32, 20.0 / 480.0 * 2), base.y0 - base.y1, 0.0001); @@ -5700,6 +5717,13 @@ test "small tagline fonts leave no background gutters between adjacent tags" { try std.testing.expectApproxEqAbs(@as(f32, 10) / atlas_w, ink.u1 - ink.u0, 0.0001); if (row > 0) try std.testing.expectApproxEqAbs(instances[(row - 1) * 2].y1, base.y0, 0.0001); } + // Column 0 is an anchor's edge: its ink is inset by the band's margin + // (2 px here) and its underlay still covers the whole cell. + next = 0; + emitSurfaceCell(&g, core, &instances, &next, 0, 1, fixedCellLayout(&g), 800, 480, null, &cell, &cell, null, false, false, Ground.opaqueRgb(bg_default)); + try std.testing.expectApproxEqAbs(@as(f32, 10.0 / 800.0 * 2), instances[0].x1 - instances[0].x0, 0.0001); + try std.testing.expectApproxEqAbs(@as(f32, 8.0 / 800.0 * 2), instances[1].x1 - instances[1].x0, 0.0001); + try std.testing.expectApproxEqAbs(@as(f32, 8) / atlas_w, instances[1].u1 - instances[1].u0, 0.0001); next = 0; emitSurfaceCell(&g, null, &instances, &next, 0, 2, fixedCellLayout(&g), 800, 480, null, &cell, &cell, null, true, false, Ground.opaqueRgb(bg_default)); try std.testing.expectEqual(@as(u32, 2), next); @@ -5730,7 +5754,7 @@ fn emitInstance( else layout.h; const band_offset: f32 = if (resolved.role == .tagline) - @floatFromInt(taglineBandOffset(row, win_h, g.cell_h, g.tagline_height, true)) + @floatFromInt(taglineBandOffset(row, win_h, g.cell_h, g.tagline_height)) else 0; const py0 = layout.y_off + @as(f32, @floatFromInt(row)) * layout.h + band_offset; @@ -6562,7 +6586,7 @@ fn addCursorBar( const x0 = layout.x_off + @as(f32, @floatFromInt(x)) * layout.w; const height = std.math.clamp(visual_height, 1.0, layout.h); const y0 = layout.y_off + @as(f32, @floatFromInt(y)) * layout.h + - @as(f32, @floatFromInt(taglineBandOffset(y, builder.win_h, @intFromFloat(layout.h), @intFromFloat(height), true))); + @as(f32, @floatFromInt(taglineBandOffset(y, builder.win_h, @intFromFloat(layout.h), @intFromFloat(height)))); builder.addRect( x0, y0, @@ -6662,7 +6686,7 @@ fn buildOverlay( const right = left + @as(f32, @floatFromInt(layer.viewport.w)) * layout.w; const x = left + @as(f32, @floatFromInt(cursor.col)) * width; if (x >= right) continue; - const top = @as(f32, @floatFromInt(layer.viewport.y)) * layout.h + @as(f32, @floatFromInt(taglineBandOffset(layer.viewport.y, builder.win_h, g.cell_h, g.tagline_height, true))); + const top = @as(f32, @floatFromInt(layer.viewport.y)) * layout.h + @as(f32, @floatFromInt(taglineBandOffset(layer.viewport.y, builder.win_h, g.cell_h, g.tagline_height))); builder.addRect(x, top, @min(right, x + @max(1, width / 8)), top + @as(f32, @floatFromInt(g.tagline_height)), overlayRgb(cursorColor(core, &layer.cells[cursor.col], .tagline))); }; if (transient_on) appendTouchOverlay(g, &builder, debug_on); @@ -6683,7 +6707,7 @@ fn appendWorkspacePet(g: *Gui, core: ?*const pardes.Pardes, surface: *const pard if (cellCodepoint(cell) != ' ') occupied = i + 1; } const editing = p.topbar_col != null and p.header_column == null; - const band_top: f32 = @floatFromInt(taglineBandOffset(0, builder.win_h, g.cell_h, g.tagline_height, true)); + const band_top: f32 = @floatFromInt(taglineBandOffset(0, builder.win_h, g.cell_h, g.tagline_height)); const region = if (occupied >= surface.cols) null else pet.lane( occupied, @floatFromInt(g.tagline_width), @@ -6810,7 +6834,10 @@ fn appendPaneChrome( } else true; if (tag_visible) { const rule_y = @as(f32, @floatFromInt(tag_y + @as(u16, if (core.settings.tag_bottom) 0 else 1))) * layout.h; - builder.addRect(x0, rule_y - @as(f32, if (core.settings.tag_bottom) 0 else 1), x1, rule_y + @as(f32, if (core.settings.tag_bottom) 1 else 0), overlayRgb(chrome.border)); + // Like the band above it, the rule of a pane at the right edge + // runs on through the pixels past the last whole cell. + const rule_x1 = if (builder.win_w - x1 < layout.w) @max(x1, builder.win_w) else x1; + builder.addRect(x0, rule_y - @as(f32, if (core.settings.tag_bottom) 0 else 1), rule_x1, rule_y + @as(f32, if (core.settings.tag_bottom) 1 else 0), overlayRgb(chrome.border)); } // Do not paint over resize previews or debug text occupying the rail. @@ -6827,12 +6854,13 @@ fn appendPaneChrome( } if (row != body_end) continue; const y0 = @as(f32, @floatFromInt(body_y)) * layout.h; - const y1 = @as(f32, @floatFromInt(body_end)) * layout.h; + const body_y1 = @as(f32, @floatFromInt(body_end)) * layout.h; + const y1 = if (body_end == surface.rows and builder.win_h - body_y1 < layout.h) @max(body_y1, builder.win_h) else body_y1; builder.addRect(x0, y0, x0 + layout.w, y1, page); appendSquareRail(builder, x0, y0, y1, layout.w, false, overlayRgb(chrome.scroll_track)); if (thumb_start) |first| { const thumb_y0 = @as(f32, @floatFromInt(first)) * layout.h; - const thumb_y1 = @as(f32, @floatFromInt(thumb_end)) * layout.h; + const thumb_y1 = if (thumb_end == body_end) y1 else @as(f32, @floatFromInt(thumb_end)) * layout.h; appendSquareRail(builder, x0, thumb_y0, thumb_y1, layout.w, true, overlayRgb(chrome.scroll_thumb)); } } @@ -6854,8 +6882,8 @@ fn appendTagGrips(g: *const Gui, surface: *const pardes.Surface, layout: CellLay .rgb => |rgb| rgb, else => continue, }; - const center_x = (@as(f32, @floatFromInt(x)) + @as(f32, @floatFromInt(config.GUTTER)) / 2) * layout.w; - const center_y = @as(f32, @floatFromInt(y)) * layout.h + @as(f32, @floatFromInt(taglineBandOffset(y, builder.win_h, g.cell_h, g.tagline_height, true))) + @as(f32, @floatFromInt(g.tagline_height)) / 2; + const center_x = (@as(f32, @floatFromInt(x)) + @as(f32, @floatFromInt(config.GUTTER)) / 2) * layout.w + @as(f32, @floatFromInt(anchorInset(g, y, builder.win_h) / 2)); + const center_y = @as(f32, @floatFromInt(y)) * layout.h + @as(f32, @floatFromInt(taglineBandOffset(y, builder.win_h, g.cell_h, g.tagline_height))) + @as(f32, @floatFromInt(g.tagline_height)) / 2; const half_w = @max(1, @min(3, layout.w - 2)); builder.addRect(@floor(center_x - half_w), @floor(center_y - 2), @floor(center_x + half_w), @floor(center_y - 1), overlayRgb(rgb)); builder.addRect(@floor(center_x - half_w), @floor(center_y + 1), @floor(center_x + half_w), @floor(center_y + 2), overlayRgb(rgb)); @@ -6875,7 +6903,9 @@ test "column grips stay unmarked while pane marks retain physical centering" { var builder: OverlayBuilder = .{ .vertices = &vertices, .win_w = 200, .win_h = 80 }; appendTagGrips(&g, &surface, .{ .w = 10, .h = 20, .x_off = 0, .y_off = 0 }, &builder); try std.testing.expectEqual(@as(usize, 12), builder.len); - try std.testing.expectApproxEqAbs(@as(f32, 57.0 / 200.0 * 2.0 - 1.0), vertices[0].x, 0.0001); + // Centered in the anchor, whose left edge is inset by the band's offset + // (8 px on this last row): the mark moves right by half of it. + try std.testing.expectApproxEqAbs(@as(f32, 61.0 / 200.0 * 2.0 - 1.0), vertices[0].x, 0.0001); } fn appendSquareRail(builder: *OverlayBuilder, x: f32, y0: f32, y1: f32, cell_w: f32, thumb: bool, color: OverlayColor) void { @@ -6885,7 +6915,9 @@ fn appendSquareRail(builder: *OverlayBuilder, x: f32, y0: f32, y1: f32, cell_w: fn appendColumnSpines(core: *const pardes.Pardes, rows: u16, layout: CellLayout, builder: *OverlayBuilder) void { const y0 = @as(f32, @floatFromInt(pardes.TOPBAR_H)) * layout.h; - const y1 = @as(f32, @floatFromInt(rows)) * layout.h; + const grid_y1 = @as(f32, @floatFromInt(rows)) * layout.h; + // Down through the pixels past the last whole row, as tags run right. + const y1 = if (builder.win_h - grid_y1 < layout.h) @max(grid_y1, builder.win_h) else grid_y1; if (y1 <= y0) return; // A single boundary spans all panes, including their tags. Its left edge // agrees with the square scroll markers and existing move-box hit area. diff --git a/src/layout.zig b/src/layout.zig index c6cb7503..8db05a07 100644 --- a/src/layout.zig +++ b/src/layout.zig @@ -723,6 +723,23 @@ pub fn columnMoveTarget(p: *const Pardes, source: usize, x: u16) usize { return insertion; } +/// Share out the width of columns `left` and `left + 1` so the left one is +/// `left_width` cells, neither below MINW. A border drag and a column grip +/// dropped inside its own place both end here. +pub fn setColumnPairWidth(p: *Pardes, left: usize, left_width: u64) void { + if (left + 1 >= p.ncol) return; + const combined: u64 = p.col_w[left] + p.col_w[left + 1]; + // Too narrow for both to keep MINW: any split would squeeze one away. + if (combined < 2 * @as(u64, config.MINW)) return; + const width = std.math.clamp(left_width, config.MINW, @max(@as(u64, config.MINW), combined -| config.MINW)); + const pair = p.col_weight[left] + p.col_weight[left + 1]; + if (pair <= 1 or combined == 0) return; + const numerator = @as(u128, pair) * width + combined / 2; + const share = std.math.clamp(@as(u64, @intCast(numerator / combined)), 1, pair - 1); + p.col_weight[left] = share; + p.col_weight[left + 1] = pair - share; +} + pub fn reorderColumn(p: *Pardes, from: usize, to: usize) void { if (from >= p.ncol or to >= p.ncol or from == to) return; const ids = p.col_panes[from]; diff --git a/src/macos.zig b/src/macos.zig index c359eb3f..3ff8bdfa 100644 --- a/src/macos.zig +++ b/src/macos.zig @@ -951,7 +951,7 @@ export fn pardes_gui_tagline_font_percent() u8 { export fn pardes_tagline_band_offset(row: u16, canvas_h: f32, cell_h: u32, tagline_h: u32) u32 { pardes.turn.wake(); defer pardes.turn.rest(); - return pardes.taglineBandOffset(row, canvas_h, cell_h, tagline_h, if (state) |*st| st.core.settings.workspace_tag else true); + return pardes.taglineBandOffset(row, canvas_h, cell_h, tagline_h); } export fn pardes_topbar_pane_border_px(cell_h: u32, tagline_h: u32) u32 { diff --git a/src/macos/Sources/PardesView.swift b/src/macos/Sources/PardesView.swift index 5ad09c38..70f467e3 100644 --- a/src/macos/Sources/PardesView.swift +++ b/src/macos/Sources/PardesView.swift @@ -523,9 +523,8 @@ private struct TaglineMetrics { /// Where this band sits inside row `row`, measured down from the row's top. /// The rule belongs to the core (`pardes_tagline_band_offset`) so that this - /// shell and the SDL one cannot disagree about it: row zero and the first - /// pane-tag row meet at a shared rule, a Tagbottom band on the last row - /// faces the window edge, and everything between is centred. + /// shell and the SDL one cannot disagree about it: every band is centred, + /// except a Tagbottom band on the last row, which faces the window edge. func top(row: Int, canvasHeight: CGFloat) -> CGFloat { CGFloat(pardes_tagline_band_offset( UInt16(clamping: row), Float(canvasHeight * scale), cellPixels, bandPixels)) / scale diff --git a/src/pardes.zig b/src/pardes.zig index fae14f47..ca2c34a4 100644 --- a/src/pardes.zig +++ b/src/pardes.zig @@ -232,19 +232,12 @@ pub const BOX_H: u16 = 1; pub const TAG_GAP: u16 = 1; pub const TAG_TEXT_INSET: u16 = config.GUTTER + TAG_GAP; -pub fn taglineBandOffset(row: u16, canvas_h: f32, cell_h: u32, tagline_h: u32, workspace: bool) u32 { +pub fn taglineBandOffset(row: u16, canvas_h: f32, cell_h: u32, tagline_h: u32) u32 { const spare = cell_h -| tagline_h; - const border = topbarPaneBorderPixels(cell_h, tagline_h); const rows: u32 = @max(1, @as(u32, @intFromFloat(@floor(canvas_h / @as(f32, @floatFromInt(cell_h)))))); - if (!workspace) { - // No workspace row: nothing above row 0 to share a rule with, so - // every band centers in its cell the way the middle rows always - // have. The anchor boxes this lets the hosts draw stay symmetric. - if (@as(u32, row) + 1 >= rows) return spare; - return spare / 2; - } - if (row == 0) return spare - border / 2; - if (row == TOPBAR_H) return border - border / 2; + // Every band centers in its cell, so text and anchors sit at the same + // height in the workspace, column and pane tags alike. Only the last row + // faces the window edge (Tagbottom). if (@as(u32, row) + 1 >= rows) return spare; return spare / 2; } @@ -5160,7 +5153,9 @@ const Drag = union(enum) { border_v: struct { left_col: usize, cur_x: u16, corner: ?struct { col: usize, idx: usize } = null, cur_y: u16 = 0 }, border_h: struct { col: usize, top_idx: usize, cur_y: u16 }, move: struct { id: usize, cur_x: u16, cur_y: u16 }, - column_move: struct { column: usize, serial: u32, cur_x: u16 }, + /// `grab`: how far into the grip it was pressed, so the column's left + /// edge lands at `cur_x - grab`. A release still on the grip moves nothing. + column_move: struct { column: usize, serial: u32, cur_x: u16, grab: u16 = 0 }, tag: struct { id: usize }, /// chorded: a 1-2/1-3 cut/paste chord fired during this left drag — /// the drag's own release is then inert @@ -12022,7 +12017,7 @@ pub const Pardes = struct { if (mcol < p.col_x[column] or mcol >= p.col_x[column] + @min(config.GUTTER, p.col_w[column])) continue; if (m.button == config.select_button) { p.header_drag = false; - p.drag = .{ .column_move = .{ .column = column, .serial = p.col_serial[column], .cur_x = mcol } }; + p.drag = .{ .column_move = .{ .column = column, .serial = p.col_serial[column], .cur_x = mcol, .grab = mcol - p.col_x[column] } }; } return; } @@ -12482,20 +12477,10 @@ pub const Pardes = struct { .border_v => |d| { const c = d.left_col; const old_seam = p.col_x[c] + p.col_w[c] -| 1; - if (c + 1 < p.ncol and d.cur_x != old_seam) { - const combined: u64 = p.col_w[c] + p.col_w[c + 1]; - // the handle is the left pane's LAST column (inclusive), so - // the new width includes it — a no-drag click changes nothing - var nl: u64 = (d.cur_x + 1) -| p.col_x[c]; - nl = std.math.clamp(nl, config.MINW, @max(@as(u64, config.MINW), combined -| config.MINW)); - const pair = p.col_weight[c] + p.col_weight[c + 1]; - if (pair > 1 and combined > 0) { - const numerator = @as(u128, pair) * nl + combined / 2; - const left = std.math.clamp(@as(u64, @intCast(numerator / combined)), 1, pair - 1); - p.col_weight[c] = left; - p.col_weight[c + 1] = pair - left; - } - } + // the handle is the left pane's LAST column (inclusive), so + // the new width includes it — a no-drag click changes nothing + if (c + 1 < p.ncol and d.cur_x != old_seam) + layout.setColumnPairWidth(p, c, (d.cur_x + 1) -| p.col_x[c]); if (d.corner) |k| { if (d.cur_y != seamRowOf(p, k.col, k.idx)) layout.applyRowSplit(p, k.col, k.idx, d.cur_y); @@ -12503,9 +12488,15 @@ pub const Pardes = struct { }, .border_h => |d| if (d.cur_y != seamRowOf(p, d.col, d.top_idx)) layout.applyRowSplit(p, d.col, d.top_idx, d.cur_y), - .column_move => |d| { - if (layout.columnBySerial(p, d.serial)) |column| - layout.reorderColumn(p, column, layout.columnMoveTarget(p, column, d.cur_x)); + .column_move => |d| if (layout.columnBySerial(p, d.serial)) |column| { + const target = layout.columnMoveTarget(p, column, d.cur_x); + if (target != column) { + layout.reorderColumn(p, column, target); + } else if (column > 0 and (d.cur_x < p.col_x[column] or d.cur_x >= p.col_x[column] + config.GUTTER)) { + // Dropped short of another column's place: as in acme, + // the column's left edge moves to where it was dropped. + layout.setColumnPairWidth(p, column - 1, (d.cur_x -| d.grab) -| p.col_x[column - 1]); + } }, .move => |d| { layout.movePane(p, d.id, d.cur_x, d.cur_y); @@ -14181,6 +14172,15 @@ pub const Pardes = struct { } var row: u16 = p.topBarHeight(); while (row < s.rows) : (row += 1) s.overlayDash(x, row, "╎"); + } else if (source > 0 and source < p.ncol and (d.cur_x < p.col_x[source] or d.cur_x >= p.col_x[source] + config.GUTTER) and + p.col_w[source - 1] + p.col_w[source] >= 2 * config.MINW) + { + // Where the left edge would land: the border drag's rail. + const lo = p.col_x[source - 1] + config.MINW; + const hi = (p.col_x[source] + p.col_w[source]) -| config.MINW; + const x = @min(std.math.clamp(d.cur_x -| d.grab, lo, @max(lo, hi)), s.cols -| 1); + var row: u16 = p.topBarHeight(); + while (row < s.rows) : (row += 1) s.overlayDash(x, row, "╎"); } }, .move => |d| if (d.cur_x < s.cols) { diff --git a/src/web.zig b/src/web.zig index 7325af54..b5a992ae 100644 --- a/src/web.zig +++ b/src/web.zig @@ -376,7 +376,7 @@ export fn pardes_tag_layer_cells(index: u32) ?[*]const WebCell { } export fn pardes_tagline_band_offset(row: u16, canvas_h: f32, cell_h: u32, tagline_h: u32) u32 { - return pardes.taglineBandOffset(row, canvas_h, cell_h, tagline_h, true); + return pardes.taglineBandOffset(row, canvas_h, cell_h, tagline_h); } export fn pardes_body_layer_value(index: u32, field: u32) u32 { diff --git a/test/column_drag.zig b/test/column_drag.zig index be4e33a3..85dca66b 100644 --- a/test/column_drag.zig +++ b/test/column_drag.zig @@ -212,3 +212,43 @@ test "column grips stay blank and muted across focus hover and drag" { } } } + +test "column grip dropped in its own place moves the column's left edge" { + const p = try Pardes.init(std.testing.allocator, .{ .tty_only = true, .cols = 120, .rows = 24 }); + defer p.deinit(); + _ = try p.setTestFile("body\n"); + p.presentation.enabled = false; + p.settings.column_tags = true; + try std.testing.expect(p.executeBuiltinLine(0, "New")); + try std.testing.expect(layout.splitColumn(p, p.active, p.active, false)); + p.update(.tick); + var frame = std.heap.ArenaAllocator.init(p.gpa); + defer frame.deinit(); + _ = try p.render(frame.allocator()); + const serials = .{ p.col_serial[0], p.col_serial[1] }; + const edge = p.col_x[1]; + const total = p.col_w[0] + p.col_w[1]; + // A click in place, from either grip cell, changes nothing. + for (0..config.GUTTER) |offset| { + const x = edge + @as(u16, @intCast(offset)); + mouse(p, .press, x); + mouse(p, .release, x); + _ = try p.render(frame.allocator()); + try std.testing.expectEqual(edge, p.col_x[1]); + } + // Grabbed by its second cell and dropped 7 cells left: the edge follows. + mouse(p, .press, edge + 1); + mouse(p, .drag, edge + 1 - 7); + _ = try p.render(frame.allocator()); + mouse(p, .release, edge + 1 - 7); + _ = try p.render(frame.allocator()); + try std.testing.expectEqual(edge - 7, p.col_x[1]); + try std.testing.expectEqual(total, p.col_w[0] + p.col_w[1]); + try std.testing.expectEqual(serials[0], p.col_serial[0]); + try std.testing.expectEqual(serials[1], p.col_serial[1]); + // Past the neighbour's middle it is still a reorder, not a resize. + mouse(p, .press, p.col_x[1]); + mouse(p, .release, p.col_x[0] + 1); + try std.testing.expectEqual(serials[1], p.col_serial[0]); + try std.testing.expectEqual(serials[0], p.col_serial[1]); +} -- cgit v1.3 From e5f764bd201df6554272427fc8cedffece18066f Mon Sep 17 00:00:00 2001 From: Gabriel Schneider Date: Thu, 24 Sep 2026 10:12:10 -0300 Subject: Shape text with HarfBuzz, so a font's programming ligatures draw across their cells The SDL shell rasterized every cell by its own codepoint, so a font's `->`, `!=` or `<=` ligature never appeared. Text is now shaped with HarfBuzz 11.0.0, built from source like FreeType: a lazy build.zig.zon dependency (the tarball Ghostty pins) compiled only for the gui shell, its FreeType integration linked against the freetype package, so the binary carries no system HarfBuzz or FreeType and a tty build never compiles it. Shaping turns on only the font's ligature features (liga, calt, clig, rlig, rclt); composition, local forms and fractions stay off, so a cell draws either its nominal glyph, as it always did, or part of a ligature. A glyph no lookup of those features covers cannot change, so its cell is resolved alone, and that resolution is cached by codepoint: in a font without ligatures (Adwaita Mono) no cell is ever shaped, and the pipeline draws pixel for pixel as before. A cell whose glyph a ligature could replace is shaped with its word: the cells between spaces that share a decoration and a role. A word ends either side of the cursor, block or bar, so the cell being edited shows its own character (Ghostty's rule), and inside f|i, f|l and s|t, whose typographic ligatures do not belong on a grid (Ghostty again). Colours never end a word: a ligature spans a syntax colour change or a selection edge. A codepoint the primary font lacks shapes in the fallback face that has it. Taglines are not shaped: they are drawn at two pitches, and a strip would not line up in one. HarfBuzz only chooses glyphs; the grid places them. A substituted glyph whose ink reaches over neighbouring cells that draw nothing of their own (the spacer glyphs of Fira Code-style fonts such as Maple Mono, or the cells a merged ligature cluster swallowed) claims them: it is rasterized once as a strip that many cells wide, and each cell samples its own slice, so selection, the cursor and per-cell colours work unchanged. Anything the grid cannot place (several glyphs in one cell, a positioned mark) keeps its nominal glyphs. A frame must not pay for this. A shaped word's atlas slots are cached by its text (checked against the stored text, not just its hash), so a frame costs one lookup per word and a compare for the rest of the word being walked. The atlas is keyed by (face, glyph, role, decoration, lead, span), packed into 64 bits so a lookup hashes one word; ASCII glyph ids are a table, and a face's HarfBuzz state is made when it is first asked about a glyph. Measured with the latency trace, whose F line now also carries the submit time (CPU = submit - present entry), in 10 interleaved rounds against main with an A/A pair, at 160x50 cells: with Adwaita Mono every scenario (idle, scrolling, typing, terminal output) is as fast or 1-3% faster, and the first frame and time to first paint are unchanged. With Maple Mono, ligatures cost the first frame about 0.8 ms (HarfBuzz setup and shaping the screen) and scrolling new text about 1-2%. With it the codepoint raster path is gone: grips look up their glyph and stay centered, since a grip is not text. ui_font_scale_for_height, an identity kept as a "size token", is removed (px is the size everywhere), ui_font_has_glyph becomes ui_font_glyph, and the space slot is simply the first, cleared cell of the atlas rather than a rasterized space. CellStyle.ul gets an explicit u3 tag so a decoration fits in the packed keys. Co-Authored-By: Claude Opus 5.5 (1M context) --- build.zig | 33 ++++ build.zig.zon | 9 + docs/design.typ | 6 +- src/gui/font.c | 283 ++++++++++++++++++++++++---- src/gui/font.h | 66 +++++-- src/gui/gui.zig | 565 +++++++++++++++++++++++++++++++++++++++++++------------- src/pardes.zig | 2 +- 7 files changed, 783 insertions(+), 181 deletions(-) (limited to 'src/pardes.zig') diff --git a/build.zig b/build.zig index 7010c863..21df1555 100644 --- a/build.zig +++ b/build.zig @@ -642,6 +642,39 @@ pub fn build(b: *std.Build) void { .@"enable-libpng" = false, }); gm.linkLibrary(freetype_dep.artifact("freetype")); + // HarfBuzz from source, like FreeType: its FreeType integration + // (HAVE_FREETYPE, hb-ft) links the freetype artifact above, so the two + // share one FreeType. The flags are the ones Ghostty builds it with. + if (b.lazyDependency("harfbuzz", .{})) |upstream| { + const harfbuzz = b.addLibrary(.{ + .name = "harfbuzz", + .linkage = .static, + .root_module = b.createModule(.{ + .target = target, + .optimize = optimize, + .link_libc = true, + .link_libcpp = true, + }), + }); + harfbuzz.root_module.linkLibrary(freetype_dep.artifact("freetype")); + harfbuzz.root_module.addIncludePath(upstream.path("src")); + harfbuzz.root_module.addCSourceFile(.{ + .file = upstream.path("src/harfbuzz.cc"), + .flags = &.{ + "-DHAVE_STDBOOL_H", + "-DHAVE_UNISTD_H", + "-DHAVE_SYS_MMAN_H", + "-DHAVE_PTHREAD=1", + "-DHAVE_FREETYPE=1", + "-DHAVE_FT_GET_VAR_BLEND_COORDINATES=1", + "-DHAVE_FT_SET_VAR_BLEND_COORDINATES=1", + "-DHAVE_FT_DONE_MM_VAR=1", + "-DHAVE_FT_GET_TRANSFORM=1", + }, + }); + gm.linkLibrary(harfbuzz); + gm.addIncludePath(upstream.path("src")); + } if (target.result.os.tag.isDarwin()) gm.addRPath(.{ .cwd_relative = "/usr/local/lib" }); gm.addIncludePath(b.path("src/gui")); diff --git a/build.zig.zon b/build.zig.zon index 8f1b8068..31649350 100644 --- a/build.zig.zon +++ b/build.zig.zon @@ -189,6 +189,15 @@ .url = "git+https://github.com/allyourcodebase/freetype#884fd2235e6ae1ec4306eda30b3259f20930ed2e", .hash = "freetype-2.14.3-C3-WdXSKAAB-kHs4qgRoeoFnRkNQn6M_SSlUGZ6ywgBQ", }, + // HarfBuzz shapes the SDL shell's text runs, which is what turns `->` + // into a font's arrow ligature. The upstream source release (the same + // tarball Ghostty pins); build.zig compiles harfbuzz.cc against the + // freetype above. Lazy: only a gui build fetches or compiles it. + .harfbuzz = .{ + .url = "https://deps.files.ghostty.org/harfbuzz-11.0.0.tar.xz", + .hash = "N-V-__8AAG02ugUcWec-Ndp-i7JTsJ0dgF8nnJRUInkGLG7G", + .lazy = true, + }, }, .minimum_zig_version = "0.16.0", .paths = .{""}, diff --git a/docs/design.typ b/docs/design.typ index f8f0b05c..8ec025f1 100644 --- a/docs/design.typ +++ b/docs/design.typ @@ -1632,7 +1632,8 @@ and web and macOS are libraries whose host owns `main()`. == Generated inputs Native dependencies are ghostty, vaxis, uucode (shared config), zstbi, SDL (a -pinned fork, lazy), FreeType, MuPDF (`-Dmupdf`, on by default everywhere but the +pinned fork, lazy), FreeType, HarfBuzz (the SDL shell's text shaping, lazy, +built against that FreeType), MuPDF (`-Dmupdf`, on by default everywhere but the web and the board, lazy), ZLS, mvzr (the regex engine behind `s`/`S`), zig-tree-sitter with 29 grammars for 28 languages (markdown takes two, block and inline) — all pinned through `zig fetch` and wired in `build.zig`. The board's @@ -2041,7 +2042,8 @@ tap-LOOK/drag-scroll, but finger-down on a tagline or a one-cell-tolerant pane separator latches to a left-mouse gesture for its lifetime, keeping layout drags out of the scroll heuristic. Touch input translation and scroll/tap state live entirely in the JavaScript shell. -The native SDL shell uses a FreeType light-hinted grayscale atlas over the SDL GPU API (SPIR-V). +The native SDL shell uses a FreeType light-hinted grayscale atlas over the SDL GPU API (SPIR-V), +with words shaped by HarfBuzz so a font's ligatures span their cells. The browser exposes each cell as selectable, inspectable text and applies the surface styles with CSS. The browser `.snap` harness drives real Chromium touch input and reads both text and per-cell styles from the DOM renderer's packed diff --git a/src/gui/font.c b/src/gui/font.c index 5ea595f9..5cb98e1a 100644 --- a/src/gui/font.c +++ b/src/gui/font.c @@ -1,9 +1,14 @@ -// FreeType wrapper for gui.zig. The policy intentionally follows Ghostty's -// FreeType backend: native hinting enabled, the auto-hinter available as a -// fallback, and the light target for shape-preserving grayscale text. +// FreeType and HarfBuzz wrapper for gui.zig. The policy intentionally follows +// Ghostty's FreeType backend: native hinting enabled, the auto-hinter available +// as a fallback, and the light target for shape-preserving grayscale text. +// HarfBuzz only picks glyphs (liga, calt); the grid, not the font's advances, +// places them. #include "font.h" #include #include +#include +#include +#include #include #include @@ -12,6 +17,22 @@ struct UIFont { FT_Library library; FT_Face face; FT_F26Dot6 size; + // The charmap's answer for ASCII, which is most of every screen: a word the + // renderer has not seen before looks up each of its cells. + uint32_t ascii[128]; + // HarfBuzz state, made by the first ui_font_substitutes question (most + // fallback faces are never asked). + hb_font_t *hb; + hb_buffer_t *buffer; + FT_F26Dot6 hb_size; + // Every glyph a lookup of a ligature feature could replace. Nothing else + // can change a glyph, so a cell outside it is its nominal glyph without + // shaping: every cell, in a font without ligatures. + hb_set_t *substitutes; + // ui_font_shape's per-cell scratch, grown to the longest run seen + uint32_t *own; + uint8_t *state; + int32_t scratch; }; static FT_F26Dot6 size_26_6(float px) { @@ -58,9 +79,33 @@ UIFont *ui_font_new(const uint8_t *data, int32_t len) { // Some symbol fonts do not expose a Unicode charmap. FreeType already // selects a usable default for those, so failure here is non-fatal. (void)FT_Select_Charmap(f->face, FT_ENCODING_UNICODE); + for (uint32_t cp = 0; cp < 128; cp++) + f->ascii[cp] = FT_Get_Char_Index(f->face, cp); return f; } +// HarfBuzz reads this same face (and its charmap) through FreeType, so shaping +// and rasterizing agree on glyph ids. None of these calls returns NULL: a +// failure is an inert empty object, and shaping then yields nominal glyphs. +static void start_harfbuzz(UIFont *f) { + f->hb = hb_ft_font_create_referenced(f->face); + f->buffer = hb_buffer_create(); + f->substitutes = hb_set_create(); + static const hb_tag_t features[] = { + HB_TAG('l', 'i', 'g', 'a'), HB_TAG('c', 'a', 'l', 't'), + HB_TAG('c', 'l', 'i', 'g'), HB_TAG('r', 'l', 'i', 'g'), + HB_TAG('r', 'c', 'l', 't'), HB_TAG_NONE}; + hb_face_t *face = hb_font_get_face(f->hb); + hb_set_t *lookups = hb_set_create(); + hb_ot_layout_collect_lookups(face, HB_OT_TAG_GSUB, NULL, NULL, features, + lookups); + hb_codepoint_t lookup = HB_SET_VALUE_INVALID; + while (hb_set_next(lookups, &lookup)) + hb_ot_layout_lookup_collect_glyphs(face, HB_OT_TAG_GSUB, lookup, NULL, + f->substitutes, NULL, NULL); + hb_set_destroy(lookups); +} + const char *ui_font_name(UIFont *f) { if (!f || !f->face) return NULL; @@ -72,29 +117,31 @@ const char *ui_font_name(UIFont *f) { return NULL; } -int ui_font_has_glyph(UIFont *f, int32_t cp) { +uint32_t ui_font_glyph(UIFont *f, int32_t cp) { if (!f || cp < 0) return 0; - return FT_Get_Char_Index(f->face, (FT_ULong)(uint32_t)cp) != 0; + if (cp < 128) + return f->ascii[cp]; + return FT_Get_Char_Index(f->face, (FT_ULong)(uint32_t)cp); } void ui_font_free(UIFont *f) { if (!f) return; + // The HarfBuzz font holds a reference on the face: release it first. (All + // three accept NULL, a face that never shaped.) + hb_set_destroy(f->substitutes); + hb_buffer_destroy(f->buffer); + hb_font_destroy(f->hb); if (f->face) FT_Done_Face(f->face); if (f->library) FT_Done_FreeType(f->library); + free(f->own); + free(f->state); free(f); } -float ui_font_scale_for_height(UIFont *f, float px) { - (void)f; - // Kept as a size token so the Zig renderer can continue to distinguish - // measurement size from high-DPI raster size. - return px; -} - void ui_font_cell_metrics(UIFont *f, float px, int32_t *cell_w, int32_t *cell_h, int32_t *ascent) { if (!f || !cell_w || !cell_h || !ascent || !set_size(f, px)) { @@ -127,18 +174,17 @@ void ui_font_cell_metrics(UIFont *f, float px, int32_t *cell_w, int32_t *cell_h, *ascent = asc > 0 ? asc : 1; } -static int raster(UIFont *f, float px, int32_t cp, int bold, uint8_t *out, - int32_t stride, int32_t cell_w, int32_t cell_h, - int32_t ascent, int centered) { - if (!f || !out || stride < cell_w || cell_w <= 0 || cell_h <= 0) +static int raster(UIFont *f, float px, uint32_t glyph_index, int bold, + uint8_t *out, int32_t stride, int32_t width, int32_t height, + int32_t cell_x, int32_t cell_w, int32_t ascent, + int centered) { + if (!f || !out || stride < width || width <= 0 || height <= 0) return 0; - for (int y = 0; y < cell_h; y++) - memset(out + (size_t)y * (size_t)stride, 0, (size_t)cell_w); + for (int y = 0; y < height; y++) + memset(out + (size_t)y * (size_t)stride, 0, (size_t)width); if (!set_size(f, px)) return 0; - const FT_UInt glyph_index = - FT_Get_Char_Index(f->face, (FT_ULong)(uint32_t)cp); if (FT_Load_Glyph(f->face, glyph_index, load_flags()) != 0) return 0; if (bold) { @@ -168,23 +214,24 @@ static int raster(UIFont *f, float px, int32_t cp, int bold, uint8_t *out, const int advance = ceil_26_6(glyph->advance.x); // Fallbacks may be proportional. Center their advance in the primary face's // fixed cell, exactly as Ghostty centers a narrower fallback face. - const int gx = centered ? (cell_w - (int)bitmap->width) / 2 - : glyph->bitmap_left + (cell_w - advance) / 2; - const int gy = centered ? (cell_h - (int)bitmap->rows) / 2 - : ascent - glyph->bitmap_top; + const int gx = centered + ? (width - (int)bitmap->width) / 2 + : cell_x + glyph->bitmap_left + (cell_w - advance) / 2; + const int gy = + centered ? (height - (int)bitmap->rows) / 2 : ascent - glyph->bitmap_top; const int pitch = bitmap->pitch; const int row_bytes = pitch < 0 ? -pitch : pitch; for (unsigned int y = 0; y < bitmap->rows; y++) { const int dy = gy + (int)y; - if (dy < 0 || dy >= cell_h) + if (dy < 0 || dy >= height) continue; const unsigned int source_y = pitch < 0 ? bitmap->rows - 1 - y : y; const uint8_t *src = bitmap->buffer + (size_t)source_y * (size_t)row_bytes; for (unsigned int x = 0; x < bitmap->width; x++) { const int dx = gx + (int)x; - if (dx < 0 || dx >= cell_w) + if (dx < 0 || dx >= width) continue; uint8_t coverage; @@ -204,14 +251,186 @@ static int raster(UIFont *f, float px, int32_t cp, int bold, uint8_t *out, return 1; } -int ui_font_raster(UIFont *f, float px, int32_t cp, int bold, uint8_t *out, - int32_t stride, int32_t cell_w, int32_t cell_h, - int32_t ascent) { - return raster(f, px, cp, bold, out, stride, cell_w, cell_h, ascent, 0); +int ui_font_raster(UIFont *f, float px, uint32_t glyph, int bold, uint8_t *out, + int32_t stride, int32_t width, int32_t height, + int32_t cell_x, int32_t cell_w, int32_t ascent) { + return raster(f, px, glyph, bold, out, stride, width, height, cell_x, cell_w, + ascent, 0); } -int ui_font_raster_centered(UIFont *f, float px, int32_t cp, int bold, +int ui_font_raster_centered(UIFont *f, float px, uint32_t glyph, int bold, uint8_t *out, int32_t stride, int32_t width, int32_t height) { - return raster(f, px, cp, bold, out, stride, width, height, 0, 1); + return raster(f, px, glyph, bold, out, stride, width, height, 0, width, 0, 1); +} + +// The horizontal ink of `glyph` placed as ui_font_raster places it in a cell +// `cell` wide (26.6), relative to the cell's left edge. 0 when it has no ink. +static int ink(UIFont *f, uint32_t glyph, FT_Pos cell, FT_Pos *left, + FT_Pos *right) { + if (FT_Load_Glyph(f->face, glyph, load_flags()) != 0) + return 0; + const FT_GlyphSlot slot = f->face->glyph; + if (slot->metrics.width <= 0 || slot->metrics.height <= 0) + return 0; + const FT_Pos origin = + (FT_Pos)(((int)(cell >> 6) - ceil_26_6(slot->advance.x)) / 2) * 64; + *left = origin + slot->metrics.horiBearingX; + *right = *left + slot->metrics.width; + return 1; +} + +// ui_font_shape's per-cell marks: no glyph of its own, keep the nominal glyph, +// drawn as a slice of another cell's glyph. +#define NONE UINT32_MAX +#define PLAIN 1 +#define CLAIMED 2 + +int ui_font_substitutes(UIFont *f, uint32_t glyph) { + if (!f) + return 0; + if (!f->hb) + start_harfbuzz(f); + return hb_set_has(f->substitutes, glyph); +} + +// The GSUB features shaping leaves on are the ligature ones; the others +// HarfBuzz would apply (glyph composition, local forms, fractions around +// U+2044, ...) are off, so a cell is either its nominal glyph, as the renderer +// always drew it, or part of a ligature. Positioning is untouched: the grid +// ignores advances and keeps nominal glyphs where marks would move. +static const hb_feature_t shaping_features[] = { + {HB_TAG('c', 'c', 'm', 'p'), 0, 0, (unsigned int)-1}, + {HB_TAG('l', 'o', 'c', 'l'), 0, 0, (unsigned int)-1}, + {HB_TAG('r', 'v', 'r', 'n'), 0, 0, (unsigned int)-1}, + {HB_TAG('l', 't', 'r', 'a'), 0, 0, (unsigned int)-1}, + {HB_TAG('l', 't', 'r', 'm'), 0, 0, (unsigned int)-1}, + {HB_TAG('r', 'a', 'n', 'd'), 0, 0, (unsigned int)-1}, + {HB_TAG('f', 'r', 'a', 'c'), 0, 0, (unsigned int)-1}, + {HB_TAG('n', 'u', 'm', 'r'), 0, 0, (unsigned int)-1}, + {HB_TAG('d', 'n', 'o', 'm'), 0, 0, (unsigned int)-1}, +}; + +void ui_font_shape(UIFont *f, float px, int32_t cell_w, const uint32_t *cps, + int32_t n, UIShapedCell *out) { + if (!f || !cps || !out || n <= 0) + return; + for (int32_t i = 0; i < n; i++) + out[i] = (UIShapedCell){ui_font_glyph(f, (int32_t)cps[i]), 0, 1, 0}; + if (!f->hb) + start_harfbuzz(f); + int substitutable = 0; + for (int32_t i = 0; i < n && !substitutable; i++) + substitutable = hb_set_has(f->substitutes, out[i].glyph); + if (!substitutable || cell_w <= 0 || !set_size(f, px)) + return; + if (n > f->scratch) { + uint32_t *own = (uint32_t *)realloc(f->own, (size_t)n * sizeof *own); + if (!own) + return; + f->own = own; + uint8_t *state = (uint8_t *)realloc(f->state, (size_t)n); + if (!state) + return; + f->state = state; + f->scratch = n; + } + // hb-ft reads the FreeType size when told; positions are only consulted + // for being nonzero, but a zero scale would hide exactly that. + if (f->hb_size != f->size) { + hb_ft_font_changed(f->hb); + f->hb_size = f->size; + } + hb_buffer_clear_contents(f->buffer); + // One codepoint per cell, so a cluster value IS a cell index. + hb_buffer_add_codepoints(f->buffer, cps, n, 0, n); + hb_buffer_set_direction(f->buffer, HB_DIRECTION_LTR); + hb_buffer_guess_segment_properties(f->buffer); + hb_shape(f->hb, f->buffer, shaping_features, + sizeof shaping_features / sizeof shaping_features[0]); + unsigned int count = 0; + const hb_glyph_info_t *info = hb_buffer_get_glyph_infos(f->buffer, &count); + const hb_glyph_position_t *pos = + hb_buffer_get_glyph_positions(f->buffer, &count); + + // Each cell's own glyph is the one HarfBuzz left in its cluster. A cell a + // ligature merged into an earlier cluster has NONE. A cluster the grid + // cannot place (several glyphs, a positioned mark) is PLAIN, and so are the + // cells merged into it: they keep their nominal glyphs. + uint32_t *own = f->own; + uint8_t *state = f->state; + for (int32_t i = 0; i < n; i++) { + own[i] = NONE; + state[i] = 0; + } + for (unsigned int k = 0; k < count; k++) { + const uint32_t cluster = info[k].cluster; + if (cluster >= (uint32_t)n) + continue; + if (own[cluster] != NONE || pos[k].x_offset != 0 || pos[k].y_offset != 0) + state[cluster] = PLAIN; + else + own[cluster] = info[k].codepoint; + } + for (int32_t i = 1; i < n; i++) + if (own[i] == NONE && (state[i - 1] & PLAIN)) + state[i] = PLAIN; + + // A substituted glyph (or one whose cluster swallowed cells) may reach over + // its neighbours: it claims those that draw nothing of their own, nearest + // first, and each draws its slice of the one strip. Ink past a cell edge by + // half a pixel or less is noise. + const FT_Pos cell = (FT_Pos)cell_w * 64; + for (int32_t i = 0; i < n; i++) { + if ((state[i] & (PLAIN | CLAIMED)) || own[i] == NONE) + continue; + int32_t merged = 0; + while (i + 1 + merged < n && own[i + 1 + merged] == NONE && + !(state[i + 1 + merged] & PLAIN)) + merged++; + if (own[i] == out[i].glyph && merged == 0) + continue; + FT_Pos left = 0, right = 0; + if (!ink(f, own[i], cell, &left, &right)) + continue; // a spacer: claimed, never claiming + int32_t want_left = + left < -32 ? (int32_t)((-left - 32 + cell - 1) / cell) : 0; + int32_t want_right = right > cell + 32 + ? (int32_t)((right - cell - 32 + cell - 1) / cell) + : 0; + if (want_right < merged) + want_right = merged; + int32_t lead = 0, trail = 0; + while (lead < want_left && 1 + lead + trail < UI_MAX_SPAN) { + const int32_t j = i - lead - 1; + FT_Pos l, r; + if (j < 0 || (state[j] & (PLAIN | CLAIMED)) || + (own[j] != NONE && + (own[j] == out[j].glyph || ink(f, own[j], cell, &l, &r)))) + break; + lead++; + } + while (trail < want_right && 1 + lead + trail < UI_MAX_SPAN) { + const int32_t j = i + trail + 1; + FT_Pos l, r; + if (j >= n || (state[j] & (PLAIN | CLAIMED)) || + (own[j] != NONE && + (own[j] == out[j].glyph || ink(f, own[j], cell, &l, &r)))) + break; + trail++; + } + for (int32_t j = i - lead; j <= i + trail; j++) { + out[j] = + (UIShapedCell){own[i], (uint8_t)lead, (uint8_t)(1 + lead + trail), + (uint8_t)(j - (i - lead))}; + state[j] |= CLAIMED; + } + } + // The rest draw their own glyph; a merged cell nothing claimed draws blank. + const uint32_t space = f->ascii[' ']; + for (int32_t i = 0; i < n; i++) { + if (state[i] & (PLAIN | CLAIMED)) + continue; + out[i].glyph = own[i] == NONE ? space : own[i]; + } } diff --git a/src/gui/font.h b/src/gui/font.h index 4410bb7c..b38f822a 100644 --- a/src/gui/font.h +++ b/src/gui/font.h @@ -1,6 +1,7 @@ -// Tiny C shim over FreeType, so gui.zig only imports the stable renderer API. -// The implementation owns FreeType's library and face objects and keeps the -// caller's font bytes borrowed for the face lifetime. +// Tiny C shim over FreeType and HarfBuzz, so gui.zig only imports the stable +// renderer API. The implementation owns FreeType's library and face objects +// and HarfBuzz's font and buffer, and keeps the caller's font bytes borrowed +// for the face lifetime. #ifndef UI_FONT_H #define UI_FONT_H #include @@ -20,27 +21,56 @@ UIFont *ui_font_new(const uint8_t *data, int32_t len); // font has no PostScript table. Borrowed for the UIFont lifetime. const char *ui_font_name(UIFont *f); -// Whether the selected Unicode charmap maps `cp` to a real glyph. Glyph zero is -// the face's .notdef box and deliberately does not count for fallback choice. -int ui_font_has_glyph(UIFont *f, int32_t cp); +// The glyph the selected Unicode charmap maps `cp` to. Glyph zero is the +// face's .notdef box: the codepoint is missing, which is what fallback choice +// asks. +uint32_t ui_font_glyph(UIFont *f, int32_t cp); -// The size token is a pixel height. Metrics and rasterization both configure -// FreeType at that size, so hinted advances, baseline and bitmaps stay in step. -float ui_font_scale_for_height(UIFont *f, float px); +// `px` is the pixel height. Metrics and rasterization both configure FreeType +// at that size, so hinted advances, baseline and bitmaps stay in step. void ui_font_cell_metrics(UIFont *f, float px, int32_t *cell_w, int32_t *cell_h, int32_t *ascent); -// Rasterize `cp` into `out` as a hinted grayscale cell mask (`stride` bytes per -// row). The origin is the baseline `ascent` pixels from the top. Pixels outside -// the glyph are zero. Missing codepoints render the face's .notdef glyph. -// `bold` emboldens the outline before rendering (synthetic bold, same advance). -// Returns 1 when the glyph produced coverage, 0 for blank/error. -int ui_font_raster(UIFont *f, float px, int32_t cp, int bold, uint8_t *out, - int32_t stride, int32_t cell_w, int32_t cell_h, - int32_t ascent); +// What one grid cell draws: `slice` of the glyph `glyph` rasterized across +// `span` cells with its own cell `lead` cells from the left. A plain cell is +// its own glyph, lead 0, span 1, slice 0. +typedef struct { + uint32_t glyph; + uint8_t lead; + uint8_t span; + uint8_t slice; +} UIShapedCell; + +// The longest glyph strip a ligature may claim, in cells. +#define UI_MAX_SPAN 8 + +// Whether a lookup of the font's ligature features (liga, calt, clig, rlig, +// rclt) could replace `glyph`. When it cannot, shaping leaves the glyph alone +// and its cell needs no shaping at all. +int ui_font_substitutes(UIFont *f, uint32_t glyph); + +// One cell per codepoint of `cps`, all in this face, shaped by HarfBuzz with +// the font's ligature features (a run with no glyph ui_font_substitutes +// reports comes back nominal without it). A substituted glyph whose ink +// reaches over neighbouring cells that draw nothing of their own (a +// ligature's spacers, or the cells a merged cluster swallowed) claims them as +// a strip. Otherwise, and for anything the grid cannot place (several glyphs +// in one cell, positioned marks), each cell is its nominal glyph. +void ui_font_shape(UIFont *f, float px, int32_t cell_w, const uint32_t *cps, + int32_t n, UIShapedCell *out); + +// Rasterize `glyph` into `out` as a hinted grayscale mask of `width` x +// `height` (`stride` bytes per row). The glyph's advance is centered in the +// `cell_w` pixels that start at `cell_x`, and its baseline is `ascent` pixels +// from the top; ink outside the mask is clipped. `bold` emboldens the outline +// before rendering (synthetic bold, same advance). Returns 1 when the glyph +// produced coverage, 0 for blank/error. +int ui_font_raster(UIFont *f, float px, uint32_t glyph, int bold, uint8_t *out, + int32_t stride, int32_t width, int32_t height, + int32_t cell_x, int32_t cell_w, int32_t ascent); // Center bitmap ink bounds, independent of advance and baseline bearings. -int ui_font_raster_centered(UIFont *f, float px, int32_t cp, int bold, +int ui_font_raster_centered(UIFont *f, float px, uint32_t glyph, int bold, uint8_t *out, int32_t stride, int32_t width, int32_t height); diff --git a/src/gui/gui.zig b/src/gui/gui.zig index 7ad9fe9a..5bcb2867 100644 --- a/src/gui/gui.zig +++ b/src/gui/gui.zig @@ -80,14 +80,22 @@ const p9_arrow_mask = blk: { const atlas_w: u32 = 2048; const atlas_h: u32 = 2048; const Slot = struct { u: u32, v: u32 }; -const GlyphKey = struct { - codepoint: u32, - centered: bool = false, +/// An atlas entry is a glyph of a face (0 the primary font, i the fallback +/// i - 1) at a role's size, drawn `span` cells wide with its own cell `lead` +/// cells in: a ligature is one strip whose cells sample their own slices. +/// Packed, so the atlas map hashes one word instead of walking fields. +const GlyphKey = packed struct(u64) { + face: u8, + glyph: u32, role: pardes.FontRole, decoration: GlyphDecoration = .{}, + centered: bool = false, + lead: u4 = 0, + span: u4 = 1, + _: u2 = 0, }; -const GlyphDecoration = struct { +const GlyphDecoration = packed struct(u5) { bold: bool = false, underline: @FieldType(pardes.CellStyle, "ul") = .off, strikethrough: bool = false, @@ -103,7 +111,7 @@ const GlyphDecoration = struct { }; const TaglineRaster = struct { - scale: f32, + px: f32, width: u32, baseline: i32, height: u32, @@ -111,16 +119,15 @@ const TaglineRaster = struct { fn taglineRaster(font: *c.UIFont, body_px: f32, body_cell_w: u32, body_cell_h: u32, percent: u8) TaglineRaster { const px = body_px * @as(f32, @floatFromInt(percent)) / 100.0; - const scale = c.ui_font_scale_for_height(font, px); var own_w: c_int = 1; var own_h: c_int = 1; var own_ascent: c_int = 1; - c.ui_font_cell_metrics(font, scale, &own_w, &own_h, &own_ascent); + c.ui_font_cell_metrics(font, px, &own_w, &own_h, &own_ascent); const fixed_w: c_int = @intCast(body_cell_w); const fixed_h: c_int = @intCast(body_cell_h); const band_h = std.math.clamp(own_h, 1, fixed_h); return .{ - .scale = scale, + .px = px, .width = @intCast(std.math.clamp(own_w, 1, fixed_w)), .baseline = std.math.clamp(own_ascent, 1, band_h), .height = @intCast(band_h), @@ -227,8 +234,8 @@ test "every font size step moves the cell, and the ends are reachable exactly" { var asc: c_int = 0; var pw: c_int = 0; var ph: c_int = 0; - c.ui_font_cell_metrics(font, c.ui_font_scale_for_height(font, px), &cw, &ch, &asc); - c.ui_font_cell_metrics(font, c.ui_font_scale_for_height(font, px - font_px_step), &pw, &ph, &asc); + c.ui_font_cell_metrics(font, px, &cw, &ch, &asc); + c.ui_font_cell_metrics(font, px - font_px_step, &pw, &ph, &asc); try std.testing.expect(cw > pw and ch > ph); } try std.testing.expectEqual(font_px_max, std.math.clamp(font_px_max + font_px_step, font_px_min, font_px_max)); @@ -238,10 +245,11 @@ test "every font size step moves the cell, and the ends are reachable exactly" { test "FreeType atlas raster is grayscale, bounded, and clears blank cells" { const font = c.ui_font_new(font_ttf.ptr, @intCast(font_ttf.len)).?; defer c.ui_font_free(font); - try std.testing.expectEqual(@as(c_int, 1), c.ui_font_has_glyph(font, 'H')); - try std.testing.expectEqual(@as(c_int, 0), c.ui_font_has_glyph(font, 0x10ffff)); + const h = c.ui_font_glyph(font, 'H'); + try std.testing.expect(h != 0); + try std.testing.expectEqual(@as(u32, 0), c.ui_font_glyph(font, 0x10ffff)); - const size = c.ui_font_scale_for_height(font, 13.0); + const size: f32 = 13.0; var cell_w: c_int = 0; var cell_h: c_int = 0; var ascent: c_int = 0; @@ -253,7 +261,7 @@ test "FreeType atlas raster is grayscale, bounded, and clears blank cells" { var bitmap: [128 * 128]u8 = @splat(0xaa); try std.testing.expectEqual( @as(c_int, 1), - c.ui_font_raster(font, size, 'H', 0, &bitmap, stride, cell_w, cell_h, ascent), + c.ui_font_raster(font, size, h, 0, &bitmap, stride, cell_w, cell_h, 0, cell_w, ascent), ); var ink: usize = 0; @@ -272,7 +280,7 @@ test "FreeType atlas raster is grayscale, bounded, and clears blank cells" { // Synthetic bold thickens the outline inside the same cell. try std.testing.expectEqual( @as(c_int, 1), - c.ui_font_raster(font, size, 'H', 1, &bitmap, stride, cell_w, cell_h, ascent), + c.ui_font_raster(font, size, h, 1, &bitmap, stride, cell_w, cell_h, 0, cell_w, ascent), ); var bold_coverage: usize = 0; for (0..@intCast(cell_h)) |y| { @@ -284,7 +292,7 @@ test "FreeType atlas raster is grayscale, bounded, and clears blank cells" { try std.testing.expectEqual( @as(c_int, 0), - c.ui_font_raster(font, size, ' ', 0, &bitmap, stride, cell_w, cell_h, ascent), + c.ui_font_raster(font, size, c.ui_font_glyph(font, ' '), 0, &bitmap, stride, cell_w, cell_h, 0, cell_w, ascent), ); for (0..@intCast(cell_h)) |y| for (0..@intCast(cell_w)) |x| @@ -314,40 +322,21 @@ test "tagline glyph shrinks into its own cell and stays vertically centered" { const font = c.ui_font_new(font_ttf.ptr, @intCast(font_ttf.len)).?; defer c.ui_font_free(font); - const body_scale = c.ui_font_scale_for_height(font, 27.0); + const body_px: f32 = 27.0; var cell_w: c_int = 1; var cell_h: c_int = 1; var body_ascent: c_int = 1; - c.ui_font_cell_metrics(font, body_scale, &cell_w, &cell_h, &body_ascent); - const tag = taglineRaster(font, 27.0, @intCast(cell_w), @intCast(cell_h), config.gui_tagline_font_percent); - try std.testing.expect(tag.scale < body_scale); + c.ui_font_cell_metrics(font, body_px, &cell_w, &cell_h, &body_ascent); + const tag = taglineRaster(font, body_px, @intCast(cell_w), @intCast(cell_h), config.gui_tagline_font_percent); + try std.testing.expect(tag.px < body_px); try std.testing.expect(tag.width < @as(u32, @intCast(cell_w))); const stride: c_int = 128; var body: [128 * 128]u8 = @splat(0); var tagline: [128 * 128]u8 = @splat(0); - try std.testing.expectEqual(@as(c_int, 1), c.ui_font_raster( - font, - body_scale, - 'H', - 0, - &body, - stride, - cell_w, - cell_h, - body_ascent, - )); - try std.testing.expectEqual(@as(c_int, 1), c.ui_font_raster( - font, - tag.scale, - 'H', - 0, - &tagline, - stride, - @intCast(tag.width), - @intCast(tag.height), - tag.baseline, - )); + const h = c.ui_font_glyph(font, 'H'); + try std.testing.expectEqual(@as(c_int, 1), c.ui_font_raster(font, body_px, h, 0, &body, stride, cell_w, cell_h, 0, cell_w, body_ascent)); + try std.testing.expectEqual(@as(c_int, 1), c.ui_font_raster(font, tag.px, h, 0, &tagline, stride, @intCast(tag.width), @intCast(tag.height), 0, @intCast(tag.width), tag.baseline)); const b = inkBounds(&body, @intCast(stride), @intCast(cell_w), @intCast(cell_h)).?; const t = inkBounds(&tagline, @intCast(stride), @intCast(tag.width), @intCast(tag.height)).?; try std.testing.expect(t.max_x - t.min_x < b.max_x - b.min_x); @@ -367,11 +356,10 @@ test "tagline glyph shrinks into its own cell and stays vertically centered" { test "tagline percentage changes measured band height without body metrics" { const font = c.ui_font_new(font_ttf.ptr, @intCast(font_ttf.len)).?; defer c.ui_font_free(font); - const body_scale = c.ui_font_scale_for_height(font, 27.0); var cell_w: c_int = 1; var cell_h: c_int = 1; var ascent: c_int = 1; - c.ui_font_cell_metrics(font, body_scale, &cell_w, &cell_h, &ascent); + c.ui_font_cell_metrics(font, 27.0, &cell_w, &cell_h, &ascent); const small = taglineRaster(font, 27.0, @intCast(cell_w), @intCast(cell_h), 40); const configured = taglineRaster(font, 27.0, @intCast(cell_w), @intCast(cell_h), 82); const full = taglineRaster(font, 27.0, @intCast(cell_w), @intCast(cell_h), 100); @@ -381,18 +369,17 @@ test "tagline percentage changes measured band height without body metrics" { try std.testing.expect(small.height < configured.height); try std.testing.expect(configured.height <= full.height); try std.testing.expect(full.height <= @as(u32, @intCast(cell_h))); - try std.testing.expectEqual(body_scale, c.ui_font_scale_for_height(font, 27.0)); } test "glyph atlas cache separates body and tagline roles" { var glyphs = std.AutoHashMap(GlyphKey, Slot).init(std.testing.allocator); defer glyphs.deinit(); - try glyphs.put(.{ .codepoint = 'A', .role = .body }, .{ .u = 0, .v = 0 }); - try glyphs.put(.{ .codepoint = 'A', .role = .tagline }, .{ .u = 10, .v = 0 }); - try glyphs.put(.{ .codepoint = 'A', .role = .body, .decoration = .{ .bold = true } }, .{ .u = 20, .v = 0 }); + try glyphs.put(.{ .face = 0, .glyph = 36, .role = .body }, .{ .u = 0, .v = 0 }); + try glyphs.put(.{ .face = 0, .glyph = 36, .role = .tagline }, .{ .u = 10, .v = 0 }); + try glyphs.put(.{ .face = 0, .glyph = 36, .role = .body, .decoration = .{ .bold = true } }, .{ .u = 20, .v = 0 }); try std.testing.expectEqual(@as(usize, 3), glyphs.count()); - try std.testing.expectEqual(@as(u32, 0), glyphs.get(.{ .codepoint = 'A', .role = .body }).?.u); - try std.testing.expectEqual(@as(u32, 10), glyphs.get(.{ .codepoint = 'A', .role = .tagline }).?.u); + try std.testing.expectEqual(@as(u32, 0), glyphs.get(.{ .face = 0, .glyph = 36, .role = .body }).?.u); + try std.testing.expectEqual(@as(u32, 10), glyphs.get(.{ .face = 0, .glyph = 36, .role = .tagline }).?.u); } test "installed Nerd Symbols fallback covers Yazi directory icons" { @@ -408,7 +395,7 @@ test "installed Nerd Symbols fallback covers Yazi directory icons" { defer std.testing.allocator.free(bytes); const face = c.ui_font_new(bytes.ptr, @intCast(bytes.len)) orelse return error.FontInit; defer c.ui_font_free(face); - try std.testing.expectEqual(@as(c_int, 1), c.ui_font_has_glyph(face, 0xe5ff)); + try std.testing.expect(c.ui_font_glyph(face, 0xe5ff) != 0); } const CellInstance = extern struct { @@ -1767,8 +1754,7 @@ const Gui = struct { fallbacks: [max_fallback_fonts]?LoadedFallback = @splat(null), fallback_count: usize = 0, px: f32, - scale: f32, - tagline_scale: f32, + tagline_px: f32, tagline_percent: u8, tagline_width: u32, tagline_height: u32, @@ -1785,6 +1771,7 @@ const Gui = struct { pen_y: u32 = 0, atlas_dirty: bool = true, space_slot: Slot = .{ .u = 0, .v = 0 }, + words: Words = .{}, touch: Touch = .{}, pet_state: pet.State = .{}, @@ -1894,13 +1881,19 @@ fn deinitFallbackFonts(g: *Gui, gpa: std.mem.Allocator) void { } } -fn fontForCodepoint(g: *const Gui, cp: u32) *c.UIFont { - if (c.ui_font_has_glyph(g.font, @intCast(cp)) != 0) return g.font; - for (g.fallbacks[0..g.fallback_count]) |loaded| { - const face = loaded.?.face; - if (c.ui_font_has_glyph(face, @intCast(cp)) != 0) return face; +const FaceGlyph = struct { face: u8, glyph: u32 }; + +/// The face and glyph that draw `cp`, the face as a GlyphKey face: 0 is the +/// primary font and i the fallback i - 1. A codepoint no face has draws the +/// primary's .notdef. +fn glyphForCodepoint(g: *const Gui, cp: u32) FaceGlyph { + const primary = c.ui_font_glyph(g.font, @intCast(cp)); + if (primary != 0) return .{ .face = 0, .glyph = primary }; + for (g.fallbacks[0..g.fallback_count], 1..) |loaded, face| { + const glyph = c.ui_font_glyph(loaded.?.face, @intCast(cp)); + if (glyph != 0) return .{ .face = @intCast(face), .glyph = glyph }; } - return g.font; + return .{ .face = 0, .glyph = 0 }; } const CellLayout = struct { w: f32, h: f32, x_off: f32, y_off: f32 }; @@ -2193,11 +2186,10 @@ fn runNative(init: std.process.Init, opts_in: pardes.Options, attach: ?[]const u return error.FontInit; }; const px: f32 = 27.0; - const scale = c.ui_font_scale_for_height(font, px); var cw: c_int = 10; var chh: c_int = 20; var asc: c_int = 16; - c.ui_font_cell_metrics(font, scale, &cw, &chh, &asc); + c.ui_font_cell_metrics(font, px, &cw, &chh, &asc); const cell_w: u32 = @intCast(@max(cw, 1)); const cell_h: u32 = @intCast(@max(chh, 1)); const tagline = taglineRaster(font, px, cell_w, cell_h, config.gui_tagline_font_percent); @@ -2282,8 +2274,7 @@ fn runNative(init: std.process.Init, opts_in: pardes.Options, attach: ?[]const u .image_capacity = initial_image_capacity, .font = font, .px = px, - .scale = scale, - .tagline_scale = tagline.scale, + .tagline_px = tagline.px, .tagline_percent = config.gui_tagline_font_percent, .tagline_width = tagline.width, .tagline_height = tagline.height, @@ -2305,6 +2296,7 @@ fn runNative(init: std.process.Init, opts_in: pardes.Options, attach: ?[]const u loadFallbackFonts(&g, gpa); defer deinitFallbackFonts(&g, gpa); defer g.glyphs.deinit(); + defer g.words.deinit(gpa); defer { clearNativeImages(&g); g.native_images.deinit(gpa); @@ -2317,8 +2309,7 @@ fn runNative(init: std.process.Init, opts_in: pardes.Options, attach: ?[]const u defer if (g.font_bytes.len != 0) gpa.free(g.font_bytes); // set by Font, if it ran defer c.ui_font_free(g.font); defer gpa.free(g.scroll_edge); // grown on demand by stepScroll - _ = c.ui_font_raster(font, scale, ' ', 0, atlas_stage.ptr, @intCast(atlas_w), @intCast(cell_w), @intCast(cell_h), asc); - g.pen_x = cell_w; + resetGlyphAtlas(&g); if (attach) |requested| return attachRequested(gpa, &g, requested); var attached: ?detached_client.Client = null; @@ -4392,10 +4383,12 @@ fn emitScrollRows(g: *Gui, instances: [*]CellInstance, base: u32, surface: *pard var n: u32 = 0; var row = y0; while (row < y0 + bh) : (row += 1) { + const line = surface.cells[@as(usize, row) * surface.cols ..][0..surface.cols]; + const row_cursor: ?usize = if (surface.cursor) |cu| if (cu.y == row) cu.x else null else null; var col = x0; while (col < x0 + bw) : (col += 1) { const sidx: u32 = @as(u32, row) * surface.cols + col; - emitInstance(g, instances, base + n, col, row, shifted, win_w, win_h, null, cellFontRole(surface.at(col, row)), surface.at(col, row), false, sidx == cursor_idx and !cursor_bar, page); + emitInstance(g, instances, base + n, col, row, shifted, win_w, win_h, null, cellFontRole(surface.at(col, row)), line, col, row_cursor, false, sidx == cursor_idx and !cursor_bar, page); n += 1; } } @@ -4403,7 +4396,7 @@ fn emitScrollRows(g: *Gui, instances: [*]CellInstance, base: u32, surface: *pard const erow: u16 = if (g.scroll_lag > 0) y0 + bh else y0 - 1; var i: u16 = 0; while (i < bw) : (i += 1) { - emitInstance(g, instances, base + n, x0 + i, erow, shifted, win_w, win_h, null, cellFontRole(&g.scroll_edge[i]), &g.scroll_edge[i], false, false, page); + emitInstance(g, instances, base + n, x0 + i, erow, shifted, win_w, win_h, null, cellFontRole(&g.scroll_edge[i]), g.scroll_edge[0..bw], i, null, false, false, page); n += 1; } } @@ -4911,6 +4904,7 @@ fn renderFrame( if (cursor) |value| _ = c.SDL_SetCursor(value); } g.scene_target_failed = false; + g.words.memo = .{}; // positional, and this frame's cells are new const cmd = c.SDL_AcquireGPUCommandBuffer(g.device) orelse return false; var command_consumed = false; defer if (!command_consumed) { @@ -5111,6 +5105,8 @@ fn renderFrame( const cursor_bar = if (surface.cursor) |cu| cu.bar else false; row = 0; while (row < surface.rows) : (row += 1) { + const line = surface.cells[@as(usize, row) * surface.cols ..][0..surface.cols]; + const line_cursor: ?usize = if (surface.cursor) |cu| if (cu.y == row) cu.x else null else null; var col: u16 = 0; while (col < surface.cols) : (col += 1) { if (bodyLayerAt(surface, col, row) != null or tagLayerIn(surface.tagLayers(), col, row) != null) continue; @@ -5134,7 +5130,9 @@ fn renderFrame( win_w, win_h, track, - &surface.previous_cells[logical_idx], + surface.previous_cells[@as(usize, row) * surface.cols ..][0..surface.cols], + col, + null, &tagline_base, paneGripCell(surface.previous_tag_layers, surface.previous_cells, surface.cols, col, row), true, @@ -5153,7 +5151,9 @@ fn renderFrame( win_w, win_h, if (data_effect and !data_diff) null else track, - surface.at(col, row), + line, + col, + line_cursor, &tagline_base, paneGripCell(surface.tagLayers(), surface.cells, surface.cols, col, row), false, @@ -5204,7 +5204,6 @@ fn renderFrame( while (col < surface.cols) : (col += 1) { if (!boxContains(track.contentBox(), col, row)) continue; if (bodyLayerIn(surface.previous_body_layers, col, row) != null or tagLayerIn(surface.previous_tag_layers, col, row) != null) continue; - const logical_idx: u32 = @as(u32, row) * surface.cols + col; const destination: usize = if (duplicate_under) 0 else batch_index; emitSurfaceCell( g, @@ -5217,7 +5216,9 @@ fn renderFrame( win_w, win_h, if (duplicate_under) null else track, - &surface.previous_cells[logical_idx], + surface.previous_cells[@as(usize, row) * surface.cols ..][0..surface.cols], + col, + null, &tagline_base, paneGripCell(surface.previous_tag_layers, surface.previous_cells, surface.cols, col, row), false, @@ -5381,12 +5382,14 @@ test "tagline bands center in their cells and Tagbottom faces the window edge" { try std.testing.expectEqual(@as(u32, 4), taglineBandOffset(9, canvas_h, cell_h, tagline_h)); } -fn resolveCell(g: *Gui, cell: *const pardes.Cell, role: pardes.FontRole, is_cursor: bool, page: Ground) ResolvedCell { +/// The colours and atlas slot of `line[at]`. `cursor` is where the cursor sits +/// in `line`, block or bar: shaping breaks around it. +fn resolveCell(g: *Gui, line: []const pardes.Cell, at: usize, cursor: ?usize, role: pardes.FontRole, is_cursor: bool, page: Ground) ResolvedCell { + const cell = &line[at]; var fg = fg_default; var bg = page.rgb; var clear_bg = page.clear; var reverse = is_cursor; - var blank = false; if (!cell.default) { const st = cell.style; fg = switch (st.fg) { @@ -5409,8 +5412,8 @@ fn resolveCell(g: *Gui, cell: *const pardes.Cell, role: pardes.FontRole, is_curs if (st.invisible) { fg = bg; // With a translucent background, painting bg-colored glyphs at - // full opacity would expose text that the terminal concealed. - blank = true; + // full opacity would expose text that the terminal concealed, so + // cellSlot draws a concealed cell blank. } if (st.dim) for (&fg) |*ch| { ch.* = @intCast(@as(u16, ch.*) * 6 / 10); @@ -5421,10 +5424,8 @@ fn resolveCell(g: *Gui, cell: *const pardes.Cell, role: pardes.FontRole, is_curs clear_bg = false; } - const cp = if (blank) ' ' else cellCodepoint(cell); - const decoration = GlyphDecoration.fromCell(cell); return .{ - .slot = if (cp == ' ' and !decoration.drawsBlank()) g.space_slot else ensureGlyph(g, cp, role, decoration), + .slot = cellSlot(g, line, at, cursor, role), .fg = fg, .bg = bg, .role = role, @@ -5439,10 +5440,11 @@ fn cellFontRole(cell: *const pardes.Cell) pardes.FontRole { test "concealed terminal text emits no ink on opaque or transparent ground" { var g: Gui = undefined; g.space_slot = .{ .u = 0, .v = 0 }; + g.words = .{}; var cell: pardes.Cell = .{ .default = false, .style = .{ .invisible = true, .ul = .single } }; cell.text[0] = 'X'; for ([_]Ground{ .opaqueRgb(bg_default), .{ .rgb = bg_default, .clear = true } }) |page| { - const resolved = resolveCell(&g, &cell, .body, false, page); + const resolved = resolveCell(&g, (&cell)[0..1], 0, null, .body, false, page); try std.testing.expectEqualDeep(g.space_slot, resolved.slot); try std.testing.expectEqual(page.rgb, resolved.bg); } @@ -5512,12 +5514,13 @@ fn emitTagLayer(g: *Gui, instances: [*]CellInstance, next: *u32, layer: *const p // A window is rarely a whole number of cells wide: a band that ends at // the last column runs on through the leftover pixels to the edge. const band_right = if (win_w - right < bw) @max(right, win_w) else right; - emitInstance(g, instances, next.*, 0, layer.viewport.y, .{ .w = band_right - left, .h = bh, .x_off = left, .y_off = slide }, win_w, win_h, track, .body, &background, old_layer, false, page); + emitInstance(g, instances, next.*, 0, layer.viewport.y, .{ .w = band_right - left, .h = bh, .x_off = left, .y_off = slide }, win_w, win_h, track, .body, (&background)[0..1], 0, null, old_layer, false, page); if (slide != 0) clipInstanceTop(&instances[next.*], top, win_h); next.* += 1; + const line_cursor: ?usize = if (layer.cursor) |cu| cu.col else null; for (0..tagLayerCellCount(g, layer)) |col| { const cursor = if (layer.cursor) |cu| show_cursor and !cu.bar and cu.col == col else false; - emitInstance(g, instances, next.*, @intCast(col), layer.viewport.y, .{ .w = tw, .h = bh, .x_off = left, .y_off = slide }, win_w, win_h, track, .tagline, &layer.cells[col], old_layer, cursor, page); + emitInstance(g, instances, next.*, @intCast(col), layer.viewport.y, .{ .w = tw, .h = bh, .x_off = left, .y_off = slide }, win_w, win_h, track, .tagline, layer.cells[0..layer.cols], col, line_cursor, old_layer, cursor, page); clipInstanceRight(&instances[next.*], right, win_w); if (slide != 0) clipInstanceTop(&instances[next.*], top, win_h); next.* += 1; @@ -5579,17 +5582,18 @@ fn emitBodyLayer(g: *Gui, instances: [*]CellInstance, next: *u32, layer: *const if (header) { var background: pardes.Cell = .{ .default = false, .style = layer.cells[index * layer.cols].style }; background.style.font_role = .body; - emitInstance(g, instances, next.*, 0, 0, .{ .w = @as(f32, @floatFromInt(layer.viewport.w)) * bw, .h = height, .x_off = left, .y_off = top }, win_w, win_h, track, .body, &background, old_layer, false, page); + emitInstance(g, instances, next.*, 0, 0, .{ .w = @as(f32, @floatFromInt(layer.viewport.w)) * bw, .h = height, .x_off = left, .y_off = top }, win_w, win_h, track, .body, (&background)[0..1], 0, null, old_layer, false, page); clipBodyInstance(&instances[next.*], bottom, win_h); clipInstanceRight(&instances[next.*], right, win_w); next.* += 1; } + const line = layer.cells[index * layer.cols ..][0..layer.cols]; + const line_cursor: ?usize = if (layer.cursor) |cu| if (cu.y == row) cu.x else null else null; for (0..layer.cols) |col| { if (left + @as(f32, @floatFromInt(col)) * width >= right) break; - const cell = &layer.cells[index * layer.cols + col]; const cursor = if (layer.cursor) |cu| show_cursor and !cu.bar and cu.x == col and cu.y == row else false; const glyph_top = top - (if (header) @as(f32, @floatFromInt(taglineBandOffset(0, win_h, g.cell_h, g.tagline_height))) else 0); - emitInstance(g, instances, next.*, 0, 0, .{ .w = width, .h = height, .x_off = left + @as(f32, @floatFromInt(col)) * width, .y_off = glyph_top }, win_w, win_h, track, role, cell, old_layer, cursor, page); + emitInstance(g, instances, next.*, 0, 0, .{ .w = width, .h = height, .x_off = left + @as(f32, @floatFromInt(col)) * width, .y_off = glyph_top }, win_w, win_h, track, role, line, col, line_cursor, old_layer, cursor, page); clipBodyInstance(&instances[next.*], bottom, win_h); clipInstanceRight(&instances[next.*], right, win_w); next.* += 1; @@ -5601,7 +5605,7 @@ fn emitBodyLayer(g: *Gui, instances: [*]CellInstance, next: *u32, layer: *const .h = 1, .x_off = left, .y_off = top + height - 1, - }, win_w, win_h, track, .body, &border, old_layer, false, page); + }, win_w, win_h, track, .body, (&border)[0..1], 0, null, old_layer, false, page); clipBodyInstance(&instances[next.*], bottom, win_h); clipInstanceRight(&instances[next.*], right, win_w); next.* += 1; @@ -5653,33 +5657,38 @@ fn emitSurfaceCell( win_w: f32, win_h: f32, track: ?pardes.layout.Track, - cell: *const pardes.Cell, + line: []const pardes.Cell, + at: usize, + cursor: ?usize, tagline_base: *const pardes.Cell, grip: ?GripCell, old_layer: bool, is_cursor: bool, page: Ground, ) void { - const role = cellFontRole(cell); + const role = cellFontRole(&line[at]); if (role == .tagline) { var band_base = tagline_base.*; if (core) |p| band_base.style.bg = .{ .rgb = taglineBaseRgb(p, col, row) }; // The smaller font changes the ink, not the chrome's coverage. Painting // this underlay at tagline height leaves page-colored gutters between // adjacent workspace, column and pane tags at TaglineSize < 100. - emitInstance(g, instances, next.*, col, row, body_layout, win_w, win_h, track, .body, &band_base, old_layer, false, page); + emitInstance(g, instances, next.*, col, row, body_layout, win_w, win_h, track, .body, (&band_base)[0..1], 0, null, old_layer, false, page); next.* += 1; // Tag glyphs keep their font size inside a full physical-width grip. - emitInstance(g, instances, next.*, col, row, body_layout, win_w, win_h, track, .tagline, cell, old_layer, is_cursor, page); + emitInstance(g, instances, next.*, col, row, body_layout, win_w, win_h, track, .tagline, line, at, cursor, old_layer, is_cursor, page); // An anchor starts at its column's rule: its left edge is inset by // its top margin so the band frames it on the left as above and // below, and its mark moves right by half that to stay centered. const inset: u32 = if (core) |p| if (std.mem.indexOfScalar(u16, p.col_x[0..p.ncol], col -| (if (grip) |indicator| indicator.offset else 0)) != null) anchorInset(g, row, win_h) else 0 else 0; if (grip) |indicator| { - const cached = cachedGlyph(g, cellCodepoint(indicator.cell), .tagline, GlyphDecoration.fromCell(indicator.cell), true); + // A grip is one glyph centered across the gutter, not text: it is + // looked up by its codepoint's glyph, never shaped. + const drawn = glyphForCodepoint(g, cellCodepoint(indicator.cell)); + const cached = cachedGlyph(g, .{ .face = drawn.face, .glyph = drawn.glyph, .role = .tagline, .decoration = GlyphDecoration.fromCell(indicator.cell), .centered = true }); const slot = cached orelse g.space_slot; const offset: f32 = if (cached != null) @as(f32, @floatFromInt(@as(u32, indicator.offset) * g.cell_w)) - @as(f32, @floatFromInt(inset / 2)) else 0; - const resolved = resolveCell(g, indicator.cell, .tagline, false, page); + const resolved = resolveCell(g, indicator.cell[0..1], 0, null, .tagline, false, page); instances[next.*].fr = @as(f32, @floatFromInt(resolved.fg[0])) / 255; instances[next.*].fg = @as(f32, @floatFromInt(resolved.fg[1])) / 255; instances[next.*].fb = @as(f32, @floatFromInt(resolved.fg[2])) / 255; @@ -5695,7 +5704,7 @@ fn emitSurfaceCell( next.* += 1; return; } - emitInstance(g, instances, next.*, col, row, body_layout, win_w, win_h, track, role, cell, old_layer, is_cursor, page); + emitInstance(g, instances, next.*, col, row, body_layout, win_w, win_h, track, role, line, at, cursor, old_layer, is_cursor, page); next.* += 1; } @@ -5703,6 +5712,7 @@ test "small tagline fonts leave no background gutters between adjacent tags" { const core = try pardes.Pardes.init(std.testing.allocator, .{ .cols = 80, .rows = 24 }); defer core.deinit(); var g: Gui = undefined; + g.words = .{}; g.cell_w = 10; g.cell_h = 20; g.tagline_width = 8; @@ -5713,7 +5723,7 @@ test "small tagline fonts leave no background gutters between adjacent tags" { var next: u32 = 0; for (0..3) |row| { // Column 1: past the anchor's inset edge at the column's left. - emitSurfaceCell(&g, core, &instances, &next, 1, @intCast(row), fixedCellLayout(&g), 800, 480, null, &cell, &cell, null, false, false, Ground.opaqueRgb(bg_default)); + emitSurfaceCell(&g, core, &instances, &next, 1, @intCast(row), fixedCellLayout(&g), 800, 480, null, (&cell)[0..1], 0, null, &cell, null, false, false, Ground.opaqueRgb(bg_default)); const base = instances[row * 2]; const ink = instances[row * 2 + 1]; try std.testing.expectApproxEqAbs(@as(f32, 20.0 / 480.0 * 2), base.y0 - base.y1, 0.0001); @@ -5726,12 +5736,12 @@ test "small tagline fonts leave no background gutters between adjacent tags" { // Column 0 is an anchor's edge: its ink is inset by the band's margin // (2 px here) and its underlay still covers the whole cell. next = 0; - emitSurfaceCell(&g, core, &instances, &next, 0, 1, fixedCellLayout(&g), 800, 480, null, &cell, &cell, null, false, false, Ground.opaqueRgb(bg_default)); + emitSurfaceCell(&g, core, &instances, &next, 0, 1, fixedCellLayout(&g), 800, 480, null, (&cell)[0..1], 0, null, &cell, null, false, false, Ground.opaqueRgb(bg_default)); try std.testing.expectApproxEqAbs(@as(f32, 10.0 / 800.0 * 2), instances[0].x1 - instances[0].x0, 0.0001); try std.testing.expectApproxEqAbs(@as(f32, 8.0 / 800.0 * 2), instances[1].x1 - instances[1].x0, 0.0001); try std.testing.expectApproxEqAbs(@as(f32, 8) / atlas_w, instances[1].u1 - instances[1].u0, 0.0001); next = 0; - emitSurfaceCell(&g, null, &instances, &next, 0, 2, fixedCellLayout(&g), 800, 480, null, &cell, &cell, null, true, false, Ground.opaqueRgb(bg_default)); + emitSurfaceCell(&g, null, &instances, &next, 0, 2, fixedCellLayout(&g), 800, 480, null, (&cell)[0..1], 0, null, &cell, null, true, false, Ground.opaqueRgb(bg_default)); try std.testing.expectEqual(@as(u32, 2), next); try std.testing.expectApproxEqAbs(@as(f32, 16.0 / 480.0 * 2), instances[1].y0 - instances[1].y1, 0.0001); } @@ -5747,12 +5757,14 @@ fn emitInstance( win_h: f32, track: ?pardes.layout.Track, role: pardes.FontRole, - cell: *const pardes.Cell, + line: []const pardes.Cell, + at: usize, + cursor: ?usize, old_layer: bool, is_cursor: bool, page: Ground, ) void { - const resolved = resolveCell(g, cell, role, is_cursor, page); + const resolved = resolveCell(g, line, at, cursor, role, is_cursor, page); const px0 = layout.x_off + @as(f32, @floatFromInt(col)) * layout.w; const visual_h: f32 = if (resolved.role == .tagline) @@ -5818,13 +5830,14 @@ fn emitInstance( test "block cursor alone overrides transparent cell background" { var g: Gui = undefined; + g.words = .{}; g.cell_w = 10; g.cell_h = 20; g.space_slot = .{ .u = 0, .v = 0 }; const cell: pardes.Cell = .{}; var instances: [2]CellInstance = undefined; for ([_]bool{ false, true }, 0..) |cursor, i| { - emitInstance(&g, &instances, @intCast(i), 0, 0, fixedCellLayout(&g), 800, 480, null, .body, &cell, false, cursor, Ground.opaqueRgb(bg_default)); + emitInstance(&g, &instances, @intCast(i), 0, 0, fixedCellLayout(&g), 800, 480, null, .body, (&cell)[0..1], 0, null, false, cursor, Ground.opaqueRgb(bg_default)); try std.testing.expectEqual(cursor, instances[i].effect & opaque_bg_bit != 0); } } @@ -5875,16 +5888,15 @@ fn firstCp(s: []const u8) u32 { } fn refitFont(g: *Gui, core: ?*pardes.Pardes) void { - g.scale = c.ui_font_scale_for_height(g.font, g.px); var cw: c_int = 10; var chh: c_int = 20; var asc: c_int = 16; - c.ui_font_cell_metrics(g.font, g.scale, &cw, &chh, &asc); + c.ui_font_cell_metrics(g.font, g.px, &cw, &chh, &asc); g.cell_w = @intCast(@max(cw, 1)); g.cell_h = @intCast(@max(chh, 1)); g.ascent = @intCast(@max(asc, 1)); const tagline = taglineRaster(g.font, g.px, g.cell_w, g.cell_h, g.tagline_percent); - g.tagline_scale = tagline.scale; + g.tagline_px = tagline.px; g.tagline_width = tagline.width; g.tagline_baseline = tagline.baseline; g.tagline_height = tagline.height; @@ -5899,10 +5911,11 @@ fn refitFont(g: *Gui, core: ?*pardes.Pardes) void { resetScroll(g); } +// The first cell of the cleared atlas stays blank: the space slot. fn resetGlyphAtlas(g: *Gui) void { g.glyphs.clearRetainingCapacity(); + g.words.clear(); @memset(g.atlas_stage, 0); - _ = c.ui_font_raster(g.font, g.scale, ' ', 0, g.atlas_stage.ptr, @intCast(atlas_w), @intCast(g.cell_w), @intCast(g.cell_h), g.ascent); g.space_slot = .{ .u = 0, .v = 0 }; g.pen_x = g.cell_w; g.pen_y = 0; @@ -5914,7 +5927,7 @@ fn syncTaglineFont(g: *Gui, core: *pardes.Pardes) void { if (percent == g.tagline_percent) return; g.tagline_percent = percent; const tagline = taglineRaster(g.font, g.px, g.cell_w, g.cell_h, percent); - g.tagline_scale = tagline.scale; + g.tagline_px = tagline.px; g.tagline_width = tagline.width; g.tagline_baseline = tagline.baseline; g.tagline_height = tagline.height; @@ -5923,14 +5936,294 @@ fn syncTaglineFont(g: *Gui, core: *pardes.Pardes) void { _ = updateCoreResize(core, geom.cols, geom.rows, g.cell_w, g.cell_h, g.tagline_width, g.tagline_height); } -fn ensureGlyph(g: *Gui, cp: u32, role: pardes.FontRole, decoration: GlyphDecoration) Slot { - return cachedGlyph(g, cp, role, decoration, false) orelse g.space_slot; +/// What text draws, so a frame does not work it out again. `cells` is the +/// atlas slot of a codepoint no ligature can touch (`shape_slot` for one that +/// is shaped with its word); `map` is the atlas slot of every cell of a word +/// holding one, found by the word's text. Bounded: past `max_cells` word cells +/// it starts over, and the next frames look up what they show again (the +/// glyphs stay in the atlas). +const Words = struct { + cells: std.AutoHashMapUnmanaged(CellKey, Slot) = .empty, + map: std.AutoHashMapUnmanaged(u64, Word) = .empty, + /// Every word's codepoints and slots, end to end; a Word indexes both. + text: std.ArrayListUnmanaged(u32) = .empty, + slots: std.ArrayListUnmanaged(Slot) = .empty, + shaped: std.ArrayListUnmanaged(c.UIShapedCell) = .empty, + /// The word the last cell was in, so the rest of it costs a compare. It + /// is positional, so every frame forgets it: the cells change under it. + memo: Memo = .{}, + + const max_cells = 1 << 17; + const CellKey = packed struct(u64) { cp: u21, role: pardes.FontRole, decoration: GlyphDecoration, _: u30 = 0 }; + const shape_slot: Slot = .{ .u = std.math.maxInt(u32), .v = std.math.maxInt(u32) }; + const Word = struct { start: u32, len: u32, decoration: GlyphDecoration }; + const Memo = struct { + line: ?[*]const pardes.Cell = null, + len: usize = 0, + start: usize = 0, + end: usize = 0, + cursor: ?usize = null, + slots: usize = 0, + }; + + fn clear(w: *Words) void { + w.cells.clearRetainingCapacity(); + w.map.clearRetainingCapacity(); + w.text.clearRetainingCapacity(); + w.slots.clearRetainingCapacity(); + w.memo = .{}; + } + + fn deinit(w: *Words, gpa: std.mem.Allocator) void { + w.cells.deinit(gpa); + w.map.deinit(gpa); + w.text.deinit(gpa); + w.slots.deinit(gpa); + w.shaped.deinit(gpa); + } +}; + +/// What decides where a word ends, for one cell. A concealed cell is a space. +const WordCell = struct { cp: u32, decoration: GlyphDecoration, role: pardes.FontRole }; + +fn wordCell(cell: *const pardes.Cell) WordCell { + return .{ + .cp = if (!cell.default and cell.style.invisible) ' ' else cellCodepoint(cell), + .decoration = GlyphDecoration.fromCell(cell), + .role = cellFontRole(cell), + }; +} + +/// Whether a word ends between `a`, cell `i`, and `b`, cell `i + 1`: at a +/// space, a decoration or role change, either side of the cursor (Ghostty's +/// rule: the cell being edited shows its own glyph, so a ligature under the +/// cursor comes apart), and inside f|i, f|l and s|t, whose typographic +/// ligatures do not belong on a grid (Ghostty again). Colours never end a +/// word: a ligature spans a syntax colour change or a selection edge, and each +/// cell tints its own slice. +fn wordBreak(a: WordCell, b: WordCell, i: usize, cursor: ?usize) bool { + if (a.cp == ' ' or b.cp == ' ') return true; + if (cursor) |at| if (at == i or at == i + 1) return true; + if (a.role != b.role or !std.meta.eql(a.decoration, b.decoration)) return true; + return (a.cp == 'f' and (b.cp == 'i' or b.cp == 'l')) or (a.cp == 's' and b.cp == 't'); +} + +/// The atlas slot `line[at]` draws: blank for a plain space (or concealed +/// text), its own glyph when no ligature could replace that glyph (every +/// cell, in a font without ligatures), else its slice of the word around it, +/// shaped once and cached by the word's text. The cells of a word being walked +/// cost a compare. Taglines are not shaped: they are drawn at two pitches +/// (tagline_width in a tag layer, a whole cell in the grid), and a strip would +/// not line up in one of them. +fn cellSlot(g: *Gui, line: []const pardes.Cell, at: usize, cursor: ?usize, role: pardes.FontRole) Slot { + const words = &g.words; + const memo = words.memo; + if (memo.line == line.ptr and memo.len == line.len and memo.cursor == cursor and at >= memo.start and at < memo.end and role == .body) + return words.slots.items[memo.slots + at - memo.start]; + var here = wordCell(&line[at]); + // An underlined or struck-out space is a glyph of its own: it draws its line. + if (here.cp == ' ' and !here.decoration.drawsBlank()) return g.space_slot; + const gpa = g.glyphs.allocator; + const cell_key: Words.CellKey = .{ .cp = @intCast(here.cp), .role = role, .decoration = here.decoration }; + const known = words.cells.getOrPut(gpa, cell_key) catch return g.space_slot; + if (!known.found_existing) { + const drawn = glyphForCodepoint(g, here.cp); + const font = if (drawn.face == 0) g.font else g.fallbacks[drawn.face - 1].?.face; + known.value_ptr.* = if (role == .body and c.ui_font_substitutes(font, drawn.glyph) != 0) + Words.shape_slot + else + cachedGlyph(g, .{ .face = drawn.face, .glyph = drawn.glyph, .role = role, .decoration = here.decoration }) orelse g.space_slot; + } + const plain = known.value_ptr.*; + if (!std.meta.eql(plain, Words.shape_slot)) return plain; + + if (words.text.items.len > Words.max_cells) words.clear(); + var start = at; + while (start > 0) { + const before = wordCell(&line[start - 1]); + if (wordBreak(before, here, start - 1, cursor)) break; + start -= 1; + here = before; + } + // The word's text goes on the end of `text`: a new word keeps it there, + // a known one gives it back. + const text_start = words.text.items.len; + var end = start; + while (true) { + words.text.append(gpa, here.cp) catch return g.space_slot; + end += 1; + if (end == line.len) break; + const next = wordCell(&line[end]); + if (wordBreak(here, next, end - 1, cursor)) break; + here = next; + } + const text = words.text.items[text_start..]; + const decoration = here.decoration; + const hash = std.hash.Wyhash.hash(@as(u5, @bitCast(decoration)), std.mem.sliceAsBytes(text)); + if (words.map.get(hash)) |word| { + if (word.len == text.len and std.meta.eql(word.decoration, decoration) and + std.mem.eql(u32, words.text.items[word.start..][0..word.len], text)) + { + words.text.shrinkRetainingCapacity(text_start); + words.memo = .{ .line = line.ptr, .len = line.len, .start = start, .end = end, .cursor = cursor, .slots = word.start }; + return words.slots.items[word.start + at - start]; + } + } + + // A new word (a hash collision takes the map entry over). Runs of one + // face are shaped in that face; fallback faces shape like the primary. + const n = text.len; + words.slots.ensureUnusedCapacity(gpa, n) catch { + words.text.shrinkRetainingCapacity(text_start); + return g.space_slot; + }; + words.shaped.resize(gpa, n) catch { + words.text.shrinkRetainingCapacity(text_start); + return g.space_slot; + }; + const shaped = words.shaped.items; + var run_start: usize = 0; + var face = glyphForCodepoint(g, text[0]).face; + while (run_start < n) { + var run_end = run_start + 1; + var next_face = face; + while (run_end < n) : (run_end += 1) { + next_face = glyphForCodepoint(g, text[run_end]).face; + if (next_face != face) break; + } + const run_font = if (face == 0) g.font else g.fallbacks[face - 1].?.face; + c.ui_font_shape(run_font, g.px, @intCast(g.cell_w), text[run_start..].ptr, @intCast(run_end - run_start), shaped[run_start..].ptr); + for (shaped[run_start..run_end]) |cell| { + const key: GlyphKey = .{ .face = face, .glyph = cell.glyph, .role = .body, .decoration = decoration, .lead = @intCast(cell.lead), .span = @intCast(cell.span) }; + const slot: Slot = if (cachedGlyph(g, key)) |strip| .{ .u = strip.u + g.cell_w * cell.slice, .v = strip.v } else g.space_slot; + words.slots.appendAssumeCapacity(slot); + } + run_start = run_end; + face = next_face; + } + words.map.put(gpa, hash, .{ .start = @intCast(text_start), .len = @intCast(n), .decoration = decoration }) catch {}; + words.memo = .{ .line = line.ptr, .len = line.len, .start = start, .end = end, .cursor = cursor, .slots = text_start }; + return words.slots.items[text_start + at - start]; +} + +/// A Gui that can shape and rasterize `font` at `px`, and nothing else. +fn textTestGui(font: *c.UIFont, px: f32) !Gui { + var g: Gui = undefined; + g.font = font; + g.fallback_count = 0; + g.px = px; + var cw: c_int = 0; + var ch: c_int = 0; + c.ui_font_cell_metrics(font, px, &cw, &ch, &g.ascent); + g.cell_w = @intCast(cw); + g.cell_h = @intCast(ch); + const tag = taglineRaster(font, px, g.cell_w, g.cell_h, 82); + g.tagline_px = tag.px; + g.tagline_width = tag.width; + g.tagline_height = tag.height; + g.tagline_baseline = tag.baseline; + g.atlas_stage = try std.testing.allocator.alloc(u8, atlas_w * atlas_h); + g.glyphs = std.AutoHashMap(GlyphKey, Slot).init(std.testing.allocator); + g.words = .{}; + resetGlyphAtlas(&g); + return g; +} + +fn textTestLine(comptime text: []const u8) [text.len]pardes.Cell { + var line: [text.len]pardes.Cell = @splat(.{ .default = false }); + for (&line, text) |*cell, byte| cell.text[0] = byte; + return line; } -fn cachedGlyph(g: *Gui, cp: u32, role: pardes.FontRole, decoration: GlyphDecoration, centered: bool) ?Slot { - const key: GlyphKey = .{ .codepoint = cp, .role = role, .decoration = decoration, .centered = centered }; - const slot_w = g.cell_w * @as(u32, if (centered) config.GUTTER else 1); +test "a ligature draws across its cells, one slice each, and comes apart under the cursor" { + const bytes = filesystem.readFile(std.testing.allocator, "assets/MapleMono-NF-Regular.ttf") catch return error.SkipZigTest; + defer std.testing.allocator.free(bytes); + const font = c.ui_font_new(bytes.ptr, @intCast(bytes.len)) orelse return error.FontInit; + defer c.ui_font_free(font); + var g = try textTestGui(font, 27); + defer std.testing.allocator.free(g.atlas_stage); + defer g.glyphs.deinit(); + defer g.words.deinit(std.testing.allocator); + + const line = textTestLine("a->b"); + var slots: [4]Slot = undefined; + for (&slots, 0..) |*slot, i| slot.* = cellSlot(&g, &line, i, null, .body); + // `->` is one glyph strip two cells wide: each cell samples its own half. + try std.testing.expectEqual(slots[1].v, slots[2].v); + try std.testing.expectEqual(slots[1].u + g.cell_w, slots[2].u); + var strips: usize = 0; + var it = g.glyphs.iterator(); + while (it.next()) |entry| if (entry.key_ptr.span == 2) { + strips += 1; + try std.testing.expectEqual(@as(u4, 1), entry.key_ptr.lead); + try std.testing.expectEqual(slots[1], entry.value_ptr.*); + }; + try std.testing.expectEqual(@as(usize, 1), strips); + // The arrow runs through the seam: both halves carry ink at it. + const seam = g.atlas_stage[@as(usize, slots[2].v) * atlas_w ..]; + var left_ink: usize = 0; + var right_ink: usize = 0; + for (0..g.cell_h) |y| { + left_ink += seam[y * atlas_w + slots[2].u - 1]; + right_ink += seam[y * atlas_w + slots[2].u]; + } + try std.testing.expect(left_ink > 0 and right_ink > 0); + // `a` and `b` are their plain glyphs. + try std.testing.expectEqual(g.glyphs.get(.{ .face = 0, .glyph = c.ui_font_glyph(font, 'a'), .role = .body }).?, slots[0]); + try std.testing.expectEqual(g.glyphs.get(.{ .face = 0, .glyph = c.ui_font_glyph(font, 'b'), .role = .body }).?, slots[3]); + + // A second line with the same word reuses the shaped slots. + const again = textTestLine("a->b"); + const text_len = g.words.text.items.len; + for (0..4) |i| try std.testing.expectEqual(slots[i], cellSlot(&g, &again, i, null, .body)); + try std.testing.expectEqual(text_len, g.words.text.items.len); + + // The cursor on either half shows plain `-` and `>`. + const plain_minus = cachedGlyph(&g, .{ .face = 0, .glyph = c.ui_font_glyph(font, '-'), .role = .body }).?; + const plain_greater = cachedGlyph(&g, .{ .face = 0, .glyph = c.ui_font_glyph(font, '>'), .role = .body }).?; + for ([_]usize{ 1, 2 }) |cursor| { + try std.testing.expectEqual(plain_minus, cellSlot(&g, &line, 1, cursor, .body)); + try std.testing.expectEqual(plain_greater, cellSlot(&g, &line, 2, cursor, .body)); + } + // A tagline is never shaped. + try std.testing.expectEqual(c.ui_font_glyph(font, '-'), (try glyphKeyAt(&g, cellSlot(&g, &line, 1, null, .tagline))).glyph); +} + +fn glyphKeyAt(g: *Gui, slot: Slot) !GlyphKey { + var it = g.glyphs.iterator(); + while (it.next()) |entry| if (std.meta.eql(entry.value_ptr.*, slot)) return entry.key_ptr.*; + return error.NoGlyph; +} + +test "a font without ligatures draws every cell as its own glyph, exactly as before shaping" { + const font = c.ui_font_new(font_ttf.ptr, @intCast(font_ttf.len)).?; + defer c.ui_font_free(font); + var g = try textTestGui(font, 18); + defer std.testing.allocator.free(g.atlas_stage); + defer g.glyphs.deinit(); + defer g.words.deinit(std.testing.allocator); + const text = "a->b != c => d <= e |> www == :: 0x1F"; + var line = textTestLine(text); + line[3].style.bold = true; // a style change inside a word + var expected: [64 * 64]u8 = undefined; + for (line, 0..) |cell, i| { + if (text[i] == ' ') continue; + const slot = cellSlot(&g, &line, i, null, .body); + const key = try glyphKeyAt(&g, slot); + try std.testing.expectEqual(c.ui_font_glyph(font, text[i]), key.glyph); + try std.testing.expectEqual(@as(u4, 1), key.span); + _ = c.ui_font_raster(font, 18, key.glyph, @intFromBool(cell.style.bold), &expected, 64, @intCast(g.cell_w), @intCast(g.cell_h), 0, @intCast(g.cell_w), g.ascent); + for (0..g.cell_h) |y| + try std.testing.expectEqualSlices(u8, expected[y * 64 ..][0..g.cell_w], g.atlas_stage[(slot.v + y) * atlas_w + slot.u ..][0..g.cell_w]); + } +} + +/// The atlas slot of `key`, rasterized on first use. A strip is `span` cells +/// wide (a grip glyph GUTTER cells, centered); a cell samples its slice of it. +/// Null when the atlas is full. +fn cachedGlyph(g: *Gui, key: GlyphKey) ?Slot { if (g.glyphs.get(key)) |s| return s; + const slot_w = g.cell_w * @as(u32, if (key.centered) config.GUTTER else key.span); if (g.pen_x + slot_w > atlas_w) { g.pen_x = 0; g.pen_y += g.cell_h; @@ -5938,18 +6231,20 @@ fn cachedGlyph(g: *Gui, cp: u32, role: pardes.FontRole, decoration: GlyphDecorat if (g.pen_y + g.cell_h > atlas_h) return null; // atlas full: fall back const s = Slot{ .u = g.pen_x, .v = g.pen_y }; const out = g.atlas_stage.ptr + @as(usize, s.v) * atlas_w + s.u; - const face = fontForCodepoint(g, cp); - const scale = if (role == .tagline) g.tagline_scale else g.scale; - const baseline = if (role == .tagline) g.tagline_baseline else g.ascent; - const raster_w = if (centered) slot_w else if (role == .tagline) g.tagline_width else g.cell_w; - const raster_h = if (role == .tagline) g.tagline_height else g.cell_h; - if (centered) { - _ = c.ui_font_raster_centered(face, scale, @intCast(cp), @intFromBool(decoration.bold), out, @intCast(atlas_w), @intCast(raster_w), @intCast(raster_h)); + const face = if (key.face == 0) g.font else g.fallbacks[key.face - 1].?.face; + const px = if (key.role == .tagline) g.tagline_px else g.px; + const baseline = if (key.role == .tagline) g.tagline_baseline else g.ascent; + const cell_w = if (key.role == .tagline) g.tagline_width else g.cell_w; + const raster_w = if (key.centered) slot_w else cell_w * key.span; + const raster_h = if (key.role == .tagline) g.tagline_height else g.cell_h; + const bold = @intFromBool(key.decoration.bold); + if (key.centered) { + _ = c.ui_font_raster_centered(face, px, key.glyph, bold, out, @intCast(atlas_w), @intCast(raster_w), @intCast(raster_h)); } else { - _ = c.ui_font_raster(face, scale, @intCast(cp), @intFromBool(decoration.bold), out, @intCast(atlas_w), @intCast(raster_w), @intCast(raster_h), baseline); + _ = c.ui_font_raster(face, px, key.glyph, bold, out, @intCast(atlas_w), @intCast(raster_w), @intCast(raster_h), @intCast(cell_w * key.lead), @intCast(cell_w), baseline); } - decorateLine(out, atlas_w, raster_w, raster_h, baseline, decoration); - if (centered) centerGlyphInk(out, raster_w, raster_h); + decorateLine(out, atlas_w, raster_w, raster_h, baseline, key.decoration); + if (key.centered) centerGlyphInk(out, raster_w, raster_h); g.glyphs.put(key, s) catch return null; g.pen_x += slot_w; g.atlas_dirty = true; @@ -5988,23 +6283,25 @@ test "pane indicator cached ink centers bearings styles and sizes" { defer std.testing.allocator.free(g.atlas_stage); g.glyphs = std.AutoHashMap(GlyphKey, Slot).init(std.testing.allocator); defer g.glyphs.deinit(); + g.words = .{}; for ([_]f32{ 13, 27, 40 }) |px| { - g.scale = c.ui_font_scale_for_height(font, px); + g.px = px; var cw: c_int = 0; var ch: c_int = 0; - c.ui_font_cell_metrics(font, g.scale, &cw, &ch, &g.ascent); + c.ui_font_cell_metrics(font, px, &cw, &ch, &g.ascent); g.cell_w = @intCast(cw); g.cell_h = @intCast(ch); for ([_]u8{ 40, 82, 100 }) |percent| { const tag = taglineRaster(font, px, g.cell_w, g.cell_h, percent); g.tagline_width = tag.width; g.tagline_height = tag.height; - g.tagline_scale = tag.scale; + g.tagline_px = tag.px; g.tagline_baseline = tag.baseline; resetGlyphAtlas(&g); try std.testing.expectEqual(@as(usize, 0), g.glyphs.count()); for ([_]u32{ '^', '$', 'j' }) |cp| for ([_]bool{ false, true }) |bold| { - const slot = cachedGlyph(&g, cp, .tagline, .{ .bold = bold }, true).?; + const key: GlyphKey = .{ .face = 0, .glyph = c.ui_font_glyph(font, @intCast(cp)), .role = .tagline, .decoration = .{ .bold = bold }, .centered = true }; + const slot = cachedGlyph(&g, key).?; const bounds = inkBounds(g.atlas_stage[@as(usize, slot.v) * atlas_w + slot.u ..], atlas_w, g.cell_w * config.GUTTER, tag.height).?; const center_x: isize = @intCast(bounds.min_x + bounds.max_x); const center_y: isize = @intCast(bounds.min_y + bounds.max_y); @@ -6012,7 +6309,7 @@ test "pane indicator cached ink centers bearings styles and sizes" { try std.testing.expect(@abs(center_y - @as(isize, @intCast(tag.height - 1))) <= 1); const count = g.glyphs.count(); const pen = g.pen_x; - try std.testing.expectEqualDeep(slot, cachedGlyph(&g, cp, .tagline, .{ .bold = bold }, true).?); + try std.testing.expectEqualDeep(slot, cachedGlyph(&g, key).?); try std.testing.expectEqual(count, g.glyphs.count()); try std.testing.expectEqual(pen, g.pen_x); }; @@ -6020,7 +6317,7 @@ test "pane indicator cached ink centers bearings styles and sizes" { } resetGlyphAtlas(&g); g.pen_y = atlas_h; - try std.testing.expectEqual(@as(?Slot, null), cachedGlyph(&g, '^', .tagline, .{}, true)); + try std.testing.expectEqual(@as(?Slot, null), cachedGlyph(&g, .{ .face = 0, .glyph = c.ui_font_glyph(font, '^'), .role = .tagline, .centered = true })); } test "pane indicator halves share dissolve changes and safe exhausted atlas" { @@ -6040,7 +6337,13 @@ test "pane indicator halves share dissolve changes and safe exhausted atlas" { layers[0].kind = .column; try std.testing.expect(paneGripCell(&layers, &cells, 6, 0, 0) == null); + const font = c.ui_font_new(font_ttf.ptr, @intCast(font_ttf.len)).?; + defer c.ui_font_free(font); var g: Gui = undefined; + g.font = font; + g.fallback_count = 0; + g.px = 20; + g.tagline_px = 16; g.cell_w = 10; g.cell_h = 20; g.tagline_width = 8; @@ -6050,11 +6353,13 @@ test "pane indicator halves share dissolve changes and safe exhausted atlas" { g.pen_y = atlas_h; g.glyphs = std.AutoHashMap(GlyphKey, Slot).init(std.testing.allocator); defer g.glyphs.deinit(); + g.words = .{}; + defer g.words.deinit(std.testing.allocator); for ([_]bool{ false, true }) |old| { var instances: [4]CellInstance = undefined; var next: u32 = 0; for (0..2) |col| { - emitSurfaceCell(&g, null, &instances, &next, @intCast(col), 0, fixedCellLayout(&g), 100, 100, null, &cells[col], &cells[2], .{ .cell = &cells[0], .offset = @intCast(col) }, old, false, Ground.opaqueRgb(bg_default)); + emitSurfaceCell(&g, null, &instances, &next, @intCast(col), 0, fixedCellLayout(&g), 100, 100, null, cells[0..6], col, null, &cells[2], .{ .cell = &cells[0], .offset = @intCast(col) }, old, false, Ground.opaqueRgb(bg_default)); try std.testing.expectEqual(@as(f32, 0), instances[col * 2 + 1].u0); try std.testing.expectEqual(old, instances[col * 2 + 1].effect & old_layer_bit != 0); } @@ -6472,8 +6777,9 @@ test "background opacity retains exact endpoints and percentage precision" { } /// PARDES_TEST_LATENCY trace for an external driver, CLOCK_MONOTONIC ns: -/// `R t` when stdin input is read, `F start fence` per captured frame (present -/// entry, and the GPU fence of that frame). Nothing is written without it. +/// `R t` when stdin input is read, `F start fence submit` per captured frame +/// (present entry, the GPU fence of that frame, and its submission: submit - +/// start is the frame's CPU cost). Nothing is written without it. var latency_fd: c_int = -1; var frame_started_ns: u64 = 0; @@ -6513,11 +6819,12 @@ fn captureFrame(g: *Gui, gpa: std.mem.Allocator, cmd: *c.SDL_GPUCommandBuffer, t c.SDL_DownloadFromGPUTexture(copy, &src, &dst); c.SDL_EndGPUCopyPass(copy); + const submit_ns = monoNs(); const fence = c.SDL_SubmitGPUCommandBufferAndAcquireFence(cmd) orelse return error.GpuSubmit; defer c.SDL_ReleaseGPUFence(g.device, fence); var fences = [_]*c.SDL_GPUFence{fence}; if (!c.SDL_WaitForGPUFences(g.device, true, &fences, 1)) return error.GpuSubmit; - latencyNote("F {d} {d}\n", .{ frame_started_ns, monoNs() }); + latencyNote("F {d} {d} {d}\n", .{ frame_started_ns, monoNs(), submit_ns }); const mapped = c.SDL_MapGPUTransferBuffer(g.device, xfer, false) orelse return error.GpuMap; defer c.SDL_UnmapGPUTransferBuffer(g.device, xfer); @@ -7260,6 +7567,7 @@ fn envU16(env: *std.process.Environ.Map, name: []const u8) ?u16 { test "compact body layer rendering fills recovered rows and clips the final glyph" { var g: Gui = undefined; + g.words = .{}; g.cell_w = 10; g.cell_h = 20; g.tagline_width = 6; @@ -7299,6 +7607,7 @@ test "compact body layer rendering fills recovered rows and clips the final glyp test "compact tag layers fill available width and clip at their physical edge" { var g: Gui = undefined; + g.words = .{}; g.cell_w = 10; g.cell_h = 20; g.tagline_width = 6; diff --git a/src/pardes.zig b/src/pardes.zig index ca2c34a4..f968511a 100644 --- a/src/pardes.zig +++ b/src/pardes.zig @@ -3702,7 +3702,7 @@ pub const CellStyle = struct { reverse: bool = false, invisible: bool = false, strikethrough: bool = false, - ul: enum { off, single, double, curly, dotted, dashed } = .off, + ul: enum(u3) { off, single, double, curly, dotted, dashed } = .off, font_role: FontRole = .body, }; -- cgit v1.3 From a39fb20cb770c3adb911cec7d1f3d033669ed1bb Mon Sep 17 00:00:00 2001 From: Gabriel Schneider Date: Thu, 24 Sep 2026 09:45:50 -0300 Subject: Light a held column grip, and rail its landing beside the rule where the GUI shows it The column grip worked in the GUI but showed nothing anyone could see. Driving the real SDL window with pixel mouse events, press, drag and release all reach the core and reorder or resize the column; the feedback is what failed. The grip kept its muted color while held, and a reorder's insertion rail was drawn in the gutter cell at the destination edge. The GUI paints that cell as the column's scroll rail, and at the window's left edge, the common case of moving the right column first, the dashes were lost in it. From the leftmost column, a drag short of a neighbour's middle shows no rail, rightly, since nothing would move, but nothing said the grip was even held. A held grip now lights in column_box, the accent its muted color is mixed from, and the rail takes that color. The rail runs in the seam cell left of where the column's rule will land, where a border drag's rail runs, for a reorder and a left-edge move alike; at the window's left edge, which has no seam, it runs just past the scroll rail, leaving column 0's grip and pane boxes whole. A carried column's pointer aims at a place, not a word, so the column tags no longer light the word under it, and a release snaps the layout as a border drag's does rather than animating it. The preview and the release both ask layout.columnDrop where the column goes, so the rail stands where the release puts the edge, and the drag no longer carries its unused column index. The GUI test feed takes ESC]777;mouse;;