From af435ba7e4fd34dd5eab17bd21ce535b6f9b8413 Mon Sep 17 00:00:00 2001 From: Gabriel Schneider Date: Tue, 15 Sep 2026 17:44:34 -0300 Subject: Align search and LSP results in groups of eight matches --- docs/config.md | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'docs') diff --git a/docs/config.md b/docs/config.md index 2474c6b0..ffd1fb3f 100644 --- a/docs/config.md +++ b/docs/config.md @@ -159,8 +159,11 @@ LocationsConfig context:5 tscontext:on tslocations:off `on`). Declaration headers use the same muted color as locations, with or without their locations visible. -Result locations are padded so the source text aligns, preserving the source's -indentation. All visible locations start flush left; `n` and `N` still stop on matches. +Result locations share padding in groups of eight matches, so a long path only +widens its own group. Context does not count toward the eight; at group boundaries, +it aligns with the nearer match (ties stay with the preceding group). Source +indentation is preserved. All visible locations start flush left; `n` and `N` +still stop on matches. With `tscontext` enabled, asterisks after a match location show its declaration depth (for example, `main.zig:42 ***`). Ordinary neighboring source lines retain syntax colors; declaration headers do not. -- cgit v1.3 From 0b6bd969ce9982aa7c8b31c38e64034d3d949b8e Mon Sep 17 00:00:00 2001 From: Gabriel Schneider Date: Tue, 15 Sep 2026 18:19:26 -0300 Subject: Mark omitted source after result declaration context with ellipses --- docs/config.md | 2 ++ src/locations.zig | 5 +++++ test/output.zig | 65 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 72 insertions(+) (limited to 'docs') diff --git a/docs/config.md b/docs/config.md index ffd1fb3f..be8a28de 100644 --- a/docs/config.md +++ b/docs/config.md @@ -167,6 +167,8 @@ still stop on matches. With `tscontext` enabled, asterisks after a match location show its declaration 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. 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/src/locations.zig b/src/locations.zig index 43d99005..45d72c57 100644 --- a/src/locations.zig +++ b/src/locations.zig @@ -256,6 +256,11 @@ pub fn format(p: *pardes.Pardes, dir: []const u8, input: []const u8, anchor: ?us try out.writer.writeByte('\t'); const code_start = out.written().len - before; try out.writer.writeAll(row.code); + if (row.declaration and index + 1 < pending.items.len) { + const next = pending.items[index + 1]; + if (std.mem.eql(u8, row.path, next.path) and next.at.line -| row.at.line > 1) + try out.writer.writeAll(" ..."); + } if (index + 1 < pending.items.len or std.mem.endsWith(u8, input, "\n")) try out.writer.writeByte('\n'); const owned_path = try p.gpa.dupe(u8, row.path); errdefer p.gpa.free(owned_path); diff --git a/test/output.zig b/test/output.zig index b0f964ee..128d6ff5 100644 --- a/test/output.zig +++ b/test/output.zig @@ -1269,3 +1269,68 @@ test "result alignment chunks assign boundary context to nearest match with prev } } } + +test "declaration context ellipses mark only final header lines before omitted source" { + if (!pardes.syntax.enabled) return error.SkipZigTest; + const text = "const Outer = struct {\n" ++ + "\n" ++ + " pub fn run(\n" ++ + " value: u32,\n" ++ + " ) void {\n" ++ + " const skipped = 1;\n" ++ + " const Inner = struct {\n" ++ + " pub fn inner(\n" ++ + " input: u32,\n" ++ + " ) void {\n" ++ + " // neighboring source\n" ++ + " _ = input;\n" ++ + " // trailing neighbor\n" ++ + " }\n" ++ + " };\n" ++ + " _ = value;\n" ++ + " }\n" ++ + "};\n"; + for ([_]panes.Output.Origin{ .search, .{ .query = .references } }) |origin| { + for ([_]bool{ false, true }) |visible| { + for ([_]u8{ 0, 1 }) |neighbors| { + const p = try Pardes.init(std.testing.allocator, .{ .tty_only = true }); + defer p.deinit(); + const source = try p.setTestFile(text); + p.gpa.free(source.file.?.path); + source.file.?.path = try p.gpa.dupe(u8, "/ellipsis-context.zig"); + p.locations_config = .{ .context = neighbors, .tscontext = true, .tslocations = visible }; + const input = try std.fmt.allocPrint(p.gpa, "{s}:12:17 {s}\n{s}:16:9 {s}\n", .{ + source.file.?.path, modal.lineSlice(text, 11), source.file.?.path, modal.lineSlice(text, 15), + }); + try panes.Output.fillResults(p, 0, "/", origin, "ellipsis", input, 1); + const file = &p.panes[source.search_pane.?].?.file.?; + var marked: usize = 0; + var matches: usize = 0; + var continuation_lines: usize = 0; + for (file.location_rows, 0..) |row, index| { + const shown = modal.lineSlice(file.content, index); + const original = modal.lineSlice(text, row.at.line - 1); + const expected_mark = row.at.line == 1 or row.at.line == 5 or (neighbors == 0 and row.at.line == 10); + if (expected_mark) { + try std.testing.expect(row.kind == .context and row.declaration); + try std.testing.expectEqualStrings(original, shown[row.code_start .. shown.len - " ...".len]); + try std.testing.expect(std.mem.endsWith(u8, shown, " ...")); + marked += 1; + } else try std.testing.expectEqualStrings(original, shown[row.code_start..]); + if (row.at.line == 4 or row.at.line == 9) continuation_lines += 1; + if (row.kind == .match) { + matches += 1; + try std.testing.expect(row.location_end > 0); + if (row.at.line == 16) try std.testing.expectEqual(index, source.search_row.?); + } else if (row.declaration) { + try std.testing.expectEqual(visible, row.location_end > 0); + } else try std.testing.expectEqual(@as(usize, 0), row.location_end); + } + try std.testing.expectEqual(@as(usize, if (neighbors == 0) 3 else 2), marked); + try std.testing.expectEqual(@as(usize, 2), matches); + try std.testing.expectEqual(@as(usize, 2), continuation_lines); + try std.testing.expectEqualStrings(text, source.file.?.content); + } + } + } +} -- cgit v1.3 From f3a9a1a9005024923f32e1acae5ecd509e9bbfd2 Mon Sep 17 00:00:00 2001 From: Gabriel Schneider Date: Tue, 15 Sep 2026 18:23:06 -0300 Subject: Show result declaration locations only on their first header line --- docs/config.md | 5 +++-- src/locations.zig | 16 +++++++++++----- test/output.zig | 5 ++++- test/panes.zig | 13 ++++++++++--- 4 files changed, 28 insertions(+), 11 deletions(-) (limited to 'docs') diff --git a/docs/config.md b/docs/config.md index be8a28de..202e58d8 100644 --- a/docs/config.md +++ b/docs/config.md @@ -155,8 +155,9 @@ LocationsConfig context:5 tscontext:on tslocations:off locations and keep their code aligned with the matching result. - `tscontext` includes enclosing tree-sitter declaration headers in source order (default `off`). -- `tslocations` shows locations beside those declaration headers (default - `on`). Declaration headers use the same muted color as locations, with or +- `tslocations` shows a location on the first line of each declaration header + (default `on`); continuation lines keep the same alignment without repeating + the location. Declaration headers use the same muted color as locations, with or without their locations visible. Result locations share padding in groups of eight matches, so a long path only diff --git a/src/locations.zig b/src/locations.zig index 45d72c57..34d1ad14 100644 --- a/src/locations.zig +++ b/src/locations.zig @@ -5,6 +5,9 @@ const syntax = @import("syntax.zig"); const filesystem = @import("fs.zig"); pub const Config = @import("locations_config.zig").Config; +const neighbor_context: u8 = 1; +const declaration_context: u8 = 2; +const declaration_start: u8 = 4; /// Legacy marked rows and hidden locations remain recognizable without metadata. /// Visible context locations are flush left and use Row.kind instead. pub fn isContextLine(line: []const u8) bool { @@ -194,24 +197,27 @@ pub fn format(p: *pardes.Pardes, dir: []const u8, input: []const u8, anchor: ?us var context_row = lo; while (context_row <= hi) : (context_row += 1) { if (context_row == row) continue; - wanted[context_row] |= 1; + wanted[context_row] |= neighbor_context; } for (declarations) |declaration| { if (declaration.start_line > row) break; if (declaration.end_line < row) continue; match.depth += 1; var header = declaration.start_line; - while (header <= declaration.header_end_line and header < row) : (header += 1) - wanted[header] |= 2; + while (header <= declaration.header_end_line and header < row) : (header += 1) { + wanted[header] |= declaration_context; + if (header == declaration.start_line) wanted[header] |= declaration_start; + } } } for (wanted, 0..) |kind, row| { if (kind > 0) { const line = source_lines.items[row]; const offset = @intFromPtr(line.ptr) - @intFromPtr(source.ptr); - const declaration = kind & 2 != 0; + const declaration = kind & declaration_context != 0; const colors = if (!declaration and offset + line.len <= source_colors.len) source_colors[offset..][0..line.len] else &.{}; - try appendContext(arena, &pending, path, line, row, declaration, !declaration or !p.locations_config.tslocations, colors); + const hidden = !declaration or !p.locations_config.tslocations or kind & declaration_start == 0; + try appendContext(arena, &pending, path, line, row, declaration, hidden, colors); } } } diff --git a/test/output.zig b/test/output.zig index 128d6ff5..722f2e44 100644 --- a/test/output.zig +++ b/test/output.zig @@ -1323,7 +1323,10 @@ test "declaration context ellipses mark only final header lines before omitted s try std.testing.expect(row.location_end > 0); if (row.at.line == 16) try std.testing.expectEqual(index, source.search_row.?); } else if (row.declaration) { - try std.testing.expectEqual(visible, row.location_end > 0); + const first_line = row.at.line == 1 or row.at.line == 3 or row.at.line == 7 or row.at.line == 8; + try std.testing.expectEqual(visible and first_line, row.location_end > 0); + try std.testing.expectEqualStrings(source.file.?.path, row.path); + if (!first_line) try std.testing.expect(std.mem.indexOf(u8, shown[0..row.code_start], row.path) == null); } else try std.testing.expectEqual(@as(usize, 0), row.location_end); } try std.testing.expectEqual(@as(usize, if (neighbors == 0) 3 else 2), marked); diff --git a/test/panes.zig b/test/panes.zig index da06f692..d844f26e 100644 --- a/test/panes.zig +++ b/test/panes.zig @@ -2322,6 +2322,7 @@ const OutputTests = struct { if (row.kind == .match) { matches += 1; try std.testing.expect(!row.declaration); + try std.testing.expect(row.location_end > 0); const location = panes.Output.location(line); try std.testing.expectEqualStrings(path, location.path); try std.testing.expectEqual(row.at, location.at); @@ -2332,9 +2333,15 @@ const OutputTests = struct { } } else if (row.at.line <= 5) { try std.testing.expect(row.declaration); - try std.testing.expect(row.location_end > 0); - try std.testing.expect(std.mem.startsWith(u8, line, path)); - try std.testing.expectEqualStrings(path, panes.Output.location(line).path); + try std.testing.expectEqualStrings(path, row.path); + if (row.at.line <= 3) { + try std.testing.expect(row.location_end > 0); + try std.testing.expect(std.mem.startsWith(u8, line, path)); + try std.testing.expectEqualStrings(path, panes.Output.location(line).path); + } else { + try std.testing.expectEqual(@as(usize, 0), row.location_end); + try std.testing.expect(std.mem.indexOf(u8, line[0..row.code_start], path) == null); + } } else { try std.testing.expect(!row.declaration); try std.testing.expectEqual(@as(usize, 0), row.location_end); -- cgit v1.3 From 4a3c5a48224cf542429504e8728e10c802e1fd52 Mon Sep 17 00:00:00 2001 From: Gabriel Schneider Date: Tue, 15 Sep 2026 18:27:49 -0300 Subject: Highlight exact source occurrences in LSP references and goto results --- docs/config.md | 3 +++ src/lsp/lsp.zig | 17 ++++++++++++----- src/lsp/lsp_client.zig | 37 +++++++++++++++++++++++++++++-------- src/lsp/lsp_zls.zig | 34 +++++++++++++++++++++++++++++++--- src/main.zig | 2 ++ src/panes.zig | 17 +++++++++++++++-- test/output.zig | 44 ++++++++++++++++++++++++++++++++++++++++++++ 7 files changed, 136 insertions(+), 18 deletions(-) (limited to 'docs') diff --git a/docs/config.md b/docs/config.md index 202e58d8..f369d798 100644 --- a/docs/config.md +++ b/docs/config.md @@ -141,6 +141,9 @@ default tags. Custom tags keep their edits. Location highlighting is enabled by the command that produces a location list. Plain reports, including `LocationsConfig`, keep ordinary text colors even when their text resembles a location. `Mini` keeps its own syntax colors. +LSP references and goto results highlight the exact symbol span supplied by +the server, using the search-result colors. Source indentation is retained so +those byte ranges stay aligned; context and descriptive labels remain unmarked. `LocationsConfig` prints the current settings for Search, Grep and LSP location results in an output pane. Execute the printed line to apply it again, or diff --git a/src/lsp/lsp.zig b/src/lsp/lsp.zig index ca19009a..9dd1da5a 100644 --- a/src/lsp/lsp.zig +++ b/src/lsp/lsp.zig @@ -85,10 +85,15 @@ pub fn row(out: *std.Io.Writer, path: []const u8, line: usize, col: usize, text: // Input positions are zero-based and end-exclusive; displayed spans are one-based and inclusive. pub fn spanRow(out: *std.Io.Writer, path: []const u8, line: usize, col: usize, end_line: usize, end_col: usize, text: []const u8) std.Io.Writer.Error!void { - if (end_line != line or end_col <= col) return row(out, path, line, col, text); - try out.print("{s}:{d}:{d}-{d} {s}\n", .{ - path, line + 1, col + 1, end_col, std.mem.trim(u8, text, " \t\r\n"), - }); + return sourceSpanRow(out, path, line, col, end_line, end_col, std.mem.trim(u8, text, " \t\r\n")); +} + +/// Source bytes keep their indentation and trailing spaces so byte columns +/// still identify the same token in the displayed snippet. +pub fn sourceSpanRow(out: *std.Io.Writer, path: []const u8, line: usize, col: usize, end_line: usize, end_col: usize, text: []const u8) std.Io.Writer.Error!void { + try out.print("{s}:{d}:{d}", .{ path, line + 1, col + 1 }); + if (end_line == line and end_col > col) try out.print("-{d}", .{end_col}); + try out.print(" {s}\n", .{std.mem.trimEnd(u8, text, "\r\n")}); } pub fn edit(out: *std.Io.Writer, start: usize, end: usize) std.Io.Writer.Error!void { @@ -114,9 +119,10 @@ pub fn lineCol(source: []const u8, offset: usize) struct { line: usize, col: usi } test "LSP encoders report every insufficient output capacity" { - const cases = [_]struct { kind: enum { row, span, edit, put }, expected: []const u8 }{ + const cases = [_]struct { kind: enum { row, span, source_span, edit, put }, expected: []const u8 }{ .{ .kind = .row, .expected = "file:1:3 hi\n" }, .{ .kind = .span, .expected = "file:1:3-5 hi\n" }, + .{ .kind = .source_span, .expected = "file:1:3-5 \t hi \t\n" }, .{ .kind = .edit, .expected = "@edit 1 3\n" }, .{ .kind = .put, .expected = "@put 1 3 hé%20%25%0A\n" }, }; @@ -127,6 +133,7 @@ test "LSP encoders report every insufficient output capacity" { const result = switch (case.kind) { .row => row(&out, "file", 0, 2, " hi \n"), .span => spanRow(&out, "file", 0, 2, 0, 5, " hi \n"), + .source_span => sourceSpanRow(&out, "file", 0, 2, 0, 5, "\t hi \t\r\n"), .edit => edit(&out, 1, 3), .put => put(&out, 1, 3, "hé %\n"), }; diff --git a/src/lsp/lsp_client.zig b/src/lsp/lsp_client.zig index 8c6a0da9..c3762f08 100644 --- a/src/lsp/lsp_client.zig +++ b/src/lsp/lsp_client.zig @@ -948,15 +948,13 @@ fn emitRange(cx: *Cx, enc: Enc, uri: []const u8, range: ?std.json.Value, note: [ const col = colBytes(lntext, r.sc, enc); const shown = lsp.rel(cx.base, path); - const rowtext = if (note.len > 0) note else lntext; - if (r.el == r.sl and r.ec > r.sc) { - // spanRow wants the protocol's EXCLUSIVE end as a 1-based inclusive - // byte column; converting the exclusive utf-16 end unit yields the - // exclusive byte column, which is the same number. - const end_col = colBytes(lntext, r.ec, enc); - try lsp.spanRow(cx.out, shown, r.sl, col, r.el, end_col, rowtext); + // A same-line exclusive end byte offset is also the displayed inclusive + // one-based column. Multi-line ranges display only their starting address. + const end_col = if (r.el == r.sl and r.ec > r.sc) colBytes(lntext, r.ec, enc) else col; + if (note.len == 0) { + try lsp.sourceSpanRow(cx.out, shown, r.sl, col, r.el, end_col, lntext); } else { - try lsp.row(cx.out, shown, r.sl, col, rowtext); + try lsp.spanRow(cx.out, shown, r.sl, col, r.el, end_col, note); } cx.rows += 1; } @@ -2208,3 +2206,26 @@ test "the transport this host actually gives us is a pair, and both ends are clo try std.testing.expectEqual(@as(isize, msg.len), libc.read(sv[1], &got, got.len)); try std.testing.expectEqualStrings(msg, got[0..msg.len]); } + +test "LSP source snippets preserve indentation with UTF16 byte ranges and prose stays trimmed" { + const gpa = std.testing.allocator; + const source = "\t const ð�•� = target; \t\r\n"; + for ([_]bool{ false, true }) |multiline| { + var arena: std.heap.ArenaAllocator = .init(gpa); + defer arena.deinit(); + const json = try std.fmt.allocPrint(arena.allocator(), "{{\"start\":{{\"line\":0,\"character\":14}},\"end\":{{\"line\":{d},\"character\":20}}}}", .{@as(u8, if (multiline) 1 else 0)}); + const parsed = try std.json.parseFromSlice(std.json.Value, arena.allocator(), json, .{}); + for ([_]bool{ false, true }) |prose| { + var buffer: [256]u8 = undefined; + var out: std.Io.Writer = .fixed(&buffer); + var cx: Cx = .{ .arena = arena.allocator(), .base = "/", .cur_path = "/file.c", .cur_src = source, .out = &out }; + try emitRange(&cx, .utf16, "file:///file.c", parsed.value, if (prose) " explanatory label \t" else ""); + const expected = try std.fmt.allocPrint(arena.allocator(), "file.c:1:17{s} {s}\n", .{ + if (multiline) "" else "-22", + if (prose) "explanatory label" else "\t const ð�•� = target; \t", + }); + try std.testing.expectEqualStrings(expected, out.buffered()); + try std.testing.expectEqual(@as(usize, 1), cx.rows); + } + } +} diff --git a/src/lsp/lsp_zls.zig b/src/lsp/lsp_zls.zig index 47e6a165..68538125 100644 --- a/src/lsp/lsp_zls.zig +++ b/src/lsp/lsp_zls.zig @@ -512,7 +512,7 @@ fn rowForToken(arena: std.mem.Allocator, base: []const u8, th: Analyser.TokenWit if (th.token >= tree.tokens.len) return; const r = offsets.tokenToRange(tree, th.token, enc); const path = lsp.rel(base, th.handle.uri.toFsPath(arena) catch return); - try lsp.spanRow(out, path, r.start.line, r.start.character, r.end.line, r.end.character, lineAt(tree.source, r.start.line)); + try lsp.sourceSpanRow(out, path, r.start.line, r.start.character, r.end.line, r.end.character, lineAt(tree.source, r.start.line)); } // ---------------------------------------------------------------- goto @@ -667,7 +667,7 @@ fn goto( const t2 = &nd.handle.tree; const rr = offsets.nodeToRange(t2, nd.node, enc); const path = lsp.rel(base, nd.handle.uri.toFsPath(arena) catch continue); - try lsp.spanRow(out, path, rr.start.line, rr.start.character, rr.end.line, rr.end.character, lineAt(t2.source, rr.start.line)); + try lsp.sourceSpanRow(out, path, rr.start.line, rr.start.character, rr.end.line, rr.end.character, lineAt(t2.source, rr.start.line)); }, } } @@ -1165,7 +1165,7 @@ fn references( try lsp.edit(out, at, at + want.len); } else { const r = offsets.tokenToRange(tree, tok, enc); - try lsp.spanRow(out, path, r.start.line, r.start.character, r.end.line, r.end.character, lines.?.line(r.start.line)); + try lsp.sourceSpanRow(out, path, r.start.line, r.start.character, r.end.line, r.end.character, lines.?.line(r.start.line)); } } } @@ -1474,3 +1474,31 @@ test "LSP ZLS rename refuses a partial edit set beyond its row budget" { } } } + +test "LSP source snippets retain native definition and reference indentation" { + const source = "const Outer = struct {\n" ++ + "\t const value: u32 = 1;\n" ++ + "\t fn use() void {\n" ++ + "\t\t_ = value;\n" ++ + "\t }\n" ++ + "};\n"; + const gpa = std.testing.allocator; + for ([_]lsp.Kind{ .definition, .declaration, .references }) |kind| { + var arena: std.heap.ArenaAllocator = .init(gpa); + defer arena.deinit(); + var out: std.Io.Writer.Allocating = .init(gpa); + defer out.deinit(); + try query(gpa, arena.allocator(), .{ + .kind = kind, + .path = "/source-snippet.zig", + .root = "/", + .source = source, + .offset = @intCast(std.mem.lastIndexOf(u8, source, "value").?), + }, &out.writer); + const definition = "source-snippet.zig:2:10-14 \t const value: u32 = 1;\n"; + try std.testing.expectEqualStrings(if (kind == .references) + definition ++ "source-snippet.zig:4:7-11 \t\t_ = value;\n" + else + definition, out.written()); + } +} diff --git a/src/main.zig b/src/main.zig index 2d7b6538..2ee295e1 100644 --- a/src/main.zig +++ b/src/main.zig @@ -379,6 +379,8 @@ test { _ = @import("host_io.zig").Shell; _ = @import("host_io.zig").Lsp; _ = @import("lsp/lsp_client.zig"); + _ = @import("lsp/lsp.zig"); + if (comptime @import("pardes_config").zls_backend) _ = @import("lsp/lsp_zls.zig"); if (comptime pardes.platform == .tty) { _ = @import("tty/tty.zig"); _ = @import("tty/panel_compositor.zig"); diff --git a/src/panes.zig b/src/panes.zig index 315b0b0f..7855866d 100644 --- a/src/panes.zig +++ b/src/panes.zig @@ -2205,12 +2205,16 @@ pub const Output = struct { const source_start = if (metadata) |m| m.code_start else target.code_start; if (source_start >= line.len) return row; if (metadata) |m| if (m.kind == .context) return row; - const is_search = switch (origin) { + const mark_occurrence = switch (origin) { .search => true, .cmd => |cmd| cmd == .Grep, + .query => |kind| switch (kind) { + .definition, .declaration, .type_definition, .implementation, .references => true, + else => false, + }, else => false, }; - if (is_search and spot.col > 0 and spot.end_line == spot.line and + if (mark_occurrence and spot.col > 0 and spot.end_line == spot.line and spot.end_col >= spot.col) { row.mark_start = source_start +| (spot.col - 1); @@ -2243,6 +2247,15 @@ pub const Output = struct { try std.testing.expectEqualStrings("warning:", "src/a.rs:3:5-7 warning: unused"[diagnostic.mark_start..diagnostic.mark_end]); const malformed = rowDecoration(.{ .from = .search }, "src/a.rs:3:99999999999999999999-99999999999999999999 text"); try std.testing.expect(malformed.mark_end <= "src/a.rs:3:99999999999999999999-99999999999999999999 text".len); + const snippet = "src/a.rs:3:14-16 \t\tfoo + 界 + foo"; + for ([_]lsp.Kind{ .definition, .declaration, .type_definition, .implementation, .references }) |kind| { + const occurrence = rowDecoration(.{ .from = .{ .query = kind } }, snippet); + try std.testing.expectEqualStrings("foo", snippet[occurrence.mark_start..occurrence.mark_end]); + } + for ([_]lsp.Kind{ .document_symbols, .workspace_symbols, .completion, .incoming_calls, .outgoing_calls, .supertypes, .subtypes, .rename }) |kind| { + const label = rowDecoration(.{ .from = .{ .query = kind } }, snippet); + try std.testing.expectEqual(@as(usize, 0), label.mark_end); + } } test "plain output does not opt into location decoration" { diff --git a/test/output.zig b/test/output.zig index 722f2e44..ede8e7dd 100644 --- a/test/output.zig +++ b/test/output.zig @@ -1337,3 +1337,47 @@ test "declaration context ellipses mark only final header lines before omitted s } } } + +test "LSP occurrence tint follows the supplied source span through context" { + const snippet = "\tfoo + 界 + foo;"; + const text = "const Box = struct {\n fn run() void {\n" ++ snippet ++ "\n foo();\n }\n};\n"; + for ([_]pardes.lsp.Kind{ .references, .definition }) |kind| { + const p = try Pardes.init(std.testing.allocator, .{ .tty_only = true, .cols = 160, .rows = 40 }); + defer p.deinit(); + const source = try p.setTestFile(text); + p.gpa.free(source.file.?.path); + source.file.?.path = try p.gpa.dupe(u8, "/occurrence.zig"); + p.locations_config = .{ .context = 1, .tscontext = true }; + p.presentation.enabled = false; + var input: std.Io.Writer.Allocating = .init(p.gpa); + defer input.deinit(); + const start = std.mem.lastIndexOf(u8, snippet, "foo").?; + try pardes.lsp.sourceSpanRow(&input.writer, source.file.?.path, 2, start, 2, start + 3, snippet); + try panes.Output.fillResults(p, 0, "/", .{ .query = kind }, "", try input.toOwnedSlice(), 0); + const id = source.search_pane.?; + const file = &p.panes[id].?.file.?; + var matches: usize = 0; + for (file.location_rows, 0..) |row, index| { + if (row.kind != .match) continue; + const line = modal.lineSlice(file.content, index); + try std.testing.expectEqualStrings(snippet, line[row.code_start..]); + try std.testing.expectEqual(start + 1, row.at.col); + try std.testing.expectEqual(start + 3, row.at.end_col); + matches += 1; + } + try std.testing.expectEqual(@as(usize, 1), matches); + pardes.layout.compute(p); + var frame = std.heap.ArenaAllocator.init(p.gpa); + defer frame.deinit(); + const surface = try p.render(frame.allocator()); + const chrome = pardes.ChromeTheme.fromTheme(p.theme()); + var marked: usize = 0; + for (surface.cells) |cell| { + if (!std.meta.eql(cell.style.bg, pardes.Color{ .rgb = chrome.search_bg })) continue; + try std.testing.expect(cell.text[0] == 'f' or cell.text[0] == 'o'); + marked += 1; + } + try std.testing.expectEqual(@as(usize, 3), marked); + try std.testing.expectEqualStrings(text, source.file.?.content); + } +} -- cgit v1.3 From 505dedb2459e7b51cbdb0c066698c6e5596d19dd Mon Sep 17 00:00:00 2001 From: Gabriel Schneider Date: Tue, 15 Sep 2026 18:33:12 -0300 Subject: Bound preceding result context by its outermost tree-sitter declaration --- docs/config.md | 3 ++- src/locations.zig | 16 ++++++++------ test/output.zig | 64 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 75 insertions(+), 8 deletions(-) (limited to 'docs') diff --git a/docs/config.md b/docs/config.md index f369d798..5b5641ba 100644 --- a/docs/config.md +++ b/docs/config.md @@ -157,7 +157,8 @@ LocationsConfig context:5 tscontext:on tslocations:off `0`). Overlapping context is shown once. These neighboring lines omit their locations and keep their code aligned with the matching result. - `tscontext` includes enclosing tree-sitter declaration headers in source - order (default `off`). + order (default `off`). Preceding neighboring context stops at the outermost + enclosing declaration, keeping unrelated lines above it out of the result. - `tslocations` shows a location on the first line of each declaration header (default `on`); continuation lines keep the same alignment without repeating the location. Declaration headers use the same muted color as locations, with or diff --git a/src/locations.zig b/src/locations.zig index 34d1ad14..0f580e34 100644 --- a/src/locations.zig +++ b/src/locations.zig @@ -192,16 +192,11 @@ pub fn format(p: *pardes.Pardes, dir: []const u8, input: []const u8, anchor: ?us for (pending.items[group_start..]) |*match| { const row = match.at.line -| 1; if (row >= count) continue; - const lo = row -| p.locations_config.context; - const hi = @min(count -| 1, row +| p.locations_config.context); - var context_row = lo; - while (context_row <= hi) : (context_row += 1) { - if (context_row == row) continue; - wanted[context_row] |= neighbor_context; - } + var enclosing_start: ?usize = null; for (declarations) |declaration| { if (declaration.start_line > row) break; if (declaration.end_line < row) continue; + enclosing_start = @min(enclosing_start orelse declaration.start_line, declaration.start_line); match.depth += 1; var header = declaration.start_line; while (header <= declaration.header_end_line and header < row) : (header += 1) { @@ -209,6 +204,13 @@ pub fn format(p: *pardes.Pardes, dir: []const u8, input: []const u8, anchor: ?us if (header == declaration.start_line) wanted[header] |= declaration_start; } } + const lo = @max(row -| p.locations_config.context, enclosing_start orelse 0); + const hi = @min(count -| 1, row +| p.locations_config.context); + var context_row = lo; + while (context_row <= hi) : (context_row += 1) { + if (context_row == row) continue; + wanted[context_row] |= neighbor_context; + } } for (wanted, 0..) |kind, row| { if (kind > 0) { diff --git a/test/output.zig b/test/output.zig index ede8e7dd..c162c1d1 100644 --- a/test/output.zig +++ b/test/output.zig @@ -1381,3 +1381,67 @@ test "LSP occurrence tint follows the supplied source span through context" { try std.testing.expectEqualStrings(text, source.file.?.content); } } + +test "result context upper bound stops at earliest enclosing declaration" { + if (!pardes.syntax.enabled) return error.SkipZigTest; + const text = "// unrelated prelude\n" ++ + "const unrelated = 1;\n" ++ + "\n" ++ + "const Outer = struct {\n" ++ + " pub fn run(\n" ++ + " value: u32,\n" ++ + " ) void {\n" ++ + " _ = value;\n" ++ + " }\n" ++ + "};\n" ++ + "// trailing context remains available"; + for ([_]panes.Output.Origin{ .search, .{ .query = .references } }) |origin| { + for ([_]bool{ false, true }) |tscontext| { + for ([_]bool{ false, true }) |visible| { + const p = try Pardes.init(std.testing.allocator, .{ .tty_only = true }); + defer p.deinit(); + const source = try p.setTestFile(text); + p.gpa.free(source.file.?.path); + source.file.?.path = try p.gpa.dupe(u8, "/bounded-context.zig"); + p.locations_config = .{ .context = 100, .tscontext = tscontext, .tslocations = visible }; + const input = try std.fmt.allocPrint(p.gpa, "{s}:8:13 {s}\n", .{ source.file.?.path, modal.lineSlice(text, 7) }); + try panes.Output.fillResults(p, 0, "/", origin, "upper bound", input, 0); + const file = &p.panes[source.search_pane.?].?.file.?; + const first: usize = if (tscontext) 4 else 1; + try std.testing.expectEqual(first, file.location_rows[0].at.line); + try std.testing.expectEqual(@as(usize, 11), file.location_rows[file.location_rows.len - 1].at.line); + try std.testing.expectEqual(@as(usize, 8) - first, source.search_row.?); + var matches: usize = 0; + for (file.location_rows, 0..) |row, index| { + try std.testing.expectEqual(first + index, row.at.line); + try std.testing.expectEqualStrings(modal.lineSlice(text, row.at.line - 1), modal.lineSlice(file.content, index)[row.code_start..]); + if (row.kind == .match) { + try std.testing.expectEqual(@as(usize, 8), row.at.line); + matches += 1; + } + } + try std.testing.expectEqual(@as(usize, 1), matches); + try std.testing.expectEqualStrings(text, source.file.?.content); + } + } + } + + // A top-level comment has no enclosing declaration, and a plain-text + // file has no grammar. Neither should lose its preceding ordinary rows. + for ([_][]const u8{ "/no-ancestor.zig", "/no-grammar.txt" }) |path| { + const p = try Pardes.init(std.testing.allocator, .{ .tty_only = true }); + defer p.deinit(); + const plain = "// first\n// second\n// matched\n// trailing"; + const source = try p.setTestFile(plain); + p.gpa.free(source.file.?.path); + source.file.?.path = try p.gpa.dupe(u8, path); + p.locations_config = .{ .context = 100, .tscontext = true, .tslocations = false }; + const input = try std.fmt.allocPrint(p.gpa, "{s}:3:4 // matched\n", .{path}); + try panes.Output.fillResults(p, 0, "/", .search, "unbounded", input, 0); + const file = &p.panes[source.search_pane.?].?.file.?; + try std.testing.expectEqual(@as(usize, 4), file.location_rows.len); + try std.testing.expectEqual(@as(usize, 1), file.location_rows[0].at.line); + try std.testing.expectEqual(@as(usize, 4), file.location_rows[3].at.line); + try std.testing.expectEqual(@as(usize, 2), source.search_row.?); + } +} -- cgit v1.3 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 --- docs/config.md | 7 ++- src/dump.zig | 2 +- src/locations.zig | 121 +++++++++++++++++++++++++------------ src/locations_config.zig | 8 ++- src/panes.zig | 69 +++++++++++++++++++-- src/pardes.zig | 2 +- src/syntax.zig | 111 ++++++++++++++++++++++------------ test/output.zig | 154 ++++++++++++++++++++++++++++++++++++++++++++--- test/panes.zig | 12 +++- test/pdf.zig | 17 +++++- 10 files changed, 406 insertions(+), 97 deletions(-) (limited to 'docs') diff --git a/docs/config.md b/docs/config.md index 5b5641ba..6f3273b9 100644 --- a/docs/config.md +++ b/docs/config.md @@ -150,7 +150,7 @@ results in an output pane. Execute the printed line to apply it again, or supply just the fields to change: ```text -LocationsConfig context:5 tscontext:on tslocations:off +LocationsConfig context:5 tscontext:on tslocations:off layout:stacked ``` - `context` is the number of source lines above and below each match (default @@ -163,8 +163,11 @@ LocationsConfig context:5 tscontext:on tslocations:off (default `on`); continuation lines keep the same alignment without repeating the location. Declaration headers use the same muted color as locations, with or without their locations visible. +- `layout:stacked` (default) puts each location on its own line, followed by its + source preview. Hidden context locations do not add an empty address line. + Use `layout:inline` to put locations beside the source instead. -Result locations share padding in groups of eight matches, so a long path only +In inline layout, result locations share padding in groups of eight matches, so a long path only widens its own group. Context does not count toward the eight; at group boundaries, it aligns with the nearer match (ties stay with the preceding group). Source indentation is preserved. All visible locations start flush left; `n` and `N` diff --git a/src/dump.zig b/src/dump.zig index 0c538a1a..89abd995 100644 --- a/src/dump.zig +++ b/src/dump.zig @@ -75,7 +75,7 @@ pub const Terminal = struct { }; pub const LocationRow = struct { - kind: enum { match, context }, + kind: enum { match, context, preview }, declaration: bool = false, path: []const u8, line: usize, diff --git a/src/locations.zig b/src/locations.zig index 0f580e34..97caf1d9 100644 --- a/src/locations.zig +++ b/src/locations.zig @@ -15,7 +15,7 @@ pub fn isContextLine(line: []const u8) bool { } pub const Row = struct { - kind: enum { match, context }, + kind: enum { match, context, preview }, declaration: bool = false, path: []u8, at: look.Spot, @@ -44,15 +44,16 @@ pub fn equalRows(a: []const Row, b: []const Row) bool { /// Compare native producer rows with an already formatted, context-free view. /// Identical refreshes retain allocations, syntax and selection state. -pub fn sameInput(input: []const u8, rendered: []const u8, rows: []const Row) bool { +pub fn sameInput(input: []const u8, rendered: []const u8, rows: []const Row, layout: Config.Layout) bool { if (rows.len == 0) return std.mem.eql(u8, input, rendered); - if (std.mem.endsWith(u8, input, "\n") != std.mem.endsWith(u8, rendered, "\n")) return false; var raw_lines = std.mem.splitScalar(u8, input, '\n'); var shown_lines = std.mem.splitScalar(u8, rendered, '\n'); var width: usize = 0; - for (rows, 0..) |row, index| { + var index: usize = 0; + while (index < rows.len) { + const row = rows[index]; if (row.kind != .match) return false; - if (index % alignment_entries == 0) { + if (layout == .@"inline" and index % alignment_entries == 0) { width = 0; var chunk = raw_lines; for (0..alignment_entries) |_| { @@ -64,9 +65,19 @@ pub fn sameInput(input: []const u8, rendered: []const u8, rows: []const Row) boo const raw = raw_lines.next() orelse return false; const shown = shown_lines.next() orelse return false; const target = parseRaw(raw); - if (target.end != row.location_end or row.code_start > shown.len or - !std.mem.eql(u8, raw[0..target.end], shown[0..row.location_end]) or - !std.mem.eql(u8, raw[target.code_start..], shown[row.code_start..])) return false; + if (target.end != row.location_end or row.location_end > shown.len or row.code_start > shown.len or + !std.mem.eql(u8, raw[0..target.end], shown[0..row.location_end])) return false; + if (layout == .stacked) { + if (shown.len != row.location_end or row.code_start != shown.len or index + 1 >= rows.len) return false; + const preview = rows[index + 1]; + if (preview.kind != .preview or preview.location_end != 0 or preview.code_start != 0 or + !std.meta.eql(row.at, preview.at) or !std.mem.eql(u8, row.path, preview.path)) return false; + const code = shown_lines.next() orelse return false; + if (!std.mem.eql(u8, raw[target.code_start..], code)) return false; + index += 2; + continue; + } + if (!std.mem.eql(u8, raw[target.code_start..], shown[row.code_start..])) return false; // A restored result may still have the old pane-wide padding. Do not // let the identical-input shortcut retain that layout when rerun. if (row.code_start <= row.location_end) return false; @@ -74,9 +85,14 @@ pub fn sameInput(input: []const u8, rendered: []const u8, rows: []const Row) boo if (padding.len != width - pardes.panes.File.displayWidth(raw[0..target.end]) + 1 or padding[padding.len - 1] != '\t') return false; for (padding[0 .. padding.len - 1]) |byte| if (byte != ' ') return false; + index += 1; } - if (raw_lines.next()) |tail| if (tail.len != 0) return false; - return raw_lines.next() == null; + const raw_tail = raw_lines.next(); + const shown_tail = shown_lines.next(); + if ((raw_tail == null) != (shown_tail == null)) return false; + if (raw_tail) |tail| if (tail.len != 0) return false; + if (shown_tail) |tail| if (tail.len != 0) return false; + return raw_lines.next() == null and shown_lines.next() == null; } pub const Parsed = struct { @@ -246,44 +262,73 @@ pub fn format(p: *pardes.Pardes, dir: []const u8, input: []const u8, anchor: ?us rows.deinit(p.gpa); } var mapped = anchor; - first = 0; - while (first < pending.items.len) { - const end = alignmentEnd(pending.items, first); - var width: usize = 0; - for (pending.items[first..end]) |row| width = @max(width, labelWidth(row)); - for (pending.items[first..end], first..) |row, index| { - const before = out.written().len; + if (p.locations_config.layout == .stacked) { + for (pending.items, 0..) |row, index| { const context = row.original == null; - try out.writer.writeAll(row.label); - const location_end = if (row.hidden) 0 else out.written().len - before; - if (row.depth > 0) { - try out.writer.writeByte(' '); - try out.writer.splatByteAll('*', row.depth); - } - try out.writer.splatByteAll(' ', width - labelWidth(row)); - try out.writer.writeByte('\t'); - const code_start = out.written().len - before; - try out.writer.writeAll(row.code); - if (row.declaration and index + 1 < pending.items.len) { - const next = pending.items[index + 1]; - if (std.mem.eql(u8, row.path, next.path) and next.at.line -| row.at.line > 1) - try out.writer.writeAll(" ..."); + if (anchor != null and row.original == anchor) mapped = rows.items.len; + if (!row.hidden) { + const before = out.written().len; + try out.writer.writeAll(row.label); + if (row.depth > 0) { + try out.writer.writeByte(' '); + try out.writer.splatByteAll('*', row.depth); + } + try appendMetadata(p.gpa, &rows, row, if (context) .context else .match, row.label.len, out.written().len - before, false); + try out.writer.writeByte('\n'); } + try writeCode(&out.writer, pending.items, index); + try appendMetadata(p.gpa, &rows, row, if (context) .context else .preview, 0, 0, true); if (index + 1 < pending.items.len or std.mem.endsWith(u8, input, "\n")) try out.writer.writeByte('\n'); - const owned_path = try p.gpa.dupe(u8, row.path); - errdefer p.gpa.free(owned_path); - const owned_colors = try p.gpa.dupe(u8, row.colors); - errdefer p.gpa.free(owned_colors); - try rows.append(p.gpa, .{ .kind = if (context) .context else .match, .declaration = row.declaration, .path = owned_path, .at = row.at, .location_end = location_end, .code_start = code_start, .colors = owned_colors }); - if (anchor != null and row.original == anchor) mapped = index; } - first = end; + } else { + first = 0; + while (first < pending.items.len) { + const end = alignmentEnd(pending.items, first); + var width: usize = 0; + for (pending.items[first..end]) |row| width = @max(width, labelWidth(row)); + for (pending.items[first..end], first..) |row, index| { + const before = out.written().len; + const context = row.original == null; + try out.writer.writeAll(row.label); + const location_end = if (row.hidden) 0 else out.written().len - before; + if (row.depth > 0) { + try out.writer.writeByte(' '); + try out.writer.splatByteAll('*', row.depth); + } + try out.writer.splatByteAll(' ', width - labelWidth(row)); + try out.writer.writeByte('\t'); + const code_start = out.written().len - before; + try writeCode(&out.writer, pending.items, index); + if (index + 1 < pending.items.len or std.mem.endsWith(u8, input, "\n")) try out.writer.writeByte('\n'); + try appendMetadata(p.gpa, &rows, row, if (context) .context else .match, location_end, code_start, true); + if (anchor != null and row.original == anchor) mapped = index; + } + first = end; + } } const owned_rows = try rows.toOwnedSlice(p.gpa); errdefer freeRows(p.gpa, owned_rows); return .{ .content = try out.toOwnedSlice(), .rows = owned_rows, .anchor = mapped }; } +fn writeCode(writer: *std.Io.Writer, rows: []const Pending, index: usize) !void { + const row = rows[index]; + try writer.writeAll(row.code); + if (row.declaration and index + 1 < rows.len) { + const next = rows[index + 1]; + if (std.mem.eql(u8, row.path, next.path) and next.at.line -| row.at.line > 1) + try writer.writeAll(" ..."); + } +} + +fn appendMetadata(gpa: std.mem.Allocator, rows: *std.ArrayList(Row), pending: Pending, kind: @FieldType(Row, "kind"), location_end: usize, code_start: usize, source: bool) !void { + const path = try gpa.dupe(u8, pending.path); + errdefer gpa.free(path); + const colors = try gpa.dupe(u8, if (source) pending.colors else &.{}); + errdefer gpa.free(colors); + try rows.append(gpa, .{ .kind = kind, .declaration = pending.declaration, .path = path, .at = pending.at, .location_end = location_end, .code_start = code_start, .colors = colors }); +} + const alignment_entries = 8; /// Keep neighboring context with the nearer match at a chunk boundary. Shared diff --git a/src/locations_config.zig b/src/locations_config.zig index ed67f990..6b23575a 100644 --- a/src/locations_config.zig +++ b/src/locations_config.zig @@ -1,9 +1,11 @@ const std = @import("std"); pub const Config = struct { + pub const Layout = enum { @"inline", stacked }; context: u16 = 0, tscontext: bool = false, tslocations: bool = true, + layout: Layout = .stacked, /// Apply only supplied fields. A malformed token rejects the whole update. /// Repeating a field uses its last supplied value. @@ -20,6 +22,7 @@ pub const Config = struct { @field(result, field.name) = switch (@typeInfo(field.type)) { .bool => if (std.mem.eql(u8, value, "on")) true else if (std.mem.eql(u8, value, "off")) false else return error.ExpectedOnOrOff, .int => std.fmt.parseInt(field.type, value, 10) catch return error.InvalidContext, + .@"enum" => std.meta.stringToEnum(field.type, value) orelse return error.InvalidLayout, else => @compileError("unsupported location setting type"), }; found = true; @@ -38,6 +41,7 @@ pub const Config = struct { switch (@typeInfo(field.type)) { .bool => try writer.writeAll(if (value) "on" else "off"), .int => try writer.print("{d}", .{value}), + .@"enum" => try writer.writeAll(@tagName(value)), else => @compileError("unsupported location setting type"), } } @@ -52,10 +56,11 @@ test "LocationsConfig reflection round trip and partial updates" { var out: std.Io.Writer.Allocating = .init(std.testing.allocator); defer out.deinit(); try config.write(&out.writer); - try std.testing.expectEqualStrings("context:5 tscontext:on tslocations:off", out.written()); + try std.testing.expectEqualStrings("context:5 tscontext:on tslocations:off layout:stacked", out.written()); try std.testing.expectEqual(config, try (Config{}).parse(out.written())); try std.testing.expectEqual(config, try config.parse(" \n\t")); try std.testing.expectEqual(@as(u16, 2), (try config.parse("context:1 context:2")).context); + try std.testing.expectEqual(Config.Layout.@"inline", (try config.parse("layout:inline")).layout); } test "LocationsConfig rejects invalid updates atomically" { @@ -63,6 +68,7 @@ test "LocationsConfig rejects invalid updates atomically" { try std.testing.expectError(error.UnknownLocationSetting, config.parse("context:5 unknown:on")); try std.testing.expectError(error.ExpectedOnOrOff, config.parse("context:5 tscontext:true")); try std.testing.expectError(error.ExpectedKeyValue, config.parse("context")); + try std.testing.expectError(error.InvalidLayout, config.parse("context:5 layout:sideways")); for ([_][]const u8{ "context:", "context:-1", "context:65536", "context:five" }) |input| try std.testing.expectError(error.InvalidContext, config.parse(input)); try std.testing.expectEqual(@as(u16, 3), config.context); diff --git a/src/panes.zig b/src/panes.zig index 7855866d..59993148 100644 --- a/src/panes.zig +++ b/src/panes.zig @@ -1082,6 +1082,11 @@ pub const File = struct { return saved; } + fn sameSavedLocation(a: dump.LocationRow, b: dump.LocationRow) bool { + return std.mem.eql(u8, a.path, b.path) and a.line == b.line and a.col == b.col and + a.end_line == b.end_line and a.end_col == b.end_col; + } + fn restoreLocationRows(gpa: std.mem.Allocator, content: []const u8, saved: []const dump.LocationRow) ![]locations.Row { if (saved.len == 0) return &.{}; if (saved.len > std.mem.count(u8, content, "\n") + 1) return error.InvalidLocationRows; @@ -1095,16 +1100,33 @@ pub const File = struct { gpa.free(rows); } var lines = std.mem.splitScalar(u8, content, '\n'); - for (saved, rows) |row, *out| { + var previous_line: []const u8 = ""; + for (saved, rows, 0..) |row, *out, index| { const line = lines.next() orelse return error.InvalidLocationRows; if (row.path.len == 0 or row.path.len >= 4096 or - row.location_end > row.code_start or row.code_start == 0 or row.code_start > line.len or - line[row.code_start - 1] != '\t' or + row.location_end > row.code_start or row.code_start > line.len or (row.kind == .match and row.location_end == 0) or (row.declaration and row.kind != .context) or row.line > std.math.maxInt(i32) or row.col > std.math.maxInt(i32) or row.end_line > std.math.maxInt(i32) or row.end_col > std.math.maxInt(i32)) return error.InvalidLocationRows; + const inline_row = row.code_start > row.location_end and row.code_start > 0 and line[row.code_start - 1] == '\t'; + const address_row = !inline_row and row.location_end > 0 and row.code_start == line.len; + const source_row = row.location_end == 0 and row.code_start == 0; + if (!inline_row and !address_row and !source_row) return error.InvalidLocationRows; + if (row.kind == .preview) { + if (!source_row or index == 0) return error.InvalidLocationRows; + const previous = saved[index - 1]; + if (previous.kind != .match or previous.location_end == 0 or previous.code_start != previous_line.len or previous_line[previous_line.len - 1] == '\t' or + !sameSavedLocation(previous, row)) return error.InvalidLocationRows; + } + if (address_row) { + if (index + 1 >= saved.len) return error.InvalidLocationRows; + const following = saved[index + 1]; + const expected: @TypeOf(row.kind) = if (row.kind == .match) .preview else .context; + if (following.kind != expected or following.code_start != 0 or following.location_end != 0 or + following.declaration != row.declaration or !sameSavedLocation(row, following)) return error.InvalidLocationRows; + } const code_len = line.len - row.code_start; if (row.colors_b64.len > std.base64.standard.Encoder.calcSize(code_len)) return error.InvalidLocationRows; const colors = try dump.decodeBytes(gpa, row.colors_b64); @@ -1122,6 +1144,7 @@ pub const File = struct { .colors = colors, }; initialized += 1; + previous_line = line; } if (lines.next()) |remaining| if (remaining.len != 0 or lines.next() != null) return error.InvalidLocationRows; return rows; @@ -1149,6 +1172,32 @@ pub const File = struct { try std.testing.expectError(error.InvalidLocationRows, restoreLocationRows(gpa, "| \tx\n", &.{row})); } + test "stacked location metadata requires matching adjacent preview ownership" { + const gpa = std.testing.allocator; + const header = "x.c:2:1-3"; + const content = header ++ "\nfoo\n"; + const match: dump.LocationRow = .{ .kind = .match, .path = "x.c", .line = 2, .col = 1, .end_line = 2, .end_col = 3, .location_end = header.len, .code_start = header.len }; + const preview: dump.LocationRow = .{ .kind = .preview, .path = "x.c", .line = 2, .col = 1, .end_line = 2, .end_col = 3, .location_end = 0, .code_start = 0 }; + const restored = try restoreLocationRows(gpa, content, &.{ match, preview }); + defer locations.freeRows(gpa, restored); + try std.testing.expectEqual(.preview, restored[1].kind); + try std.testing.expectEqual(restored[0].at, restored[1].at); + try std.testing.expectError(error.InvalidLocationRows, restoreLocationRows(gpa, "foo\n", &.{preview})); + try std.testing.expectError(error.InvalidLocationRows, restoreLocationRows(gpa, header ++ "\n", &.{match})); + var inline_match = match; + inline_match.code_start += 1; + try std.testing.expectError(error.InvalidLocationRows, restoreLocationRows(gpa, header ++ "\t\nfoo\n", &.{ inline_match, preview })); + var wrong = preview; + wrong.path = "other.c"; + try std.testing.expectError(error.InvalidLocationRows, restoreLocationRows(gpa, content, &.{ match, wrong })); + wrong = preview; + wrong.line = 3; + try std.testing.expectError(error.InvalidLocationRows, restoreLocationRows(gpa, content, &.{ match, wrong })); + wrong = preview; + wrong.code_start = 1; + try std.testing.expectError(error.InvalidLocationRows, restoreLocationRows(gpa, content, &.{ match, wrong })); + } + pub fn graphemeDisplayWidth(grapheme: []const u8) usize { if (std.mem.eql(u8, grapheme, "\t")) return config.tab_width; if (grapheme.len == 1 and grapheme[0] >= 0x20 and grapheme[0] < 0x7f) return 1; @@ -2258,6 +2307,18 @@ pub const Output = struct { } } + test "stacked empty previews distinguish separators from trailing newlines" { + var path = [_]u8{ 'x', '.', 'c' }; + const rows = [_]locations.Row{ + .{ .kind = .match, .path = &path, .at = .{ .line = 1, .col = 1 }, .location_end = 7, .code_start = 7 }, + .{ .kind = .preview, .path = &path, .at = .{ .line = 1, .col = 1 }, .location_end = 0, .code_start = 0 }, + }; + try std.testing.expect(locations.sameInput("x.c:1:1 ", "x.c:1:1\n", &rows, .stacked)); + try std.testing.expect(locations.sameInput("x.c:1:1 \n", "x.c:1:1\n\n", &rows, .stacked)); + try std.testing.expect(!locations.sameInput("x.c:1:1 ", "x.c:1:1\n\n", &rows, .stacked)); + try std.testing.expect(!locations.sameInput("x.c:1:1 \n", "x.c:1:1\n", &rows, .stacked)); + } + test "plain output does not opt into location decoration" { const report = rowDecoration(.{ .from = .{ .cmd = .LocationsConfig } }, "LocationsConfig context:5 tscontext:on"); try std.testing.expectEqualDeep(RowDecoration{}, report); @@ -2527,7 +2588,7 @@ pub const Output = struct { if (!std.meta.eql(output.from, from)) continue; if (by_arg and !std.mem.eql(u8, output.arg(), arg)) continue; if (!std.mem.eql(u8, std.fs.path.dirname(rf.path) orelse "", dir)) continue; - if (!locations.sameInput(content, rf.content, rf.location_rows)) continue; + if (!locations.sameInput(content, rf.content, rf.location_rows, p.locations_config.layout)) continue; try setArg(output, arg); p.gpa.free(content); p.active = id; 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(); diff --git a/src/syntax.zig b/src/syntax.zig index bd6a64a0..9e31669f 100644 --- a/src/syntax.zig +++ b/src/syntax.zig @@ -630,48 +630,58 @@ pub fn highlightLocationRows(gpa: std.mem.Allocator, content: []const u8, rows: defer gpa.free(code); const colors = try gpa.alloc(u8, content.len); defer gpa.free(colors); - var painted = false; - var row_index: usize = 0; + const SourceRow = struct { index: usize, start: usize, len: usize }; + const sources = try gpa.alloc(SourceRow, rows.len); + defer gpa.free(sources); + var source_count: usize = 0; var offset: usize = 0; - while (row_index < rows.len and offset < content.len) { - const first = row_index; - const group_start = offset; - const selected = (forExt(std.fs.path.extension(rows[first].path)) catch null); - var code_len: usize = 0; - while (row_index < rows.len and offset < content.len) { - const row = rows[row_index]; - if (row_index > first and (!std.mem.eql(u8, row.path, rows[first].path) or - row.at.line != rows[row_index - 1].at.line +| 1)) break; - const end = std.mem.indexOfScalarPos(u8, content, offset, '\n') orelse content.len; - const source_start = offset + @min(row.code_start, end - offset); - if (row_index > first) { - code[code_len] = '\n'; - code_len += 1; - } - @memcpy(code[code_len..][0 .. end - source_start], content[source_start..end]); - code_len += end - source_start; - offset = @min(end + 1, content.len); - row_index += 1; + for (rows, 0..) |row, index| { + if (offset >= content.len) break; + const end = std.mem.indexOfScalarPos(u8, content, offset, '\n') orelse content.len; + const source_start = offset + @min(row.code_start, end - offset); + var address_only = false; + if (comptime @hasField(@TypeOf(row), "location_end")) { + address_only = row.location_end > 0 and source_start == end; } - const language = selected orelse continue; - if (offset > 0 and content[offset - 1] == '\n') { - code[code_len] = '\n'; - code_len += 1; + if (!address_only) { + sources[source_count] = .{ .index = index, .start = source_start, .len = end - source_start }; + source_count += 1; } - if (code_len == 0) continue; - @memset(colors[0..code_len], 0); - paint(colors[0..code_len], code[0..code_len], language); - painted = true; - var target = group_start; - var source_offset: usize = 0; - for (rows[first..row_index]) |row| { - const end = std.mem.indexOfScalarPos(u8, content, target, '\n') orelse content.len; - const source_start = target + @min(row.code_start, end - target); - const len = end - source_start; - @memcpy(styles[source_start..end], colors[source_offset..][0..len]); - source_offset += len + 1; - target = @min(end + 1, content.len); + offset = @min(end + 1, content.len); + } + var painted = false; + var first: usize = 0; + while (first < source_count) { + const first_row = rows[sources[first].index]; + var end = first + 1; + while (end < source_count) : (end += 1) { + const row = rows[sources[end].index]; + const previous = rows[sources[end - 1].index]; + if (!std.mem.eql(u8, row.path, first_row.path) or row.at.line != previous.at.line +| 1) break; } + const language = (forExt(std.fs.path.extension(first_row.path)) catch null); + if (language) |selected| { + var code_len: usize = 0; + for (sources[first..end]) |source| { + @memcpy(code[code_len..][0..source.len], content[source.start..][0..source.len]); + code_len += source.len; + if (code_len < code.len) { + code[code_len] = '\n'; + code_len += 1; + } + } + if (code_len > 0) { + @memset(colors[0..code_len], 0); + paint(colors[0..code_len], code[0..code_len], selected); + painted = true; + var at: usize = 0; + for (sources[first..end]) |source| { + @memcpy(styles[source.start..][0..source.len], colors[at..][0..source.len]); + at += source.len + 1; + } + } + } + first = end; } // A shown context range can begin inside a comment/string whose opener was // omitted. Formatter snapshots from the complete source take precedence, @@ -1244,3 +1254,28 @@ test "syntax declaration locations clear snapshots without muting ordinary conte for (styles[3..][0..header.len]) |style| try std.testing.expectEqual(@as(u8, 0), style); try std.testing.expectEqual(@intFromEnum(Syn.number), styles[std.mem.indexOf(u8, content, "42").?]); } + +test "syntax stacked addresses do not split multiline source groups" { + if (!enabled or (!minimal_grammars and !full_grammars)) return; + const gpa = std.testing.allocator; + start(gpa); + defer stop(); + const Row = struct { path: []const u8 = "a.c", code_start: usize, location_end: usize, at: look.Spot }; + const content = "a.c:1:1\n/* open\na.c:2:1\nint value = 42;\na.c:3:1\n*/ int other = 7;\n"; + const rows = [_]Row{ + .{ .code_start = 7, .location_end = 7, .at = .{ .line = 1 } }, + .{ .code_start = 0, .location_end = 0, .at = .{ .line = 1 } }, + .{ .code_start = 7, .location_end = 7, .at = .{ .line = 2 } }, + .{ .code_start = 0, .location_end = 0, .at = .{ .line = 2 } }, + .{ .code_start = 7, .location_end = 7, .at = .{ .line = 3 } }, + .{ .code_start = 0, .location_end = 0, .at = .{ .line = 3 } }, + }; + const styles = try highlightLocationRows(gpa, content, &rows); + defer gpa.free(styles); + try std.testing.expectEqual(@intFromEnum(Syn.comment), styles[std.mem.indexOf(u8, content, "42").?]); + try std.testing.expectEqual(@intFromEnum(Syn.number), styles[std.mem.indexOf(u8, content, "7;").?]); + for ([_][]const u8{ "a.c:1:1", "a.c:2:1", "a.c:3:1" }) |label| { + const at = std.mem.indexOf(u8, content, label).?; + for (styles[at..][0..label.len]) |style| try std.testing.expectEqual(@intFromEnum(Syn.none), style); + } +} diff --git a/test/output.zig b/test/output.zig index c162c1d1..c738a661 100644 --- a/test/output.zig +++ b/test/output.zig @@ -92,6 +92,7 @@ test "output callers opt into location highlighting instead of matching prose co for ([_]panes.Output.Origin{ .{ .cmd = .LocationsConfig }, .{ .cmd = .Config }, .{ .query = .hover } }) |origin| { const p = try Pardes.init(std.testing.allocator, .{ .tty_only = true, .cols = 140, .rows = 30 }); defer p.deinit(); + p.locations_config.layout = .@"inline"; _ = try p.setTestFile("ordinary\n"); p.presentation.enabled = false; if (origin == .cmd and origin.cmd == .LocationsConfig) { @@ -122,6 +123,7 @@ test "location producers retain rendered location match and diagnostic styles" { for ([_]panes.Output.Origin{ .search, .{ .cmd = .Grep }, .{ .query = .references }, .{ .query = .diagnostics } }) |origin| { const p = try Pardes.init(std.testing.allocator, .{ .tty_only = true, .cols = 140, .rows = 30 }); defer p.deinit(); + p.locations_config.layout = .@"inline"; _ = try p.setTestFile("ordinary\n"); p.presentation.enabled = false; const diagnostic = origin == .query and origin.query == .diagnostics; @@ -157,6 +159,7 @@ test "location results sort filenames and numeric positions while remapping thei for ([_]panes.Output.Origin{ .search, .{ .cmd = .Grep }, .{ .query = .references }, .{ .query = .diagnostics } }) |origin| { const p = try Pardes.init(std.testing.allocator, .{ .tty_only = true }); defer p.deinit(); + p.locations_config.layout = .@"inline"; const source = try p.setTestFile("notes\n"); try panes.Output.fillResults(p, 0, "/tmp", origin, "", try p.gpa.dupe(u8, before), 2); const results = p.panes[source.search_pane.?].?; @@ -170,6 +173,7 @@ test "ranked choices and prose retain their supplied order" { for ([_]pardes.lsp.Kind{ .completion, .hover, .code_action }) |kind| { const p = try Pardes.init(std.testing.allocator, .{ .tty_only = true }); defer p.deinit(); + p.locations_config.layout = .@"inline"; _ = try p.setTestFile("notes\n"); try panes.Output.fillResults(p, 0, "/tmp", .{ .query = kind }, "", try p.gpa.dupe(u8, text), null); const result = for (p.panes) |slot| { @@ -192,6 +196,7 @@ test "reference Look selects the next sorted row from the captured request and k const path = try std.fmt.bufPrint(&path_buf, ".zig-cache/tmp/{s}/m.zig", .{tmp.sub_path}); const p = try Pardes.init(std.testing.allocator, .{ .file = path, .cols = 80, .rows = 24 }); defer p.deinit(); + p.locations_config.layout = .@"inline"; const source = p.panes[0].?; const response = "m.zig:5:5-8 later\nz.zig:1:1 last-file\nm.zig:1:7-10 earlier\nm.zig:3:5-8 current\na.zig:1:1 first-file\nm.zig:4:5-8 next\n"; const sorted = "a.zig:1:1 first-file\nm.zig:1:7-10 earlier\nm.zig:3:5-8 current\nm.zig:4:5-8 next\nm.zig:5:5-8 later\nz.zig:1:1 last-file\n"; @@ -254,6 +259,7 @@ test "location sorting leaves mixed prose alone and preserves newline shape" { for (cases) |case| { const p = try Pardes.init(std.testing.allocator, .{ .tty_only = true }); defer p.deinit(); + p.locations_config.layout = .@"inline"; const source = try p.setTestFile("notes\n"); try panes.Output.fillResults(p, 0, "/tmp", .search, "", try p.gpa.dupe(u8, case.before), 1); try expectResultRows(case.after, &p.panes[source.search_pane.?].?.file.?); @@ -301,6 +307,7 @@ test "result locations stop before preview text and retain full addresses" { test "reordered identical results preserve the selected row and warm line index" { const p = try Pardes.init(std.testing.allocator, .{ .tty_only = true }); defer p.deinit(); + p.locations_config.layout = .@"inline"; const source = try p.setTestFile("notes\n"); const sorted = "a.zig:2:1 first\na.zig:10:1 second\n"; try panes.Output.fillResults(p, 0, "/tmp", .{ .query = .references }, "", try p.gpa.dupe(u8, sorted), null); @@ -328,6 +335,7 @@ test "reordered identical results preserve the selected row and warm line index" test "result sorting allocation failures preserve the previous answer and navigation" { const p = try Pardes.init(std.testing.allocator, .{ .tty_only = true }); defer p.deinit(); + p.locations_config.layout = .@"inline"; const source = try p.setTestFile("notes\n"); try panes.Output.fillResults(p, 0, "/tmp", .{ .query = .references }, "before", try p.gpa.dupe(u8, "a.zig:1:1 keep\n"), 0); const id = source.search_pane.?; @@ -360,6 +368,7 @@ test "result sorting allocation failures preserve the previous answer and naviga test "Find sorts whole filenames and next location uses numeric columns" { const p = try Pardes.init(std.testing.allocator, .{ .tty_only = true }); defer p.deinit(); + p.locations_config.layout = .@"inline"; const source = try p.setTestFile(""); try panes.Output.fillResults(p, 0, "/tmp", .{ .cmd = .Find }, "", try p.gpa.dupe(u8, "x:2\nx:10\n"), 0); const result = p.panes[source.search_pane.?].?; @@ -374,6 +383,7 @@ test "Find sorts whole filenames and next location uses numeric columns" { test "result stepping reaches an unterminated last row" { const p = try Pardes.init(std.testing.allocator, .{ .tty_only = true }); defer p.deinit(); + p.locations_config.layout = .@"inline"; const source = try p.setTestFile("one\ntwo\n"); const rows = try std.fmt.allocPrint(p.gpa, "{s}:1:1 first\n{s}:2:1 last", .{ source.file.?.path, source.file.?.path }); try panes.Output.fillResults(p, 0, "/tmp", .search, "", rows, 0); @@ -604,6 +614,7 @@ test "EffectCode lists readable virtual sources used by this backend" { test "every enabled setting builtin mutates the State Config reports" { const p = try Pardes.init(std.testing.allocator, .{ .tty_only = true }); defer p.deinit(); + p.locations_config.layout = .@"inline"; try std.testing.expectEqual(config.gui_tagline_font_percent, p.settings.font.tagline_percent); var font_arena: std.heap.ArenaAllocator = .init(std.testing.allocator); @@ -730,6 +741,7 @@ test "n/N skips formatted context and selects comment match locations" { for ([_]bool{ false, true }) |tslocations| { const p = try Pardes.init(std.testing.allocator, .{ .tty_only = true, .cols = 100, .rows = 30 }); defer p.deinit(); + p.locations_config.layout = .@"inline"; const text = "const Box = struct {\n" ++ " pub fn run() void {\n" ++ " // /tmp neighboring path\n" ++ @@ -742,7 +754,7 @@ test "n/N skips formatted context and selects comment match locations" { p.gpa.free(source.file.?.path); source.file.?.path = try p.gpa.dupe(u8, "/look-walk-context.zig"); p.presentation.enabled = false; - p.locations_config = .{ .context = 1, .tscontext = true, .tslocations = tslocations }; + p.locations_config = .{ .layout = .@"inline", .context = 1, .tscontext = true, .tslocations = tslocations }; const path = source.file.?.path; const input = try std.fmt.allocPrint(p.gpa, "{s}:4:9 {s}\n{s}:6:9 {s}\n", .{ path, modal.lineSlice(text, 3), path, modal.lineSlice(text, 5), @@ -798,6 +810,7 @@ test "n/N selects one output location per row and opens nothing" { const paths = try projectPaths(&cwd_buf, &path_buf); const p = try Pardes.init(std.testing.allocator, .{ .cols = 100, .rows = 40, .file = paths.boot }); defer p.deinit(); + p.locations_config.layout = .@"inline"; p.update(.{ .resize = .{ .cols = 100, .rows = 40 } }); const rid = try walkFixture(p, p.active, paths.cwd, "one"); const results = p.panes[rid].?; @@ -837,6 +850,7 @@ test "n/N resumes the result output whose Look moved focus away" { const path = try std.fmt.bufPrint(&path_buf, ".zig-cache/tmp/{s}/look-owner.txt", .{tmp.sub_path}); const p = try Pardes.init(std.testing.allocator, .{ .file = path, .cols = 80, .rows = 24 }); defer p.deinit(); + p.locations_config.layout = .@"inline"; try std.testing.expect(p.executeBuiltinLine(0, "Look target")); const rid = p.panes[0].?.search_pane orelse return error.MissingResults; @@ -889,6 +903,7 @@ test "N exactly reverses n across output panes and the ring seam" { const paths = try projectPaths(&cwd_buf, &path_buf); const p = try Pardes.init(std.testing.allocator, .{ .cols = 100, .rows = 40, .file = paths.boot }); defer p.deinit(); + p.locations_config.layout = .@"inline"; p.update(.{ .resize = .{ .cols = 100, .rows = 40 } }); const first = try walkFixture(p, p.active, paths.cwd, "one"); p.update(.{ .key = .{ .cp = 'n', .alt = true } }); @@ -995,6 +1010,7 @@ test "identical result refresh keeps warm content caches without allocation" { var allocator: std.testing.FailingAllocator = .init(std.testing.allocator, .{}); const p = try Pardes.init(allocator.allocator(), .{ .tty_only = true, .cols = 80, .rows = 24 }); defer p.deinit(); + p.locations_config.layout = .@"inline"; const source = try p.setTestFile("notes\n"); p.settings.colors = true; const text = "a.zig:1:1 pub fn first() void {}\na.zig:2:1 if (true) return;\n"; @@ -1088,6 +1104,7 @@ test "rejected result refresh frees incoming text and leaves the existing output var allocator: std.testing.FailingAllocator = .init(std.testing.allocator, .{}); const p = try Pardes.init(allocator.allocator(), .{ .tty_only = true, .cols = 80, .rows = 24 }); defer p.deinit(); + p.locations_config.layout = .@"inline"; const source = try p.setTestFile("notes\n"); try panes.Output.fillResults(p, 0, "/tmp", .{ .query = .references }, "before", try p.gpa.dupe(u8, "keep\n"), 1); const id = source.search_pane.?; @@ -1152,8 +1169,9 @@ test "result alignment chunks keep seventeen matches independent and refresh sta for ([_]usize{ 7, 8 }) |long_at| { const p = try Pardes.init(std.testing.allocator, .{ .tty_only = true }); defer p.deinit(); + p.locations_config.layout = .@"inline"; const source = try p.setTestFile("notes\n"); - p.locations_config = .{ .context = 0, .tscontext = false }; + p.locations_config = .{ .layout = .@"inline", .context = 0, .tscontext = false }; var input: std.ArrayList(u8) = .empty; defer input.deinit(p.gpa); var widths: [17]usize = undefined; @@ -1234,13 +1252,14 @@ test "result alignment chunks assign boundary context to nearest match with prev for ([_]panes.Output.Origin{ .search, .{ .query = .references } }) |origin| { const p = try Pardes.init(std.testing.allocator, .{ .tty_only = true }); defer p.deinit(); + p.locations_config.layout = .@"inline"; var source_text: std.ArrayList(u8) = .empty; defer source_text.deinit(p.gpa); for (0..14) |_| try source_text.appendSlice(p.gpa, "\t source();\n"); const source = try p.setTestFile(source_text.items); p.gpa.free(source.file.?.path); source.file.?.path = try p.gpa.dupe(u8, "/chunk-boundary-界.txt"); - p.locations_config = .{ .context = 2, .tscontext = false }; + p.locations_config = .{ .layout = .@"inline", .context = 2, .tscontext = false }; var input: std.ArrayList(u8) = .empty; defer input.deinit(p.gpa); for ([_]usize{ 1, 2, 3, 4, 5, 6, 7, 8, 12 }) |line| { @@ -1295,10 +1314,11 @@ test "declaration context ellipses mark only final header lines before omitted s for ([_]u8{ 0, 1 }) |neighbors| { const p = try Pardes.init(std.testing.allocator, .{ .tty_only = true }); defer p.deinit(); + p.locations_config.layout = .@"inline"; const source = try p.setTestFile(text); p.gpa.free(source.file.?.path); source.file.?.path = try p.gpa.dupe(u8, "/ellipsis-context.zig"); - p.locations_config = .{ .context = neighbors, .tscontext = true, .tslocations = visible }; + p.locations_config = .{ .layout = .@"inline", .context = neighbors, .tscontext = true, .tslocations = visible }; const input = try std.fmt.allocPrint(p.gpa, "{s}:12:17 {s}\n{s}:16:9 {s}\n", .{ source.file.?.path, modal.lineSlice(text, 11), source.file.?.path, modal.lineSlice(text, 15), }); @@ -1344,10 +1364,11 @@ test "LSP occurrence tint follows the supplied source span through context" { for ([_]pardes.lsp.Kind{ .references, .definition }) |kind| { const p = try Pardes.init(std.testing.allocator, .{ .tty_only = true, .cols = 160, .rows = 40 }); defer p.deinit(); + p.locations_config.layout = .@"inline"; const source = try p.setTestFile(text); p.gpa.free(source.file.?.path); source.file.?.path = try p.gpa.dupe(u8, "/occurrence.zig"); - p.locations_config = .{ .context = 1, .tscontext = true }; + p.locations_config = .{ .layout = .@"inline", .context = 1, .tscontext = true }; p.presentation.enabled = false; var input: std.Io.Writer.Allocating = .init(p.gpa); defer input.deinit(); @@ -1400,10 +1421,11 @@ test "result context upper bound stops at earliest enclosing declaration" { for ([_]bool{ false, true }) |visible| { const p = try Pardes.init(std.testing.allocator, .{ .tty_only = true }); defer p.deinit(); + p.locations_config.layout = .@"inline"; const source = try p.setTestFile(text); p.gpa.free(source.file.?.path); source.file.?.path = try p.gpa.dupe(u8, "/bounded-context.zig"); - p.locations_config = .{ .context = 100, .tscontext = tscontext, .tslocations = visible }; + p.locations_config = .{ .layout = .@"inline", .context = 100, .tscontext = tscontext, .tslocations = visible }; const input = try std.fmt.allocPrint(p.gpa, "{s}:8:13 {s}\n", .{ source.file.?.path, modal.lineSlice(text, 7) }); try panes.Output.fillResults(p, 0, "/", origin, "upper bound", input, 0); const file = &p.panes[source.search_pane.?].?.file.?; @@ -1431,11 +1453,12 @@ test "result context upper bound stops at earliest enclosing declaration" { for ([_][]const u8{ "/no-ancestor.zig", "/no-grammar.txt" }) |path| { const p = try Pardes.init(std.testing.allocator, .{ .tty_only = true }); defer p.deinit(); + p.locations_config.layout = .@"inline"; const plain = "// first\n// second\n// matched\n// trailing"; const source = try p.setTestFile(plain); p.gpa.free(source.file.?.path); source.file.?.path = try p.gpa.dupe(u8, path); - p.locations_config = .{ .context = 100, .tscontext = true, .tslocations = false }; + p.locations_config = .{ .layout = .@"inline", .context = 100, .tscontext = true, .tslocations = false }; const input = try std.fmt.allocPrint(p.gpa, "{s}:3:4 // matched\n", .{path}); try panes.Output.fillResults(p, 0, "/", .search, "unbounded", input, 0); const file = &p.panes[source.search_pane.?].?.file.?; @@ -1445,3 +1468,120 @@ test "result context upper bound stops at earliest enclosing declaration" { try std.testing.expectEqual(@as(usize, 2), source.search_row.?); } } + +test "stacked search and LSP results retain source tint navigation and dump ownership" { + if (!pardes.syntax.enabled) return error.SkipZigTest; + const first = "\tfoo + 界 + foo;"; + const second = " return foo;"; + const source_text = "const Box = struct {\n fn run() void {\n" ++ first ++ "\n const neighbor = 42;\n" ++ second ++ "\n }\n};\n"; + for ([_]panes.Output.Origin{ .search, .{ .query = .references } }) |origin| { + for ([_]bool{ false, true }) |visible| { + const p = try Pardes.init(std.testing.allocator, .{ .tty_only = true, .cols = 160, .rows = 50 }); + defer p.deinit(); + try std.testing.expectEqual(.stacked, p.locations_config.layout); + p.locations_config = .{ .context = 1, .tscontext = true, .tslocations = visible }; + p.presentation.enabled = false; + const source = try p.setTestFile(source_text); + p.gpa.free(source.file.?.path); + source.file.?.path = try p.gpa.dupe(u8, "/stacked-界.zig"); + var input: std.Io.Writer.Allocating = .init(p.gpa); + defer input.deinit(); + const first_col = std.mem.lastIndexOf(u8, first, "foo").?; + const second_col = std.mem.lastIndexOf(u8, second, "foo").?; + try pardes.lsp.sourceSpanRow(&input.writer, source.file.?.path, 2, first_col, 2, first_col + 3, first); + try pardes.lsp.sourceSpanRow(&input.writer, source.file.?.path, 4, second_col, 4, second_col + 3, second); + try panes.Output.fillResults(p, 0, "/", origin, "stacked", try p.gpa.dupe(u8, input.written()), 1); + const id = source.search_pane.?; + const pane = p.panes[id].?; + const file = &pane.file.?; + var matches: [2]usize = undefined; + var count: usize = 0; + var previews: usize = 0; + var context_addresses: usize = 0; + for (file.location_rows, 0..) |row, index| { + const line = modal.lineSlice(file.content, index); + switch (row.kind) { + .match => { + try std.testing.expectEqual(line.len, row.code_start); + try std.testing.expect(row.location_end > 0); + try std.testing.expect(!std.mem.containsAtLeast(u8, line, 1, "foo")); + matches[count] = index; + count += 1; + }, + .preview => { + try std.testing.expect(index > 0); + try std.testing.expectEqual(.match, file.location_rows[index - 1].kind); + try std.testing.expectEqual(file.location_rows[index - 1].at, row.at); + try std.testing.expectEqualStrings(file.location_rows[index - 1].path, row.path); + try std.testing.expectEqual(@as(usize, 0), row.location_end); + try std.testing.expectEqual(@as(usize, 0), row.code_start); + try std.testing.expectEqualStrings(if (previews == 0) first else second, line); + previews += 1; + }, + .context => { + if (row.location_end > 0) { + try std.testing.expect(visible and row.declaration); + try std.testing.expectEqual(line.len, row.code_start); + context_addresses += 1; + } else { + try std.testing.expectEqual(@as(usize, 0), row.code_start); + try std.testing.expectEqualStrings(modal.lineSlice(source_text, row.at.line - 1), line); + } + }, + } + } + try std.testing.expectEqual(@as(usize, 2), count); + try std.testing.expectEqual(count, previews); + try std.testing.expectEqual(@as(usize, if (visible) 2 else 0), context_addresses); + try std.testing.expectEqual(matches[1], source.search_row.?); + const original_content = try p.gpa.dupe(u8, file.content); + defer p.gpa.free(original_content); + try panes.Output.fillResults(p, 0, "/", origin, "stacked", try p.gpa.dupe(u8, input.written()), 0); + try std.testing.expectEqual(id, source.search_pane.?); + try std.testing.expectEqualStrings(original_content, file.content); + pardes.layout.compute(p); + var arena = std.heap.ArenaAllocator.init(p.gpa); + defer arena.deinit(); + const surface = try p.render(arena.allocator()); + const chrome = pardes.ChromeTheme.fromTheme(p.theme()); + var marked: usize = 0; + for (surface.cells) |cell| { + if (!std.meta.eql(cell.style.bg, pardes.Color{ .rgb = chrome.search_bg })) continue; + try std.testing.expect(cell.text[0] == 'f' or cell.text[0] == 'o'); + marked += 1; + } + try std.testing.expectEqual(@as(usize, 6), marked); + const number = std.mem.indexOf(u8, file.content, "42").?; + try std.testing.expectEqual(@intFromEnum(pardes.syntax.Syn.number), file.highlights[number]); + p.active = id; + pane.mode = .normal; + p.armLookWalk(id); + for ([_]struct { key: u21, match: usize }{ .{ .key = 'n', .match = 0 }, .{ .key = 'n', .match = 1 }, .{ .key = 'N', .match = 0 } }) |step| { + p.update(.{ .key = .{ .cp = step.key } }); + try std.testing.expectEqual(@as(i32, @intCast(matches[step.match])), pane.cur_row); + const row = file.location_rows[matches[step.match]]; + const line = modal.lineSlice(file.content, matches[step.match]); + try std.testing.expectEqualStrings(line[0..row.location_end], selectedOutputText(pane) orelse ""); + } + try p.dumpState(); + const restored = try Pardes.initFromDump(p.gpa, .{ .tty_only = true }, p.dump_out.?); + defer restored.deinit(); + const restored_file = &restored.panes[id].?.file.?; + try std.testing.expectEqualStrings(file.content, restored_file.content); + try std.testing.expectEqual(file.location_rows.len, restored_file.location_rows.len); + for (file.location_rows, restored_file.location_rows) |before, after| { + try std.testing.expectEqual(before.kind, after.kind); + try std.testing.expectEqual(before.at, after.at); + try std.testing.expectEqualStrings(before.path, after.path); + try std.testing.expectEqual(before.code_start, after.code_start); + try std.testing.expectEqual(before.location_end, after.location_end); + try std.testing.expectEqualSlices(u8, before.colors, after.colors); + } + restored.active = id; + restored.armLookWalk(id); + restored.update(.{ .key = .{ .cp = 'N' } }); + try std.testing.expectEqual(@as(i32, @intCast(matches[1])), restored.panes[id].?.cur_row); + try std.testing.expectEqualStrings(source_text, source.file.?.content); + } + } +} diff --git a/test/panes.zig b/test/panes.zig index d844f26e..28af8141 100644 --- a/test/panes.zig +++ b/test/panes.zig @@ -975,6 +975,7 @@ const TagNameTintTests = struct { for ([_]bool{ false, true }) |bottom| { const p = try Pardes.init(std.testing.allocator, .{ .tty_only = true, .cols = 100, .rows = 24 }); defer p.deinit(); + p.locations_config.layout = .@"inline"; const pane = try p.setTestFile("body\n"); p.gpa.free(pane.file.?.path); pane.file.?.path = try p.gpa.dupe(u8, "/project/界file.zig"); @@ -2129,6 +2130,7 @@ const OutputTests = struct { test "Locations align Unicode paths by display width and preserve source indentation" { const p = try Pardes.init(std.testing.allocator, .{ .tty_only = true }); defer p.deinit(); + p.locations_config.layout = .@"inline"; _ = try p.setTestFile("notes\n"); try fillResults(p, 0, "/", .search, "alignment", try p.gpa.dupe(u8, "/界.zig:2:1 first\n/longer-name.zig:12:3 \tsecond\n"), null); const result = p.panes[p.panes[0].?.search_pane.?].?; @@ -2150,9 +2152,10 @@ const OutputTests = struct { for ([_]bool{ false, true }) |tslocations| { const p = try Pardes.init(std.testing.allocator, .{ .tty_only = true }); defer p.deinit(); + p.locations_config.layout = .@"inline"; const source = "\tbefore\n\tmatch\n after\n"; const pane = try TreeContextTests.setZigFile(p, source); - p.locations_config = .{ .context = 1, .tscontext = false, .tslocations = tslocations }; + p.locations_config = .{ .layout = .@"inline", .context = 1, .tscontext = false, .tslocations = tslocations }; const path = pane.file.?.path; try fillResults(p, 0, "/", .search, "neighbors", try std.fmt.allocPrint(p.gpa, "{s}:2:1 \tmatch\n", .{path}), 0); const file = &p.panes[pane.search_pane.?].?.file.?; @@ -2183,6 +2186,7 @@ const OutputTests = struct { if (!syntax.enabled) return error.SkipZigTest; const p = try Pardes.init(std.testing.allocator, .{ .tty_only = true, .cols = 100, .rows = 30 }); defer p.deinit(); + p.locations_config.layout = .@"inline"; const source = "const Box = struct {\n" ++ " pub fn run() void {\n" ++ " // unsaved before\n" ++ @@ -2297,6 +2301,7 @@ const OutputTests = struct { if (!syntax.enabled) return error.SkipZigTest; const p = try Pardes.init(std.testing.allocator, .{ .tty_only = true, .cols = 120, .rows = 40 }); defer p.deinit(); + p.locations_config.layout = .@"inline"; const source = "const Outer = struct {\n" ++ " const Inner = struct {\n" ++ " pub fn run(\n" ++ @@ -2306,7 +2311,7 @@ const OutputTests = struct { "\t\tcall();\n" ++ " }\n };\n};\n"; const pane = try TreeContextTests.setZigFile(p, source); - p.locations_config = .{ .context = 1, .tscontext = true, .tslocations = true }; + p.locations_config = .{ .layout = .@"inline", .context = 1, .tscontext = true, .tslocations = true }; const path = pane.file.?.path; try fillResults(p, 0, "/", .search, "nesting", try std.fmt.allocPrint(p.gpa, "{s}:7:1 \t\tcall();\n{s}:2:5 const Inner = struct {{\n", .{ path, path }), 0); const result = p.panes[pane.search_pane.?].?; @@ -2431,6 +2436,7 @@ const OutputTests = struct { test "generated result refills preserve unchanged selections and reset changed text" { const p = try Pardes.init(std.testing.allocator, .{ .tty_only = true, .cols = 80, .rows = 24 }); defer p.deinit(); + p.locations_config.layout = .@"inline"; _ = try p.setTestFile("notes\n"); const content = "first\nsecond\nthird\n"; try fillResults(p, 0, "/", .{ .query = .hover }, "", try p.gpa.dupe(u8, content), null); @@ -2474,6 +2480,7 @@ const OutputTests = struct { test "generated result replacement cancels an in-progress body selection" { const p = try Pardes.init(std.testing.allocator, .{ .tty_only = true, .cols = 80, .rows = 24 }); defer p.deinit(); + p.locations_config.layout = .@"inline"; _ = try p.setTestFile("notes\n"); p.presentation.enabled = false; try fillResults(p, 0, "/", .{ .query = .hover }, "", try p.gpa.dupe(u8, "first\nsecond\nthird\n"), null); @@ -2513,6 +2520,7 @@ const OutputTests = struct { .rows = 24, }); defer p.deinit(); + p.locations_config.layout = .@"inline"; var first: [max_arg]u8 = @splat('a'); var second = first; diff --git a/test/pdf.zig b/test/pdf.zig index 04b2e8b9..113ed8b9 100644 --- a/test/pdf.zig +++ b/test/pdf.zig @@ -1576,12 +1576,20 @@ test "PDF n/N addresses and reveals distinct MuPDF hits on one page" { const results = p.panes[results_id].?.file.?; var found: [3]bool = @splat(false); for (results.location_rows, 0..) |row, index| { - // PDF locations address page/hit pairs, not binary file lines. + // PDF locations address page/hit pairs, not binary file lines. Each + // address owns one snippet, which must not add a navigation stop. + if (index % 2 == 1) { + try std.testing.expectEqual(.preview, row.kind); + try std.testing.expectEqual(results.location_rows[index - 1].at, row.at); + try std.testing.expectEqual(@as(usize, 0), row.code_start); + try std.testing.expectEqualStrings("Pardes", pardes.modal.lineSlice(results.content, index)); + continue; + } try std.testing.expectEqual(.match, row.kind); + const line = pardes.modal.lineSlice(results.content, index); + try std.testing.expectEqual(line.len, row.code_start); if (!std.mem.endsWith(u8, row.path, "design.pdf") or row.at.line != 1) continue; if (row.at.col < 1 or row.at.col > found.len) continue; - const line = pardes.modal.lineSlice(results.content, index); - try std.testing.expectEqualStrings("Pardes", line[row.code_start..]); found[row.at.col - 1] = true; } for (found) |present| try std.testing.expect(present); @@ -1599,6 +1607,7 @@ test "PDF n/N addresses and reveals distinct MuPDF hits on one page" { defer frame.deinit(); try std.testing.expect(pardes.test_api.searchStep(p, 0, 1)); try std.testing.expectEqual(@as(usize, 0), pv.search_hit); + try std.testing.expectEqual(@as(usize, 0), pane.search_row.?); const first = try p.render(frame.allocator()); const revision = first.images[0].?.native.revision; const raster = panes.Pdf.rasterForPage(pv, pv.page).?; @@ -1617,12 +1626,14 @@ test "PDF n/N addresses and reveals distinct MuPDF hits on one page" { try std.testing.expect(pardes.test_api.searchStep(p, 0, 1)); try std.testing.expectEqual(@as(usize, 1), pv.search_hit); + try std.testing.expectEqual(@as(usize, 2), pane.search_row.?); _ = frame.reset(.retain_capacity); const second = try p.render(frame.allocator()); try std.testing.expectEqual(revision, second.images[0].?.native.revision); try std.testing.expect(pardes.test_api.searchStep(p, 0, 1)); try std.testing.expectEqual(@as(usize, 2), pv.search_hit); + try std.testing.expectEqual(@as(usize, 4), pane.search_row.?); _ = frame.reset(.retain_capacity); const third = try p.render(frame.allocator()); try std.testing.expectEqual(revision, third.images[0].?.native.revision); -- 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 'docs') 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 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 'docs') 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 051fa32a31fab2980b5e8af3113befc83d7914b3 Mon Sep 17 00:00:00 2001 From: Gabriel Schneider Date: Tue, 15 Sep 2026 20:36:53 -0300 Subject: Fetch cloud9 from sourcehut, and correct the citations into the board toolchain --- build.zig.zon | 11 ++++++++++- docs/cloud9.md | 9 ++++++--- docs/design.typ | 4 ++++ src/esp32p4/app.zig | 4 ++-- src/esp32p4/input_rescue.zig | 13 ++++++++----- 5 files changed, 30 insertions(+), 11 deletions(-) (limited to 'docs') diff --git a/build.zig.zon b/build.zig.zon index 2ffe5d47..79c2a261 100644 --- a/build.zig.zon +++ b/build.zig.zon @@ -2,7 +2,16 @@ .name = .pardes, .version = "0.0.3", .dependencies = .{ - .cloud9 = .{ .path = "../cloud9" }, + // 9P sessions and transports live in the published cloud9 package, so + // the manifest pins the build: `zig build` fetches this commit into + // zig-pkg/ like any other dependency. Push to + // `git@git.sr.ht:~gbrls/cloud9`; zig has no git+ssh support, so the + // 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", + }, // 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 // process — no zls binary, no JSON-RPC, no handshake. diff --git a/docs/cloud9.md b/docs/cloud9.md index db547afc..e18130ef 100644 --- a/docs/cloud9.md +++ b/docs/cloud9.md @@ -1,8 +1,11 @@ # cloud9 integration -The sibling `../cloud9` package owns the base 9P2000 wire format, client and server -connections, and TCP/Unix/QUIC transports. `build.zig.zon` uses the local package -path so both checkouts can be developed together. +The published `cloud9` package owns the base 9P2000 wire format, client and server +connections, and TCP/Unix/QUIC transports. `build.zig.zon` pins a commit from +`git@git.sr.ht:~gbrls/cloud9`, so `zig build` fetches it into `zig-pkg/` like every +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 diff --git a/docs/design.typ b/docs/design.typ index f6e2e240..4c8956ba 100644 --- a/docs/design.typ +++ b/docs/design.typ @@ -1633,6 +1633,10 @@ 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 `05-zig-p4` firmware toolchain is a separate sibling checkout. +The 9P library is the one pinned dependency that is not third-party: `cloud9` +lives at `git.sr.ht/~gbrls/cloud9`, pushed as `git@git.sr.ht:~gbrls/cloud9` and +fetched from that commit's HTTPS URL, since zig has no `git+ssh` support. + Generated during the build: `highlights.scm` into an options module; the vendored helix and zed theme sources into the generated half of the theme ring; working-tree `.zig` sources into the web shell's read-only archive; and eight diff --git a/src/esp32p4/app.zig b/src/esp32p4/app.zig index ae5679f3..4ee131ec 100644 --- a/src/esp32p4/app.zig +++ b/src/esp32p4/app.zig @@ -35,7 +35,7 @@ //! builds, it is what every measurement in that repository's `experiments/` was taken through, and //! it is the firmware build path. Its externs link against that object file. //! The reasons the seam is a file at all - a nested `build.zig.zon` dependency broke every build in -//! the toolchain repository - are recorded in `src/esp32p4.zig:8-15` and `05-zig-p4/build.zig:238-260`. +//! the toolchain repository - are recorded in `src/esp32p4.zig:8-15` and `05-zig-p4/build.zig:252-272`. //! //! Who owns which symbol: `src/esp32p4.zig` exports all eight `pardes_esp32p4_*` functions and nothing else. //! This file exports `_start`, `zig_main`, `trapEntry` and `trapReport`. `esp_app_desc` belongs to @@ -52,7 +52,7 @@ //! ## Where the memory is //! //! Measured on this die by the toolchain's `examples/memprobe.zig`, not read off a datasheet, and -//! written down once in the generated linker script (`05-zig-p4/build.zig:1572,1579,1584-1585`): +//! written down once in the generated linker script (`05-zig-p4/build.zig:1569,1576,1581-1582`): //! //! 0x4FF00000..0x4FF3F000 252 KiB `l2mem`: .data/.bss/.stack are linked into this //! 0x4FF3F000..0x4FF40000 4 KiB mask ROM .data/.bss - untouchable, ets_printf needs it diff --git a/src/esp32p4/input_rescue.zig b/src/esp32p4/input_rescue.zig index 3f1c0268..ba6974d2 100644 --- a/src/esp32p4/input_rescue.zig +++ b/src/esp32p4/input_rescue.zig @@ -31,11 +31,14 @@ //! same source compile for riscv32-freestanding and for the host unchanged. //! //! ONE COPY, TWO BUILDS. This file is the only copy; the toolchain repository's is gone. Its build -//! reads this tree across a sibling-relative seam, and names this path twice: once as the -//! `input_rescue` module of `-Dpardes`'s application (`05-zig-p4/build.zig:230-231`, whose root is -//! `../02-pardes-code/src/esp32p4/app.zig` by the `-Dapp` default at `:168-169`) and once as the -//! same-named module of `zig build selftest`'s on-die root (`:437-438`). Both spell -//! `../02-pardes-code/src/esp32p4/input_rescue.zig`, so there is nothing to keep in step. +//! reads this tree across a sibling-relative seam in exactly one place: `zig build selftest` hands +//! this path over as the `input_rescue` module of its on-die root (`05-zig-p4/build.zig:434-435`, +//! the module at `:453`). The editor's own application root needs no such wiring - `app.zig` reads +//! the policy through the `uart.zig` beside it, which imports this file as its sibling - and the +//! toolchain deliberately registers no module for it, because zig hashes every registered module's +//! root source on every compile, so registering one that a root does not use breaks every build in +//! a checkout without this tree. `-Dapp` still defaults under `-Dpardes` to +//! `../02-pardes-code/src/esp32p4/app.zig` (`:168-169`). //! //! Host checks run under `zig build unit-test` here. In `../05-zig-p4`, //! `zig build selftest` flashes and runs the on-die checks against UART0. -- cgit v1.3 From 7cbd44dd1cfe97126e7fc996214e458525d2980c Mon Sep 17 00:00:00 2001 From: Gabriel Schneider Date: Wed, 16 Sep 2026 13:20:29 -0300 Subject: Align macOS rendering with Linux and establish parity regressions --- docs/macos.md | 64 ++++----- docs/rendering-parity-design.md | 132 +++++++++++++++++++ src/macos.zig | 21 ++- src/macos/Sources/AppDelegate.swift | 2 +- src/macos/Sources/PardesView.swift | 128 +++++++++++------- src/macos/pardes.h | 1 + test/macos-snapshots/context.zig | 109 ++++++++++++++++ test/macos-snapshots/rendering-parity.golden | 14 ++ test/macos-snapshots/rendering-parity.snap | 54 ++++++++ test/macos-snapshots/tag-ink.golden | 1 + test/macos-snapshots/tag-ink.snap | 8 ++ test/macos_e2e.swift | 185 ++++++++++++++++++++++++++- 12 files changed, 634 insertions(+), 85 deletions(-) create mode 100644 docs/rendering-parity-design.md create mode 100644 test/macos-snapshots/context.zig create mode 100644 test/macos-snapshots/rendering-parity.golden create mode 100644 test/macos-snapshots/rendering-parity.snap create mode 100644 test/macos-snapshots/tag-ink.golden create mode 100644 test/macos-snapshots/tag-ink.snap (limited to 'docs') diff --git a/docs/macos.md b/docs/macos.md index 3c02de8a..3fdf399f 100644 --- a/docs/macos.md +++ b/docs/macos.md @@ -14,6 +14,10 @@ plumbing actually requires, and which parts of it are distribution machinery rather than integration. Read that for the alternatives; this file is what was built and why. +Future layout/compositing ownership and the regression baseline are discussed in +[Shared rendering contract](rendering-parity-design.md). That proposal is design +groundwork; the native drawing implementation remains in place. + ## Why not ghostty's split Ghostty was read carefully before this was written, and this backend @@ -496,33 +500,22 @@ different kinds of assertion because a snapshot is the core's cell buffer and the core has no font: `font Menlo-Regular` asks the view what it is actually wearing, and the snapshots catch the grid moving when the cell changes size. -### The tagline band follows the core's rule, not this shell's - -A pane tag is drawn at `gui_tagline_font_percent` of the body face -(`TaglineSize ` changes it live) and the band it sits on shrinks with -it, while the grid row stays body-sized. Where that shorter band sits inside its -row is no longer this shell's arithmetic: `pardes_tagline_band_offset` and -`pardes_topbar_pane_border_px` answer out of `src/pardes.zig`, and that is the -same rule `src/gui/gui.zig` draws with. - -It is shared because it drifted. This shell centred every band in its own row, -and centring two reduced-height bands is precisely the case -`config.gui_topbar_pane_border_px` exists to prevent: the topbar's unused -half-band meets the first pane tag's unused half-band and the window background -shows through the seam. The strip is as wide as the bands are short — on a -20-pixel cell, 4 physical pixels at the default 82%, 10 at 50%, 14 at 30% — so it -read as "the tagline is wrong on the mac" rather than as one missing rule. Row -zero is bottom-aligned now, the first pane-tag row top-aligned, the two joined by -`gui_topbar_pane_border_px` in the theme's scrollbar-track colour -(`pardes_topbar_pane_border_rgb`, or a compiled override), every row between -centred, and a `Tagbottom` band on the final row bottom-aligned against the -window edge — with the sub-cell strip below it painted in that band's own colour, -because the core grid holds only whole cells and a window is any height it likes. - -The offsets cross as PHYSICAL PIXELS. The host multiplies its points by the -backing scale going in and divides coming out, which is the snapping `Metrics` -already does for the cell, and is what keeps a one-pixel rule one pixel instead -of a two-pixel smear. +### Compact tags and context rows + +`TaglineSize ` scales the tag face, pitch and glyph band. The tag's +background still fills a whole body-grid row, as in the SDL renderer. Painting +only the compact band leaves dark strips between tags. Glyph offsets come from +`pardes_tagline_band_offset`; all measurements cross the ABI in physical pixels. + +The chrome overlay runs after the compact layers. It draws the topbar rule, +the column rule and the pane's tag/body boundary using the theme's border +colour. The pane rule moves above a bottom-positioned tag. Tag-layer fields 11 +and 12 preserve that placement and colour in frozen transition frames. + +Tree-sitter context rows use the compact height and pitch, with full-width row +backgrounds. Their one-physical-pixel separators use the same border colour as +SDL, after discontinuous declarations and after the final context row. The +remaining body starts immediately after the compact rows. ### The cell is snapped to device pixels, not to points @@ -713,6 +706,20 @@ The blur is a **sibling** of the grid inside a plain container, never its parent. Hiding a superview hides its subviews, so a nested backdrop drew a blank window for every opaque theme the moment it was hidden. +`WindowOpacity <0..100>` sets one background coverage throughout the frame. +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. + +`test/macos-snapshots/rendering-parity.snap` checks background colour and alpha, +regular and bottom tags, compact context separators, and PDF fit, tint and +scrolling. Its native-metrics mode uses backing pixels like the shipping app; +the older grid-only tests keep their display-independent point metrics. + ## Threading One core, touched only from the main thread, plus one pty reader task per pane @@ -955,8 +962,7 @@ select scripts or directories instead. The executable stays in the build cache. `test/macos_e2e.swift` links the same Swift sources the app does, minus `main.swift`, into a second binary — test scaffolding does not ship inside the -product. Scripts are `test/macos-snapshots/*.snap` (seven of them: boot, cwd, -drop, font, keys, rotate, trackpad) and speak the tty suite's +product. Scripts are `test/macos-snapshots/*.snap` and speak the tty suite's vocabulary (`start`, `wait`, `stable`, `text`, `key`, `snap`, `command`, `mouse`, `click`, `wheel`, `resize`, `draw`) plus what only exists here: `fingers `, `force `, diff --git a/docs/rendering-parity-design.md b/docs/rendering-parity-design.md new file mode 100644 index 00000000..b6036543 --- /dev/null +++ b/docs/rendering-parity-design.md @@ -0,0 +1,132 @@ +# Shared rendering contract: design groundwork + +Status: proposed direction, not an implemented renderer abstraction. The current +change fixes the native macOS backend and adds regression coverage. It does not +move layout or drawing into a new shared module. + +## Why the backends diverged + +The core shares editor state, cells, tag layers, body layers, and PDF placements. +It does not yet specify every visual operation needed to present them. SDL and +AppKit therefore independently reconstruct tag backgrounds, compact text bands, +context separators, overlay order, and opacity. A correct cell snapshot can +coexist with an incorrect rendered frame. + +The macOS/Linux comparison exposed concrete gaps in this contract: + +- Reduced tag glyph bands were also used as background bounds on macOS; SDL + fills the entire row. Column and pane rules were missing or painted before + an overlapping layer. +- Tree-sitter context rows had matching compact geometry, but the separator + used the scroll-track color instead of the border color. +- Repeated source-over background fills compounded window opacity. At 71%, + two overlapping fills yield about 92%, and three about 98%. The window's own + colored background added another layer behind the view. +- CoreText fallback runs did not inherit the selected foreground color. +- PDF/image composition ignored window opacity on macOS, while SDL applies it + to raster content. Theme colors also need an explicit sRGB interpretation. + +These are duplicated policy decisions, rather than a reason to replace CoreText +or require identical fonts on every host. + +## Proposed ownership boundary + +A shared scene builder should translate the existing surface and its layers +into an ordered list of positioned drawing operations. Platform code should +consume that list without deciding which rows are compact, which edge has a +separator, or which objects participate in window opacity. + +The builder would own: + +- Tag and context geometry, background extents, separator positions and colors, + clipping, and the order of backgrounds, text, images, cursors, and overlays. +- Coordinate conversion rules: logical layout units, supplied font metrics, + device scale, and the rounding policy for one-device-pixel rules. +- Color and compositing semantics, including clear backgrounds, replacement + background fills, image coverage, selection, and opaque native text/cursors. +- Stable image references and a defined frame lifetime, including snapshots + retained for transitions and postprocessing. + +Backends would continue to own native font selection, shaping/rasterization, +image upload/cache management, and presentation. Native event handling, window +management, and the text-only terminal frontend are outside this proposal. + +A small 2D operation vocabulary could include solid rectangles, positioned text +runs, images with source/destination rectangles, and explicit clips. Operations +must carry semantic blend behavior and a documented color space. Wrapping +`fillRect` and `drawText` while leaving each backend to build the scene would +preserve most of the duplication that caused these bugs. + +Do not freeze a new ABI before extracting one small path and checking its needs. +Font metrics must enter the shared layout explicitly; changing fonts can still +change line capacity and glyph appearance. Pixel equality across different +fonts, rasterizers, and display scales is not the acceptance criterion. + +## Compositing contract to preserve + +Let p be WindowOpacity in [0, 1]. An ordinary background region has alpha p, +regardless of how many logical layers cover it. Clear background regions remain +clear. Native text and cursors retain their own opacity. + +For an image sample with coverage a and straight RGB c, the existing SDL +background-layer behavior produces premultiplied output: + +``` +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 +with source alpha p*a is not equivalent. Any future operation API needs to +express this distinction directly and specify sampling and premultiplication. + +## Tests available before extraction + +`test/macos-snapshots/tag-ink.snap` checks actual rendered tag foreground pixels, +covering failures that a cell-grid golden cannot detect. + +`test/macos-snapshots/rendering-parity.snap` uses native backing-scale metrics +and checks rendered tag backgrounds and rules, top/bottom tags, opacity 100/71/0, +invalid opacity rejection, and nested multiline Tree-sitter context separators. +It also checks PDF placement and sampled page alpha at those opacity values, +height fit, tint modes, and scrolling. `context.zig` is the nested context fixture; +`docs/9p.pdf` is the existing PDF fixture. Optional PNG output is enabled with +`PARDES_TEST_CAPTURE_DIR`. + +The Zig test named `mac tag layer ABI preserves logical capacity and physical +grip` covers tag-bottom and border-color metadata as well as existing capacity +and grip behavior. The existing Linux `test/window_opacity.py` checks background +changes, native glyph preservation, zero opacity, invalid input, and restoration. + +Run on macOS: + +```sh +zig build unit-test -Dplatform=macos '-Dtest-filter=mac tag layer ABI' +zig build macos-e2e -Dplatform=macos +zig build -Dplatform=macos +``` + +These are baseline regressions, not a comprehensive cross-backend image oracle. +PDF alpha samples do not establish exact raster color or interpolation equality; +offscreen AppKit captures do not test the desktop compositor. Live comparison +still matters for window transparency and display color management. + +## Suggested later extraction and acceptance gates + +1. Add shared geometry/scene assertions for tags and context rows using supplied + metrics at several scales. Include clipping, partial rows, bottom tags, and + final separator order; expected values should come from the contract rather + than a copy of either backend's implementation. +2. Extract that scene construction once and adapt both native renderers. Keep + current backend pixel checks running without regenerating goldens merely to + accept differences. Compare matching fixtures and settings on both systems. +3. Add synthetic RGBA image coverage cases before extracting image composition: + opaque, transparent, and partial-alpha pixels over a known destination at + p=0, intermediate p, and p=1. Include fit, crop, and clip boundaries. +4. Extend the contract to the remaining overlays and retained transition frames. + Measure frame time and allocations before broadening the abstraction. + +The desired result is one definition of visual policy with small native drawing +adapters. A new GPU engine, shared font rasterizer, or wholesale backend rewrite +is not required to reach that boundary. diff --git a/src/macos.zig b/src/macos.zig index 4b37255e..bbfb8c08 100644 --- a/src/macos.zig +++ b/src/macos.zig @@ -931,7 +931,7 @@ export fn pardes_grid_col_at(x: f32, row: u16, body_w: f32, tagline_w: f32) u16 export fn pardes_topbar_pane_border_rgb() u32 { const rgb = pardes.config.gui_topbar_pane_border_rgb orelse fromTheme: { const st = state orelse return color_default; - break :fromTheme st.core.chromeTheme().scroll_track; + break :fromTheme st.core.chromeTheme().border; }; return @as(u32, rgb[0]) << 16 | @as(u32, rgb[1]) << 8 | rgb[2]; } @@ -1979,6 +1979,11 @@ export fn pardes_tag_layer_value(index: u32, field: u32) u32 { 8 => if (layer.cursor) |c| c.col else 65535, 9 => if (layer.cursor) |c| @intFromBool(c.bar) else 0, 10 => @as(u32, layer.bg[0]) << 16 | @as(u32, layer.bg[1]) << 8 | layer.bg[2], + 11 => @intFromBool(layer.kind == .pane and st.core.settings.tag_bottom), + 12 => rgb: { + const border = st.core.chromeTheme().border; + break :rgb @as(u32, border[0]) << 16 | @as(u32, border[1]) << 8 | border[2]; + }, else => 0, }; } @@ -2914,6 +2919,20 @@ test "mac tag layer ABI preserves logical capacity and physical grip" { defer core.surface.tag_layers[0] = .{}; try std.testing.expectEqual(@as(u32, 12), pardes_tag_layer_value(0, 0)); try std.testing.expectEqual(@as(u32, 0x123456), pardes_tag_layer_value(0, 10)); + try std.testing.expectEqual(@as(u32, 0), pardes_tag_layer_value(0, 11)); + core.settings.tag_bottom = true; + try std.testing.expectEqual(@as(u32, 1), pardes_tag_layer_value(0, 11)); + core.surface.tag_layers[0].kind = .column; + try std.testing.expectEqual(@as(u32, 0), pardes_tag_layer_value(0, 11)); + core.surface.tag_layers[0].kind = .pane; + const border = core.chromeTheme().border; + const border_rgb = @as(u32, border[0]) << 16 | @as(u32, border[1]) << 8 | border[2]; + try std.testing.expectEqual(border_rgb, pardes_tag_layer_value(0, 12)); + try std.testing.expectEqual(pardes.config.gui_topbar_pane_border_rgb orelse border, .{ + @as(u8, @intCast(pardes_topbar_pane_border_rgb() >> 16)), + @as(u8, @truncate(pardes_topbar_pane_border_rgb() >> 8)), + @as(u8, @truncate(pardes_topbar_pane_border_rgb())), + }); 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 })); diff --git a/src/macos/Sources/AppDelegate.swift b/src/macos/Sources/AppDelegate.swift index 107c40fd..4e91e407 100644 --- a/src/macos/Sources/AppDelegate.swift +++ b/src/macos/Sources/AppDelegate.swift @@ -478,7 +478,7 @@ final class AppDelegate: NSObject, NSApplicationDelegate, PardesViewDelegate { if let rgb = view.themeBG { backdrop.isHidden = true window.isOpaque = view.backgroundAlpha >= 1 - window.backgroundColor = NSColor( + window.backgroundColor = view.backgroundAlpha < 1 ? .clear : NSColor( srgbRed: CGFloat((rgb >> 16) & 0xFF) / 255, green: CGFloat((rgb >> 8) & 0xFF) / 255, blue: CGFloat(rgb & 0xFF) / 255, diff --git a/src/macos/Sources/PardesView.swift b/src/macos/Sources/PardesView.swift index ba3677e7..7c537055 100644 --- a/src/macos/Sources/PardesView.swift +++ b/src/macos/Sources/PardesView.swift @@ -1006,7 +1006,7 @@ final class PardesView: NSView { // up on themselves — a translucent ground would darken toward opaque // over a few frames otherwise. if clearGround || backgroundAlpha < 1 { ctx.clear(bounds) } - if !clearGround { fill(ctx, bounds, ground, backgroundAlpha) } + if !clearGround { fillBackground(ctx, bounds, ground, backgroundAlpha) } if frozenImages == nil { frameImages.removeAll(keepingCapacity: true) } guard cols > 0, rows > 0, Int(count) == cols * rows, let cells = suppliedCells ?? pardes_frame_cells() @@ -1060,7 +1060,7 @@ final class PardesView: NSView { if color != bgClear { let bandY = tagline ? y + bandTop : y let bandHeight = tagline ? taglines.height : cellHeight - fill(ctx, CGRect(x: CGFloat(start) * cellWidth, y: bandY, + fillBackground(ctx, CGRect(x: CGFloat(start) * cellWidth, y: bandY, width: CGFloat(col - start) * cellWidth, height: bandHeight), color, block ? 1 : backgroundAlpha) } @@ -1071,29 +1071,6 @@ final class PardesView: NSView { } } - // The rule joining the topbar band to the first pane-tag band. Both were - // centred in their own rows until now, and centring two reduced-height - // bands is exactly what leaves their unused half-bands touching with a - // strip of window background showing between them — the case - // config.gui_topbar_pane_border_px exists to close. Drawn only when that - // first pane row really carries a band, so a session whose second row is - // pane BODY gets no stray line across it. - let ruleThickness = taglines.borderThickness - let ruleColor = pardes_topbar_pane_border_rgb() - if ruleThickness > 0, ruleColor != UInt32(PARDES_COLOR_DEFAULT), - rows > Int(PARDES_TOPBAR_H) { - let base = Int(PARDES_TOPBAR_H) * cols - let joins = (0.. [FrozenBodyLayer] { var result: [FrozenBodyLayer] = [] for index in 0.., cols: Int, rows: Int) { + var layers: [[Int]] = [] for index in 0.. 0 { + fillBackground(ctx, CGRect(x: 0, y: taglines.borderTop, width: bounds.width, + height: taglines.borderThickness), + pardes_topbar_pane_border_rgb(), backgroundAlpha) + } } private func gripGlyph(_ text: String, face: Face) -> GripGlyph? { @@ -1288,10 +1289,13 @@ final class PardesView: NSView { private func drawTagLayer(_ ctx: CGContext, values: [Int], cells: UnsafePointer, hideCursor: Bool) { let left = CGFloat(values[4]) * cellWidth let y = CGFloat(values[5]) * cellHeight + taglines.top(row: values[5], canvasHeight: bounds.height) - let viewport = CGRect(x: left, y: y, width: CGFloat(values[6]) * cellWidth, height: taglines.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) ctx.saveGState() ctx.clip(to: viewport) - fill(ctx, viewport, UInt32(values[10]), backgroundAlpha) + fillBackground(ctx, viewport, UInt32(values[10]), backgroundAlpha) for pass in 0...1 { for col in 0..= viewport.maxY { break } - let rowStyle = resolve(cells[row*cols], block: false, ground: themeBG ?? pardesDefaultBG, clearGround: false) - fill(ctx, CGRect(x: left, y: y, width: viewport.width, height: height), rowStyle.bg, backgroundAlpha) + let rowStyle = resolve(cells[row*cols], block: false, ground: themeBG ?? pardesDefaultBG, clearGround: themeBG == nil) + fillBackground(ctx, CGRect(x: left, y: y, width: viewport.width, height: height), rowStyle.bg, backgroundAlpha) for pass in 0...1 { for col in 0..> 16) & 0xFF) / 255, - green: CGFloat((rgb >> 8) & 0xFF) / 255, - blue: CGFloat(rgb & 0xFF) / 255, - alpha: alpha) + // Theme channels, like PDF raster bytes, are sRGB. Device RGB can + // brighten them when AppKit's backing bitmap uses another profile. + ctx.setFillColor(CGColor(srgbRed: CGFloat((rgb >> 16) & 0xFF) / 255, + green: CGFloat((rgb >> 8) & 0xFF) / 255, + blue: CGFloat(rgb & 0xFF) / 255, + alpha: alpha)) + } + + /// One surface pixel has one background opacity, even when a compact + /// layer covers a canonical cell. Source-over would turn 71% into 92%, + /// then 98%, as the ground, row and cell are painted over each other. + private func fillBackground(_ ctx: CGContext, _ rect: CGRect, _ rgb: UInt32, _ alpha: CGFloat) { + ctx.saveGState() + ctx.setShouldAntialias(false) + if rgb == bgClear { + ctx.clear(rect) + } else { + ctx.setBlendMode(.copy) + fill(ctx, rect, rgb, alpha) + } + ctx.restoreGState() } private func fill(_ ctx: CGContext, _ rect: CGRect, _ rgb: UInt32, _ alpha: CGFloat) { diff --git a/src/macos/pardes.h b/src/macos/pardes.h index a2d13b1f..a2e34f53 100644 --- a/src/macos/pardes.h +++ b/src/macos/pardes.h @@ -353,6 +353,7 @@ void pardes_row_metrics(uint16_t body_w, uint16_t body_h, uint16_t tagline_w, ui uint32_t pardes_tag_text_inset(void); uint32_t pardes_grip_columns(void); uint32_t pardes_tag_layer_limit(void); +// Tag layer fields 11 and 12 carry tag-bottom placement and chrome border RGB. uint32_t pardes_tag_layer_value(uint32_t index, uint32_t field); const pardes_cell_s *pardes_tag_layer_cells(uint32_t index); uint32_t pardes_body_layer_limit(void); diff --git a/test/macos-snapshots/context.zig b/test/macos-snapshots/context.zig new file mode 100644 index 00000000..ff8f8553 --- /dev/null +++ b/test/macos-snapshots/context.zig @@ -0,0 +1,109 @@ +const Workspace = struct { + const enabled = true; + + fn draw( + value: u32, + ) u32 { + var result = value; + result +%= 1; + result +%= 2; + result +%= 3; + result +%= 4; + result +%= 5; + result +%= 6; + result +%= 7; + result +%= 8; + result +%= 9; + result +%= 10; + result +%= 11; + result +%= 12; + result +%= 13; + result +%= 14; + result +%= 15; + result +%= 16; + result +%= 17; + result +%= 18; + result +%= 19; + result +%= 20; + result +%= 21; + result +%= 22; + result +%= 23; + result +%= 24; + result +%= 25; + result +%= 26; + result +%= 27; + result +%= 28; + result +%= 29; + result +%= 30; + result +%= 31; + result +%= 32; + result +%= 33; + result +%= 34; + result +%= 35; + result +%= 36; + result +%= 37; + result +%= 38; + result +%= 39; + result +%= 40; + result +%= 41; + result +%= 42; + result +%= 43; + result +%= 44; + result +%= 45; + result +%= 46; + result +%= 47; + result +%= 48; + result +%= 49; + result +%= 50; + result +%= 51; + result +%= 52; + result +%= 53; + result +%= 54; + result +%= 55; + result +%= 56; + result +%= 57; + result +%= 58; + result +%= 59; + result +%= 60; + result +%= 61; + result +%= 62; + result +%= 63; + result +%= 64; + result +%= 65; + result +%= 66; + result +%= 67; + result +%= 68; + result +%= 69; + result +%= 70; + result +%= 71; + result +%= 72; + result +%= 73; + result +%= 74; + result +%= 75; + result +%= 76; + result +%= 77; + result +%= 78; + result +%= 79; + result +%= 80; + result +%= 81; + result +%= 82; + result +%= 83; + result +%= 84; + result +%= 85; + result +%= 86; + result +%= 87; + result +%= 88; + result +%= 89; + result +%= 90; + result +%= 91; + result +%= 92; + result +%= 93; + result +%= 94; + result +%= 95; + result +%= 96; + result +%= 97; + result +%= 98; + result +%= 99; + return result; + } +}; diff --git a/test/macos-snapshots/rendering-parity.golden b/test/macos-snapshots/rendering-parity.golden new file mode 100644 index 00000000..536f6800 --- /dev/null +++ b/test/macos-snapshots/rendering-parity.golden @@ -0,0 +1,14 @@ +== backgrounds tags-100 uniform +== backgrounds tags-bottom uniform +== backgrounds tags-71 uniform +== backgrounds tags-0 uniform +== 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 diff --git a/test/macos-snapshots/rendering-parity.snap b/test/macos-snapshots/rendering-parity.snap new file mode 100644 index 00000000..cdd940c8 --- /dev/null +++ b/test/macos-snapshots/rendering-parity.snap @@ -0,0 +1,54 @@ +start 40 110 +native-metrics +wait 8000 $ +command Theme forge +command TaglineSize 70 +stable 700 20000 +check-backgrounds tags-100 +command Tagbottom +stable 700 20000 +check-backgrounds tags-bottom +command Tagbottom +stable 700 20000 +command WindowOpacity 71 +stable 700 20000 +check-backgrounds tags-71 +command WindowOpacity 0 +stable 700 20000 +check-backgrounds tags-0 +command WindowOpacity 101 +stable 700 20000 +check-backgrounds invalid-stays-0 +command WindowOpacity 100 +open-fixture context.zig:55 +command TreeContext on +stable 700 20000 +capture context-initial +check-context context-100 +command WindowOpacity 71 +stable 700 20000 +check-context context-71 +command WindowOpacity 100 +open-fixture ../../docs/9p.pdf +stable 1000 20000 +check-pdf pdf-100 +command WindowOpacity 0 +stable 700 20000 +check-pdf pdf-0 +command WindowOpacity 71 +stable 700 20000 +check-pdf pdf-71 +command WindowOpacity 100 +command PdfFit +stable 700 20000 +check-pdf pdf-fit-height +command PdfTint +stable 700 20000 +check-pdf pdf-full-tint +command PdfTint +stable 700 20000 +check-pdf pdf-original-colors +command PdfFit +scroll 6 10 30 +stable 700 20000 +check-pdf pdf-scrolled diff --git a/test/macos-snapshots/tag-ink.golden b/test/macos-snapshots/tag-ink.golden new file mode 100644 index 00000000..dfb0704d --- /dev/null +++ b/test/macos-snapshots/tag-ink.golden @@ -0,0 +1 @@ +== tag-ink forge-tags visible diff --git a/test/macos-snapshots/tag-ink.snap b/test/macos-snapshots/tag-ink.snap new file mode 100644 index 00000000..e9e4c8e2 --- /dev/null +++ b/test/macos-snapshots/tag-ink.snap @@ -0,0 +1,8 @@ +start 24 80 +wait 8000 Newcol Joincol +wait 8000 $ +stable 700 20000 +command Theme forge +command TaglineSize 70 +stable 700 20000 +draw-tag-ink forge-tags diff --git a/test/macos_e2e.swift b/test/macos_e2e.swift index 43627a7e..5427c3ad 100644 --- a/test/macos_e2e.swift +++ b/test/macos_e2e.swift @@ -92,6 +92,8 @@ private final class Driver: PardesViewDelegate { private var window: NSWindow? private var view: PardesView? private var booted = false + private var nativeMetrics = false + private let scriptDirectory: String private var observer: NSObjectProtocol? private var output = "" private var nextAnimationFrame: Date? @@ -101,7 +103,8 @@ private final class Driver: PardesViewDelegate { /// The script's own file name, for error messages. private let scriptName: String - init(scriptName: String) { + init(scriptName: String, scriptDirectory: String) { + self.scriptDirectory = scriptDirectory self.scriptName = scriptName // The app answers this notification with pump(); so does the harness, // and for the same reason — the view calls into the core and never @@ -232,11 +235,17 @@ private final class Driver: PardesViewDelegate { let grid = view.gridSize // Points, not backing-store pixels. The app passes physical pixels // because the native PDF placement path measures in them; a golden must - // not change when the same script runs on a Retina display, and nothing - // here places a PDF. - let cellW = UInt16(max(1, min(view.cellWidth.rounded(), CGFloat(UInt16.max)))) - let cellH = UInt16(max(1, min(view.cellHeight.rounded(), CGFloat(UInt16.max)))) + // not change when the same grid script runs on a Retina display. Pixel + // parity scripts opt into native metrics below, including PDF placement. + let scale: CGFloat = nativeMetrics ? (window?.backingScaleFactor ?? 1) : 1 + let cellW = UInt16(max(1, min((view.cellWidth * scale).rounded(), CGFloat(UInt16.max)))) + let cellH = UInt16(max(1, min((view.cellHeight * scale).rounded(), CGFloat(UInt16.max)))) pardes_resize(grid.cols, grid.rows, cellW, cellH) + if nativeMetrics { + pardes_row_metrics(cellW, cellH, + UInt16(max(1, (view.taglineCellWidth * scale).rounded())), + UInt16(max(1, (view.taglineBandHeight * scale).rounded()))) + } pump() } @@ -498,6 +507,34 @@ private final class Driver: PardesViewDelegate { output += "== draw \(label) \(w)x\(h) nonblank\n" } + /// Forge's topbar must contain light ink, not CoreText's default black. + /// Restrict the sample to text, excluding grips, pane bodies and cursors. + private func drawTagInk(_ label: String) throws { + let view = try live() + let bounds = view.bounds + guard let rep = view.bitmapImageRepForCachingDisplay(in: bounds) else { + throw ScriptError(message: "draw-tag-ink: no bitmap") + } + view.cacheDisplay(in: bounds, to: rep) + let scale = CGFloat(rep.pixelsWide) / bounds.width + var brightest: CGFloat = 0 + for y in 0.. 0.5 else { + throw ScriptError(message: "draw-tag-ink: Forge topbar has no light foreground ink") + } + if let directory = ProcessInfo.processInfo.environment["PARDES_TEST_CAPTURE_DIR"], + let png = rep.representation(using: .png, properties: [:]) { + try png.write(to: URL(fileURLWithPath: directory).appendingPathComponent(label + ".png")) + } + output += "== tag-ink \(label) visible\n" + } + /// The alpha range of a drawn frame, recorded into the golden. /// /// The contract WindowOpacity states (shaders/ui.frag.glsl, and @@ -543,6 +580,122 @@ private final class Driver: PardesViewDelegate { output += "== draw-opacity \(label) \(w)x\(h) alpha \(lowest)..\(highest)\n" } + private func renderedCapture(_ label: String) throws -> NSBitmapImageRep { + let view = try live() + guard let rep = view.bitmapImageRepForCachingDisplay(in: view.bounds) else { + throw ScriptError(message: "capture: no bitmap") + } + view.cacheDisplay(in: view.bounds, to: rep) + if let directory = ProcessInfo.processInfo.environment["PARDES_TEST_CAPTURE_DIR"], + let png = rep.representation(using: .png, properties: [:]) { + try png.write(to: URL(fileURLWithPath: directory).appendingPathComponent(label + ".png")) + } + return rep + } + + // colorAt labels components as calibrated RGB even for a Display P3 + // bitmap. Reattach the bitmap's actual profile before comparing sRGB. + private func sample(_ rep: NSBitmapImageRep, x: Int, y: Int) -> NSColor? { + guard let raw = rep.colorAt(x: x, y: y) else { return nil } + let components = [raw.redComponent, raw.greenComponent, raw.blueComponent, raw.alphaComponent] + return NSColor(colorSpace: rep.colorSpace, components: components, count: 4).usingColorSpace(.sRGB) + } + + private func checkBackgrounds(_ label: String) throws { + let view = try live(), rep = try renderedCapture(label) + let scale = CGFloat(rep.pixelsWide) / view.bounds.width + func check(x: CGFloat, y: CGFloat, rgb: UInt32, name: String) throws { + guard let c = sample(rep, x: Int(x * scale), y: Int(y * scale)) else { + throw ScriptError(message: "\(name): no pixel") + } + guard abs(c.alphaComponent - view.backgroundAlpha) < 2.0 / 255 else { + throw ScriptError(message: "\(name): background alpha \(c.alphaComponent), expected \(view.backgroundAlpha)") + } + if view.backgroundAlpha > 0 { + let actual = [c.redComponent, c.greenComponent, c.blueComponent] + let expected = [CGFloat((rgb >> 16) & 255), CGFloat((rgb >> 8) & 255), CGFloat(rgb & 255)] + guard zip(actual, expected).allSatisfy({ abs($0 * 255 - $1) < 4 }) else { + throw ScriptError(message: "\(name): tag background does not cover the full row: \(actual) vs \(expected)") + } + } + } + for i in 0.. 0 else { continue } + let x = CGFloat(pardes_tag_layer_value(i, 4) + pardes_tag_layer_value(i, 6)) * view.cellWidth - 2 / scale + let top = CGFloat(pardes_tag_layer_value(i, 5)) * view.cellHeight + let height = Int(view.cellHeight * scale) + let kind = pardes_tag_layer_value(i, 1) + let bottom = kind == 2 && pardes_tag_layer_value(i, 11) != 0 + for pixel in 0.. 0 else { continue } + headers += count + let x = CGFloat(pardes_body_layer_value(i, 3) + pardes_body_layer_value(i, 5)) * view.cellWidth - 2 / scale + let top = CGFloat(pardes_body_layer_value(i, 4)) * view.cellHeight + for row in 0..> 16) & 255)) < 4, + abs(c.greenComponent * 255 - CGFloat((rgb >> 8) & 255)) < 4, + abs(c.blueComponent * 255 - CGFloat(rgb & 255)) < 4, + abs(c.alphaComponent - view.backgroundAlpha) < 2.0 / 255 else { + throw ScriptError(message: "context: separator is misplaced or has accumulated opacity") + } + } + } + guard headers >= 2, separators > 0 else { + throw ScriptError(message: "context: expected nested compact declarations, got \(headers) rows") + } + output += "== context \(label) compact separators verified\n" + } + + private func checkPDF(_ label: String) throws { + let view = try live(), rep = try renderedCapture(label) + guard nativeMetrics, pardes_frame_images() > 0, let images = pardes_frame_image_list() else { + throw ScriptError(message: "PDF: no native image placements") + } + let scale = window?.backingScaleFactor ?? 1 + let image = images[0] + let x = CGFloat(image.cell_x) * view.cellWidth + CGFloat(image.dst_x) / scale + let y = CGFloat(image.cell_y) * view.cellHeight + (CGFloat(image.dst_y) + CGFloat(image.offset_y)) / scale + let width = CGFloat(image.dst_w) / scale, height = CGFloat(image.dst_h) / scale + guard width > view.cellWidth * 4, height > view.cellHeight * 2, + y >= CGFloat(image.cell_y) * view.cellHeight - 1, + x + width <= view.bounds.width + 1, y + height <= view.bounds.height + 1 else { + 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 matched == 4 else { throw ScriptError(message: "PDF: raster opacity does not match WindowOpacity") } + output += "== pdf \(label) native page opacity verified\n" + } + // MARK: - the script func run(source: String) throws -> String { @@ -569,6 +722,23 @@ private final class Driver: PardesViewDelegate { let args = rest.split(separator: " ").map(String.init) switch cmd { + case "native-metrics": + nativeMetrics = true + pardesViewDidResize(try live()) + case "open-fixture": + _ = try live() + let path = URL(fileURLWithPath: scriptDirectory).appendingPathComponent(rest).standardized.path + let command = "Look " + path + pardes_command(command, command.utf8.count) + pump() + case "check-backgrounds": + try checkBackgrounds(rest) + case "check-context": + try checkContext(rest) + case "check-pdf": + try checkPDF(rest) + case "capture": + _ = try renderedCapture(rest) case "start": let rows = try int(args, 0, "start rows") let cols = try int(args, 1, "start cols") @@ -882,6 +1052,9 @@ private final class Driver: PardesViewDelegate { // place it can be checked: the core's cell buffer says nothing about // alpha, and `draw` deliberately compares channels without knowing // which one is which. + case "draw-tag-ink": + try drawTagInk(rest) + case "draw-opacity": guard !rest.isEmpty else { throw ScriptError(message: "draw-opacity needs a label") } try drawOpacity(rest) @@ -1125,7 +1298,7 @@ private func runOne(scriptPath: String, update: Bool) -> Bool { let goldenPath = String(scriptPath.dropLast(".snap".count)) + ".golden" let actualPath = String(scriptPath.dropLast(".snap".count)) + ".actual" - let driver = Driver(scriptName: name) + let driver = Driver(scriptName: name, scriptDirectory: (scriptPath as NSString).deletingLastPathComponent) // pardes_deinit is mandatory, not tidiness: the ABI is a singleton, so a // core left standing makes the NEXT script's pardes_init return 1. defer { driver.shutdown() } -- 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 'docs') 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 'docs') 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 'docs') 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 fd50bd971d6dea7eaaa4ee5436ba16b95fa25b30 Mon Sep 17 00:00:00 2001 From: Gabriel Schneider Date: Sun, 20 Sep 2026 02:34:12 -0300 Subject: Serve Unix and TCP 9P through cloud9.serve's std.Io runner The hand-written poll loop for Unix/TCP listeners is replaced by cloud9.serve.Runner; requests are queued to the editor thread, which answers them under the connection lock on each frame and retries parked reads as before. QUIC keeps the poll path (its adapter is fd based). The detached server no longer loses a wake that lands between frames. The firmware path keeps driving the engine with push/step. cloud9 re-pinned. Co-Authored-By: Claude Fable 5.1 --- build.zig.zon | 4 +- docs/cloud9.md | 11 +- docs/fs.md | 10 +- src/9p_io.zig | 565 +++++++++++++++++++++++++++++------------------- src/detached/server.zig | 56 ++--- src/gui/gui.zig | 6 +- src/macos.zig | 4 +- src/tty/tty.zig | 4 +- 8 files changed, 391 insertions(+), 269 deletions(-) (limited to 'docs') diff --git a/build.zig.zon b/build.zig.zon index 5bf0d5dc..cc53c227 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#65209217b5b68f56bc0bd5bc6c4dce33911ded59", - .hash = "cloud9-0.1.0-yt86qs3eEQDqC8duRUGBEWOLj82-iCpAb_afpu0KPjPB", + .url = "git+https://git.sr.ht/~gbrls/cloud9#ba7ec40782ba7020d82a56896a5eb1b52578d6aa", + .hash = "cloud9-0.1.0-yt86qiEeEwBu1DUzSB0tFDCD2R4CS5gSc_Lm1IXmlBwH", }, // 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 d31d2cb3..d5acc37c 100644 --- a/docs/cloud9.md +++ b/docs/cloud9.md @@ -13,8 +13,15 @@ The file-server engine (fids, jobs, parking, flush, hangup) is cloud9's 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. +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 +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 a9293393..55ffdc9c 100644 --- a/docs/fs.md +++ b/docs/fs.md @@ -40,8 +40,9 @@ IPv4/IPv6 addresses, not DNS names. Listener port zero chooses a free port; All connections have session access, including `os`. TCP is unencrypted. QUIC uses an ephemeral TLS identity without peer verification or login. It carries 9P2000 on one bidirectional stream with ALPN `pardes-9p`. -The four application connection slots are shared across transports; -OpenSSL's internal buffers are separate, dynamically allocated memory. +Unix and TCP connections share four slots served by cloud9's `std.Io` +runner; QUIC has four of its own on the editor's poll loop. 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, and `9ns` mounts the tree in a @@ -141,8 +142,9 @@ 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. +capacities); the transports are `src/9p_io.zig` (cloud9's `serve.Runner` +for Unix and TCP, a poll loop for QUIC, and the 9P client for mounts); +`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 diff --git a/src/9p_io.zig b/src/9p_io.zig index 57ce67b5..090eb838 100644 --- a/src/9p_io.zig +++ b/src/9p_io.zig @@ -2,7 +2,8 @@ const std = @import("std"); const libc = std.c; const builtin = @import("builtin"); const ninep = @import("9p.zig"); -const transport = @import("cloud9").transport; +const cloud9 = @import("cloud9"); +const transport = cloud9.transport; const pardes = @import("pardes.zig"); const limits = @import("memory.zig").limits; pub const quic_enabled = @import("9p_options").quic; @@ -140,49 +141,112 @@ fn localIp(address: std.Io.net.IpAddress) bool { 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. +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. const Conn = struct { - fd: c_int = -1, quic: if (quic_enabled) ?quic.Connection else void = if (quic_enabled) null else {}, draining: bool = false, accepted_ms: i64 = 0, srv: Srv = undefined, in: [msize]u8 = undefined, out: [2 * msize]u8 = undefined, - - fn step(c: *Conn, core: *pardes.Pardes, 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; - c.srv.reply(&reply, core.fsPayload(reply)); - } else core.perform(effect); - } - if (!answered) { - const reply = pardes.ctlfs.Reply.fail(req.tag, pardes.ctlfs.E.IO); - c.srv.reply(&reply, ""); - } - } }; const accept_pause_ms: i64 = 100; pub const Listener = struct { - fd: c_int = -1, - tcp_fd: c_int = -1, + io: std.Io, + 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, paused_ms: i64 = 0, path_buf: [sun_path_len]u8 = undefined, path_len: usize = 0, - conns: [max_conns]Conn = @splat(.{}), + conns: [quic_slots]Conn = @splat(.{}), control: [2]c_int = .{ -1, -1 }, watcher: ?std.Thread = null, - stopping: std.atomic.Value(bool) = .init(false), + watch_stop: std.atomic.Value(bool) = .init(false), watch_lock: std.atomic.Mutex = .unlocked, - watch_fds: [max_conns + 3 + @as(usize, @intFromBool(quic_enabled))]libc.pollfd = undefined, + watch_fds: [2]libc.pollfd = undefined, watch_len: usize = 0, watch_timeout: c_int = -1, wake_ctx: ?*anyopaque = null, @@ -192,104 +256,103 @@ pub const Listener = struct { return l.path_buf[0..l.path_len]; } - fn listenTcp(l: *Listener, address: std.Io.net.IpAddress) !void { - const fd = try transport.listenFd(.{ .tcp = address }, max_conns); - errdefer transport.close(fd); - var addr: libc.sockaddr.storage = undefined; - var len: libc.socklen_t = @sizeOf(@TypeOf(addr)); - if (libc.getsockname(fd, @ptrCast(&addr), &len) != 0) return error.SocketAddressFailed; - l.tcp_address = sockaddrIp(@ptrCast(&addr)) orelse return error.SocketAddressFailed; - l.tcp_fd = fd; - log.info("serving 9P2000 over TCP on {f}", .{l.tcp_address.?}); + fn of(ctx: ?*anyopaque) *Listener { + return @ptrCast(@alignCast(ctx.?)); } - pub fn accept(l: *Listener) void { - if (comptime !supported) return; - for ([_]c_int{ l.fd, l.tcp_fd }) |listener_fd| { - if (listener_fd < 0) continue; - for (0..max_conns + 1) |_| { - const fd = (transport.acceptFd(listener_fd, listener_fd == l.tcp_fd) catch { - l.paused_ms = nowMs() +| accept_pause_ms; - log.warn("accept failed; pausing the listener for {d} ms", .{accept_pause_ms}); - return; - }) orelse break; - const c = for (&l.conns, 0..) |*cand, i| { - if (!l.live(@intCast(i)) and !cand.draining) break cand; - } else { - log.debug("refusing a connection, all {d} slots busy", .{max_conns}); - _ = libc.close(fd); - continue; - }; - c.fd = fd; - c.draining = false; - c.accepted_ms = nowMs(); - c.srv = .init(.{ - .in = &c.in, - .out = &c.out, - .root = pardes.ctlfs.root, - }); - } + /// 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); + } + + 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; } - if (comptime quic_enabled) { - if (l.quic) |*listener| for (0..max_conns + 1) |_| { - var connection = (listener.accept() catch |err| { - log.warn("QUIC accept failed: {s}", .{@errorName(err)}); - return; - }) orelse break; - const c = for (&l.conns, 0..) |*cand, i| { - if (!l.live(@intCast(i)) and !cand.draining) break cand; - } else { - connection.deinit(); - continue; - }; - c.fd = -1; - c.quic = connection; - c.draining = false; - c.accepted_ms = nowMs(); - c.srv = .init(.{ .in = &c.in, .out = &c.out, .root = pardes.ctlfs.root }); - }; + 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 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 {}; + } + + fn kick(l: *Listener) void { + if (l.stopping.load(.acquire)) return; + if (l.wake) |f| f(l.wake_ctx); + } + + /// Accepts and reads QUIC connections (the runner does its own). + pub fn accept(l: *Listener) void { + if (comptime !quic_enabled) return; + if (l.quic) |*listener| for (0..max_conns + 1) |_| { + var connection = (listener.accept() catch |err| { + log.warn("QUIC accept failed: {s}", .{@errorName(err)}); + return; + }) orelse break; + const c = for (&l.conns, 0..) |*cand, i| { + if (!l.live(@intCast(i)) and !cand.draining) break cand; + } else { + connection.deinit(); + continue; + }; + c.quic = connection; + c.draining = false; + c.accepted_ms = nowMs(); + c.srv = .init(.{ .in = &c.in, .out = &c.out, .root = pardes.ctlfs.root }); + }; } pub const greet_deadline_ms: i64 = 5000; pub fn expire(l: *Listener) void { - if (comptime !supported) return; + if (comptime !quic_enabled) return; const now = nowMs(); if (now == 0) return; for (&l.conns, 0..) |*c, i| { if (!l.live(@intCast(i)) or c.srv.protocol.msize != 0) continue; if (now - c.accepted_ms < greet_deadline_ms) continue; - log.debug("slot {d} never sent Tversion; taking it back", .{i}); + log.debug("QUIC slot {d} never sent Tversion; taking it back", .{i}); l.drop(@intCast(i)); } } - pub fn accepting(l: *const Listener) bool { - if (comptime !supported) return false; - if (l.fd < 0 and l.tcp_fd < 0) return false; - if (l.paused_ms == 0) return true; - const now = nowMs(); - return now == 0 or now >= l.paused_ms; - } - pub fn nextDue(l: *const Listener) ?i32 { - if (comptime !supported) return null; + if (comptime !quic_enabled) return null; const now = nowMs(); if (now == 0) return null; var due: ?i64 = null; - if (l.paused_ms > now) due = l.paused_ms; - if (comptime quic_enabled) { - if (l.quic) |*listener| if (listener.nextDue()) |ms| { - const at = now + ms; - due = if (due) |d| @min(d, at) else at; - }; - } + if (l.quic) |*listener| if (listener.nextDue()) |ms| { + const at = now + ms; + due = if (due) |d| @min(d, at) else at; + }; for (&l.conns, 0..) |*c, i| { if (!l.live(@intCast(i))) continue; - if (comptime quic_enabled) { - if (c.quic) |*connection| if (connection.pending()) return 0; - } + if (c.quic) |*connection| if (connection.pending()) return 0; if (c.srv.protocol.msize != 0) continue; const at = c.accepted_ms + greet_deadline_ms; due = if (due) |d| @min(d, at) else at; @@ -301,16 +364,13 @@ pub const Listener = struct { const nowMs = transport.nowMs; pub fn fill(l: *Listener, i: u8) void { - if (comptime !supported) return; + if (comptime !quic_enabled) return; const c = &l.conns[i]; if (c.srv.protocol.dead) return l.drop(i); const room = c.srv.protocol.in.len - c.srv.protocol.in_len; if (room == 0) return; var buf: [msize]u8 = undefined; - const got = if (quic_enabled and c.quic != null) - (c.quic.?.read(buf[0..@min(room, buf.len)]) catch return l.drop(i)) orelse return - else - (transport.read(c.fd, buf[0..@min(room, buf.len)]) catch return l.drop(i)) orelse return; + const got = (c.quic.?.read(buf[0..@min(room, buf.len)]) catch return l.drop(i)) orelse return; if (got == 0) return l.drop(i); const n = c.srv.push(buf[0..@intCast(got)]); if (c.srv.protocol.dead) return l.drop(i); @@ -318,40 +378,29 @@ pub const Listener = struct { } pub fn flush(l: *Listener, i: u8) void { - if (comptime !supported) return; + if (comptime !quic_enabled) return; const c = &l.conns[i]; if (!l.live(i)) return; while (true) { const bytes = c.srv.output(); if (bytes.len == 0) return; - const n = if (quic_enabled and c.quic != null) - c.quic.?.write(bytes) catch return l.drop(i) - else - (transport.write(c.fd, bytes) catch return l.drop(i)) orelse return; + const n = c.quic.?.write(bytes) catch return l.drop(i); if (n == 0) return; c.srv.wrote(@intCast(n)); } } - pub fn owes(l: *const Listener, i: u8) bool { - return l.conns[i].srv.output().len != 0; - } - pub fn live(l: *const Listener, i: u8) bool { - return l.conns[i].fd >= 0 or (quic_enabled and l.conns[i].quic != null); + if (comptime !quic_enabled) return false; + return l.conns[i].quic != null; } pub fn drop(l: *Listener, i: u8) void { + if (comptime !quic_enabled) return; const c = &l.conns[i]; - if (c.fd >= 0) { - _ = libc.close(c.fd); - c.fd = -1; - } - if (comptime quic_enabled) { - if (c.quic) |*connection| { - connection.deinit(); - c.quic = null; - } + if (c.quic) |*connection| { + connection.deinit(); + c.quic = null; } if (c.draining or c.accepted_ms == 0) return; c.srv.hangup(); @@ -360,38 +409,80 @@ pub const Listener = struct { 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 = .{}; - for (&l.conns, 0..) |*conn, i| { - if (!l.live(@intCast(i)) and !conn.draining) continue; - var count: usize = 0; - while (conn.srv.retry()) |req| { - conn.step(core, req); - l.collectOs(core); - count += 1; - } - while (count < 64) { - const req = conn.srv.next() orelse break; - conn.step(core, req); - l.collectOs(core); - count += 1; + 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); } - result.count += count; - result.pending = result.pending or count >= 64; - if (conn.draining) { - if (count == 0) conn.draining = false else result.pending = true; - } else l.flush(@intCast(i)); - if (comptime quic_enabled) { + } + if (comptime quic_enabled) { + 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); + count += 1; + } + while (count < 64) { + const req = conn.srv.next() orelse break; + step(core, &conn.srv, req); + l.collectOs(core); + count += 1; + } + result.count += count; + result.pending = result.pending or count >= 64; + if (conn.draining) { + if (count == 0) conn.draining = false else result.pending = true; + } else l.flush(@intCast(i)); if (conn.quic) |*connection| result.pending = result.pending or connection.pending(); } } 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| { @@ -401,17 +492,44 @@ pub const Listener = struct { l.quic = null; l.quic_address = null; }; + l.accept(); + for (0..quic_slots) |i| if (l.live(@intCast(i))) l.fill(@intCast(i)); } - if (l.accepting()) l.accept(); - for (0..max_conns) |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 { - for (0..max_conns) |i| l.drop(@intCast(i)); - while (l.drain(core).pending) {} + for (0..quic_slots) |i| l.drop(@intCast(i)); + 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(); + 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); for (&l.conns) |*conn| conn.accepted_ms = 0; l.arm(); @@ -421,15 +539,7 @@ pub const Listener = struct { var i: usize = 0; while (i < core.fs.os_paths.items.len) { const entry = core.fs.os_paths.items[i]; - var held = false; - for (&l.conns, 0..) |*conn, j| { - if (!l.live(@intCast(j)) and !conn.draining) continue; - if (conn.srv.references(entry.node)) { - held = true; - break; - } - } - if (held) { + if (l.references(entry.node)) { i += 1; } else { core.gpa.free(entry.path); @@ -438,8 +548,42 @@ pub const Listener = struct { } } - pub fn wakeThread(l: *Listener, ctx: ?*anyopaque, wake: *const fn (?*anyopaque) void) !void { - if (l.watcher != null) return; + /// Whether any connection, or a release still to be paid, 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; + } + if (!conn.live()) continue; + conn.lock(); + defer conn.unlock(); + if (conn.engine.references(node)) return true; + } + } + for (&l.conns, 0..) |*conn, j| { + if (!l.live(@intCast(j)) and !conn.draining) continue; + if (conn.srv.references(node)) return true; + } + 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 { + 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; errdefer { _ = libc.close(l.control[0]); @@ -450,37 +594,18 @@ pub const Listener = struct { setCloexec(fd); setNonblock(fd); } - l.wake_ctx = ctx; - l.wake = wake; l.arm(); - l.watcher = try std.Thread.spawn(.{}, watch, .{l}); + l.watcher = try std.Thread.spawn(.{}, watchQuic, .{l}); } fn arm(l: *Listener) void { + if (comptime !quic_enabled) return; if (l.control[1] < 0) return; while (!l.watch_lock.tryLock()) std.atomic.spinLoopHint(); l.watch_fds[0] = .{ .fd = l.control[0], .events = @intCast(libc.POLL.IN), .revents = 0 }; l.watch_len = 1; - if (l.accepting()) { - for ([_]c_int{ l.fd, l.tcp_fd }) |fd| { - if (fd < 0) continue; - l.watch_fds[l.watch_len] = .{ .fd = fd, .events = @intCast(libc.POLL.IN), .revents = 0 }; - l.watch_len += 1; - } - } - if (comptime quic_enabled) { - if (l.quic) |*listener| { - l.watch_fds[l.watch_len] = listener.poll(); - l.watch_len += 1; - } - } - for (0..max_conns) |i| { - if (l.conns[i].fd < 0) continue; - l.watch_fds[l.watch_len] = .{ - .fd = l.conns[i].fd, - .events = @as(i16, @intCast(libc.POLL.IN)) | if (l.owes(@intCast(i))) @as(i16, @intCast(libc.POLL.OUT)) else 0, - .revents = 0, - }; + if (l.quic) |*listener| { + l.watch_fds[l.watch_len] = listener.poll(); l.watch_len += 1; } l.watch_timeout = l.nextDue() orelse -1; @@ -488,10 +613,10 @@ pub const Listener = struct { _ = libc.write(l.control[1], "w", 1); } - fn watch(l: *Listener) void { + fn watchQuic(l: *Listener) void { var notified = false; - while (!l.stopping.load(.acquire)) { - var fds: [max_conns + 3 + @as(usize, @intFromBool(quic_enabled))]libc.pollfd = undefined; + while (!l.watch_stop.load(.acquire)) { + var fds: [2]libc.pollfd = undefined; while (!l.watch_lock.tryLock()) std.atomic.spinLoopHint(); const len = if (notified) 1 else l.watch_len; @memcpy(fds[0..len], l.watch_fds[0..len]); @@ -505,26 +630,25 @@ pub const Listener = struct { notified = false; continue; } - if (!l.stopping.load(.acquire)) l.wake.?(l.wake_ctx); + if (!l.watch_stop.load(.acquire)) l.wake.?(l.wake_ctx); notified = true; } } pub fn deinit(l: *Listener, gpa: std.mem.Allocator) void { + l.stopping.store(true, .release); if (l.watcher) |thread| { - l.stopping.store(true, .release); + l.watch_stop.store(true, .release); _ = libc.write(l.control[1], "q", 1); thread.join(); for (l.control) |fd| _ = libc.close(fd); } - for (0..max_conns) |i| l.drop(@intCast(i)); + for (0..quic_slots) |i| l.drop(@intCast(i)); if (comptime quic_enabled) { if (l.quic) |*listener| listener.deinit(); } - if (l.tcp_fd >= 0) _ = libc.close(l.tcp_fd); - if (l.fd >= 0) { - _ = libc.close(l.fd); - l.fd = -1; + if (comptime supported) l.runner.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]); z[l.path_len] = 0; @@ -540,7 +664,7 @@ 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(gpa: std.mem.Allocator, named: []const u8, fallback: []const u8, tcp_dial: ?[]const u8, quic_dial: ?[]const u8) ?*Listener { +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 { if (comptime !supported) return null; var dir_buf: [sun_path_len:0]u8 = undefined; const dir = socketDir(&dir_buf) orelse { @@ -549,36 +673,38 @@ pub fn listen(gpa: std.mem.Allocator, named: []const u8, fallback: []const u8, t }; if (!ensureSocketDir(dir)) return null; const l = gpa.create(Listener) catch return null; - l.* = .{}; + l.* = .{ .io = io }; + l.runner.init(.{ + .io = io, + .root = pardes.ctlfs.root, + .handler = .{ .ctx = l, .serve = Listener.onServe, .opened = Listener.onOpened, .closed = Listener.onClosed }, + .greet_timeout_ms = Listener.greet_deadline_ms, + }); const p = socketPath(&l.path_buf, dir, if (named.len != 0) named else fallback) orelse { gpa.destroy(l); return null; }; - const fd = transport.listenFd(.{ .unix = p }, max_conns) catch |err| retry: { - const io = std.Io.Threaded.global_single_threaded.io(); + _ = l.runner.listen(.{ .unix = p }, max_conns) catch |err| retry: { const existing = std.Io.Dir.cwd().statFile(io, p, .{ .follow_symlinks = false }) catch null; - if (err != error.Bind or existing == null or existing.?.kind != .unix_domain_socket or alive(p)) { + if (err != error.AddressInUse or existing == null or existing.?.kind != .unix_domain_socket or alive(p)) { log.warn("something is already listening on {s}", .{p}); - gpa.destroy(l); + l.deinit(gpa); return null; } if (libc.unlink(p) != 0) { - gpa.destroy(l); + l.deinit(gpa); return null; } - break :retry transport.listenFd(.{ .unix = p }, max_conns) catch { - gpa.destroy(l); + break :retry l.runner.listen(.{ .unix = p }, max_conns) catch { + l.deinit(gpa); return null; }; }; + l.path_len = p.len; if (libc.chmod(p, 0o600) != 0) { - transport.close(fd); - _ = libc.unlink(p); - gpa.destroy(l); + l.deinit(gpa); return null; } - l.fd = fd; - l.path_len = p.len; if (tcp_dial) |dial| { if (!std.mem.startsWith(u8, dial, "tcp!")) { l.deinit(gpa); @@ -589,11 +715,13 @@ pub fn listen(gpa: std.mem.Allocator, named: []const u8, fallback: []const u8, t l.deinit(gpa); return null; }; - l.listenTcp(address) catch |err| { + const bound = l.runner.listen(.{ .tcp = address }, max_conns) catch |err| { log.warn("cannot listen on {s}: {s}", .{ dial, @errorName(err) }); l.deinit(gpa); return null; }; + l.tcp_address = canonicalIp(bound); + log.info("serving 9P2000 over TCP on {f}", .{l.tcp_address.?}); } if (quic_dial) |dial| { if (comptime quic_enabled) { @@ -651,9 +779,14 @@ test "a name that is not one path component is no address at all" { test "one connection's buffers are sized from the one msize constant" { try testing.expect(msize >= ninep.min_msize); - const c: Conn = .{}; - try testing.expectEqual(@as(usize, msize), c.in.len); - try testing.expectEqual(@as(usize, 2 * msize), c.out.len); + try testing.expectEqual(@as(u32, msize), Runner.msize); + try testing.expectEqual(@as(usize, msize), @typeInfo(@FieldType(Runner.Conn, "in")).array.len); + try testing.expectEqual(@as(usize, 2 * msize), @typeInfo(@FieldType(Runner.Conn, "out")).array.len); + try testing.expectEqual(@as(usize, max_conns), Runner.max_connections); + if (quic_enabled) { + const c: Conn = .{}; + try testing.expectEqual(@as(usize, msize), c.in.len); + } } test "TCP addresses are numeric and normalize mapped IPv4" { @@ -776,14 +909,14 @@ 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(gpa, "roundtrip", "", if (tcp) bind else null, if (tcp) null else bind) orelse return error.ListenFailed; + const l = listen(testing.io, gpa, "roundtrip", "", if (tcp) bind else null, if (tcp) null else bind) orelse return error.ListenFailed; defer { l.reset(p); l.deinit(gpa); } - try testing.expect(l.fd >= 0); - try testing.expectEqual(tcp, l.tcp_fd >= 0); - try testing.expectEqual(@as(usize, 4), l.conns.len); + try testing.expect(l.path().len != 0); + try testing.expectEqual(tcp, l.tcp_address != null); + try testing.expectEqual(@as(usize, 4), l.runner.conns.len); try testing.expect(l.watcher == null); const port = (if (tcp) l.tcp_address else l.quic_address).?.getPort(); try testing.expect(port != 0); @@ -802,11 +935,9 @@ test "Unix TCP and QUIC share one listener through reads writes reconnects and r } try testing.expect(worker.done.load(.acquire)); if (worker.failure) |err| return err; - const unix_fd = l.fd; - const tcp_fd = l.tcp_fd; l.reset(p); - try testing.expectEqual(unix_fd, l.fd); - try testing.expectEqual(tcp_fd, l.tcp_fd); + 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); } @@ -816,10 +947,10 @@ test "Unix TCP and QUIC share one listener through reads writes reconnects and r 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(gpa: std.mem.Allocator, core: *pardes.Pardes) ?*Listener { +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(gpa, core.opts.ninep_name, fallback, core.opts.ninep_tcp, core.opts.ninep_quic) orelse { + const listener = listen(io, gpa, core.opts.ninep_name, fallback, core.opts.ninep_tcp, core.opts.ninep_quic) orelse { core.reportError(0, "9p listener", error.ListenFailed); return null; }; @@ -869,7 +1000,7 @@ test "9P shell environment preserves identity when nested Look forwarding is dis const listener = try testing.allocator.create(Listener); defer testing.allocator.destroy(listener); - listener.* = .{}; + listener.* = .{ .io = testing.io }; const path = "/tmp/pardes-example.sock"; @memcpy(listener.path_buf[0..path.len], path); listener.path_len = path.len; diff --git a/src/detached/server.zig b/src/detached/server.zig index 6b82cd7b..ac9af2ee 100644 --- a/src/detached/server.zig +++ b/src/detached/server.zig @@ -35,7 +35,7 @@ const read_chunk = 16 * 1024; const pty_chunk = 64 * 1024; -const poll_slots = 2 + max_clients + pardes.MAX_PANES + 2 + 2 + @as(usize, @intFromBool(ninep_io.quic_enabled)) + ninep_io.max_conns; +const poll_slots = 2 + max_clients + pardes.MAX_PANES + 2 + @as(usize, @intFromBool(ninep_io.quic_enabled)); const reload_retries = 4; @@ -131,9 +131,7 @@ const Source = union(enum) { client: u8, pty: u8, inotify, - ninep_listener, ninep_quic, - ninep: u8, }; pub const Session = struct { @@ -158,6 +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`. + ninep_wake: std.atomic.Value(bool) = .init(false), watches: file_watch.Table = @splat(null), check_files: bool = false, in_loop: bool = false, @@ -587,9 +587,16 @@ pub const Session = struct { if (s.origins()) |c| s.send(c, .detach); } + /// The 9P runner has a request for `tick`: wake the poll loop. + fn wakeNinep(ctx: ?*anyopaque) void { + const s = of(ctx); + s.ninep_wake.store(true, .release); + s.mailbox.signal(); + } + fn pollFrame(ctx: ?*anyopaque) void { const s = of(ctx); - if (s.ninep) |l| s.ninep_pending = if (ninep_io.quic_enabled and l.quic != null) l.tick(s.core).pending else l.drain(s.core).pending; + if (s.ninep) |l| s.ninep_pending = l.tick(s.core).pending; for (&s.ptys, 0..) |*pt, pane| { if (pt.fd < 0) continue; var lbuf: [pardes.memory.limits.host_path_cap + 1]u8 = undefined; @@ -740,7 +747,10 @@ pub const Session = struct { fn waitInput(ctx: ?*anyopaque, timeout_ms: u32) void { const s = of(ctx); - const completed = s.drainCompletions(true); + // Both before the poll: a wake that landed since the last frame has + // had its byte drained here and must not be waited for again. + const drained = s.drainCompletions(true); + const completed = s.ninep_wake.swap(false, .acq_rel) or drained; for (&s.clients) |*c| if (c.fd >= 0) s.flush(c); const regridded = s.reconcile(); @@ -785,14 +795,8 @@ pub const Session = struct { n += 1; } if (s.ninep) |l| { - if (l.accepting()) { - for ([_]c_int{ l.fd, l.tcp_fd }) |fd| { - if (fd < 0) continue; - fds[n] = .{ .fd = fd, .events = poll_in, .revents = 0 }; - src[n] = .ninep_listener; - n += 1; - } - } + // Unix and TCP connections run on cloud9's runner, which wakes + // this loop through the mailbox; only QUIC is polled here. if (comptime ninep_io.quic_enabled) { if (l.quic) |*listener| { fds[n] = listener.poll(); @@ -800,16 +804,6 @@ pub const Session = struct { n += 1; } } - for (0..ninep_io.max_conns) |i| { - if (l.conns[i].fd < 0) continue; - fds[n] = .{ - .fd = l.conns[i].fd, - .events = if (l.owes(@intCast(i))) poll_in | poll_out else poll_in, - .revents = 0, - }; - src[n] = .{ .ninep = @intCast(i) }; - n += 1; - } } if (n == 0) 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))); @@ -850,20 +844,7 @@ pub const Session = struct { } }, .inotify => if (pfd.revents & poll_in != 0) s.drainInotify(), - .ninep_listener => if (pfd.revents != 0) { - if (s.ninep) |l| l.accept(); - }, .ninep_quic => {}, - .ninep => |i| if (s.ninep) |l| { - if (!l.live(i)) continue; - if (pfd.revents & poll_out != 0) l.flush(i); - if (!l.live(i)) continue; - if (pfd.revents & poll_in != 0) { - l.fill(i); - } else if (pfd.revents & (poll_hup | poll_err | poll_nval) != 0) { - l.drop(i); - } - }, }; } @@ -1153,8 +1134,9 @@ pub fn run(init: std.process.Init, opts: pardes.Options, name: []const u8) !void return error.NoSocket; } - session.ninep = ninep_io.listen(gpa, opts.ninep_name, name, opts.ninep_tcp, opts.ninep_quic); + session.ninep = ninep_io.listen(init.io, gpa, 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; diff --git a/src/gui/gui.zig b/src/gui/gui.zig index dbad10d4..27f3346c 100644 --- a/src/gui/gui.zig +++ b/src/gui/gui.zig @@ -2382,7 +2382,7 @@ fn localSession( inotify_fd = -1; }; var watches: file_watch.Table = @splat(null); - var fs = ninep_io.start(gpa, core); + var fs = ninep_io.start(io, gpa, core); defer if (fs) |f| f.deinit(gpa); var shell: Shell = .{ @@ -2412,7 +2412,7 @@ fn localSession( watch_stop = try stopPipe(); watch_reader = try std.Thread.spawn(.{}, watchThread, .{ inotify_fd, watch_stop[0], &queue }); } - if (fs) |f| try f.wakeThread(&queue, wakeFs); + if (fs) |f| try f.watch(&queue, wakeFs); _ = c.SDL_StartTextInput(g.window); @@ -2680,7 +2680,7 @@ fn runGrid(init: std.process.Init, opts_in: pardes.Options) !void { var pipe_tasks: PipeTasks = .{}; defer pipe_tasks.cancelAll(io); var watches: file_watch.Table = @splat(null); - const fs = ninep_io.start(gpa, core); + const fs = ninep_io.start(io, gpa, core); defer if (fs) |f| f.deinit(gpa); var shell: Shell = .{ .core = core, diff --git a/src/macos.zig b/src/macos.zig index d0d379de..79036c3e 100644 --- a/src/macos.zig +++ b/src/macos.zig @@ -745,7 +745,7 @@ fn initCore(runtime: ?*const Runtime, cols_arg: u16, rows_arg: u16) !void { .runtime = if (runtime) |r| r.* else .{}, }; const st = &state.?; - st.ninep = ninep_io.start(gpa, core); + st.ninep = ninep_io.start(io, gpa, core); core.host = hostFor(st); const cols = @max(1, cols_arg); @@ -754,7 +754,7 @@ fn initCore(runtime: ?*const Runtime, cols_arg: u16, rows_arg: u16) !void { while (core.nextEffect()) |effect| core.perform(effect); st.started = true; - if (st.ninep) |listener| listener.wakeThread(st, wakeNinep) catch |err| core.reportError(0, "9p wake", err); + if (st.ninep) |listener| listener.watch(st, wakeNinep) catch |err| core.reportError(0, "9p wake", err); for (&st.ptys, 0..) |*slot, id| if (slot.*) |*pt| startReader(st, pt, @intCast(id)); pardes.lsp.setStatusSink(st, lspStatusSink); diff --git a/src/tty/tty.zig b/src/tty/tty.zig index 1927577b..23b7c09b 100644 --- a/src/tty/tty.zig +++ b/src/tty/tty.zig @@ -653,7 +653,7 @@ fn localSession( var frame_arena: std.heap.ArenaAllocator = .init(allocs.frame); defer frame_arena.deinit(); - var fs = ninep_io.start(gpa, core); + var fs = ninep_io.start(io, gpa, core); defer if (fs) |f| f.deinit(gpa); var sh: Shell = .{ @@ -717,7 +717,7 @@ fn localSession( try startInput(loop, input_cache); defer if (attached.* == null) stopInput(loop); (try std.Thread.spawn(.{}, winchWatch, .{ loop, vx, tty })).detach(); - if (fs) |f| try f.wakeThread(loop, wakeFs); + if (fs) |f| try f.watch(loop, wakeFs); try vx.queryTerminalSend(tty.writer()); sh.threads_ok = true; -- cgit v1.3 From 0122e94fb37422085325f2dc78ca015051ce5f91 Mon Sep 17 00:00:00 2001 From: Gabriel Schneider Date: Mon, 21 Sep 2026 17:24:37 -0300 Subject: Advertise the editor in the posted-9P registry MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit pardes spoke 9P and could be mounted, but only by naming its socket: $XDG_RUNTIME_DIR/pardes-9p-.sock sits one directory above the registry and nothing could find it. Now a listening editor advertises itself at $XDG_RUNTIME_DIR/9p/pardes/, a symlink to the socket it already binds. One directory for the program, one entry per editor — the layout zmx posts its sessions under — so several editors group rather than crowd the registry root. The socket does not move: adopting the registry only advertises. Only the runtime-directory socket posts, so an instance on the ~/.local/state fallback stays out of the user's registry, the 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. The cloud9 pin moves to 9c4d668c for cloud9.post's path helpers. Serving is the whole of it. Consuming the registry is 9ns's job: it mounts the lot at /mnt/9p and an interactive fish already self-wraps in one, so a pardes started from a terminal reads /mnt/9p/harness/... with the same code that reads any other path. Two drafts that taught `resolve` to dial the registry itself were reverted — one duplicated 9ns for no gain, the other reinterpreted relative dials, which are a feature. `resolve` is byte-identical to what it was, and no dial that worked changes meaning. What pardes still does not do, and why, is in docs/cloud9.md: it binds its own socket rather than posting through cloud9.post, because post claims flat names only — legalName rejects '/', and claimName derives its lock directory by stripping "/9p" — so a name inside a subdirectory cannot go through it. zmx hand-rolls the same symlink for the same reason. Unifying them means teaching post a group, which is a change to adversarially-hardened code rather than a rename. docs/divergences.md records what this bookmark move leaves beside it: the editor line rruwvuzm (~1300 lines, forked at 01104e7c, still on the old cloud9 pin), the other bookmarks, and two failures that are not this change — fs-test's syntax-highlighting assertion, which fails identically on a clean main, and pardes not starting headless, which is why this is covered by 9p-io-test rather than by running the editor. Tests: 11/11 9p-io-test, including a listener that posts on start and unposts on stop; 31/31 unit-test. --- build.zig | 2 +- build.zig.zon | 4 +- docs/cloud9.md | 53 +++++++++++++++++++ docs/divergences.md | 70 +++++++++++++++++++++++++ src/9p_io.zig | 144 +++++++++++++++++++++++++++++++++++++++++++++++++++- 5 files changed, 269 insertions(+), 4 deletions(-) create mode 100644 docs/divergences.md (limited to 'docs') diff --git a/build.zig b/build.zig index 6734d9b0..a9bf4c0f 100644 --- a/build.zig +++ b/build.zig @@ -1284,7 +1284,7 @@ pub fn build(b: *std.Build) void { } const ninep_io_tests = b.addTest(.{ .root_module = ninep_io_module, - .filters = &.{ "Unix TCP", "one fetch", "expired sessions" }, + .filters = &.{ "Unix TCP", "one fetch", "expired sessions", "posts itself" }, }); b.step("9p-io-test", "run native 9P transport and client integration tests") .dependOn(&b.addRunArtifact(ninep_io_tests).step); diff --git a/build.zig.zon b/build.zig.zon index cc53c227..3a172f3b 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#ba7ec40782ba7020d82a56896a5eb1b52578d6aa", - .hash = "cloud9-0.1.0-yt86qiEeEwBu1DUzSB0tFDCD2R4CS5gSc_Lm1IXmlBwH", + .url = "git+https://git.sr.ht/~gbrls/cloud9#9c4d668c926e2d9eae6ef87cd9b391d8185605f9", + .hash = "cloud9-0.1.0-yt86qjAoGgBEPMJl2t4CZn7iWPMZUw4sMHAL54tq7spP", }, // 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 d5acc37c..79fda717 100644 --- a/docs/cloud9.md +++ b/docs/cloud9.md @@ -34,3 +34,56 @@ known test-environment limits. Invalid framing now terminates a server connection. Cloud9 also checks reply counts and reserves tags until flush completion. Client metadata is slightly larger to track those reservations, and its bounds tests reflect that fixed cost. + +## The posted-9P registry + +`$XDG_RUNTIME_DIR/9p` is this machine's `/srv`: a server posts itself in it +under a name, and clients dial names rather than paths. cloud9 owns both +sides (`cloud9.post`), and `9ns --mntgen` mounts the whole registry at +`/mnt/9p` for programs that want it as a filesystem. pardes's only part in +it is to put itself there. + +**Serving.** A listening editor advertises itself at +`$XDG_RUNTIME_DIR/9p/pardes/`, a symlink to the socket it already +binds. One directory for the program, one entry per editor, so several +editors group instead of crowding the registry root — the layout zmx posts +its sessions under. The socket itself does not move: adopting the registry +only advertises. Only the runtime-directory socket posts; an instance that +fell back to `~/.local/state/pardes` stays out of the user's registry, the +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. + +**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 — +`/mnt/9p/harness/active/...` is read with the same code that reads any other +path. Teaching pardes to dial the registry itself would put discovery in a +second place for no gain: mounting is the client's job and 9ns is the +client. `--mount==` keeps meaning exactly what it always did, +and a dial keeps resolving exactly as it always did — a bare name is another +pardes session, and anything with a slash is a path, relative ones included. + +The one case that is not free: a pardes started outside a mntgen mount has +no `/mnt/9p`. That is 9ns's problem to solve — by being in the namespace — +not a reason for pardes to carry its own registry client. + +### What this diverges from, deliberately + +* **pardes binds its own socket; it does not post through `cloud9.post`.** + `post` would give us its hardened claim protocol (temp-bind plus atomic + rename under a lock) instead of the stale-socket retry in `listen`, but it + claims *flat* names only: `legalName` rejects `/`, and `claimName` derives + its lock directory by stripping `/9p` from the registry path, so a name + inside a subdirectory cannot go through it. zmx hand-rolls the same + symlink for the same reason. Unifying them means teaching `post` a group — + passing the lock directory in rather than deriving it — and that is a + change to adversarially-hardened code, not a rename. +* **The registry entry is a symlink, not the socket.** A reader that expects + every registry entry to be a socket must `stat` following symlinks. + `9ns --mntgen` and `cloud9.post.dial` both do. +* **Dialing is untouched.** An earlier draft taught `resolve` to fall back + to the registry for a bare name and to read `/` as a + subdirectory entry. Both were reverted: the second reinterpreted relative + dials, which are a feature, and the first duplicated what 9ns already + does. `src/9p_io.zig`'s `resolve` is byte-identical to what it was. diff --git a/docs/divergences.md b/docs/divergences.md new file mode 100644 index 00000000..fada830c --- /dev/null +++ b/docs/divergences.md @@ -0,0 +1,70 @@ +# Divergences + +What is not on `main`, and what on `main` is known to be wrong. Written so +that moving a bookmark does not quietly orphan work or hide a failure. + +## Two lines, forked at `01104e7c` + +`main` is not the only living line, and the other one is not behind it — +they are siblings: + +``` +â—† rruwvuzm 09-17 editor work: syntax, panes, modal, gui, fs, output +│ â—† xqxpolmw 2b547e15 main 09-20 "Serve Unix and TCP 9P through cloud9.serve" +├─╯ +â—† lsnxpxtq 01104e7c 09-16 "Add macOS backdrop blur and preserve PDF ink opacity" +``` + +* **`main`** carries the 9P work: the `cloud9.serve` runner, and now the + posted-9P registry (`docs/cloud9.md`). +* **`rruwvuzm`** carries editor work — roughly 1300 lines across + `src/syntax.zig`, `src/panes.zig`, `src/modal.zig`, `src/gui/gui.zig`, + `src/fs.zig`, `src/pardes.zig`, `test/output.zig`, `docs/fs.md`. Reach it + with `jj edit rruwvuzm`. + +The fork matters for one concrete reason: **the cloud9 pin lives on `main` +only**. `rruwvuzm` still pins `ae310a20` (2026-09-14), `main` now pins +`9c4d668c`. Rebasing or merging the editor line will want the newer pin, or +`zig build` there fetches a cloud9 that predates `fs.Server`'s current shape. + +## Other bookmarks + +| bookmark | | | +|---|---|---| +| `reload-perf-wip` | 09-11 | unfinished: Reload presentation transport regression | +| `reload` | 09-10 | reload core code with shell-owned allocators | +| `reload-start` | 09-10 | names the Core/Shell seam, deferred Reload request | +| `ninep` | 08-27 | a 9P design note and a design registry to argue it in | +| `macos-fix` | 07-23 | | +| `full-prototype`, `term`, `tty-colors-mouse`, `vibes-ghostty`, `mouse` | 06-xx | older prototypes, also on the `vps` remote | + +None of these are published to the FreeBSD mirror: only `main` is pushed +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: + + ``` + AssertionError: ('fn', [{'fg': {'rgb': [201, 176, 228]}, ..., 'bold': False}, ...]) + ``` + + 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. + +* **pardes does not start headless.** `pardes --9p=` with no terminal + exits 1 from the argument-forwarding path; the installed build fails + earlier still, with `error.NoDevice` opening a terminal device. So the + registry posting above is covered by unit tests + (`zig build 9p-io-test`) rather than by running the editor. + +## Upstream + +`build.zig.zon` pins cloud9 `9c4d668c`. That commit exists because pinning +cloud9 `534c084f` here failed: cloud9's `build.zig` `@import`s each program's +build fragment, and `9harness` was missing from its `.paths`, so the +published package built from a checkout and not from a tarball. The pardes +build was the first consumer to notice. diff --git a/src/9p_io.zig b/src/9p_io.zig index 090eb838..4f7c2e97 100644 --- a/src/9p_io.zig +++ b/src/9p_io.zig @@ -241,6 +241,10 @@ pub const Listener = struct { paused_ms: i64 = 0, path_buf: [sun_path_len]u8 = undefined, path_len: usize = 0, + /// The registry entry this editor posted + /// (`$XDG_RUNTIME_DIR/9p/pardes/`), zero when it did not. + posted_buf: [sun_path_len]u8 = undefined, + posted_len: usize = 0, conns: [quic_slots]Conn = @splat(.{}), control: [2]c_int = .{ -1, -1 }, watcher: ?std.Thread = null, @@ -635,8 +639,91 @@ pub const Listener = struct { } } + /// Advertises this editor in the posted-9P registry so a + /// `9ns --mntgen` mount lists it and dials it on a walk: + /// `$XDG_RUNTIME_DIR/9p/pardes/` is a symlink to the socket + /// pardes already binds. One directory for the program, one entry + /// per running editor — the layout zmx uses for its sessions, so + /// several editors group instead of crowding the registry root. + /// + /// Only the runtime-directory socket posts: an instance that fell + /// back to `~/.local/state/pardes` stays out of the user's + /// registry, the way a private `ZMX_DIR` does for zmx. + /// + /// The socket itself is still bound by `listen` above, not by + /// `cloud9.post`: `post` claims flat names only, and its claim + /// protocol derives its lock directory from the registry path, so + /// a name inside a subdirectory cannot go through it yet. See + /// docs/cloud9.md. + fn postToRegistry(l: *Listener, name: []const u8) void { + if (comptime !supported) return; + if (name.len == 0 or std.mem.indexOfAny(u8, name, "/\x00") != null) return; + const xdg_c = libc.getenv("XDG_RUNTIME_DIR") orelse return; + const xdg = std.mem.span(xdg_c); + if (xdg.len == 0) return; + + var reg_buf: [sun_path_len:0]u8 = undefined; + const reg = std.fmt.bufPrintSentinel(®_buf, "{s}/9p", .{xdg}, 0) catch return; + _ = libc.mkdir(reg, 0o750); + var svc_buf: [sun_path_len:0]u8 = undefined; + const svc = std.fmt.bufPrintSentinel(&svc_buf, "{s}/9p/pardes", .{xdg}, 0) catch return; + if (libc.mkdir(svc, 0o750) != 0 and statNoFollow(svc) == null) { + log.warn("registry post skipped: cannot create {s}", .{svc}); + return; + } + 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}); + return; + }; + 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. + 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)) { + log.warn("registry entry pardes/{s} is live; not re-posted", .{name}); + return; + } + _ = libc.unlink(entry); + } + var target_z: [sun_path_len:0]u8 = undefined; + const target_zs = std.fmt.bufPrintSentinel(&target_z, "{s}", .{target}, 0) catch return; + if (libc.symlink(target_zs, entry) != 0) { + log.warn("registry post skipped: pardes/{s} is occupied", .{name}); + return; + } + @memcpy(l.posted_buf[0..entry.len], entry); + l.posted_len = entry.len; + log.info("posted pardes/{s} -> {s}", .{ name, target }); + } + + /// Removes the registry entry, but only while it is still ours: a + /// name another editor has since claimed is never unlinked. + fn unpostFromRegistry(l: *Listener) void { + if (comptime !supported) return; + if (l.posted_len == 0) return; + var z: [sun_path_len:0]u8 = undefined; + @memcpy(z[0..l.posted_len], l.posted_buf[0..l.posted_len]); + z[l.posted_len] = 0; + const entry = z[0..l.posted_len :0]; + var link_buf: [sun_path_len]u8 = undefined; + const n = libc.readlink(entry, &link_buf, link_buf.len); + if (n >= 0 and std.mem.eql(u8, link_buf[0..@intCast(n)], l.path_buf[0..l.path_len])) { + _ = libc.unlink(entry); + } + l.posted_len = 0; + } + pub fn deinit(l: *Listener, gpa: std.mem.Allocator) void { l.stopping.store(true, .release); + l.unpostFromRegistry(); if (l.watcher) |thread| { l.watch_stop.store(true, .release); _ = libc.write(l.control[1], "q", 1); @@ -680,7 +767,8 @@ pub fn listen(io: std.Io, gpa: std.mem.Allocator, named: []const u8, fallback: [ .handler = .{ .ctx = l, .serve = Listener.onServe, .opened = Listener.onOpened, .closed = Listener.onClosed }, .greet_timeout_ms = Listener.greet_deadline_ms, }); - const p = socketPath(&l.path_buf, dir, if (named.len != 0) named else fallback) orelse { + const entry_name = if (named.len != 0) named else fallback; + const p = socketPath(&l.path_buf, dir, entry_name) orelse { gpa.destroy(l); return null; }; @@ -705,6 +793,7 @@ pub fn listen(io: std.Io, gpa: std.mem.Allocator, named: []const u8, fallback: [ l.deinit(gpa); return null; } + l.postToRegistry(entry_name); if (tcp_dial) |dial| { if (!std.mem.startsWith(u8, dial, "tcp!")) { l.deinit(gpa); @@ -840,6 +929,59 @@ test "same-session TCP mounts compare canonical endpoints and local wildcard des extern "c" fn mkdtemp(template: [*:0]u8) ?[*:0]u8; extern "c" fn rmdir(path: [*:0]const u8) c_int; +test "a listening editor posts itself into the 9P registry and unposts on stop" { + if (comptime !supported) return error.SkipZigTest; + const gpa = testing.allocator; + var directory: [64:0]u8 = undefined; + _ = try std.fmt.bufPrintSentinel(&directory, "/tmp/pardes-post-XXXXXX", .{}, 0); + if (mkdtemp(&directory) == null) return error.TempDirectoryFailed; + const dir = std.mem.span(@as([*:0]const u8, &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)); + + var entry_buf: [sun_path_len:0]u8 = undefined; + const entry = try std.fmt.bufPrintSentinel(&entry_buf, "{s}/9p/pardes/unit", .{dir}, 0); + var svc_buf: [sun_path_len:0]u8 = undefined; + const svc = try std.fmt.bufPrintSentinel(&svc_buf, "{s}/9p/pardes", .{dir}, 0); + var sock_buf: [sun_path_len:0]u8 = undefined; + const sock = try std.fmt.bufPrintSentinel(&sock_buf, "{s}/" ++ prefix ++ "unit.sock", .{dir}, 0); + defer { + _ = libc.unlink(entry); + _ = rmdir(svc); + var reg_buf: [sun_path_len:0]u8 = undefined; + if (std.fmt.bufPrintSentinel(®_buf, "{s}/9p", .{dir}, 0)) |reg| { + _ = rmdir(reg); + } else |_| {} + _ = libc.unlink(sock); + _ = rmdir(&directory); + } + + var link: [sun_path_len]u8 = undefined; + { + const l = listen(testing.io, gpa, "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. + try testing.expect(statNoFollow(sock) != null); + // And the registry holds a symlink to it one directory down, so + // several editors group under /mnt/9p/pardes/ instead of + // crowding the registry root — the layout zmx posts its + // sessions in. + const n = libc.readlink(entry, &link, link.len); + try testing.expect(n > 0); + try testing.expectEqualStrings(sock, link[0..@intCast(n)]); + } + // Stopping takes the name back out, so the next editor of that name + // is not refused by its own corpse. + try testing.expect(libc.readlink(entry, &link, link.len) < 0); +} + test "Unix TCP and QUIC share one listener through reads writes reconnects and reset" { if (comptime !supported) return error.SkipZigTest; const gpa = testing.allocator; -- 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 'docs') 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 'docs') 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 5dcfade5f102256de787b2157b01293160780411 Mon Sep 17 00:00:00 2001 From: Gabriel Schneider Date: Mon, 21 Sep 2026 22:37:06 -0300 Subject: Make a pane by opening /pane/new, and a Plan 9 idiom pass The Tcreate that replaced acme's /new was a step away from the idiom dressed up as a step toward it. A pane is named by a server-assigned serial, so the create ignored the client's name: `mkdir /pane/foo` succeeded and left you /pane/12. A mkdir that does not make the directory you named is worse than the read-with-side-effect it replaced, and it broke in the shell workflow that motivated the change. `create` is out of the declared features, so Tcreate is EPERM again; Tremove stays, since `rm` to close a pane is unambiguously right. /pane/new is now opened, not created: the open makes the pane, the read of that fid answers its serial, two reads agree, and closing it leaves the pane. That is /net/tcp/clone's mechanism (kernel/network/ip/devip.c, in ipopen), not acme's, and the difference is deliberate. acme allocates during the walk and lands inside the new window, so /dev/new/body works in one step, and it can afford to list `new` because a Plan 9 directory read carries every entry's stat and nothing walks. A kernel or FUSE mount walks and stats each name a listing gave it, so allocate-on-walk would make a pane per `ls -l`. Allocating on open keeps `new` listed -- a stat is not an open -- at the cost of the one-step new/body. `new` stays unreachable from an editor path, because that resolution serves Look hover previews. The idiom pass behind it, read out of the Plan 9 tree at ~/05-genizah/principia-softwarica rather than recalled: Rerror carries a string, not an errno (man 5 error: `ename[s]`), and acme names every refusal. The five refusals pardes shares with acme now say what they mean; the generic sites keep their bare errno rather than invent strings acme does not have. body and tag declare DMAPPEND, which they had always behaved as (acme(4): "always appended; the file offset is ignored"), checked first against Linux's fs/9p, which never maps the bit. excl stays unset everywhere, because acme sets DMEXCL on nothing. Blocking reads, per-object addr scope and the readable pane ctl were already right. Real stat sizes and qid versions stay: acme reports length 0 and version 0 for everything, and Linux clients need better. One bug fell out of it. open reset the addr range, so `echo '#0,#5' >addr; cat addr` answered `0 0` and `cp addr dot` copied zeros. acme(4) makes the contract explicit -- "a regular expression may be evaluated by writing it to addr and reading it back" -- and acme gets away with resetting on the 0-to-1 open only because its clients hold the fid across both. A shell cannot: that is two opens. The register is cleared by truncating it now. Co-Authored-By: Claude Opus 5 (1M context) --- .agents/skills/pardes-9p/SKILL.md | 38 ++++++--- docs/fs.md | 40 +++++++--- docs/v9fs.md | 9 +++ features.txt | 5 ++ src/fs-help.txt | 10 +-- src/ninep/ctl.zig | 2 +- src/ninep/events.zig | 6 +- src/ninep/pane.zig | 8 +- src/ninep/pty.zig | 2 +- src/ninep/testing.zig | 26 ++---- src/ninep/tree.zig | 162 ++++++++++++++++++++++++++++---------- src/tutor.txt | 2 +- test/fs.py | 27 ++++--- test/v9fs.py | 29 +++---- 14 files changed, 239 insertions(+), 127 deletions(-) (limited to 'docs') diff --git a/.agents/skills/pardes-9p/SKILL.md b/.agents/skills/pardes-9p/SKILL.md index 2cea4d4a..91a8e864 100644 --- a/.agents/skills/pardes-9p/SKILL.md +++ b/.agents/skills/pardes-9p/SKILL.md @@ -49,7 +49,7 @@ $m/exec write a line = a middle click: an editor command word, or a shell $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/pane/new open it to make a pane, read names it; rmdir $m/pane/ closes it $m/os/ the host filesystem ``` @@ -60,7 +60,7 @@ 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 +n=$(cat "$m/pane/new") # make 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 @@ -69,10 +69,20 @@ 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 ``` -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. +**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 +the pane. A pane is named by the serial the editor gives it, never by a name +you choose. + +A *stat* makes nothing, which is the whole reason the allocation sits on open: +`new` is listed in `$m/pane`, so `ls` shows it, and `ls -l`, `find` and +anything else that stats every name a listing handed it stay inert. acme +allocates on the walk instead and lets it land inside the new window, so +`/dev/new/body` works in one step — it can afford that because a Plan 9 +directory read carries every entry's stat and nothing walks. Under a kernel or +FUSE mount that would be a pane per `ls -l`. Nothing else in the tree can be +created or removed, and no read creates anything. `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 @@ -107,11 +117,12 @@ search and reads empty until set; truncate it to lift it. 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`. +Address state belongs to the pane, not to a client: it keeps the last range +written until someone writes or truncates it, so writing an address and reading +it back evaluates it, and 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. @@ -209,8 +220,9 @@ with tempfile.TemporaryDirectory(prefix='pardes-9p-skill-') as directory: PY ``` -`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 +`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 +`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, and diff --git a/docs/fs.md b/docs/fs.md index 0bcc0313..8607a26f 100644 --- a/docs/fs.md +++ b/docs/fs.md @@ -79,19 +79,32 @@ Existing Plan9port/v9fs clients need a userspace bridge for QUIC. /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/ create a directory here to open a pane; remove one to close it +/pane/new open it to make a pane; the read answers that pane's serial /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. 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. +A pane is made by **opening** `/pane/new`, and closed by Tremove on +`/pane/` (`rmdir`), which is the only remove the tree serves; Tcreate is +refused everywhere, as it is in acme. Reading the open fid answers the serial +of the pane that open made, so `n=$(cat /pane/new)` makes one and names it in +a line. Each open makes another pane, and two reads of one fid answer the same +serial: the open acted, the read only observes. Closing the fid leaves the +pane. + +This is `/net/tcp/clone`'s mechanism, not acme's `new`, and the difference is +deliberate. acme allocates during the *walk* and lets the walk land inside the +new window, so `/dev/new/body` works in one step (acme(4): "accessing any file +in `new` creates a new window"). acme can also afford to list `new`, because a +Plan 9 directory read carries the stat of every entry and nothing walks. A +kernel or FUSE mount is not so lucky: it walks and stats each name a listing +gave it, so an allocate-on-walk name would make a pane per `ls -l`. Allocating +on open instead keeps `new` listed and `ls` honest — a stat is not an open — +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. `/look` and `/exec` are the editor's two clicks, one per line of a write: @@ -130,6 +143,9 @@ 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. +`addr` belongs to the pane rather than to a client and keeps what was written +until someone writes or truncates it, so writing an address and reading it +back evaluates it, which is what acme(4) promises of its own `addr`. 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 @@ -164,8 +180,8 @@ 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; 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 +metadata changes are refused, as is every create in the control tree and every +remove in it but a pane directory's. 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. @@ -180,9 +196,9 @@ for Unix and TCP, a poll loop for QUIC, and the 9P client for mounts); `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, that a pane create and remove work, and that `look`, `exec`, `name`, -`sel` and `log` behave. `zig build +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 +`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 8cc97ff9..1b14c21f 100644 --- a/docs/v9fs.md +++ b/docs/v9fs.md @@ -13,8 +13,17 @@ 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" ``` +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. + 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 sessions, including detached sessions. A frontend attaching from elsewhere does diff --git a/features.txt b/features.txt index bee079a7..a09607ea 100644 --- a/features.txt +++ b/features.txt @@ -68,3 +68,8 @@ 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. + +9p create semantics: doing an action on read is not how plan9 frames it. The canonical pattern is the clone file -- /net/tcp/clone -- where *opening* allocates the +object and reading the fid only tells you which one you got; acme's new/ctl is the same shape, and pardes's old /new already keyed its side effect on open. The +Tcreate that replaced it has a real wart: a pane is named by a server-assigned serial, so the create ignores the client's name and `mkdir /pane/foo` leaves you +/pane/12. Replace it with /pane/clone (open allocates, read answers the serial) and keep Tremove, which is unambiguously right. diff --git a/src/fs-help.txt b/src/fs-help.txt index 1e5d64c2..3113590a 100644 --- a/src/fs-help.txt +++ b/src/fs-help.txt @@ -8,16 +8,16 @@ exec write a line: a middle click, an editor command word or a shell line 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/ mkdir makes a pane, rmdir closes it +pane/new open it to make a pane; the read answers that pane's serial pane// name body tag ctl addr dot limit data xdata sel dirty mark scroll - errors event look exec, and pty/ for terminals + errors event look exec, and pty/ for terminals; rmdir closes it os/ the host filesystem src/ the editor's own sources, only in a -Dembed-sources=true build Below, $m is the mount point (PARDES_MOUNT in a Tty9p shell; 9ns and 9p work too): cat $m/index which panes exist - mkdir $m/pane/x; n=$(awk 'END{print $1}' $m/index) make a pane, take its serial + n=$(cat $m/pane/new) 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 @@ -31,8 +31,8 @@ Below, $m is the mount point (PARDES_MOUNT in a Tty9p shell; 9ns and 9p work too echo exec > $m/pane/$n/pty/ctl restart a shell; also winsize C R, sig INT Pitfalls, one each: - 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. + Each open of pane/new makes another pane; two reads of one fid name the same one. + Only that open creates: ls, stat, find and every other read leave the tree alone. 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. diff --git a/src/ninep/ctl.zig b/src/ninep/ctl.zig index c213ece5..7625f501 100644 --- a/src/ninep/ctl.zig +++ b/src/ninep/ctl.zig @@ -188,7 +188,7 @@ pub fn writePane(p: *Pardes, req: Req, pane: *Pane) Reply { 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); + if (!std.mem.eql(u8, line, "get")) return tree.failText(req.tag, E.INVAL, tree.e_bad_ctl); asked = true; } if (asked) { diff --git a/src/ninep/events.zig b/src/ninep/events.zig index bd53bcd9..d94fb54d 100644 --- a/src/ninep/events.zig +++ b/src/ninep/events.zig @@ -317,12 +317,12 @@ pub fn writeEvent(p: *Pardes, req: Req, id: usize) Reply { while (check.next()) |r| { switch (r.action) { .body_look, .tag_look, .body_exec, .tag_exec => {}, - else => return Reply.fail(req.tag, E.INVAL), + else => return tree.failText(req.tag, E.INVAL, tree.e_bad_event), } 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 (r.q0 > r.q1 or r.q1 > n) return tree.failText(req.tag, E.INVAL, tree.e_bad_event); } - if (check.i != req.data.len) return Reply.fail(req.tag, E.INVAL); + if (check.i != req.data.len) return tree.failText(req.tag, E.INVAL, tree.e_bad_event); } var run: EventReader = .{ .data = req.data }; while (run.next()) |r| { diff --git a/src/ninep/pane.zig b/src/ninep/pane.zig index 42c0c48e..4b34cf96 100644 --- a/src/ninep/pane.zig +++ b/src/ninep/pane.zig @@ -24,6 +24,12 @@ const Node = tree.Node; /// Filesystem state a pane carries beside its editor state. pub const State = struct { + /// The range `data` and `xdata` read and write through. acme clears it + /// when the first client opens `addr` (editors/acme/xfid.c:105), which + /// suits a client that holds the fid open and leaves a shell reading back + /// `0 0` from the address it just wrote. Here it is the pane's own + /// register, cleared by truncating the file, so that `cp addr dot` and + /// `cat addr` answer what was written. addr: Range = .{}, limit: ?Range = null, readers: u16 = 0, @@ -458,7 +464,7 @@ fn writeRange(p: *Pardes, req: Req, id: usize, pane: *Pane, file: PaneFile) Repl const pf = &p.fs.panes[id]; const text = bodyOf(pane); clampAddr(pf, text.len); - const r = rangeOf(pf, text, req.data) orelse return Reply.fail(req.tag, E.INVAL); + const r = rangeOf(pf, text, req.data) orelse return tree.failText(req.tag, E.INVAL, tree.e_bad_addr); switch (file) { .addr => pf.addr = r, .limit => pf.limit = r, diff --git a/src/ninep/pty.zig b/src/ninep/pty.zig index 1b71a8d3..c657d27d 100644 --- a/src/ninep/pty.zig +++ b/src/ninep/pty.zig @@ -42,7 +42,7 @@ pub fn writeCtl(p: *Pardes, req: Req, id: usize) Reply { 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); + if (!verb(p, id, line, apply)) return tree.failText(req.tag, E.INVAL, tree.e_bad_ctl); } } return .{ .tag = req.tag, .written = @intCast(req.data.len) }; diff --git a/src/ninep/testing.zig b/src/ninep/testing.zig index ad1d84e4..44329eee 100644 --- a/src/ninep/testing.zig +++ b/src/ninep/testing.zig @@ -69,26 +69,14 @@ pub fn look_up(p: *Pardes, dir: u64, name: []const u8) Answer { return call(p, .{ .tag = 3, .op = .lookup, .node = dir, .data = name }); } -/// Creates a pane in /pane, as a client's mkdir does, and returns its serial. +/// Makes a pane the way a client does, by walking to /pane/new, and answers +/// the serial of the pane the walk landed on. +/// The open is what makes the pane; the handle it answers is the serial, which +/// is also what a read of that fid reports. pub fn newPane(p: *Pardes) !u32 { - 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, - }); + const made = call(p, .{ .tag = 8, .op = .open, .node = @intFromEnum(tree.TopFile.new) }); + if (made.reply.status != .ok or made.reply.handle == 0) return error.NoPane; + return made.reply.handle; } pub fn rmdir(p: *Pardes, node: u64) Answer { diff --git a/src/ninep/tree.zig b/src/ninep/tree.zig index 46609649..5a0c1e11 100644 --- a/src/ninep/tree.zig +++ b/src/ninep/tree.zig @@ -5,7 +5,8 @@ //! and mounts. //! //! /README /index /status /look /exec /log /screen /listeners -//! /pane/ mkdir makes a pane, rmdir closes it +//! /pane/new an open makes a pane, a read names it +//! /pane/ rmdir closes that pane //! /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) @@ -49,14 +50,28 @@ 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 }; +/// 9P answers a failure with a string, not a number (man 5 error): the errno +/// still travels, for clients that map it, but the string is what a person +/// reads. acme names its refusals the same way, and these are its spellings +/// (editors/acme/xfid.c:19) for the ones this tree shares. +pub fn failText(tag: u64, errno: u16, text: []const u8) Reply { + return .{ .tag = tag, .status = .err, .errno = errno, .ename = text }; +} + +pub const e_bad_addr = "bad address syntax"; +pub const e_bad_ctl = "ill-formed control message"; +pub const e_bad_event = "bad event syntax"; + +/// Tremove closes a pane; nothing else in the tree is created or destroyed by +/// the protocol, and wstat stays a truncation. Making a pane is an open of +/// /pane/new, which needs no feature of the engine's, so Tcreate is refused +/// everywhere, as it is in acme (editors/acme/fsys.c, fsyscreate). +pub const features: cloud9.fs.Features = .{ .remove = true }; pub fn changesPane(req: Req) bool { return switch (req.op) { .write, .setattr => true, - .open => req.create, + .open => req.node == @intFromEnum(TopFile.new), .release => req.remove, .lookup, .getattr, .read, .readdir => false, }; @@ -77,6 +92,7 @@ pub const TopFile = enum(u4) { screen, listeners, pane, + new, pub fn fileName(f: TopFile) []const u8 { return if (f == .root) "/" else @tagName(f); @@ -86,7 +102,7 @@ pub const TopFile = enum(u4) { return switch (f) { .root, .pane => 0o755, .look, .exec => 0o666, - .README, .index, .status, .log, .screen, .listeners => 0o444, + .README, .index, .status, .log, .screen, .listeners, .new => 0o444, }; } @@ -187,8 +203,21 @@ fn paneFileNamed(name: []const u8) ?PaneFile { fn topFileNamed(name: []const u8) ?TopFile { const f = std.meta.stringToEnum(TopFile, name) orelse return null; - return if (f == .root) null else f; -} + // `new` is reached in /pane, where the panes it makes are. + return if (f == .root or f == .new) null else f; +} + +/// Opening /pane/new makes a pane and reading the open fid answers its +/// serial, which is /net/tcp/clone's mechanism exactly (kernel/network/ip/ +/// devip.c, `case Qclone` in ipopen, whose Qctl read prints the number it +/// allocated). acme spells the same idea as a directory made by the walk +/// (editors/acme/fsys.c:481), which would be the nicer `new/body`, but a +/// Plan 9 directory read carries every entry's stat and a kernel or FUSE +/// mount instead walks each name it listed: allocating on the walk would +/// make a pane every time someone ran `ls -l`. A stat is not an open, so +/// this file can be listed. Panes are named by their serial, so the name +/// can never collide with one. +pub const new_pane = "new"; fn serialNamed(name: []const u8) ?u32 { if (name.len == 0 or name.len > 10) return null; @@ -218,7 +247,12 @@ pub fn resolveSelf(p: *Pardes, path: []const u8) ?u64 { 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 next = parts.next() orelse return @intFromEnum(TopFile.pane); + // `new` is served on the wire but deliberately unreachable from an editor + // path: this resolves Look targets and hover previews, and a preview that + // opened `new` to see what was there would make a pane per hover. + if (std.mem.eql(u8, next, new_pane)) return null; + const serial = serialNamed(next) 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; @@ -258,9 +292,9 @@ pub fn stagedReply(p: *Pardes, req: Req) Reply { pub fn handle(p: *Pardes, req: Req) Reply { 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); + // Only a pane directory is removed. The host tree and the embedded + // sources say so, rather than quietly doing nothing. + if ((host or archive) and 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); @@ -302,6 +336,10 @@ fn attrOf(p: *Pardes, target: Target) ?Reply.Attr { .size = pane.fileSize(p, id, t.file), .mtime = pane.mtimeOf(p, pn), .version = pane.versionOf(pn, t.file), + // A write to body or tag appends whatever its offset says, + // which is why acme's dirtab marks both DMAPPEND + // (editors/acme/fsys.c:78). + .append = t.file == .body or t.file == .tag, }; }, } @@ -314,8 +352,9 @@ fn attrReply(p: *Pardes, tag: u64, target: Target) Reply { fn topSize(p: *Pardes, f: TopFile) u64 { return switch (f) { - // ponytail: /screen has no length until an open renders its frame. - .root, .pane, .screen => 0, + // ponytail: /screen has no length until an open renders its frame, + // and /pane/new none until an open has a pane to name. + .root, .pane, .screen, .new => 0, .index => pane.indexLen(p), .README => fs.help.len, .status => ctl.statusLen(p), @@ -348,6 +387,7 @@ fn lookup(p: *Pardes, req: Req, target: Target) Reply { return Reply.fail(req.tag, E.NOENT); }, .pane => pane: { + if (std.mem.eql(u8, name, new_pane)) break :pane @intFromEnum(TopFile.new); const serial = serialNamed(name) orelse return Reply.fail(req.tag, E.NOENT); break :pane Node.of(serial, .dir); }, @@ -396,6 +436,7 @@ fn readdir(p: *Pardes, req: Req, target: Target) Reply { sources.stage(p, out, "", &skip); }, .pane => { + if (skip > 0) skip -= 1 else stageDirent(out, p.gpa, @intFromEnum(TopFile.new), false, TopFile.new.fileName()); var last: u32 = 0; while (nextSerialAfter(p, last)) |serial| { last = serial; @@ -426,27 +467,19 @@ fn readdir(p: *Pardes, req: Req, target: Target) Reply { return .{ .tag = req.tag, .payload = .{ .staged = @intCast(out.items.len) } }; } -/// 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); +/// Opens a pane for an open of /pane/new, whose serial becomes the handle: +/// the fid remembers which pane it made, so reading it twice answers the +/// same one and closing it leaves the pane alone. +fn makePane(p: *Pardes) ?u32 { + const slot = p.freeSlot() orelse return null; p.newScratchBelow(p.active); - 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 }; + return (p.panes[slot] orelse return null).serial; } fn open(p: *Pardes, req: Req, target: Target) Reply { - if (req.create) return create(p, req, target); switch (target) { .top => |f| switch (f) { + .new => return .{ .tag = req.tag, .handle = makePane(p) orelse return Reply.fail(req.tag, E.NFILE) }, .screen => return screen.openSnapshot(p, req, true), .log => p.fs.log_readers +|= 1, else => {}, @@ -458,7 +491,6 @@ 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), - .addr => pf.addr = .{}, .event => { pf.readers +|= 1; p.fs.listeners +|= 1; @@ -552,6 +584,14 @@ fn read(p: *Pardes, req: Req, target: Target) Reply { .log => events.readQueue(p, req, &p.fs.log), .screen => screen.readSnapshot(p, req, null), .listeners => screen.readListeners(p, req), + // The serial the open handed this fid, so that two reads of one + // fid answer the same pane: the read observes, the open acted. + .new => serial: { + if (req.handle == 0) break :serial Reply.fail(req.tag, E.IO); + p.fs.stage(p.gpa).print(p.gpa, "{d}\n", .{req.handle}) catch + break :serial Reply.fail(req.tag, E.NOMEM); + break :serial stagedReply(p, req); + }, .root, .pane => Reply.fail(req.tag, E.PERM), }, .pane => |t| { @@ -655,7 +695,9 @@ 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.pane), .data = "x", .create = true, .perm = cloud9.dmdir | 0o755 }, + // Opening `new` is what makes a pane now; walking to it makes none, + // and so must leave a pending hover alone. + .{ .tag = 2, .op = .open, .node = @intFromEnum(TopFile.new) }, .{ .tag = 3, .op = .setattr, .node = 0, .truncate = true }, }; for (requests) |request| { @@ -719,6 +761,14 @@ test "readdir lists the root and a pane directory without creating anything" { 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); + // `new` is listed, so `ls` shows it. Walking and stat-ing it allocates + // nothing — only an open does — which is what keeps `ls -l` and any other + // client that stats every name a listing gave it inert. + const shown = th.nameAt(listed, new_pane).?; + try testing.expect(!shown.dir); + try testing.expectEqual(Status.ok, look_up(p, @intFromEnum(TopFile.pane), new_pane).reply.status); + try testing.expectEqual(Status.ok, call(p, .{ .tag = 1, .op = .getattr, .node = @intFromEnum(TopFile.new) }).reply.status); + try testing.expectEqual(before, p.next_serial); const dir = rdir(p, Node.of(serial, .dir), 0); const files = th.dirents(dir.bytes, &buf); @@ -780,38 +830,58 @@ 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 "creating in the pane directory opens a pane and removing one closes it" { +test "opening /pane/new makes 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 panes_dir = @intFromEnum(TopFile.pane); - // Browsing /pane creates nothing; only a create does. + // Browsing /pane creates nothing, and neither does walking or stat-ing + // `new` itself: only an open does. That is what lets `new` be listed at + // all, since `ls -l` stats every name a listing handed it. try testing.expectEqual(Status.ok, rdir(p, panes_dir, 0).reply.status); + try testing.expectEqual(Status.ok, look_up(p, panes_dir, new_pane).reply.status); + try testing.expectEqual(Status.ok, call(p, .{ .tag = 1, .op = .getattr, .node = @intFromEnum(TopFile.new) }).reply.status); try testing.expectEqual(before, p.next_serial); - const made = th.mkdir(p, "scratch"); + // The open makes the pane and hands back its serial; the read only + // observes, so two reads of one fid answer the same pane. + const made = call(p, .{ .tag = 2, .op = .open, .node = @intFromEnum(TopFile.new) }); try testing.expectEqual(Status.ok, made.reply.status); try testing.expectEqual(before + 1, p.next_serial); const serial = before + 1; - try testing.expectEqual(Node.of(serial, .dir), made.reply.attr.node); - try testing.expect(made.reply.attr.dir); + try testing.expectEqual(serial, made.reply.handle); var expected: [16]u8 = undefined; - try testing.expectEqualStrings(try std.fmt.bufPrint(&expected, "{d}", .{serial}), made.reply.attr.name); + const want = try std.fmt.bufPrint(&expected, "{d}\n", .{serial}); + for (0..2) |_| { + const answer = call(p, .{ .tag = 3, .op = .read, .node = @intFromEnum(TopFile.new), .handle = made.reply.handle, .size = 64 }); + try testing.expectEqualStrings(want, answer.bytes); + } const id = p.paneBySerial(serial).?; try testing.expectEqualStrings("", p.panes[id].?.file.?.content); _ = wr(p, Node.of(serial, .body), "hi"); - const second = th.mkdir(p, "another"); + + // A second open is a second pane, and releasing a clone fid leaves the + // pane it made standing. + const second = call(p, .{ .tag = 4, .op = .open, .node = @intFromEnum(TopFile.new) }); try testing.expectEqual(Status.ok, second.reply.status); - try testing.expect(second.reply.attr.node != made.reply.attr.node); + try testing.expect(second.reply.handle != made.reply.handle); + _ = call(p, .{ .tag = 5, .op = .release, .node = @intFromEnum(TopFile.new), .handle = made.reply.handle, .opened = true }); + try testing.expect(p.paneBySerial(serial) != null); try testing.expectEqualStrings("hi", p.panes[id].?.file.?.content); - // 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()); + // The tree declares no create, so the engine refuses every Tcreate + // (cloud9 fs.zig: `.tcreate => if (features.create) ... else fail(e_perm)`), + // and `new` is the only name in /pane that is not a serial. + try testing.expect(!features.create); + try testing.expectEqual(E.NOENT, look_up(p, panes_dir, "scratch").errno()); + try testing.expectEqual(E.NOENT, look_up(p, root, new_pane).errno()); + // ...and it is listed, because the user asked to see it in `ls`. + var listing: [32]th.Dirent = undefined; + const shown = rdir(p, panes_dir, 0); + try testing.expect(th.nameAt(th.dirents(shown.bytes, &listing), new_pane) != null); // 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()); @@ -858,4 +928,10 @@ test "editor paths resolve to the same nodes the wire serves" { try testing.expect(resolveSelf(p, "status/ctl") == null); try testing.expect(resolveSelf(p, "cons") == null); try testing.expect(resolveSelf(p, "pane/0") == null); + // The editor resolves its own paths to inspect them, so `new` names + // nothing here; only a client's walk makes a pane. + const before = p.next_serial; + try testing.expect(resolveSelf(p, "pane/new") == null); + try testing.expect(resolveSelf(p, "pane/new/body") == null); + try testing.expectEqual(before, p.next_serial); } diff --git a/src/tutor.txt b/src/tutor.txt index adf4ae3a..ab73be33 100644 --- a/src/tutor.txt +++ b/src/tutor.txt @@ -396,7 +396,7 @@ typed /pane//body /index - /pane mkdir here makes a pane, rmdir closes it + /pane/new open it to make a pane; rmdir closes one /look /exec `FILE:12` and `Save`, as the mouse does A terminal pane also has `pty/`: diff --git a/test/fs.py b/test/fs.py index c3ffa440..b20dc8ee 100644 --- a/test/fs.py +++ b/test/fs.py @@ -106,9 +106,8 @@ def newest(client): def new_pane(client, contents): - """mkdir in /pane; the editor names the directory after the new serial.""" - client.mkdir('/pane', 'scratch') - serial = newest(client) + """An open of /pane/new makes a pane; the read names it.""" + serial = int(client.read('/pane/new')) if contents: client.write(f'/pane/{serial}/body', contents) return serial @@ -151,7 +150,7 @@ def discovery(binary, embedded=False): assert ('src' in top) == embedded, (top, embedded) before = client.read('/index') guide = client.read('/README') - assert guide.count(b'\n') <= 45 and b'Msg hello' in guide and b'mkdir' in guide, guide + assert guide.count(b'\n') <= 45 and b'Msg hello' in guide and b'pane/new' 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) @@ -183,17 +182,20 @@ def discovery(binary, embedded=False): 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. + # An open of /pane/new makes a pane and the read names it; each + # open makes another. A stat makes none, which is why new can be + # listed at all: ls -l stats every name a listing gave it. log = client.open('/log') - client.mkdir('/pane', 'one') - first = newest(client) - client.mkdir('/pane', 'two') - second = newest(client) + first = int(client.read('/pane/new')) + assert first == newest(client) + second = int(client.read('/pane/new')) assert first != second and first != fixture, (first, second) - assert 'one' not in client.list('/pane') and 'two' not in client.list('/pane') + assert 'new' in client.list('/pane'), 'new should be visible to ls' + client.stat('/pane/new') + assert newest(client) == second, 'a stat of new made a 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)} + assert set(client.list('/pane')) == {'new', 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'' @@ -247,6 +249,7 @@ def discovery(binary, embedded=False): refused = [lambda: client.write('/exec', b'Msg a\x00b'), lambda: client.write('/status', b'anything\n'), lambda: client.mkdir('/', 'x'), + lambda: client.mkdir('/pane', 'one'), lambda: client.create('/pane', 'plain-file'), lambda: client.remove('/pane/1/body'), lambda: client.remove('/index')] @@ -262,7 +265,7 @@ def discovery(binary, embedded=False): 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; create, remove, look, exec, name, sel and log behave') + print('9P discovery: listing/stat/find are inert; new, remove, look, exec, name, sel and log behave') def test(binary, quic=False): diff --git a/test/v9fs.py b/test/v9fs.py index fa35388f..30efe9fb 100644 --- a/test/v9fs.py +++ b/test/v9fs.py @@ -45,6 +45,7 @@ def worker(mountpoint, socket, uid, gid, original_namespace): tree = mountpoint 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) + assert 'new' not in os.listdir(tree / 'pane'), 'a listing would make a pane per stat' # A direct connection provides independent evidence for VFS reads/writes. with Client(socket) as client: assert (tree / 'index').read_bytes() == client.read('/index') @@ -55,26 +56,22 @@ def worker(mountpoint, socket, uid, gid, original_namespace): subprocess.run(['find', str(tree / 'pane'), '-ls'], check=True, capture_output=True, timeout=5) assert (tree / 'README').read_bytes() == client.read('/README') assert client.read('/index') == before, 'browsing created panes' - # 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. + # Opening pane/new makes a pane and the read names it, so no trip + # through the index. Whether a repeated path reaches the server at all + # is the kernel's dentry cache's business, so the second pane comes + # over the wire, where the open is exact. def serials(): return {int(row.split()[0]) for row in (tree / 'index').read_bytes().splitlines()} - def mkpane(name): + def mkpane(): 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() + made = int((tree / 'pane' / 'new').read_bytes()) + assert made not in known, 'the open of new made no pane' + return made + + serial = mkpane() + another = int(client.read('/pane/new')) + assert serial != another, 'a second open of new reused a pane' (tree / 'pane' / str(another)).rmdir() assert another not in serials() pane = tree / 'pane' / str(serial) -- 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 'docs') 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 'docs') 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 'docs') 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 'docs') 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 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 'docs') 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 'docs') 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 'docs') 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 'docs') 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;;',2),Dt=$A('',6),yt=$A('Unmute (m)',2),pt=$A('Mute (m)',2),kt=$A('',2),mt=$A('
',18),qt=$A('',6);function Lt(A){let e=Math.floor(A);const t=Math.floor(e/86400);e%=86400;const V=Math.floor(e/3600);e%=3600;const g=Math.floor(e/60);return e%=60,t>0?`${Ft(t)}:${Ft(V)}:${Ft(g)}:${Ft(e)}`:V>0?`${Ft(V)}:${Ft(g)}:${Ft(e)}`:`${Ft(g)}:${Ft(e)}`}function Ft(A){return A<10?`0${A}`:A.toString()}var Mt=A=>{const e=A=>e=>{e.preventDefault(),A(e)},t=()=>"number"==typeof A.currentTime?Lt(A.currentTime):"--:--",V=()=>"number"==typeof A.remainingTime?"-"+Lt(A.remainingTime):t(),g=uA((()=>"number"==typeof A.duration?A.markers.filter((e=>e[0]{const e=A.currentTarget.offsetWidth,t=A.currentTarget.getBoundingClientRect(),V=A.clientX-t.left;return 100*Math.max(0,V/e)+"%"},[r,i]=EA(!1),o=function(A,e){let t=!0;return function(...V){t&&(t=!1,A.apply(this,V),setTimeout((()=>t=!0),e))}}(A.onSeekClick,50),I=e=>{e._marker||e.altKey||e.shiftKey||e.metaKey||e.ctrlKey||0!==e.button||(i(!0),A.onSeekClick(n(e)))},B=A=>{A.altKey||A.shiftKey||A.metaKey||A.ctrlKey||r()&&o(n(A))},s=()=>{i(!1)};return document.addEventListener("mouseup",s),hA((()=>{document.removeEventListener("mouseup",s)})),(()=>{const n=mt.cloneNode(!0),r=n.firstChild,i=r.firstChild,o=i.nextSibling,s=r.nextSibling,C=s.nextSibling,Q=C.firstChild,a=C.nextSibling,E=a.firstChild,c=A.ref;return"function"==typeof c?Ae(c,n):A.ref=n,ee(n,TA(OA,{get when(){return A.isPausable},get children(){const t=ht.cloneNode(!0);return PA(t,"click",e(A.onPlayClick)),ee(t,TA(xA,{get children(){return[TA(ZA,{get when(){return A.isPlaying},get children(){return TA(Qt,{})}}),TA(ZA,{when:!0,get children(){return TA(Et,{})}})]}})),cA((()=>zA(t,"aria-label",A.isPlaying?"Pause":"Play"))),t}}),r),ee(i,t),ee(o,V),ee(s,TA(OA,{get when(){return"number"==typeof A.progress||A.isSeekable},get children(){const t=Dt.cloneNode(!0),V=t.firstChild.nextSibling;return t.$$mousemove=B,t.$$mousedown=I,ee(t,TA(HA,{get each(){return g()},children:(t,V)=>(()=>{const g=qt.cloneNode(!0),n=g.firstChild,r=n.nextSibling;var i;return g.$$mousedown=A=>{A._marker=!0},PA(g,"click",(i=V(),e((()=>{A.onSeekClick({marker:i})})))),ee(r,(()=>(A=>""===A[1]?Lt(A[0]):`${Lt(A[0])} - ${A[1]}`)(t))),cA((e=>{const V=(e=>e[0]/A.duration*100+"%")(t),r=!!(e=>"number"==typeof A.currentTime&&e[0]<=A.currentTime)(t);return V!==e._v$&&g.style.setProperty("left",e._v$=V),r!==e._v$2&&n.classList.toggle("ap-marker-past",e._v$2=r),e}),{_v$:void 0,_v$2:void 0}),g})()}),null),cA((e=>_A(V,{transform:`scaleX(${A.progress||0}`},e))),t}})),ee(n,TA(OA,{get when(){return void 0!==A.isMuted},get children(){const t=kt.cloneNode(!0);return PA(t,"click",e(A.onMuteClick)),ee(t,TA(xA,{get children(){return[TA(ZA,{get when(){return!0===A.isMuted},get children(){return[TA(wt,{}),yt.cloneNode(!0)]}}),TA(ZA,{get when(){return!1===A.isMuted},get children(){return[TA(dt,{}),pt.cloneNode(!0)]}})]}})),t}}),C),PA(C,"click",e(A.onHelpClick)),ee(C,TA(st,{}),Q),PA(a,"click",e(A.onFullscreenClick)),ee(a,TA(lt,{}),E),ee(a,TA(It,{}),E),cA((()=>n.classList.toggle("ap-seekable",!!A.isSeekable))),n})()};jA(["click","mousedown","mousemove"]);const Rt=$A('
💥
',4);var Nt=A=>Rt.cloneNode(!0);const vt=$A('
',4);var bt=A=>vt.cloneNode(!0);const Gt=$A('
',4);var Ut=A=>(()=>{const e=Gt.cloneNode(!0);return ee(e.firstChild,(()=>A.message)),cA((()=>e.classList.toggle("ap-was-playing",!!A.wasPlaying))),e})();const St=$A('
',22);var Jt=A=>(()=>{const e=St.cloneNode(!0);var t;return PA(e,"click",(t=A.onClick,A=>{A.preventDefault(),t(A)})),e})();jA(["click"]);const Yt=$A("
  • space - pause / resume
  • ",4),Tt=$A("
  • â†� / → - rewind / fast-forward by 5 seconds
  • ",6),Kt=$A("
  • Shift + â†� / → - rewind / fast-forward by 10%
  • ",8),Ht=$A("
  • [ / ] - jump to the previous / next marker
  • ",6),Ot=$A("
  • 0, 1, 2 ... 9 - jump to 0%, 10%, 20% ... 90%
  • ",10),xt=$A("
  • , / . - step back / forward, a frame at a time (when paused)
  • ",6),Zt=$A("
  • m - mute / unmute audio
  • ",4),Wt=$A('

    Keyboard shortcuts

    • f - toggle fullscreen mode
    • k - toggle keystroke overlay
    • ? - show this help popup
    ',22);var $t=A=>(()=>{const e=Wt.cloneNode(!0),t=e.firstChild,V=t.firstChild.firstChild.nextSibling,g=V.firstChild,n=g.nextSibling.nextSibling;var r;return PA(e,"click",(r=A.onClose,A=>{A.preventDefault(),r(A)})),t.$$click=A=>{A.stopPropagation()},ee(V,TA(OA,{get when(){return A.isPausable},get children(){return Yt.cloneNode(!0)}}),g),ee(V,TA(OA,{get when(){return A.isSeekable},get children(){return[Tt.cloneNode(!0),Kt.cloneNode(!0),Ht.cloneNode(!0),Ot.cloneNode(!0),xt.cloneNode(!0)]}}),g),ee(V,TA(OA,{get when(){return A.hasAudio},get children(){return Zt.cloneNode(!0)}}),n),e})();jA(["click"]);const jt=$A("
    ",4),zt=$A('
    ',2);function Xt(A){const[e,t]=EA(!1);return lA((()=>{const{id:e}=A.keystroke;A.keystroke.rev(),t(!1);const V=setTimeout((function(){t(!0)}),2e3),g=setTimeout((function(){A.onExpired(e)}),2700);hA((()=>{clearTimeout(V),clearTimeout(g)}))})),(()=>{const t=jt.cloneNode(!0);return ee(t.firstChild,(()=>A.keystroke.label())),cA((()=>XA(t,e()?"ap-keystroke-pill fading":"ap-keystroke-pill"))),t})()}var Pt=A=>(()=>{const e=zt.cloneNode(!0);return ee(e,TA(HA,{get each(){return A.keystrokes},children:e=>TA(Xt,{keystroke:e,get onExpired(){return A.onExpired}})})),cA((()=>e.style.setProperty("--ap-keystrokes-bottom",`${(A.bottomOffset??0)+12}px`))),e})();const _t={...Object.fromEntries(Array.from({length:26},((A,e)=>[String.fromCharCode(e+1),`C-${String.fromCharCode(97+e)}`]))),"\b":"Back","\r":"Ret","\t":"Tab","":"Esc","":"Back"},AV={" ":"Spc"},eV={57358:"Caps",57359:"Scroll",57360:"Num",57361:"Print",57362:"Pause",57363:"Menu",57414:"Enter",57421:"PgUp",57422:"PgDn"},tV={A:"↑",B:"↓",C:"→",D:"�",F:"End",H:"Home",P:"F1",Q:"F2",R:"F3",S:"F4"},VV={2:"Ins",3:"Del",5:"PgUp",6:"PgDn",15:"F5",17:"F6",18:"F7",19:"F8",20:"F9",21:"F10",23:"F11",24:"F12"};function gV(A,e){const t=Number.parseInt(e.split(":")[0],10);if(!Number.isFinite(t)||t<=1)return A;const V=t-1,g=[];return 4&V&&g.push("C"),2&V&&g.push("A"),1&V&&g.push("S"),0===g.length?A:`${g.join("-")}-${A}`}function nV(A){if(A in eV)return eV[A];const e=String.fromCodePoint(A);return e in _t?_t[e]:e in AV?AV[e]:e}function rV(A){const e=A.match(/^(\d+);;(\d+)u$/);if(null!==e)return`A-${nV(Number.parseInt(e[2],10))}`;const t=A.match(/^(\d+)(?:;([\d:]+))?u$/);if(null!==t){const A=nV(Number.parseInt(t[1],10));return void 0===t[2]?A:gV(A,t[2])}const V=A.match(/^O?([A-Z])$/);if(null!==V&&V[1]in tV)return tV[V[1]];const g=A.match(/^(\d+)~$/);if(null!==g&&g[1]in VV)return VV[g[1]];const n=A.match(/^27;([\d:]+);(\d+)~$/);if(null!==n){return gV(nV(Number.parseInt(n[2],10)),n[1])}const r=A.match(/^(?:1;)?([\d:]+)([A-Z])$/);if(null!==r&&r[2]in tV)return gV(tV[r[2]],r[1]);const i=A.match(/^(\d+);([\d:]+)~$/);return null!==i&&i[1]in VV?gV(VV[i[1]],i[2]):""}function iV(A){if(A in _t)return{kind:"special",label:_t[A]};if(1===A.length)return A in AV?{kind:"special",label:AV[A]}:{kind:"text",label:A};if(A.startsWith("")){const e=function(A){const e=A.slice(1);return 1===e.length?e in _t?"A-"+_t[e]:e in AV?"A-"+AV[e]:"A-"+e:e.startsWith("[")?rV(e.slice(1)):e.startsWith("O")?rV(e):""}(A);if(""!==e)return{kind:"special",label:e}}return null}const oV=$A('
    ',4);var IV=A=>{const e=A.logger,t=A.core,V=A.autoPlay,g=A.charW,n=A.charH,r=A.bordersW,i=A.bordersH,o=A.theme??"auto/asciinema",I="auto/"===o.slice(0,5),B=I?o.slice(5):o,[s,C]=(Q=A.cols,a=A.rows,EA({cols:Q,rows:a},{equals:(A,e)=>A.cols===e.cols&&A.rows===e.rows}));var Q,a;const[E,c]=EA({width:0,height:0},{equals:(A,e)=>A.width===e.width&&A.height===e.height}),[l,u]=EA(!0),[d,f]=EA(!0),[w,h]=EA(!1),[D,y]=EA(null),[p,k]=EA(null),[m,q]=EA(null),[L,F]=EA(!1),[M,R]=EA(void 0),[N,v]=EA(!1),[b,G]=EA(V?null:"start"),[U,S]=EA(null),[J,Y]=EA(!1),[T,K]=EA(null),[H,O]=EA([]),[x,Z]=EA(!1),[W,$]=EA(!1),[j,z]=EA(null),X=uA((()=>s().cols||80)),P=uA((()=>s().rows||24)),_=()=>!1===A.controls?0:32,[AA,eA]=EA(!1!==A.keystrokeOverlay),[tA,VA]=EA([]);let gA,nA,rA,iA,oA,IA,BA=1;function sA(){Y(!1),jA(),zA()}const CA=({isPausable:A,isSeekable:e})=>{dA((()=>{u(A),f(e)}))},QA=A=>{dA((()=>{void 0!==A.duration&&(K(A.duration),y(0),k(A.duration),q(0)),void 0!==A.markers&&O(A.markers),void 0!==A.hasAudio&&R(!A.hasAudio&&void 0)}))},aA=({size:A,theme:e})=>{dA((()=>{C(A),void 0!==e&&z(e)}))},lA=A=>{C(A)},fA=()=>{G(null)},DA=()=>{dA((()=>{F(!0),v(!0),G(null),Y(!0),$A()}))},yA=()=>{dA((()=>{F(!1),sA()}))},pA=()=>{dA((()=>{F(!1),sA(),G("loader"),NA()}))},kA=({message:A})=>{dA((()=>{F(!1),sA(),NA(),void 0!==A&&(S(A),G("info"))}))},mA=A=>{R(A)},qA={renders:0},LA=({message:A})=>{dA((()=>{F(!1),sA(),void 0!==A&&(S(A),G("info"))})),e.debug("stats",qA)},FA=()=>{NA(),G("error")},MA=({data:A})=>{if(!AA())return;const e=iV(A);if(null===e)return;const t=tA(),V=t[t.length-1];"text"!==V?.kind||"text"!==e.kind?"special"!==V?.kind||"special"!==e.kind||V.key!==e.label?VA([...t,bA(e)].slice(-4)):V.increment():V.append(e.label)},RA=()=>{zA(),NA()},NA=()=>{VA([])},vA=A=>{VA((e=>e.filter((e=>e.id!==A))))},bA=({kind:A,label:e})=>{const[t,V]=EA(e),[g,n]=EA(1),[r,i]=EA(0);return{id:BA++,kind:A,key:e,label:()=>1===g()?t():`${t()} × ${g()}`,rev:r,append:A=>{V((e=>(e+A).slice(-10))),i((A=>A+1))},increment:()=>{n((A=>A+1)),i((A=>A+1))}}};t.addEventListener("ready",CA),t.addEventListener("metadata",QA),t.addEventListener("play",fA),t.addEventListener("playing",DA),t.addEventListener("pause",yA),t.addEventListener("loading",pA),t.addEventListener("offline",kA),t.addEventListener("muted",mA),t.addEventListener("ended",LA),t.addEventListener("error",FA),t.addEventListener("input",MA),t.addEventListener("seeked",RA),t.addEventListener("reset",aA),t.addEventListener("resize",lA);const GA=()=>{IA=new ResizeObserver(function(A,e){let t;return function(...V){clearTimeout(t),t=setTimeout((()=>A.apply(this,V)),e)}}((A=>{c({width:rA.offsetWidth,height:rA.offsetHeight}),rA.dispatchEvent(new CustomEvent("resize",{detail:{el:iA}}))}),10)),IA.observe(rA)};wA((async()=>{e.info("view: mounted"),e.debug("view: font measurements",{charW:g,charH:n}),GA(),c({width:rA.offsetWidth,height:rA.offsetHeight})})),hA((()=>{t.removeEventListener("ready",CA),t.removeEventListener("metadata",QA),t.removeEventListener("play",fA),t.removeEventListener("playing",DA),t.removeEventListener("pause",yA),t.removeEventListener("loading",pA),t.removeEventListener("offline",kA),t.removeEventListener("muted",mA),t.removeEventListener("ended",LA),t.removeEventListener("error",FA),t.removeEventListener("input",MA),t.removeEventListener("seeked",RA),t.removeEventListener("reset",aA),t.removeEventListener("resize",lA),t.stop(),jA(),IA.disconnect()}));const UA=uA((()=>{const e=g*X()+r,t=n*P()+i;let V=A.fit??"width";const o=E();if("both"===V||w()){V=o.width/(o.height-_())>e/t?"height":"width"}if(!1===V||"none"===V)return{};if("width"===V){const A=o.width/e;return{scale:A,width:o.width,height:t*A+_()}}if("height"===V){const A=(o.height-_())/t;return{scale:A,width:e*A,height:o.height}}throw new Error(`unsupported fit mode: ${V}`)})),SA=()=>{h(document.fullscreenElement??document.webkitFullscreenElement)},JA=()=>{w()?(document.exitFullscreen??document.webkitExitFullscreen??(()=>{})).apply(document):(rA.requestFullscreen??rA.webkitRequestFullscreen??(()=>{})).apply(rA)},YA=()=>{W()?$(!1):(t.pause(),$(!0))},KA=A=>{if(!(A.altKey||A.metaKey||A.ctrlKey||(" "==A.key||"Enter"==A.key)&&A.target instanceof HTMLButtonElement)){if(" "==A.key)ge();else if(","==A.key)t.step(-1).then(zA);else if("."==A.key)t.step().then(zA);else if("f"==A.key)JA();else if("m"==A.key)ne();else if("["==A.key)t.seek({marker:"prev"});else if("]"==A.key)t.seek({marker:"next"});else if(A.key.charCodeAt(0)>=48&&A.key.charCodeAt(0)<=57){const e=(A.key.charCodeAt(0)-48)/10;t.seek(100*e+"%")}else if("?"==A.key)YA();else if("k"==A.key)AA()?(NA(),eA(!1)):eA(!0);else if("ArrowLeft"==A.key)A.shiftKey?t.seek("<<<"):t.seek("<<");else if("ArrowRight"==A.key)A.shiftKey?t.seek(">>>"):t.seek(">>");else{if("Escape"!=A.key)return;$(!1)}A.stopPropagation(),A.preventDefault()}},HA=()=>{w()&&PA(!0)},WA=()=>{w()||PA(!1)},$A=()=>{clearInterval(nA),nA=setInterval(zA,100)},jA=()=>{clearInterval(nA)},zA=async()=>{const A=await t.getCurrentTime(),e=await t.getRemainingTime(),V=await t.getProgress();dA((()=>{y(A),k(e),q(V)}))},PA=A=>{clearTimeout(gA),A&&(gA=setTimeout((()=>PA(!1)),2e3)),Z(A)},te=uA((()=>I?j():null)),Ve=()=>{t.play()},ge=()=>{L()?t.pause():t.play()},ne=()=>{!0===M()?t.unmute():t.mute()},re=A=>{t.seek(A)},ie=(()=>{const V=oV.cloneNode(!0),g=V.firstChild;"function"==typeof rA?Ae(rA,V):rA=V,V.addEventListener("webkitfullscreenchange",SA),V.addEventListener("fullscreenchange",SA),V.$$mousemove=HA,V.$$keydown=KA;return"function"==typeof iA?Ae(iA,g):iA=g,g.$$mousemove=()=>PA(!0),g.addEventListener("mouseleave",WA),ee(g,TA(Pe,{get cols(){return X()},get rows(){return P()},get scale(){return UA()?.scale},get blinking(){return J()},get cursorMode(){return A.cursorMode},get boldIsBright(){return A.boldIsBright},get adaptivePalette(){return A.adaptivePalette},get lineHeight(){return A.terminalLineHeight},preferEmbeddedTheme:I,core:t,logger:e,get onReady(){return A.onTerminalReady},get stats(){return qA}}),null),ee(g,TA(OA,{get when(){return!1!==A.controls},get children(){return TA(Mt,{get duration(){return T()},get currentTime(){return D()},get remainingTime(){return p()},get progress(){return m()},get markers(){return H()},get isPlaying(){return L()||"loader"==b()},get isPausable(){return l()},get isSeekable(){return d()},get isMuted(){return M()},onPlayClick:ge,onFullscreenClick:JA,onHelpClick:YA,onSeekClick:re,onMuteClick:ne,ref(A){"function"==typeof oA?oA(A):oA=A}})}}),null),ee(g,TA(OA,{get when(){return tA().length>0},get children(){return TA(Pt,{get bottomOffset(){return _()},get keystrokes(){return tA()},onExpired:vA})}}),null),ee(g,TA(xA,{get children(){return[TA(ZA,{get when(){return"start"==b()},get children(){return TA(Jt,{onClick:Ve})}}),TA(ZA,{get when(){return"loader"==b()},get children(){return TA(bt,{})}}),TA(ZA,{get when(){return"error"==b()},get children(){return TA(Nt,{})}})]}}),null),ee(g,TA(Ee,{name:"slide",get children(){return TA(OA,{get when(){return"info"==b()},get children(){return TA(Ut,{get message(){return U()},get wasPlaying(){return N()}})}})}}),null),ee(g,TA(OA,{get when(){return W()},get children(){return TA($t,{onClose:()=>$(!1),get isPausable(){return l()},get isSeekable(){return d()},get hasAudio(){return void 0!==M()}})}}),null),cA((e=>{const t=!!(!0===A.controls||"auto"===A.controls&&x()),n=`ap-player ap-default-term-ff asciinema-player-theme-${B}`,r=(()=>{const e={};!1!==A.fit&&"none"!==A.fit||void 0===A.terminalFontSize||("small"===A.terminalFontSize?e["font-size"]="12px":"medium"===A.terminalFontSize?e["font-size"]="18px":"big"===A.terminalFontSize?e["font-size"]="24px":e["font-size"]=A.terminalFontSize);const t=UA();void 0!==t.width&&(e.width=`${t.width}px`,e.height=`${t.height}px`),void 0!==A.terminalFontFamily&&(e["--term-font-family"]=A.terminalFontFamily);const V=te();return V&&(e["--term-color-foreground"]=V.foreground,e["--term-color-background"]=V.background),e})();return t!==e._v$&&V.classList.toggle("ap-hud",e._v$=t),n!==e._v$2&&XA(g,e._v$2=n),e._v$3=_A(g,r,e._v$3),e}),{_v$:void 0,_v$2:void 0,_v$3:void 0}),V})();return ie};function BV(A,e,t={}){const V=function(A,e){const t=80,V=24,g=document.createElement("div");g.className="ap-default-term-ff",g.style.height="0px",g.style.overflow="hidden",g.style.fontSize="15px",void 0!==A&&g.style.setProperty("--term-font-family",A);const n=document.createElement("div");n.className="ap-term",n.style.width=`${t}ch`,n.style.height=V*(e??1.3333333333)+"em",n.style.fontSize="100%",g.appendChild(n),document.body.appendChild(g);const r={charW:n.clientWidth/t,charH:n.clientHeight/V,bordersW:n.offsetWidth-n.clientWidth,bordersH:n.offsetHeight-n.clientHeight};return document.body.removeChild(g),r}(t.terminalFontFamily,t.terminalLineHeight),g={core:A,logger:t.logger,cols:t.cols,rows:t.rows,fit:t.fit,controls:t.controls,cursorMode:t.cursorMode,keystrokeOverlay:t.keystrokeOverlay,autoPlay:t.autoPlay,boldIsBright:t.boldIsBright,adaptivePalette:t.adaptivePalette,terminalFontSize:t.terminalFontSize,terminalFontFamily:t.terminalFontFamily,terminalLineHeight:t.terminalLineHeight,theme:t.theme,onTerminalReady:t.onTerminalReady,...V};let n;const r=function(A,e,t,V={}){let g;return aA((V=>{g=V,e===document?A():ee(e,A(),e.firstChild?null:void 0,t)}),V.owner),()=>{g(),e.textContent=""}}((()=>(n=TA(IV,g),n)),e);return{el:n,dispose:r}}jA(["keydown","mousemove"]);const sV=["audioUrl","autoPlay","autoplay","cols","idleTimeLimit","loop","markers","pauseOnMarkers","poster","preload","rows","speed","startAt"],CV=["autoPlay","autoplay","boldIsBright","cols","adaptivePalette","controls","cursorMode","fit","keystrokeOverlay","rows","terminalFontFamily","terminalFontSize","terminalLineHeight","theme"];return A.create=function(A,e,t={}){const V=t.logger??new u,g=new _(A,function(A,e={}){const t=Object.fromEntries(Object.entries(A).filter((([A])=>sV.includes(A))));return t.autoPlay??=t.autoplay,t.speed??=1,{...t,...e}}(t,{logger:V})),{el:n,dispose:r}=BV(g,e,function(A,e={}){const t=Object.fromEntries(Object.entries(A).filter((([A])=>CV.includes(A))));if(t.autoPlay??=t.autoplay,t.adaptivePalette??=!1,t.controls??="auto",t.cursorMode??="blinking",t.keystrokeOverlay??=!1,!["blinking","steady","hidden"].includes(t.cursorMode))throw new Error(`unsupported cursor mode: ${t.cursorMode}`);if("boolean"!=typeof t.keystrokeOverlay)throw new Error(`unsupported keystroke overlay option: ${t.keystrokeOverlay}`);return{...t,...e}}(t,{logger:V,onTerminalReady:()=>g.terminalReady()}));g.init().catch((()=>{}));const i={el:n,dispose:r,getCurrentTime:()=>g.getCurrentTime(),getDuration:()=>g.getDuration(),play:()=>g.play(),pause:()=>g.pause(),seek:A=>g.seek(A),addEventListener:(A,e)=>g.addEventListener(A,e.bind(i))};return i},A}({}); +/* @license-end */ diff --git a/docs/site/site.css b/docs/site/site.css index 2435841b..bab762d0 100644 --- a/docs/site/site.css +++ b/docs/site/site.css @@ -107,7 +107,7 @@ body { margin:0; min-height:100vh; background:var(--field) radial-gradient(color .toc ol { padding:8px 14px 10px 2.4em; columns:2 14em; font-size:18px; } .masthead { font:clamp(56px, 12vw, 104px)/1 var(--pixel) !important; text-shadow:5px 5px 0 var(--amber) !important; margin:.1em 0 .1em !important; } .pitch { font-style:italic; font-size:22px; color:var(--dim); margin-top:0; } -.clips { display:grid; grid-template-columns:repeat(auto-fit, minmax(min(100%, 240px), 1fr)); gap:18px; margin:1.4em 0; } +.clips { display:grid; grid-template-columns:repeat(auto-fit, minmax(min(100%, 340px), 1fr)); gap:18px; margin:1em 0 1.4em; } .clip { margin:0; border:2px solid var(--leaf); background:var(--deep); box-shadow:5px 5px 0 var(--shadow); } .clip video, .clip img { display:block; width:100%; height:auto; aspect-ratio:960/700; background:var(--deep); } .clip figcaption { padding:8px 12px; font-size:18px; color:var(--dim); border-top:2px solid var(--leaf); } @@ -142,3 +142,18 @@ body { margin:0; min-height:100vh; background:var(--field) radial-gradient(color } /* a shell line wraps on a phone rather than hide its end */ @media (max-width:600px) { .cmd pre { white-space:pre-wrap; overflow-wrap:anywhere; } } + +/* terminal recordings: the first across the page, the rest two by two */ +.casts { display:grid; grid-template-columns:repeat(auto-fit, minmax(min(100%, 340px), 1fr)); gap:18px; margin:1em 0 1.4em; } +.casts .first { grid-column:1 / -1; } +.cast .player { background:#121314; } +.cast figcaption strong { color:var(--leaf); } +.content h2.shelf { font-size:26px; margin:1.2em 0 .4em; } + +/* the Themes page gallery: thumbnails that open the full picture */ +.gallery { display:grid; grid-template-columns:repeat(auto-fill, minmax(min(100%, 140px), 1fr)); gap:12px; margin:1em 0 1.6em; } +.shot { margin:0; border:2px solid var(--leaf); background:var(--deep); box-shadow:4px 4px 0 var(--shadow); } +.shot img { display:block; width:100%; height:auto; aspect-ratio:960/700; object-fit:cover; } +.shot figcaption { padding:3px 8px; font:16px var(--pixel); color:var(--dim); border-top:2px solid var(--leaf); } +.shot.light figcaption::after { content:" · light"; color:var(--amber); } +.shot .pending { aspect-ratio:960/700; display:flex; align-items:center; justify-content:center; font:15px var(--pixel); color:var(--dim); } diff --git a/docs/site/site.typ b/docs/site/site.typ index 068b5b9c..afcd1041 100644 --- a/docs/site/site.typ +++ b/docs/site/site.typ @@ -4,9 +4,34 @@ // typst compile --root . --format bundle --features bundle,html docs/site/site.typ OUT // Every link is relative and every page sits at the top of OUT, so the site // works from file:// and from any static server. -#import "../typ/style.typ": chapters, tutor-path, doc-links, tagline, project +#import "../typ/style.typ": chapters, tutor-path, doc-links, project #let clips = toml("media/clips.toml").clip +#let casts = toml("casts/casts.toml").cast +#let themes = toml("media/themes/themes.toml") +/// The version, from build.zig.zon: 0.23.0 reads 0.23. +#let version = { + let v = read("/build.zig.zon").match(regex("\\.version\\s*=\\s*\"([^\"]+)\"")).captures.first() + if v.ends-with(".0") and v.split(".").len() == 3 { v.slice(0, -2) } else { v } +} + +// --- the landing page's own words: everything a visitor reads first ---------- +// Change the landing here; the rest of the site is the chapters. +#let landing = ( + lead: [pardes is a text environment, after acme and helix, where any text + is live: right-click looks at it (opens the file at that line, the URL, + or finds the word) and middle-click runs it (a builtin or a shell + command). Read PDFs and source, edit code and use terminals with it, in + a terminal or in its own window.], + status: [Linux; macOS in progress. Version #version.], + terminal: [In a terminal], + window: [In its own window], + start: ( + (id: "guide", label: [Start: the guide], note: [about 15 min]), + (id: "tutor", label: [Hands on: the tutor], note: [run `Tutor` inside pardes]), + ), + install: [Install], +) #let pages = ( (id: "index", title: "pardes"), ..chapters.filter(c => c.file != none).map(c => (id: c.id, title: c.title, file: c.file)), @@ -22,6 +47,12 @@ asset("fonts/" + f, read("fonts/" + f, encoding: none)) } #asset("media/placeholder.svg", read("media/placeholder.svg", encoding: none)) +#for f in ("asciinema-player.min.js", "asciinema-player.css", "LICENSE-asciinema-player.txt") { + asset("player/" + f, read("player/" + f, encoding: none)) +} +#if themes.at("ready", default: true) { + for t in themes.theme { asset("media/themes/" + t.file, read("media/themes/" + t.file, encoding: none)) } +} #for c in clips.filter(c => c.ready) { for ext in ("webm", "mp4", "png") { asset("media/" + c.name + "." + ext, read("media/" + c.name + "." + ext, encoding: none)) @@ -68,11 +99,12 @@ #el("article", (class: "content"))[#body] ] #el("footer", (class: "colophon"))[ - pardes · - #if project.source != none [#el("a", (href: project.source))[source] · ] + pardes #version · + source: #project.mirrors.map(m => el("a", (href: m.web))[#m.name]).join(", ") · #if project.license != none [#project.license license · ] built from `docs/typ` with Typst · - #el("a", (href: "fonts/LICENSE-DepartureMono.txt"))[fonts] (OFL) + #el("a", (href: "fonts/LICENSE-DepartureMono.txt"))[fonts] (OFL) · + #el("a", (href: "player/LICENSE-asciinema-player.txt"))[asciinema-player] (Apache-2.0) ] ] }) @@ -94,54 +126,62 @@ #doc-links.update(true) -// The first ready clip plays at the top; the grid shows the rest. -#let hero = clips.find(c => c.ready) -#let video(c, extra) = el("video", (poster: "media/" + c.name + ".png", muted: "", loop: "", playsinline: "", - controls: "") + extra)[ +#let video(c) = el("video", (poster: "media/" + c.name + ".png", muted: "", loop: "", playsinline: "", + controls: "", preload: "none"))[ #el("source", (src: "media/" + c.name + ".webm", type: "video/webm"))[] #el("source", (src: "media/" + c.name + ".mp4", type: "video/mp4"))[] ] -#let start = ( - (id: "guide", label: [Start: the guide], note: [about 15 min]), - (id: "tutor", label: [Hands on: the tutor], note: none), -) +#let placeholder = el("img", (src: "media/placeholder.svg", alt: "", width: "640", height: "400"))[] + +/// A terminal recording: a box the player fills, its data inline (so it +/// plays from file://), its caption under it. The first ready one plays. +#let ready-casts = casts.filter(c => c.ready) +#let cast(c, i) = el("figure", (class: if i == 0 { "clip cast first" } else { "clip cast" }))[ + #if c.ready { el("div", (class: "player", id: "cast-" + c.name, "aria-label": c.title))[] } else { placeholder } + #el("figcaption")[#el("strong")[#c.title.] #c.caption] +] +#let player-script = { + let list = ready-casts.enumerate().map(((i, c)) => ( + id: "cast-" + c.name, data: read("casts/" + c.name + ".cast"), + cols: c.cols, rows: c.rows, autoPlay: i == 0, + )) + // " p.id not in start.map(s => s.id)) { + #for p in pages.slice(1).filter(p => p.id not in landing.start.map(s => s.id)) { el("a", (href: href(p.id)))[#p.title] } ] + #el("h2", (class: "shelf"))[#landing.terminal] + #el("div", (class: "casts"))[#for (i, c) in casts.enumerate() { cast(c, i) }] + #el("h2", (class: "shelf"))[#landing.window] #el("div", (class: "clips"))[ - #for c in clips.filter(c => c != hero) { + #for c in clips { el("figure", (class: "clip"))[ - #if c.ready { video(c, (preload: "none")) } else { - el("img", (src: "media/placeholder.svg", alt: "", width: "640", height: "400"))[] - } + #if c.ready { video(c) } else { placeholder } #el("figcaption")[#c.caption] ] } ] - #el("h2", (class: "install"))[Install] + #el("h2", (class: "install"))[#landing.install] #include "../typ/install.typ" + #if ready-casts.len() > 0 { + el("link", (rel: "stylesheet", href: "player/asciinema-player.css"))[] + player-script + } ]) #for p in pages.slice(1, -1) { diff --git a/docs/typ/install.typ b/docs/typ/install.typ index 37e07d1a..6d853f3f 100644 --- a/docs/typ/install.typ +++ b/docs/typ/install.typ @@ -1,6 +1,11 @@ -// Installing pardes, in three lines: included by setup.typ and by the -// site's landing page, so it is written once. -#import "style.typ": cmd +// Installing pardes: the clone and the build, included by setup.typ and by +// the site's landing page, so it is written once. The mirrors come from +// `project` in style.typ. +#import "style.typ": cmd, project + +#let first = project.mirrors.first() +#cmd("git clone " + first.clone + " && cd pardes") +Every mirror holds the same tree: #project.mirrors.map(m => link(m.web, m.name)).join(", "). With Zig 0.16 (the build fetches everything else): #cmd("# pardes, in a terminal\nzig build -Dplatform=tty --prefix ~/.local") diff --git a/docs/typ/style.typ b/docs/typ/style.typ index ed713537..065cc210 100644 --- a/docs/typ/style.typ +++ b/docs/typ/style.typ @@ -59,8 +59,8 @@ (id: "building", title: "Building, for contributors", file: "building.typ"), ) -/// The one-line pitch: the A4 sheet's header and the site's landing page. -#let tagline = "acme's tags and three buttons, helix's keys, terminals as panes, the editor as a 9P filesystem" +/// The one-line pitch: the A4 sheet's header and the book's title page. +#let tagline = "acme's tags and three buttons, helix's keys, terminals as panes, the editor as a virtual filesystem over 9P" /// The tutor, shown as it is in the editor (`Tutor`), from the repo root. #let tutor-path = "/src/tutor.txt" @@ -254,9 +254,16 @@ } } -/// Where pardes lives and under what licence, for the site's footer (and -/// any output that wants them). none until decided. -#let project = (source: "https://git.0x4200.cafe/pardes", license: "ISC") +/// Where pardes lives and under what licence: install.typ, the site's +/// landing and its footer all read it. Every mirror holds the same tree; +/// the first is the one the install line clones. A new mirror is one line. +#let project = ( + mirrors: ( + (name: "sourcehut", web: "https://git.sr.ht/~gbrls/pardes", clone: "https://git.sr.ht/~gbrls/pardes"), + (name: "git.0x4200.cafe", web: "https://git.0x4200.cafe/pardes", clone: "https://git.0x4200.cafe/pardes.git"), + ), + license: "ISC", +) /// A glossary: like #pairs, under its own heading. On paper the heading /// and the table; in HTML a
    that starts closed, its summary the @@ -270,3 +277,25 @@ [#heading(title) #lbl] pairs(..cells) } + +/// Every theme as a picture, on the site's Themes page; nothing on paper, +/// where forty-odd screenshots would only add weight. Reads +/// docs/site/media/themes/themes.toml: `ready` (absent means true) and a +/// [[theme]] per theme, in NextColor's order, with `name`, `file` (under +/// media/themes/) and `kind` ("light" or "dark"). +#let theme-gallery() = context if html-out() { + let g = toml("../site/media/themes/themes.toml") + let ready = g.at("ready", default: true) + heading[Every theme] + html.elem("div", attrs: (class: "gallery"), for t in g.theme { + let src = "media/themes/" + t.file + html.elem("figure", attrs: (class: "shot " + t.kind), { + if ready { + html.elem("a", attrs: (href: src), html.elem("img", attrs: (src: src, alt: t.name + " (" + t.kind + ")", loading: "lazy"))) + } else { + html.elem("div", attrs: (class: "pending"), "screenshot to come") + } + html.elem("figcaption", raw(t.name)) + }) + }) +} diff --git a/docs/typ/themes.typ b/docs/typ/themes.typ index dc81bfdf..a85abb23 100644 --- a/docs/typ/themes.typ +++ b/docs/typ/themes.typ @@ -1,6 +1,6 @@ // Themes: choosing one, the native palettes and the faithful ports, and // the roles a theme file sets. -#import "style.typ": key, keys, btn, chord, word, tag, addr, file, cmd, doc, pairs +#import "style.typ": key, keys, btn, chord, word, tag, addr, file, cmd, doc, pairs, theme-gallery #word("Themes") (#key("SPC t t")) lists every theme as a word to click; `Theme ` sets one anywhere, and the same line in the startup file @@ -11,6 +11,8 @@ default. `lapis` draws its ornament in the GUI; `lapis_plain` is the same theme on flat grounds, keeping its framed and shadowed tags and its file-name shadow. +#theme-gallery() + = The native themes #pairs( -- cgit v1.3 From 406d0bc6f1debe5d9de43a60ab0931d937845194 Mon Sep 17 00:00:00 2001 From: Gabriel Schneider Date: Thu, 1 Oct 2026 12:41:52 -0300 Subject: The docs call pardes's scripting interface a virtual filesystem, served over 9P, and the guide opens on look and execute as the core idea Co-Authored-By: Claude Opus 5.5 --- .agents/skills/pardes-9p/SKILL.md | 2 +- docs/typ/building.typ | 2 +- docs/typ/cheatsheet-a4.pdf | 1029 +++++++++++++++++++------------------ docs/typ/cheatsheet.typ | 2 +- docs/typ/guide.typ | 13 +- docs/typ/reference.typ | 6 +- docs/typ/scripting.typ | 5 +- docs/typ/setup.typ | 4 +- src/fs-help.txt | 2 +- src/tutor.txt | 2 +- 10 files changed, 536 insertions(+), 531 deletions(-) (limited to 'docs') diff --git a/.agents/skills/pardes-9p/SKILL.md b/.agents/skills/pardes-9p/SKILL.md index ea2114ce..06edbdf2 100644 --- a/.agents/skills/pardes-9p/SKILL.md +++ b/.agents/skills/pardes-9p/SKILL.md @@ -1,6 +1,6 @@ --- name: pardes-9p -description: Inspect and drive a running Pardes editor through its 9P 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. +description: Inspect and drive a running Pardes editor through its virtual filesystem (served 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. --- # Pardes over 9P diff --git a/docs/typ/building.typ b/docs/typ/building.typ index ab26e44c..cca3161e 100644 --- a/docs/typ/building.typ +++ b/docs/typ/building.typ @@ -128,7 +128,7 @@ with `-Dplatform=gui`, `core-test`, `fs-test`, `snap`, the GUI goldens = The core and its shells One core, five shells (tty, gui, web, macos, esp32p4). The core owns -editing, layout, rendering and the control filesystem; a shell turns native +editing, layout, rendering and the virtual filesystem it serves over 9P; a shell turns native input into `pardes.Event`, presents `pardes.Surface`, and performs host effects such as spawning processes. diff --git a/docs/typ/cheatsheet-a4.pdf b/docs/typ/cheatsheet-a4.pdf index 4f8839f6..9f9f50fa 100644 --- a/docs/typ/cheatsheet-a4.pdf +++ b/docs/typ/cheatsheet-a4.pdf @@ -44,7 +44,7 @@ endobj <> endobj 15 0 obj -<> +<> endobj 16 0 obj <> @@ -950,7 +950,7 @@ endobj <> endobj 317 0 obj -<> +<> endobj 318 0 obj <> @@ -1121,13 +1121,13 @@ endobj <>/ExtGState<>/Font<>>> endobj 374 0 obj -<> +<> endobj 375 0 obj -<>/FontDescriptor 376 0 R/DW 0/W[0 0 500 1 1 581 2 2 505.99997 3 3 428 4 4 561 5 5 489 6 6 427 7 7 652 8 8 619 9 9 250 10 10 905 11 11 551 12 12 598 13 13 561 14 14 456 15 15 358 16 16 325 17 17 613 18 18 706 19 19 256 20 20 641 21 21 244 22 22 322 23 23 616 24 24 521 25 25 577 26 26 736 27 27 558 28 28 716 29 29 529 30 30 777 31 31 716 32 32 545 33 33 504 34 34 514 35 35 614]>> +<>/FontDescriptor 376 0 R/DW 0/W[0 0 500 1 1 581 2 2 505.99997 3 3 428 4 4 561 5 5 489 6 6 427 7 7 652 8 8 619 9 9 250 10 10 905 11 11 551 12 12 598 13 13 561 14 14 456 15 15 358 16 16 325 17 17 613 18 18 706 19 19 256 20 20 641 21 21 244 22 22 322 23 23 616 24 24 521 25 25 577 26 26 736 27 27 558 28 28 716 29 29 529 30 30 777 31 31 716 32 32 545 33 33 504 34 34 315 35 35 514 36 36 614 37 37 315]>> endobj 376 0 obj -<> +<> endobj 377 0 obj <> @@ -1180,36 +1180,37 @@ endobj 393 0 obj <> stream -xœûÿÿÿÿçí +xœûÿÿÿÿ?óù endstream endobj 394 0 obj -<> +<> stream -xœm“M�Ú0†ïùÓC$ö@ã|Â"„�HöC˪=‡x ‘ˆ%Î�_ůîªBôxÆ3óÛÿñ~šo¥>ó<þ)èƒ{=tÏó—²õ|¯«¡ae^™%Ë)Ú¯¨ítÕ³¡ü¸?ªÚx¾TÕm�<åü/eÇ×Z}%Œ=(z£Ï÷?ksãͰ@v&:JV¦6wOžïÿ⮯µZQèùþAÉ\7ãp½¸¼wº:±¡K­dç:Ñyìë…ɺ2ŽìoÕ”­Ý|º÷†›£ºhŠ‘%‡Öe|­{ÓÝif{"ÉDÞ:É]­®4›†ý< m{ãqHv••´ï`”-¦À ?V�%…_KŸ÷–]�à÷‹–„±Ò’û¶¬¸+Õ•½µBlh]E±;þ�Sl;_ª?egÓà ­…Xˆ�¥ÈR‚bÄ"P‚XJA)(Cf ZXJ]æ™Kг¥ÈõÛ"¶í@(GM×arUÈtý -ÄÐ/?€Y‚_¶Á/Á¾~ñäü2!²g¬À1r•à8Åà˜@KÐÇÄíƒcâ&€ãÂU�cŠ/:Ç Ç…« G;â<GðLaÁ3F—ž©°GÂý÷ãáïÀã4VC×±2ö -Ø£7ž³Zñã.µºwÙÇ^Âé>�ôVüµ(m +xœm“M�¢@†ïüŠÚ‰spi@`4ÆDQó‘q²{FºtI¤›4pðßoè·q&›=¨yºª«êi»ýï§ùVê3Ï㟂>¸Óƒ©xž¿”­çû{] «þ•Y²œ¢ÝŠZ£«Ž{Ê�û£ª{Ï÷�ªº ’§œÿ¥ìøZ«¯„±åC×ëÆóýϺ¿ñŠfX ;%«¾îï$ž<ßÿŦ«µZQèùþAÉ\7ãp�¸¼]�¸§K­¤q�è<öõˆd]õŽìwÕ”­Ý|ºw=7GuÑ#K­Ë$" +>øZw½¹ÓÌöD’/ˆ¼ɦVWšMÃ~ ž†¶½ñ8$ »ÊJÚß`”-¦À ?V�%…_KŸ÷–]�à÷‹–„±Ò’»¶¬Ø”êÊÞZ!6´.Š¢ØŒÿ‰Ç¶�/ÕŸÒØôpCk!2±±YJCPŒXZ ¶% ”"3e–—ùŒÌgÐÒRäúmÛƒv ”£¦ë°¹*dº~bèŽ Dšƒà—î@ð[`_¿x r~©é+pŒ\%8N18¦�sÌ@p\¸}[�›Ž™«Ç':ÇÇÌÕ„£�ñž GðL`Á3ÂiEÎ=#x&ø"縴×ÅÝ‹ñâŒïãqS«ÁV½}öZŽw°Vüxg­nÇ]öcèôÖGz+þçå-Í endstream endobj 395 0 obj -<> +<> stream -xœ�W{xUÚO(Mèí�Zft¦*âäCY®‹"ØTn•b�R iÒKhCo¹ôš´Ímfrk’6…´éýJÛôh¡¥µ]DT°ºâeequùv]E]žu¿7~‡o÷{Â]EþÈdæÌóžó;ïû;¿ß;|Þôé<>Ÿ/~%=Yš“—ž•Ÿûª4']¶àÅþ”Ð‹Ø ¼Ÿ� ‚Dð¨™<še¯]#„÷ÿ­�¿?šü_&ü�wlö<Ö½ðxÿùOÄC¡¡FÌ ý}ñ/ŒÏˆ^^“¢H–nH‘få¥çiÖ*hrÒSÓòbnÝ-^ô_‹,^´øÙ˜miÒ˜[˜b¶ä(2¤’¼˜5ùyiŠœÜ…<Þ4Ÿ÷P©'¸®ÆS‘îo›S€ÊZ„ÔÌi¦Xñ"f°³fBÔ,ˆrGü&8*ãñy<o^hWs8–åB›á{*t‹äÍ M¹‘w™o˜†M{"¬wzìôËÓ¿ÿNð¼àsáY,ë›1ãâÌgÍze;ëßu¿9,Š™=möG÷°÷â÷žŒ<†§Ï ›“-æmgGƒ—FùìhpÞh;=húaË“àÓÿ£Ä°œ°9ï‚câÐ -=A8¯¾ ¿R)D‰0.F¡øR jCéJÈ À7gù_AÄBLØWpZ|e©p™Ö¼É@éõl¾C�¸7>>ȉ˜çp° z¶É¦µ^ `†PÛP¯o"á©o¿ƒG'•§Súéž´_#³âÓäi´^`n35°D5Sn/&eºÍűef½EeÑcwyQÈ$—ÐÁÚDK»ßÓHß�f,Í\ð¬6ÇÑšC‹u§6¿_"�BÄ#0 fÂ|Ž�ˆ“+[5Gɉþú?�ï7W�¥NLW¢3ªÉ|}ím�yá0oqûòÐô}Õùý½- MvÆÁ8(³Û춸±*ÎY}˜ ôhN¯W†ãƒe¬ÉZEÄö¥~Ñ~²«å0ÅÁj1Šªrr -5äÞ¢öN¿µóýFZ„î­SÂû0‡ÿ D…�êŽU=)·ÓUy�tU•éœty¥·¼‘loë´dv¤¦I37ì¦�s‡a„%\L¹³˜L,Ý^¼¡Â¬·¨¯%¤,Ž@›ï.õ"§î |Ъ Ùê"ý/@~à¸Ø’k)`‰RÎi¨!ýîS5S.‹Ãì3;°x»öÐï‰àv!~䫟¥\¶2JVºR»Îd*åJìeØ[;K (!~֡εg‘HŒÂQ8š»¥>vDJ+z›‹'ÉÖsGkêiÇ1q�r{~)¹#efŒ;†ë:éVo롲¥Ù”ÑD#FXΖqå”èeÝçðÌà�H?�ˆ„ Ç/ׂX¼/9^+%ñï·k躒³Ù ¨4Ù½5Îø=Jã—B Ñ‚­õ›Ž¤Ðé}#…ï“Sïö|0J{ µ: -UÂ|1×cï«ñaM‡ZÝUd«?{¥ž-1›iŠÔõgøoAøŸ ;óŶ�öD§Ó×½]8I~üuà‹îòÖ¼fZѵ¯y·“x‹»Ú‰Æººöžnù¦fªÖTŹ+±^c_YU#Ïqo#·ïPÉåt^žVq€È¬Î­SR�éiÅØ€¦*5—�Ë $íþ@IZË™B#&úÖÜœtª"¡bð©àã0[¼Gø¶ÛßK5> ä¬öÒUuœÍEãþŠaÃ3„qf CáS¦tfXE¢¸5ši·Ji³ÙÌÐÆ$Ýví.Ìèö2Õ$>õ©o°ù 9"ð»e›è+¸pY�a¥é{F¸1îí3ãÌèMö¬´Ø/¢3uÊ vô!î|Q° -¢ðóÁf˜#†EB˜–8ºD¶N–GAª¿t®horåÊKÂe…e›n.à†¸‰ã�·vŸµÈu�€}–ÀáêZr GG£•Â¥…eÉ·EuqÇ'ŽÞ…Ÿßd-t}FˆÐ¤¾¿ -·Àù DÁ’k¿9÷ãçA "1ìÚY»�hêïq{É�Ž_šþG $Ö×g,63>“›ªë;R}ˆh»+h×€]M”dt‰l©D¾•:R$ißB¦®•Êãh|ÄÔajd üü/êÞ�ùpÛíY³éBÇܬ ~è|0?HÄè¾.âý7|þAêÄ�÷ÝIî[| =¾lcVR -%ÝS°y ¹ðšøÝáè‘(O].‡ÙçþvèüYZ4¤;ÄTü‹×’¬„¹bX#üÌRÚDx�Uz¥aTŒZñ—1ï:º†CK ´Q¨cuœŽÊIÎ0kHI¦ý=Vþ8RÉh¤ÜÞ›‘ÃæzÝR->ˆÿ¼÷ƒö®“”%Ç¢þu9ÍÝAAw¤~‹~ I0âÑBXˆ_„—?ŸþÂf·Z­†¹Çyå:Sšaîõu|Ü[ÜøØiÆw#2GºG~ü¸/Úàd­VÛEàE·u÷VwZoðëM³ŸÉHIæT7Ñâ{MN­*+~u´É``�•IE+{=–>Ûõ ó³mgÜm!C¾’6ú"­FÖ¨¯˜û4äÈ÷h3�7�áS>®“ë:rì6 ¿¨±íw4tb¢'t€/Cå%Â+¾W›ë´”L’®Î"Ÿßò:D@Xóĸÿ`ŠÜJ°¶ªºÈ®ÆæÎ¡ø7Í|ø)ôØK�qý2ZÖ?\ô>yj*0ÑG‹Ðkº÷àãQxÔùˆB8à‡hüocÅÅEFm �%4pŒ�zG`žÏ 9;ˆ4Wz½†R7ö–5‘o¶µùèj½£ÔMéJrBVšï¥G™ÿùŽø‡À]csÑ�B›Éb ð‹h†€ë·œµ³„Ãd5Pø—2mE!]P‘¥¯(Ã*ÊŒV"¤®Sþ°öºÐàþïÿ\0~v¾.ÁD!>õ«Ò#:eî†`A7XnÙÈFx ÿöÎë=Ê4Ý\'ÓVà¼@üIØÖi*tÓ�émÉ^æQXËŠˆl¡ÅβC–žÁIÆ#"Å–oÊB<m¨4;möщhü_]=­=9¯Ï™Ï¼ÂdË9Ù †¼n¨_º8|ñ]Úe(¨Ö’¿[·"ûEaOÃý°žþæÀ, †~·¤…®6ú¬UÃXùñ² Ìž�4€f“(-G³Ñ�ƒhÚ§[éÝoRp‰¡Ñr á ù§`~Ø©SbiWæÀ@wW_¿¼C"I—§PpbúÏÆD©S£FÝ*( -D~Q°)äPr Ü'6¸´ñÚ&\VjÞq›´õr#wjw ñ‘QÛ$KU•9Š)ü|‘>ËœnÆ�â¨?ÓÞp¸¾ ù %¯nÎð“=í Cµê®ý^º6#ÁOnŒ/J•Ñ»“¤ûP8QR*L—•Ó -›©‘šDU‚å?«ü˜ÿ6¯ÙŠœ!k9�VÂ1>Ü{. ¦.ΖIòrêuÚcj,Ï'²Ö%•R†NWUîwmnkÃÚÚZFzˆ?e ÆS"TX§ Æ©þsø—Cm`Ñ53ºµ'…vEùO…ÛÝõwˆ f‰3š2†Zz[:òz÷%æÉ3)Ñ[W�0Ôu†,;ÔyŠÄ°[Ø:0à«ýëû%ûJ]"Y·Gº�2õ;~¥M¿k»’£²<÷÷x%<ÖÊ>ã‰È*à?÷í÷€¨ôøàx05H‰ÛUûë²Û¥{¶fdgÑøÐ¸[£´$‘{÷éò3èäì) ÄÎöídz)|øùývmWjk©»ˆÂ�ŏЫË}zloöž¸BV½·UMè?£?N†ýL£ñObêuG$­TK -z¢r ©9`8ä®±WÓºúz¦“ÄÇOóttÓí-¾ž!bRáOo£ÜÎõnÒU©×[é[­²™Äÿƒ†®, �™¶§&ghhÍþ³”Ü�4r¢›m¬òÑF·Ç\OâCã „3â'¥ÙËÏ�8WÛÚÌ—²Š5±�àesÁ—âÍeqÝ):8_x¡Í6a¥Ü¶AçÀ–3™ŒD‚6bžNÏæ»õØ„©Í¸Œ¸òˆp™Â¸ÍD]eAhé§ WÐþW3K»GÝï8Ætv¥¥ÔŒ­UÉ^}ˆÁËæîà'ÝüÚÊ ¡Ua=¬^Ð'þéTÜ9n`àÌ@ļë(¶Y¶ $;*û²áI´#Ú—]£°b&Îd£|Ü8×Ñ?Àôߨz¦-ß™Ý�P]à+ñ:‰J®ºÊMÿÒc“#o8ç^'G“ƤI’8é Q|CoÜ¿#Û/î–xi«B�¡Å`Ã�s"aÖ2ÉNò“”ˆì¨è»Gÿ¹Lùƒ¨;Ò»áYØ„¢ -_´J|¨í`ouǧ?¼q˜^ÓÞÑé¿éù«r £HK¿%Ï~°ËÔe(L�‡ -£–eŠc9ÆB-i8ñGhú+¼oدO!c63©é·uG�ΊÖW@ŒF¢­›ÑjôhªŠôŹۢ÷—”j$¾Sc²“ÒülU‰µÐ¥¥µ.o…‡ôtØ54¾¢ÞÝÖTåÃD°T(QB_#¯¦Á“ø ø÷‰%ÈV!!Ê ¼äî -ºDøGWE^ �Ÿ€è…ð¤ÎÁ=§È�1«ÝMÛ*™:£KÊk -(ht?ÈÂ_oødì21Ptj£Ÿj�m«zžüm£ÙkÔK©½°KðncýøÉ³¹HD‰r]Êàân¾$°î ƒ¯‚óů+ óV¡—£�eÆJSå+m¶›íŒ­¸O_3y+�fgZ­:œ¬°¨|;à>4]äðê=¤Ûg©wÑðœñ yÚÆí7¸”ÏÈ™|™Œ;p³‚"È»Ä ²àB Â‚JøL¬>^z”%4ŒšU[žBÞhS…ÑltÇÁêhÆÊXkq@趪îe~ Ǫ®KšŠVWzÌÒ]g©wÒökd ×TÖ™<¤Ûkõ9i˜ '½G¼}“·!Ô0Ù²½··ölõέhq´±TÏÝ¡j_uRH ȯ9iÜíN‡ª„?7°;i¸ësa­×^M7 -ŒMMÍ?!€Ç¼¶¢ÜJJîjÉé%7ÕiÝìÁÄW ’¥4~Éh4Œ¬]“px¹{{Qò:q�lí*Ât7.zÇO4Ø|V\žcÈJ%T(®[ˆ_ºêßÞMº‡ÂÏ»³}ùífLTnîß0TlªÈË󥿆�½x^8U§N²Ò}'ëp`æ¶£‘h亹vJïØÏêõØ6“²l=¹¤‚&osõß‚[öÆ6ÐÕf�ÅmÇðó¦£åß0NÌÂp& -¿d*(grI4*`ævp76ðžÉkXF\™w'üÓ�N�Ôv�íÔòá¹àúÁÈA¸žƒH|(¸ü‡Ybç6eÝB2iKqú>Z–©Ø½“�ºw5fRÃ/¤ÉĆåC’W‰�{Ó7­��ø«ŠÂÕ…ŽBc‘c†!Ÿwn¯’QøÐï­* È7Gjýƒtog×ðib,¿'ó0•räÕÎ&ñ­û=1ÙÝ}âÏm«7ÔR5Æf¶Ê…�+NR¢Ý ì…þ~þQ ` D†½ß)6•rj§´}ØúÑì£3]ßM@š˜�mE‘Ïì<‚¦Ãc}‡= }TùÚŒØDé–]±eq& ºà°8Wª4kÈõŠ©SÀëé�HA/hÙFK‹Þ¬SBWŽ ^÷±¿Ã“aðíUQ*½ƒ(Ý•$ç ß­¼®#gíY^¤ä,Å”ÚQ\SF™kLLù—ÓУƒÞwÆ$F¢ÿ‚‰¨— +xœ�Wix×¹–0–pEãaŒ™Ifœ”’Ê%¡¬!ˆ aslbÀ°,y¶ð¦Å»lk›m–ädËûŠmyØ`cÇ.!$��44MCI“rÛ4!I¹Mï§Üý½�Ø“Ð<üÐhæÌó�óžï{Ïû~#LŸ. +…Ä+iI²ìܴ̼œWeÙiò…/*&_D¨ÀÃ\x$L@Ï0wó&~ø¯EèÒÑÔÿ°¡�‚³„³zD ø×¿Â ý#l~ðï˰_ +B„B‘äåuÉÊ$Ù¦dYfnZ®v½ò�6;-%57êîÝ’Åÿ±dá’ÅKž‹ŠM•EÝŵ=[™.“æF­ËËMUfç,¦ „‚ù%5� µ5µîîõ´;E¨¬ULÏœfŠ&þ6ƒ ›58"fA„;ìg�1"D ‚Á]Íá9Žn"ˆï™àe<\° 8åÁ5¡a6m0ä©�¾éÑÓ¯Mÿ6ôÑZѧâóXÖ?#lÆ•™/Í,œõÊ,nÖÿ…Õÿì¨$jö´Ùþœ{ètø þ_š€5à„5Èz]'‚w(øùà¼ñ.ôz¥%À�‚ð¹HÒŽÒT�뇯Π¿€ˆ†¨�/à,q}™xy©y«�Öë¹<‡óó~~bbˆ=6ßáàõl«­Ôz™„âÒÆ}3Ï|ý <>¥:›<Àô¦î:ü•—ªHeô"s»©‘#«Ùr{%×m+Š.3ë-j‹›4¸ËcHˆ@&\bgw�­¾š&jèä.4cYÆÂçJ³mÙŒ$AwfÛ{ð…?ü8„ý¦ÁL˜ƒÁÉQ"©²M{œšhèõ1øAsµÑYâÄtÅ:£†ÊÓ×�2˜ +ó—t¬xM?°IY�7Ð×ÚØlg¬ƒ6»Ín‹«â�ÕG)¯áÌFU(>ôXúºÌÕdtÊg§»[�Ò<¬!P¤X��] ¥övtù¬]ï71ôP½ +Þ‡9¯ "4Ð@ôU®9L»�®ÊÔ«ªLçdÊ+=åMTG{§¿5£3%U–±i/c™; £ébË�ETBÉ΢Mf½Es3!e1$Úö`©—8uçàk©Zj8u¸¢àEˆÀÏœ$,9–|Ž,á�†ZÊç>S{Áeq˜½fg/=ò2°SŒ{ÇêãhW…­Œ–—¬*Ý`2•ðÅö2ì-ƒ��&Q„?ïÐäØ3)D PŠæmoˆ•1ʾ–¢)ªíâñÚÆq‚ÈWíÌ+¡v%OÁŒ ÇH}Óæi;ÒIµ¶˜Ò›Ċ˹2¾œ–¼¬ûžÜî +Q4àøÕÀz ˆIq¥2 +ÿöù=Ã_1•¼ÍNB…¨Ùî©ýSúçèq¿ú +[„îhØz,™Ië-xŸºðnïcL�¡NG£JX@ð½öþZ/Ö|¤Í]Eµù²Vé¹b³™‘ pÝ@`†_ø„þ °�“°€°í¶'8e˜¾þí‚)ê÷_ú?ë)oËma”ÝZöz1©§¨»ƒlª¯ïèíQlm¡ëLU¼»ë3ö—uÓµŠlw,µs—Z¡`rsK•‡ÈŒêœzÝ•6™ÚY„ j«RrH…"ÿPâž‘Tt�µœ-0b’¯Í=� CNu8ÔA~!ð$Ì&?¿íöõÑ�¢ßù³×x˜ªzÞæbp_ňaœÆx³…¥ñ ¦4bXM¡GE¸o ši·Ê³ÙÌ2ÆDÝÎÒ=˜Ñía«)üÂÇÞ¡–sÔ¨Èç–oe®ãâåù†U¦ÛìåÇù·ÏM°cwسʚo¿LJÎÕ«ØEйó DÀjˆÀ/Z`‹Å0-al©|ƒ<5††1~õ>\)½Ã•ë›ÅË Ê¶ÞYÒÏó“'»î!ìk¡ë2 Ä­þ£ÕuÔ`¯6†A«ÄË +Ê’î‰êæON¿' +¿´ÕZàú„” ) |{n¾'ü+ˆ€¥7sÆ/�$ìÛ9»�lèu{¨ÁÎ7ý÷@I­ù®OHX,na½&7]߬ú5Øþ@Ðn»‘(éØRù2©b}¬PÚ±�JY/SÄ0ø¨©ÓÔÄ‘ø¥«{÷=æ#í÷fͦ s³Îù…Áó½ ¢B| %ÐÜ,òý7¼¾!úÔ°çÝ)æ.¹Šž\¾%31™–íËß¶�„x�xwd%z…%(RV(`öÅ¿¹tž‘ ë.0µðÊÍ$†*aëÄŸXJšI�±Jï µ¬šÕ(7óÉaóo¡;e8R±ŒD[Ä:NÇëèì¤t³–’fØßc`Õ÷#U¬6^Æï¿9bnÐ-#Ñbñ£þ¸Oû>èè>M[²-šŸP'‰ÓÜõ„×À¯Ñ¯!æAZ‹ð+ðòÄÙÏlv«Õj˜wr±G¡3¥æÝZÇË¿ÅOŒŸe½·ó'w¤Õ(N> s# NÎjµ]Ad{O_u—õ6¿ÞT³Ùôä$^}-~¥Ïä,UgÆ­‰4 œ±2ñÃHU_�¥ßv+HÍnfcwÇÜ2ì=$mg® ÜjäŒúŠy¿B¢lÅ¾Ò ãmdø/ßÅw;q†_ÑÚ:»0ÉSºßÂçÁòR!�•ŸÕæúRZ.MÓdRk·¿aÒ29á;œ¬°2‡¬mênª»©¥k8î $D3ñ zbsSÌ€œ‘Œ¾O�¹àŸìg$è5Ý{ðû1xÜþgˆ@8à‡Hüïo¢‰¢Bci1“)6ð¬�~Gd^À¢9»ÈTWZƒ–Ö4õ•5S“o¶·{™j½£ÄM늳ƒVšçcÆØÿþ†ü»È]ks1]b›Éb ñ+h†ˆï µœ·Žp¤Ãd5ÐøçòÒŠ&¿"S_Q†U”­"%HS¯úný-¡Á}ßNüX0~t¾.“�1~á'¥GrÆÜ/ °ܲ…�…¤°ÿúþë?Î6ßY'Öï¼LþQÜÞe*p3MiíI9V£´–’Yb‹9”ã†-½CS¬ïvD²-Ï”1Œ0x!ÒPivÚìc“‘ø?»{Ûz?tÞš3�}…Í’'ðòÛ yÝx¤,Sš—‘—£Öb¥Å{ó3(øLüÓû‚…ºñÀo‡„>x:$𨎸zeäÊ»ŒË�_]J=¿aeÖKÂ~ÃbøÕÇ0f=üüÒV¦ÚèµV9 ãå'Ë&1{|â šM¡x´ÍF‡¡iï`ö¾ýQþUJ‚ÆÊ��g�ž�!gβîŒÁÁžîþE§Tš¦H¦áÔô�Iþ\¯ +DŒ¹ÕPèÿ"`kÐ5 $è.˜+1¸JãH+^^bÞu�´õñ£÷k÷ˆñÑ1ÛGW•9ŠhüR¡>ÓœfÆ�ò¸ž<×Ñx´!?é0­¨nI÷Q½�Ãušîƒ¦.=¾&ŽÚW˜"gö&Ê P²¸Dœ&/,gòÅ6S=…ªD+~Tùqß=^³:ƒÖr­‚BxèbLœÈ’Ks³”õ¦ÆÔTžGfÅoH,¡ ż®ªÜç8ÞÒÞŽµ··Žö’LŠ£%¨ ^ˆQÿæ¯ÛÀ›ftwOÊÒ•å?þØëïÈ$Ò›Ó‡[ûZ;sû$ä*2hÉ[7Œ0Øu-;ØyJØ+nôÖý„õý;ûJ[*ݰOK›z��?Ѧ?°])P™^ø[œ +žèU¿ñTx_øú)ƒŸƒ¤äïøÐD %@íGª}õY²};Ò³2|x­UY©ýtyéLRÖ¡äxrwÇΓY4>²öà¡=;Õ¤ÆZâ.¤ñQ®¢êr¯ÛŸµ/&Ÿ”WïoÓЇÎéORAFÓü£¨Ý1iÝšŒžª\GiY�¸kíÕŒ®¡�í¢ð¡‰S'j:{˜ŽVoï09¥ô¥µÓnçÑ:7åªÔë­L±­NÕBáˆBÃ×—¿‡'L;S +’ÒµŒö`¼YFmJ=ÕÃ5Uy£»ÆÜ@áà †sÄÓÊ’¬-åO]¬k8áM^MKš9àšZ"ˆºì �k~b›HUT† ,_n·MZi·ƒkÔ9°l+•"‘… ›¯Ósyn=6ij7.'¯ÿR¼\iŒ5Ñ·F9[hÈuüÅÌ1î1÷;Žq�]e)1cëÕòW£$ð²¹'ðQ�°®òrpUØC@ð?œj�¿Èþ– › E¬Ui»LB¼¸³âp‘7 žF»"½YµJKfâM6ÚËOð�ƒìÀíªgØòœY�H Õ‘ùÞb�“¬ä««Ü4¯¾1>5ú†sÞ-rd³©lª4‘—ÝÅ7ôƃ»â±ƒŠ^áÈÍ;”šôR 6}?'Rv=+•®ã¥?H‰ÄŽ +¿yüËUßIz°žƒ­("ð•`@«‰#í‡ûª;?†¸QLÀôÚŽÎ.ßÏ_�ÍjYejÚ]yÆðÃݦnCAÊ|TÉrËÒ<dzzÈBYžãyR;PáyÃ~k +9»�MI»§8ntV´½�´lF«±F[U¨/ʉ�a¿Í¥«¦>$èB¤¦²Æ\C¹ë- NæoÀ}‰,¡ÚÊzS åöX½NfÃiÏ1OÿÔ=µl–|ÿ½-€=K³{Zi,ÑóFw°Ú7œRýŠ›Ns¯“Æ *ñ� ì~îúT\ç±W3MbkÓÐ N‰àÉ¡ÆF�­0§’V¸Z³û¨£Í ÇÚžx4áÕü$ƒ_5�£ëÐÆ]NíÝY˜´�IØ'_¿š4=ˆ‹Þ÷ öž#ʳ ™)¤Åôˆñ«7üÛÓªM«¡ñKî,o^‡“”›{À;U~›:üD}îį‚!è_/]_¨×$Z‡¾‹s80s/×ÙD6ñ=|­wäôz,Ö¤*ÛH­™¨ÙÓÒLÿ§èw­û£™js�ÅmÇðK¦ãå_±NÌÂò&¿jÊ/gs(4&â~Áïâooà=“ǰœ¼>ÿ~2øÇï�™í2)Ù­óçÁ ��CáCð¼áøp`Åw³g¬ª~•¸½(í#ÏPîÝMÊÜ{š2è‘-—ÓŽe`#Šaé«äîýi[7FOþEMãšG�±Ðˆ±,ËRk�;«ä4>ü«hêÍÑ:ßÓ×Õ=r–ÏëÍ8J'{µ+Ù‹I½ÆCNõôœúSûšMut­±…«raÆ¡ŠÓ´•¡X•°Ä!}à í(Ô(žîìUô!1�à!Á3€ì쥕=¡h. +��֢ͤ$Y7ûÇ``@xHXá!ïw¦^ãÔÁ£¶ßµ}xûð\÷·_’�Žfú Å;Pø³»�¡éðDÿÑšÆ~º|}zt‚lûžè²Ýp”È‘©ÌZj£òÂt�ö�M&£K¹l¶”‘¼Y¯‚n?œºå€ƒ§CàërVr9{ 1 ,¿[yK�~‘¹oE¡Š·ÑGQmm®5±ÍÔŸÏ>:ÈŒ yÞ™øžŒÓöšJËAÝ`#† �‡ÔOg(B»S@ŒHä!‘Í@dF*Ýž +s!ô¿`-l&%ÿÐÖæ÷ endstream endobj 396 0 obj @@ -1422,95 +1423,95 @@ B endstream endobj 411 0 obj -<> +<> stream -xœí}]×$·qÞ=Å�’)¾· -_²"Ù¢�ÄŽ$Û¡î¬\h÷x™ä,7Îzs|üïsª?Ð�éénÌÌò4/¸�~gzª«€B¡>žúæ¯?|ü_oÿüæãå·¿ÿö³ÿ{‘q—Wü�# ÎywyóÃ7oÄåÍ¿ñÁ{”Ú8×ý•ºüÛ›÷Ý×~¸h¯­6qy7 “ÞÅ�}÷ÙÿüìígÿôÙßþþÛoF*~õ«oþøÿú/ßüîÏÿñþßÇ_ÿú·“…´”N^œô€ÍD›”Ò²L¤Þ åõEIo„uº#RjéõEJPV3Åñ-ouGczÉŒ‰ýî_ÿüþW¿úæ÷ßþÝß\Ä7¿ûóûï¿ú—÷/b…­lB,)©,j¦­#%‰ojòBzô~öÛ?^Äå�¾y+.R_þø6�¸üñ‡þêOBˆ? !‡qøW½¸ñO4ü«‡ÍËÿøãßö·,¼ˆ¬¼Y°ÎY[|TÝ<ðŠù/xj¨þ?JßD^üM/2¾Å ÒWù› ÿÚîß×É>?3þõ}?’ªð„·Ýÿ?D |yesf�“Ããeü€�ñO�„àø‚6ú±ð\^Âp&¼ô÷q¼O/#‰hª?8r©ð‡”ËÃÏŽ$Ë”¨^Ή*ò:°®FWÆŽðK‘dJkÊìë( ÷‡±ê¿-T~3äï�ò:å-/Âd¥Ýªß¬'0ÙBsžXñʈ®°»¶‘–ÁK¥|§„§‘”`iÔi|µAÿÚ@ÎèÓ¬ÆXW -PÔi`¾•FOñ&Æ;DweGºú‹M‹3j”鬓êb�fNl×°U½”®é˜T—Œ3xœzç°¬é_ê{qùþßnž È\á÷¾¼ ×Ò�dNuó`¼Þ±[BÐRбT*ÆJì¨ ×;¨4΂Góò *µR -% rI¼—~Xüat�Ø#RwË}‰Ôùº_ø�I�Ôªµ ùµC´�^½ˆ�4 N˜ËüpÂi«l|5ü]\Þ\‰ñý�“ýd®îEô@(¶½ûÁ«nÄ”yƒÙHƒ4Lg7õßGŒÔhIFWñçúë71ï.„�Î*ÞºgtOîõŸÓ¨#@ÌFý#o磒 Q¹nõß"ý@ðû�œK¹Šà½±8ÞèÙ:±¨�/y�éãcÓÑDÌ»ëŒå6ŽFv#)$v/ßKm×ìDPZÚÉU ÚR6B°ÈßRKg/l–ð…ºhpºûƒÅáúÍð¥~ÔÍ@åœD7Üé <ªö_ys›Fâ†òع‹BM²²ß ¿~ågÖwßéopÝKê‡#eýhë@$T',^“Yër�`qÐÖ -aêä²ÿ+Àá‚׃1Þ£gý¨€(þ|7î>ÉK�º)9L\¢Nsj�ÞEÏ PÎô_é/ßăwñÃû["zŒž¿az+Bè^i0Z­f™gÜÀ3圑ƩärøDÏ4Õ]u:…¬rŠ @@e⯌7øko†:˜ýH�òºûúô ÖÑðýõ›áýè]üý-=H ?q$ó¾ýnI7|÷íøO—¿Ðå÷�C?| -2}·FêŸ}W8|©¹y¥&£U²%ù Hö¹‘â�É -í\wÙÝ”™W/Ì¿œ35ÿPrf nœáìöòŠ�:ï�×é3G¿BæitêÆçΙ)–bôÕˆÌs’ú®Ò3gú›¯Ë#a—½{T“ŸA@j&=�º³¤�¤†ëxŠzòÈ%,ÜvÀ¦�ö Hôg˜ÓrÝc¹ÞÄÉÓt];? 0]™§áú¤†«vàPŸvëzÓK;Ðk'÷iµ.³î4Z—ŒV½ÒŒ¬­ Ûö†®™?ctn´#uÏ2qÜ`°gqƒø•ÌìMœ!-Êâ‹jÈ­4|ÑŒÆÚÛÜzKMïðç…Ý æ>ÆOü˜›Å%Szû}È–ªøÜY@yY@¶6Õˆ@.ó&Ê9–s²|¨� òŸ’òq -§¼9Ò.'>ãÓi–o1ËoaäéB¬â�P„†õì>¡…~<™Þ…¶R~ž'Ö­+e@x:ŸÂ�‚¯I�GŠõv1 PÉü>]á[™wž*–NnÕ©BiÎ*Ýž�T·ôFç±T…ä8¹l�úÉ–Õ®%©‹$i�föøÛEwðÇÛÎ!qOÍ-Ñbà}|I\Ë™Ù\Î ¿hK¾é¥Êtz%ÇøBHð\8UruEmêqv’Nµä˜©†«,32nÝqd`1:³ÿ°©t1~3[F‰©�¶—þD8–'I§A¾Å�NEt²&:iÀÊfr $ãHñ°ò^WÇ»ÂäE‘rZç1�òó¾•E߯ìÛ�š47sšYÝ¿—ú”Ió ß¯!ÖD(,�òí¼0QðóëGï„nµ|40Þ�v ]2g~ª-‡I!kl¯Å0Ó6‹x¶å+¤Ÿm_Ô•zeb¦[E–æÿ¡°5.9Ж"ÚoãISJjŽTw®sµ7~!/V¨ P×è<¨!G³‰õ±Ja ½ØÏ–j ’ÙœízÅ‚4•éØ6l—T’Rµ[_�5çfc‚W­À«¦¢xy%ùÄ#„£€ç@î îžò“ÒÒ+­N׈§V?o~½ëDØ0wÃâ¯HÈÕ$d%ÈvjÙ�îçÖ_”ÿ˜Y�‰ ¿¨㌚·×òF2�Pò-5 à˹zý2‘ÂÏ–� W'_E^¾&/#Á‹v¦Ä�J_mâå‚ù=Ó;ãêÜ›ïH£µ0ª,.òº¢È©Èd7ý}YfX;|ÍuQìžh»� „¿/O½Ú¦ƒ²R%CȤVÔõªÚÔmA×7�×™ò,¬Ž/¢¢¹”}-LOŠç›\.ÖšŒ”ñ‡Ó +xœí}]×$·qÞ=ÅP”(¾· +_²"Û¢�ÄŠ$Û¡îì\h÷x™ä,7Îzs|üïsª?Ð�éénÌÌò4/¸�~gzª«€B¡>žúæ¯?|ü_oÿüæãå·øö³ÿ{‘q—Wü�# ÎywyóÃ7oÄåÍ¿ñÁ{”Ú8×ý•ºüÛ›÷Ý×~¸h¯­6qy7 “ÞÅ�}÷ÙÿüìígÿøÙßþáÛoF*~ýëoþôÿú/ßüþÏÿñþßÇßüæ·“…´”N^œô€ÍD›”Ò²L¤Þ åõEIo„uº#RjéõEJPV3Åñ-ouGczÉŒ‰ýî_ÿüþ׿þæßþÝß\Ä7¿ÿóûï¿ú—÷/b…­lB,)©,j¦­#%‰ojòBzô~öÛ?]ÄåO¾y+.R_þô6�¸üé‡úꟅÿ,„þÅá_õâÆ?Ñð¯þ5/ÿãO¿ûìoÿTxYy²`�³¶ø&¨ºyà/ó_ðÔPý”¾‰¼ø›^d|‹¤¯ò7þµÝ¿¯“'|,~füëû~$Uá o»ÿˆøòÊæÌ'‡ÇËø!(⟠Áñmôcá¹8¼6„áLxéïãxŸ^FÑTpäRÿà)—‡ŸI–)Q ¼œUäu`]�®Œá—"Ȕ֔ÙÖQîcÕ[¨ü>fÈß!åuÊ[^„ÉJ»U¿YO`²…æ<±†c•]awm#,-‚—JùN O#)ÁÒ¨Óøjƒþµ�>œÑ§Y�±® ¨ÓÀ|)*�žâMŒvˆîÊŽtõ šgÔ(ÒY'ÕÅ:͜خa«z)]=:Ò1©.gð83ôÎ9`XÓ¿Ô÷âòý¿Ý<�¹Âï}y®¥ÉœêæÁx½c'¶„ ¥ c©TŒ•ØQ®wPiœ+ŽæåATj ¤J<@ä’ x/ý°øÃè ±G¤î–û©‡su¿ð“:©UkAòj5†h;½ziœ0—ø1à„ÓVÙøjø»¸¼¹(0;âû+'ûÉ0\Ý‹è�$Pl{÷ƒW݈)ó³‘i˜Îþn:ê¿=Ž©Ñ’Œ®âÏõ×obÞ]$!�U¼5tÏè>žÜë?ÿ¦PG€4˜�úGÞÎG%A¢rÝê¿Eú�à†w9—rÁ{cq¼Ñ³ubQ?_ò:ÓÇǦ£‰˜w×5Êm�ìF0RHì^60¾—Ú®Ù‰ ´2´“«´¥l„`5†¿¥–Î^Ø,á uÑàt÷‹Ãõ›áKý¨›�Ê9‰n¸Óÿ@xT?ì¿òæ6ŒÄ ä3°s „šd'd=¾Aý&Ê#6άï¾Óß0ທÔGÊúÑÖ%€H¨NX¼&³Öå Áâ ÿ¬ +ÔÉeÿV€Ã¯c¼GÏúQQüùnÜ}’—uSr˜¸D�æÔ½‹žA œé¿Ò_¾‰ïâ‡÷·Dô1<ÃôV„нÒ0`´ZÍ2θ�gÊ9#�SÉåð‰žiª»êt +Y倀ÊÄ_oð×Þ #>t0ú‘åu÷õéA +¬£á'úë7Ã3úÑ»ø'ú["z�~âHæ}ûÝ’nøîÛ?òŸ.ÿ~¡Ë‡~ø48dún�Ô?û®pøRsóJMF«dK0ò +�ìs#Å; ’ڹ)3¯^˜-~!,8gjþ¡äÌÜ8ÃÙíåuÞ¯ÓgŽ~…Ì?0þÒè +Ô�Ï�ÿ2S,Åè«™ç$õ]¥gÎô7_—FÂ.{÷¨&?ƒ€ÔLz:ugII ×ñõä‘KX¸í€LíA�èÏ0§åºÇr½‰“§éºv~`º2OÃõI WíÀ¡>íÖõ¦—v ×NîÓj]fÝi´.­z9¤Y?ZA·‡m \3ÆèÜhGê(žeâ¸Á`1Îâñ+™Ù›8BZ”Å9Ô�[iø¢�µ·¹õ–šÞáÏ ºÌ}ŒŸø17‹K¦ôöû�…-Uñ¹³€ò²€lmª�\æM$”s,çdùP!ä9>%åã0Nys¤]N|ƧÓ,ßb–ßÂÈ!Ò1„ XÅ;¡ ëÙ!|B ýx2½ +)l¥ü… 0^“:�ëíb ’ù}ºÂ·2ïÒ:Íìñ·‹îà�·�7Bâžš[¢Å0Àûø,’¸–3³¹œA8~Ñ–|ÓK'”é(ôJŽñ…�à¹pªäêŠÚÔãì$'œj%È13R WYfdܺãÈ(ÀbtfÿaSébüf:¶ŒS!m/ý‰p,O’Nƒ|‹!�ŠèdMtÒ€•ÍäHÆ‘âa7ä½®Žw…É?Š"å´Îc:åç/|+‹¾�Ù·5inæ4³º/õ)“æA¿_!B¬‰PX åÛya¢àç×�Þ Ýjùh`¼íº&dÎüT[“BÖØ^‹a6¦?lñlËWH?Û~RWꕉ™nYšÿ‡ÂÖ¸ä@[Šh¿�'M)©9RݹZÌÕÞø…¼X¡&@] ó †Í&ÖÇ*…�ôb <[ª-Hfs¶[è ÒT¤cÛ°]REHHÕn}Öœ›� ^µ¯šŠâå•ä�JŒž¹3¸{Ê¥¥W,"Z�®O­~Þü4z׉°aî†Å_‘�«IÈJ�í&Ô²!ÝÏ­Ÿ•ÿ˜Y�‰ ¿¨㌚·×òF2�Pò-5 à˹zý2‘ÂÏ—� W'_E^¾&/#Á‹v¦Ä�J_mâå‚ù=Ó;ãêÜ›ïH£µ0ª,.òº¢È©Èd7ý}YfX;|ÍuQìžh»� „¿/O½Ú¦ƒ²R%CȤVÔõªÚÔmA×7�×™ò,¬Ž/¢¢¹”}-LOŠç›\.ÖšŒ”ñ‡Ó ÎqÎ|Ì™™²>Ü—«×.Ä‚óÍöæª&eyÏí�vÛ*[gÇ{€ß…k© ÷—�W{ -¯$Oq4…±iC ÑzýtŒÔœ1šUË~aK µ3cÓ8:–ÎÝ_$ó ¶@êboÈÒé, 8"¶:ŒûUa7}ñ—Cá·Iÿ …¯œ�÷8CáŸB(œ€QLË _Ìe–©dzŸ‘ð­Ì;#áK‘p,@rh@¥yѲªÍs�®„ÄaT‚=êP//üß7Ÿ›”a­4Ÿ”Aµ�èÓ ÊùHŒã™ÚSÇÙSÑä<í©'·§”o¼4ýwTkt†må 3R{ê¬VÚÆºÓšZ´¦ -5ö~rþ �Ý/5ÊÏHkÝõ�qÕîߟ]dz¯ŠÄ ‚RŸ†‘·�èÓÈ«xÍn’þiå­›�’¯N+ï“ðš!‚ìh9�¼µŽ”à’é}zͶ2ï´óí<ªxÍ$+…gõš}BÕ6¢OƒjÙkv›ð^J¼‘ðÓ\·ªNCðr÷�–à­>«Ó<Šw§¸hêš¿Ovhâ¦Yg–¯š•f¾å$ø<Ã>JuÝ缜üÔœw·}ÚšçÝMÒ?m¶•³S�?Ñ_> ç�p ýi²ÝâÐÓzÀœÓh«pï4ÛÍ6Sqß NÿV÷Ý'dRm#ú4©–½`§EÕÀ vZTŸ�ì4©nõäÌ-ª3ëm#ïN{jÑžšƒŠ�'$;¿žÑ "†PZ>ªmDŸÕÌC‹€š´T·JÿáÑ­”Ÿ¶àÊuuÚ‚On jZÑ OSp] ]©Ì¨3NïÚQÜ;­ÁEkÐÕ‚¢B�lˆPœBZI;°Qºm©j¬ªžÈ`Žo +¯$Oq4…±iC ÑzýtŒÔœ1šUË~aK µ3cÓ8:–ÎÝ_$ó ¶@êboÈÒé, 8"¶:ŒûUa7}ñ—Cá·Iÿ …¯œ�÷8CáŸB(œ€QLË _Ìe–©dzŸ‘ð­Ì;#áK‘p,@rh@¥yѲªÍs�®„ÄaT‚=êP//úß7Ÿ›”a­4Ÿ”Aµ�èÓ ÊùHŒã™ÚSÇÙSÑä<í©'·§”o¼4ýwTkt†må 3R{ê¬VÚÆºÓšZ´¦ +5ö~rþ �Ý/5ÊÏHkÝõ�qÕîß_]dz¯ŠÄ ‚RŸ†‘·�èÓÈ«xÍn’þiå­›�’¯N+ï“ðš!‚ìh9�¼µŽ”à’é}zͶ2ï´óí<ªxÍ$+…gõš}BÕ6¢OƒjÙkv›ð^J¼‘ðÓ\·ªNCðr÷�–à­>«Ó<Šw§¸hêš¿Ovhâ¦Yg–¯š•f¾å$ø<Ã>JuÝ缜üÔœw·}ÚšçÝMÒ?m¶•³S�?Ñ_> ç�p ýi²ÝâÐÓzÀœÓh«pï4ÛÍ6Sqß NÿV÷Ý'dRm#ú4©–½`§EÕÀ vZTŸ�ì4©nõäÌ-ª3ëm#ïN{jÑžšƒŠ�'$;¿žÑ "†PZ>ªmDŸÕÌC‹€š´T·JÿáÑ­”Ÿ¶àÊuuÚ‚On jZÑ OSp] ]©Ì¨3NïÚQÜ;­ÁEkÐÕ‚¢B�lˆPœBZI;°Qºm©j¬ªžÈ`Žo ÈŽíKTÆÏË?_/ÎÈ`¸æM?*HR¾"+í8×p‘·/ꬽ“}Ǹ71ò41WÎN§ÁÚËÔÓļC—Éê41¯„ ™erõô> Ì ïNûr±�µXŽÞj‡@˜MÀg‰ÞÞ¶£>Iôö´§Ž‰ÞžæTƒèíiN}BÑÛÓžº5yšSG±î´¦­)Yó9 Û5Â)tnš#‹ä®9lÔË8fŸ?ù±P*×½y -k²´”gUÞFš¹×3ñ…†V˜÷È]©I1Ê/6ù¥p Ðèþ8à’f\k1¡¹J++x½‹Fv•Øí"Dš*ÈH +k²´”gUÞFš¹×3ñ…†V˜÷È]©I1Ê/7ù¥p Ðèþ8à’f\k1¡¹J++x½‹Fv•Øí"Dš*ÈH ÔWªnô¼„³¿·’úÿ2y¨‹/qEǦٜ£Êš—¶KôìÆös¨ÜA¤Úòú–õ4o@Q]Mµâ.m H´¾#¢n É2ùz§sÜ x<Ïr»}ã7ðñ<Ë­œ›Ú�”ҟ韂oÜ X‰}×…ó0·ÎÁkHÊdË8Os›xwç�s•Ò&­‰ Ò3 û4ÞñÓ69ÄÏ|‹iòø”ÖmtŸ&Õº%ušTŸ’ü´©nöòž&ÕA¬;-ªE‹ÊÖÜ@%“ªA>kÚà•\_+ýÓ«¹àŠE¡�?]OûÌ;‰ JúS3ð¶R~šx+×Õiã=½�'Qƒ'7hÁÓÆ[Ç3Z‹�g©‘w–-meÞiæ-šyóª%©$X×qñ=gRD¼mc=m«9 "´Ÿœiµ�ðÓ²Z¹ªNËêù-+eÄ|X§eµŽg¤4xºÏäÝiX-VócIL©áUÛÜ–úÄÞ¾¼2à½÷Æë()4K«ŠÉ§yµê1e…x?ô²õ(_^I±·;Ë�½wS¶ë˜þš~=É1+;_W; -¾ŽëÖ±˜zÅ#ùeDÞ‡<»ïexÿ¼(þUúÄ>Uö'׳úHV䉬–²Ùd Ž×˜¯ÁÏ:þuEÝ>2}% ´(Uñ5n9¬t;¶[<¬!·W´+г™ ,aÓeó¬…p[É>ÏY…¨‰’´aœ–µ¹Ál -®rXžêÀ¢-hOÞ^´2`=FJú<®”9æ@z3pŒ¼”«Oxçye™yçyeé¼Bóš�λÖq±µ�¸§¸EæfrÅ|œùx$RöI­GoÀ*ÁÆíi…íóv –awL8­°ã¬°h~žFسaÞ±‹¿Öi„­ã˜D8–a§Ïx#ïNlÑ›—ÞJgÖïd„ ŽÒ¹Ëøš›óímé˜[<µ(¶O§tà)Ûû×ÖÆKË’VÊ÷31Œ¤ÛM“ñjO5¨4s¯›¡…ŒíÃòý• ë/ªõ©P;Å{«u<ëdWœŸÔ‘ƒº[½ÃT@š¼�Þ¤³N\|uν�Ïf×€+„Ù)k�àÅÁ²V¼´ÖÛŽ­Ñh�Ì “7û�‰#Ëûr'qå™R’žW¼Ž(%°=XCwÑ¥Û0iýÅ’Äm±ZŽ˜òäsj…gÐÙé.ʼns¾¸©¢¿¤“åï˜ù§•óþLDü)É_Ó\ô÷•³¦[–896Á›±e¦JŬ:y¥±$}y]„ˆ#cv\·ãgÕÈÞò3¦‡O�ãäÙÃû¼ŽßB©dÓ¸._ˆe³Ñ«v˜$A«�ïGg.)�À�ïh÷iD2–«•:x÷36@ÃD£‘ ±�$ìÝ4¢�¨=osâî1_2 ÎÒÑzn‹ŽÍ&u ¸æãÎ)«%X™ñ~ï”EÉ- ´ê¦Å4Ø3aÉ�óÆáý&¬¬LXR DFÍ 6Ûµ {ITøë’¿,ßü�l7¶¤ö?Ï&|Ø}–µ»Æb6¸$E®Ì�Wðñ.û“ä�®¬áÊ ©ÊtSlýëÖD¼æ?fi”lÔÙûæša§`I¢ŠÛÞ<¥@žf˜&$·ÕTÑÒrfhJÍÓh�iÞ·@e-Ìý"Þ‚6è±üšÇ®…âÚýifÇ¥vëÈ–÷kÔÃ_Ó¢†T¸b*SQX@ôÍx’X±,›ð�×(Ü�½ÀçÖ(Ê[°ÂZs?�Rq (�À¬Øê ZqJ’Åóê¸ÿGfæçéœW�ŠæLç3üYP9ÝU÷;/•5U(‡B Ê ¡ËïUÓ¿ÎÏKoúE¹>APMOÍ⬰ rNVN‚QÔÊî(¾bàJr(Þð.Ê%掩äE+ãÀ£J�ƒ¯¯Ö8‡ ì¢ŸÐ -¶ M)pAÀ‹²”"²Û”/ÐÚAé�£Û�aMùØÂô-°¯¡¦&æB¢±ï´q¶Lh 8Ø&újü‡äø­…ø›s ØJì •:K}ŸB5ZF¢©g®YÁ·Mà< ùàë’m9,ù€ÐFÕV�ö`4¶*^5RžÒš°¸Ç�O¬x»¹Ño  -#w¿› -}mr�>ï X) Ís Þi K€m+�YëÃ(à˜7á›…6•àJB%fqP5{Ê‹ÃYy¨2ᆩl"Z€À,àöL›ˆ¶@$âvª÷†7¶²‰ÙwÜ&òu¬îÆÆ—Iš‚j°}:D‘Ö#fþ]ÝR°bÁy/¥z -Qu"ÓGÍeý*5®¯KÛÎ�Cë9uË=­´�/Ð=ź¶sãÐuµŽ¼¶²žbnƒ˜bn ½Ÿ³P`µÑø¤â–Bƒ=}�—w©M„eO½n/ð§[EÚ¥¬áͤ=ËΚ·u‰Ý!™M?Fú¥�qînéauÍ V;Õª­uÿ‡ôòJêÌ^˓˒ÊTC»Æ¬¶s£Ì"8Û™Õ¥5‚g£É²² §3Ê[^ó›XvbÙÉ!pŸÏS)B:õ´ÉoJÉ9��“߬­$¿)$PR¤b?,ùmtvJ5-Îá8=:´>fŽñÈx¦ÙžwpÏ�ðY6]ÂW™4‚#ÛÄÕ-–¸œòÿÖêªc5íï7vfb\2‡ÜKÅ‚Ô"MÁ9ËxÖsR -�VÜÌÉg€­ÚJúY�´vm!»·SUu– =U ÷¨#Ý/^éxo=‹�xæAhxfÅÒY -¾™{gÒR’-`WIþÉŽ�m-Â,X…º6"±k^ƒŽÝ…Ò m:ù//ßÿÛm)£öáïêN!áêÒ+$0Ò²Šï´�‹Òx>2¡  ߚFûM4KpºË ŒÚ±¶�õýMô»áÖ› Nƒwѯ†›bz¤ˆ~3^bñœp¢èþÌÛýsbµ{.=Ç‹Ç7w+JÍë�Ï�Ífs>mqÓEÇ/)D¯³¾ñœ]{r'Þ±E·êßMÏs~ôÔMƒ §÷‘Tt -ŒµîhJ¥ÉÉÎÇ0^ï¡“,�tƒ8’P h=·mëH�F{ˆ•Bø>Õà ¹j”CCúˆ™Ê Û‚P÷G´itØ\�¨Ý?Y—ˆ=œ±Ì×EZ�›±½û§ìVÞ&Z—�È5ŽÎ§õEÇ&2ÆÅi£óH…D—.ñO_Uö¬yh¤+Që9ì IÝÎSÅŒ›¤€»ËÕû¢òTá¿Ó€Ö:õ`þ‡ñ7•÷Ð5I8 F õxA”½™¡&sÖ<ózRRÁåt}9¯ìª™Z•”t´„1úaB¿”²w.•—±5É[Ã烦}Я§ä}Yªé…ºêŸTóW·Ðº +ÉE^‘¼ç\�íÆ‚¤´�ë0ký‰©žÐ4?[jÐì7ÚIÒš”»úÄ[f·/œç¤fW‰kÇæ¥”¼�÷Ÿƒºé+0Õ^VŽ¶à•‰¡ñU8ï;B+©~k³Y;@>}6Û?Öa°¤möò5¯jâŸ_K/ÍæåË…ðÛŠ ¯û]W$¾jC;Bœ¹·&ñTÑ${iºªJ¢)»Æöñ…º;Í“@’iÇÁ0y—qA&ƒ&þÛû´âv–«´Š¼ac¬pgnìH#2Ó¶•e/Êå)6·[¤Ñ`•%ßxÞ½LT•'8ôÚFQc\vZɃð¾ª0Hí]³CW\RùåÕÒˆ`yÉöÖúR )J~]ÅX™tÄ[_UIåâØÁw®r 9¦Ú\HkPf¥(ä…g†É;p4K[É%ìž+¬.$hϹæYX]HÊ´<{Iû;°z:í‹6ï"œáÕÞ¥êià¦|Ê¥.“Cße­–”¢vÈG�¶Ù!?©æ¤õþ4)ª‡yDÆnn¥Ø¯Ù—+^›…ÓwV-œï %ó©Põ?ëËÂö‘=vL“Ÿ�@Ö-÷ð隌ª'©ÀßÌåRi•T#¹R,�‚@yÛìüYÂÐèfS…^)j,Vg%‡§s�3&+”Ló3—¼I!) ÎøÌUpmŽÉ‚õ 8ò|ÛË€ëư.Tʼn*e ˈ3¶„Lj\]j�‘-–~r<ùg[án•Shí”/=™z#ïí`Y›mœûQsÿjIwÏ�ázµäj­Î4Z=K§€¼èc¤ x÷Ջį¶�ÛËÕå³Úê%÷uŒ(œogë”H §Y€ðRÀ·«JdÈ„©XpMˆ'‰<5—ì:Ó]Ü\C¢‰ü˜x«¿\Ê4 › -–Ís°´�·Ç55Ê“¹KM‰¥µ“|d’|–b)yL€B"lÊÒŽÈ´Æ3%¬`$h©´4Ï»‚û€;3Y+X1+ç½2wƒ¦§©?‚ñ|àP®=7×”'J,l:V�Ñr‰Äà kÔU -¤%@išÄQÄM0Q$MÙ[F ™G%×E¾Ñq'#oÅON8ûÊ:%ƒ¿Xïݳ–uJCs—uJ¬ÕuJmÁZL'äqu�ø‚Áàדì3¿LŒf7ƒÃäMðÉ %püÒi¹¶T+åž’¼V­¼,yúQê3–GœղçÇËtÕÆM•ë)(kUö‹ëY}$+òDVKÙl2ÇkÌ×àgÿº¢nŸ +™¾PZ”ªø·VºÛ-V„�[Ž+ZƒèÙLP„°é²yÖB¸­dŸç¬BÔDIÚ0ÎËÚ ŠÜ`6W9,Ou`Ñ´'o/Z°#%}WÊs ½8F^ÊÕ'¼ó¼²Ì¼ó¼²t^¡yÍNç]ë¸ØÚ@ÜSÜ"s3¹b>΋|<)û¤Ö£7`•`ãö´Âöy»˰;&œVØqVX4?O#ìÙ�0ïØÅß ë4ÂÖqÌ" ËŒ°Óg¼‘w§ ¶hƒÍKo%ƒ3ëŽ�w2ÂGéÜe|ÍÍùö¶tÌ-žZÛ +�ƒ§S:ð”íýkkã¥eI+åû™FR‚í¦Éxµ§Tš9�×ÍÐ�B ÆöaùþÊŽ„õ ÕúT¨�â½Õ:žu²+ÎO êÈAÝ­Þaª M^HoÒY'.¾:ç^Èg³kÀ‡Â씵@ðâ`Y+^ZëmÇÖh´Gæ‚…É›} ˆÀÄ‘å}¹“¸òL)IÏ+^G”ج¡»èÒm˜´þbIâ¶X-GL yò95‡Â3èìt—âŒÄ9ß\�TÑ_Ò€ÉòwÌüÓƒÊy &"þŠä¯i.úûÊYÓ-Kœ›àÍXŒ2S¥*fÈ �¼ÒˆX’¾¼.BÄŒ‘1Œ?;®Ûñ³jdoù‰ÓçÇqòìá}^Ço¡T²i\ˆ¯IJÙèU;L’ ÕÆ÷£Œ³ —”Nà�Æw´û4"ËU‡J¼û a¢Ñ�H†ØNönQ‹ŠFÔž·9qw�˜/™géh=·EÇf“º\óqç”Õ¬Ìx¿wÊ¢ä–ZuÓbì™°äÀyãð~VV&,)P"£æ›íÚ„½$*üuI�_–o~H¶ûŸg>ì>ËÚ]c1\’"WfÈ�+ø'ñ.ûEòFWÖpå…Teº)¶þuk"^ó³4 J6êì}sͰS °$QÅmožR O3L’Ûjªhi934¥æi´À4o‚[ ²æ~oAôX~Íc×Bqíþ4³ãR»udËû5êágÅ´¨á®˜ÊT}3ž$VÇÇ…F,Ë&üã5 +wgD/ð¹5Šò¬°ÖÜO£T\Ê#0+¶ú‚Vœ’dñ¼:îÿ‘™ùy:gÆU£¢9Óù TNwÕýÎKeMÊ¡P‚rBèòûßAÕô¯ó‹Ò›þ¤\ +Ÿ ¨¦§æaQVXP9'+'Á(jew_1p%9” oxåsÇTò¢•qàQ¥ÀÁ×WkœCPvÑOh[�¦8Ž àEYJÙmJ„hí ôÆÑmȰ¦|laúØ×Ð Ss!ÑX€wÚ8[&´ì}5þCrüŽÖBüÍ9ì %v†J�¥¾O¡š -#ÑÔ3Wƒ¬àÛ&p�|ðuɶ–ü +@h£j«@{0[/Œ)OiŠM +XÜãÆ'V¼ÝÜè7…‘»_ŽÍ…¾69‹NŸ÷¬”„æ¹ï4�%À¶ȬõapÌ›ðÍB›Jp% +!„³8¨š=åE�ᬢHë3Š®n)X±à¼—R=…¨‹�:‘飿²~•××¥mçÆ¡õœºåžVÚN‚èžb]Û¹qè:�ZG^[YO1·AÌ 1·„Þ‚ÏY(°Úh|RqK¡Á‹ž¾ÇË»Ô&²§^·ø‚Ó­"íR‡ Öp‡ˆfÒžegÍÛºÄî�̦#ýÒÆ8w·tƒ°ºf �«�jÕÖ:�ÿCzy%uf¯åÉeÉ eª¡]cVÛ¹QfœíÌêÒ‹Á³ÑdYY†Óå-¯ùM,;±ìä¸Ïç©”!�zÚä7¥äœÀÆÉoÖV’ß()R±–ü6:;¥šçpœZ³Çxd <ÓlÏ;¸çGø,›.á�«LÁ‘mâê€K\NùkuÕ±šáÖŽ÷;31.™Cî¥bAj‘¦àœe<ë9)H+næä3ÀVm%ý¬@Z»¶�ÝÛ©ª:K�žª‰{Ô‘î�¯t¼·žEH <ó 4<3Šbé,ß̽³i©É°«$ÿdÇÆ¶a,ŠB]‘Ø5¯AÇîBi€„6�ü¿——ïÿí¶”ŠQûðáWu§�puéiYÅwÚGƒEi<™Ð„¿„oM÷XM# ‚ý&š%8ÝePFíXÛ‡Çúþƒ&úÝpëͧÁ»èWÃM1=RD¿/±xN8Qtæíþ9±Ú=—žŒc„€Åã�›»¥æuÈçÇf³9Ÿ¶¸é¢ã‚¢×Yß‹xή=¹ïØ¢[õï¦�ç9?zê¦Á†ÓûH*:ÆZw4¥Ò�äˆdçc¯÷ÐIHºA I¨´žÛ¶u¤N£=ÄJ!|Ÿjð„\µÊ¡!}ÄLå„mA¨û#Ú4:l®NÔKÄÎØæë"­ÇÍØˆÞýSv+o­�ËŽFäGçÓú¢cãâ´Ñy¤B¢K—‹øÏ_Uö¬yh¤+Që9ì IÝÎSÅŒ›¤€»ËÕûIå ¨Â§­uêÁüão*ï¡k’pŒêñ‚({3CMæ¬#xæõ¤¤‚?Êéúr^ÙU3µ*)éh côÄ~)eï\*/ck’·†ÏMû _OÉû²T;:Ò uÕ_TóW·Ðº +ÉE^‘¼ç\�íÆ‚¤´�ë0ký—‰©žÐ4?[jÐì7ÚIÒš”»úÄ[f·/œç¤fW‰kÇæ¥”¼�÷Ÿƒºé+0Õ^VŽ¶à•‰¡ñU8ï;B+©~k³Y;@>}6Û?Öa°¤möò5¯jâŸ_K/ÍæåË…ðÛŠ ¯û]W$¾jC;Bœ¹·&ñTÑ${iºªJ¢)»Æöñ…º;Í“@’iÇÁ0y—qA&ƒ&þÛû´âv–«´Š¼ac¬pgnìH#2Ó¶•e/Êå)6·[¤Ñ`•%ßxÞ½LT•'8ôÚFQc\vZɃð¾ª0Hí]³CW\RùåÕÒˆ`yÉöÖúR )J~]ÅX™tÄ[_UIåâØÁw®r 9¦Ú\HkPf¥(ä…g†É;p4K[É%ìž+¬.$hϹæYX]HÊ´<{Iû;°z:í‹6ï"œáÕÞ¥êià¦|Ê¥.“Cße­–”¢vÈG�¶Ù!?©æ¤õþ4)ª‡yDÆnn¥Ø¯Ù—+^›…ÓwV-œï %ó©Põ?ëËÂö‘=vL“Ÿ�@Ö-÷ð隌ª'©ÀßÌåRi•T#¹R,�‚@yÛìüYÂÐèfS…^)j,Vg%‡§s�3&+”Ló3—¼I!) ÎøÌUpmŽÉ‚õ 8ò|ÛË€ëư.Tʼn*e ˈ3¶„Lj\]j�‘-–~r<ùg[án•Shí”/=™z#ïí`Y›mœûQsÿjIwÏ�ázµäj­Î4Z=K§€¼èc¤ x÷Ջį¶�ÛËÕå³Úê%÷uŒ(œogë”H §Y€ðRÀ·«JdÈ„©XpMˆ'‰<5—ì:Ó]Ü\C¢‰ü˜x«¿\Ê4 › +–Ís°´�·Ç55Ê“¹KM‰¥µ“|d’|–b)yL€B"lÊÒŽÈ´Æ3%¬`$h©´4Ï»‚û€;3Y+X1+ç½2wƒ¦§©?‚ñ|àP®=7×”'J,l:V�Ñr‰Äà kÔU -¤%@išÄQÄM0Q$MÙ[F ™G%×E¾Ñq'#oÅON8ûÊ:%ƒ¿Xïݳ–uJCs—uJ¬ÕuJmÁZL'äqu�ø‚Áàדì3¿LŒf7ƒÃäMðÉ %püÒi¹¶T+åž’¼V­¼,yúQê3–GœղçÇËtÕÆM•ë)(k�ùŒ=IaЗu×wM˜Ú(p]¢ñ^a^3ìý²a¯JA7 F®•m>ËÊο…Èà u Êð‚�í�òq 5Ç+G)U°¬x—cˆÍ^†ñIéªÙÔÈù§²]öMÜ}kæaÜîËÝÛÁ‹Ñx�“\¨¶µºÀxp¤ºBÏwÓàø‚(Æ‚Bí…§£i=º$Êjð’K蟞§ Zåµ1öùIU„UŸ–R¯AimýkŠçº0žºbØwñ°¹¬«ezZ[�Úýkëž¼=`}Ý“ÜýkìÔNŽ” �4¢]ºmצW`Œõž¡ \2ü!|'Üâòó0ˆ«ÏÃÍP)>=2Ô‘‡ŸlW{.ÕÜ›ƒ!’€m£�Ý—Õ&Dp—|¡ÅͶxÕ6¯q8y34¨€œ›, i@Ym;@Ù®=9¡�¤  ßšîñÚ˜Fñâ˜î†¹<=6Ìôéw[.S;~ §30�c�ß©^LI+äy«f1!í{¼MìihÉ¢^¤ð/+äί,’$wέ=Â:<©Ø¾=×ÍžuS8Çz î‡¼n - ïµäüõ‡/šBosÃüðü¶íÙVÛŽ mƧíXhæP;X®:JÊõR¼JJœxqûs÷íÍBq•.Ã’Ÿ:ævSêöf¯ÁP†³v?C•­9¦ì1JFWvæö|Ã�ó¹hv-SÙ˜»hìÒ¾üøã*Ûrk¦}Üäuì;Pt‡åò#uŒš�¾cjc‘WR$ M¸ƒæ gŸòK?“sfC½¾–7™<%-#É1=×Y�q®ìÇk…x…¶Ü�¡Ž†§fyá•äß}†¥ÓÜ’�ú¬¦sͯ^ó…Þç“Ei™»n{•Àu'¸Ù—kqJ}£ÔU%Ó¢±Ô²/ÑâùF‘ÓršEc‰ÿª²¹W"Öv 9í½÷öŠç$[N÷ù¥ú£%ôå < (O¡Špßj58éðŒ'Þº²jã¸Å1C2´Y[ÿ©²¶ìòÚ2ŒöÔ »Éâ*�Ìg®Ç›WÂÉ` VÖSÒ;(5œ§x宥b a|xJ|£Ä+®—¶UÙ+ž-¸q±³ö.(Ùó ®hÙñ¢ýÂöV‚%ÉñÂfy«õ sŽ2šA¾çΟ�i2ä@:R®OË:—Úú¥VóÅ�c•Ô “ðvÆ3N¹o•»­mª�å¾ÜGZ·¬eI‚@Í@?m´ì‡YxùíJ—!n½Ý§Ì”o•¤î=ÏI}äöe¦$�‘.m¾q¤2{»O•�Rß(u'*ª¬¹Ô7ö°Ÿ §Ü·Ê].ŸZ‹ý×»êàO‘o9.—Á·ùov›Ÿ"ß*rµ\kÞ\¹¿ÞUi~Ê|«Ìi¹Ð¼µÌÿjùlRhvÎ&»ÉºŠ8yäh¨>Þtéïå=ö)î©íÚÅO�žY®£°ý_l\Gîuua”ÔQ„»SExìTG~·å4.ô™A¢çm»yr‡uÖ­†?ë - g”«�°¢×ëéΉwðóI.×±�·É¥é$«Z¸g…* d’i¬|z:%‚Ö›g'Ô8ÞïŽg("X/X_‰éz�®s‰0?›C~N¤îž£w¤uÿ<½±ûçê2­GÍW©à ´²gÅÙ­&E!PãÉ‹uš´Qü±B›êr»þÁž´:¥¾Uê¿6`ÏÔÆbÿbù@äçžWtjP�΂²íúFBÌQ*וž¯·d@§ß‘6*;(–,¤¨.¦¢­ë áe…ÏÖ�N´3Íe¹gûÔUf£i=nÖ ¦Ë©Vë�•�À8p~{!Ðõ˜‡Ü¹œ2ß$sUÛÚ -ÝU¶ª¨'ã¡Y#– ª;ëh•Œ -ÍWÂü$~·Øm—§å¹PU¥¯+\Õ¼uÍŠ‘FGÎá|CËšÌïÜ´ëÁ� -áF…`*›€ææuÜL¶�B¸ìÜN‘o¹­í�eþ§›„®LçE9…¾Qè…c¿"ÂzÝ^èlâ/oþ¾¶MI�ÜѳñÑdØW_ÏO†‹§­µ»~–õ'‹Ùpb¼�í!wî�äA+Û-œ3  -QÙ&I‚Öº!dKzVJ +ì‘{>wÊ<¢ì�f( -GLÔ ¼¢”º§É¦D¥À -ã̹bv®˜ÂISi�Â8ûà%S8l’`àôO°d -‡6âwÌ6SÙ¦I‚®yoæå}ömýw·âº¬r´¦çõà*®œÀQØ -ÏØ¦B-qßJX9Á³p�V ðÊê3,s«’¬ãP¡i•¥öו•^3ÈQ�µÎ6ƒ öq%J’Á9¾^0Õnܾ„†3Yò‰Å>*ˆ‰œŠ¢�µ8Ïa}síºï#þ¾+¨‰àDßfå4´nÕ!RVtCæ7 ã,C-£ÄÚÑ$¢ì!v–Tµ£Ik¾mƒEŠ'ç’Ù³d¨v6yèšÑµ³ÉÃ׌©œMZ³M`…°š�-GÛß \h@� v…Y±ù C,šäc†�™>UÛÃ-3Ïx^�®oPt<÷~ñòJbŠ Z‚Vú�8gCŽNÝ̋‹yoµî�²·ý¾Þg»Ï-7œjç%BÆpÏAVÄèÁZa˜%Æûá+áká0ˆ•p¸fxbЦá[j`¿l´n hìv„ùëu 8b¼g¸ð•U‚ ])0Š\Fr;ÕüÓe ˆ+PY0NYlÉÑ}ö ožãNç2Ú´Œ°`bCF±ÛúI×QÁî6H GÏ°Ž -¦¡@Þ[s‡u”¡Ù¤¤UÒy˜2-}»òª{<ùÃ$ nÖwêádô½ ©˜Cƒ3EÚ�Û´Ó@Æ6ìÜ‹FZ‰}™j°(�÷üwþ¾5Ýc3�b%3Ý�´Lxì¤fÂï¶Ô3•,!c-xÍßn\…8úÕ²4º­À_² ‡êsãÇ\£ŠX8{‘EŒkß~r„Ãa:¨,‘0¥µvÔ±Œß0†5Àོ2à½÷ƹ�oãˆÌ¬aÑ<à5w[¨‚ù­öïîw�×X_ *6¨UBá�9�Ÿ‡Á¶m2J0Žû£K`|²Ñ¡\Ñk‘‹è‡'8l¥4×ÍuƒWÝèÝE�7˜�4ÈnÅöwÓQÿíq$ÀH�–dt®¿~ðî"Aé¬b;¸{F÷ñä^ÿù7ý€€: ÁlÔ?òöÚ>%”�·2’¿=r°Û{Á ܱ³R�‘L�N[sêÆã›ô#'ûÊáê~”Vÿ0He”y:¼7Çý„˜„Û�§—º6]ÆÇ¦£‰˜w×E<θq4N#oñ”éçÛ®†…ÅeÏN ÞÉV ÚR6B°È_SKg/¤ã uÑàt÷‹Ãõ›áKý¨[<Ê9¶Áú;ý„GõÃþ+on“ÁHÜð@¶:œ»H ÔÄý@êñ úë7�P½»h°¾ûNÀë^rxP?)ëGÛW/²A8¬†s�œ†¬‹¼G©9xÁ•Ãݕ֯;QÖ -aYÐñeÿ�Î’ê/xIã=z6¢ÅŸïÆÝ'y5P7+‡¹KÔ-zí‘KèÃ3”3ýWúË7ñà]üðþ–ˆ#†çošá|>Qd;žÉ¤¯Î2θ�gÊ9#�SÉåð‰žiª»êÔ -Yå€ 8e¼Á_{3Œ|§û‘b0êîëÓƒp6vÿýõ›áýè]üý-=H ?q$ó¾ýnI;|÷íøO—¿Ðå÷�C?| -2}·FêŸ}W²ÂTéP°‰­:-ÛÆ ÛÕD1®4{YOëj§u%7?m”cm”izž6ÊóÛ(R²;bØ2NeÏ´¶º`¢Ôe§…²ÄºÓ@Y6PæqL%- ³­ ”RþæƒA0œ¶tf@ßä=V -£Ù&нc¾A¸ –cmJU¼•Zƒ–v{Ñ•ù¸76áLboS]"R†å8å%ÏÍcvó§½_´Xq+ª€ä‘iM’£e„ò(;õÖiÇnUúRÞÂÏob²E!’”ep¥@?CWÒΊÌñ�•Ré;¯†Y³¬r•âðâ»h$%ØN_�W;ÖŒR3ú4Ïfeu&‡J£§ˆ@Íʰ#®¿²#]ýÅ¢6(„¸Q‚ÓV^ rPß%ôtÔ «Á®(œWšÒä× '“D\|-Ĉ/útè)æ2Î…j B7[©Âìœ!Òƒ6c{èMx|VqZ€¥Žo¡¢I¸Þ�r©µò¼CM)§Qw¼—;è$ß�KO¨ç�~Ø£Á8F+ºt˜ýÀ{Ni7}ÚS%þ@é~ù— =Fú�ÌÄ_¦ó8áõ+=�éÕÝ™·Úœ¬%ªt‡ÿ¾—âÓ¤Ã)[K+�(~H6œrµ¬Òfü ³*”Ò Hñ‘–3wRÖÄ‘%»¶^Ú?Ò³"‰Z¶këÙˆÛ kµ+…¶§Ô·J½�Ù®-È�©M¥þ‹M"7£ýùF‘œBÆ@—PØVà¿Ü$p«A*K¼%žß$ð‚»�û(Û^±\62¨KjÂá A ß AsÁß÷±Cý>5?Ë FW¥rfhס‡ó,y5OA•eò*0铹�@ìjÂä{5b\ÝPjo�b=$¯¿ˆžý¶Œ›a¿ÚÛ;4e`´ 5^› -¯µWŒØo=q4¯�Å B�a�@‚H聯ÏEŠ[f,h†ÔÊO隟‹”0€RK׌�D©´GÆ4k›ý£®t JѪvZý½¸P‹ÚBw^øÆÀS7wàZáº:sM l Se�©VƒQixâÀ†š -Í6ë´&c,x âƬkM-æü~;�¥Mäk6�5Öu=N-µë|˜"¸Í'Z¡Ü åiý-³¥¨„Z•6w‡=›þ$ë·U�Ûš5ª¹oôúzw½~sÛUäÉA5!Zìn„|Q²ß݈@áºL+¢ð—ð­éïnÓ(Þݦ»a+š6ªéwînš*»Yp]Va›Ýí‹dU�XŽ¡V«6Õ §å@y‡˜�ýÿ¹.æ Pç¥nÍÔ[M[SäU»³Á�×fp5®r{ܱò¸IÕ¾ªíà…ŸÌNøráÔRf^dÈšÈaŒÖí¹Ö¸êk\EÏéíÒ¶áêç É™p-}hÙ§0¡¿Ê,›VÈ¢“füœÚì@0ÕsŠ.é»™WtšÔ5€ˆ5 /˜_³¢ç`€å³_( uÝà÷2ÕÓ'¬èv)†Y+¶×Ë þeÆ–�}z´ðœ Õ§•�y k�3SI“Õ‚‘,Eñ™Œª$6$$?Ä23TÉlhÈÑž¡¯÷%œ‹hÛ"Ò•ü�']E¦‚–õ«ÈVÐ²š¯¢·ªf·@@¿”¦¾¹ºé‘{ÊF.7�eé„“µÇKQ;/­ ¬˜šM¾«th|()¾¦Y°€÷œö©új£-x�Fö)Á¨¹­–tÝßuøË„ýîuØ_a”`…»1ö×ðØIi†ßm¨5m¥õ9®+h¤4“œMk3Ú–!9pV*—ÒùMi œBðÈÀÎ ÙXjº—Vó“#®Ên…�<ïž6E…³Óuâÿ²p\É� 'E9?fçg¾Šp§¢q’S�NU³IÕT\ÐÄ É=�ªÑ5UÓùUcjª¦ËÙÑ)i53“æ5µjö8ú2ßï’ëfc�å -_u]­é¾ÚÜ«¶d4G}˺†½²S?bdêfG™›«³´áö iÒgª‰$Ms[EZ¿\IdÁ(“Jü°ªÈb²À¨!ÅèdÞhM¥¥“Ûfˆñìšapnµm™¿d5yF÷éó—œöšÒöÀ4}i¸7¤/ # è…Ó¾Ï^nrLRúé¡~üØô£áV¿·†ÇÄ{ëpSLOä 4~oi¹‚o%ˆŽ©¥It‹Ú`ÓÝú6»³ŽQ)©%ǸR¼°šNøqj—S>ÒTØqbçÕãb^1/U)ùv§ª$d>l«d$+ÉëÞÉ7�¬e‰E¡‡Zò§'V°—Z -û)«œnè¼øìÄÖ}¤’eì =xþ©‰Õ -œ7Â¥¸HÚ‰ØnЂÖcôÖ}h=FmÝ…Öƒ´Ö}h=Bi݇ÒCtÖ}H=Feµ¤5ùH€²F¶CöŠw쎳‘KÏ\z6qéÙ¢KÏÎ]zvîÒÓwpé¹Jâ)gÈÙ¦i¥?ƒ¯µ#G©¨=z1™é»èJÉ -4zôÚq±£«Âà -ŽP­Ç I)@i{}ÔÄò8Kíý–c§i“¢ÉÝ·Óõ¯$HCí:²*ÛhÊ‚“^c×äÀ…¿LYá^—–FI^F¸Öôôذâ§ßm©&*¸-„ -ŒV-:¡ßª&lMMÄd>FM¸ššhÇÅ–V!­×"†t«ÇsΗ�E4X…ŒAÕžs›¡EFU+ArIPg­!Õ¹’•}§çiäÀM¦Ô4XZÁ¾ Ó�Þ°×®ÄBd|G.ìï ,²= -wÿ߯ú‘Î%÷“²�ñf…ŽŒ;Ðw¾=ú­ -Ý×ì>I@„Û-ƒÃº¯Ú}1™�QKU»¯W(t¯k -ýñœ35…Þšsvªó^ ›mQÐPfŸÏߦÍmM›—øw 6Ÿ7#©Žº\²ƒ¶þq+sWQæB*)Ü㕹¯)ó˜ÌG¨$%DM™·ãâue®„¬)óÇskÊüÞœ»]�KC˜æÁß×:WBÕôy‰…‡êó!—êí‘-�9à¡CÀãÔé·ét%*¹–ÊÒ?\¥+¡+*=¦ò1zÉT4z;®Qè¶¢ÐÏ7WÑçÍù†´S� î‹ å#µ¹¯hó�5ΗÚEï, Vž@Iß=óG­Ðe¥NG9Óµ@6×èRÖ4zLæCT“ÄšJoÇÅ:]ªšN<稦ԛsNìt¡³òÁQùܪ֕NNõJݨ֥®©õ Ôë¯2ežD„ŽI;U¼Ó …ÓíJ1Ü*¾%UÖ‚ööáAR%kAÒ˜ÊǨ©ZŒ´×è÷Zˆôá|ÃZ„´9ß6vܘ´»ãŠÆ kíÎÚkÒ5Úì‰×±6Wi!þ^óÝ2·-¶þ1'Ê)¬L•qÜÑ·o[õP厵€iBæc´T-`Ú�‹Uk§š²Ü -Ûöõm�‰ü)¬¡%ª§`“Ñîü¸S'ÜÍû´6·h¤šµ©=HK=ÐÁc5RÕÜŒÉ|ŒFªÚ›í¸x ÷CaÕÜ|8ßTÕÞlÍ7>èîÓ䯀v&mU~gM^h¥iò �µ8Óö2Bíõh dÉžÚ|“6¯5ZWäÁ•CU楶ë“2�¨|ŒNªZ—ÍxxU•—ºfOªüá\«¥â5æÚowjqmA�*çæXŸ#­Ä¾YÀ4ºU‹×2ñJìk¬Ä;¶ðcPùqjž -ýV…^IÊS$ÀjÄÇ{ƒK}z#�‘ùåTj)©ôf\  ùÒjIyOÀ¹ZR^{ÎeÝxSÒTM§“)È4ke±±UâyëÒ*~²Sµ*B#ž¹›tk©ñgЭJ‚kת[K�3'Ý“ù QM�kÇžaZ…®jrÜãÙVÍŽ»+Ûn7˜¹¡�îµÎƒrãJM'{¹Ä¾ æoã:Ä©ïÒî´ ^Õ4ô>µù­Ú¼Ô 3hsDnûp -Uj.9)óˆÊ‡(¥RÿÆI—7ãá5U^jt8©ò‡3­š×–iY[óÛ59·è ‘Ò·:cÂEØ¢ò1 -«¬lÆÃ1ô¿ ®J ÿ&]%�m×Ð:`¶††¤cºGz‚€†"dðÏ·)ïÀp³ÍOä5û)€¼b?�בØOä5ûü ¯�ÔOä5Ðú €¼²kUi´úy�h}z�׈֧y�h}~�׈Ö'y�(}v�׈ԧyUBL†Ö òºùèUè -­‚P–yû,(¯ªÐqYI -]‡¡÷`”WUèñÛ¹9¬ñM¹N9Òæ~6EjÜ”š½®<eÀ®iWM®Ýr›tÄ ðºGEPME< «*´ŽTÄ£qJU¡p¤"šã”fYÑ)isÏ–B’=ãæž-¥Øíꕺ?ãV›R“ŠÝðzPýb¡e°"â4Ûà5ÊDÌPG‚c>Ä\wªùöu‡š/4 ŽÔü³à¾ªB³àHÍ?½TšGj¾9îkMÍÚOjþñŒ£ššJØ×HÉï€}=$âZèkiø»ƒ¾ª´ _Zž6}Þ«óOxØ]JßÔ”þ³àêBóáHé?å´ÐÙ7RúÍQN«JßW”þÃWhm)ýæŒËrøoWûO[h¹iþÆð°ç½OÉ“«‹&¥~âÃîQê…Æ]“R€ØBã®I§?è´Ð·kRéÍ�N3Ф”2½¬ÑÏ6SQè­Ù¶×ˆß�{�£¦Ð¥jRæíÑag­'ý`½ïSí'Rì>Õîjªýi b =Ã"ÝþpÀÓBϰH¹·<­h÷B/®I»?žqXSïíGû4ü>¤Ø#ü4…®U‘‚oŒûóÈý2Ùê¶ê”߇;©ý=v�Ú/t‹Ôþ³ÀÇ‹EZÿÑ0¨…¾b‘Òo[)z/tìštþÃÙV ¿6gÛ6XÆHãïA�=ÈCShnéüÖè±#*ã¼j§FoŽûcÖèTh)iôg�¥B{±H¥?4– -íÅ"�Þ4¶¢Ô©Ð¶kRê�g\-ÚÚžqÛZ>Dj}Ú®2 Iñ) Ó+at›Z§Bƒ«H­7FÛÍZ>Le¬iluüÔNUBñîPôµëÓ`ñR¡íX¤è�)K…¾c‘¢oŽ)[Uô•ëãWh-)úö`¼j§¢ßÆ{ŒSž -}¯"Eߌ÷7Y"�-{opg͉лKÉz�EJþI z©Ð†,Òñ›¥B²HÅ7†è­jøBs¯IÃ?œmÕˆks¶‰�ú}LïQú½tm Ó›uÍh§áOÄÞ= -¾w}È^*4"‹5üƒ�g©Ð‰,Vñž¥B‹¯HÇ?œqÕ¸k{Æíõ“i¹Ç�±S¡ýU¬å ,lS•fÆ”bïÒî…Þc‘vÐ`*ô÷Š´û£Ño©Ðt*Òî�Ño¯h÷Z„õñŒ«†X›3NÉ�Ú}rðI5T臩öƸÁQöÄ�ühÖÓ±µ®íq…̰'TèQiü'¦B°Há?#— -m©"}ß#÷owª¬=¹Ç¤…P¡aV¤µZƒä*�Tj¾Ý ƒ+\¡ÀZG›Òm¤EðR)?ôÎGR‚¥Ž©ÃÕ,¾€Ó+äœ@ÍóOY&KQ·bøR8T=Ej0–uÍ»áÊŽ„õ‹’.€IwÓÆ2J a%'�ŽÔL‹CiòBz“JZ\|-£ß¾UÎî_<�L¥\£[ÊÄI£á¯¶©,¤I˜ßÇ¿³ðM.Á«è?½<ÕÐIpÞËt‰Ü ùhºhWŠJÚ�½ ó@R4ÜžcDo9±:³Â0JŒ÷§ÓØx«;Œ�ƒä,6Þœ6æñ‰Ó¾<þ`Ëm¹�|ÏÑ‚À�Ü–C™z¾²’—”ârGÁhË Åí¶èŸV¶èRCa¬Â– 7™e\2*uÓ¼É ›q®.ÙÌ»®cw̨û¿þ¢"þR2‹¼9Xsƒ [‹Zj¹Ž„J-ȬrV·æî× kGËB'w?ÎÿöeâSÙ6´±þëÕ©c%=°½ Ú®)” {úJ»ÙѧÔ×ø^––R[2O%xãÛ¯N‘ H/¶Ü�-k½6oÍ–/ìíCñyj¥\ ÊoÐêÙë@6¬]#Y™æ¸{}Ì‚ÙBÔ‡¬0f‚'òxAëÁp7„†rKmÕ,�"òeqÛx$>K�eV³�µÙVÊ$P¨ï0ÝÄj×Ã[2ûf ð ‚�ƒÃèÖ™Pðø -v °õT(7ßýéh¥FHðVçFÁILÐ2°l³¹1¾N𿑿+‡4#€„õOzF3|¤Q)×t˜œˆ¶ó\D7=%°×M€Òì«è¯ºÑ»‹o0i�Ýdí念þÛãH€‘-Éè*þ\ý&&àÝE‚ÒYÅç¼îÝÇ“{ýçßôêP€³QÿÈ ^T ­¹•‘Á? ï6r.å*‚÷Æâx£gëÄ¢~<¾äu¦��MG1ï®3j”Û8Ù�`¤à£mÌø^j[|Uaz*p”.ž Lµ -e#d7cñKjéìÅ€t|¡.¸fŽ€,3µ«Ÿ¾Ô�º ¨œã@|§ÿ�ð¨~ØåÍm‰ÈZÁ¹‹BM²“1Ç•bøúM ”G윳¾ûNÀë^rxP?)ëGÛW€Òà - r‘¬x5ûnGq<†+5ìtìèâ±V+P'—ýØÏ3\ðr0Æ{ö ‹‹¢øóݸû$¯êfä0o‰.Š×ŒGï¢g—§ô_é/ßăwñÃû["zŒž¿evw-;xË2];»Ù€0nà˜rÎHãTr9|¢g™ê®:…BV9Å?�€ÊÄ_oð×Þ #ö9óë÷#ÊëîëÓƒXGÃOô×o†gô£wñOô·Dô 1üÄ�¬ûö»%Ö}÷íøO—¿Ðå÷�A?| -"}·FèŸ}W²MJíC‘û…t\œÛ& ±Éi AÒ)ùBºë±RW¤ ÙA"µ0ÓȳI3÷}v8þPef/V1dµüæw~ÿýWÿòþ¥¡3¬sJ¹)*r¥Ñû푊šXãò+MÛ9yVIlôN³ƒ~\�òBV値ö²Lñ‘§ŠMÅAC ¬U=JàÍÁFC ÑÛ!ØF(=iÕi�i°Í4ÈdTò¬û⪠PwÛ»» Ô™IÃÅÒá·Ô½=¿ G•e¤Û:¯~/ãa6Ö)ªÌ¥v‹ºª[œÿ9ý^~þeü�ÿ’¬dUŽqOŸµ¥QȶÓ爔™x á¿ÎöŽþÿïk›Ê$D Îf8ÒûE,‘ŸÍs艈²�|?«“¨ªc[ñHHNk|V—«c‰WB¥V²![d_Óy_tÁõDH:Z�ô�»W-úV誅¤@Ž -參 Ù=e Yae¡Áên®¨©7 ø¤�ŸÞfñªªi -»¼×èhƒÚ<Å,ôCÏÁ7Þ¢[¯ÁµÉa)Å¥ÚR’ͽæÏ_ÏKã¹EÖã]éÛ”àQº¼Tgî°€3t�$˪fZ`M;‹à†êD-’òno}´#ªeŒmÁµ(˜0„@è9±xï¬O -©‘XJø1`D—Yќɟ眮‘ZØÈµÑeÃ7çfÄÏ \ûûŸ/¨vŒ5OxT²-,y(PìKb•Þ€#ÚV­v�$VéiN`ë$ÖB±�Ä*�©XË´HbÃ¥B¿Ølƒ -‰ZÑŸL9±u8?Œþª1;úÚìŠtÔB‡¬iÒX‹‚c -ÍÔëPCR8Çiø›O¾5“¯ÐI‹­gc¬Àýïs“{ôCº‚‡—ÉîÎÖ»¬8UÇSg7úU]¿¯6='“1sœÏ*àŒoëÝÌsËÞÊÈAÁöoÓ… œP„¦+B#™ †O¶Êã)8Ì#×….Äxu?Êψ÷Ê…e +™Tëœ1ï§Šys MîÖ€52ÞöϨ÷"ÏŒð‚:ž‘Z®åÙø®pï }/†¾K�H…¥üÝ­»Zð{Ö8�Q/E²_¤˜å­FÏ¿Y3€ >+Æôï`ÏwïUµÏ N(K€(ì�UoÔè­TëIÃ)ÝšWSz_¯œ4HÙ r:DÔÞ¬à–R¼G¼Úµ*ŸJ}W¡/&ᬬ‡Zñü*Uåª3­�¡öìú» -a¥xg­{åšOÑarºéhûe=¼NÃ&¯àxq_ÍÕà*Çv¡á&zJèÁ�“y• o´ò–×ÿ&~·RbSž}3+Ћ_ºwöü,óŒ÷gΟ1ÐŒk8$+ZL#HÉ ÷ 8TtY¹Ó—IÄøŠîy}™„s[û2 2'_¦Òl廾ÌËBÍ=­qYjâuõ³uf¡åæ4S�¼6B?gf„D^ÿÈ -ÎBSÐ�±À¿fõeƒö”U]¦+ùe‚ï” Qè$övÝ—>î=³¦g5nÚJŠD;nTž‡yÖ+ó+©`"l¾”òdÙ)Ô^›óÑXÁ´›Òä¶…ÃÉÞz|Ò mgÏ @§Ì#Ëñ !9WÆwôùß®ERæZèkš’_0R¬ád~cî0ò#ð¢§4÷¨De:,ÌJš 0@YÑÑì›t™Ånš]î$êö³.bæ�¨¾Â°(õØä´7©ýÉOdY*âjˤîÿ18ßÅn›–M!¿¤ôô“®K=!­aõ’ºlñp³£Ih� -•ÓOëiª@acW“.4Ð ®&o€�”kàiúaXÒPñ—5«À»f]46öÂK©/EL´a›¾@þ}NªºÐß²+o–Òè½d­Ñ­·.­x§¯É`+.VÕÜj'(�T„ø+©Ð›�­¨Èħh;–¾@Á¸ñ´$kÛNƒyªÇ`tSøgQ¬øFT‹9"ÆÇ-Þš”MGŸà;» l:<æ^£­4�"ß‚¶ )3Ÿý8NQ›Óœ³�ñsÝy«h[£€{œj4l}¨)´ê ‡š¾Í`:i+—]~n»«¨�¥_l ˆ�}ÊŽÚô²y¥4�ˆ­P2”†I1ÑhÊVYºÐŒt²®ŠÔ·èló›[ÆÒ$ÃsÀ¥9÷ì¥v3„¿.tSå;c‰ôþ)pTk]hèÉx‹œÊ�)™�è­£ �<ѰL”¡–\­CµLZ¡‰'c,[k…}Îy2±Cs¾ÕŽx…žè4xç�è*Dþ5õíºÐ'=‚UÒÁÀ+GQ ir£Ó^ß�Âwnu^fùT+ .t©[$§ãkËj·ù&Wªv¸"ÒZ dœ÷ÍèÝ�b¸2©¿²ù§l('†-d«ö³aMŽÌø®Y$6‹ëŽiÀ¹k>'¾]*¯K½/…çŒ?à½×)ž�ñei€¼´ê¢œãê¼ ö¹æs¡îã‹ÓèFû¼Ô¬SZp^Z,³³‰ß&ÈLñí3àK­49•‡A|ZkŠUÛS©q#ãuhîhå>|6Ó½¡ò`æ`BýòJŽÍIB³Ï%Ï…¾C&‘á’å.Öîli—”¡ �,‰,xíÄv§ES›is{�å[¢¼ÃL‹ûEl�V9ïwÉ_�¤<¿ -Ÿ3ÃèVùÏ­J²\G^cùg‰`¡ÛF–˜1~ª6%æ–Ÿ–ŒâÖÍçÄ̺P|ÙfÔRI2C\JËJXÓ�…eºÐªqÒËÖCjy–º²á…§q@OÜØ£yzoÉàÛ�:�•w�ÆÏ lí<.ôx$aA£a‚�ûýèVÝP“©®“ù2evÊ\[ÆædX±Ð’’%ŽyäÁ*ƒí ¯<åÌ §¯07² 7‡ô¦ü-C‹K Üë -v¿Ü¶f»ÃJÏklÇô:&ÁRw’å6‹Þ꧘_•yUh×I^ƒR†7ðVój…s°Ð®“¼r‡Ö¤NúYjɰÞ5_¤ûÖ“–¼ðû´5ñ®'£¦1<ݸœ -}6µd˜yO÷XNYWð¨p«àOø¸:•¹Ð7SŽb -4÷^h7oáÄÖHÚ‘ýÞ“B×¶pV¶ªo-þÐ-¼Ôï²®1 -¦‡‡‘+ÞŠïu/õ;7™ˆŒ•¨ö¶°Ý„£Ù‹x5fl$£À"ùv¼üç[΄…Î�d,XcXõ–Hlr*”‹VYœK´ÓìW c¡žö §DN^ëc^¡õÖtÌCÆ0aÇó¾˜:�ŒÀ ÅQìÑ›>"‡,e“>«ªÑvÇqxðp¬,-+sJ -pœPÛd ÿ§Ù¾>‡^+®œ(줪àÝswwMYè‚»U3ƪ�n7+®j`òF~¹ G¿qÖͬßñÿ~Û}ºö2w§ãfZ¼~šŠ5BkGÒ™ˆß¾¼2Å럗$ùõ"ÞÞû5‚¦Ê”]5 -Ñ“zúàÄJU駦 M£: ÇztûßîÑË>M}~›ƒge?q¢0¾NdÉ¡àdý2ïcÃÌ1Ë3Çx%È4cíª.øòjàbxŸõù Ëž}#U¼oWªßP‡ºÐ;‹¼Æ¿ÝËâuk3l£…´œØ‘.´­Òœ%mð³#MʹªvWˆºP¢P{y_YN�Pi™é¡g�´x(wйp6¶ö˜Xa=h{,¶³ÎD:+¸çD‡#, hk½¥k<¾Ñ�{sv,çÏvÿ.ÙÄ…¶`Êû‘4§üŽúK J.Šé·IBÈB‰ìpÀÏrµB6CŒœñ>ÿMÉÿ”¾:üØßß¾)ÿÿï¯ÂÎ¥Q\·· mÎ& 0•äÜæ&HZÒ¡2í—ÁГä}1³ñCÙÝró‚ОM’ ‚“7�zß�oܰ °"�à�Ï~-WÄÈ×i-w·~Ÿè¸d7ê}6Øz|˜žž…¨s,¦a³x_ÿK¿¡v/ 9Î -õ�?ü{go¯õfpΉ– ²ÀâŸFÒ�使ógŒ×[<#©¬ªO€T핦(ÆëRbò •5ÆTB ÚÉ®~í‘B¸r)&ˆLQÁê+V¢"üŠ^5+¬Î:³G÷âl²´ÕoÁKuí5KÙ Œ­í¬Ùýž+Tù(‹Y§ƒZ}\¡?µV¬“–Z §Üiy&£A?­¼E¡Çô4Ã,í|8k¥Ùç“' –Ï�N²)6K¿­½ª¬è £€†„…çÐyNmíŰ"C£8J%Ÿ -1p„lY.´AÖ‚Àk<àí®ê†/bJCêg�ÜB-uçðÔ²¹,V%CÚ sü •ÝOà«yL¶O�´QÖäçÓÿj¯QÛü5¿O†ë÷ÐŬ(Öf£ŽKs†ó¦ÕÓ_¡½ñ´ä5�ö²] �]‡¬‰Q*ˆ^‹ÿYè9¬»x½·»ßðê<ý‡î5ò -›¿`P’i.€Ô~ž Ê+=±¾Þ—t¬‰³}惻_z¡wrÈA×Ü…‘tŠqdMÀ¬=)ÎM®ųj‚f—æ„e �¹ü³îNTbóÓåø-¹ ¤…‹¼çÔÖ˼%/AH½³båÜž'EO3©›4ÿ¦Wabe᡹¿n ¬ˆ[dÓü¿ÚÒß*kÀêþ`*"pÊwÑù&"ø§éUjÚʶÈí",=Yßܱrý×ü¿oG Y{É7%2Nëýoy[zV%¶°² à 2#w*®ñ@‘3’‚|Ô¹‡àÇ-­÷§ý:�þU¨RýûhÜÞay™ ¦ÔÔa=Nhãñ[þü(± +µ9È»œh1ÚBÛ0s¹‡F¶ÚOÁoüÜW¥¸‹µFe› þ—[¤N kãŒQ§Ô·K}Ç$ŠÙÚ\è¿Ú„™lÁ\ô¦Ô)ó-2§¹sR;.Gc®¶Öð—á4÷ù”ºóZì%¬ ȯ1 ŒÖxÎÆí³qî4Œõ«µ¼ƒ½!̱s}µuœßsŠ}«Ø É„¨çjs±+Ú„àÎè}¨xk<å¾Uîs×´³ ý=¬Ì®gyû)¶>!’€m£�Ý—Õ&Dp—|¡ÅͶxÕ6¯q8y34¨€œ›, i@Ym;@Ù®=9¡�¤  ßšîñÚ˜Fñâ˜î†¹<=6Ìôéw[.S;~ §30�c�ß©^LI+äy«f1!í{¼MìihÉ¢^¤ð/*äί,’$wέ=Â:<©Ø¾=×ÍžuS8Çz î‡¼n + ïµäüõ‡/šBosÃüðü¶íÙVÛŽ mƧíXhæP;X®:JÊõR¼JJœxqûs÷íÍBq•.Ã’Ÿ:ævSêöf¯ÁP†³v?C•­9¦ì1JFWvæö|Ã�ó¹hv-SÙ˜»hìÒ¾üøã*Ûrk¦}Üäuì;Pt‡åò#uŒš�¾cjc‘WR$ M¸ƒæ gŸòK?“sfC½¾–7™<%-#É1=×Y�q®ìÇk…x…¶Ü�¡Ž†§fyá•äß}†¥ÓÜ’�ú¬¦sͯ^ó…Þç“Ei™»n{•Àu'¸Ù—kqJ}£ÔU%Ó¢±Ô¿Ø—hqŠ|£Èi9Í¢±Ä]ÙÜ+k»†œöÞ{{Ås’‚-§ûüRýÑúò† +ž”§PE¸o µœtxÆo]Yµ€‰qÜâ˜!Ú¬­ÿTY[vymF{ê…Ýdq•@æ3×c€Í+ád0P«aË)é”ÎS¼r×R1Œ0¾?žŸKeýRq•¥¢=¯¹³x+sSÚ}ææ)ö�b÷s³½Ø·%ÖM&ç)ömb·bÙäl/uU)¶´ˆö@Äú¨ÍΘ×Rçøyz£:tãõïà +Ç9_´åΔ¦;?œ ä†Rs¾�çˆÚiEÚ·žBß(ôšï¥­Ð±o<%¾Qâ×K[�¿ªl�Ï‹ܸØY{”ìyPW´ìxÑ~a{+Á’äxa³¼Õú†9GÍ ßsçÏÎ4r )×§e�KmýR«ùbH€±Jê†Ix;ã§Ü·ÊÝÖ6ÕÆr_n„#­[Ö²$A f Ÿ6ZöÃ,¼üv¥ŠË·ÞîSfÊ�·JR÷žç¤¾aRûŠ2SÈH—6ß8R™½Ý§ÊN©o”ºUÖ\ê{ØO‡„Sî[å.—O ­Åþ›]uð§È·Š—Ëà[‹ü/w›Ÿ"ß*rµ\kÞ\¹¿ÞUi~Ê|«Ìi¹Ð¼µÌÿjùlRhvÎ&»ÉºŠ8yäh¨>Þtéïå=ö)î©íÚÅO�žY®£°ý_l\Gîuua”ÔQ„»SExìTG~·å4.ô™A¢çm»yr‡uÖ­†?ë + g”«�°¢×ëéΉwðóI.×±�·É¥é$«Z¸g…* d’i¬|z:%‚Ö›g'Ô8ÞïŽg("X/X_‰éz�®s‰0?›C~N¤îž£w¤uÿ<½±ûçê2­GÍW©à ´²gÅÙ­&E!PãÉ‹uš´Qü±B›êr»þÁž´:¥¾Uê¿6`ÏÔÆbÿÉò�ÈÏ=¯èÔ :�eÛõ�.„˜£T®+=5^oÉ€N¿#mTvP,YH P]LE[×ÂË +Ÿ­)œhgšËrÏö©«ÌFÓzÜ +¬L—S'¬Ö +;�qàüöB ë1¹s#8e¾I檶´º«lTQOÆ3B³F,TwÖÑ*š®„ùIün±Û".OËs¡ªJ_W¸ª=xëš#�ŽœÃù†–5™ß¹h×5‚;Â� +ÁT6ÍÍ븙l…pÙ¹œ"ß&r[ÛËüŸ?lºB0�åúF¡ŽýŠ@ëu{¡³‰¿¼ùûÚ6%ArGÏÆG“a_}=?.ž¶ÖîúYÖŸ,fÿ À‰að6¶K„ܹ?’a¬l·p~Ì€f(De›$ Zë†�-éY)%¬p°GîùÜ)óˆ²G@š¡(1QƒòŠRêž&›•+Œ3çŠÙ¹b +'M¥A +ã샗Lá°I‚�OÐ?Á’)Úˆ{Üy|0ÛLe›& ^¸æ½™—÷Ù·qôßÝŠë²ÊÑšž×ƒ«¸rGa+$‚}›•ÓкU‡HYÑ! ™ß4Œ³ µŒkG“ˆ²‡ØYRÕŽ&­ù¶ ):œœKfÏ’¡ÚÙä¡kF×Î&_3¦r6iÍ6�Âjv¶`m'p¡=z<$ØfÅ +äƒ ±hþ‘�9BfúTm·Ì<ãy=º¾AÑñÜûåË+‰)6h ZéC✠9:u3/ +/æ½Õº?ÊÞöûzŸíb<·Üpª�—Ã=Y£k…a:”„[¬…à VÂáfP˜á‰A›†l©�ý²Ñb¸5 ±Ûæ¯×5àˆñžáÂWV ,t¥À(rÉíTóO—5 ¬@eÁ8e±%G÷Ù3¼yxŽ;�ËhÓ2‚‰M Ånë']G»Û -=Ã:*˜†VyoÍÖQ†f“’VIçaÊ´ôíÊ«Rüíñä “4¸Yß©G„“Ñ÷‚¦b ÎiwnÓNÛ°s/i%öe:¨Á¢4ÞóßMøKøÖt�uÌ4Š•ÌtwÒ2᱓š ¿ÛRÏT²„Œµà5»qâèWËÒè¶qÈ‚ª;Ì�s�*báìE +1®}ûÉ ‡é ²D”ÖÚQÇ2n|ÃÖƒ÷òÊ€÷Þ?ä>¾�#2³†Eó€×Ümý¡ +æ·Ú¿»ßA^c}%¨`Ø V…Cæ@~Û¶É(!À8î�b,�ñiÈF‡r9DK¬E.¢Sœà°•Ò\7× ^u£wÞ`6Ò »ÛßMGý·Ç‘#5Z’ÑUü¹þúMLÀ»‹!¤³ŠíàîÝÇ“{ýçßôêP€³QÿÈÛkû” PBÞÊHþöÈÁnï'8pÇÎJF2AN8mÌ©�oÒ�œìk(‡«ûQXýà •Qæé|@ðÞXoôbn?ž^êÚt›Ž&bÞ]ñ8ãÆÑ8QŒ¼aÄS¦Ÿo[¸—=;�z'[-hKÙÁj #~M-�½�Ž/ÔEƒÓÝ,×o†/õ£nñ(çØëïô?Õû¯¼¹M#qÃÙêpî"�P÷o©Ç7è¯ßByôî¢Áúî;ý ®{ÉáAýp¤¬m_½Èá°Î=r².ò¥æàWwWjX¿ìhDY+„eAÇ—ý:Kª¿à%aŒ÷èÙˆR@¾wŸäÕ@ݬæ.Q·èµG.¡Ï PÎô_é/ßăwñÃû["zŒž¿i†óùD‘íx&“¼:Ë8ãž)çŒ4N%—Ã'z¦©îªS+d•SL2àpü•ñíÍ0Bð�nìGŠÁ¨»¯ORÀÙØýOô×o†gô£wñOô·Dô 1üÄ‘Ìûö»%íðÝ·ä?]þýB—?ýðip(ÈôÝ©ö]É +S¤CÁ&¶ê´l3lWOŸÒìe=­«�Ö•TÜü´Q޵Q¦éyÚ(Ïo£HÉîˆaË8m”u)n™± R+?¥k~.RÂJ-]3>¥ÒÓ¬lö�ºÒ�*E«ÚhmôsôâB-j ÝxáOÝÜ�km„ëvèÌ5�²5L•5¦Z F¥á‰kj*4Û¬ÓšŒ±à�г®5µ˜óûí–6A�¯Ùx4ÖX×õ8µÔ®óaŠà6Ÿh…p3”§ô·Ì–¢jUÚÜölú“¬kÜV5nkÖ¨æ¾ÑëëÝõúÍmW‘'!Ô„h±»òIDÉ~w#a„ë2­ˆÂ_·¦{¼»M£xw›î†­hzlب¦ßm¸»iªìndÁuY…mv·Ÿ$«jÄr µZµ©^8=(Ê;Ä„ì‡øÏu 0�:/uk¦Þj2ØšÒ ¨Ú� ~¼6ƒ«q•Û㎕ÇMªöUm/äødv— §þ�2ó"CÖDc´nÏ­°ÆU_ã*zNo—¶ W?_HöÈ,€kéCË>…ýûUfÙ´B�4ãçÔf‚©ž+PtIßÍ̸¢Ó¤®D¬}Áüš=,¨˜ýB©ë¿—©ž&8aE·K1ÌZ±½^fð¯2¶ììÓ£…ç­>­ìÌkXkœ™Jš¬ŒdÁ(ŠÏ”Ø`T%±!!ù!–™¡JfCCŽö }½/�à\DÛ‘®ä<é*2´¬'XE¶‚–Õ|½­V5»úí 4õÍÕMçˆÜS6p¹i,K'œ¬=^úˆÚyiM`ÅÔ hò]¥CãCIñ5Í‚¼Ïèà´OÕ¿Pm©À 4²O FÍmµ¤ëþ®Ã_&ì¯p¯Ãþ +£û+Ü�±¿†ÇNJ3ünC­i+­�È)p]A@#¥ù—ÉÙ´6£m©’g¥r)�Ñ”¶`À)� ìÜ��¥¦{)a5_19âªìVØÉóîiST8;]'îð/ Ç• ™pR”ócv~æ‹¡w*‡ 9èT5›TMÅM Z �ܨ]S51��Q5¦¦jÚ±±œ�’Vó13i^S«f�£/sðý.¹n6ÖY®ðU§ÑÕšî«Í½šaKFƒqÔ·¬kØ+;õ#F¦nv”¹¹:Kn’ö!}¦šHÒ4'°uQ¤õËE‘DŒ2©Ä«Š,& ŒR,€Næ�ÖTZ:¹m†Ï®çVÛ–ùKV“gtŸ>Éi¯y mÿLÓ—†{CúÒ0²€^8íûì¥á&Ç$5¡ŸêÇ�M?nõ{kxL¼·7ÅôDž@ã÷–&‘+XñV‚è˜ZšD·¨ 6Эo³;ë•’ZrŒ[ Å «é„§v9å#M…'v^=.æóR•’owªJ@vàöJFB°’¼î�|ÓèÀZÆ‘XDz¨%zb{©¥°Ÿ±Êi@á†Î‹ÏN¬1`ݧA*9P†!Á>Zу'៚X­Ày#ÌQŠ‹¤�ˆí-h=Fo݇ÖcÔÖ]h=Hk݇Ö#”Ö}(=Dg݇ÔcTVKZÑ�(kd;d¯ÈqÇî8¹ôlÁ¥g—ž-ºôìÜ¥gç.=}—ž«$.�Bp†œmšVú‹1øZ;r”š�úÑ£“ù�¾‹®”¬@£G¯;º* ®àÕzÜ�””¶×GMœQ!�³ÔÞo9vš6)šÜ};]ÿJ‚4Ô®#«2±�¦,8é5vM\øË”•îuia”äe„»aMO� +~úÝ–j¢‚ÛB¨ÀhÕ¢ú­jÂÖÔDLæcÔ„«©‰v\ `iÒJp-bH·z<ç| YDƒUÈTí9·ZdTµ„!—uÖR�+YYÑwzžFÜdJMƒ¥ìË0è {íJ,DÆwäÂþÎÀ"Û£p÷ÿm¬é\r_”}Œ7+tdÜ�¾óí©ÐoUè¾f÷I"Ün¦Ð}Õî‹É|ŒZªÚ}í¸¸B¡{]Sè�眩)ôÖœû°S�÷JØl‹‚†2û¬xþ6mnkڼĿµùB%)!jʼ¯+s%dM™?žsXSæ÷æÜíê\"Â4þ¾Ö¹ª¦ÏK,oÎ7¤�ê\p_)©Í}E›—x¬q¾Ô.zgi°òJú†è™?j….+u:Ê™®²y¸F—²¦Ñc2¢š$ÖTz;.®ÐéRÕtúã9G5¥Þœsb§ �•ŽÊçVµ®$prê¨WÂèFµ.uM­—Xx ^•)ó "tLÚ©â�)œnWŠùãVñ•(©²´·’*Y ’ÆT>FMÕb¤íx¸F¿×B¤çÖ"¤Íù¶±ãƤÝW4fXkwÖîX �–8x¨Ñ>`O¼Žµ¹J ñ÷šï–¹m±¸ð�9QNa%`ªŒã޾}Ûª‡*w¬L2£¥jÓ†\ ¨Z;Õ”åVض¯o{LäOaÕ-±ðP=5›ŒvçÇ�:ÉànÞ§µ¹E#Õ¬MíAZê�«‘ªæfLæc4RÕÞlÇÅk¸ +«ææÃù¦ªöfk¾ñAwŸ&7´3i«ò;kòB+õH“—Xx¬Å™¶—j¯ï@[ KöÔæ›´y­Ñº"~¨z¨2/µ]Ÿ”yDåctRÕºlÆÃ«ª¼Ô5{RåçZ-¯1×~»S‹k jT97Çú i%öͦѭZ¼–‰Wb_c%Þ±õ €ƒÊ�SóTè·*ôJRž"V#>Þ\êÓiôˆÌ‡(§RKÙH¥7ãbͯ�VKÊ{ÎÕ’òÚs.ëÆ›’¦j:�$HA¦Y+‹�­§È[—VñÅNÕª<�xæRlÒ­¥ÆŸA·* z¬]¨n-uΜtkLæc4D5=®û†iºªÉq�g[5;î®l»Ý`æ†6º×:Ê�+5iœìåû4˜¿�ë§¾K»Ó&xUÓÐkøÔæ·jóR3̠͹ ìÃ!(T©¹ä¤Ì#*¢”Jý']ÞŒ‡×Ty©Ñá¤ÊδjJ\[¦emÍo×äÜ¢ƒDJßêŒ aó„Á�мÔÙoRäî[±2–Ž-ÀCÿ£ž»qæÄqj^€'ì™@q«–¯…+™ÅÒ=>ZYj²8iùˆÊÇ(¬j°²ÇÐÿ2p¸*5ü›t•T@¶]Cë€Ù’Žéé ~Š�Á?ߦ¼ÃÍ6? �×@ì§òˆý@^Gb? �×@ìóƒ¼R?�×@ë'òÊ®U¥ÑêOä5¢õéA^#ZŸäu¢õùA^#ZŸä5¢ôÙA^#RŸäU 1Z'Èëæ£W¡+´BYæí³ ¼ªBÇe%-(t†ÞƒQ^U¡Çoçæ°Æ7åb8åTH›ûÙ©qSjôºòü•»¦]5¹BtËalÒ'ÀëA5ñ,¯ªÐ"8R�Æ)U…vÀ‘ŠhŽSšeE§¤Í=[ +Hô Œ›{¶”b·«WêþŒ[mJM*vÀëAõ‹…–ÁŠˆÓ|l{€×(1C ŽùsÝ©æOØ×j¾Ð,8RóÏ‚ûª +Í‚#5ÿhôRUh©ù港55_h<©ùÇ3Žjjþ)a_#%¿öõ�ˆk¡¯m¤áïúªÒ6|i {Úôy¯Î?áaw)}SSúÏ‚« +͇#¥ÿp”ÓBgßHé7G9­*}_Qúg\¡µi¤ô›3.Ëá¿]í?%On¬.š”ú‰»G©wMJýib �»&�þp ÓBß®I¥7:Í@“RÊô²F<ÛLE¡·fÛ^#~:ìAŽšB—ªI™·G‡�µnHœôƒõ¾OµŸH±ûT»«©ö§�Š-ô ‹tûÃO =Ã"åÞð´¢Ý ½¸&íþxÆaM½·gíÓðû�b�ðÓºVE +¾1Nì/"÷Ëd«ÛªS~zì¤öOôØ=j¿ÐM,RûÏ[h,iýGàúŠEJ¿9|l¥è½Ð±kÒùg[-üÚœmÛ`#�¿=ö M¡¹U¤ó[£ÇލŒój¨�½9fì�Y£S¡¥X¤ÑŸ4– +íÅ"•þhÐX*´‹tzsÐØŠR§BÛ®I©?žqµhk{Æmkù©õ=h»Ê€$ŧ€N¯„Ñmj� + ®"µÞm7kù0•±¦±ÕñS;Uý Å»CÑ×"¬OƒÅK…¶c‘¢4¦,úŽEо9¦lUÑW"¬�g\¡µT¤èÛƒñª�Š~ï1Ny*ô½Š}c0Þ¿ÌilÙ{ƒ;ÓhN„Þ]J¾Ð{,RòOÑK…6d‘Ž0Ø,º�E*¾1DoUÚ{Mþál«F\›³MìÔï{`z�ÒïÕ kk˜Þ¬kF; "öîQðÕ¸ë³@öR¡Y¬á >6Mļ»Î¨Qnãhd7‚‘‚�¶1ã{©mñU…é©ÀQºx60Õ‚¶”��ÝŒaÄ/©¥³Òñ…ºhàš9²ÌÔ®~nøR?ê& rŽñý�þ£úaÿ•7·I`$nx kç.5ÉNÆWˆáë7�P±sÎúî;ý ®{ÉáAýp¤¬m_H+€ÈE²âÕì»Åñ\®Ô°ÓI°£‹ÇZ!¬@�\ö`?ÏpÁËÁïÙ',. +ˆâÏwã¨›‘ü%º(^3½‹žA\žÒ¥¿|ÞÅïo‰è1bxþ–Ùݵìà-Ëpüuíìf¸�cÊ9#�SÉåð‰žeª»ê +Yåÿ<*e¼Á_{3ŒØç̯ß�(¯»¯OR` ?Ñ_¿žÑ�ÞÅ?ÑßуÄð²îÛï–X÷Ý·ä?]þýB—?ýði0(ˆôÝ¡ö]É6)µEîÒqqn›48Ä&§�I§ä é®ÇJ]‘"0d‰ÔÂL Ï&ÍÜ÷ÙáøCñ¼˜U„ðAù”™½XÅ�Õò›ßÿùý÷_ýËû—b„ΰÎ) 禨ȕFï·G*jN`�˯4mçäAX%±Ñ;ÍúAp5Ê ]X•’ÚË2ÅGž*6E %°Võ(�7 �Fo‡`c¡ô¤U§u¦Á6Ó` “Qɳ‚@Ýqlïvì. Pg& K‡ßR÷Zôü.qT”‘në<¼vø½Œ‡ÙX#¤¨2—ÚM,êªnqþçô{ýùùWñCþK²’U9Æ=}FÔ–F!ÛN;Pœ#Rfâ�„ÿ:Û;úÿ¿¯l*“58›á`HïOb‰|Q 4Ï! s$"Êf@òý¬N¢ªŽmÅ#!8­ñY]¬rŒy$^ •ZɆ l‘}Mç}MÐ×I éhAÒî^µè[¡«’m8*¼—®JT0d÷”5d…•…[¨»¹¢¤Þ$à“6~z›Å«ª¦)ìò^£  jóK°ÐO =ßx‹n½×&‡¥—jKH4÷š?Q)¤Fb)áÇ€]fEs&žsºFja#×D— ßœ›y?/píï¾ Ú1Ö<áQɶ°ä¡@±/‰UzŽh[µÚ=’X¥§9�­“X =ÄB«t¤b-Ó"‰u — +ýb³ *$jE2åÄÖáü0ú«Æìèk³+ÒQ ²¦Ic, +Ž)4S¯C Iál¤áoj<ùÖL¾B'-¶ž�±÷¿ÏMîÑé +^&»;[ï²âTO�Ýè×uý¾ÚDôœLÆÌq<«€3n¼­w3Ï-{+#Û¿M‚pBš®Œd‚>Ù*;Œ§à0�\ºãÕý(?#Þ+–5¬dR­sƼŸ*æÍ%4]d¸[ÖÈxÛ?£Þ‹<3 êxFFh¹–ggà»Â½3ô½ú.5"”òw·îjÁïYà/8¡,¢°w`T½Q£·R­' §tk^MMè}½rÒ e'ÈéQ{³‚[JYðVñjת|*õ]…¾˜|„³N°jÅó«T•«Î´v†Ú³ëï*„•âEœµî•k>E‡É馣í—õðF8 ›¼‚ãÅ}5Wƒ«Û…†›è (¡`LæU2¼ÑÊ[^ÿ›øÝJ‰Myöͬ@/~éÞÙóóÌ0ÞŸ9Æ@3®á�¬h1� %'Ü7àPÑe!äN_&ã+ºçõeÎ líË,4Èœ|™J³•ïZø2/ 5÷´Æe9¨‰×ÕÏÖ˜…–›ÓLAòÚýœ™=xaü#+8 MACfÄÿšÕ— ÚSVu™®äG” ¾S‚D¡OhH�ØOØu_ú¸÷ÌšžÕ¸i+)í¸yPyäY¯Ìs¬¤‚‰hp °ùRÊ“e§P{mÌGG`ÓòÐåThh‰ÜL°ÛÐî°œfÙé! +WSO¥^—A +Á®žö j@wx%ñ«…µ.ÖN'õ×_íÕ5‰ð¥fš$@ ‰wQ‚?�7Û/xaª¥©¥¦–Æpx„¼,*ÕûR"8‹le¶š_ùlJ“Û'{ëñIƒ¶�='�2�,Ç/4„ä\ßÑWä»I™kh¡¯iJ~ÁH±†“ù�¹ÃüÉ�À‹žÒÜo ”é°0+i‚Â8eED³oÒdZ»iv¹“¨ÛϺˆ™C¢ú +âÔc“ÓÞ¤öK$?‘e©ˆ«Q,“ºKüÇà|»mZ6…ü’Ò ÐwLº.õ„´ +„ÕKê²ÄÃÍŽ&¡A*TN?­§I¨…�]MºÐ@3¸š¼BR®�§éóLù�+#À9vvØtx̽F[%$h:D¾mRf>ûqœ¢6§9g;ãçºóVѶF÷8Õh*ØúPShÕ5}›ÁtÒV +4.»üÜ2vWQ;K¿Øû”µ)èeóJi[¡8d( ’b¢Ñ”­8²t¡éd]©oÐÙæ7·Œ¥I†ç€JsîÙKíf]è¦Ê9vÆéýSà¨Ö:ºÐГñ9•S2Ñ[Gy¢a™(C-¹8Z‡j™´BOÆX¶Ö +ûœ+4òdg†Ñ­òŸ[•d ¸Ž¼ÆòÏÁB·�,1cüTmJÌ-?-%Å­šÏ‰™?t¡>,ø²Í¨¥’(d†¸”–•°¦ Ët¡U㤗­‡<Ôò,ueà 'N〞¸±GóôÞ’Á¶! 6t+ï�ŸØÚy\èñH‚FÃ!÷ûÑ­º¡&S]'ó#dÊ씹¶ŒÍÿȰb¡%%K;òȃUÛ5^yÊ™5@O_and:néMùZ†—¸×ì~¹?lÍv‡•ž×ØŽéuL‚¥.4î$Ëm½ÕO1¿*óªÐ®“¼¥ oà­æÕ +ç`¡]'y ä!¬I=œ.ô³Ô’a)¼k¾H÷­'- xá÷ikâ]O8FMcxþ0ºq9úljÉ0óžî±œ²®àQáVÁŸðqu*s¡o¦6Åhî½ÐnÞ‰­‘´#û½'…®má¬lUßZü¡[x©ße]cL?#W¼ßë^êwn2+Qí'l `» G³ÿ;ðjÌ,ØHF�EòíxùO·œ �!ÉX°Æ°ê-‘ØäT(­²8—h§Ù¯ÆB=íAO‰œ¼ÖǼBë­é˜‡ +ŒaÂîvÌû¸<ª²$];8 Dâ—¥lîgÅ#èî81Çø ù1d)|<|?«¬!-+“N +pœqÛd‘ÿ§ÙÆ?Çf+.­(.¥ªèÞsxM›è‚?V3«�n7+®ªhKþ2ò)ŽŽå~Zubý=ÿï·Ý§k/Sð‡:î¶Å ¬©XC¤´vf�‰øíË+SìÀþyI’_/ò½_#hªLyÑ•«=‰ §N¬T•†kºÐUª3�¬G·ÿí}0ýÓÜè·9ºVÖr0q$' +ãëäÄ–(ç‚ö˼Ñý 3Ç,Ïã” ÓŒµ«ÚàË«�‹á}Ö'@,sxö�Tñ¾]©~W`!êBs-ò w/‹×­Í°ÁòvjhHºÐ×JsµÁ;ÌŽ4kçªÚ]!êB Cíå}ei8B¥u¨‡Òê¢ÜkzäÂÙØûcb…õ  ²l)ÛÎ|w|RéÌäžа4 ­õ–z0òøF‡þÍ鳜`Ûý»d4ú†)ïGÒœò; +4-(¹(¦ß&# 5´ƒ Kæ +é1´ÆûüÿI¸%ë Túêðc¿»}Sþÿï¯ÂÎåY 4TÖI¡Ú$F¨’œüÜD‰BKZX¦ ƒ"š–¼/¦>~(ûcn^Ú³I²aApvÃUèüñ�VÄ¡òá°åŠù:­…ÀâîÖ—ìF½Sç�[�ÓÓ³vÖ4lïKè€é7ÔÎè¦!Çi£¾s˜/âôîµîNJÑ’QXüÓH:�¼÷w�ñz‹Ëc$•õ¯Bõ �ª�é‡> +ONªá 0î?r4¥ž Fù4¸�V²lÊIwÄdå·`¹¼/bèDäþiÚžÈ&èˆÜ=5ç4^Ÿ”én¥–]°†h.‘‰£6�»[ÛØÑÅrn ÛܤøS²ç²4."f•ê«áÜŸŸŽÂi Çf\u‚ºVY`åCõ\VÊS]á©’`4¶Êü¼ÀÂ÷ÅchÏ ñ�Ú;™ÊôfœG’²ÙôŽcϯ§®ÆåVïê_í}lEF(@zÓë冇â|®Íñú6Ô¬#]›,�l×t@UE:»Þ­ç£Î~¸��OÐôn#ágÏ»u«J�Q™ž9;Þ=UÇ;�]‡o»%€Š×ÚÙñî:ϼ°žÕ†¯’ºˆ³ãÝfî�ï–:ÞéB»sÍ–¶ºƒ5w(ÜŸ&d¥¾uË=m®9'-§næäi¼¬ž §ùòôæ iPFõkà´^Ö²Ì]4^ꇵÓvYäÝiº,›.¾âYŽ×å}Ö§ÒÅx]JL¾!£²Æ˜JD;Ù¸=RÈW.Å‘)*X}ÅJT„_Ñ«f•×Yëöè^œM–öÎ"x©î¯½f)”Á·�5»ßs…*e1k…P+ +4°ÖJ€uÒRká”[1Ïd4ˆà§•·(4¡žf˜e£�g­4û|òdÁòJ6Åfé·µW•}aÐ�°ðú"Ï©­½VdhG©äSA +Ž˜.kÃ…>ÉZx�¼ÝUÝð“˜Ò�úY#·PlÝ9<µl.‹UÉ…>ÄÿBe÷¸Æj“íS'm”5ùùô¿ÚkÔ6Íï“ÿ=t1+ŠµÙ¨ãÒœá¼ëCõôWè<-yM ½lWB`×A¯„Cb” +¢×„škÁ.^ïíî7¼:Oÿ¾û_�¼Âæ/”dš µŸ'ƒrÁJOl�¯÷%kâìCŸùàî—ƒ^h®rÐ5·i$�‚EY0ë_Šs“ëCñ¬šÀÝ¥9aÊGg.ÿ¼»•Øüýt9~K.#-ÏÕ‘�î_2¸vÎ †¸‹àe­kuJݫôPÄÐBàA³bÜb›öõô‡6"®œ8§’ò¬^eÐIúj˜§C¡EE+–ºh1pRâ/ÑU1¨2Üx#æ®=2Þ¼�¤ëR6Ýs!©Š%‡ðÔ#Ò?¬5"]¬[¯,¿á÷.µit™~}÷„ª- ª°_ �ð„lÂÿù¯Ao�ÙŒ¡f�Oñ$ï9µõ2oÉKRïÁ¬X9·çIÑÓLê&Í?†éU˜XYxh®Ç¯(+âÙ4ÿï�¶ô·Ê°º?˜Š‚ò]t¾‰þqz•…¶2�-r? KOÖXw¬\ÿ ÿïÛQCÖ^²€VÅ]‹ŒÓzÿ[Þ–žU‰-¬l8ƒÌÈ�Šk<Ð…N匤`uî!øqKëýi¿‰¤ªTí�Û[0/³Á”ºž‡éoúß;ô>_*ÙØÿ¡Fw²Sjð‚„ÛOøl¦Ð±›¤O†‘Ø +6Á_‹�±²ö}‹Ë'¬Ç Ž<~Ëÿê1; endstream endobj 412 0 obj @@ -1522,12 +1523,12 @@ x endstream endobj 413 0 obj -<> +<> endobj 414 0 obj <> stream -Typst 0.15.1en2026-10-01T12:29:22-03:002026-10-01T12:29:22-03:001application/pdfpwP6dy/TnRzkslYNFVRKLA==pwP6dy/TnRzkslYNFVRKLA==proof1.7 +Typst 0.15.1en2026-10-01T12:39:50-03:002026-10-01T12:39:50-03:001application/pdffOK5WLGONesfRJIiwiITiQ==fOK5WLGONesfRJIiwiITiQ==proof1.7 endstream endobj 415 0 obj @@ -1551,408 +1552,408 @@ xref 0000001102 00000 n 0000001188 00000 n 0000001274 00000 n -0000001363 00000 n -0000001431 00000 n -0000001598 00000 n -0000006324 00000 n -0000006429 00000 n -0000006510 00000 n -0000006653 00000 n -0000006810 00000 n -0000006878 00000 n -0000006959 00000 n -0000007030 00000 n -0000007132 00000 n -0000007200 00000 n -0000007343 00000 n -0000007414 00000 n -0000007585 00000 n -0000007653 00000 n -0000007747 00000 n -0000007844 00000 n -0000007912 00000 n -0000008068 00000 n -0000008233 00000 n -0000008301 00000 n -0000008394 00000 n -0000008505 00000 n -0000008661 00000 n -0000008817 00000 n -0000008885 00000 n -0000008979 00000 n -0000009073 00000 n -0000009141 00000 n -0000009300 00000 n -0000009459 00000 n -0000009527 00000 n -0000009621 00000 n -0000009727 00000 n -0000009795 00000 n -0000009951 00000 n -0000010113 00000 n -0000010181 00000 n -0000010274 00000 n -0000010357 00000 n -0000010434 00000 n -0000010574 00000 n -0000010643 00000 n -0000010713 00000 n -0000010800 00000 n -0000010868 00000 n -0000010937 00000 n -0000011035 00000 n -0000011103 00000 n -0000011207 00000 n -0000011294 00000 n -0000011371 00000 n -0000011527 00000 n -0000011683 00000 n -0000011751 00000 n -0000011845 00000 n -0000011939 00000 n -0000012007 00000 n -0000012163 00000 n -0000012233 00000 n -0000012402 00000 n -0000012470 00000 n -0000012564 00000 n -0000012634 00000 n -0000012704 00000 n -0000012821 00000 n -0000012889 00000 n -0000013045 00000 n -0000013116 00000 n -0000013187 00000 n -0000013262 00000 n -0000013447 00000 n -0000013515 00000 n -0000013610 00000 n -0000013709 00000 n -0000013777 00000 n -0000013934 00000 n -0000014005 00000 n -0000014177 00000 n -0000014245 00000 n -0000014352 00000 n -0000014424 00000 n -0000014496 00000 n -0000014569 00000 n -0000014642 00000 n -0000014715 00000 n -0000014851 00000 n -0000014943 00000 n -0000015018 00000 n -0000015091 00000 n -0000015164 00000 n -0000015278 00000 n -0000015465 00000 n -0000015624 00000 n -0000015696 00000 n -0000015813 00000 n -0000015910 00000 n -0000015982 00000 n -0000016165 00000 n -0000016328 00000 n -0000016400 00000 n -0000016505 00000 n -0000016602 00000 n -0000016674 00000 n -0000016833 00000 n -0000016992 00000 n -0000017064 00000 n -0000017169 00000 n -0000017266 00000 n -0000017338 00000 n -0000017505 00000 n -0000017664 00000 n -0000017736 00000 n -0000017837 00000 n -0000017934 00000 n -0000018006 00000 n -0000018185 00000 n -0000018352 00000 n -0000018424 00000 n -0000018525 00000 n -0000018626 00000 n -0000018698 00000 n -0000018861 00000 n -0000019024 00000 n -0000019096 00000 n -0000019201 00000 n -0000019298 00000 n -0000019370 00000 n -0000019549 00000 n -0000019712 00000 n -0000019784 00000 n -0000019881 00000 n -0000019982 00000 n -0000020054 00000 n -0000020233 00000 n -0000020396 00000 n -0000020468 00000 n -0000020585 00000 n -0000020682 00000 n -0000020754 00000 n -0000020917 00000 n -0000021088 00000 n -0000021160 00000 n -0000021257 00000 n -0000021354 00000 n -0000021426 00000 n -0000021629 00000 n -0000021699 00000 n -0000021785 00000 n -0000021972 00000 n -0000022045 00000 n -0000022224 00000 n -0000022296 00000 n -0000022393 00000 n -0000022502 00000 n -0000022574 00000 n -0000022741 00000 n -0000022916 00000 n -0000022988 00000 n -0000023105 00000 n -0000023206 00000 n -0000023278 00000 n -0000023445 00000 n -0000023604 00000 n -0000023676 00000 n -0000023781 00000 n -0000023882 00000 n -0000023954 00000 n -0000024061 00000 n -0000024171 00000 n -0000024338 00000 n -0000024497 00000 n -0000024569 00000 n -0000024682 00000 n -0000024779 00000 n -0000024851 00000 n -0000025026 00000 n -0000025185 00000 n -0000025257 00000 n -0000025370 00000 n -0000025467 00000 n -0000025539 00000 n -0000025714 00000 n -0000025873 00000 n -0000025945 00000 n -0000026058 00000 n -0000026155 00000 n -0000026227 00000 n -0000026402 00000 n -0000026561 00000 n -0000026633 00000 n -0000026738 00000 n -0000026835 00000 n -0000026907 00000 n -0000027082 00000 n -0000027241 00000 n -0000027313 00000 n -0000027426 00000 n -0000027523 00000 n -0000027595 00000 n -0000027770 00000 n -0000027929 00000 n -0000028001 00000 n -0000028114 00000 n -0000028211 00000 n -0000028283 00000 n -0000028458 00000 n -0000028617 00000 n -0000028689 00000 n -0000028794 00000 n -0000028891 00000 n -0000028963 00000 n -0000029134 00000 n -0000029199 00000 n -0000029366 00000 n -0000029525 00000 n -0000029597 00000 n -0000029710 00000 n -0000029807 00000 n -0000029879 00000 n -0000030054 00000 n -0000030213 00000 n -0000030285 00000 n -0000030398 00000 n -0000030495 00000 n -0000030567 00000 n -0000030742 00000 n -0000030901 00000 n -0000030973 00000 n -0000031086 00000 n -0000031183 00000 n -0000031255 00000 n -0000031430 00000 n -0000031589 00000 n -0000031661 00000 n -0000031774 00000 n -0000031871 00000 n -0000031943 00000 n -0000032118 00000 n -0000032277 00000 n -0000032349 00000 n -0000032462 00000 n -0000032559 00000 n -0000032631 00000 n -0000032806 00000 n -0000032965 00000 n -0000033037 00000 n -0000033150 00000 n -0000033247 00000 n -0000033319 00000 n -0000033486 00000 n -0000033645 00000 n -0000033717 00000 n -0000033880 00000 n -0000033945 00000 n -0000034018 00000 n -0000034115 00000 n -0000034187 00000 n -0000034260 00000 n -0000034386 00000 n -0000034458 00000 n -0000034530 00000 n -0000034609 00000 n -0000034691 00000 n -0000034781 00000 n -0000034853 00000 n -0000034925 00000 n -0000034998 00000 n -0000035075 00000 n -0000035148 00000 n -0000035270 00000 n -0000035342 00000 n -0000035457 00000 n -0000035547 00000 n -0000035620 00000 n -0000035693 00000 n -0000035766 00000 n -0000035839 00000 n -0000035969 00000 n -0000036058 00000 n -0000036130 00000 n -0000036203 00000 n -0000036276 00000 n -0000036349 00000 n -0000036499 00000 n -0000036571 00000 n -0000036670 00000 n -0000036753 00000 n -0000036826 00000 n -0000036899 00000 n -0000036972 00000 n -0000037098 00000 n -0000037179 00000 n -0000037252 00000 n -0000037325 00000 n -0000037483 00000 n -0000037564 00000 n -0000037637 00000 n -0000037710 00000 n -0000037836 00000 n -0000037932 00000 n -0000038005 00000 n -0000038078 00000 n -0000038151 00000 n -0000038265 00000 n -0000038379 00000 n -0000038538 00000 n -0000038701 00000 n -0000038773 00000 n -0000038870 00000 n -0000038971 00000 n -0000039043 00000 n -0000039202 00000 n -0000039275 00000 n -0000039450 00000 n -0000039522 00000 n -0000039619 00000 n -0000039716 00000 n -0000039788 00000 n -0000039947 00000 n -0000040020 00000 n -0000040195 00000 n -0000040267 00000 n -0000040364 00000 n -0000040437 00000 n -0000040510 00000 n -0000040627 00000 n -0000040699 00000 n -0000040858 00000 n -0000040931 00000 n -0000041102 00000 n -0000041174 00000 n -0000041289 00000 n -0000041419 00000 n -0000041492 00000 n -0000041569 00000 n -0000041663 00000 n -0000042024 00000 n -0000042061 00000 n -0000042112 00000 n -0000042163 00000 n -0000042215 00000 n -0000042267 00000 n -0000042319 00000 n -0000042370 00000 n -0000042422 00000 n -0000042474 00000 n -0000042526 00000 n -0000042578 00000 n -0000042631 00000 n -0000042681 00000 n -0000042733 00000 n -0000042783 00000 n -0000042833 00000 n -0000042884 00000 n -0000042934 00000 n -0000043137 00000 n -0000043294 00000 n -0000043827 00000 n -0000044041 00000 n -0000044200 00000 n -0000044645 00000 n -0000044864 00000 n -0000045024 00000 n -0000045797 00000 n -0000046016 00000 n -0000046156 00000 n -0000046372 00000 n -0000046611 00000 n -0000046765 00000 n -0000046973 00000 n -0000047184 00000 n -0000047329 00000 n -0000047549 00000 n -0000047801 00000 n -0000047929 00000 n -0000048011 00000 n -0000048605 00000 n -0000053065 00000 n -0000053146 00000 n -0000053696 00000 n -0000057339 00000 n -0000057421 00000 n -0000058130 00000 n -0000065003 00000 n -0000065085 00000 n -0000065874 00000 n -0000078951 00000 n -0000079028 00000 n -0000079468 00000 n -0000080110 00000 n -0000080187 00000 n -0000080630 00000 n -0000084576 00000 n -0000104170 00000 n -0000104577 00000 n -0000104690 00000 n -0000105763 00000 n +0000001369 00000 n +0000001437 00000 n +0000001604 00000 n +0000006330 00000 n +0000006435 00000 n +0000006516 00000 n +0000006659 00000 n +0000006816 00000 n +0000006884 00000 n +0000006965 00000 n +0000007036 00000 n +0000007138 00000 n +0000007206 00000 n +0000007349 00000 n +0000007420 00000 n +0000007591 00000 n +0000007659 00000 n +0000007753 00000 n +0000007850 00000 n +0000007918 00000 n +0000008074 00000 n +0000008239 00000 n +0000008307 00000 n +0000008400 00000 n +0000008511 00000 n +0000008667 00000 n +0000008823 00000 n +0000008891 00000 n +0000008985 00000 n +0000009079 00000 n +0000009147 00000 n +0000009306 00000 n +0000009465 00000 n +0000009533 00000 n +0000009627 00000 n +0000009733 00000 n +0000009801 00000 n +0000009957 00000 n +0000010119 00000 n +0000010187 00000 n +0000010280 00000 n +0000010363 00000 n +0000010440 00000 n +0000010580 00000 n +0000010649 00000 n +0000010719 00000 n +0000010806 00000 n +0000010874 00000 n +0000010943 00000 n +0000011041 00000 n +0000011109 00000 n +0000011213 00000 n +0000011300 00000 n +0000011377 00000 n +0000011533 00000 n +0000011689 00000 n +0000011757 00000 n +0000011851 00000 n +0000011945 00000 n +0000012013 00000 n +0000012169 00000 n +0000012239 00000 n +0000012408 00000 n +0000012476 00000 n +0000012570 00000 n +0000012640 00000 n +0000012710 00000 n +0000012827 00000 n +0000012895 00000 n +0000013051 00000 n +0000013122 00000 n +0000013193 00000 n +0000013268 00000 n +0000013453 00000 n +0000013521 00000 n +0000013616 00000 n +0000013715 00000 n +0000013783 00000 n +0000013940 00000 n +0000014011 00000 n +0000014183 00000 n +0000014251 00000 n +0000014358 00000 n +0000014430 00000 n +0000014502 00000 n +0000014575 00000 n +0000014648 00000 n +0000014721 00000 n +0000014857 00000 n +0000014949 00000 n +0000015024 00000 n +0000015097 00000 n +0000015170 00000 n +0000015284 00000 n +0000015471 00000 n +0000015630 00000 n +0000015702 00000 n +0000015819 00000 n +0000015916 00000 n +0000015988 00000 n +0000016171 00000 n +0000016334 00000 n +0000016406 00000 n +0000016511 00000 n +0000016608 00000 n +0000016680 00000 n +0000016839 00000 n +0000016998 00000 n +0000017070 00000 n +0000017175 00000 n +0000017272 00000 n +0000017344 00000 n +0000017511 00000 n +0000017670 00000 n +0000017742 00000 n +0000017843 00000 n +0000017940 00000 n +0000018012 00000 n +0000018191 00000 n +0000018358 00000 n +0000018430 00000 n +0000018531 00000 n +0000018632 00000 n +0000018704 00000 n +0000018867 00000 n +0000019030 00000 n +0000019102 00000 n +0000019207 00000 n +0000019304 00000 n +0000019376 00000 n +0000019555 00000 n +0000019718 00000 n +0000019790 00000 n +0000019887 00000 n +0000019988 00000 n +0000020060 00000 n +0000020239 00000 n +0000020402 00000 n +0000020474 00000 n +0000020591 00000 n +0000020688 00000 n +0000020760 00000 n +0000020923 00000 n +0000021094 00000 n +0000021166 00000 n +0000021263 00000 n +0000021360 00000 n +0000021432 00000 n +0000021635 00000 n +0000021705 00000 n +0000021791 00000 n +0000021978 00000 n +0000022051 00000 n +0000022230 00000 n +0000022302 00000 n +0000022399 00000 n +0000022508 00000 n +0000022580 00000 n +0000022747 00000 n +0000022922 00000 n +0000022994 00000 n +0000023111 00000 n +0000023212 00000 n +0000023284 00000 n +0000023451 00000 n +0000023610 00000 n +0000023682 00000 n +0000023787 00000 n +0000023888 00000 n +0000023960 00000 n +0000024067 00000 n +0000024177 00000 n +0000024344 00000 n +0000024503 00000 n +0000024575 00000 n +0000024688 00000 n +0000024785 00000 n +0000024857 00000 n +0000025032 00000 n +0000025191 00000 n +0000025263 00000 n +0000025376 00000 n +0000025473 00000 n +0000025545 00000 n +0000025720 00000 n +0000025879 00000 n +0000025951 00000 n +0000026064 00000 n +0000026161 00000 n +0000026233 00000 n +0000026408 00000 n +0000026567 00000 n +0000026639 00000 n +0000026744 00000 n +0000026841 00000 n +0000026913 00000 n +0000027088 00000 n +0000027247 00000 n +0000027319 00000 n +0000027432 00000 n +0000027529 00000 n +0000027601 00000 n +0000027776 00000 n +0000027935 00000 n +0000028007 00000 n +0000028120 00000 n +0000028217 00000 n +0000028289 00000 n +0000028464 00000 n +0000028623 00000 n +0000028695 00000 n +0000028800 00000 n +0000028897 00000 n +0000028969 00000 n +0000029140 00000 n +0000029205 00000 n +0000029372 00000 n +0000029531 00000 n +0000029603 00000 n +0000029716 00000 n +0000029813 00000 n +0000029885 00000 n +0000030060 00000 n +0000030219 00000 n +0000030291 00000 n +0000030404 00000 n +0000030501 00000 n +0000030573 00000 n +0000030748 00000 n +0000030907 00000 n +0000030979 00000 n +0000031092 00000 n +0000031189 00000 n +0000031261 00000 n +0000031436 00000 n +0000031595 00000 n +0000031667 00000 n +0000031780 00000 n +0000031877 00000 n +0000031949 00000 n +0000032124 00000 n +0000032283 00000 n +0000032355 00000 n +0000032468 00000 n +0000032565 00000 n +0000032637 00000 n +0000032812 00000 n +0000032971 00000 n +0000033043 00000 n +0000033156 00000 n +0000033253 00000 n +0000033325 00000 n +0000033492 00000 n +0000033651 00000 n +0000033723 00000 n +0000033886 00000 n +0000033951 00000 n +0000034024 00000 n +0000034121 00000 n +0000034193 00000 n +0000034266 00000 n +0000034392 00000 n +0000034464 00000 n +0000034536 00000 n +0000034615 00000 n +0000034697 00000 n +0000034787 00000 n +0000034859 00000 n +0000034931 00000 n +0000035004 00000 n +0000035081 00000 n +0000035154 00000 n +0000035276 00000 n +0000035348 00000 n +0000035463 00000 n +0000035553 00000 n +0000035626 00000 n +0000035699 00000 n +0000035772 00000 n +0000035845 00000 n +0000035975 00000 n +0000036064 00000 n +0000036136 00000 n +0000036209 00000 n +0000036282 00000 n +0000036355 00000 n +0000036505 00000 n +0000036577 00000 n +0000036676 00000 n +0000036759 00000 n +0000036832 00000 n +0000036905 00000 n +0000036978 00000 n +0000037104 00000 n +0000037185 00000 n +0000037258 00000 n +0000037331 00000 n +0000037489 00000 n +0000037570 00000 n +0000037643 00000 n +0000037716 00000 n +0000037842 00000 n +0000037944 00000 n +0000038017 00000 n +0000038090 00000 n +0000038163 00000 n +0000038277 00000 n +0000038391 00000 n +0000038550 00000 n +0000038713 00000 n +0000038785 00000 n +0000038882 00000 n +0000038983 00000 n +0000039055 00000 n +0000039214 00000 n +0000039287 00000 n +0000039462 00000 n +0000039534 00000 n +0000039631 00000 n +0000039728 00000 n +0000039800 00000 n +0000039959 00000 n +0000040032 00000 n +0000040207 00000 n +0000040279 00000 n +0000040376 00000 n +0000040449 00000 n +0000040522 00000 n +0000040639 00000 n +0000040711 00000 n +0000040870 00000 n +0000040943 00000 n +0000041114 00000 n +0000041186 00000 n +0000041301 00000 n +0000041431 00000 n +0000041504 00000 n +0000041581 00000 n +0000041675 00000 n +0000042036 00000 n +0000042073 00000 n +0000042124 00000 n +0000042175 00000 n +0000042227 00000 n +0000042279 00000 n +0000042331 00000 n +0000042382 00000 n +0000042434 00000 n +0000042486 00000 n +0000042538 00000 n +0000042590 00000 n +0000042643 00000 n +0000042693 00000 n +0000042745 00000 n +0000042795 00000 n +0000042845 00000 n +0000042896 00000 n +0000042946 00000 n +0000043149 00000 n +0000043306 00000 n +0000043859 00000 n +0000044073 00000 n +0000044232 00000 n +0000044677 00000 n +0000044896 00000 n +0000045056 00000 n +0000045829 00000 n +0000046048 00000 n +0000046188 00000 n +0000046404 00000 n +0000046643 00000 n +0000046797 00000 n +0000047005 00000 n +0000047216 00000 n +0000047361 00000 n +0000047581 00000 n +0000047833 00000 n +0000047961 00000 n +0000048043 00000 n +0000048646 00000 n +0000053208 00000 n +0000053289 00000 n +0000053839 00000 n +0000057482 00000 n +0000057564 00000 n +0000058273 00000 n +0000065146 00000 n +0000065228 00000 n +0000066017 00000 n +0000079094 00000 n +0000079171 00000 n +0000079611 00000 n +0000080253 00000 n +0000080330 00000 n +0000080773 00000 n +0000084719 00000 n +0000104318 00000 n +0000104725 00000 n +0000104838 00000 n +0000105911 00000 n trailer -<> +<> startxref -105950 +106098 %%EOF \ No newline at end of file diff --git a/docs/typ/cheatsheet.typ b/docs/typ/cheatsheet.typ index 74d039c7..d7bf51ff 100644 --- a/docs/typ/cheatsheet.typ +++ b/docs/typ/cheatsheet.typ @@ -129,7 +129,7 @@ Helix-style: motions *select*, then an edit acts on the selection. Mode box: bla == Themes #word("Themes") lists them; #word("Theme") `name`; #word("NextColor"); #word("ThemeFile") `x.zon`. #doc("themes") -== 9P control filesystem +== The virtual filesystem (9P) Pane shells get `$PARDES_9P` (the socket) and `$PARDES_PANE` (their own pane); a command clicked in a pane also gets `$winid`, the pane it was clicked in. #cmd("9ns --mntgen # then m=$PARDES_MOUNT in every pane") #cmd("9p -a \"unix!$PARDES_9P\" read index") diff --git a/docs/typ/guide.typ b/docs/typ/guide.typ index f154bb1b..3a6e5bea 100644 --- a/docs/typ/guide.typ +++ b/docs/typ/guide.typ @@ -3,11 +3,14 @@ // keys on the cheatsheet. #import "style.typ": key, keys, btn, chord, word, tag, addr, file, cmd, doc, pairs, glossary -pardes is a screen of columns. Each column holds panes, and each pane is a -tag (a line of words) over a body: a file, a terminal, a PDF or an image. -Above the columns runs the workspace tag, and each column has a tag of its -own. Any text anywhere can be clicked: #btn("B2") runs it, #btn("B3") looks -at it. The keys are helix's, in modes. +pardes reads the text on its screen as things to do. Right-click (#btn("B3")) +any text to *look* at it: open the `file:line`, address or URL it names, or +else find the text. Middle-click (#btn("B2")) it to *execute* it: run the +builtin it names, or else run it as a shell line. Everything else is where +that happens: columns of panes, each a tag (a line of words) over a body +that is a file you edit, a terminal, a PDF or an image, with a tag for each +column and the workspace above. The keys are helix's, in modes, and every +session is also a virtual filesystem, served over 9P, for scripts. #glossary("Words you'll see", , [tag], [the line of words over a pane, a column or the screen; every word in it can be clicked], diff --git a/docs/typ/reference.typ b/docs/typ/reference.typ index 5ef871a3..afbbd899 100644 --- a/docs/typ/reference.typ +++ b/docs/typ/reference.typ @@ -1,11 +1,11 @@ -// The reference: every file the 9P control filesystem serves, what it +// The reference: every file the virtual filesystem serves over 9P, what it // does, how it fails, and the limits. How pardes behaves on screen is the // guide's; recipes and traps are scripting's; how a mount cuts writes and // the listeners are building's. #import "style.typ": key, keys, btn, chord, word, tag, addr, file, cmd, doc, pairs -Every native session serves 9P2000 (not .u, not .L) as a control -filesystem, in acme's manner: panes, columns, tags and the session are +Every native session is a virtual filesystem, served as 9P2000 (not .u, +not .L), in acme's manner: panes, columns, tags and the session are files. Paths here are the served ones (#file("/pane/2/body")); through a mount they sit under the session's directory (`$m`; #doc("scripting", section: "find-the-session") says how to find it). The served #file("/README") is a diff --git a/docs/typ/scripting.typ b/docs/typ/scripting.typ index b293bdb3..fe9146fc 100644 --- a/docs/typ/scripting.typ +++ b/docs/typ/scripting.typ @@ -3,8 +3,9 @@ // reference. #import "style.typ": key, keys, btn, chord, word, tag, addr, file, cmd, doc, pairs -Every session serves its panes, columns and tags as files, as acme does: -`cat`, `echo >` and `ls` are the whole interface, and a program that opens +Every session is a virtual filesystem, served over 9P, as acme's is: its +panes, columns and tags are files. `cat`, `echo >` and `ls` are the whole +interface, and a program that opens files is an extension. The reference (#doc("fs")) has every file. = Finding the session diff --git a/docs/typ/setup.typ b/docs/typ/setup.typ index 1ed6447b..7d2970f8 100644 --- a/docs/typ/setup.typ +++ b/docs/typ/setup.typ @@ -14,8 +14,8 @@ pardes runs as it is; a few lines elsewhere make it fit. on Linux; it needs `/dev/fuse`), mounts 9P trees through FUSE as a plain user. With `--mntgen` it mounts every posted session at `/mnt/9p` and exports `$NINE_MOUNT`; a pardes session is `$NINE_MOUNT/pardes/`. Run pardes inside one, and everything it starts sees the session -as files: +name>`. Run pardes inside one, and everything it starts sees the session's +virtual filesystem as files: #cmd("9ns --mntgen -- pardes-gui") diff --git a/src/fs-help.txt b/src/fs-help.txt index 1ffccc00..40dd05c5 100644 --- a/src/fs-help.txt +++ b/src/fs-help.txt @@ -1,4 +1,4 @@ -Pardes control filesystem +Pardes virtual filesystem ========================= README this summary; the pardes book's Scripting and Reference chapters have the rest index a line per pane: serial kind(text|term|cmd|pdf|image) dirty name column; names hold blanks: rsplit(maxsplit=1) diff --git a/src/tutor.txt b/src/tutor.txt index 76df0197..a6adcb35 100644 --- a/src/tutor.txt +++ b/src/tutor.txt @@ -295,7 +295,7 @@ typed = PART 10 — SCRIPTING = ================================================================= - Every session serves its panes as files over 9P: a program that + Every session is a virtual filesystem, served over 9P: a program that opens files IS an extension, with no plugin API. Pane shells get $PARDES_9P (the socket) and $PARDES_PANE (their pane's serial). -- cgit v1.3 From 0c3f1694ad547d734b332b1f69620e8df7bcf97c Mon Sep 17 00:00:00 2001 From: Gabriel Schneider Date: Thu, 1 Oct 2026 12:44:43 -0300 Subject: Prose that names a mouse button in words drops the glyph beside it, so a screen reader or text browser reads each click once Co-Authored-By: Claude Opus 5.5 --- docs/typ/cheatsheet-a4.pdf | 231 ++++++++++++++++++++++----------------------- docs/typ/cheatsheet.typ | 2 +- docs/typ/guide.typ | 15 ++- docs/typ/reference.typ | 16 ++-- docs/typ/scripting.typ | 5 +- 5 files changed, 130 insertions(+), 139 deletions(-) (limited to 'docs') diff --git a/docs/typ/cheatsheet-a4.pdf b/docs/typ/cheatsheet-a4.pdf index 9f9f50fa..a7c1b3c9 100644 --- a/docs/typ/cheatsheet-a4.pdf +++ b/docs/typ/cheatsheet-a4.pdf @@ -1130,13 +1130,13 @@ endobj <> endobj 377 0 obj -<> +<> endobj 378 0 obj -<>/FontDescriptor 379 0 R/DW 0/W[0 0 500 1 1 486 2 2 389 3 3 783 4 4 401 5 5 190 6 6 353 7 7 250 8 8 307 9 9 477 10 10 518 11 11 489 12 12 519 13 13 357 14 14 478 15 15 521 16 16 447 17 17 219 18 18 266 19 19 276 20 20 475 21 21 486 22 22 503.00003 23 23 489 24 24 444 25 25 499 26 26 564]>> +<>/FontDescriptor 379 0 R/DW 0/W[0 0 500 1 1 486 2 2 389 3 3 783 4 4 401 5 5 190 6 6 353 7 7 250 8 8 307 9 9 477 10 10 518 11 11 489 12 12 519 13 13 357 14 14 478 15 15 521 16 16 447 17 17 219 18 18 266 19 19 276 20 20 475 21 21 486 22 22 503.00003 23 23 489 24 24 472 25 25 564 26 26 444 27 27 499]>> endobj 379 0 obj -<> +<> endobj 380 0 obj <> @@ -1216,30 +1216,34 @@ endobj 396 0 obj <> stream -xœûÿÿÿ ÛÞ +xœûÿÿÿ ëî endstream endobj 397 0 obj -<> +<> stream -xœm“Mo£0†ïüŠÙƒ¥ô�Å@CÚ(ŠÔ� q臚j{&ö$µldÌ!ÿ~e�I«Õ=óÎxæÅ6ûõv˜?IsÄyñ›Ã;f´çÕsÛ'ŒíŒ;ÔîQ¢œÔa½5b@U³k´r c�—Qâ”ó¿”-ž•þNð= gº„±å.¸‚ Ì�Dí”»¿KûƒvPF¯ KÛkY™Î7$iìé›5â€NJK;ÁÑ÷M²¤.Rx‹®íCñá:8ì}2PP–û˜ �¾ãY Î^a»‰'R^­D«ôfÓ°?ÄÃØ÷ôCQÔ2|Soþ¥íÒhø�.!û}\{Œ ¤ŸÏFN�шÂHúV mõ“5çœo`]×u½ñÿÑó’ÊŽ'ñÕÚ�žm`Íy™måDQA´#º'Z-åK¢2Ð2Ö-IãD¤Ý=Ò*±î‰hO´%Š™ÑÑŽVɉö¤EªI£É2ÿ8/k"ò—WDÑ_¤èü-©_FþÊ-Qô3Éß’üe䯈ù[D-ú+© jÿ¼ßogAŒÖ¢vá†�÷»¬4ÞNroz_žp¦Ûäéµþ ‹q +xœm“Mo£0†ïüŠÙƒ¥ô�Å@mEjH�8ôCMµ{&ö$‹l˘CþýÊ'©V{ôÌ÷‹ÇìÇÇ~þ"õçÅOŸ8êÉ +œ×¯�IÛj1 ¨Ü¢DyõŽK0V‹Ôí¶U½Kk•8O¯1ÿ Ùà©W÷ßêitzHûêÝ—0#„™ •¨\ï.ÀÆ~¡{­–�%Œí”¬õà‡“4ö€ôÃj±GÇ^I;ÁÁ÷M²d/\¤ðCgBòþ2:ZuÔPP”œLŒH?ñÔ�Î^`{‰Gò¼[‰¶W'˜]‡ýæÜOÆœÑ > +<> stream -xœ�–yXç¾Çq *'™æ(3uÆöÚslï£-Ví±öQ[wÜQ‘Љì!! aÉ2É$™ì! BöMPêUqÁWÚ.´·Vko�ÞçÜs¥p*{ê�i5‘ë‡þŽb¯œ¾2Þx<ø—ãLãñàÜãaÆÉAêŸ[žPá·þã€åÀ–ÓèIxð'4¢C3POïAOìt8É¡C𠜽’­ê‚¨±[`é<\ü�cÉ“[RÑ9ôt ³ÝýÁ—'O|3ˆ›õò)¢ -ˆÔ.h¿ÐÝ}¦sjµv9ÊË“(¥2—;K›¬>î».A¤ÆH¢ðh¡¡ÈPbeí¡391‰ËßËB3ˆîÓ�ÇÁâo«kH…7¯ 7`lz%qЭÌñ;`ëµ0À%8ÃC'®ôã.а«Ðä´ÔÌ´HjõÉðáDÀ›×ïŽV4i35z5¥Å(�^©AŠ]ÅU�õþú.ê ÍLÝ H>€%&d.�A2íûj3±Üêvé” „Ä`š$=81qCɘ`¼¥d ¢À+àM°`ôáí’Q8E ÖƒÏ9Ûh3¤-P ¤Ø©<Ô©ïítaÝ`1 ±Óm‡P)™£0ä“Ùø^:ùå ½�N¬Ä@`ÚW]­‡PŸ‹ÌQrÕÙ8œÊH£c "E�¢B -¼òŠsÍwÚ1¸ŽáÔ“69ÊÍçç¢Z}©Íj®·”á0Oy |•ÖZ[}ÈÅœºìÕ;âWmÅ,“×�\Ï©âÇ­OX±Ó›ÌNŽWººÜ]UH…Ú.ÏÚGj’08AIªÍÊRU75«ÜPª"8E©¢d>Ʀƒà‡VæøøSÁ—�½à:né áŠÔ‹>�£WÅÑËixI÷Úñ+ç#ç°2­Æ¦@·n©ö¢û²ëîÛŒÕ&¶€œ˜×3Wx=0Ðü ÚáVåâì'Áå — 4…�Áåœ&+d¼–Z<˜=ÂMºÅ9y|1…éUzú]#¦ӈ¶ ÜÆÓ/}ùEXEp*Þ;õù±¼£oŸÇsü„· ø;zê«Ô –o©â7 M¯§cWï¦E âSkö%ã':2%ÈŽTé>�ÌVCaµ”¬%ÍUç+yGy×t8›¾Ä¦íOíŸÛõ×›pˆÆr(©�TëÕÑŠRè½ÅhÁ®‡ÇÓõ™EfK‘ƒ^¢µïò‘ í|ØM‘¥ -t×Ç…D1Jær§ÅïhÇÏô0¼ÜælP:XóÂ]}�Õçl.GªÔ®¬ƒæ}<c¿G«Ú@¾ -ÀØe¿òÉ齟ƒù“ܳïw=ÚÛ¶Óƒ-«[eîGüuÎ*ŒðÔ‘M(L3¾|„ÓvúþAéÕ]·•°N êÄé7#õ]zòÎÃL3ú/ôÖ{1°ãl’¯Ý¯î.¸ÜS³g ÆÞÿkµô7ð¯à­›p|ðCð{N'x‚yŽ€­Ö‹ æùÓví—ÐŒ·1ƒÉbÖ}ØÙSù Ù$ BöĪ© Ûþ¢Ë^TØûÌ»sqà\Z]¡ÍVhø$çÒ‹ u–*EŠHËd-ýýíçŽb°ÅIi24G�[@ $e+Çáx§­¦´cÇGƒa`_«Çe,ˆº} ,ƒ¯€‡€Å!�&_'ý¿óîq0‚¿¨ru;eQaðý<"NžBQù³(“ÞŠµê!·C#Vê‹´bœG¯� á-ŠÜz.:‡žMÏ£cvT,¼‹ÃWNë¾;ˆ[F81‰ÛÖ¤¡YäÙÓ�¿ú¶³~Wº¨èãÜœ}àG¹Ÿ¯7sæ�ÕÜ�w.=•B“-ÓKÕ¿”¢ï©­¿”â©xÈ¥—<Ú%yímì<¨ƒ^Þ•ð7vE3Ÿ(^Ê@ æ=5 gÓûË$àÑ}xýg„|зÁÿ<èä8lpv9UH¥Ê%ÏJy_ög,°àÒn -z†ƒÊ(#ùØŽuaqècÍSO— kS ¸æëþÓjQ—MK–âðµÝ-¯@½Í�Õ% <سuÓ‚dœýg" ;ö\ÄG#@q¾:ƒ·8ÿç>ùÚ$kØymír×ðû¿¯ü¹*û·w>Ú½1%Ó› °6�C¿AÏ g®8¨éºêÁÚÁ\hàXßù~´¥V´g§ƒàÎ`è÷y,ƒ-àï«×ÙRŽT®,®9™K`¹ô$ˆŽŠM\½-T¸=æj{#ÞÞƒ‡ÜG|ˆOS‘³w[Æ–�1xTe)UW - m~j·h*�˜àÉô) ÄRdÛ!Q`ìø…¿ÝÀ,ze¤ÊR‡ð°?Çã×á`ÓáÄáàô6æØ8Œ‡��%œ7= À‡Z­•ÍØ×½Wƒ©Èpá=z:½ì:†ŽÄÆœ{]à��[<ÅüJ¬\háå ©šÅ¼íØ~~j!ÍÝßùwœMÿ= 0Üv¡�“_©ði1�®RWˆðw'%(0JeQ;4,ÀªnºwéÕeçäJ³16ݪƒâÏü{pó� ¯]!ÿ¶½ì_Êoøoœ÷dK(à3¤ˆÔ&<Ü7ÐðE›\ºP�ÌÉ+Pµ®Ôá°T:»q6ÝúäÓñÄ�¿�SÀ›‹ÿ}ý÷pЃÏ8ήòŸÿ³Ÿœù`}à$:"³ˆKƒ“žÊ�ÃU¿n¼ÇÜÆÔˆjjÄ5�X,ÀØ‹‰O/mÙ! N_1²ñ¢± *ÔÃ3” \àt¼ Á±Êù4•J‰ª•f«‡_SZU„™@ÅÅÅbA@QÛ^Wy±¿þŸ�4Ju»ŠÛÑ@¯ïD+«”:§Ê¡4³2rµU‘î:5¾,“¡ZO�ÕŽ:ÜéÄáYJ�Ý£s¡^m}^¥hOfÑêD|Oÿ.t¢H颢ØA:¿¢4)­ -‡šUZÞæ©FÝ.JeÃáJ«Ú^\ZÈb¯$N€]�;_­¾ñ¼4G‚[à»ß s^ꮌ}‡XXYv£uØI• ÷f•íöïcŵÕgAÛ­§áRgS¢¹©•’^?�óä]²¦âVME¦“e�€‡O…z?môúQø^ƒNÖŽVòµ6‰íyYñÜ qxjTR$)– ÃàÒÏrð»ß Š½•–Ÿ�' ~7*kïIý0n^ÿÁw°Áæ¦Ë¬Ê@yGÒ$÷¥åÉó5f¢Ãàù•¢RI1’œ²2c'fÜõž�‡‘ `‘ßå€ßGŸ”ɫұìWd´ªK‹m…­o´Ð:…€µ6å@² %¤n›‡ãKɇ• ²3{UU'o =º„³ãhÙ#Zɘ˜¸BzvhôXÉ�q 8ùhTpÅ8 ø‚ó^N#c2W�É·ì9ÈËá§GˬNÒ‹Ö4×x›jYpÕÜ'É~‰"K-¥ ­AkÐ ðÒ³‚“ŒWm]WõFÌl†ü6½Yg¤–³Àæh�î¡âÊæ¢fôÆÙø©Ë�W‡‘/ù—ÿ´›'-ÎÃÀbz&goÁ‡Ü­ØAjä¹›%øeÐy꛽�èU×êDœMOQ4Q8ÓÂ3>¢á°QGOUÕ÷–»É3Á,+ˆiA¾*KÏx‹žöÚ††÷ÁŒÃ§j›Ú1ñÚý›ö%oÛ¾„§b�qp–s01K%D—J®¿q„w d¼~@½“ÌÇÙ›ôÍÀÑ…íQ s$~"np´ü"e%ÔÏÒR”Ö€ë¤f=0õ›º;û }‘sÍf«²™(‹M7CÙf™½±­&Ö鯢ÚQ÷˜ö•7»L®rä\Æ(=ƒÿ"ܤJC¹‰&S:NéuHg0ë­èa=Ta¨&óʨ3P|{ìÍ6wÕ5ô̩¥%ú"]N3$›“ ù™f �³-¡.t×Pr¨N; -ŠÚ¢‚û¾Þuþ佊S¨”ÈKP™ÎîÒàn•Ô'Fù*i‘¸.ÿê‘^O+^æqTÙ} 7Ž€5=À`©š÷ü#Üç7ê=¸‡*£”ˆÊ ÿ_áöcßqå§d+yžlU¥ xØ ½ˆM î$‘ëPšn©pÝëºÆ‚?lï±úQO�Vî½ùFm*¯*¬¯i¨n?;»cQv:¶soö2éüÍÔ¬BƒJ­W³^êão†KèÉzNmØ¿.šý?Tnد +xœ�–{XWÞÇq *W¦YuFgl_»«}m±j×ꪈ­w¼£"¹‡@Â%—I&Éär�@HÂý&wPêªxÁ ^i ¨Ðn­Ö¾]}Ÿ½¸'Ûqö‰Öjûöíûþ3sæœyfÎù~?¿ï9LÆÄ‰ &“9}sr<7K˜œ!ÊÞÉÍJæ-Ø <”–œúÐ�úgB1ÿìP6™� ϯ¡!³¾–Ò³f ß-†f3Œ�§Îf0˜Ó§Íf0ÆÇCßt�‡Î Ü@蛌 &3˜½)"‘ÏÝ�ÈÍ& s#ù™¹Yɇ“„s^¶½¾hÁ¢w-ž³+‰;ç嬿lËâ§p„s"DÂ$~VöBcƒÉ@ä.ÿj—§äaÑ5Wƒ3˜V…È‹ý?ô°h¹}69ˆÇ“‡N2„Né˜<4ÅžÄ`2 ƬÀú^3 ÆÀr3]¸œ cÌ +|| c˜9aÃ„Æ ÃA«‚Ö�˜h…¶CãÁí!†\g‰Y×&OÊ�Ìž<:¥"tã¯Ð_U²+§N�Úe8éÿóI¦á¤îÉ ÃD?õÏmO©à;ÿÂ8`%°ƒ•´zì?Å ´èÀÈögcÐS[ NsèÀxÌ^Mô�ñFUNØÈ°lö/ôÀ1gÊÌ èúM:œßéZñùé³}_õã&�ìD +©9"± š/uvž«Á�M†ò2%ùJ)MÅŽÂ:‹‡{n€+©6�(<œ«ÏÓXXûèNxÌÊ÷RÑd¢óì“1°äëò +RîÅ ÄëY›06½š¸èFæØ(Ø~#p ÎàÀ©k½¸“"lJ4.1!%Í“X¼R¼ÀKøú0ÿæ½á’:MŠZ§¢4¥Õ)ÔH¾3¿¬¶ÚWÝA�£™ ›q‡°˜è”•áHŠí@e +–QÞ,9вAÑŸ(öÏì¿¥`Œ3ÞR0 9aà50,~t·`ŽW€�àSÎÚirTY’ïPi×u·;±N°ÐÈÙ¦#¨¯�L—ë³É4|?÷ê‹úîvÖÂ!0勎Æ#¨×I¦+ôª4N`$ÒᯊW"9YÉ…¾úÑf ®b8t¤U†r³ù™¹¨FWhµ˜ªÍE8ÌSœB…•–F/r9½*mí®¨5Û1³Ûèq!7ÓËø‘£WmÃtF“‚£ÎWGR¢²ÉR�êX ŽV�*“¢PÙIÍ(Ö* ŽW()©š�±éÅD?ø®‘96öLðå`?8O†ÚÀ"ÕÂ�#é5‘ôJ^Ú¹~ìÚÅ–¡ X‘Fm•£Ûw•ûÑiU¬†r£ÛÀ*Nø)« ¼ÑÒW mu)3pöÓÿJ�Á ë‚ÀBÿJN�2\ËÌnÌâ"]¢ôL¾ˆÂtJý®aÓ‰D“nb‚©W>ÿ,¬!8¥Á�.œùôDæñ·/âé>ÂS�´øZ»ªËTb3–m.ã× uv�»uO÷–ÅÑ›¢*Äá§ÛSÄÈ®É�ÔZAa•”´!ÍPe+xÇy7´8›¾Â¦mÏìŸÛö—Ûp&ˆòGp¢)‰žTéT3õ%×!:³ÁŒÝ Ž¢«!2•L“ ‡=DcÏÕ£—š1¸ÍE‘…rtÏG¹D>J¦b‡ÙgoÆ/7ô(¸Øê¨QØYó‚�=�Åë¨/FÊTÎÔæ<c¿G+›@¶  ÀÐf»vììþOÁ|=Ó ÿ» ›S«n•ú°’Òê"ê0k4f\eµ)ݨÇUâõä»….‘š„׈RÝq(=1nÕò8ï¡ÚT~ªÈdìOBƒ°¦‹ÎX¶k+ò>ß³t<Øß´Û�-¯ZcêE|%UŽ2ŒpW‘u(L3¾èŒÓ6úþNáÑÞ5°Î +ªDI79á]zâî¶> ¦½—º«=XNp¶ÈÖo�Rö÷]íªØ·cü¹ZúøOðÖm8Êÿø5§¼ Á<{‹µÒƒôgú÷ÓŒ·1½Ñ`ÖÕæè*}Žl¬š ûbUT�š�í|YŠE/+ì}æ�^î»ÐŠ–—hÒäj>ÉǹôbH•ªŒ— ’"iCooó…ãlvPj»Mdä(IY‹q8Êa­(¬ÁØ‘ÄqP+8ÐèvrÂîÞËGàkà`qH¤ÎÖJþï¼{âO€àÏJœ�ÄF™•ü “ˆ”ÅSTö ʨ³`�:ÈeW‹º<�çÑë }pƒ<£š‹Î¡gÓóèð]%‹îáðµS':ïõãæ!NxÌŽu‰h*yþì“ÏÀï¾n¯Þ“$Ìû(#gú^îóõ‡ß†y`í ' Æèå�gR¨Ó¤:‰*ù§Rô<“¢ñ§R<Ó¸ôŠG{į¿�]UЫ«Êú…UŅ̃òW2ƒyÏLÂÙôÁ"1xü×nþˆ�¯ÀCú.øíïÇà> í{ 뎖2¤T锥Æ?‹/ÛsXpa'=ÇAi�’|lW±*7?ð³úcW‡«“ ¸âËÞ³+Q§UCâð9•Í%+Ak=õµå5<îÛ·}ËÂ8œý{¢Åtâ…ˆ�‡€|¾Úýw8ÿç>ýÚ"­Ù}mìpUµà. ^û r]úÇw>Ü»9> Ó!°>‰C¿IO£§¯:¬î¸îÆšÁ\¨ïDÏÅ^´¡R¸g'ý`´?°ý„ÞKGà6¿ü�cñ8Š‘2™Ê5Åq ,ƒžÑa1k÷¡¹rg­ÛTn«Å»À{�ýˆë¨ñªKÒ÷ïHÞö+Í…ª´¡¦ÉçDmf�\©‘<Ž^‘J$Av¶Œœ¼ô·[˜Y§H„”©ª¶xü<l:˜hóOmbŽŒÁXÐXʉvÑS|¤ÑRZ�}Ù}ý ˜Œ æÞ§§ÒËWÐát(6fçÜï¿}ÒàÎç—bÅYf^:’ ^ÂÛ‰ä'ärÑŒƒíÇÙôÑ3@À½A—z8Ù¥r¯skKµ¹ol´£”f•]ͬòºû§�NaUZz†$ cÓ½�:ø'þÜ¿‡·W€ x#èø·ãUÿâÁ?xó¼§ÛŸ,A$Ö¬¶ž¾šÏz0ØèÔjüpzªHŽª´…v»¹Ôщ³éöÀ/Ç™ö ~òm˜æ/ùÓÆoáX ŸpÅ?ÞÓ^œò`]àX:"S‰ïKƒcŸÉ�Ãe?o¼ÏèßÁTˆjj**jjD�H$ÀØKˆ�c®lÚ%öO[5´ù²!'¬Å¯ƒ§)@*¸Äi�ÁŠ4 +-‰ª&‹ +‡_WX”„‰@Eùù"A‹¼²¹ªôr7~ó¿Ûi6”àræ7£-ÝÞS�8¬ThJ»ÂÄJÈT +TIºªTøn°dL„*ÝUjwQ¤‡g(Ô6·Ö‰–x|•Õ™¥Â})ykcð}‘ü{Щ<…/ FÄ ’pø5…Qa‘ÛU¬Ââ&w9êrRJ+OSXT¶üÂ\{5q +ìiýbí­¥9äßßûj�óÊéÊÐÓfÇZÁRÈl·l¨ÝF*­¸'µh¯ï+²©:í(ÚÜÒxön'µVš‘#–(P éñ8¿OÖ!­ËoT—¤8X–xðÔq¨ûãZ�…ï×h¥ÍhÉoc�È–™Å݉'$Cyâ|1:®ü(¿ùªØÛiÙŨ‡‘bÿ7C�²öœ3E Á“ßx�6ØZw•UÚRÜÚŠÔɼ‰y²lµ‰0k1xA©°Pœ�ÄůNÞ�ö¼—ÅÃH³°ÈoÒÁ¯gž–ÊÊбègd´¨ +ó­¹�o6ÐZ¹€µ>þPœ%$.«‡£ +É» +g夥t+ËNßx|gGÒÒqÆLc|üAéÙ�ÖC D-þ‰ÇÃü«FáXàõÏ{5� q\&Û¶ï0/�Ÿ4Sjq�´¢¾ÂSWÉ‚Ëæ>�Só 䩚™ +Òè5z5¯�„˜tk¸nmí¸®3`&ä ±êLZ#&1˜V{óÌn°Ê/­Ï«Go�ï<Ý�Ÿ¹Z{}ùœõw{y’üL ,¡§söç|ÀÝŽ$¤sQA¦«^Œ_=�»ºÞÓŽ^w®�ÁÙ‹b?4jÈ õo˜м œâ$)ôP*oã¡)Û·E'áð a'‹ô¬ÚºÊr/ê´æÅÙñc4ÅÙ�9%h‘Ë]îÅ›Û{KËYp}yÃñ‹ÿ›aÕ߯ûw/·ÉòÇJ,¶9pÎÛ38b&yMaþ_î¹»C¯áä*IJTªµ9Õ¸K)ñŠP¾R’'ªÊ¾~´Û×Õˆ¹íe6oÍ­£`]ЛËfÀ]ÿöú :7(¢ÔËþG||¿³_û!; +^dGYa ÞöB/ƒ ƒ»±ä”f›Kœ÷;n°àcýÍ]ê®ÒÈœ¸'Û I@øe¹Õ5åÍÇ#"vÌKKÂvïO[.Y°•š‘«Wªt*Ö+'åÛÁbz¢€ž“Cën˜É¦'É뀰œk`‚iŸá`а›£# J³ò[ó?NŒÜf�é`†„7 _ÓAO{‹žòú¦š÷Á´¶3•u͘hýÁ-âvì\Ê‹T²À8Ï9“ªÌB—‰oœ¼uvô%¿qHµ›ÌÆÙ[tõÀÞ új³šÃ@Ê0ˆùþ„ÜâhøyŠD*K7CCQ=®•˜tP‹±×ØÙÞ«ï �k2Y¼�ÕH™µh’ J3ImåˆÙ`1Z±. €H_ÕŒ‚ÈOÀ”/ܸÉit#’‡éyüç¬-ÊD”c4&á”N+†´z“΂¶é }9™�P­žÂà»#¿©·ºÊn çÎä.+Ðåispš!Þ·ÍN1™ œýo.©Ï endstream endobj 399 0 obj @@ -1423,19 +1427,14 @@ B endstream endobj 411 0 obj -<> +<> stream xœí}]×$·qÞ=ÅP”(¾· -_²"Û¢�ÄŠ$Û¡îì\h÷x™ä,7Îzs|üïsª?Ð�éénÌÌò4/¸�~gzª«€B¡>žúæ¯?|ü_oÿüæãå·øö³ÿ{‘q—Wü�# ÎywyóÃ7oÄåÍ¿ñÁ{”Ú8×ý•ºüÛ›÷Ý×~¸h¯­6qy7 “ÞÅ�}÷ÙÿüìígÿøÙßþáÛoF*~ýëoþôÿú/ßüþÏÿñþßÇßüæ·“…´”N^œô€ÍD›”Ò²L¤Þ åõEIo„uº#RjéõEJPV3Åñ-ouGczÉŒ‰ýî_ÿüþ׿þæßþÝß\Ä7¿ÿóûï¿ú—÷/b…­lB,)©,j¦­#%‰ojòBzô~öÛ?]ÄåO¾y+.R_þô6�¸üé‡úꟅÿ,„þÅá_õâÆ?Ñð¯þ5/ÿãO¿ûìoÿTxYy²`�³¶ø&¨ºyà/ó_ðÔPý”¾‰¼ø›^d|‹¤¯ò7þµÝ¿¯“'|,~füëû~$Uá o»ÿˆøòÊæÌ'‡ÇËø!(⟠Áñmôcá¹8¼6„áLxéïãxŸ^FÑTpäRÿà)—‡ŸI–)Q ¼œUäu`]�®Œá—"Ȕ֔ÙÖQîcÕ[¨ü>fÈß!åuÊ[^„ÉJ»U¿YO`²…æ<±†c•]awm#,-‚—JùN O#)ÁÒ¨Óøjƒþµ�>œÑ§Y�±® ¨ÓÀ|)*�žâMŒvˆîÊŽtõ šgÔ(ÒY'ÕÅ:͜خa«z)]=:Ò1©.gð83ôÎ9`XÓ¿Ô÷âòý¿Ý<�¹Âï}y®¥ÉœêæÁx½c'¶„ ¥ c©TŒ•ØQ®wPiœ+ŽæåATj ¤J<@ä’ x/ý°øÃè ±G¤î–û©‡su¿ð“:©UkAòj5†h;½ziœ0—ø1à„ÓVÙøjø»¸¼¹(0;âû+'ûÉ0\Ý‹è�$Pl{÷ƒW݈)ó³‘i˜Îþn:ê¿=Ž©Ñ’Œ®âÏõ×obÞ]$!�U¼5tÏè>žÜë?ÿ¦PG€4˜�úGÞÎG%A¢rÝê¿Eú�à†w9—rÁ{cq¼Ñ³ubQ?_ò:ÓÇǦ£‰˜w×5Êm�ìF0RHì^60¾—Ú®Ù‰ ´2´“«´¥l„`5†¿¥–Î^Ø,á uÑàt÷‹Ãõ›áKý¨›�Ê9‰n¸Óÿ@xT?ì¿òæ6ŒÄ ä3°s „šd'd=¾Aý&Ê#6άï¾Óß0ທÔGÊúÑÖ%€H¨NX¼&³Öå Áâ ÿ¬ -ÔÉeÿV€Ã¯c¼GÏúQQüùnÜ}’—uSr˜¸D�æÔ½‹žA œé¿Ò_¾‰ïâ‡÷·Dô1<ÃôV„нÒ0`´ZÍ2θ�gÊ9#�SÉåð‰žiª»êt -Y倀ÊÄ_oð×Þ #>t0ú‘åu÷õéA -¬£á'úë7Ã3úÑ»ø'ú["z�~âHæ}ûÝ’nøîÛ?òŸ.ÿ~¡Ë‡~ø48dún�Ô?û®pøRsóJMF«dK0ò -�ìs#Å; ’ڹ)3¯^˜-~!,8gjþ¡äÌÜ8ÃÙíåuÞ¯ÓgŽ~…Ì?0þÒè -Ô�Ï�ÿ2S,Åè«™ç$õ]¥gÎô7_—FÂ.{÷¨&?ƒ€ÔLz:ugII ×ñõä‘KX¸í€LíA�èÏ0§åºÇr½‰“§éºv~`º2OÃõI WíÀ¡>íÖõ¦—v ×NîÓj]fÝi´.­z9¤Y?ZA·‡m \3ÆèÜhGê(žeâ¸Á`1Îâñ+™Ù›8BZ”Å9Ô�[iø¢�µ·¹õ–šÞáÏ ºÌ}ŒŸø17‹K¦ôöû�…-Uñ¹³€ò²€lmª�\æM$”s,çdùP!ä9>%åã0Nys¤]N|ƧÓ,ßb–ßÂÈ!Ò1„ XÅ;¡ ëÙ!|B ýx2½ -)l¥ü… 0^“:�ëíb ’ù}ºÂ·2ïÒ:Íìñ·‹îà�·�7Bâžš[¢Å0Àûø,’¸–3³¹œA8~Ñ–|ÓK'”é(ôJŽñ…�à¹pªäêŠÚÔãì$'œj%È13R WYfdܺãÈ(ÀbtfÿaSébüf:¶ŒS!m/ý‰p,O’Nƒ|‹!�ŠèdMtÒ€•ÍäHÆ‘âa7ä½®Žw…É?Š"å´Îc:åç/|+‹¾�Ù·5inæ4³º/õ)“æA¿_!B¬‰PX åÛya¢àç×�Þ Ýjùh`¼íº&dÎüT[“BÖØ^‹a6¦?lñlËWH?Û~RWꕉ™nYšÿ‡ÂÖ¸ä@[Šh¿�'M)©9RݹZÌÕÞø…¼X¡&@] ó †Í&ÖÇ*…�ôb <[ª-Hfs¶[è ÒT¤cÛ°]REHHÕn}Öœ›� ^µ¯šŠâå•ä�JŒž¹3¸{Ê¥¥W,"Z�®O­~Þü4z׉°aî†Å_‘�«IÈJ�í&Ô²!ÝÏ­Ÿ•ÿ˜Y�‰ ¿¨㌚·×òF2�Pò-5 à˹zý2‘ÂÏ—� W'_E^¾&/#Á‹v¦Ä�J_mâå‚ù=Ó;ãêÜ›ïH£µ0ª,.òº¢È©Èd7ý}YfX;|ÍuQìžh»� „¿/O½Ú¦ƒ²R%CȤVÔõªÚÔmA×7�×™ò,¬Ž/¢¢¹”}-LOŠç›\.ÖšŒ”ñ‡Ó -ÎqÎ|Ì™™²>Ü—«×.Ä‚óÍöæª&eyÏí�vÛ*[gÇ{€ß…k© ÷—�W{ -¯$Oq4…±iC ÑzýtŒÔœ1šUË~aK µ3cÓ8:–ÎÝ_$ó ¶@êboÈÒé, 8"¶:ŒûUa7}ñ—Cá·Iÿ …¯œ�÷8CáŸB(œ€QLË _Ìe–©dzŸ‘ð­Ì;#áK‘p,@rh@¥yѲªÍs�®„ÄaT‚=êP//úß7Ÿ›”a­4Ÿ”Aµ�èÓ ÊùHŒã™ÚSÇÙSÑä<í©'·§”o¼4ýwTkt†må 3R{ê¬VÚÆºÓšZ´¦ +_²"Û¢�ÄŠ$Û¡îì\h÷x™ä,7Îzs|üïsª?Ð�éénÌÌò4/¸�~gzª«€B¡>žúæ¯?|ü_oÿüæãå·øö³ÿ{‘q—Wü�# ÎywyóÃ7oÄåÍ¿ñÁ{”Ú8×ý•ºüÛ›÷Ý×~¸h¯­6qy7 “ÞÅ�}÷ÙÿüìígÿøÙßþáÛoF*~ýëoþôÿú/ßüþÏÿñþßÇßüæ·“…´”N^œô€ÍD›”Ò²L¤Þ åõEIo„uº#RjéõEJPV3Åñ-ouGczÉŒ‰ýî_ÿüþ׿þæßþÝß\Ä7¿ÿóûï¿ú—÷/b…­lB,)©,j¦­#%‰ojòBzô~öÛ?]ÄåO¾y+.R_þô6�¸üé‡úꟅÿ,„þÅá_õâÆ?Ñð¯þ5/ÿãO¿ûìoÿTxYyA �¶¾ø&¨ºyà/ó_ðÔPý”¾‰¼ø›^d|‹¤¯ò7þµÝ¿¯“'|,~füëû~$Uá o»ÿˆøòÊæÌ'‡ÇËø!(⟠Áñmôcá¹8¼6„áLxéïãxŸ^FÑTpäRÿà)—‡ŸI–)Q ¼œUäu`]�®Œá—"Ȕ֔ÙÖQîc%’g~ˆŸ<ˆvÎ�ñ»ùýü=Sy¤üŸæ÷È;©D¾†³·SÃ/*•®è[õ¨õ&[ÐÎkRVMÑv×6ÒõÒ"x©”ï”ý4’,�º“¯6èyèÃ}šÕ%ëdŠ:Mϗ¡Òè)ÞŒÀØa'ê®ìHW± ÑqF�2 �uR]¬Ó̉횼ªÿÒUª#]–ê¬q¥Œ³KïœÖ�5ýK}/.ßÿÛÍ3™+üÞ—wáZ:�Ì©nŒ×;v|KZ +:–JeÀX‰•áz•ÆY°âh^D¥–@J¡ÄD.É€÷Ò‹?Œ{Dên¹/‘z8W÷ ¿1©“Zµä ÿ Vaˆ¶Ó«1�&Á sù�N8m•�¯†¿‹Ë›‹#±#¾¿"p²Ÿ ÃÕ½ˆHÅ6~?xÕ�˜2o0i�†éì念þÛãH€‘-Éè*þ\ý&&àÝE‚ÒYÅ[C÷Œîãɽþóoúu(@ƒÙ¨äí|T$*×­þ[¤þax·‘s)W¼7Ç=['õãñ%¯3}|l:šˆyw�Q£ÜÆÑÈn#…Äîeã{©íš�J+C;¹jA[ÊFVcñ[jéì…;P Nw°8\¿¾Ô�º¨œ“è†;ý„GõÃþ+onÁHÜð@>k;w‘@¨IvBÖãô×o¡áÅ�Ù₨æ‡JÎlÁ]4œÝ^^±Qç½ñº|ÂÏüã/�î¦@ÝøÜù/3ÅRŒ>!‘yRYzæLóuÙ1%첑jò3Hͤ§S·™´‘ÔpOQOn—„…ÛØÁ4Љþ sZ®{,×›8yš®kç'¦+ó4\ŸÔpÕêÓn]ozizíä>­ÖeÖ�Fë’Ѫ—C§‘õ£t{ØÖÐÁ5óg �v¤Žâf&Ž„¨V7ˆ_ÉÌÞÄ)Ò¢,¾È¡†ÜJÃÍh¬½Í­·Ôô^Þ`îcüÄ�¹Y\2¥‡ðâ‡,<ªŠÏ�®—dkS�äà2o"¡œc9'ˇ +¹ OU‡†ÀtÊ›#írà3>�fù³üF‘Ž!dÀ*Þ EhXÏáƒZèÇ“é}PHa+åçybݺR„§ó@ñ)(H€ñšÔy¤Xo“•ÌïÓ¾•yç©béTáV�*”æìÕí IuKotKUH“ËÖ©Ÿ‘lYíZ’ºHò‘Öif�¿]t¼í¼1&ûEç„`‰Ãïã³HâZÎÌær¦âøE[òM/�P¦£Ð+9ÆB"éÂq¨’,jS�³“œpª• §Çáß,»2nÝqd`1:³ÿ°©t1~3[BngHÛK"Ë“äÖ ßbH§":Y�4`e3¹…’q¤xØÍsj¯Ç»ÂäE‘rZç1�òó¾•E߯ Þ�š47sšYÝ¿—ú”Ió­ß¯!ÖD(,�òí¼0QðóëGï„nµ|40Þ�v ]2g~ª-‡I!kl¯Å0Ó6‹x¶Í²Î»RWꕉ™nY9Á‡ÂÖ¸ä@[Šh¿�'M)©9RݹZÌÕÞø…¼(¢&@] ó †Í&ÖÇ*…�ôb <[ªaHfs¶[è ÒT¤cÛ°]REHHÕn}Öœ›� ^µ¯šŠâå•ä�JŒž¹3¸{Ê¥¥W,VZ�®O­~Þü4z׉°aî†Å_‘�«IÈJ�í&Ô²!ÝÏ­Ÿ•ÿ˜Y�‰ ¿¨㌚·×òF2�Pò­¨²è˹zý2‘ÂÏ—� W'_E^¾&/#Á‹v¦Ä�J_mâå‚ù=Ó;ãêÜ›ïH£µ0ª,.òº¢È©Èd7ý}YfX;|ÍuQìžh»� „¿/O½Ú¦ƒ²R%CȤVÔõêÝÔmA×7�±ŠO-ÆŽ/¢¢¹”}-LOŠç›\.ÖšŒ”ñ‡ÓJÑqÎ|Ì™™²>Ü—«×.Ä‚óÍöæª&eyÏí�vÛ*[gÇ{€ß…k© ÷—�W{ +¯$Oq4…±iC ÑzýtŒÔœ1šUË~aK µ3cÓ8:–ÎÝ_$ó ¶@êboÈÒé, 8"¶:ŒûUa7}ñ—Cá·Iÿ …¯œ�÷8CáŸB(œ€QLË _Ìe–©dzŸ‘ð­Ì;#áK‘p,@rh@¥yѲªÍs�®„ÄaT‚WêP//úß7Ÿ›”a­4Ÿ”Aµ�èÓ ÊùHŒã™ÚSÇÙSÑä<í©'·§”o¼4ýwTkt†må 3R{ê¬VÚÆºÓšZ´¦ 5ö~rþ �Ý/5ÊÏHkÝõ�qÕîß_]dz¯ŠÄ ‚RŸ†‘·�èÓÈ«xÍn’þiå­›�’¯N+ï“ðš!‚ìh9�¼µŽ”à’é}zͶ2ï´óí<ªxÍ$+…gõš}BÕ6¢OƒjÙkv›ð^J¼‘ðÓ\·ªNCðr÷�–à­>«Ó<Šw§¸hêš¿Ovhâ¦Yg–¯š•f¾å$ø<Ã>JuÝ缜üÔœw·}ÚšçÝMÒ?m¶•³S�?Ñ_> ç�p ýi²ÝâÐÓzÀœÓh«pï4ÛÍ6Sqß NÿV÷Ý'dRm#ú4©–½`§EÕÀ vZTŸ�ì4©nõäÌ-ª3ëm#ïN{jÑžšƒŠ�'$;¿žÑ "†PZ>ªmDŸÕÌC‹€š´T·JÿáÑ­”Ÿ¶àÊuuÚ‚On jZÑ OSp] ]©Ì¨3NïÚQÜ;­ÁEkÐÕ‚¢B�lˆPœBZI;°Qºm©j¬ªžÈ`Žo ÈŽíKTÆÏË?_/ÎÈ`¸æM?*HR¾"+í8×p‘·/ꬽ“}Ǹ71ò41WÎN§ÁÚËÔÓļC—Éê41¯„ ™erõô> Ì ïNûr±�µXŽÞj‡@˜MÀg‰ÞÞ¶£>Iôö´§Ž‰ÞžæTƒèíiN}BÑÛÓžº5yšSG±î´¦­)Yó9 Û5Â)tnš#‹ä®9lÔË8fŸ?ù±P*×½y @@ -1465,53 +1464,49 @@ X /æ½Õº?ÊÞöûzŸíb<·Üpª�—Ã=Y£k…a:”„[¬…à VÂáfP˜á‰A›†l©�ý²Ñb¸5 ±Ûæ¯×5àˆñžáÂWV ,t¥À(rÉíTóO—5 ¬@eÁ8e±%G÷Ù3¼yxŽ;�ËhÓ2‚‰M Ånë']G»Û -=Ã:*˜†VyoÍÖQ†f“’VIçaÊ´ôíÊ«Rüíñä “4¸Yß©G„“Ñ÷‚¦b ÎiwnÓNÛ°s/i%öe:¨Á¢4ÞóßMøKøÖt�uÌ4Š•ÌtwÒ2᱓š ¿ÛRÏT²„Œµà5»qâèWËÒè¶qÈ‚ª;Ì�s�*báìE 1®}ûÉ ‡é ²D”ÖÚQÇ2n|ÃÖƒ÷òÊ€÷Þ?ä>¾�#2³†Eó€×Ümý¡ æ·Ú¿»ßA^c}%¨`Ø V…Cæ@~Û¶É(!À8î�b,�ñiÈF‡r9DK¬E.¢Sœà°•Ò\7× ^u£wÞ`6Ò »ÛßMGý·Ç‘#5Z’ÑUü¹þúMLÀ»‹!¤³ŠíàîÝÇ“{ýçßôêP€³QÿÈÛkû” PBÞÊHþöÈÁnï'8pÇÎJF2AN8mÌ©�oÒ�œìk(‡«ûQXýà •Qæé|@ðÞXoôbn?ž^êÚt›Ž&bÞ]ñ8ãÆÑ8QŒ¼aÄS¦Ÿo[¸—=;�z'[-hKÙÁj #~M-�½�Ž/ÔEƒÓÝ,×o†/õ£nñ(çØëïô?Õû¯¼¹M#qÃÙêpî"�P÷o©Ç7è¯ßByôî¢Áúî;ý ®{ÉáAýp¤¬m_½Èá°Î=r².ò¥æàWwWjX¿ìhDY+„eAÇ—ý:Kª¿à%aŒ÷èÙˆR@¾wŸäÕ@ݬæ.Q·èµG.¡Ï PÎô_é/ßăwñÃû["zŒž¿i†óùD‘íx&“¼:Ë8ãž)çŒ4N%—Ã'z¦©îªS+d•SL2àpü•ñíÍ0Bð�nìGŠÁ¨»¯ORÀÙØýOô×o†gô£wñOô·Dô 1üÄ‘Ìûö»%íðÝ·ä?]þýB—?ýðip(ÈôÝ©ö]É -S¤CÁ&¶ê´l3lWOŸÒìe=­«�Ö•TÜü´Q޵Q¦éyÚ(Ïo£HÉîˆaË8m”u)n™± R+?¥k~.RÂJ-]3>¥ÒÓ¬lö�ºÒ�*E«ÚhmôsôâB-j ÝxáOÝÜ�km„ëvèÌ5�²5L•5¦Z F¥á‰kj*4Û¬ÓšŒ±à�г®5µ˜óûí–6A�¯Ùx4ÖX×õ8µÔ®óaŠà6Ÿh…p3”§ô·Ì–¢jUÚÜölú“¬kÜV5nkÖ¨æ¾ÑëëÝõúÍmW‘'!Ô„h±»òIDÉ~w#a„ë2­ˆÂ_·¦{¼»M£xw›î†­hzlب¦ßm¸»iªìndÁuY…mv·Ÿ$«jÄr µZµ©^8=(Ê;Ä„ì‡øÏu 0�:/uk¦Þj2ØšÒ ¨Ú� ~¼6ƒ«q•Û㎕ÇMªöUm/äødv— §þ�2ó"CÖDc´nÏ­°ÆU_ã*zNo—¶ W?_HöÈ,€kéCË>…ýûUfÙ´B�4ãçÔf‚©ž+PtIßÍ̸¢Ó¤®D¬}Áüš=,¨˜ýB©ë¿—©ž&8aE·K1ÌZ±½^fð¯2¶ììÓ£…ç­>­ìÌkXkœ™Jš¬ŒdÁ(ŠÏ”Ø`T%±!!ù!–™¡JfCCŽö }½/�à\DÛ‘®ä<é*2´¬'XE¶‚–Õ|½­V5»úí 4õÍÕMçˆÜS6p¹i,K'œ¬=^úˆÚyiM`ÅÔ hò]¥CãCIñ5Í‚¼Ïèà´OÕ¿Pm©À 4²O FÍmµ¤ëþ®Ã_&ì¯p¯Ãþ -£û+Ü�±¿†ÇNJ3ünC­i+­�È)p]A@#¥ù—ÉÙ´6£m©’g¥r)�Ñ”¶`À)� ìÜ��¥¦{)a5_19âªìVØÉóîiST8;]'îð/ Ç• ™pR”ócv~æ‹¡w*‡ 9èT5›TMÅM Z �ܨ]S51��Q5¦¦jÚ±±œ�’Vó13i^S«f�£/sðý.¹n6ÖY®ðU§ÑÕšî«Í½šaKFƒqÔ·¬kØ+;õ#F¦nv”¹¹:Kn’ö!}¦šHÒ4'°uQ¤õËE‘DŒ2©Ä«Š,& ŒR,€Næ�ÖTZ:¹m†Ï®çVÛ–ùKV“gtŸ>Éi¯y mÿLÓ—†{CúÒ0²€^8íûì¥á&Ç$5¡ŸêÇ�M?nõ{kxL¼·7ÅôDž@ã÷–&‘+XñV‚è˜ZšD·¨ 6Эo³;ë•’ZrŒ[ Å «é„§v9å#M…'v^=.æóR•’owªJ@vàöJFB°’¼î�|ÓèÀZÆ‘XDz¨%zb{©¥°Ÿ±Êi@á†Î‹ÏN¬1`ݧA*9P†!Á>Zу'៚X­Ày#ÌQŠ‹¤�ˆí-h=Fo݇ÖcÔÖ]h=Hk݇Ö#”Ö}(=Dg݇ÔcTVKZÑ�(kd;d¯ÈqÇî8¹ôlÁ¥g—ž-ºôìÜ¥gç.=}—ž«$.�Bp†œmšVú‹1øZ;r”š�úÑ£“ù�¾‹®”¬@£G¯;º* ®àÕzÜ�””¶×GMœQ!�³ÔÞo9vš6)šÜ};]ÿJ‚4Ô®#«2±�¦,8é5vM\øË”•îuia”äe„»aMO� +~úÝ–j¢‚ÛB¨ÀhÕ¢ú­jÂÖÔDLæcÔ„«©‰v\ `iÒJp-bH·z<ç| YDƒUÈTí9·ZdTµ„!—uÖR�+YYÑwzžFÜdJMƒ¥ìË0è {íJ,DÆwäÂþÎÀ"Û£p÷ÿm¬é\r_”}Œ7+tdÜ�¾óí©ÐoUè¾f÷I"Ün¦Ð}Õî‹É|ŒZªÚ}í¸¸B¡{]Sè�眩)ôÖœû°S�÷JØl‹‚†2û¬xþ6mnkڼĿµùB%)!jʼ¯+s%dM™?žsXSæ÷æÜíê\"Â4þ¾Ö¹ª¦ÏK,oÎ7¤�ê\p_)©Í}E›—x¬q¾Ô.zgi°òJú†è™?j….+u:Ê™®²y¸F—²¦Ñc2¢š$ÖTz;.®ÐéRÕtúã9G5¥Þœsb§ �•ŽÊçVµ®$prê¨WÂèFµ.uM­—Xx ^•)ó "tLÚ©â�)œnWŠùãVñ•(©²´·’*Y ’ÆT>FMÕb¤íx¸F¿×B¤çÖ"¤Íù¶±ãƤÝW4fXkwÖîX �–8x¨Ñ>`O¼Žµ¹J ñ÷šï–¹m±¸ð�9QNa%`ªŒã޾}Ûª‡*w¬L2£¥jÓ†\ ¨Z;Õ”åVض¯o{LäOaÕ-±ðP=5›ŒvçÇ�:ÉànÞ§µ¹E#Õ¬MíAZê�«‘ªæfLæc4RÕÞlÇÅk¸ -«ææÃù¦ªöfk¾ñAwŸ&7´3i«ò;kòB+õH“—Xx¬Å™¶—j¯ï@[ KöÔæ›´y­Ñº"~¨z¨2/µ]Ÿ”yDåctRÕºlÆÃ«ª¼Ô5{RåçZ-¯1×~»S‹k jT97Çú i%öͦѭZ¼–‰Wb_c%Þ±õ €ƒÊ�SóTè·*ôJRž"V#>Þ\êÓiôˆÌ‡(§RKÙH¥7ãbͯ�VKÊ{ÎÕ’òÚs.ëÆ›’¦j:�$HA¦Y+‹�­§È[—VñÅNÕª<�xæRlÒ­¥ÆŸA·* z¬]¨n-uΜtkLæc4D5=®û†iºªÉq�g[5;î®l»Ý`æ†6º×:Ê�+5iœìåû4˜¿�ë§¾K»Ó&xUÓÐkøÔæ·jóR3̠͹ ìÃ!(T©¹ä¤Ì#*¢”Jý']ÞŒ‡×Ty©Ñá¤ÊδjJ\[¦emÍo×äÜ¢ƒDJßêŒ aó„Á�мÔÙoRäî[±2–Ž-ÀCÿ£ž»qæÄqj^€'ì™@q«–¯…+™ÅÒ=>ZYj²8iùˆÊÇ(¬j°²ÇÐÿ2p¸*5ü›t•T@¶]Cë€Ù’Žéé ~Š�Á?ߦ¼ÃÍ6? �×@ì§òˆý@^Gb? �×@ìóƒ¼R?�×@ë'òÊ®U¥ÑêOä5¢õéA^#ZŸäu¢õùA^#ZŸä5¢ôÙA^#RŸäU 1Z'Èëæ£W¡+´BYæí³ ¼ªBÇe%-(t†ÞƒQ^U¡Çoçæ°Æ7åb8åTH›ûÙ©qSjôºòü•»¦]5¹BtËalÒ'ÀëA5ñ,¯ªÐ"8R�Æ)U…vÀ‘ŠhŽSšeE§¤Í=[ -Hô Œ›{¶”b·«WêþŒ[mJM*vÀëAõ‹…–ÁŠˆÓ|l{€×(1C ŽùsÝ©æOØ×j¾Ð,8RóÏ‚ûª -Í‚#5ÿhôRUh©ù港55_h<©ùÇ3Žjjþ)a_#%¿öõ�ˆk¡¯m¤áïúªÒ6|i {Úôy¯Î?áaw)}SSúÏ‚« -͇#¥ÿp”ÓBgßHé7G9­*}_Qúg\¡µi¤ô›3.Ëá¿]í?%On¬.š”ú‰»G©wMJýib �»&�þp ÓBß®I¥7:Í@“RÊô²F<ÛLE¡·fÛ^#~:ìAŽšB—ªI™·G‡�µnHœôƒõ¾OµŸH±ûT»«©ö§�Š-ô ‹tûÃO =Ã"åÞð´¢Ý ½¸&íþxÆaM½·gíÓðû�b�ðÓºVE -¾1Nì/"÷Ëd«ÛªS~zì¤öOôØ=j¿ÐM,RûÏ[h,iýGàúŠEJ¿9|l¥è½Ð±kÒùg[-üÚœmÛ`#�¿=ö M¡¹U¤ó[£ÇލŒój¨�½9fì�Y£S¡¥X¤ÑŸ4– -íÅ"•þhÐX*´‹tzsÐØŠR§BÛ®I©?žqµhk{Æmkù©õ=h»Ê€$ŧ€N¯„Ñmj� - ®"µÞm7kù0•±¦±ÕñS;Uý Å»CÑ×"¬OƒÅK…¶c‘¢4¦,úŽEо9¦lUÑW"¬�g\¡µT¤èÛƒñª�Š~ï1Ny*ô½Š}c0Þ¿ÌilÙ{ƒ;ÓhN„Þ]J¾Ð{,RòOÑK…6d‘Ž0Ø,º�E*¾1DoUÚ{Mþál«F\›³MìÔï{`z�ÒïÕ kk˜Þ¬kF; "öîQðÕ¸ë³@öR¡Y¬á >6Mļ»Î¨Qnãhd7‚‘‚�¶1ã{©mñU…é©ÀQºx60Õ‚¶”��ÝŒaÄ/©¥³Òñ…ºhàš9²ÌÔ®~nøR?ê& rŽñý�þ£úaÿ•7·I`$nx kç.5ÉNÆWˆáë7�P±sÎúî;ý ®{ÉáAýp¤¬m_H+€ÈE²âÕì»Åñ\®Ô°ÓI°£‹ÇZ!¬@�\ö`?ÏpÁËÁïÙ',. -ˆâÏwã¨›‘ü%º(^3½‹žA\žÒ¥¿|ÞÅïo‰è1bxþ–Ùݵìà-Ëpüuíìf¸�cÊ9#�SÉåð‰žeª»ê -Yåÿ<*e¼Á_{3ŒØç̯ß�(¯»¯OR` ?Ñ_¿žÑ�ÞÅ?ÑßуÄð²îÛï–X÷Ý·ä?]þýB—?ýði0(ˆôÝ¡ö]É6)µEîÒqqn›48Ä&§�I§ä é®ÇJ]‘"0d‰ÔÂL Ï&ÍÜ÷ÙáøCñ¼˜U„ðAù”™½XÅ�Õò›ßÿùý÷_ýËû—b„ΰÎ) 禨ȕFï·G*jN`�˯4mçäAX%±Ñ;ÍúAp5Ê ]X•’ÚË2ÅGž*6E %°Võ(�7 �Fo‡`c¡ô¤U§u¦Á6Ó` “Qɳ‚@Ýqlïvì. Pg& K‡ßR÷Zôü.qT”‘në<¼vø½Œ‡ÙX#¤¨2—ÚM,êªnqþçô{ýùùWñCþK²’U9Æ=}FÔ–F!ÛN;Pœ#Rfâ�„ÿ:Û;úÿ¿¯l*“58›á`HïOb‰|Q 4Ï! s$"Êf@òý¬N¢ªŽmÅ#!8­ñY]¬rŒy$^ •ZɆ l‘}Mç}MÐ×I éhAÒî^µè[¡«’m8*¼—®JT0d÷”5d…•…[¨»¹¢¤Þ$à“6~z›Å«ª¦)ìò^£  jóK°ÐO =ßx‹n½×&‡¥—jKH4÷š?Q)¤Fb)áÇ€]fEs&žsºFja#×D— ßœ›y?/píï¾ Ú1Ö<áQɶ°ä¡@±/‰UzŽh[µÚ=’X¥§9�­“X =ÄB«t¤b-Ó"‰u — -ýb³ *$jE2åÄÖáü0ú«Æìèk³+ÒQ ²¦Ic, -Ž)4S¯C Iál¤áoj<ùÖL¾B'-¶ž�±÷¿ÏMîÑé -^&»;[ï²âTO�Ýè×uý¾ÚDôœLÆÌq<«€3n¼­w3Ï-{+#Û¿M‚pBš®Œd‚>Ù*;Œ§à0�\ºãÕý(?#Þ+–5¬dR­sƼŸ*æÍ%4]d¸[ÖÈxÛ?£Þ‹<3 êxFFh¹–ggà»Â½3ô½ú.5"”òw·îjÁïYà/8¡,¢°w`T½Q£·R­' §tk^MMè}½rÒ e'ÈéQ{³‚[JYðVñjת|*õ]…¾˜|„³N°jÅó«T•«Î´v†Ú³ëï*„•âEœµî•k>E‡É馣í—õðF8 ›¼‚ãÅ}5Wƒ«Û…†›è (¡`LæU2¼ÑÊ[^ÿ›øÝJ‰Myöͬ@/~éÞÙóóÌ0ÞŸ9Æ@3®á�¬h1� %'Ü7àPÑe!äN_&ã+ºçõeÎ líË,4Èœ|™J³•ïZø2/ 5÷´Æe9¨‰×ÕÏÖ˜…–›ÓLAòÚýœ™=xaü#+8 MACfÄÿšÕ— ÚSVu™®äG” ¾S‚D¡OhH�ØOØu_ú¸÷ÌšžÕ¸i+)í¸yPyäY¯Ìs¬¤‚‰hp °ùRÊ“e§P{mÌGG`ÓòÐåThh‰ÜL°ÛÐî°œfÙé! -WSO¥^—A -Á®žö j@wx%ñ«…µ.ÖN'õ×_íÕ5‰ð¥fš$@ ‰wQ‚?�7Û/xaª¥©¥¦–Æpx„¼,*ÕûR"8‹le¶š_ùlJ“Û'{ëñIƒ¶�='�2�,Ç/4„ä\ßÑWä»I™kh¡¯iJ~ÁH±†“ù�¹ÃüÉ�À‹žÒÜo ”é°0+i‚Â8eED³oÒdZ»iv¹“¨ÛϺˆ™C¢ú -âÔc“ÓÞ¤öK$?‘e©ˆ«Q,“ºKüÇà|»mZ6…ü’Ò ÐwLº.õ„´ -„ÕKê²ÄÃÍŽ&¡A*TN?­§I¨…�]MºÐ@3¸š¼BR®�§éóLù�+#À9vvØtx̽F[%$h:D¾mRf>ûqœ¢6§9g;ãçºóVѶF÷8Õh*ØúPShÕ5}›ÁtÒV -4.»üÜ2vWQ;K¿Øû”µ)èeóJi[¡8d( ’b¢Ñ”­8²t¡éd]©oÐÙæ7·Œ¥I†ç€JsîÙKíf]è¦Ê9vÆéýSà¨Ö:ºÐГñ9•S2Ñ[Gy¢a™(C-¹8Z‡j™´BOÆX¶Ö -ûœ+4òdg†Ñ­òŸ[•d ¸Ž¼ÆòÏÁB·�,1cüTmJÌ-?-%Å­šÏ‰™?t¡>,ø²Í¨¥’(d†¸”–•°¦ Ët¡U㤗­‡<Ôò,ueà 'N〞¸±GóôÞ’Á¶! 6t+ï�ŸØÚy\èñH‚FÃ!÷ûÑ­º¡&S]'ó#dÊ씹¶ŒÍÿȰb¡%%K;òȃUÛ5^yÊ™5@O_and:néMùZ†—¸×ì~¹?lÍv‡•ž×ØŽéuL‚¥.4î$Ëm½ÕO1¿*óªÐ®“¼¥ oà­æÕ -ç`¡]'y ä!¬I=œ.ô³Ô’a)¼k¾H÷­'- xá÷ikâ]O8FMcxþ0ºq9úljÉ0óžî±œ²®àQáVÁŸðqu*s¡o¦6Åhî½ÐnÞ‰­‘´#û½'…®má¬lUßZü¡[x©ße]cL?#W¼ßë^êwn2+Qí'l `» G³ÿ;ðjÌ,ØHF�EòíxùO·œ �!ÉX°Æ°ê-‘ØäT(­²8—h§Ù¯ÆB=íAO‰œ¼ÖǼBë­é˜‡ -ŒaÂîvÌû¸<ª²$];8 Dâ—¥lîgÅ#èî81Çø ù1d)|<|?«¬!-+“N -pœqÛd‘ÿ§ÙÆ?Çf+.­(.¥ªèÞsxM›è‚?V3«�n7+®ªhKþ2ò)ŽŽå~Zubý=ÿï·Ý§k/Sð‡:î¶Å ¬©XC¤´vf�‰øíË+SìÀþyI’_/ò½_#hªLyÑ•«=‰ §N¬T•†kºÐUª3�¬G·ÿí}0ýÓÜè·9ºVÖr0q$' -ãëäÄ–(ç‚ö˼Ñý 3Ç,Ïã” ÓŒµ«ÚàË«�‹á}Ö'@,sxö�Tñ¾]©~W`!êBs-ò w/‹×­Í°ÁòvjhHºÐ×JsµÁ;ÌŽ4kçªÚ]!êB Cíå}ei8B¥u¨‡Òê¢ÜkzäÂÙØûcb…õ  ²l)ÛÎ|w|RéÌäžа4 ­õ–z0òøF‡þÍ鳜`Ûý»d4ú†)ïGÒœò; -4-(¹(¦ß&# 5´ƒ Kæ -é1´ÆûüÿI¸%ë Túêðc¿»}Sþÿï¯ÂÎåY 4TÖI¡Ú$F¨’œüÜD‰BKZX¦ ƒ"š–¼/¦>~(ûcn^Ú³I²aApvÃUèüñ�VÄ¡òá°åŠù:­…ÀâîÖ—ìF½Sç�[�ÓÓ³vÖ4lïKè€é7ÔÎè¦!Çi£¾s˜/âôîµîNJÑ’QXüÓH:�¼÷w�ñz‹Ëc$•õ¯Bõ �ª�é‡> -ONªá 0î?r4¥ž Fù4¸�V²lÊIwÄdå·`¹¼/bèDäþiÚžÈ&èˆÜ=5ç4^Ÿ”én¥–]°†h.‘‰£6�»[ÛØÑÅrn ÛܤøS²ç²4."f•ê«áÜŸŸŽÂi Çf\u‚ºVY`åCõ\VÊS]á©’`4¶Êü¼ÀÂ÷ÅchÏ ñ�Ú;™ÊôfœG’²ÙôŽcϯ§®ÆåVïê_í}lEF(@zÓë冇â|®Íñú6Ô¬#]›,�l×t@UE:»Þ­ç£Î~¸��OÐôn#ágÏ»u«J�Q™ž9;Þ=UÇ;�]‡o»%€Š×ÚÙñî:ϼ°žÕ†¯’ºˆ³ãÝfî�ï–:ÞéB»sÍ–¶ºƒ5w(ÜŸ&d¥¾uË=m®9'-§næäi¼¬ž §ùòôæ iPFõkà´^Ö²Ì]4^ꇵÓvYäÝiº,›.¾âYŽ×å}Ö§ÒÅx]JL¾!£²Æ˜JD;Ù¸=RÈW.Å‘)*X}ÅJT„_Ñ«f•×Yëöè^œM–öÎ"x©î¯½f)”Á·�5»ßs…*e1k…P+ +4°ÖJ€uÒRká”[1Ïd4ˆà§•·(4¡žf˜e£�g­4û|òdÁòJ6Åfé·µW•}aÐ�°ðú"Ï©­½VdhG©äSA -Ž˜.kÃ…>ÉZx�¼ÝUÝð“˜Ò�úY#·PlÝ9<µl.‹UÉ…>ÄÿBe÷¸Æj“íS'm”5ùùô¿ÚkÔ6Íï“ÿ=t1+ŠµÙ¨ãÒœá¼ëCõôWè<-yM ½lWB`×A¯„Cb” -¢×„škÁ.^ïíî7¼:Oÿ¾û_�¼Âæ/”dš µŸ'ƒrÁJOl�¯÷%kâìCŸùàî—ƒ^h®rÐ5·i$�‚EY0ë_Šs“ëCñ¬šÀÝ¥9aÊGg.ÿ¼»•Øüýt9~K.#-ÏÕ‘�î_2¸vÎ †¸‹àe­kuJݫôPÄÐBàA³bÜb›öõô‡6"®œ8§’ò¬^eÐIúj˜§C¡EE+–ºh1pRâ/ÑU1¨2Üx#æ®=2Þ¼�¤ëR6Ýs!©Š%‡ðÔ#Ò?¬5"]¬[¯,¿á÷.µit™~}÷„ª- ª°_ �ð„lÂÿù¯Ao�ÙŒ¡f�Oñ$ï9µõ2oÉKRïÁ¬X9·çIÑÓLê&Í?†éU˜XYxh®Ç¯(+âÙ4ÿï�¶ô·Ê°º?˜Š‚ò]t¾‰þqz•…¶2�-r? KOÖXw¬\ÿ ÿïÛQCÖ^²€VÅ]‹ŒÓzÿ[Þ–žU‰-¬l8ƒÌÈ�Šk<Ð…N匤`uî!øqKëýi¿‰¤ªTí�Û[0/³Á”ºž‡éoúß;ô>_*ÙØÿ¡Fw²Sjð‚„ÛOøl¦Ð±›¤O†‘Ø -6Á_‹�±²ö}‹Ë'¬Ç Ž<~Ëÿê1; +S¤CÁ&¶ê´lK3l¹Ru­¼¥ä³Ä ïÓÎÚ®©eóp+#Okeíô<­•ç·V¤b=¬�ÓZYÇ3"¯ ÆJýxvÚ*K¬;M•eSeÑTÒƒ´¾S±mL•¸üÍ¡ƒ`8�éÌ…¾É�¬*pF³M {}ƒÀ,GÝ”ªø-µ-íöN£+3solÇ™Dᦠ+E¤ ÕqÊJž›GïæO{¿r±â +VT�Ë#Òš$[ËåQvê­ÓŽÝª†u¥¼…ŸßÄd‹BL)ËåJ!&4†¸¤�µ™ã;+ ¤Òw^ ¸fYå*Å�ÆwÑHJ°�¾¯v@­¥fôižÍÊêL(•FO�š•aG\eGºú‹EmPv£§­¼äð¾Kèé¨AVƒ]y8¯4¤É ®N&‰¸øZ°_0tìÐSôeœ )Ô˜n¶R…Ù9C¤mÆFÑ›�ù¬âK=0ß4B $D/’p½ïRk äy‡8šRN¢îx.wÐI¾;—<žPÏ;ý°/Fƒ-ÀŒVt‰1û'€÷œÜnú¨08Jü�Òýò/zŒô™ˆ¿LçqÂêWz Ó«»35nµ9YKYé\5}WŧIŒS¶–`Qü�¼8åjù¥Íø<ÇÊ +‰Ô9w8r'eÕsâÖ6×QÚkë¥ý#=+’¨å½¶ž�¸ ÄVk°Rh{J}«Ô 9îÚ‚˜ÚTê¿Ü$r£��ÑÚO‘oyÁ)d t©…mþ«M·¤²Ä[â)ðM/¸Û¸3�²íûÇe#ƒJ¥&ΔðͰ4ü}+€ÔïSó³ÜjtURg†{º9ÏÒXódTY&¯b“®1™[ tÁ®&LNPX#Æe ¥F×)êCöúËèÙoËh° +¬½½WSK‘P㵩ðZ{Åx€ ‘×Gó€ *t$ˆônzù\¤¸yÆ‚fH­ü”®ù¹H (µtÍøx@”J{dt³vÚ?ꚪ”¯jG µÑÏÑ• µ¨-tGà…o Aus/®µ®ÛA4×ÊÖ0UÖ˜j5•†'¬f¨©Ðl³N«3ÆÒ*n̺ÖÞbÎï·lÚF¾fãÑXc]×íÔR»ˆ)–Û|¢šÁÍðžpà2[ŠJøUi›wسéO²®q[Õ¸­Y£šûF¯¯÷Ùë7·]åž„Pc¢ÅîFÈ'%ûÝ�„®Ë´" + ßšîñî6�âÝmº¶¢é±a£š~·á²»‘×e¶ÙÝ~’¬ªÕ1TmÕ¦záô (ï²â?×%èê¼Ô­™z«É`kJƒ jw6øñÚ ®ÆUn”;Ö 7©ßWµ¼�ã“Ù _.œúCÊÌ‹ Y9 Ñº=·"ÀW}�«è9½]Ú6\ý|!Ù#³®¥-ûfpôïW™eÓ +YtÒŒŸS›¦z®@Ñ%}73ãŠN“º±ôókVþ °ªbö Ì®ü^¦zšà„Ý.Å0kÊöz™Á¿Êز³c�ž´ú´²3¯a­qf*i²Z0¦ã)>SbƒQ•Ć„ä‡Xf†*™ 9Ú3ôõ¾‚sm[Dº’?ð¤«ÈTp³ž`Ù +nVóUô¶BXÕìè·ÃÓÔ7W7�#rOÙhÀ妱,�p²Fyé#jç¥5�S3 Éw•�%Å×4 ð>£ƒÓ>UÿBm´¥/ÐÈ>%57Ø’®û»™PÀ½,Œ°p7F;)Íð» µ¦­4A"§Àu�”æ_&gÓÚŒ¶¥–Hœ•Ê¥t>DSÚ‚§<2ÄsC6–Ú籠Õ|Å䈫²[¡(Ïû¨MQáìt�¸Ã¿,W2ŒÂIQÎ�Ùù™/%Ü©h‚äT SÕlR541h�@rO jtMÕÄt>FÕ˜šªiÇÆrvtJZÍÇ̤yM­Ú>޾ÌÁ÷»äºÙXg¹ÂW�FWkº¯6÷j†- ÆQß¼®a×ìÔ�™ºÙQææê,m¸QHÚ‘ô™j"IÓœÀÖE‘Ö/EY0ʤ?¬*²˜,0jH±?™·\Siéä¶b<»fXœ[m[æ/YMžÑ}úü%§½æ�´ý0M_î éKÃÈzá´ï³—†›“Ô„~z¨?6ýh¸Õï­á1ñÞ:ÜÓy�ß[šD®`Å[ ¢cjiÝ¢6Øt@·¾áî¬wTJjÉ1n�/¬¦~œÚå”�4vœØyõ¸˜WÌKUJ¾Ý©*IÙ�Û* ÁJòºwòM£kGbAè¡–üé‰쥖Â~ +Ä*§…z0>;±Æ€uŸ©ä@†ûhEž„jbµç�0G).’v"¶´ õ½uZ�Q[w¡õ ­uZ�PZ÷¡ô�uR�QY-i G> ¬‘í�½"Ç»ãläÒ³—žM\z¶èÒ³s—ž�»ôô\z®’¸@ +Ár¶iZé/ÆàkíÈQj êG�^LæC:0ºR²�½v\ì誀0¸‚#TëqCR +PÚ^5qF…<ÎR£¿åØiÚ®hr÷ítý+ ÒP»Þ¬ÊÄ6š²à¤×ص;pá/SVF¸×¥e„Q’—î†5==6¬øéw[ª‰ +n ¡£U‹žè·ª [S1™�Q®¦&Úq1€¥UH+Áµˆ!Ýêñœó%d V!cPµçÜfh‘QÕJ†\ÔYkHu®deEßóy9p“)5 –V°/Ãt 7ìµ+±ß‘ û;‹l�ÂÝÿ·±~¤sÉ}Qö1ެБqú¸§B¿U¡ûšÝ×Á"ãvËà0…î«v_LæcÔRÕîkÇÅ +ÝëšB<çLM¡·æÜ‡�ê¼WÂf[4”ÙgÅó·is[Óæ%þ¨ÍçÁÃÍHª£.—ì À†�†ÜÊÜU”¹Ð€J +÷xeîkÊ<&ó*I QSæí¸x]™+!kÊüñœÃš2¿7çnWçÁ¦yð÷µÎ•P5}^bá¡ú|È¥z{dsgxèð8uúm:]‰J®¥ò„ôWéJèŠJ�©|Œ^2�ÞŽ‡kº­(ôÇóÍUôys¾!íTç‚û"HùHmî+Ú¼ÄÀc�ó¥ÆÑ;Kƒ•'PÒ7DÏüQ+tY©ÓQÎtÍ�ÍÃ5º”5�“ùÕ$±¦ÒÛqq…N—ª¦ÓÏ9ª)õæœ;]è¬|pT>·ªu%�“SG½F7ªu©kj½ÄÂõú«L™§¡cÒNï4Hát»RÌ·Š¯DI•µ ½}x�TÉZ�4¦ò1jª#mÇÃ5ú½"}8ß°!mη�7&í1ÃZ»³vÇZ€´ÄÁC�ö{âu¬ÍUZˆ¿×|·Ìm‹íÀ…̉r ++SewôíÛV=T¹c-`š�ù-U ˜6äb@ÕÚ©¦,·Â¶}}Ûc" +«Fh‰…‡ê©Ød´;?îÔIÆwó>­Í-©fmjîÉL=ÐÁc5RÕÜŒÉ|ŒFªÚ›í¸x ÷CaÕÜ|8ßTÕÞlÍ7>èîÓ䯀v&mU~gM^h¥iò �µ8Óö2Bíõh dÉžÚ|“6¯5ZWäÁ•CU楶ë“2�¨|ŒNªZ—ÍxxU•—ºfOªüá\«¥â5æÚowjqmA�*çæXŸ#­Ä¾YÀ4ºU‹×2ñJìk¬Ä;¶ðcPùqjž +ýV…^IÊS$ÀjÄÇ{ƒK}z#�‘ùåTj)©ôf\  ùÒjIyOÀ¹ZR^{ÎeÝxSÒTM§“)È4ke±±UâyëÒ*¾Ø©Z•¡Ï\ŠMºµÔø3èV%A�µëÕ­¥Î™“n�É|Œ†¨¦Çµãbß0­BW59îñl«fÇÝ•m·ÌÜÐF÷ZçA¹q¥&�“½\bß�ó·qâÔwiwÚ¯jz ŸÚüVm^j†´9"7�}8…*5—œ”yDåC”R©ã¤Ë›ñðš*/5:œTùÙVM‰kË´¬­ùíšœ[t�Hé[�1á"lž0¸Q‘—:ûMмÀ½c+VFØÒ±xèÔs7Μ8NÍ 0ã„=(nÕòµp%³XºÇG+KM'-Qù…U V6ãáú_W¥†“®’ +ȶkh0[CCÒ1Ý#=Á@C2øçÛ‚w`¸Ùæ'òˆý@^±ŸÈëHì'òˆ}~�×@ê'òhý@^Ùµª4Zý €¼F´>=ÈkDëÓƒ¼N´>?ÈkD듃¼F”>;ÈkDêÓƒ¼*!&CëyÝ|ô*t…VA(˼}”WU踬¤…®ÃÐ{0Ê«*ôøíÜÖø¦\ §œ +is?›"5nJÍ�^Wž¿2`×´«&Wˆn9ŒM:âxÝ£"¨¦"žáUZG*âÑ8¥ªÐ8RÍqJ³¬è”´¹gK¡I‚ž�qsÏ–RìvõJÝŸq«M©IÅîx=¨~±Ð2Xqš�mðe"f¨#Á1b®;Õü ûºCÍšGjþYp_U¡Yp¤æ�^ª +Í‚#5ß÷µ¦æ í‚'5ÿxÆQMÍ?%ìk¤äwÀ¾q-ôµ�4üÝA_UÚ†/-aO›>ïÕù'<ì.¥ojJÿYðaU¡ùp¤ôŽrZèì)ýæ(§U¥ï+JÿáŒ+´6�”~sÆe9ü·«ý'€‡-´\�4cxØ¿‰óÞ§äÉ�ÕE“R?ña÷(õBã®I©? @l¡qפÓtZèÛ5©ôæ@§hRJ™^Öè�g›©(ôÖlÛkÄï@‡=ÈQSèR5)óöè°³Ö ‰“~°Þ÷©ö)vŸjw5Õþ4P±…ža‘n8ài¡gX¤ÜÛžV´{¡פÝÏ8¬©÷öŒ£}~Rì~šBתHÁ7ƉýEä~™lu[uÊïC��Ôþ‰»Gíº‰EjÿYàc �Å"­ÿhÔB_±Hé7‡�­½:vM:ÿál«…_›³m,c¤ñ÷ Çä¡)4·Št~kôØ•q^ µS£7ÇŒý1kt*´‹4ú³€ÆR¡½X¤Ò K…öb‘No[QêThÛ5)õÇ3®mmϸm-"µ¾mW�¤øÐé•0ºM­S¡ÁU¤Ö£íf-¦2Ö4¶:~j§ª?¡xw(úZ„õi°x©Ðv,Rô�Æ”¥Bß±HÑ7Ç”­*úJ„õñŒ+´–Š}{0^µSÑïã=Æ)O…¾W‘¢o Æû—Y"�-{opg͉лKÉz�EJþI z©Ð†,Òñ›¥B²HÅ7†è­jøBs¯IÃ?œmÕˆks¶‰�ú}LïQú½tm Ó›uÍh§áOÄÞ= +¾w}È^*4"‹5üƒ�g©Ð‰,Vñž¥B‹¯HÇ?œqÕ¸k{Æíõ“i¹Ç�±S¡ýU¬å ,lS•fÆ”bïÒî…Þc‘vÐ`*ô÷Š´û£Ño©Ðt*Òî�Ño¯h÷Z„õñŒ«†X›3NÉ�Ú}rðI5T臩öƸÁ?+{âƒG~4ëéØZ×ö¸Â?fØ*ô(‹4þ“ S¡ X¤ðŒ‘K…¶T‘¾o‹‘û·;UÖˆÜcÒB¨Ð0+ÒZ­Ar•N*5ßî„Á• ®P`­£Mé6Ò"x©”zç�#)ÁRÇÔáj_ÀérN æù§,“¥¨[1|)*�ž" +5˺æÝpeGÂú‹EIÀ¤»ic%Pƒ°‚’“GGj¦‡Å!€4y!½I%-.¾–Ño_Œ*g÷¿/žG¦R®Ñ-eâ¤ÑðW[€TÒ$ÌïãßYø&—àUôŸ^žjè$8ïeºDnÐ|´]´+E¥mÈ^Ðy )nÏŒ1¢·œX�Ya˜ %ÆûÓil¼ÕÆÆAroNóøÄi_°å¶\‚F¾çhAàGnË¡L=_ YÉKJq¹#‰`´å„âv[ôO+[t©! �0VaK†Ž›Ì2.•º‹iÞä„Í8×—læ]×±;fTŠý_Y© ™EÞ¬9‚Á†­€E-µ\GB¥dÖ9«[s÷넵£e¡“»çû2qˆ©lÚX€‚õ�êÔ±’‚ØÞ† +m×JÐ=}¥ÝìèSêë |/Ë K©-™§¼ñíW§ÈŒ¤[nÈ–µ^›·fËö‹ö¡ø¿<µR.Pe‹·huŠìu Ö®‘¬Lsܽ>f Ál!êCV3Áy¼ õ`¸ÂC¹¥¶j–@ù²¸Žm<Ÿ¥Æ2«Y‹ÀÚl+å +(Ôw˜n‹ bµkŠá�-™}3�xa‰ÁÀÁatëL(x|…;Øz*”›ïþt4‹R#$ø +«s£à$&hX¶ÙÜ_'MóH ó•Cš@Âú'=£>Ò¨”k:LNDÛy.¢›žØë&@iöUtƒWÝèÝE�7˜�4Èn²öwÓQÿíq$ÀH�–dt®¿~ðî"Aé¬âs^÷Œîãɽþóoúu(@ƒÙ¨ä¯ +*�ÖÜÊȉà†w9—rÁ{cq¼Ñ³ubQ?_ò:ÓÇǦ£‰˜w×5Êm�ìF0RðÑ6f|/µ-¾ª0=8JϦZЖ²²›1Œø%µtöb@:¾P \3G@–™ÚÕÏ _êGÝTÎq ¾¿Óÿ@xT?ì¿òæ6 ŒÄ d­àÜE¡&ÙɘãÊ1|ý&Ê#vÎYß}§¿aÀu/9<¨Ž”õ£í+@éa¹HV¼š}·£8ž Õv: vtñX+„¨“Ëþìç.x9ã=û„ÅEQüùnÜ}’Wu3r˜·DÅkÆ£wÑ3ˆËSú¯ô—oâÁ»øáý-=F Ïß2»»–¼eŽ¿®�Ýl@7pL9g¤q*¹>ѳLuW�B!«œâŸG@e⯌7øko†ûœùõû‘åu÷õéA +¬£á'úë7Ã3úÑ»ø'ú["z�~â@Ö}ûÝë¾ûö�ü§Ë¿_èò‡À > ‘¾[#ôϾ+Ù&¥ö¡ÈýB:.Îm“‡Øä4� é”|!ÝõX©+R†ì ‘Z˜éäÙ¤™û>;(ž³Šƒ>(Ÿ2³«²Z~óû?¿ÿþ«yÿRŒÐÖ9%áܹÒèýöHEÍ ¬qù•¦íœ<«$6z§ÙA?®Fy¡ «r@R{Y¦øÈSŦ⠈¡Öª%ðæ`£!Ðèíl #”€ž´ê´Î4Øf d2*yÖ}qU¨;ƒíÝŽÝ…ê̤ábéð[ê^‹žß…#ŽÊ€2Òm�‡×¿—ñ0k„UæR»‰E]Õ-Îÿœ~¯??ÿ*~ÈIV²*Ǹ§ÏˆÚÒ(dÛiŠsDÊL<Ѓð_g{Gÿÿ÷5‚Me¢g3ŒéýI,‘/Š�æ9tŽDDÙ H¾ŸÕITÕ±­x$¤§5>«K‚UŽ1�Ä+¡R+Ù„-²¯é¼¯ ºàz" $-HúÀÝ«}+tÕBR  G…÷ÒU‰ +†ìž²†¬°²Ð` u7WÔ‚Ô›|ÒÆOo³xUÕ4…]Þkô´Amžb ú‰¡çàoÑ­×àÚä°”âRm)Iƒæ^óç/Šç¥ñÜ"ëñ®ômJð(]^ª3wXÀºG’eU³ +-°¦�EpCu¢Éy··>ÚÕ2ƶà‡Ú LB ôœX¼÷ Ö'…ÔH,%ü0¢Ë¬hÎäÏsN×H-läÚ�è²á›s3âç®ýýÏT;Æš'<*Ù–<(ö%±JoÀm«V»G«ô4'°uk¡‡XHb•Î�T¬eZ$±ŽáR¡_l¶A…D­èO¦œØ:œFÕ‚}mvE:j¡CÖ4i,‚EÁ1…fêu¨!)œcƒ�4üM�'ßšÉWè¤ÅÖ³1Vàþ÷¹É=ú!]ÁÃËdwgë]Vœªã©³ýº®ßW›ˆž“ɘ9N€gpÆ�·õnæ¹eoeä `û·éBN(BÓ¡‚‘LÃ'[e‡ñæ�ëBb¼ºågÄ{岆•LªuΘ÷Sż¹„¦‹ wkÀoûgÔ{‘gFxAÏÈ-×òì |W¸w†¾CߥF¤Â€RþîÖ]-ø=kœÇ¨—"Ù/RÌòV£ç‡ß¬ÀŸã z�w°ç»÷ªÚç'”%@öÎŒª7jôVªõ¤á”nÍ«© ½¯WN¤ì9"joVpK) ÞŠ#^íZ•O¥¾«Ð“�pÖ ÖC­x~•ªrÕ™ÖÎP{vý]…°R¼ˆ³Ö½rͧè09Ýt´ý²Þ§a“Wp¼¸¯æjp•c»Ðp½%ôŒàÀ‚ɼJ†7ZyËë¿[)±)Ͼ™èÅ/Ý;{~žùÆû3çÏhÆ5’-¦¤ä„û*º,„ÜéË$b|E÷¼¾LÂ9�­}™…™“/Si¶ò] _æe¡æžÖ¸,5ñºúÙº³Ðrsš)ˆ@^¡Ÿ33B¢/Œdg¡)hÈŒXà_³ú²A{ʪ.Ó•üˆ2ÁwJ�(ô û »îK÷žYÓ³7m%E¢7*ÏCƒ<ë•yŽ•T0 6_Jy²ìj¯M€‚ùè¬`Zºœ + -‘› vÚ–Ó,;=Dájê©ÔëR H!ØÕÓ~A è¯$~µ¢ÖÅÚé¤þú뢽º&¾ÔL“(!ñ.Jð§Qâfxó/Lµ4µÔÔÒ�Ѓ—E¥z_Jg‘­ÌVó+ŸMirÛÂádo=>iж³ç Sæ‘åø…†�œ+ã;úŠüo×")s -ô5MÉ/)Öp2¿1w˜?ùxÑSšû T¢‚2f%MP ¬hƒhöMºƒL‹b7Í.wuûY1sHT_aX”zlrÚ›Ô~‰ä'²,q5ŠeRw‰ÿœïb·M˦�_RúúŽI×¥ž�V�°zI]¶ƒx¸ÙÑ$4H…Êé§õ4 U °±«IhW“7@HÊ5ð4}ž)ÿq…gÉq27Q*Þ#]h¶Äï¸nSë–5 ÁK–mšÕ°MâäMý»ð¿ùç–­ð¿¿K–4TüU�G›³áõ»yTWã å)u{ØKÐVëöŒeP±mKY”tJÎ4’ÔXkã§·jY'Ay¥µ~œQ¯ -Q"h¦Ï*ð®Y��½ðRêKSmئ/�Ÿ“ª.ô·ìÊ›¥4z/Yktë­K«ÞéÁk2ØŠ‹U5·Ú J !>ÅJ*ôæD£A+*2ñ)ÚŽ¥/P0n¼-ÉÚ¶Ó`žê1˜Ýþy+¾ÕbŽˆñq‹·&eSÁÑg8ÇÎî›�¹×h«„M§€È· mC +ÀÌg?ŽSÔæ4çlgü\wÞ*ÚÖ(à§M[j +­:á¦o3˜NšÃJ�Æe—Ÿ[Æî*jgé[bcŸ²£6½l^) Â#b+‡ ¥áCRL4š²G–.4#�¬«"õ-:Ûüæ–±4Éð0BiÎÃ={©Ý ᯠÝT9ÇÎX"½ +ÕZGz2Þ"§r`Jæ#zëèB#O4,e¨%GëP-“VhâÉËÖZaŸ€s…FžŒGìÐÜ�oµ#^¡‡': Þù$º +‘M}».ôÉD�`•tG0ðÊQCšÜèÁ´×7¤ð�[�„—Y>Õ +¨ ]êÉéøÚ²Úm¾É•ª®ˆ´ÖFGç}3zw ®Lê¯lþ) +Ɖa ÙªýlX“#3¾k‰Íâºcpîš�Éo׃ÊëRïKáÁ9ãxïuŠgg|Y /­º(ç¸:oƒ}®ùB¨ûøâ4ºÑ>/5딜—Ëìlâ· À2S|û øR+MNåaŸÖšbÕöTjÜÈxš;Z9†ŸÍto¨<˜9˜P¿¼’cs’ÐìsÉs¡ï� Dd¸äF¹‹õ†;[šÇ%eèB'K" ^»±ÝiÑÔfÚÜ^#Fù–(ï0Óâ~['€Õ@Îû]òW$)ϯÂçÌ0ºUþs«’¬ב×XþY"Xè¶‘%fŒŸªM‰¹å§¥£¸õAó91ó‡.Ô‡_¶µT…Ì—Ò²’Ötca™.´jœô²õ�‡Zž¥®lxáÄiÐ7öhžÞ[2xÀ6$Á†ÎcåÝ@ ñs[;� =IXÐh˜ ä~?ºU7Ôdªëd~„L™�2×–±ùV,´¤d‰cGy°Ê`»ÆÂ+O9³èé+Ì�lBÇÍ!½)¿CËÐâR÷º‚Ý/÷‡­Ùî°ÒóÛ1½ŽI°Ô…Æ�d¹Í¢·ú)æWe^Úu’× ”á ¼Õ¼Zá,´ë$o�Ü!„5©‡Ó…~–Z2,…wÍé¾õ¤¥/ü>mM¼ë Ǩi ÏF7.§BŸM-fÞÓ=–SÖ<*Ü*ø>®Ne.ôÍÔ†£˜ͽÚÍ[8±5’vd¿÷¤Ðµ-œ•­ê[‹?t /õ»¬kŒ‚éÇáa䊷â{ÝKýÎM&"c%ªý„­l7áhößb^�™É(°H¾/ÿé–3a¡3$ ÖV½%›œ +å¢Uçí4ûÃX¨§=è)‘“×ú˜Wh½5óP�1LØÝŽy€ƒGU–¤kg�Hü²”Íý¬¸bÝÇ!æ4?†,…/‚‡ïg•5¤eeÒIŽ3n›,òÿ4ÛøçØlťťTÝ{î¯i]ðÇjaÒífÅUmCbÉ_F>ÅѱÜO«N¬¿çÿý¶ûtíe +þPÇݶx�5kˆ”Öά3¿}yeŠØ?/IòëE@¾÷kM•)/ºr¢'ôôÁ‰•ªÒpMºJu&�õèö¿Ý!¢¦šý6G×ÊZ&ŽäDa|�œØå\ðÂ~™7º¿aæ˜å™c<‚dš±vU›|y5p1¼ÏúˆeϾ‘*Þ·+Õï +,D]h®E^äîeñºµ6ØBÞN IúZiN£6x‡Ù‘fí\U»+D]¨a¨½¼¯, §@¨´õÐÃBZ]”{M�\8{L¬°4£A–-eÛ™ïŽO*�™Üs¢–´µÞRFßèп9}–l»—ŒæBß0åýH‚S~G�¦%ÅôÛ$cd¡†vðdÉ\!Ý!†ÖxŸÿ? ·d��J_~ìw·oÊ?ãÿýUØy¢<‹�†Ê:)ôA›$ÀU’“Ÿ›H QhI Ë´¡bPCÓ’÷ÅÔÇeÌÍ B{6I6,Îî`¸ê�?¾qÂÀŠ84‚C>¶\#_§µXÜÝúC¢ã’ݨwêüqëñazzÃÎÁš†Íâ} 0ý†ÚÝ4ä8mÔwóïEœÞ½ÖÝÁI)Z2 +‹I’÷þÎá1^oqyŒ¤²þU¨>Rµó ýÐGáÉI5œÆýGަÔs�Àè!Ÿ·ÓJ–M9鎘¬‚ã,—wãåA �ˆÜ?MÛyÀ½‘»§æœÆë“2Ý­Ô² Ö�Í%2qÔ¦swk;:£XÎma››JöÜáB–ÆEĬR}5Üã€ûóÓQ8 äØŒ«NP×*‹C¬|¨^€ËJyª+ƒBɦØ,ý¶öª²¢/ŒžC_ä9µµÊ �â(•|*HÁÓeM`¸Ð'Y ¯ñ€·»ª~SR?k䊭;‡§–Íe±*¢Ð‡˜ã_¨ì~×XÍc²}ê¤�²&?ŸþW{�Úæ¯ù}2࿇.fE±6u\š3œw}¨žþ +ý�§%¯ ´—íJì:è•pHŒRAôZ€ÐBSb-ØÅë½Ýý†Wçéßwÿ«‘WØü¥ƒ’Ls¤öódP.Xé‰-ðõ¾¤cMœ}è3ÜýrÐ Í•Cºæ6�¤S°ˆ#kfýKqnr}(žU¸»4',CùèÌåŸww¢›¿Ÿ.ÇoÉe¤å¹:²ÓýËB×ÎyÁ÷b¼¬u­N©{u˜J‚Z> +<> endobj 414 0 obj <> stream -Typst 0.15.1en2026-10-01T12:39:50-03:002026-10-01T12:39:50-03:001application/pdffOK5WLGONesfRJIiwiITiQ==fOK5WLGONesfRJIiwiITiQ==proof1.7 +Typst 0.15.1en2026-10-01T12:44:14-03:002026-10-01T12:44:14-03:001application/pdfCJLc6tBfdOjtrdLwMNqm3Q==CJLc6tBfdOjtrdLwMNqm3Q==proof1.7 endstream endobj 415 0 obj @@ -1915,45 +1910,45 @@ xref 0000043859 00000 n 0000044073 00000 n 0000044232 00000 n -0000044677 00000 n -0000044896 00000 n -0000045056 00000 n -0000045829 00000 n -0000046048 00000 n -0000046188 00000 n -0000046404 00000 n -0000046643 00000 n -0000046797 00000 n -0000047005 00000 n -0000047216 00000 n -0000047361 00000 n -0000047581 00000 n -0000047833 00000 n -0000047961 00000 n -0000048043 00000 n -0000048646 00000 n -0000053208 00000 n -0000053289 00000 n -0000053839 00000 n -0000057482 00000 n -0000057564 00000 n -0000058273 00000 n -0000065146 00000 n -0000065228 00000 n -0000066017 00000 n -0000079094 00000 n -0000079171 00000 n -0000079611 00000 n -0000080253 00000 n -0000080330 00000 n -0000080773 00000 n -0000084719 00000 n -0000104318 00000 n -0000104725 00000 n -0000104838 00000 n -0000105911 00000 n +0000044687 00000 n +0000044906 00000 n +0000045066 00000 n +0000045839 00000 n +0000046058 00000 n +0000046198 00000 n +0000046414 00000 n +0000046653 00000 n +0000046807 00000 n +0000047015 00000 n +0000047226 00000 n +0000047371 00000 n +0000047591 00000 n +0000047843 00000 n +0000047971 00000 n +0000048053 00000 n +0000048656 00000 n +0000053218 00000 n +0000053299 00000 n +0000053850 00000 n +0000057595 00000 n +0000057677 00000 n +0000058386 00000 n +0000065259 00000 n +0000065341 00000 n +0000066130 00000 n +0000079207 00000 n +0000079284 00000 n +0000079724 00000 n +0000080366 00000 n +0000080443 00000 n +0000080886 00000 n +0000084832 00000 n +0000104457 00000 n +0000104864 00000 n +0000104977 00000 n +0000106050 00000 n trailer -<> +<> startxref -106098 +106237 %%EOF \ No newline at end of file diff --git a/docs/typ/cheatsheet.typ b/docs/typ/cheatsheet.typ index d7bf51ff..1291d838 100644 --- a/docs/typ/cheatsheet.typ +++ b/docs/typ/cheatsheet.typ @@ -63,7 +63,7 @@ Helix-style: motions *select*, then an edit acts on the selection. Mode box: bla [#key("|")], [pipe each selection through the shell], [#keys("g d", "g r")], [definition, references (language server)], [#keys("Ctrl-d", "Ctrl-u")], [half page down, up], - [#keys("Enter", "Tab")], [look, execute the selection (like #btn("B3") #btn("B2"))], + [#keys("Enter", "Tab")], [look, execute the selection (like #btn("B3"), #btn("B2"))], [#key(":")], [to the pane's tag and back], ) #doc("keys") diff --git a/docs/typ/guide.typ b/docs/typ/guide.typ index 3a6e5bea..7144c249 100644 --- a/docs/typ/guide.typ +++ b/docs/typ/guide.typ @@ -3,9 +3,8 @@ // keys on the cheatsheet. #import "style.typ": key, keys, btn, chord, word, tag, addr, file, cmd, doc, pairs, glossary -pardes reads the text on its screen as things to do. Right-click (#btn("B3")) -any text to *look* at it: open the `file:line`, address or URL it names, or -else find the text. Middle-click (#btn("B2")) it to *execute* it: run the +pardes reads the text on its screen as things to do. Right-click any text to *look* at it: open the `file:line`, address or URL it names, or +else find the text. Middle-click it to *execute* it: run the builtin it names, or else run it as a shell line. Everything else is where that happens: columns of panes, each a tag (a line of words) over a body that is a file you edit, a terminal, a PDF or an image, with a tag for each @@ -64,14 +63,14 @@ you out of raw mode first. btn("B3"), [look: open the file, address, directory or URL, else find the word's next place.], ) -A #btn("B2") or #btn("B3") click with no drag takes the word under it: the +A middle- or right-click with no drag takes the word under it: the run of letters, digits and `. - + / : @ _ ~`, a trailing `:` dropped. So #btn("B3") on `src/bar.c:12:5:` in a compiler's error opens `src/bar.c` at line 12, column 5. Drag to say exactly what you mean. #key("Enter") and #key("Tab") in normal mode look and execute. -Hold #btn("B1") and click #btn("B2") to cut the selection, #btn("B3") to -paste over it, both one after the other to copy. #key("y") yanks and +Hold the left button and click the middle one to cut the selection, the +right one to paste over it, both one after the other to copy. #key("y") yanks and #key("p") pastes after (a line yanked with #key("x") #key("y") goes in as a new line below), through registers every pane shares; #key("SPC y") and #key("SPC p") use the system clipboard. @@ -116,7 +115,7 @@ tag (#word("Save"), #word("Del")) acts on that column's pane with the keyboard, or its first. Every other new pane goes into the *active column*: the column you last -typed or #btn("B1")-clicked in, or the one that got the last new pane. It +typed or left-clicked in, or the one that got the last new pane. It takes the keyboard, except a listing, which opens below the pane that asked and leaves it the keyboard, so #keys("n", "N") walk the listing. A look moves the keyboard but not the active column: #btn("B3") on a file @@ -153,7 +152,7 @@ pane is listed in `+Unsaved`. The same #word("Del") again discards it. way. A pane with nothing unsaved closes at once. From the keyboard (#key("SPC d")), #word("Del") between two panes also asks which takes its rows: #key("k") above, #key("j") below. To quit, press #key("SPC q") or -click #word("Exit") in the workspace tag with #btn("B2"); it refuses once +middle-click #word("Exit") in the workspace tag; it refuses once over unsaved panes too. = Terminals diff --git a/docs/typ/reference.typ b/docs/typ/reference.typ index afbbd899..0f9a9341 100644 --- a/docs/typ/reference.typ +++ b/docs/typ/reference.typ @@ -163,7 +163,7 @@ read-only, 0222 write-only. = look and exec -A line written to #file("look") is a #btn("B3") click on it, on the line as +A line written to #file("look") is a right-click on it, on the line as written: its leading blanks are its own (` return x` finds that indented line, and a diff's blank context line ` ` is a look too); only its newline and `\r` go. An #file("exec") line's blanks at either end are @@ -186,8 +186,7 @@ files. that is there but will not open fails the write and is named: `look: : permission denied`. A zero column is refused, `file:0:0` included: columns count from 1. -- A whole line of a diff pane written to #file("look") is the look a - #btn("B3") click on its first column makes. The line is matched in the +- A whole line of a diff pane written to #file("look") is the look a right-click on its first column makes. The line is matched in the pane from its cursor row on, wrapping, and the first match wins. - On a PDF pane `:P:H` is hit H of the pane's search on page P, as `file.pdf:P:H` is; a hit not there, or any H with no search active, is a @@ -211,7 +210,7 @@ it opened. A look of `file:12:` reads as `file:12`: a trailing colon is dropped, as a click leaves it off. A path too long to repeat whole gives up its middle to `…`. -A line written to #file("exec") is a #btn("B2") click: +A line written to #file("exec") is a middle-click: - A builtin word runs (#file("/commands") lists them). A builtin that needs its argument (#word("Msg"), #word("Mount"), #word("Find")) written bare is @@ -423,8 +422,7 @@ may lower the contrast of text, the selection or a focus indicator. build embeds them. Resting the pointer on text for about 32 ms (`look_preview_delay_frames`, -2 frames, in `src/config.zig`; `null` turns it off) tints what a -#btn("B3") click would look at, with no other effect. A terminal's +2 frames, in `src/config.zig`; `null` turns it off) tints what a right-click would look at, with no other effect. A terminal's #word("Filter") keeps each foreground at least `tty_filter_min_contrast` (WCAG 1.5, `src/config.zig`) against its background. @@ -718,7 +716,7 @@ back as a record: run it through #file("ctl") instead. == REPLs `Repl python` on a terminal's #file("ctl") (or in its tag) binds it as -that language's REPL: a #btn("B2") click or #key("Tab") on a `.py` body +that language's REPL: a middle-click or #key("Tab") on a `.py` body then types the text into the REPL instead of running it; builtin words, tag words, `Exec ` and #raw("@`cmd`") words still run. #word("Repl") takes the languages a code fence names (ada, bash, c, c_sharp, clojure, @@ -854,7 +852,7 @@ starts a separate session whose shells do not forward to it. = Placement `Placement acme` (the default) puts a new pane in the column whose tag -asked, else the active column (last typed or #btn("B1")-clicked in, +asked, else the active column (last typed or left-clicked in, dropped into, its tag given the keyboard, or given the last new pane), never a new column. An empty column it takes whole; #word("New") and #file("pane/new") take the bottom half of the column's last pane; a pane @@ -895,7 +893,7 @@ it was. itself do not count); for other shells, from no program holding the terminal, typed text or not. - *A program's mouse.* A program that tracks the mouse (htop, vim with - `mouse=a`) gets #btn("B1")'s clicks and drags and the wheel over its + `mouse=a`) gets the left button's clicks and drags and the wheel over its grid; Shift-#btn("B1") selects and Shift-wheel scrolls pardes's scrollback, while Shift-#btn("B2") and Shift-#btn("B3") go to the program. A full-screen program that does not track the mouse gets the wheel as diff --git a/docs/typ/scripting.typ b/docs/typ/scripting.typ index fe9146fc..b3f5ca26 100644 --- a/docs/typ/scripting.typ +++ b/docs/typ/scripting.typ @@ -48,7 +48,7 @@ echo Save | wr pane/$n/ctl && gofmt -w "$f" && echo get | wr pane/$n/ctl `get` on a pane's ctl reloads its text from the file on disk. -Type `Fmt` into a Go pane's tag and click it with #btn("B2"); its output +Type `Fmt` into a Go pane's tag and middle-click it; its output shows in a command pane. To have `Fmt` in every Go file's tag, follow the log and add it to each new `.go` pane (with a mount): @@ -93,8 +93,7 @@ open stays open: read its #file("body") before you close it. In == Event helpers -Holding a pane's #file("event") open takes its #btn("B2") and #btn("B3") -clicks: they arrive as acme's records instead of acting, and writing a +Holding a pane's #file("event") open takes its middle- and right-clicks: they arrive as acme's records instead of acting, and writing a record back has pardes do it. A record is a line, `MX31 36 1 5 Upper`: who (`M` mouse, `K` keyboard, `E` or `F` a write to a file), what (`X` execute or `L` look in the body, `x` `l` in the tag), the range, a flag, the text's length and -- cgit v1.3 From a99edf403dbcebae2ce557e2ba39078ffe876a92 Mon Sep 17 00:00:00 2001 From: Gabriel Schneider Date: Thu, 1 Oct 2026 12:48:17 -0300 Subject: Builtins are written by name: each chapter and the tutor define Look and Exec once and then say Look and Exec; the cheatsheet draws every mouse button as its icon; one-button clicks (Alt is B2, Super is B3) are in the guide and cheatsheet; building says how to send patches to the list Co-Authored-By: Claude Opus 5.5 --- docs/typ/building.typ | 19 +- docs/typ/cheatsheet-a4.pdf | 2077 ++++++++++++++++++++-------------------- docs/typ/cheatsheet.typ | 27 +- docs/typ/guide.typ | 35 +- docs/typ/reference.typ | 200 ++-- docs/typ/scripting.typ | 12 +- docs/typ/setup.typ | 8 +- docs/typ/themes.typ | 10 +- src/tutor.txt | 59 +- test/snapshots/builtins.golden | 72 +- test/snapshots/leader.golden | 32 +- 11 files changed, 1271 insertions(+), 1280 deletions(-) (limited to 'docs') diff --git a/docs/typ/building.typ b/docs/typ/building.typ index cca3161e..ae2f3a60 100644 --- a/docs/typ/building.typ +++ b/docs/typ/building.typ @@ -1,6 +1,7 @@ -// Building pardes, for contributors: platforms, options, tests and the -// release gates, then how the pieces fit: the core and its shells, the -// threads, detached sessions, the 9P engine, the listeners and mounts. +// Building pardes, for contributors: platforms, options, tests, the +// release gates and sending patches, then how the pieces fit: the core +// and its shells, the threads, detached sessions, the 9P engine, the +// listeners and mounts. #import "style.typ": key, keys, btn, chord, word, tag, addr, file, cmd, doc, pairs For contributors: how pardes is built, tested and released, and how its @@ -125,6 +126,14 @@ with `-Dplatform=gui`, `core-test`, `fs-test`, `snap`, the GUI goldens `web`, and the ReleaseSafe tty and ReleaseFast gui builds. The committed `docs/typ/cheatsheet-a4.pdf` is rendered again when the docs change. += Sending patches + +Mail patches to the list `~gbrls/inbox@lists.sr.ht`; it is the preferred way to contribute: + +#cmd("git config format.subjectPrefix \"PATCH pardes\"\ngit send-email --to=~gbrls/inbox@lists.sr.ht HEAD^") + +#link("https://git-send-email.io")[git-send-email.io] sets `git send-email` up. The mirrors (#doc("setup", section: "install")) are for cloning, as a GitHub one will be; pull requests are not the preferred route. + = The core and its shells One core, five shells (tty, gui, web, macos, esp32p4). The core owns @@ -195,7 +204,7 @@ frontend with unsent bytes skips that frame, and one that stops draining past 1 MiB of control backlog is closed, its peers untouched. Frontends never spawn shells, write session files or watch files. #word("Attach") connects first and swaps second: only after the handshake does a shell -give up its own core. Restore builds the replacement core before touching +give up its own core. #word("Restore") builds the replacement core before touching the current one. `src/detached/wire.zig` is the versioned protocol (version 10): fixed-width @@ -239,7 +248,7 @@ use `.cloud9 = .{ .path = "../cloud9" }` while editing both. cloud9's own A mount cuts a big write into pieces of at most one message (msize 65536, less the header), anywhere, and each command line runs once its newline comes; nothing is read into a write's size. A last line with no newline -(`printf Save > exec`) runs when the file is closed, as does an `Edit` +(`printf Save > exec`) runs when the file is closed, as does an #word("Edit") block never ended, and its failure is then only in the log, as its `err` record: the close reports no error, and the write that sent it had already succeeded. So a script that needs a line's result ends it with a diff --git a/docs/typ/cheatsheet-a4.pdf b/docs/typ/cheatsheet-a4.pdf index a7c1b3c9..b8cebf62 100644 --- a/docs/typ/cheatsheet-a4.pdf +++ b/docs/typ/cheatsheet-a4.pdf @@ -2,1231 +2,1215 @@ %€€€€ 1 0 obj -<> +<> endobj 2 0 obj -<> +<> endobj 3 0 obj -<> +<> endobj 4 0 obj -<> +<> endobj 5 0 obj -<> +<> endobj 6 0 obj -<> +<> endobj 7 0 obj -<> +<> endobj 8 0 obj -<> +<> endobj 9 0 obj -<> +<> endobj 10 0 obj -<> +<> endobj 11 0 obj -<> +<> endobj 12 0 obj -<> +<> endobj 13 0 obj -<> +<> endobj 14 0 obj -<> +<> endobj 15 0 obj -<> +<> endobj 16 0 obj <> endobj 17 0 obj -<>/K[354 0 R]/ParentTree<>/ParentTreeNextKey 1>> +<>/K[349 0 R]/ParentTree<>/ParentTreeNextKey 1>> endobj 18 0 obj -[19 0 R 19 0 R 20 0 R 22 0 R 22 0 R 25 0 R 26 0 R 26 0 R 29 0 R 30 0 R 30 0 R 30 0 R 30 0 R 32 0 R 33 0 R 33 0 R 35 0 R 36 0 R 36 0 R 36 0 R 36 0 R 39 0 R 40 0 R 41 0 R 43 0 R 44 0 R 46 0 R 46 0 R 47 0 R 47 0 R 49 0 R 50 0 R 50 0 R 50 0 R 50 0 R 50 0 R 52 0 R 53 0 R 53 0 R 53 0 R 56 0 R 56 0 R 56 0 R 56 0 R 56 0 R 56 0 R 57 0 R 58 0 R 58 0 R 58 0 R 58 0 R 58 0 R 58 0 R 58 0 R 58 0 R 58 0 R 58 0 R 58 0 R 58 0 R 58 0 R 59 0 R 61 0 R 61 0 R 61 0 R 60 0 R 61 0 R 63 0 R 64 0 R 64 0 R 64 0 R 64 0 R 64 0 R 64 0 R 64 0 R 64 0 R 64 0 R 64 0 R 67 0 R 68 0 R 68 0 R 68 0 R 68 0 R 69 0 R 70 0 R 72 0 R 73 0 R 75 0 R 77 0 R 77 0 R 76 0 R 77 0 R 79 0 R 82 0 R 82 0 R 80 0 R 82 0 R 81 0 R 82 0 R 84 0 R 88 0 R 85 0 R 88 0 R 86 0 R 88 0 R 87 0 R 87 0 R 90 0 R 91 0 R 91 0 R 93 0 R 95 0 R 94 0 R 95 0 R 95 0 R 103 0 R 98 0 R 103 0 R 99 0 R 103 0 R 100 0 R 103 0 R 101 0 R 103 0 R 102 0 R 103 0 R 103 0 R 103 0 R 104 0 R 108 0 R 105 0 R 108 0 R 108 0 R 106 0 R 108 0 R 107 0 R 108 0 R 108 0 R 109 0 R 109 0 R 109 0 R 109 0 R 109 0 R 109 0 R 109 0 R 109 0 R 110 0 R 112 0 R 112 0 R 112 0 R 112 0 R 112 0 R 112 0 R 113 0 R 115 0 R 115 0 R 115 0 R 115 0 R 115 0 R 115 0 R 115 0 R 116 0 R 116 0 R 118 0 R 118 0 R 118 0 R 119 0 R 121 0 R 122 0 R 124 0 R 124 0 R 124 0 R 125 0 R 127 0 R 127 0 R 127 0 R 128 0 R 130 0 R 130 0 R 131 0 R 133 0 R 133 0 R 133 0 R 133 0 R 133 0 R 133 0 R 134 0 R 134 0 R 134 0 R 136 0 R 136 0 R 137 0 R 137 0 R 139 0 R 139 0 R 140 0 R 140 0 R 142 0 R 142 0 R 142 0 R 143 0 R 145 0 R 145 0 R 145 0 R 145 0 R 145 0 R 145 0 R 146 0 R 146 0 R 148 0 R 149 0 R 149 0 R 151 0 R 151 0 R 151 0 R 151 0 R 151 0 R 151 0 R 152 0 R 152 0 R 154 0 R 154 0 R 154 0 R 154 0 R 154 0 R 154 0 R 155 0 R 157 0 R 157 0 R 158 0 R 158 0 R 158 0 R 158 0 R 160 0 R 161 0 R 164 0 R 165 0 R 166 0 R 166 0 R 166 0 R 166 0 R 166 0 R 166 0 R 166 0 R 166 0 R 168 0 R 168 0 R 168 0 R 167 0 R 168 0 R 170 0 R 171 0 R 171 0 R 171 0 R 171 0 R 173 0 R 173 0 R 173 0 R 174 0 R 174 0 R 174 0 R 174 0 R 174 0 R 176 0 R 176 0 R 176 0 R 176 0 R 176 0 R 176 0 R 177 0 R 177 0 R 179 0 R 179 0 R 179 0 R 180 0 R 182 0 R 182 0 R 182 0 R 183 0 R 183 0 R 186 0 R 186 0 R 186 0 R 187 0 R 187 0 R 187 0 R 188 0 R 190 0 R 190 0 R 190 0 R 190 0 R 190 0 R 191 0 R 193 0 R 193 0 R 193 0 R 193 0 R 193 0 R 194 0 R 196 0 R 196 0 R 196 0 R 196 0 R 196 0 R 197 0 R 199 0 R 199 0 R 199 0 R 199 0 R 199 0 R 200 0 R 202 0 R 202 0 R 202 0 R 202 0 R 202 0 R 203 0 R 205 0 R 205 0 R 205 0 R 205 0 R 205 0 R 206 0 R 208 0 R 208 0 R 208 0 R 209 0 R 211 0 R 211 0 R 211 0 R 211 0 R 211 0 R 212 0 R 214 0 R 214 0 R 214 0 R 214 0 R 214 0 R 215 0 R 217 0 R 217 0 R 217 0 R 217 0 R 217 0 R 218 0 R 220 0 R 220 0 R 220 0 R 220 0 R 220 0 R 221 0 R 223 0 R 223 0 R 223 0 R 223 0 R 223 0 R 224 0 R 226 0 R 226 0 R 226 0 R 227 0 R 231 0 R 231 0 R 231 0 R 232 0 R 234 0 R 234 0 R 234 0 R 234 0 R 234 0 R 235 0 R 237 0 R 237 0 R 237 0 R 237 0 R 237 0 R 238 0 R 240 0 R 240 0 R 240 0 R 240 0 R 240 0 R 241 0 R 243 0 R 243 0 R 243 0 R 243 0 R 243 0 R 244 0 R 246 0 R 246 0 R 246 0 R 246 0 R 246 0 R 247 0 R 249 0 R 249 0 R 249 0 R 249 0 R 249 0 R 250 0 R 252 0 R 252 0 R 252 0 R 252 0 R 252 0 R 253 0 R 255 0 R 255 0 R 255 0 R 255 0 R 255 0 R 256 0 R 258 0 R 258 0 R 258 0 R 258 0 R 258 0 R 259 0 R 261 0 R 261 0 R 261 0 R 261 0 R 261 0 R 262 0 R 264 0 R 264 0 R 264 0 R 264 0 R 264 0 R 265 0 R 267 0 R 267 0 R 267 0 R 268 0 R 273 0 R 274 0 R 276 0 R 276 0 R 276 0 R 276 0 R 275 0 R 276 0 R 276 0 R 276 0 R 276 0 R 276 0 R 276 0 R 276 0 R 276 0 R 278 0 R 280 0 R 279 0 R 279 0 R 280 0 R 281 0 R 281 0 R 281 0 R 283 0 R 287 0 R 287 0 R 284 0 R 287 0 R 287 0 R 287 0 R 285 0 R 285 0 R 287 0 R 286 0 R 287 0 R 290 0 R 291 0 R 295 0 R 295 0 R 292 0 R 295 0 R 295 0 R 293 0 R 295 0 R 294 0 R 295 0 R 295 0 R 295 0 R 296 0 R 297 0 R 301 0 R 301 0 R 298 0 R 301 0 R 301 0 R 301 0 R 299 0 R 301 0 R 300 0 R 301 0 R 301 0 R 301 0 R 301 0 R 301 0 R 301 0 R 301 0 R 301 0 R 304 0 R 305 0 R 308 0 R 306 0 R 308 0 R 308 0 R 308 0 R 307 0 R 308 0 R 308 0 R 308 0 R 308 0 R 308 0 R 309 0 R 312 0 R 312 0 R 312 0 R 312 0 R 312 0 R 312 0 R 312 0 R 312 0 R 310 0 R 312 0 R 312 0 R 311 0 R 312 0 R 312 0 R 312 0 R 312 0 R 312 0 R 312 0 R 312 0 R 312 0 R 312 0 R 313 0 R 316 0 R 316 0 R 316 0 R 316 0 R 314 0 R 316 0 R 316 0 R 316 0 R 316 0 R 316 0 R 315 0 R 316 0 R 316 0 R 317 0 R 321 0 R 318 0 R 321 0 R 319 0 R 321 0 R 321 0 R 320 0 R 321 0 R 321 0 R 322 0 R 322 0 R 322 0 R 323 0 R 324 0 R 324 0 R 326 0 R 327 0 R 327 0 R 329 0 R 331 0 R 330 0 R 331 0 R 331 0 R 333 0 R 334 0 R 336 0 R 338 0 R 337 0 R 338 0 R 338 0 R 340 0 R 343 0 R 341 0 R 343 0 R 342 0 R 345 0 R 347 0 R 346 0 R 347 0 R 350 0 R 350 0 R 350 0 R 350 0 R 350 0 R 350 0 R 350 0 R 351 0 R 353 0 R 352 0 R 352 0 R 353 0 R 353 0 R] +[19 0 R 19 0 R 20 0 R 22 0 R 22 0 R 25 0 R 25 0 R 25 0 R 28 0 R 28 0 R 28 0 R 28 0 R 28 0 R 28 0 R 30 0 R 31 0 R 31 0 R 31 0 R 31 0 R 31 0 R 31 0 R 31 0 R 31 0 R 33 0 R 34 0 R 34 0 R 34 0 R 34 0 R 37 0 R 38 0 R 39 0 R 39 0 R 41 0 R 42 0 R 44 0 R 44 0 R 45 0 R 45 0 R 45 0 R 47 0 R 48 0 R 48 0 R 48 0 R 48 0 R 48 0 R 48 0 R 48 0 R 50 0 R 51 0 R 51 0 R 51 0 R 54 0 R 54 0 R 54 0 R 54 0 R 54 0 R 54 0 R 54 0 R 54 0 R 54 0 R 54 0 R 54 0 R 55 0 R 56 0 R 56 0 R 56 0 R 56 0 R 56 0 R 56 0 R 56 0 R 56 0 R 56 0 R 56 0 R 56 0 R 56 0 R 56 0 R 57 0 R 59 0 R 59 0 R 59 0 R 59 0 R 59 0 R 58 0 R 59 0 R 61 0 R 62 0 R 62 0 R 62 0 R 62 0 R 62 0 R 62 0 R 62 0 R 62 0 R 62 0 R 62 0 R 65 0 R 65 0 R 66 0 R 66 0 R 66 0 R 66 0 R 67 0 R 68 0 R 70 0 R 71 0 R 73 0 R 75 0 R 75 0 R 74 0 R 75 0 R 77 0 R 80 0 R 80 0 R 78 0 R 80 0 R 79 0 R 80 0 R 82 0 R 84 0 R 84 0 R 84 0 R 84 0 R 84 0 R 83 0 R 86 0 R 87 0 R 87 0 R 89 0 R 91 0 R 90 0 R 91 0 R 91 0 R 99 0 R 94 0 R 99 0 R 95 0 R 99 0 R 96 0 R 99 0 R 97 0 R 99 0 R 98 0 R 99 0 R 99 0 R 99 0 R 100 0 R 104 0 R 101 0 R 104 0 R 104 0 R 102 0 R 104 0 R 103 0 R 104 0 R 104 0 R 105 0 R 105 0 R 105 0 R 105 0 R 105 0 R 105 0 R 105 0 R 105 0 R 106 0 R 108 0 R 108 0 R 108 0 R 108 0 R 108 0 R 108 0 R 109 0 R 111 0 R 111 0 R 111 0 R 111 0 R 111 0 R 111 0 R 111 0 R 112 0 R 112 0 R 114 0 R 114 0 R 114 0 R 115 0 R 117 0 R 118 0 R 120 0 R 120 0 R 120 0 R 121 0 R 123 0 R 123 0 R 123 0 R 124 0 R 126 0 R 126 0 R 127 0 R 129 0 R 129 0 R 129 0 R 129 0 R 129 0 R 129 0 R 130 0 R 130 0 R 130 0 R 132 0 R 132 0 R 133 0 R 133 0 R 135 0 R 135 0 R 136 0 R 136 0 R 138 0 R 138 0 R 138 0 R 139 0 R 141 0 R 141 0 R 141 0 R 141 0 R 141 0 R 141 0 R 142 0 R 142 0 R 144 0 R 145 0 R 145 0 R 147 0 R 147 0 R 147 0 R 147 0 R 147 0 R 147 0 R 148 0 R 148 0 R 150 0 R 150 0 R 150 0 R 150 0 R 150 0 R 150 0 R 151 0 R 153 0 R 153 0 R 154 0 R 154 0 R 154 0 R 154 0 R 154 0 R 154 0 R 154 0 R 156 0 R 157 0 R 160 0 R 161 0 R 162 0 R 162 0 R 162 0 R 162 0 R 162 0 R 162 0 R 162 0 R 162 0 R 164 0 R 164 0 R 164 0 R 163 0 R 164 0 R 166 0 R 167 0 R 167 0 R 167 0 R 167 0 R 169 0 R 169 0 R 169 0 R 170 0 R 170 0 R 170 0 R 170 0 R 170 0 R 172 0 R 172 0 R 172 0 R 172 0 R 172 0 R 172 0 R 173 0 R 173 0 R 175 0 R 175 0 R 175 0 R 176 0 R 178 0 R 178 0 R 178 0 R 179 0 R 179 0 R 182 0 R 182 0 R 182 0 R 183 0 R 183 0 R 183 0 R 184 0 R 186 0 R 186 0 R 186 0 R 186 0 R 186 0 R 187 0 R 189 0 R 189 0 R 189 0 R 189 0 R 189 0 R 190 0 R 192 0 R 192 0 R 192 0 R 192 0 R 192 0 R 193 0 R 195 0 R 195 0 R 195 0 R 195 0 R 195 0 R 196 0 R 198 0 R 198 0 R 198 0 R 198 0 R 198 0 R 199 0 R 201 0 R 201 0 R 201 0 R 201 0 R 201 0 R 202 0 R 204 0 R 204 0 R 204 0 R 205 0 R 207 0 R 207 0 R 207 0 R 207 0 R 207 0 R 208 0 R 210 0 R 210 0 R 210 0 R 210 0 R 210 0 R 211 0 R 213 0 R 213 0 R 213 0 R 213 0 R 213 0 R 214 0 R 216 0 R 216 0 R 216 0 R 216 0 R 216 0 R 217 0 R 219 0 R 219 0 R 219 0 R 219 0 R 219 0 R 220 0 R 222 0 R 222 0 R 222 0 R 223 0 R 227 0 R 227 0 R 227 0 R 228 0 R 230 0 R 230 0 R 230 0 R 230 0 R 230 0 R 231 0 R 233 0 R 233 0 R 233 0 R 233 0 R 233 0 R 234 0 R 236 0 R 236 0 R 236 0 R 236 0 R 236 0 R 237 0 R 239 0 R 239 0 R 239 0 R 239 0 R 239 0 R 240 0 R 242 0 R 242 0 R 242 0 R 242 0 R 242 0 R 243 0 R 245 0 R 245 0 R 245 0 R 245 0 R 245 0 R 246 0 R 248 0 R 248 0 R 248 0 R 248 0 R 248 0 R 249 0 R 251 0 R 251 0 R 251 0 R 251 0 R 251 0 R 252 0 R 254 0 R 254 0 R 254 0 R 254 0 R 254 0 R 255 0 R 257 0 R 257 0 R 257 0 R 257 0 R 257 0 R 258 0 R 260 0 R 260 0 R 260 0 R 260 0 R 260 0 R 261 0 R 263 0 R 263 0 R 263 0 R 264 0 R 269 0 R 270 0 R 272 0 R 272 0 R 272 0 R 272 0 R 271 0 R 272 0 R 272 0 R 272 0 R 272 0 R 272 0 R 272 0 R 272 0 R 272 0 R 274 0 R 276 0 R 275 0 R 275 0 R 276 0 R 277 0 R 277 0 R 277 0 R 279 0 R 283 0 R 283 0 R 280 0 R 283 0 R 283 0 R 283 0 R 283 0 R 283 0 R 281 0 R 283 0 R 282 0 R 283 0 R 286 0 R 287 0 R 291 0 R 291 0 R 288 0 R 291 0 R 291 0 R 289 0 R 291 0 R 290 0 R 291 0 R 291 0 R 291 0 R 292 0 R 293 0 R 297 0 R 297 0 R 294 0 R 297 0 R 297 0 R 297 0 R 295 0 R 297 0 R 296 0 R 297 0 R 297 0 R 297 0 R 297 0 R 297 0 R 297 0 R 297 0 R 297 0 R 300 0 R 301 0 R 304 0 R 302 0 R 304 0 R 304 0 R 304 0 R 303 0 R 304 0 R 304 0 R 304 0 R 304 0 R 304 0 R 305 0 R 308 0 R 308 0 R 308 0 R 308 0 R 308 0 R 308 0 R 308 0 R 308 0 R 306 0 R 308 0 R 308 0 R 308 0 R 308 0 R 307 0 R 308 0 R 308 0 R 308 0 R 308 0 R 308 0 R 308 0 R 308 0 R 308 0 R 308 0 R 309 0 R 312 0 R 312 0 R 312 0 R 312 0 R 310 0 R 312 0 R 312 0 R 312 0 R 312 0 R 312 0 R 311 0 R 312 0 R 312 0 R 313 0 R 317 0 R 314 0 R 317 0 R 315 0 R 317 0 R 317 0 R 316 0 R 317 0 R 317 0 R 318 0 R 318 0 R 318 0 R 319 0 R 320 0 R 320 0 R 322 0 R 323 0 R 323 0 R 325 0 R 327 0 R 326 0 R 327 0 R 327 0 R 329 0 R 330 0 R 332 0 R 334 0 R 333 0 R 334 0 R 334 0 R 336 0 R 338 0 R 338 0 R 338 0 R 338 0 R 338 0 R 337 0 R 340 0 R 342 0 R 341 0 R 342 0 R 345 0 R 345 0 R 345 0 R 345 0 R 345 0 R 345 0 R 345 0 R 346 0 R 348 0 R 347 0 R 347 0 R 348 0 R 348 0 R] endobj 19 0 obj -<>]/K[0 1]/Pg 392 0 R>> +<>]/K[0 1]/Pg 387 0 R>> endobj 20 0 obj -<> +<> endobj 21 0 obj <><>]/K[]>> endobj 22 0 obj -<><>]/K[3 4]/Pg 392 0 R>> +<><>]/K[3 4]/Pg 387 0 R>> endobj 23 0 obj -<> +<> endobj 24 0 obj -<>]/K[]>> +<>]/K[]>> endobj 25 0 obj -<> +<>]/K[5 6 7]/Pg 387 0 R>> endobj 26 0 obj -<>]/K[25 0 R 6 7]/Pg 392 0 R>> +<> endobj 27 0 obj -<> +<><>]/K[]>> endobj 28 0 obj -<><>]/K[]>> +<><>]/K[8 9 10 11 12 13]/Pg 387 0 R>> endobj 29 0 obj -<> +<> endobj 30 0 obj -<><>]/K[29 0 R 9 10 11 12]/Pg 392 0 R>> +<>]/K[14]/Pg 387 0 R>> endobj 31 0 obj -<> +<>]/K[15 16 17 18 19 20 21 22]/Pg 387 0 R>> endobj 32 0 obj -<>]/K[13]/Pg 392 0 R>> +<> endobj 33 0 obj -<>]/K[14 15]/Pg 392 0 R>> +<><>]/K[23]/Pg 387 0 R>> endobj 34 0 obj -<> +<><>]/K[24 25 26 27]/Pg 387 0 R>> endobj 35 0 obj -<><>]/K[16]/Pg 392 0 R>> +<> endobj 36 0 obj -<><>]/K[17 18 19 20]/Pg 392 0 R>> +<> endobj 37 0 obj -<> +<> endobj 38 0 obj -<> +<><>]/K[29]/Pg 387 0 R>> endobj 39 0 obj -<> +<><>]/K[30 31]/Pg 387 0 R>> endobj 40 0 obj -<><>]/K[22]/Pg 392 0 R>> +<> endobj 41 0 obj -<><>]/K[23]/Pg 392 0 R>> +<>]/K[32]/Pg 387 0 R>> endobj 42 0 obj -<> +<>]/K[33]/Pg 387 0 R>> endobj 43 0 obj -<>]/K[24]/Pg 392 0 R>> +<> endobj 44 0 obj -<>]/K[25]/Pg 392 0 R>> +<><>]/K[34 35]/Pg 387 0 R>> endobj 45 0 obj -<> +<><>]/K[36 37 38]/Pg 387 0 R>> endobj 46 0 obj -<><>]/K[26 27]/Pg 392 0 R>> +<> endobj 47 0 obj -<><>]/K[28 29]/Pg 392 0 R>> +<>]/K[39]/Pg 387 0 R>> endobj 48 0 obj -<> +<>]/K[40 41 42 43 44 45 46]/Pg 387 0 R>> endobj 49 0 obj -<>]/K[30]/Pg 392 0 R>> +<> endobj 50 0 obj -<>]/K[31 32 33 34 35]/Pg 392 0 R>> +<><>]/K[47]/Pg 387 0 R>> endobj 51 0 obj -<> +<><>]/K[48 49 50]/Pg 387 0 R>> endobj 52 0 obj -<><>]/K[36]/Pg 392 0 R>> +<> endobj 53 0 obj -<><>]/K[37 38 39]/Pg 392 0 R>> +<> endobj 54 0 obj -<> +<> endobj 55 0 obj -<> +<> endobj 56 0 obj -<> +<>]/K[63 64 65 66 67 68 69 70 71 72 73 74 75]/Pg 387 0 R>> endobj 57 0 obj -<> +<> endobj 58 0 obj -<>]/K[47 48 49 50 51 52 53 54 55 56 57 58 59]/Pg 392 0 R>> +<> endobj 59 0 obj -<> +<> endobj 60 0 obj -<> +<> endobj 61 0 obj -<> +<> endobj 62 0 obj -<> +<> endobj 63 0 obj -<> +<> endobj 64 0 obj -<> +<>]/K[60 0 R 63 0 R]>> endobj 65 0 obj -<> +<> endobj 66 0 obj -<>]/K[62 0 R 65 0 R]>> +<> endobj 67 0 obj -<> +<><>]/K[101]/Pg 387 0 R>> endobj 68 0 obj -<> +<><>]/K[102]/Pg 387 0 R>> endobj 69 0 obj -<><>]/K[82]/Pg 392 0 R>> +<> endobj 70 0 obj -<><>]/K[83]/Pg 392 0 R>> +<>]/K[103]/Pg 387 0 R>> endobj 71 0 obj -<> +<>]/K[104]/Pg 387 0 R>> endobj 72 0 obj -<>]/K[84]/Pg 392 0 R>> +<> endobj 73 0 obj -<>]/K[85]/Pg 392 0 R>> +<><>]/K[105]/Pg 387 0 R>> endobj 74 0 obj -<> +<> endobj 75 0 obj -<><>]/K[86]/Pg 392 0 R>> +<><>]/K[106 107 74 0 R 109]/Pg 387 0 R>> endobj 76 0 obj -<> +<> endobj 77 0 obj -<><>]/K[87 88 76 0 R 90]/Pg 392 0 R>> +<>]/K[110]/Pg 387 0 R>> endobj 78 0 obj -<> +<> endobj 79 0 obj -<>]/K[91]/Pg 392 0 R>> +<> endobj 80 0 obj -<> +<>]/K[111 112 78 0 R 114 79 0 R 116]/Pg 387 0 R>> endobj 81 0 obj -<> +<> endobj 82 0 obj -<>]/K[92 93 80 0 R 95 81 0 R 97]/Pg 392 0 R>> +<><>]/K[117]/Pg 387 0 R>> endobj 83 0 obj -<> +<> endobj 84 0 obj -<><>]/K[98]/Pg 392 0 R>> +<><>]/K[118 119 120 121 122 83 0 R]/Pg 387 0 R>> endobj 85 0 obj -<> +<> endobj 86 0 obj -<> +<>]/K[124]/Pg 387 0 R>> endobj 87 0 obj -<> +<>]/K[125 126]/Pg 387 0 R>> endobj 88 0 obj -<><>]/K[99 85 0 R 101 86 0 R 103 87 0 R]/Pg 392 0 R>> +<> endobj 89 0 obj -<> +<><>]/K[127]/Pg 387 0 R>> endobj 90 0 obj -<>]/K[106]/Pg 392 0 R>> +<> endobj 91 0 obj -<>]/K[107 108]/Pg 392 0 R>> +<><>]/K[128 90 0 R 130 131]/Pg 387 0 R>> endobj 92 0 obj -<> +<> endobj 93 0 obj -<><>]/K[109]/Pg 392 0 R>> +<> endobj 94 0 obj -<> +<> endobj 95 0 obj -<><>]/K[110 94 0 R 112 113]/Pg 392 0 R>> +<> endobj 96 0 obj -<> +<> endobj 97 0 obj -<> +<> endobj 98 0 obj -<> +<> endobj 99 0 obj -<> +<> endobj 100 0 obj -<> +<> endobj 101 0 obj -<> +<> endobj 102 0 obj -<> +<> endobj 103 0 obj -<> +<> endobj 104 0 obj -<> +<> endobj 105 0 obj -<> +<><>]/K[155 156 157 158 159 160 161 162]/Pg 387 0 R>> endobj 106 0 obj -<> +<><>]/K[163]/Pg 387 0 R>> endobj 107 0 obj -<> +<> endobj 108 0 obj -<> +<>]/K[164 165 166 167 168 169]/Pg 387 0 R>> endobj 109 0 obj -<><>]/K[137 138 139 140 141 142 143 144]/Pg 392 0 R>> +<>]/K[170]/Pg 387 0 R>> endobj 110 0 obj -<><>]/K[145]/Pg 392 0 R>> +<> endobj 111 0 obj -<> +<><>]/K[171 172 173 174 175 176 177]/Pg 387 0 R>> endobj 112 0 obj -<>]/K[146 147 148 149 150 151]/Pg 392 0 R>> +<><>]/K[178 179]/Pg 387 0 R>> endobj 113 0 obj -<>]/K[152]/Pg 392 0 R>> +<> endobj 114 0 obj -<> +<>]/K[180 181 182]/Pg 387 0 R>> endobj 115 0 obj -<><>]/K[153 154 155 156 157 158 159]/Pg 392 0 R>> +<>]/K[183]/Pg 387 0 R>> endobj 116 0 obj -<><>]/K[160 161]/Pg 392 0 R>> +<> endobj 117 0 obj -<> +<><>]/K[184]/Pg 387 0 R>> endobj 118 0 obj -<>]/K[162 163 164]/Pg 392 0 R>> +<><>]/K[185]/Pg 387 0 R>> endobj 119 0 obj -<>]/K[165]/Pg 392 0 R>> +<> endobj 120 0 obj -<> +<>]/K[186 187 188]/Pg 387 0 R>> endobj 121 0 obj -<><>]/K[166]/Pg 392 0 R>> +<>]/K[189]/Pg 387 0 R>> endobj 122 0 obj -<><>]/K[167]/Pg 392 0 R>> +<> endobj 123 0 obj -<> +<><>]/K[190 191 192]/Pg 387 0 R>> endobj 124 0 obj -<>]/K[168 169 170]/Pg 392 0 R>> +<><>]/K[193]/Pg 387 0 R>> endobj 125 0 obj -<>]/K[171]/Pg 392 0 R>> +<> endobj 126 0 obj -<> +<>]/K[194 195]/Pg 387 0 R>> endobj 127 0 obj -<><>]/K[172 173 174]/Pg 392 0 R>> +<>]/K[196]/Pg 387 0 R>> endobj 128 0 obj -<><>]/K[175]/Pg 392 0 R>> +<> endobj 129 0 obj -<> +<><>]/K[197 198 199 200 201 202]/Pg 387 0 R>> endobj 130 0 obj -<>]/K[176 177]/Pg 392 0 R>> +<><>]/K[203 204 205]/Pg 387 0 R>> endobj 131 0 obj -<>]/K[178]/Pg 392 0 R>> +<> endobj 132 0 obj -<> +<>]/K[206 207]/Pg 387 0 R>> endobj 133 0 obj -<><>]/K[179 180 181 182 183 184]/Pg 392 0 R>> +<>]/K[208 209]/Pg 387 0 R>> endobj 134 0 obj -<><>]/K[185 186 187]/Pg 392 0 R>> +<> endobj 135 0 obj -<> +<><>]/K[210 211]/Pg 387 0 R>> endobj 136 0 obj -<>]/K[188 189]/Pg 392 0 R>> +<><>]/K[212 213]/Pg 387 0 R>> endobj 137 0 obj -<>]/K[190 191]/Pg 392 0 R>> +<> endobj 138 0 obj -<> +<>]/K[214 215 216]/Pg 387 0 R>> endobj 139 0 obj -<><>]/K[192 193]/Pg 392 0 R>> +<>]/K[217]/Pg 387 0 R>> endobj 140 0 obj -<><>]/K[194 195]/Pg 392 0 R>> +<> endobj 141 0 obj -<> +<><>]/K[218 219 220 221 222 223]/Pg 387 0 R>> endobj 142 0 obj -<>]/K[196 197 198]/Pg 392 0 R>> +<><>]/K[224 225]/Pg 387 0 R>> endobj 143 0 obj -<>]/K[199]/Pg 392 0 R>> +<> endobj 144 0 obj -<> +<>]/K[226]/Pg 387 0 R>> endobj 145 0 obj -<><>]/K[200 201 202 203 204 205]/Pg 392 0 R>> +<>]/K[227 228]/Pg 387 0 R>> endobj 146 0 obj -<><>]/K[206 207]/Pg 392 0 R>> +<> endobj 147 0 obj -<> +<><>]/K[229 230 231 232 233 234]/Pg 387 0 R>> endobj 148 0 obj -<>]/K[208]/Pg 392 0 R>> +<><>]/K[235 236]/Pg 387 0 R>> endobj 149 0 obj -<>]/K[209 210]/Pg 392 0 R>> +<> endobj 150 0 obj -<> +<>]/K[237 238 239 240 241 242]/Pg 387 0 R>> endobj 151 0 obj -<><>]/K[211 212 213 214 215 216]/Pg 392 0 R>> +<>]/K[243]/Pg 387 0 R>> endobj 152 0 obj -<><>]/K[217 218]/Pg 392 0 R>> +<> endobj 153 0 obj -<> +<><>]/K[244 245]/Pg 387 0 R>> endobj 154 0 obj -<>]/K[219 220 221 222 223 224]/Pg 392 0 R>> +<><>]/K[246 247 248 249 250 251 252]/Pg 387 0 R>> endobj 155 0 obj -<>]/K[225]/Pg 392 0 R>> +<> endobj 156 0 obj -<> +<>]/K[253]/Pg 387 0 R>> endobj 157 0 obj -<><>]/K[226 227]/Pg 392 0 R>> +<>]/K[254]/Pg 387 0 R>> endobj 158 0 obj -<><>]/K[228 229 230 231]/Pg 392 0 R>> +<> endobj 159 0 obj -<> +<> endobj 160 0 obj -<>]/K[232]/Pg 392 0 R>> +<> endobj 161 0 obj -<>]/K[233]/Pg 392 0 R>> +<> endobj 162 0 obj -<> +<><>]/K[257 258 259 260 261 262 263 264]/Pg 387 0 R>> endobj 163 0 obj -<> +<> endobj 164 0 obj -<> +<><>]/K[265 266 267 163 0 R 269]/Pg 387 0 R>> endobj 165 0 obj -<> +<> endobj 166 0 obj -<><>]/K[236 237 238 239 240 241 242 243]/Pg 392 0 R>> +<>]/K[270]/Pg 387 0 R>> endobj 167 0 obj -<> +<>]/K[271 272 273 274]/Pg 387 0 R>> endobj 168 0 obj -<><>]/K[244 245 246 167 0 R 248]/Pg 392 0 R>> +<> endobj 169 0 obj -<> +<><>]/K[275 276 277]/Pg 387 0 R>> endobj 170 0 obj -<>]/K[249]/Pg 392 0 R>> +<><>]/K[278 279 280 281 282]/Pg 387 0 R>> endobj 171 0 obj -<>]/K[250 251 252 253]/Pg 392 0 R>> +<> endobj 172 0 obj -<> +<>]/K[283 284 285 286 287 288]/Pg 387 0 R>> endobj 173 0 obj -<><>]/K[254 255 256]/Pg 392 0 R>> +<>]/K[289 290]/Pg 387 0 R>> endobj 174 0 obj -<><>]/K[257 258 259 260 261]/Pg 392 0 R>> +<> endobj 175 0 obj -<> +<><>]/K[291 292 293]/Pg 387 0 R>> endobj 176 0 obj -<>]/K[262 263 264 265 266 267]/Pg 392 0 R>> +<><>]/K[294]/Pg 387 0 R>> endobj 177 0 obj -<>]/K[268 269]/Pg 392 0 R>> +<> endobj 178 0 obj -<> +<>]/K[295 296 297]/Pg 387 0 R>> endobj 179 0 obj -<><>]/K[270 271 272]/Pg 392 0 R>> +<>]/K[298 299]/Pg 387 0 R>> endobj 180 0 obj -<><>]/K[273]/Pg 392 0 R>> +<> endobj 181 0 obj -<> +<> endobj 182 0 obj -<>]/K[274 275 276]/Pg 392 0 R>> +<> endobj 183 0 obj -<>]/K[277 278]/Pg 392 0 R>> +<><>]/K[303 304 305]/Pg 387 0 R>> endobj 184 0 obj -<> +<><>]/K[306]/Pg 387 0 R>> endobj 185 0 obj -<> +<> endobj 186 0 obj -<> +<>]/K[307 308 309 310 311]/Pg 387 0 R>> endobj 187 0 obj -<><>]/K[282 283 284]/Pg 392 0 R>> +<>]/K[312]/Pg 387 0 R>> endobj 188 0 obj -<><>]/K[285]/Pg 392 0 R>> +<> endobj 189 0 obj -<> +<><>]/K[313 314 315 316 317]/Pg 387 0 R>> endobj 190 0 obj -<>]/K[286 287 288 289 290]/Pg 392 0 R>> +<><>]/K[318]/Pg 387 0 R>> endobj 191 0 obj -<>]/K[291]/Pg 392 0 R>> +<> endobj 192 0 obj -<> +<>]/K[319 320 321 322 323]/Pg 387 0 R>> endobj 193 0 obj -<><>]/K[292 293 294 295 296]/Pg 392 0 R>> +<>]/K[324]/Pg 387 0 R>> endobj 194 0 obj -<><>]/K[297]/Pg 392 0 R>> +<> endobj 195 0 obj -<> +<><>]/K[325 326 327 328 329]/Pg 387 0 R>> endobj 196 0 obj -<>]/K[298 299 300 301 302]/Pg 392 0 R>> +<><>]/K[330]/Pg 387 0 R>> endobj 197 0 obj -<>]/K[303]/Pg 392 0 R>> +<> endobj 198 0 obj -<> +<>]/K[331 332 333 334 335]/Pg 387 0 R>> endobj 199 0 obj -<><>]/K[304 305 306 307 308]/Pg 392 0 R>> +<>]/K[336]/Pg 387 0 R>> endobj 200 0 obj -<><>]/K[309]/Pg 392 0 R>> +<> endobj 201 0 obj -<> +<><>]/K[337 338 339 340 341]/Pg 387 0 R>> endobj 202 0 obj -<>]/K[310 311 312 313 314]/Pg 392 0 R>> +<><>]/K[342]/Pg 387 0 R>> endobj 203 0 obj -<>]/K[315]/Pg 392 0 R>> +<> endobj 204 0 obj -<> +<>]/K[343 344 345]/Pg 387 0 R>> endobj 205 0 obj -<><>]/K[316 317 318 319 320]/Pg 392 0 R>> +<>]/K[346]/Pg 387 0 R>> endobj 206 0 obj -<><>]/K[321]/Pg 392 0 R>> +<> endobj 207 0 obj -<> +<><>]/K[347 348 349 350 351]/Pg 387 0 R>> endobj 208 0 obj -<>]/K[322 323 324]/Pg 392 0 R>> +<><>]/K[352]/Pg 387 0 R>> endobj 209 0 obj -<>]/K[325]/Pg 392 0 R>> +<> endobj 210 0 obj -<> +<>]/K[353 354 355 356 357]/Pg 387 0 R>> endobj 211 0 obj -<><>]/K[326 327 328 329 330]/Pg 392 0 R>> +<>]/K[358]/Pg 387 0 R>> endobj 212 0 obj -<><>]/K[331]/Pg 392 0 R>> +<> endobj 213 0 obj -<> +<><>]/K[359 360 361 362 363]/Pg 387 0 R>> endobj 214 0 obj -<>]/K[332 333 334 335 336]/Pg 392 0 R>> +<><>]/K[364]/Pg 387 0 R>> endobj 215 0 obj -<>]/K[337]/Pg 392 0 R>> +<> endobj 216 0 obj -<> +<>]/K[365 366 367 368 369]/Pg 387 0 R>> endobj 217 0 obj -<><>]/K[338 339 340 341 342]/Pg 392 0 R>> +<>]/K[370]/Pg 387 0 R>> endobj 218 0 obj -<><>]/K[343]/Pg 392 0 R>> +<> endobj 219 0 obj -<> +<><>]/K[371 372 373 374 375]/Pg 387 0 R>> endobj 220 0 obj -<>]/K[344 345 346 347 348]/Pg 392 0 R>> +<><>]/K[376]/Pg 387 0 R>> endobj 221 0 obj -<>]/K[349]/Pg 392 0 R>> +<> endobj 222 0 obj -<> +<>]/K[377 378 379]/Pg 387 0 R>> endobj 223 0 obj -<><>]/K[350 351 352 353 354]/Pg 392 0 R>> +<>]/K[380]/Pg 387 0 R>> endobj 224 0 obj -<><>]/K[355]/Pg 392 0 R>> +<> endobj 225 0 obj -<> +<> endobj 226 0 obj -<>]/K[356 357 358]/Pg 392 0 R>> +<> endobj 227 0 obj -<>]/K[359]/Pg 392 0 R>> +<><>]/K[381 382 383]/Pg 387 0 R>> endobj 228 0 obj -<> +<><>]/K[384]/Pg 387 0 R>> endobj 229 0 obj -<> +<> endobj 230 0 obj -<> +<>]/K[385 386 387 388 389]/Pg 387 0 R>> endobj 231 0 obj -<><>]/K[360 361 362]/Pg 392 0 R>> +<>]/K[390]/Pg 387 0 R>> endobj 232 0 obj -<><>]/K[363]/Pg 392 0 R>> +<> endobj 233 0 obj -<> +<><>]/K[391 392 393 394 395]/Pg 387 0 R>> endobj 234 0 obj -<>]/K[364 365 366 367 368]/Pg 392 0 R>> +<><>]/K[396]/Pg 387 0 R>> endobj 235 0 obj -<>]/K[369]/Pg 392 0 R>> +<> endobj 236 0 obj -<> +<>]/K[397 398 399 400 401]/Pg 387 0 R>> endobj 237 0 obj -<><>]/K[370 371 372 373 374]/Pg 392 0 R>> +<>]/K[402]/Pg 387 0 R>> endobj 238 0 obj -<><>]/K[375]/Pg 392 0 R>> +<> endobj 239 0 obj -<> +<><>]/K[403 404 405 406 407]/Pg 387 0 R>> endobj 240 0 obj -<>]/K[376 377 378 379 380]/Pg 392 0 R>> +<><>]/K[408]/Pg 387 0 R>> endobj 241 0 obj -<>]/K[381]/Pg 392 0 R>> +<> endobj 242 0 obj -<> +<>]/K[409 410 411 412 413]/Pg 387 0 R>> endobj 243 0 obj -<><>]/K[382 383 384 385 386]/Pg 392 0 R>> +<>]/K[414]/Pg 387 0 R>> endobj 244 0 obj -<><>]/K[387]/Pg 392 0 R>> +<> endobj 245 0 obj -<> +<><>]/K[415 416 417 418 419]/Pg 387 0 R>> endobj 246 0 obj -<>]/K[388 389 390 391 392]/Pg 392 0 R>> +<><>]/K[420]/Pg 387 0 R>> endobj 247 0 obj -<>]/K[393]/Pg 392 0 R>> +<> endobj 248 0 obj -<> +<>]/K[421 422 423 424 425]/Pg 387 0 R>> endobj 249 0 obj -<><>]/K[394 395 396 397 398]/Pg 392 0 R>> +<>]/K[426]/Pg 387 0 R>> endobj 250 0 obj -<><>]/K[399]/Pg 392 0 R>> +<> endobj 251 0 obj -<> +<><>]/K[427 428 429 430 431]/Pg 387 0 R>> endobj 252 0 obj -<>]/K[400 401 402 403 404]/Pg 392 0 R>> +<><>]/K[432]/Pg 387 0 R>> endobj 253 0 obj -<>]/K[405]/Pg 392 0 R>> +<> endobj 254 0 obj -<> +<>]/K[433 434 435 436 437]/Pg 387 0 R>> endobj 255 0 obj -<><>]/K[406 407 408 409 410]/Pg 392 0 R>> +<>]/K[438]/Pg 387 0 R>> endobj 256 0 obj -<><>]/K[411]/Pg 392 0 R>> +<> endobj 257 0 obj -<> +<><>]/K[439 440 441 442 443]/Pg 387 0 R>> endobj 258 0 obj -<>]/K[412 413 414 415 416]/Pg 392 0 R>> +<><>]/K[444]/Pg 387 0 R>> endobj 259 0 obj -<>]/K[417]/Pg 392 0 R>> +<> endobj 260 0 obj -<> +<>]/K[445 446 447 448 449]/Pg 387 0 R>> endobj 261 0 obj -<><>]/K[418 419 420 421 422]/Pg 392 0 R>> +<>]/K[450]/Pg 387 0 R>> endobj 262 0 obj -<><>]/K[423]/Pg 392 0 R>> +<> endobj 263 0 obj -<> +<><>]/K[451 452 453]/Pg 387 0 R>> endobj 264 0 obj -<>]/K[424 425 426 427 428]/Pg 392 0 R>> +<><>]/K[454]/Pg 387 0 R>> endobj 265 0 obj -<>]/K[429]/Pg 392 0 R>> +<> endobj 266 0 obj -<> +<> endobj 267 0 obj -<><>]/K[430 431 432]/Pg 392 0 R>> +<> endobj 268 0 obj -<><>]/K[433]/Pg 392 0 R>> +<> endobj 269 0 obj -<> +<> endobj 270 0 obj -<> +<> endobj 271 0 obj -<> +<> endobj 272 0 obj -<> +<> endobj 273 0 obj -<> +<> endobj 274 0 obj -<> +<> endobj 275 0 obj -<> +<> endobj 276 0 obj -<> +<> endobj 277 0 obj -<> +<> endobj 278 0 obj -<> +<> endobj 279 0 obj -<> +<> endobj 280 0 obj -<> +<> endobj 281 0 obj -<> +<> endobj 282 0 obj -<> +<> endobj 283 0 obj -<> +<> endobj 284 0 obj -<> +<> endobj 285 0 obj -<> +<>]/K[273 0 R 278 0 R 284 0 R]>> endobj 286 0 obj -<> +<> endobj 287 0 obj -<> +<> endobj 288 0 obj -<> +<> endobj 289 0 obj -<>]/K[277 0 R 282 0 R 288 0 R]>> +<> endobj 290 0 obj -<> +<> endobj 291 0 obj -<> +<> endobj 292 0 obj -<> +<> endobj 293 0 obj -<> +<> endobj 294 0 obj -<> +<> endobj 295 0 obj -<> +<> endobj 296 0 obj -<> +<> endobj 297 0 obj -<> +<> endobj 298 0 obj -<> +<> endobj 299 0 obj -<> +<>]/K[298 0 R]>> endobj 300 0 obj -<> +<> endobj 301 0 obj -<> +<> endobj 302 0 obj -<> +<> endobj 303 0 obj -<>]/K[302 0 R]>> +<> endobj 304 0 obj -<> +<> endobj 305 0 obj -<> +<> endobj 306 0 obj -<> +<> endobj 307 0 obj -<> +<> endobj 308 0 obj -<> +<> endobj 309 0 obj -<> +<> endobj 310 0 obj -<> +<> endobj 311 0 obj -<> +<> endobj 312 0 obj -<> +<> endobj 313 0 obj -<> +<> endobj 314 0 obj -<> +<> endobj 315 0 obj -<> +<> endobj 316 0 obj -<> +<> endobj 317 0 obj -<> +<> endobj 318 0 obj -<> +<>]/K[584 585 586]/Pg 387 0 R>> endobj 319 0 obj -<> +<><>]/K[587]/Pg 387 0 R>> endobj 320 0 obj -<> +<><>]/K[588 589]/Pg 387 0 R>> endobj 321 0 obj -<> +<> endobj 322 0 obj -<>]/K[560 561 562]/Pg 392 0 R>> +<>]/K[590]/Pg 387 0 R>> endobj 323 0 obj -<><>]/K[563]/Pg 392 0 R>> +<>]/K[591 592]/Pg 387 0 R>> endobj 324 0 obj -<><>]/K[564 565]/Pg 392 0 R>> +<> endobj 325 0 obj -<> +<><>]/K[593]/Pg 387 0 R>> endobj 326 0 obj -<>]/K[566]/Pg 392 0 R>> +<> endobj 327 0 obj -<>]/K[567 568]/Pg 392 0 R>> +<><>]/K[594 326 0 R 596 597]/Pg 387 0 R>> endobj 328 0 obj -<> +<> endobj 329 0 obj -<><>]/K[569]/Pg 392 0 R>> +<>]/K[598]/Pg 387 0 R>> endobj 330 0 obj -<> +<>]/K[599]/Pg 387 0 R>> endobj 331 0 obj -<><>]/K[570 330 0 R 572 573]/Pg 392 0 R>> +<> endobj 332 0 obj -<> +<><>]/K[600]/Pg 387 0 R>> endobj 333 0 obj -<>]/K[574]/Pg 392 0 R>> +<> endobj 334 0 obj -<>]/K[575]/Pg 392 0 R>> +<><>]/K[601 333 0 R 603 604]/Pg 387 0 R>> endobj 335 0 obj -<> +<> endobj 336 0 obj -<><>]/K[576]/Pg 392 0 R>> +<>]/K[605]/Pg 387 0 R>> endobj 337 0 obj -<> +<> endobj 338 0 obj -<><>]/K[577 337 0 R 579 580]/Pg 392 0 R>> +<>]/K[606 607 608 609 610 337 0 R]/Pg 387 0 R>> endobj 339 0 obj -<> +<> endobj 340 0 obj -<>]/K[581]/Pg 392 0 R>> +<><>]/K[612]/Pg 387 0 R>> endobj 341 0 obj -<> +<> endobj 342 0 obj -<> +<><>]/K[613 341 0 R 615]/Pg 387 0 R>> endobj 343 0 obj -<>]/K[582 341 0 R 584 342 0 R]/Pg 392 0 R>> +<> endobj 344 0 obj -<> +<> endobj 345 0 obj -<><>]/K[586]/Pg 392 0 R>> +<>]/K[616 617 618 619 620 621 622]/Pg 387 0 R>> endobj 346 0 obj -<> +<> endobj 347 0 obj -<><>]/K[587 346 0 R 589]/Pg 392 0 R>> +<> endobj 348 0 obj -<> +<> endobj 349 0 obj -<> +<> endobj 350 0 obj -<>]/K[590 591 592 593 594 595 596]/Pg 392 0 R>> +[/ICCBased 407 0 R] endobj 351 0 obj -<> +[387 0 R/XYZ 25.51181 645.8511 0] endobj 352 0 obj -<> +[387 0 R/XYZ 25.51181 804.6376 0] endobj 353 0 obj -<> +[387 0 R/XYZ 25.51181 463.1918 0] endobj 354 0 obj -<> +[387 0 R/XYZ 25.51181 276.91058 0] endobj 355 0 obj -[/ICCBased 412 0 R] +[387 0 R/XYZ 25.51181 110.019775 0] endobj 356 0 obj -[392 0 R/XYZ 25.51181 655.8784 0] +[387 0 R/XYZ 211.1811 571.6865 0] endobj 357 0 obj -[392 0 R/XYZ 25.51181 804.6376 0] +[387 0 R/XYZ 211.1811 392.59448 0] endobj 358 0 obj -[392 0 R/XYZ 25.51181 528.94714 0] +[387 0 R/XYZ 211.1811 240.02875 0] endobj 359 0 obj -[392 0 R/XYZ 25.51181 343.01834 0] +[387 0 R/XYZ 211.1811 133.09485 0] endobj 360 0 obj -[392 0 R/XYZ 25.51181 176.47998 0] +[387 0 R/XYZ 211.1811 80.625244 0] endobj 361 0 obj -[392 0 R/XYZ 211.1811 645.4362 0] +[387 0 R/XYZ 396.8504 804.6376 0] endobj 362 0 obj -[392 0 R/XYZ 211.1811 466.34415 0] +[387 0 R/XYZ 396.8504 756.47675 0] endobj 363 0 obj -[392 0 R/XYZ 211.1811 313.77844 0] +[387 0 R/XYZ 396.8504 698.34015 0] endobj 364 0 obj -[392 0 R/XYZ 211.1811 206.84448 0] +[387 0 R/XYZ 396.8504 659.0976 0] endobj 365 0 obj -[392 0 R/XYZ 211.1811 154.37488 0] +<> endobj 366 0 obj -[392 0 R/XYZ 211.1811 115.132385 0] +<> endobj 367 0 obj -[392 0 R/XYZ 211.1811 66.9715 0] +<> endobj 368 0 obj -[392 0 R/XYZ 396.8504 781.61554 0] +<>/ExtGState<>/Font<>>> endobj 369 0 obj -[392 0 R/XYZ 396.8504 742.373 0] +<> endobj 370 0 obj -<> +<>/FontDescriptor 371 0 R/DW 0/W[0 0 500 1 1 581 2 2 505.99997 3 3 428 4 4 561 5 5 489 6 6 427 7 7 652 8 8 619 9 9 250 10 10 905 11 11 551 12 12 598 13 13 706 14 14 256 15 15 325 16 16 358 17 17 641 18 18 244 19 19 456 20 20 322 21 21 613 22 22 616 23 23 561 24 24 521 25 25 736 26 26 558 27 27 716 28 28 529 29 29 777 30 30 716 31 31 545 32 32 504 33 33 315 34 34 514 35 35 614 36 36 315]>> endobj 371 0 obj -<> +<> endobj 372 0 obj -<> +<> endobj 373 0 obj -<>/ExtGState<>/Font<>>> +<>/FontDescriptor 374 0 R/DW 0/W[0 0 500 1 1 486 2 2 389 3 3 783 4 4 401 5 5 190 6 6 353 7 7 250 8 8 307 9 9 477 10 10 518 11 11 489 12 12 519 13 13 357 14 14 478 15 15 521 16 16 447 17 17 219 18 18 266 19 19 276 20 20 475 21 21 486 22 22 503.00003 23 23 489 24 24 472 25 25 564 26 26 444 27 27 499]>> endobj 374 0 obj -<> +<> endobj 375 0 obj -<>/FontDescriptor 376 0 R/DW 0/W[0 0 500 1 1 581 2 2 505.99997 3 3 428 4 4 561 5 5 489 6 6 427 7 7 652 8 8 619 9 9 250 10 10 905 11 11 551 12 12 598 13 13 561 14 14 456 15 15 358 16 16 325 17 17 613 18 18 706 19 19 256 20 20 641 21 21 244 22 22 322 23 23 616 24 24 521 25 25 577 26 26 736 27 27 558 28 28 716 29 29 529 30 30 777 31 31 716 32 32 545 33 33 504 34 34 315 35 35 514 36 36 614 37 37 315]>> +<> endobj 376 0 obj -<> +<>/FontDescriptor 377 0 R/DW 0/W[0 0 500 1 1 390 2 2 447 3 3 264 4 4 428 5 5 316 6 6 220 7 7 250 8 8 457 9 9 542 10 10 505.99997 11 11 310 12 12 504 13 13 531 14 14 538 15 15 519 16 16 220 17 17 702 18 18 500 19 19 236 20 20 515 21 21 372 22 22 747 23 23 271 24 24 493 25 25 560 26 26 661 27 27 587 28 28 528 29 29 268 30 30 490 31 31 512 32 32 596 33 33 323 34 34 424 35 35 790 36 36 497 37 37 695 38 38 363 39 40 298 41 41 485 42 42 338 43 43 646 44 44 236 45 45 1130 46 46 685 47 47 597 48 53 465 54 54 730 55 55 839 56 56 272 57 57 297 58 58 557 59 59 503.00003 60 60 582 61 61 541]>> endobj 377 0 obj -<> +<> endobj 378 0 obj -<>/FontDescriptor 379 0 R/DW 0/W[0 0 500 1 1 486 2 2 389 3 3 783 4 4 401 5 5 190 6 6 353 7 7 250 8 8 307 9 9 477 10 10 518 11 11 489 12 12 519 13 13 357 14 14 478 15 15 521 16 16 447 17 17 219 18 18 266 19 19 276 20 20 475 21 21 486 22 22 503.00003 23 23 489 24 24 472 25 25 564 26 26 444 27 27 499]>> +<> endobj 379 0 obj -<> +<>/FontDescriptor 380 0 R/DW 0/CIDToGIDMap/Identity/W[0 82 602.0508]>> endobj 380 0 obj -<> +<> endobj 381 0 obj -<>/FontDescriptor 382 0 R/DW 0/W[0 0 500 1 1 390 2 2 447 3 3 264 4 4 428 5 5 316 6 6 220 7 7 250 8 8 457 9 9 542 10 10 505.99997 11 11 310 12 12 504 13 13 531 14 14 538 15 15 519 16 16 220 17 17 702 18 18 500 19 19 236 20 20 515 21 21 372 22 22 747 23 23 271 24 24 493 25 25 560 26 26 661 27 27 587 28 28 528 29 29 268 30 30 490 31 31 588 32 32 465 33 33 512 34 34 465 35 35 596 36 36 323 37 37 424 38 38 790 39 39 497 40 40 695 41 41 363 42 42 465 43 44 298 45 45 485 46 46 236 47 47 1130 48 48 685 49 49 597 50 52 465 53 53 730 54 54 338 55 55 839 56 56 272 57 57 297 58 58 557 59 59 503.00003 60 60 582 61 61 541]>> +<> endobj 382 0 obj -<> +<>/FontDescriptor 383 0 R/DW 0/W[0 0 280 1 1 652 2 2 626]>> endobj 383 0 obj -<> +<> endobj 384 0 obj -<>/FontDescriptor 385 0 R/DW 0/CIDToGIDMap/Identity/W[0 82 602.0508]>> +<> endobj 385 0 obj -<> +<>/FontDescriptor 386 0 R/DW 0/CIDToGIDMap/Identity/W[0 6 602.0508]>> endobj 386 0 obj -<> +<> endobj 387 0 obj -<>/FontDescriptor 388 0 R/DW 0/W[0 0 280 1 1 652 2 2 626]>> +<> endobj 388 0 obj -<> -endobj -389 0 obj -<> -endobj -390 0 obj -<>/FontDescriptor 391 0 R/DW 0/CIDToGIDMap/Identity/W[0 3 602.0508]>> -endobj -391 0 obj -<> -endobj -392 0 obj -<> -endobj -393 0 obj <> stream -xœûÿÿÿÿ?óù +xœûÿÿÿÿïõ endstream endobj -394 0 obj +389 0 obj <> stream -xœm“M�¢@†ïüŠÚ‰spi@`4ÆDQó‘q²{FºtI¤›4pðßoè·q&›=¨yºª«êi»ýï§ùVê3Ï㟂>¸Óƒ©xž¿”­çû{] «þ•Y²œ¢ÝŠZ£«Ž{Ê�û£ª{Ï÷�ªº ’§œÿ¥ìøZ«¯„±åC×ëÆóýϺ¿ñŠfX ;%«¾îï$ž<ßÿŦ«µZQèùþAÉ\7ãp�¸¼]�¸§K­¤q�è<öõˆd]õŽìwÕ”­Ý|ºw=7GuÑ#K­Ë$" ->øZw½¹ÓÌöD’/ˆ¼ɦVWšMÃ~ ž†¶½ñ8$ »ÊJÚß`”-¦À ?V�%…_KŸ÷–]�à÷‹–„±Ò’»¶¬Ø”êÊÞZ!6´.Š¢ØŒÿ‰Ç¶�/ÕŸÒØôpCk!2±±YJCPŒXZ ¶% ”"3e–—ùŒÌgÐÒRäúmÛƒv ”£¦ë°¹*dº~bèŽ Dšƒà—î@ð[`_¿x r~©é+pŒ\%8N18¦�sÌ@p\¸}[�›Ž™«Ç':ÇÇÌÕ„£�ñž GðL`Á3ÂiEÎ=#x&ø"縴×ÅÝ‹ñâŒïãqS«ÁV½}öZŽw°Vüxg­nÇ]öcèôÖGz+þçå-Í +xœm“M�Ú0†ïùÓC$ö@ã8�,!A ‡ýвjÏ!h$bGNràßWñkØUÕA�gì™Ç‡?Þ�Ó�2'ž&?}pg[ñ4)Û w¦Öý+³bu�vKj­©:î)?ìºîƒ0<èê:(¾çü/eË—Z%Œ5(ºÞ4A~Öý•—4Á¹žè X÷u#ñ„á/¶]mô’â ÷Z妛ë‚È× èÝšêÈ=�k­¬¯D§±nKRuÕ{rߪ)[·ùxëznúl(A–ZŸID}ð¥îz{£‰k쉟y³Šm­/4¹7û-xÚöÊc“$Ü*kåþ£Qþµl˜"/üXõ–-}ÞZöD¿_ŒºCŒ+£¸kËŠm©/¬„bM«¢(ŠõXñŸx’bÛé\ý)­K�×´"kGÒQƒÄ$h†Ø 4ÍA)2Pæhî3Ÿ‘ù Z8’¾Þ±h *@9ÎôvŽf¾ÂÞQ²Ø—;ŠÇ "Cõ~i*DºÀ +¥Ï†cŠscïè3½ãÇt‚c«Ø;f zõûà˜ù3á8Ç�ÆÞ1Á1ó§ÀÑuîãðœ�$<çè\ÂS¢ Ç5%ç¸s G¹pâ'a•ñE> +390 0 obj +<> stream -xœ�Wix×¹–0–pEãaŒ™Ifœ”’Ê%¡¬!ˆ aslbÀ°,y¶ð¦Å»lk›m–ädËûŠmyØ`cÇ.!$��44MCI“rÛ4!I¹Mï§Üý½�Ø“Ð<üÐhæÌó�óžï{Ïû~#LŸ. -…Ä+iI²ìܴ̼œWeÙiò…/*&_D¨ÀÃ\x$L@Ï0wó&~ø¯EèÒÑÔÿ°¡�‚³„³zD ø×¿Â ý#l~ðï˰_ -B„B‘äåuÉÊ$Ù¦dYfnZ®v½ò�6;-%57êîÝ’Åÿ±dá’ÅKž‹ŠM•EÝŵ=[™.“æF­ËËMUfç,¦ „‚ù%5� µ5µîîõ´;E¨¬ULÏœfŠ&þ6ƒ ›58"fA„;ìg�1"D ‚Á]Íá9Žn"ˆï™àe<\° 8åÁ5¡a6m0ä©�¾éÑÓ¯Mÿ6ôÑZѧâóXÖ?#lÆ•™/Í,œõÊ,nÖÿ…Õÿì¨$jö´Ùþœ{ètø þ_š€5à„5Èz]'‚w(øùà¼ñ.ôz¥%À�‚ð¹HÒŽÒT�뇯Π¿€ˆ†¨�/à,q}™xy©y«�Öë¹<‡óó~~bbˆ=6ßáàõl«­Ôz™„âÒÆ}3Ï|ý <>¥:›<Àô¦î:ü•—ªHeô"s»©‘#«Ùr{%×m+Š.3ë-j‹›4¸ËcHˆ@&\bgw�­¾š&jèä.4cYÆÂçJ³mÙŒ$AwfÛ{ð…?ü8„ý¦ÁL˜ƒÁÉQ"©²M{œšhèõ1øAsµÑYâÄtÅ:£†ÊÓ×�2˜ -ó—t¬xM?°IY�7Ð×ÚØlg¬ƒ6»Ín‹«â�ÕG)¯áÌFU(>ôXúºÌÕdtÊg§»[�Ò<¬!P¤X��] ¥övtù¬]ï71ôP½ -Þ‡9¯ "4Ð@ôU®9L»�®ÊÔ«ªLçdÊ+=åMTG{§¿5£3%U–±i/c™; £ébË�ETBÉ΢Mf½Es3!e1$Úö`©—8uçàk©Zj8u¸¢àEˆÀÏœ$,9–|Ž,á�†ZÊç>S{Áeq˜½fg/=ò2°SŒ{ÇêãhW…­Œ–—¬*Ý`2•ðÅö2ì-ƒ��&Q„?ïÐäØ3)D PŠæmoˆ•1ʾ–¢)ªíâñÚÆq‚ÈWíÌ+¡v%OÁŒ ÇH}Óæi;ÒIµ¶˜Ò›Ċ˹2¾œ–¼¬ûžÜî -Q4àøÕÀz ˆIq¥2 -ÿöù=Ã_1•¼ÍNB…¨Ùî©ýSúçèq¿ú -[„îhØz,™Ië-xŸºðnïcL�¡NG£JX@ð½öþZ/Ö|¤Í]Eµù²Vé¹b³™‘ pÝ@`†_ø„þ °�“°€°í¶'8e˜¾þí‚)ê÷_ú?ë)oËma”ÝZöz1©§¨»ƒlª¯ïèíQlm¡ëLU¼»ë3ö—uÓµŠlw,µs—Z¡`rsK•‡ÈŒêœzÝ•6™ÚY„ j«RrH…"ÿPâž‘Tt�µœ-0b’¯Í=� CNu8ÔA~!ð$Ì&?¿íöõÑ�¢ßù³×x˜ªzÞæbp_ňaœÆx³…¥ñ ¦4bXM¡GE¸o ši·Ê³ÙÌ2ÆDÝÎÒ=˜Ñía«)üÂÇÞ¡–sÔ¨Èç–oe®ãâåù†U¦ÛìåÇù·ÏM°cwسʚo¿LJÎÕ«ØEйó DÀjˆÀ/Z`‹Å0-al©|ƒ<5††1~õ>\)½Ã•ë›ÅË Ê¶ÞYÒÏó“'»î!ìk¡ë2 Ä­þ£ÕuÔ`¯6†A«ÄË -Ê’î‰êæON¿' -¿´ÕZàú„” ) |{n¾'ü+ˆ€¥7sÆ/�$ìÛ9»�lèu{¨ÁÎ7ý÷@I­ù®OHX,na½&7]߬ú5Øþ@Ðn»‘(éØRù2©b}¬PÚ±�JY/SÄ0ø¨©ÓÔÄ‘ø¥«{÷=æ#í÷fͦ s³Îù…Áó½ ¢B| %ÐÜ,òý7¼¾!úÔ°çÝ)æ.¹Šž\¾%31™–íËß¶�„x�xwd%z…%(RV(`öÅ¿¹tž‘ ë.0µðÊÍ$†*aëÄŸXJšI�±Jï µ¬šÕ(7óÉaóo¡;e8R±ŒD[Ä:NÇëèì¤t³–’fØßc`Õ÷#U¬6^Æï¿9bnÐ-#Ñbñ£þ¸Oû>èè>M[²-šŸP'‰ÓÜõ„×À¯Ñ¯!æAZ‹ð+ðòÄÙÏlv«Õj˜wr±G¡3¥æÝZÇË¿ÅOŒŸe½·ó'w¤Õ(N> s# NÎjµ]Ad{O_u—õ6¿ÞT³Ùôä$^}-~¥Ïä,UgÆ­‰4 œ±2ñÃHU_�¥ßv+HÍnfcwÇÜ2ì=$mg® ÜjäŒúŠy¿B¢lÅ¾Ò ãmdø/ßÅw;q†_ÑÚ:»0ÉSºßÂçÁòR!�•ŸÕæúRZ.MÓdRk·¿aÒ29á;œ¬°2‡¬mênª»©¥k8î $D3ñ zbsSÌ€œ‘Œ¾O�¹àŸìg$è5Ý{ðû1xÜþgˆ@8à‡Hüïo¢‰¢Bci1“)6ð¬�~Gd^À¢9»ÈTWZƒ–Ö4õ•5S“o¶·{™j½£ÄM늳ƒVšçcÆØÿþ†ü»È]ks1]b›Éb ñ+h†ˆï µœ·Žp¤Ãd5ÐøçòÒŠ&¿"S_Q†U”­"%HS¯úný-¡Á}ßNüX0~t¾.“�1~á'¥GrÆÜ/ °ܲ…�…¤°ÿúþë?Î6ßY'Öï¼LþQÜÞe*p3MiíI9V£´–’Yb‹9”ã†-½CS¬ïvD²-Ï”1Œ0x!ÒPivÚìc“‘ø?»{Ûz?tÞš3�}…Í’'ðòÛ yÝx¤,Sš—‘—£Öb¥Å{ó3(øLüÓû‚…ºñÀo‡„>x:$𨎸zeäÊ»ŒË�_]J=¿aeÖKÂ~ÃbøÕÇ0f=üüÒV¦ÚèµV9 ãå'Ë&1{|â šM¡x´ÍF‡¡iï`ö¾ýQþUJ‚ÆÊ��g�ž�!gβîŒÁÁžîþE§Tš¦H¦áÔô�Iþ\¯ -DŒ¹ÕPèÿ"`kÐ5 $è.˜+1¸JãH+^^bÞu�´õñ£÷k÷ˆñÑ1ÛGW•9ŠhüR¡>ÓœfÆ�ò¸ž<×Ñx´!?é0­¨nI÷Q½�Ãušîƒ¦.=¾&ŽÚW˜"gö&Ê P²¸Dœ&/,gòÅ6S=…ªD+~Tùqß=^³:ƒÖr­‚BxèbLœÈ’Ks³”õ¦ÆÔTžGfÅoH,¡ ż®ªÜç8ÞÒÞŽµ··Žö’LŠ£%¨ ^ˆQÿæ¯ÛÀ›ftwOÊÒ•å?þØëïÈ$Ò›Ó‡[ûZ;sû$ä*2hÉ[7Œ0Øu-;ØyJØ+nôÖý„õý;ûJ[*ݰOK›z��?Ѧ?°])P™^ø[œ -žèU¿ñTx_øú)ƒŸƒ¤äïøÐD %@íGª}õY²};Ò³2|x­UY©ýtyéLRÖ¡äxrwÇΓY4>²öà¡=;Õ¤ÆZâ.¤ñQ®¢êr¯ÛŸµ/&Ÿ”WïoÓЇÎéORAFÓü£¨Ý1iÝšŒžª\GiY�¸kíÕŒ®¡�í¢ð¡‰S'j:{˜ŽVoï09¥ô¥µÓnçÑ:7åªÔë­L±­NÕBáˆBÃ×—¿‡'L;S -’ÒµŒö`¼YFmJ=ÕÃ5Uy£»ÆÜ@áà †sÄÓÊ’¬-åO]¬k8áM^MKš9àšZ"ˆºì �k~b›HUT† ,_n·MZi·ƒkÔ9°l+•"‘… ›¯Ósyn=6ij7.'¯ÿR¼\iŒ5Ñ·F9[hÈuüÅÌ1î1÷;Žq�]e)1cëÕòW£$ð²¹'ðQ�°®òrpUØC@ð?œj�¿Èþ– › E¬Ui»LB¼¸³âp‘7 žF»"½YµJKfâM6ÚËOð�ƒìÀíªgØòœY�H Õ‘ùÞb�“¬ä««Ü4¯¾1>5ú†sÞ-rd³©lª4‘—ÝÅ7ôƃ»â±ƒŠ^áÈÍ;”šôR 6}?'Rv=+•®ã¥?H‰ÄŽ -¿yüËUßIz°žƒ­("ð•`@«‰#í‡ûª;?†¸QLÀôÚŽÎ.ßÏ_�ÍjYejÚ]yÆðÃݦnCAÊ|TÉrËÒ<dzzÈBYžãyR;PáyÃ~k -9»�MI»§8ntV´½�´lF«±F[U¨/ʉ�a¿Í¥«¦>$èB¤¦²Æ\C¹ë- NæoÀ}‰,¡ÚÊzS åöX½NfÃiÏ1OÿÔ=µl–|ÿ½-€=K³{Zi,ÑóFw°Ú7œRýŠ›Ns¯“Æ *ñ� ì~îúT\ç±W3MbkÓÐ N‰àÉ¡ÆF�­0§’V¸Z³û¨£Í ÇÚžx4áÕü$ƒ_5�£ëÐÆ]NíÝY˜´�IØ'_¿š4=ˆ‹Þ÷ öž#ʳ ™)¤Åôˆñ«7üÛÓªM«¡ñKî,o^‡“”›{À;U~›:üD}îį‚!è_/]_¨×$Z‡¾‹s80s/×ÙD6ñ=|­wäôz,Ö¤*ÛH­™¨ÙÓÒLÿ§èw­û£™js�ÅmÇðK¦ãå_±NÌÂò&¿jÊ/gs(4&â~Áïâooà=“ǰœ¼>ÿ~2øÇï�™í2)Ù­óçÁ ��CáCð¼áøp`Åw³g¬ª~•¸½(í#ÏPîÝMÊÜ{š2è‘-—ÓŽe`#Šaé«äîýi[7FOþEMãšG�±Ðˆ±,ËRk�;«ä4>ü«hêÍÑ:ßÓ×Õ=r–ÏëÍ8J'{µ+Ù‹I½ÆCNõôœúSûšMut­±…«raÆ¡ŠÓ´•¡X•°Ä!}à í(Ô(žîìUô!1�à!Á3€ì쥕=¡h. -��֢ͤ$Y7ûÇ``@xHXá!ïw¦^ãÔÁ£¶ßµ}xûð\÷·_’�Žfú Å;Pø³»�¡éðDÿÑšÆ~º|}zt‚lûžè²Ýp”È‘©ÌZj£òÂt�ö�M&£K¹l¶”‘¼Y¯‚n?œºå€ƒ§CàërVr9{ 1 ,¿[yK�~‘¹oE¡Š·ÑGQmm®5±ÍÔŸÏ>:ÈŒ yÞ™øžŒÓöšJËAÝ`#† �‡ÔOg(B»S@ŒHä!‘Í@dF*Ýž -s!ô¿`-l&%ÿÐÖæ÷ +xœ�Wy|Su¶O(ͽ@'h/)å^½·*â +ÃCV„éPj‹J�¦I—ІnYº&m³ÝÜlMÒ¦�6ÝWÚ¦K …–ÖvQѺ0Ž#ƒ£Ã{ã(êøF߉ïÇ{ó>a÷Éøá�ÜÜåsN¾÷œïùžoø¼™3y|>_ôRFŠ$7?#» ïIn†tñ òC©¡±A*ø€9‚>Á£gó³ùú1{à¯%èâÑÔ³áòx¼“säñøsî�Çûç?#ÝúGÄÂÐ×W�òÂø|�ðÅ ©òÉ–TIv~F¾z£ü°:7#-=?æöÙ²¥ÿ¶lñ²¥Ëž�‰O—ÄÜÆ³#Wž)çÇl(ÈO—çæ-áñfðø¼GÊ<ÁMµžZˆt÷zÛ�TފѳgcEÿŒ˜eŽ˜38¢æ@”;âWÁ1Q�Ïãñx�†Þjg6s¡—á{:t�ä=J¹�÷_?Ÿ1ödXßÌØ™ßÍü>ü[ÁzÁgØ ˜û—ÌZ>+Ö™Ù«æÜ?§?¢þWDŽֹâûæßç»gdlä„�87oż3¢»ÌcÁ+c|óXpáX˜yfÐøãŽ«FÁ'ÿC‹`8ar†_ÇE¡3º‚Bp^{~µ +CI0!B¡ øB lG +ÈÀ×ïð¿„(ˆ…˜°/áœèê +l¥Æ´]Oëtæ‡pnbbˆ=±Ðá07êøv›Æz‰„Y˜¦±A×LÁÓß| �M)Î¥0½é»�¼Je'¤ËÒ�ÀÔnl4“5l…½„’j_.‰-7é,J‹ŸÔ»+âHˆBF¸0‡Ùî [;üž&jèÔn4kEÖâg5¹Ž¶\F˜¤=ûò{ðe òD< +3`6Ì#†àÔ¨(¥ªM}‚šhèõ3Ä!S�ÁYæÄµ¥ZƒŠ*ÐÕ�2X —u¬zÍ<¸E^S0Ð×ÚØlg¬ƒ6¹Mn‹¯æœ5Ǩ@¯ÌfE81ôpæ†ìµdlÚç¯w·£9X'Bј27·HM(îèò[»Þob„èþz¼óø_CT¨ AÔW}Äs„v;]UG(Wu¹ÖÉTTy+š¨ŽöÎ@kVgZº$kË>Æ 0uêGͤ‹­p–PIe»J¶TštÕõ‚”Ç‘èå{+½Ð©=ß4Jhñ˜•‘~ˆ� Šxà”È’g)4“eœS_KùÝgk§]‡Égrà vÍÑß‘Á]qüm«ßL»*må´´l�f“ÑXÆ•ÚËñ7õv6–DQñŽC•gϦ�…£p´`GC쨄‘÷µ”LQmNÔ60Ž“¢BÅ®‚2jwêÌšpŒÔw1mÞ¶£�Tk‹1³™A,Va.ç*há‹ÚÏà™A ‘~ 1@A\ n‘è`J‚FBß?·wøk¦Š³ÙI¨4Û½µÎü=ÆWFKÐâ� Û�§2ý£EïSÓïö~8ÆxôuZUÁ"×kï¯õáÍGÛÜÕT›?g�Î\j21B©Î +ðß„ð?v +‰l{ìIN ®««hŠúÃW�Ï{*Úò[y÷Á–}>\ì-éî ›êë;z{dÛ[è:c5ç®Âû ýåÝt­,×OíÚ­”ɘü|�ü0™U“W¯ »2&Ó;KðAuuZ)“NÞ;ò¡‚.²V°E\ø�©'8=äTFBÄÓÁ'`®(xö–ÛßG7 +~È]çeªë9›‹!ü•#úqvçL–&¦�(L¿–B ÿ:4Ûn•0&“‰e ÉÚ]š½¸Áíek(búßPËyjTàwK·3W le¡~�ñ&{F¹qî­óìØ-ö¬±Ú/‘ÂóõŠ ~t!î| Q°¢ˆ‹Á˜'‚¥ÌH[.Ý$M�£! #®Ü…+š[\¹º[YT¾ýÖO¸anòTׄ=h-v]"á Ö8VSG öªã´[QTžrGT7wjòÄQÄÅíÖ"×§¤M áûkp ½‘_C,¿þ™÷qT Á^Ìn¶ÛÉæ�^·—ìüWéJl-t}JÂR¬…õÝt}ÿñš£Ô`û=A»ìZ¡ÄcË¥+IJ�ôñbqÇ*m£DÇ£ÆNc“™$.þKÝ»ë˜�´ßY5›64æ&m (ðCó½bÂü ¡ùÿXäûg|þ!úô°÷Ý)æ/»‚žX¹-;9•–ì/|y yðªèÝ‘ÕèA‘$K[%ƒ¹þzôâ;ŒpX{!ˆ+ù—¯1,X D°ûÔRÖLz Õ:­f•¬J¾•K�XxÝiýÑÊ$Ú†iÍZNKç¦dšÔ”8Ëþk~©`Õ‰îÀ­ÈSƒv‰–b>ëû°£ûuÚ’kQý‚: a±v<øÁßO…ÒŠ®\¹ü.ãÒÖh¨ç6­Îù-…ð_ð~ý ̃9@?·¼•©1ø¬ÕýxÅ©òIÜž˜<ˆæR(­BsÑáÅChÆ';™}o}\x…¢± +`à`øgaQØÙ³"IwÖà`Owÿ€¬S,Î�¥ÒpzæÏî ‘ª^ñãÆCø¿BôsâÿŒ'—È`FLÿâ Ñ«Ú÷àcð˜+ò/… ÑÄßß ÆŠJŠ šR&Ós¬�~[`ZÄ¢y»ÉtWFƒšV5õ•7S“o´·û˜�£ÌMkKsCë¯À;ÆŒ±ÿõ-ùw�»Öæbº0›Ñ¢§‰Ëh–€ë ·¼c1“£UO_TJ5•ELae¶®²¯,7^C +ÿR¯F�¹•Pˆü¢`{H ,$.˜��è]šÅc+ËL»ïàp7z7—°#FÇlSfººÜQB‹uÙ¦ Žä'ðÄùŽÆc …)GhYMK¦Ÿêíh®Suò2u™‰žj[Bqš”Ù—,9ˆÂÉÒ2,CZ\Áb•6c=…ª«~Ö‚qÿ^µ;Cr­�“|¸ÿBÌB”#çç6ÈëõŒÇØTQ@æ$nJ.£õ¥œ¶ºÂï8ÑÒÞŽ···Žö’ÊJ …Oj?€/BCH…W.ª1Õkh©8C•M­ßñD@XËä„ÿHªÌʶ¶)»©î¦–®á„3ˆ�f?ò4z|kSÜ€”‘Œ¿O��Lö3BTT¯Æ)€yüïB¢øºŽÝ®’\³ºâÿkFü½YD³E™Í™ƒÃ­}­�ù}“òeY´ð¬©~;‹{ÀrSõCÃVâ›»“ùÄ ¶ùVî,[¡óù'¬½ËXäfš2ÚS¼RÜ#·–“9˜Ån6[z‡¦Xÿ͈T[�1káð|´¾Êä´ÙÇ&£‰º{Ûz?rÞÈYÀ¾ÄæH“8éM½xÍp´<[\�U�§TãšÒ}…Y|Žýòð¼ym7„ŒXh‹…̘Pû°¶ÁA_Ý/lƒ¥èIcËÅ›öKâic¯¡óœë=+¸ÓÔôDzà7è7� -�%ÄexñCѹÏmv«Õª_pj©W¦5¦ëÜÈæãÞä&ÆÏ±¾›Ù¤Ž �ìÔ30?Zï4[­¶ËÀ‹nïé«é²ÞÜ—o(ÙClfj +§¼¥¾Äå>£S£ÌNXmÔë͆ªä�¢}K¿íF�’ÝÊÆï‰»#dØwXÜÎ\F„Õ`6è*ü reû5Y†›Èˆi×Åu?yN\VÛ9»p¡ •àù¿%(àñ~PôNGVÿùož„¸„e'†&‚iAZÔ~´Æ_ŸÓ!Ù¿33'›!†'Üj…%™:pP[�ɤäNM$÷tì:•C#ëÞ»KIª¬eîbš8ã*©©ðéð9ûã +IiÍ�6}xà¼îõaC|Ó =.n£[SÑ“U(õaËàQw­½†Ñ64°]14qú¤§³‡éhõõ“SrF;ív«sS®*�ÎÊ”Úê-ñÇ4|u…èð¸qWZQJ¦šQJ4I¨-É£§{ÌMÕ>Æàö˜(bx08/zJ^–³­âÂé um'}©ki!¼hê ~Ü﫺1—œ°6‡/è]}[)7Äi­Î\àÖáƒÜnpðv0b¡ÛanÔ:ðx«Üv‰„D¬³òH‰/žB»£}9µrKnäŒ6ÚÇMp�ƒìÀÍ&dÙ +œ9�H5Ñ…¾R¯“¬âjªÝ4𯜟=ã\p£W¹l:›.Næ$7[~Fg8´;?${þ%3¹u§\•©Áa v©Ý6i¥o ³Y±x'ŽXxñ¤±Ý°’ÚQñ·�ýc¥âGaO¤öÁ³°EA±ôh­èhû‘¾šÎO ax0³¶£³Ë‹¯ksY5+Oϸ=ý8q¤ÛØ­/J[ˆŠ¢Y³™eiÎ̱z HÂYÎÌq¤z Ò{Æ~#…”}™M˸ƒ½' Îʶ—@„F£­z›Áj𨫋u%yñчJËÔrŠØ£6ÚJ(IA޲ÔZäÒ0—·ÒCy:mŽZ†XÝàno®öáBX¡ ”* ?CC‘ ¸Öºðqþ÷LJEbd«S?)ÃÕG1¢ôÞºû£«2¿–!NÃ,ôBxr×Ðþ³Ôà¸ÕîflUl½Á‰'ç7ä z¤á¯5~<þ9X|v›Ÿn”ÆW¯§¾@/‹ÐÜ ªôØ+x·©aâõwò��æ¹Áe=|ˆa3̃/ƒ‹D¯ªŠ +×¢£ å†*cÕKm²›ì¬­¤_W;u»ŒbvOzâí>¼^iQúvÃ|4]ìðê<”Ûgip1ð œ÷ {Ú'ì7¹TÀÊØ©”;|«ƒBÈ¿Ä Òà Ã‚ +øT¤:UvÂLªY•Yeyy£�•“Áë¢Y+ka­%ÝÑ;ºz€Mü)«ª>„h:ZUå1y(w½¥ÁÉü Ì_!K¸ºªÞè¡Ü^«ÏÉÀ\xÝ{ÜÛ?uB5›#=p熱ç¨öìDË¢ e:ÎàuûšÙ�ô€ìºÙ‰»ÓìÄ¡jìçãnËÃõVçµ×0M˜ƒµ©èE§ðÄPc£×VœWEË\­¹}Ô±æ†ãm‡N>”ôJaŠ„!® ½A�w¨�­¤öí*NÙÏ$í—n\KïÅèÜõïì>+ªÈÕg§‘J׃W®Y,o«:ÃCÝ9¾‚.¬0õ€oª6eäw󅓸úÐâüíElº^•leº.³Ã�›zÍ�Md×ÃuÐ:Ç!³N‡Çå›©Õ 4{[šéü¾õ@l#ScòXÜvœ¸hpˆ’í¨”(‘îì—õ! Hð’à…Y@vöÒòžp4…/DëÑVR˜ª‚c00À?$l€È°÷»DÆ2NåÔÂC¶ß·}tÿè|÷÷_‘�‰f¡¥;Qä3{Ž£™ðxÿ1Oc?]±136I²colyœ‡n8&Ê“(Ljj³|ú,ðºGûÆ&SÑ s.«a„oÔ+ ;'‡ø×íoðT|sMÎÊî"g÷$fÁEØ»U7è‘ìý«Šœ¥„V9JjËiS­‘m¦þrîȱAflÈûöÄOd,T¶W|X XtƒM4¬‡¤„D:KÞ�"‘—D^4 ‘Yét{F8̇ðÿ„õ°•þb¯÷ endstream endobj -396 0 obj +391 0 obj <> stream xœûÿÿÿ ëî endstream endobj -397 0 obj +392 0 obj <> stream xœm“Mo£0†ïüŠÙƒ¥ô�Å@mEjH�8ôCMµ{&ö$‹l˘CþýÊ'©V{ôÌ÷‹ÇìÇÇ~þ"õçÅOŸ8êÉ œ×¯�IÛj1 ¨Ü¢DyõŽK0V‹Ôí¶U½Kk•8O¯1ÿ Ùà©W÷ßêitzHûêÝ—0#„™ •¨\ï.ÀÆ~¡{­–�%Œí”¬õà‡“4ö€ôÃj±GÇ^I;ÁÁ÷M²d/\¤ðCgBòþ2:ZuÔPP”œLŒH?ñÔ�Î^`{‰Gò¼[‰¶W'˜]‡ýæÜOÆœÑ > stream xœ�–{XWÞÇq *W¦YuFgl_»«}m±j×ꪈ­w¼£"¹‡@Â%—I&Éär�@HÂý&wPêªxÁ ^i ¨Ðn­Ö¾]}Ÿ½¸'Ûqö‰Öjûöíûþ3sæœyfÎù~?¿ï9LÆÄ‰ &“9}sr<7K˜œ!ÊÞÉÍJæ-Ø <”–œúÐ�úgB1ÿìP6™� ϯ¡!³¾–Ò³f ß-†f3Œ�§Îf0˜Ó§Íf0ÆÇCßt�‡Î Ü@蛌 &3˜½)"‘ÏÝ�ÈÍ& s#ù™¹Yɇ“„s^¶½¾hÁ¢w-ž³+‰;ç嬿lËâ§p„s"DÂ$~VöBcƒÉ@ä.ÿj—§äaÑ5Wƒ3˜V…È‹ý?ô°h¹}69ˆÇ“‡N2„Né˜<4ÅžÄ`2 ƬÀú^3 ÆÀr3]¸œ cÌ @@ -1246,134 +1230,122 @@ TI ^dGYa ÞöB/ƒ ƒ»±ä”f›Kœ÷;n°àcýÍ]ê®ÒÈœ¸'Û I@øe¹Õ5åÍÇ#"vÌKKÂvïO[.Y°•š‘«Wªt*Ö+'åÛÁbz¢€ž“Cën˜É¦'É뀰œk`‚iŸá`а›£# J³ò[ó?NŒÜf�é`†„7 _ÓAO{‹žòú¦š÷Á´¶3•u͘hýÁ-âvì\Ê‹T²À8Ï9“ªÌB—‰oœ¼uvô%¿qHµ›ÌÆÙ[tõÀÞ új³šÃ@Ê0ˆùþ„ÜâhøyŠD*K7CCQ=®•˜tP‹±×ØÙÞ«ï �k2Y¼�ÕH™µh’ J3ImåˆÙ`1Z±. €H_ÕŒ‚ÈOÀ”/ܸÉit#’‡éyüç¬-ÊD”c4&á”N+†´z“΂¶é }9™�P­žÂà»#¿©·ºÊn çÎä.+Ðåispš!Þ·ÍN1™ œýo.©Ï endstream endobj -399 0 obj +394 0 obj <> stream xœûÿ þ#áö endstream endobj -400 0 obj -<> +395 0 obj +<> stream -xœm”IoÛ0…ïúÓƒ€ä�š‹,%�aÀ›² Ú³#Ž]1%h9øßä;AÑC<Î�ó¾‘é�×ÝÝÂ5|g*zã¾»ŠïVOû6IÓuS�'öÃ3³cw‰ö�ÔvMÕó@«ízëë!IÓ­¯>GÇ—œÿ¥,ùXû¯„PƒVc?4§$Mßëá“é =ÑÖ±êáLê6IÓ_ÜõuãI'iºñnÕœ‚¹>™H š¼vMµã�µw�T¢�P7ц\] ¢âouÚ·qóîÜ|ÚúCCYnl%“ˆhòÆÇºº3ÝDc·äø€ÈK縫ý‘n.f¿wcÛ~r0I*®²wñÿ$À?ïOL¾® -%鯥÷sËrÀä÷Sã.BÃbÕ8îÛ}ÅÝÞ9™)¥ÔœfeY–óPñŸx.Û>ÕŸ}ÓõœfJv•‰*ŸBY¨T%™SìË ò¨ŒdP -êû4ÔÔj%§,¡r¨T µF=q¶AìªD õth€R4ø2œ¢…¯€Ÿ]@�¯x€>¾Bö�/—Lá“LáË¿â`œÂ¹ãT²Á˜¡o:0špDT`,À¨Á˜aŸ£Å, ó%­dÊ óë¬ 8 :b„=0àÌ×Pà,0Î s4�Ó\zgÀh%FçŒTsœŠs0Zq�~€s Æ =·`œ‚Á -#zjeŽŸÅ×`Á—Á‹•ï||™(™#ˆ,æ˜Áµ_&õÀW€ÖÊw&ŽNYaTñ -Ê] —1¼9×Û_�]Ç~ˆON¼êá^מ¯oWÛ´aWü‹�Þåý ê¥ü p÷oð +xœm”IoÛ0…ïúÓƒ€ä�š‹–Ä $vø�qОmqì +ˆ)AËÁÿ¾ ߨ Šâàqf8ïãˆL¼mn\»ãûSÑ;íÔ×|³|ÞvIš®Úz:²_˜»st˜S×·õÀ#-׫µoÆ$M×¾þœŸsþ—òȇÆ%„´œ†±=&iúÑŒŸ<§+,PôDkÇ~lÆ©ë$Mq?4­Ÿ“NÒôÉ»e{ æ†d&=höÖ·õ†GÚ7ÞõÒ‰v¡o¢ ¹¦EÅßú¸íbñæ4Œ|\û}KYnê$“ˆhö·fû]Ec×äx�Èkï¸oü�®Îf¿7S×}r0I*®²wñÿ,À¿l�L3¾¬ +%鯥�SDzÁì÷sëÎBÃbÝ:ºmÍýÖ8¹WJ©ÝWUU-BÇâ…”íöõŸmÓõ‚î•*í"*U‘CY¨%T%™9ê2¨"*#™%”‚ºE�†ºƒz‚z€’]¡ +¨%TµB?qö„Ø-T…úépJtÐà˰‹¾ +|ö +|å”ð(ð•R¾B2…O2…¯øŠƒ1‡s Æ\²Á˜áÜt`4a‹¨ÀX‚Qƒ±xŒÊ¨K™€§§g 2#s\A 'NÙ€3ÃtLà4ç12G80à4pgÀ™ãk0`4ÒŒ™ÄÀhÅydÔwà7`Ìp®Œ9ˆ,-œYðYÔYðYœ©•9Jø,¾ > /sÌ@dÁ—Áµ•9‚Ý‚/­_&ýÀWŠ3ùNÃÄq¦ßj®â”».cxs.·¿žúžýŸœxÕýn<_Þ®®íBUü‹�Þùý êµú ”ùoñ endstream endobj -401 0 obj -<> +396 0 obj +<> stream -xœ�YxSeÛn í1RÎÑsás#"*ˆldʦ¬2Jw¡{$ÝIÚÌ““Ù¤énJw›tS:(£  ¢lÄ2d8üÜøxù~ÿ+…¿Oýþë¿®\™çyó¾Ïs?ã¾ÇkØ0/‡ãó^x@p\BxTbüÚà¸ð�WÖ‡&Fìˆóü¶�%اõ#Iö™‘^äp/J¯ðª9¢axïˆ^ëÈÇØýb®ÇËËËk–çDO2z=ã9€goÏ{žz¼½fy–[îu�³”SÎùñ‘ Gò)âNãþϰý¼wy6þ�Hð©à¶pÁ£³�>nx×íÈGGÖ=ùد¢ªQâQï=¾ìñ«Ol÷^àýÖŽ�zr‹8PüÕSIO5Ž5zÕh«�Èg«�sÌ«cŽàÓñb4qž@OôÌŠgÈ8ÊgìSc‹}õÝì·û9únvB7W?ŒÕÞ]q_Ë¿ø¯§Å0 ¬0 Yy÷ùl·Øóy>A -Xû~ãÝ7 Ð8 F³Àƒ›|š¦pé$ì‹.½Ô»§,å4Œû Û٤شٸen°Û3�ÕZ-z�•RVVj‰Ã?W~bsË¢r -«\¹;0¿omØí.}?ëÍ\Ò¢*a,!–cl042.!ViŽðËÛ@Ì]ì·lž+âÂ.êJx±Äßì' !±Ú ÄÜ•¸[¾WU.Ävª,I´J%�UìƒÀfáâ4~~׸ìS7ÅÁ!Q©«‰ÐÎý”Ô%ëx‡bÏaµä|ù¢¦"Þ4ôòÚ<_W0èîŒ?C|v¨þ@ ¥µ«Ì2FˆòaµxŧleDS»ä­L�ZN‰P[±äîB»^ê}«k¼"ñ4¹z…–T©ô‹JXÏ42--M´kä‹EïTY„+ŒróœÝ!ÀN7µèI«Æ˜IÆ)æ¤juY†T‹Jø¾Æ¢�ƒ‹�·bËuq¯qÙñ_‹5¶,S&#ÜîŸèOÌ[q…Gº>ùäƒì°0cÌËtΪÜÚž5-/=?n -�Äg¦€÷уŗ»)ÊTôÀ?›a‚�óe/·��+N×Ȳ¨ �š¡MäèAmtGGwéÞfRgWYŒP™KĨj>¤Àò‹Àžg²Q%“Ö &ÑÈf~ßÞ-Z£Z“©Qg’r•B�¡Ê4 -­Rf´"..B×ÑHâÀèfî/·Ä‰’èˆ -E‘–*ÖªpIèÖ ¤Â ´*É£9ïw�Â�Æ6’"tDô¢¢5 ‹æòn¸²ì¼ñ9Ö -]âKNL7ÑÔPX⤰�Cc“[„*eŠ"ƒˆ¢›;(xNãgVΛ>ÍwM¼C¶»ºÈ™k¥­:IiK^»'§ÉÝ™‚xJ­FK“oHxXëKñ ×/§Ž=U_“íÞK–ð °\Œ|*e–ДĆ'D›[jÛ�çŠ)‘¬XÂŽ9`”zßþlv/ø÷bgá=¸'ÆZUJ•Άӕºfµ]ˆ¹Ì:�1‹ˆ–Çf.ÌÔ© ©•ð�:G½GÓš•ê~|Ô0-LKK ]3€��f…é2ÓØq§Í‘m#›ÚK›‰gF‚ƒ²K 1‘8zÙ³È5©Vé%fÏ"uLKKƒg³EïT[„kÍrÏ"/z4] µdiJ„#ŒÀÎn^›±h%òSt*+á‡zØVSèAnó5ˆéŪàz·Øl²¥ÐŸ¦Ç³µfÆbb»J‹êó�Y-}¾Ê"\fÎ,Þ‡³›ƒðÅZþ`£Qo$öjsôïàèI�R§S’š€Â�Ä’í‰Á�”¿쪹8õákàEbUÍ�%-û¨œsâ$]VºŒÜ²+5Žð]ûÝ 27çv/æƒH ΛÛPˆzáäŽ2WM�,,�LÎÎIw…eÎ’By‘¤€*Š�5oMš‡&S�ÉêÁd8‰œüi©_Í` -×3--]tý@ˆfšT¦+¸h“¢žUÏi½ÆkÜVØ!žxñ`üÇûv»ÜdûÞ’�Žá¿¬�ÇÐ+K|cüCÈPÿ¤Õïá° üÄ×ÎD�÷Òˆ-φƒ÷…ëÎ/¿¢D ž¨°Ã¥Þ7zac/Ö‘ -qs§Ç9ýA‰Ë JÒŸÖ jLgõ¤QkT“j:�NÛÊ„�œðð$û´¹²%8ÖŽ|ýÎN�#"7å}IÁÒ¿5íÒäÉ—âh�`aÍâïIQj_ôãçF/„ôbŸÂ h÷cvÿÁlãfZZ\žÂøŸ˜Ý—Pó³›Wf,ZAÑ´ž¦I­F­rà $ò°óC°÷õ_aïþÁ4™fõ@ ]žZÜ䢫sÍ”é d -—@‚›åu¥Þ=™-¿†õÂdv˜˜®ÑUx2úü_fôýÙ‚?©ø]C*þ“Üt/A®‰¶kHEy�ªŽ8Ü]ØÜJuvT~x ÇnÝ™óω[7Fn $±^•J£§íBìëâq]EGM5ñqÏ|Ä›5 K3$SÒ"�¥‡¥§ÉæÈ#EèºâçÈî‘6qTY|uuYYuu|YTT||)‚ç ìÍNãmvÉmîÝIpY �èY¡Eh=â¡Ih=ÚÏ¢Q0 ¸7º>ï![Ž”žùG7 C >¿¡GÐ6´è�ñˆ�DHX!ß_ýžù¢ÌFX},BT-Äœ÷­ÕK½ëN\ž{6_,êÁ.8ÙUìhqqQQ‰3© &Ö/%<–ÂÎ:³e;KVS¦¯|Õ·,¢*†ÂZý£ãSýÃñÐ’èŠ ;7ÙwWôV|êå˜ @À?ŽƒW]ZyTYô.B`§ý“ãtÚxŠNSÐj"*,¯­ÄâtRéeUÊfâÆ¥žv¦WFÕPvkI^.aµj3-vÁ™eÊUäعÉèøýqbmN�.·¶Ê˜Gtï¡S«©æDGz,>\ðk¡oUŸpÊ«ëIì¬VÂñ¤-I!oežþøTyCÏGî­ÓH:m½ëîpNÝáž:úŸ>‡ýÃþ3A(íÛíòvÀ+0f#°›à�¦Š ªr«5Á·ýç0¬dO^A§å!t°¥tÁD¤"v³N[§J }%û(S3µY%S È'y�ºø°é¡YH‡†Ç0Ò~£unfÅ -à¡›4«"Z¶S�!”ÊÓ3ãÒ5F9•™!)I­t¶dÜ@‰ÐÒb Üþçò�Rï>›Ý‹å¸'ÖµÐ}é`û»7M¦Y>¤z63--Cªç»f™ñ -”+¯pìv‘9»]ÂfÓɳ)ìˆÂêÈ($Êv——SXuqrõŽ-ÛƒH,W%Wg›qøÚ$ì$Ç -“~†‰ù°�/~¸z$F‡Ç0±ýGïTç(œ`4úÌ'Ý’­²¶lK�•úèŸÃø*ßBÁh8UÐZXµß8æábR:‘ŽŒÜ1èüóETzØ[(ÈG§Ñg9߀hŸ¤Nƒý`¿ç#é@:2nç E§ÆU´Í’êó.z7c§ŽÎ¨3’º˜‚.ãj(–°K¬z)<ñƒ^êýÕ¯÷bµ°ÄÓÐüØGݦ�õ¤ImÌ"£å�ƒžîQÛUkú<-×®%\}ž:jbµ+úJÖ:™�Ç–Å–U•U:Ë$U1$æŠ�Ž�§D+n­„¥öö—òÏ{!üV3XR¬Ri 6Þ`uCÊmü_–Û4A�¬M'±ª,³Yã ,»-ÛfwXô9™Â¤Ý5ªzâ'q^Ñkç§ú§DGPÖñîŠ[5q¬{¿õ�—#$¥åR -Œ§Éž›CŠ,}½>W -j·÷·½Õ‹]bwz*Àö5÷9HeÐ�Ø%YdF MGø·ÜWN´¹åÙä&»3­–(u–8?|³kÒÖuÉ~ÔŽÍ™+fâi›ÿÐõ?õt}ù�®ïf˜úúö!Þ\fRxʸ j³¥)´ÉƒôuC�ÞÀ4Ô7Ó�ƒ£~Ÿ÷E¿)ZÙ‹.Îõ«ðÛ>.ÌaKÄWòÍŒäë¶Ð›é  &h Ã�j ÕÓpÔ&@þàôìØ,$!Ip±ÐtÔÚoLÐ ’ÍÌÖÃóÊBíÛ8¢hXÂÑL¿€¢êHrs§î³ã¸È¥¨ÕI Ã nµÔû—«ñ Ö«=®œ)ø¢8-!�ú Íãm©nÛq”È/4˜í”ÉJÛ4ÙÂmqî¶X -yC¯-ï«¿âÝ)­¡n²Ýo¹ñ½-;”¡¶…a¶P·qªoÿ÷' -¦¥¨ßhŒíL'ÓÔÔIïÄgÛ»Æóü -«;“ˆ†£'D¿HùA2¿ÚQšÅê›Ù_¥œ;W¹ðÂSίüF§§ìÝöã– -³Ü Ó çKCV�#Þã%ï§Ø)‚+…æSžÝFo¡ƒC· qПïŒi>¸ j¾»BÊ�ÉÍ\ß]ñf,Ët.{(—w!x#o˜ŽÞ„NÑK0áðV9–Â=q‚ÛÊ´›n.†ÞNGFF*·¶*¥*à:Â|ÌJ½V£bÕsÞB^�µaº1·Z”255UtÅ –‡š²L¥u}í“í0Ñ–Ì÷gøÔû¥êvi8†‹ihª¤Ëúm¶ÓŒ�G^ÌGc¡�f‹çŸ¾ø­±³ÌÜ0Pú°/O뉌ŒÜ¡ûrN£&G¾t²�R¡a²r„"·Î‡Ü w{ß¹ -—Âob,<wŒ8Ô—a‚þÍÌ!¦±¡B÷ÅÈ Ø¯àwð‡k·÷L-§ Œí.o?pÿ4ê:ZA†ùêB‰6ô‰ø$ûž92ëµyÑ+ÐËïfT£ØÃêí×IŒ=|6r⛫"§Qsù¢)Šz¶³Þ»ó,,ü|ã ìGØÅž·µÄ.Û´zÖóé”yÏPX¤Ï%°›GÎ¥"3%&lcæî"•§ÈpH ‰$)5ð‹˜£0âÎðÎôæUvŠ6ð°/7ïn=ˆ×(ËâËÉÒİ znÇK;ÓíÒ²z“«øã“Ž -J´Cç‚…å0Í!Êêµ^x&aß\ëÓ4k‡Ì¤n¦¥ÞEïˆg@_Ѹ.(¦óh»6'Ë–éH=û‚Ou�#‰‘ µŒÎHz@PR[K—ô…›âL1näoûhÌZ“7é &yã뚺úìSLèh:48„IèèaM|X¦,!*"<6)15F–¤ÂOìö�rÿË_•{ÑýqÖZï}àÊÜós®Ã¼Øñcl˜XRœì,¬)*ÍÖYtV;«³ªlÙxyEÃÙ†ýq/-Kذj%9wûò…çRýVáúý†:æóë:tz*÷ ý28Á~Éí}»Ö÷b0ŸÅŰž�íG‡ÿ/e£ïð«ciZGëè1j�F«Æ ‰úÌy½Vƒ£õGø…úÂ|œÞC×Y -…eÙ¥yùDU^J”ƒJ±:ä%Dq^¾³ ³PšOåK#mÁDÔÖÔ]ñTd`Öú×ñ?!œXÆŸ4Ÿ6ºe‹´”z—rò¡– wqq)þåËkå‹ÐSzwªäw#÷úÝëY¹—w#ËÅO³ËÄ:�FGÑÛÔa™›m‡Îa,9[[XÃÀ“FŸEˆÿš0s¼0S¦×ªqe¶:ŸÄbà¸ÖáÎ=`ícRÉ 2kL�Š[/IÜ@�Acøç¾ý^ûð'a~¹1Û„›ÔF%©ŽÖEh—ÌlN£D ïI¾í…µžÇ“Ocû`Üó°©µ]ø·êH†z°¥Ö0MLKKíÔ‘>’8M€]zÀ4›[Kj‰¦ªøÅš'˜ž¥öÕôSÌò>&æ¢Ë(æ&S¦ù2¯ òôy´ƒ<ØÕžÛL4•&.¦ÐÁt…zÿÙÖ{¸âCÛul§¾L;õúÆåIë6�Z­J­³ [3ƒê6«7„oÙAaûÔj•’vEkúÇÔW!åÂçìxñ!�E&Ùø6Ú蓤֧>É]ÇAëÃãí¤Ãè�;#Çǃ*kjÉFx�ôI³XT¹„Ýj)´R0>)Þ›S~Ø<8ªÆÓ±;Ù¸�b-‚q:„ìaGH9Fx� ¯öŠ{`"/×l1•ÊÍt„kü´ýÍ¥‘éaš[›gõ S¸1¥ °'}2Óbä’ÞwÅ.�Tm°©`\LMk÷àÔlÜb*h‚ø‹•F»‰ú < ÿ[TΡµ¬ˆs‚¹»ÄÁþ!~Þ1*ìY9tïµî®Ãû„ÁÚ}›ºÞ¹&§YZÅ�wýšü…¢):{NÊ�Ð \hõL,?Ž2Ç ¹¤Y§×�ëÂ×ǽ`�›6•°¸£ÔRLãÃ)Ô+˜3¤ßìc˜C]et÷ é›?DȆüï=ËÙ{…»Ìâm&” -Ah1i7d[�ÙÂ�MèQ ¡‡d]©µ+­rFˆFLœ„f žî.’r`ö.XÁ,n×@* -‚ŤB—¥Ôf ]Áð("QŽ -ÐpDî -%� -«2‡ˆŸn X�‹*2àUv‹Û{ÿiÈükg©»#ÄÙ« Å/ÿ˜²xÜøë~7©£ ç¢_ÀßÞ¶cƤ•mß'’XR†I¡S¨M³L±ŽÍB¬ý£ª„/‰ö¶œÒzêý††cãwftN¯%W–>×ô~xÿᾫ]¾¤„ÌÑå26«¦KS¥8(¡ÓÐsÇûÔ�ØfÌ £þÏZ-vp=äþ‰âÀž½ Ál€`ïîé0óÝï.‹¯}wéð¾Bán6yíE^ð$ƒò±UÍoµnuÅÿuoÃÝ{|̼+b³oä|¡F+ «Îõéã®rÙÇîþCŒf ¹h4ŠA‹áqô ¬…á7Ëß?AÉmêì„‚úB{ußðW¦²ãé8:pçf{_BÄ[TÂM¥&G¯v…/VùhÊ[0|`>ða$abë´7*¨:Ç�cÖíQ·¤žÚW†Ô#.!jÓ¹Ø3ÍÙRo(ºŠ�„ŸA$f½Û›ÈRþùÎØY…TNc²QX£²C½Ÿn2:Mb'µáˆ«~‡xƒ�5ÎBÃÍÆ`J§ÓÑ”f›bƒÜO¨±;h��¼XÒQñ ±�ßh^AÝ{†¤C@»ŸiiÚ?´3€vмNuÃøO­Ro8ó%vÎÀjñË›Þ]œQ^’Ff¤äKˆ¤¤iÀÕð#ðø�oÀû»Å×Ñ0ÿ�Le2U3xšÆ:uQã6˜Z)ìBÁ ¥‰‡ÝT­ñU¯'BB Æ0*µòJ6™ˆãûý‡ò$"Œëd )Ê>ã²ó Z< ÚùÝúfC6©3ðvñ•j•ZC½7 ÑôWѳÂ4£%¦†ÿWù[ƒõþǪcZ˜Žæ&ºnàX›M]'þÍIA^~±Ã®±È)ô:´ŠQ+Z+Øù4 ;ù­ðá`Çi¾Á×¹�¤_€G?Ù÷ñW·¿OÕÇî¨ñ%ž G›ÇºžëYGEW¹Ó› {Y\X ’;¨ÚØÊÙÇ_Õ¾—¾‘œž¸93™˜¤€Ù×�>ÖÑN‰`A±>Û�η®rÙÿñ„zâiE½‘ñ{ˆ¬ÁñME·`ê¯õp´�›˜àÿBAö2]LSþ!äèAi?¸…üþ�Hu1��]ÿq­E@üQN äp¡ âŹyU»Æ® P4_–‘�¬°dÚ(4åHª%ìn…xÀÓK½ `8ÓÈÊà5lùÝ—@(6¿­¡—ös‡F¦…©©é¤Á‹ŒZ“êJ$;ÝGsÈœwâ¡î�Fë|PØ}O¡Ñjt„NkÎÖRØ2´ƒ5£‰†k�9©±è”s„ØòÀû“U+eqkÔýMÄs£¬¬e°Ï/1«k͇…XY;‘gàCàýžÒhɲ“5ÛDa¾�ÈVð |ªGñ{Ù{Ê÷?¼á‘PxpJŒTä£A£6É3LV%iWÈ - ¹DšÕ�^ì<`¬m¤:›ªÎÀjÜ£%ü•Ø‚ÕRç¨ÖàXk:Ôÿ¹ˆ‚ìÅ’»Ï<à©kÿ0Ûé-tÐÎÍÌ–ÿ‚vfÓÐÐE·ÿ{`�úfhl:!-“º“Ôû׫X/¸á_âɰ˜¿×Qrˆ<Ï?_¸°”rèr v³;¯nM»­ËhFKb·´)Yt<�²ù‘«&ðïYÓx”q°‹ßuQ§§òºó?ÉÞ¯°È Zá|iتÙòw¤tRûµàª1a›‘²¨œz‹EHWÐUnÜ£ì—ytl‹D¯R ×iµo¢�}ûÞä"Và6J½ë¯Ab/v¾G\!ú/7L=Ö§l¹ O“#Wª²äY$v>#Y£•e KvÙvHôÚsÈgÒGèq˜P鲨 )¬mw®É ÁãÙaâ’DSZ<Ž�G)‚dZ�¡$e 1t*±zêxé—=ç.RX[M¥,®”U=¸±W“\ïýU/øyÄ&ODÁùÍy‚×A~ Ónq“gó*l¥D™3]j£$v{R%Q’Ÿ_ÒºÕ57dMâúp -û®,c›{«”I¨…�; ¾™ÿ·Ú“Ë£$Õ¹‡ÔÆ­¦ŒÚ“r -¦É5Û®­fêw]Ý6(\z@²+Ä™¡t�D~6ö݉ìzK1yÑÙž“OÔÅÇåPR›MZA`— F†a(Q†Î&7ô<Ô‡obßý–ˆÿ¦õ éH3MñžíÍ(KË´õ,í�W?ú -§‚W) ìRȆ!¸Ã¾{€¼«µâêüú3'O& ymØþb\ Á('Eÿ Ïg�× +xœ�YxSe÷o †Ï\£å^½WPÜ"¢(ˆ K¦lJ�2Jw¡{$ÝIÚÌ››ÙŒî¦´t¦3¥tƒdˆeÈRùÜx/ßßÿ“B‡ß§~ÿçÿ9ìÖ“«bw„'=979)"6!q²�Ï>,Ÿ·¥Ïܼb,ŸÙÞ=ÂètŒw^ßžó>õ }f{—[îs…µ”UÁúñ�� +(fOgÿϨ^λ+wOÀû”÷Áƒï<˜8zÂè®1š±Ž­{(ú¡_UãDãÞûDz‡§Iá›Â>ìÃG–=rQô¨È_”ÿ¨èÑ·-~ôæc¯<Öë»Ö·eüôñõøË¸ŽM|øxÞ�?‘IÎ!¿¦®=å§ëñ|ÛËÒõxžîaëFy4·WÜÕpÏýëqÌ ÌFÎ]®§Gä}‡¼Ÿ ,¿qîšxh3ì¡Ù`æÀu®M—»´bÏ .�DØWžöLøÛѤȸɰy;®·Ù�ÕZÌ:­…RTVª›ˆ?W~l“{Q…U®Ü\Ї·6îª/;”óFiV–2f3³õMŒ‹�Uš¢òý‰¹‹–ÍsE�ÝI]Œ,â›Äa$V’œg—SÉ»d{•|l‡ÒœB+•|Á“ònn�1.VÓ—p™íyôº(4,&}5¾ÝÙEI\ÒŽC8”h9‹ÙþeôWˆzq¦£—Öæû¹B©àúÎÄ“Äçï7ìsS›Ò$eø¨V‹€SrÂZN4·‹ßÌV«d”µ•ˆo/´é$ÂýXÓ ˆ¦ËT+4¤R©›•ü¦‰q»›iר§Íf�Siæ¯0ÈLqÏvvü¨Ñ­#-jC6™ Ÿ“¬ÑæèÓÍJþ!µY3 ¡¼ÛÃv±š.³=¿©­9Æl†¿-209�˜·â4<t}òɹF*Î�Ÿí$œUyµ}kÜ/>7a*šˆD'§‚ððþ’ =”eËûàŸ-ð´•u­ŸÝæ™+ÊTKs¨,žŠ¡�äè}î‚ÚØŽŽž²½-¤Ö¦4˾$>:'žˆSÖ|H�ùž-ßh¥JyF�^E¢±-Üß̓J�­Ve“2¥\•¥áKÕr�Bj° 6.@WÐxHaÁc-ì_nˆ¢’űQ»åŪD[¤LÂÅá[ü³H¹^aQ�‡í‡ºNà‡ã[‚I:(xAÞÔåå6^\v¦}�µBG—(Êl�ë!š‹J�¥u¨­23_©H“g1tKÏò`â¬Êy3¦û­ItHwU;ó,´Ek$im¶ãµ{ìÍõ�iˆ£Ð¨549MÌÁZ_L\¸~>ã@ü‰†šÜú½di!GËEÈ——¥Tä(Iq|dR,±1Ù]Ûîì8]B ¤%bÏø}‰ð»Ïßé‡À~ì¼wDX«R¡ÔZqºRÛ¢²ñ1—I«5ä±²øì…ÙZ¥>]¯ä¿¯²«VãÈŸ7C®^©ÄG ãfÜîºfLrã¦ó°£N«#×J65·—µ¥Î¬$e“èã¢qô’w©RêÄ&ï"uŒÛÝè]ÄdÖ9UfþZ“Ì»Èó¼>uWR-Y–åˆ °S›Öf-ZE ä�ŠJø¡¶Öy‘Ûrâú±*¸Ò#2­zFÁ7$æFèð\�‰1ëùØÎ²â†‚#³YW 4ó—™²KºqÏFÞ0|1÷l0è Ä^�]÷6Žá)´Z©*ÚA,Ù–LƯš‹£q¾ +>$VÕÒTêî¦ì§E)ÚœL)¹3lgzá·öxød¾»ÀIuÖî1”�YI¥T~ºA… �¦Dìy¼¤õ¬ïúÙ0"p^çYGBÔç &w”»j +¥ùdj®=ÓI•;K‹dÅâBª8>ÞJ¼9yšBo४†‹á8rr§§«ýÔÃ%ÜÀ¸Ý]tÃPŠf•Æ‹¸`£¼Á3®�Õz —Ù­°]4éâÀÄ�»w¹êÉö½¥ÁY¡——øÅ†‘á�)«ßÃa#ˆ.žFÂ¥Q›ŸŠáÙ+Îk_Q‚$oV<£%«ý°¡k‡h¹¨¥ÓœÁ¤$äF'%åO’ëx5ÆS:Ò 1¨H�Agì g"Ç>}'Ýš<ékG~¼Á`‡¦'Ñó¯Q°ôoM»Ôù²¥8ZÇ[X³ø{R�>Pƒø¹Úaýا0ZDƒ˜íý/˜­bê·Ûå%ÆÿÄlwRÍ}ÌnZ™µhEÓ:š&5j•Ò�3�ÌÁÎŒÀÞ×…½»KxÓ¥êÕC‰ty¹¸ÙEW ך1Û›È)†¤z§Ã žóV¶ì2ÖS<£Dt�v··¢ÏüeEß}‡÷'Œß5‚ñeÆ‹8øðòŒ´MMÊ+j”uÄ�ž¢–Vª³£òÃó8vãÖœNÚ²!zk0‰õ+•jmãc_—„‰êvwÔT÷ÍGœ1“ШÔSa*%)V›qXÊs­Ž|R€®Èo±ÞblÅ”'VW——WW'–ÇÄ$&Æ�xNÞè¹ÞÈjúγä;öíÉpAÁè) Eh=â Éh=ÚO¡q0ØW»¾è#ÝËN~‰£«Ð!ßßÐh+Z4m"â"â ÖAØ÷—¾§~(» V‰U qgüjuaÝñ  s÷æsÅ}ØY§g•ç1QIqq©3¥0.> -2žÂN9s¥;JWSg¬|ů<ª*ŽÂZcÓ#ñðÒØÝY$vzŠßÎØ-�øëâÎÏŸºŒŠ˜r².ä]&ŒÀ> LMÐj):CN«ˆ˜ˆü¶R³ÓQDe–W)Zˆ«çûþÙ™YSCÙ,¥ùy„Å¢É6SØYgŽ1On'°ÓSÐÑ»D{¡6¯¶Ê�Oôì¡Ó«©–dGf<>Bè«áoV«×WT7�Ø)'¬„=¢É›SÂÞÌþìã�}Õo™N +Ðg–[°îëÄ-ö‰ÃÿsèõŸyAg==.¡^†9ðâ»�èuQaU^•£æøµÿ¼F•îÉ/ì4߇ö£„N¢c££˜è¡RÄ®×iê”éáÏ¡T_Ez¶&§t*„ø¦îQ•0Þ7 £ƒéðÈ8F2häVåeï^Tèk•l‘ÇJwHc3¢øYfvB¦Ú #b2¢³Ä¥é•NwîÇ�”--Ãwÿ\þ¡A"üáówú±Þ£'::vØC>vmN“Ú®IŒ\:ÅW!W39v¾`»Ö +`º ÂîQÈå~˜“±o.haõÚýW=ãnpÑ»†|(�+¼:Ÿ¶iì9ÖlGú©ç}«C)Œ”¯a´Ò»áÒÚZºtÐ(Ò˜`Œ«G¾ð–¯Ú¤1šp£No4’W¿®©kÈuýO¢céðÐ0&iÐùêĈliRLTd|Jrzœ4EÇŸxØw#¨í—¿¢6Áy_ü€äxÚv¾^ø]?¬ïDz`¾Áz.Ö‹Þçý¿ôóÀ߮ާi-­¥Ç«´j� +×'ë²ç©u5ŽÖäéŠ +pz]g.â—ç–åUùi1*Íâ�•%ùÎÂì"IU ‰¶†1[Òw&RÑÁ9ë_ÃÿDÖ`YBqm´{(‹îJ¿�KXPˆŽÛ¸(ˆ‹äÿòã´rèQ]}ºøw#óùÝç)™�°ÉÃÆš>ó,iÕj-EoUEdo²ªZ‡¡ôTmQ �|!î³èéYùÙR�F…+rU$G5Žú¼}–žñF¥T/%°¦Ì˜„õâdz<Ï=ýí/ðê‡?ñ * ¹Fܨ2(HU¬6†@˸;¥&S%Ù ÿ¶Öz�<ŽuÃl¸ãíÙU6þßjð,Õ0q×0ÍŒÛ]û > E¦ó°ó÷ôL‹»©´–h®J\L¡y¼9*?õ �©è÷]tÅ��ÙhÌ6]Àá5^¾.Ÿv�û»ÚóZˆæ²äÅZÀ›!Wùÿ›mƒW‘Ü·]wÏv*ïZƉ×6,OYçOj4J•ÖÊoÍ©ó'VûGnÞNaÝ*•RA;ø‚5ƒÍÐ+ ²á ÏDÑûj³T¼á-´Á7=D¥Kß3ü|S»ÔŽý–ûÛÛAGÐ;vD7)û•–ôÒ ð:î›a6+ó›Å\d¡`<|R²×^qÀ4Ü%Òñ;"™„!JÀ­ ÂöxÆHXxž ¯ô‹ú`'Ïd6–Î=„f9"CÕšA +kbú˜–ÖæáŽ0ÄiHëBAžã¾Ùq²,Iîºâ—G+· Ùìf\LMkÏðÙjØl,l僊’›‘ú 3÷[TÁ µ»=Ö9eC0ì…†ø¿m�Ûrìtÿåž®Ý|om÷Æ®·/ËhyŽF¾ïí¦€æ@¾YQà�§X{/²÷‚I´ÕˆÒ!-&mú\‹!—¿£=$âP£�¬k$56…EÆðјI“ÑL´ ëíE¼s‘ 0‰ÚÕ�ŽB`1)׿(49|W(<ˆHTˆ£B4‘;ÃIƒÜ¢°Ó|óÓu˜ +pÁByc¼âÙ\/ìý ²¿ÄÚ=Ôí1¢ÜÕú’ç‰g¦.ž0ñJÀÕHêpÒéØçñ·¶nŸ9yeÛ÷É$–’e”kå*ãlc¼ckÿ¨*éÑÞf/k 56ù¿5³sF-¹²ìÙæ/ñ½>¸Y»|I)i׿1V‹ºK]%ßÏ (H<Ìrƒ� å�(Ê˯rØÔ69…b¹Ò¬¤T¹9ÛJ ¾‘·z®4±š¾fÃm¹è济kÇ(«Ja–³,ŠšL b2¼Ï\Þu²±�:Òs¨jdߌi»)‡Úf°›Uû]ò>¾iÃV7G¼± ÊoµdEðóOáhÞ¯èØéUWÐwKxâV| æ„qÿçÑ!¶=äý‰öœº¡þûü!TøÁ-fº}ó‚èòÍóº‹ø»xØä³ùÀ# ÌÅVµ¼ÙºÅÇÿ×ÿÛw¸˜igÔ&¿èù|<&o„œF8= £'\b{ºýŒÍDsÑc(-† '`-Œ¾^qè%³ªrí8ðy E¶ê�^¤\iæ'Ò tðŽÍ̶�ÊI4+ù}êJu0Ž^æíŒ\¬ô#ÐÔ7aøÂ|àÂXàäÖéÓvSvÚ®·›´{Tîô“|ÛʰÄ&mZ—çdK®DÅ—°ãð3D!ïc[s#YÆ=Ó?»ˆ²ç3F+…5):T½t;ŸÑêi;®‰DlÕÛÄ4.Ö4�6B)­VKSê­rY_msÐ;~®´c÷'D7·Éº‚º+òöJ3‡z¥n¦—q7÷Ò=Cd9s ‡LÕº<§%,?ˆVoSùï0sDŸGš´:5¹.r}ÂkAz™QnUòK:ÊÌ%D‘!1’Bý¼éq#Z±n¦‘y¿«|Äò÷ZDÁTÝQ�¥A¸ïâÜ3s®À¼«ØÑ#ž‘¸$ÕYTS\–«5k-$vJkQZsñŠÝ�§{^\–ä¿j%9w»öü³é«p]¯¾Ž„ùܺ­ŽÊÛo;ÃÔ(MYz¹–¿ --!œ@ ¹]Ç�™Lä�79ûÚö~ŽƒÏk{ß"±£ˆ½pÆJJ0UÖ'z`⧉N^îÃIX-ziã»+C³*J3È¢¬´1‘’’& ºyþqõÞ\|� + ËV¤R¥0“£nªSu5õzc+…�-<¦0r°ëÊ5~ªõDX¸ÞAE¢VNéþfc#q´7±(odaB§‡�° üs¶gÄŠ¦C;·G×¢Ï%µzÎN®B¥T©©÷f#>šñ +zŠŸa0ÇÕø +wK¨.p(¸uŒ›éhi¦ë†‚»É(Övâßçå”8lj³ŒB¯A«µ¢µ¼Þ ŸÁ¨ãßòSå žÎV˽†¹è,<øH¿O¼´íÕ¿½Æ�xîe4mzÒõlß:*¶ª>³…0z.ˆŠ +•2U_ùÂñW4ïen g$oÊN%&Ëá�+@éh§î¯.ì< ¿ØpûvzNŠÚÜñË6®žý\&eÚÉÑëòìúÁÓ鈃ÆO�‹Ø�½«XJå˳B,NIþ2î0Œ¹u|�5£e•�¢õìÇ -»Z÷ã5ŠòÄ +²,9¢ÈŸ@ÏnqG¦MRÞ`t•||ܱ›À‚1|¾š¼2n\b{þÇ[N“þ¨$‚è thXÀýêVèut^ÿãµ^Y¶acú_TÇ^¦‹in졇îAà +øwíÔÅ45uýǵh¶‹«Åž]0q€£“ a4Óä‘«ØòÛ/_dzKM/TMŒ›©©éµ‹ £òb´g†¯ú}Sþ±ûS ô˜ÖEÜ5räj�ZKh5¦\ …-CÛ=&4Io­ñÇÕf­b[|wŠr¥4a�jð°öÞŽ(/w÷SKLªZÓ>VÞì™ÄÑs!øn!Ga0ç˜ ³Ñ’k¤0?Höìæè¹Ô€÷zî D¾ÿašw Â�"¤ä!_5·Q–e´(H›\Z˜LÈÄ’Ô˜ÆÌç>CmÕÙ\uVãÞÉÀ_�N°Ú÷UvåkÍ„†?‰ [‰øö÷TçÚ?ÁÂ6z3²c³ù¿ä·�éf»èöÏ™A×MÍÇ$åXç6J„¿^Âú¡þ%š‹¹{¥ï“g¸g +ƒ–Q­]o3ñ±3ªÖŒï´¹|=ÍhHì†&-‡N$P.7zÃÿ½êfš3.vr»ÎiuT~OÁ'¹½r³TŸ¥áÏ—D¬z‡@|îöÌÂN +â¿æ]2$m5Pf¥Sg6óéÝtU=î�Ó—{§Òf±N©ä¯Óh²Þ &æ{S‹=¼zƒDØp’û±3ð=b{%ß¹ýé�H}ê©àå«í2…2G–Cbg²RÕi.¿tgˆu;�¯>‹|'„þOWºÌ¶" +kÛ•gÔ‹ñDÏ(Qi²1#ÇΠ4^*­ÊR�Ò¤8:�Xýúxñ—=§ÏQX[M¥4¡ŒTÝ»M”P“Ú üª¼£#oFÁùÍõ˜Ï~n)Ón®'Oåï¶–åÎL‰•Ûl)•DiAAië×ܰ5Éë#)ìfyÖÖú™D\¼B*¦ïX€ø&îßN’\Þ¹P]ýÖÝb̺7I +@NÞt™zÛеÕLS_×F· Ëûó÷DÙBÏ +Qv8"ÁƒQ€•‡Ý<–Û`.!Ï9ÛíDCqb‚�’X­’Ýv^o`†di]`¬‡¾ûÓžäëØÍ_<¥¢?…iÃ#NÜYÆD¯{³yвrMKû`Ì¥B~CË©ÐUŠ`;æ?wØÍ{È»T+ª.h8yüxÂ��ÿ¶‚õ)ø_¸Áu¡ endstream endobj -402 0 obj +397 0 obj <> stream xœûÿAª × endstream endobj -403 0 obj -<> +398 0 obj +<> stream -xœm•ÁNã@ †ïyŠÙC$8°M<“ª-•z`AížK2íF¢I”¤‡¾ý*ó¹°Zí¡­þ±Çög�ÜøÛËæê¾jßý•ýž˜W?´Ç¾ôW‹§mÅñ²-�ߌ?¼¯|u¶·¦ëÛrð£Y¬—릣8^7åDZògŸÿ¹<ø}Ý|9L9Ìâ8Œí!Šã·züð·æ‚j2ëÊ7c=žLrÅñOßuÛÜš4ŠãǦZ´‡©¸!ši3{éÛrãG³«›ª×Læ}Ê¥bªºU…ïò°íÂåÍiýaÝìZcñªŽ�zcÌìÕïëaìOæ"vi*¿ÃòÜW¾¯›½¹8û—qsìº?i’pê›*üÎ&øÛƒ73þeüÇ~-\{ß•¿·}pOçæ.I\1J‚*eƒÊ3”Ö 2î=¢rl¥àžE]£V¨Ôu”hÌbÞ£xÞ –(Í÷ˆgŽZasA¥S’Ä]£”�ZRørµ)_Š‚/‡!…/Ó˜ÊG'Rø -µÁçT)ß_¡ÙáË©:U>z�Âç4|…Ö _A'>¡ŸŸÐ�/#ŸÀW�Oà“”Î�:¾LmðYú"ðYêø2½_ÆüDù˜ŸÀ—A$ðe>«žðY<-|–˜>Kw­¾Oh-|N=á³°[øD|–žYøDcÂ'¼H«|š¾œ¾Ø‰OÎU[øD«†Ïª§¾O&fásôÓéû¤_AvŸåžS>µÁ—ñ>|…Æ„Ox/Nù4оO*sð ósðYU̯€Ïéü´Nø„ù9øD³ëüèY¦ï“:3� |’‡å¤[hZSÓ6þÜ‹å±ï}3†e–à´ñêÆnõ®í¦[áþÎÿ,“z^ýñw§ +xœm•Koâ0…÷ùžE¤vÑ!±�¤E©…FbчJ5³¦ñ…‰Tœ(�ÿ~Ÿ­F³trŸŸ¯s‰¼noî]ó!7æg¢Þ¤oÆ®’›ÕÓ®�âxÝTãQüð,âÄ�­ý\µ]Sõ2¨Õf½ñõÅñÆWŸ£“³Ïÿ\äPû/‡©†Z�ýУ8~¯‡O™«+ > ö”| MÉGùR(ðåè3_Æœäà ¦à+hŸ¥"ß +|«ƒ/Gך|8A ¾´|sÐàÓ`×àË�Sƒ¯`NðiLLƒÏ¢ ¾Œ6ð°kðö¾ŒqàË0#M>ÌHƒ/ùhðeÈbÀgàiÀgàiÀg�Ó€Ïà ø +ÐÎ�žà3`7àÓTà383>ÍœàÓ¸u†|¬0ñéKŸàÓì|gfx?1# >‹´|ÿPÝòýC=K>Æq~¸g–ócÎ÷Ó’�q|ÿЋ%fd9?*ÞOYÎ��‘3²|ÿX|ç’�O£ÏŒóQÆû™‡åÄ-4­©i_öb5v�ø!,ã°§�W{¹lõ¶i§¨ð ç–I½”*�§ endstream endobj -404 0 obj -<> +399 0 obj +<> stream -xœÝ¼ xTÕÝ0þ;Û½³eæÎd&“u’É0Y Ù !Ì–€€�%@XBPˆ)äc3ÁhÑÄ-‘RÔ” -EŰ4 QI´U[ë Ú¢‘òÚ€&‡ï9÷NB@´}þïÿ{¾çùfæÌ½çþÎoßÎ €Àk€@ÚìåËb.ÕÉ&8 -€Óæ.™Wö^øn€½ó­œ{cój7y ¹ºtÎÌù&|�Þ ú––Ι©k }*ô*-[öHl˜+ } ¼°¨|öÌ¿¤µ #A|/›ùÈö/�ñ>Ä,žY6ç³�qÀñÄ’ò¥Ëtµ: -0\<ÿÖ’‡ç,éÿæq p8€MpF}5¢§  æ@lÄ«wÿ6ÁI8X�ׄΠÍè0œ�=à‡3°¾Eò&ʆuÐ ÅÔ g v¨OÖ�¿A9 -çá4|äo(‡†3è<¸ÑgЛo­Bša3œ$ÍPIšI1ŠFe°½•ЄÊa5®„&<jà]zÞ…�°¶Ân(‡wUÌÖ¡§àÏð -TA<‹/ÁxÃ)êfm Ô×`5nÄñ\¨‚SPÛ`Zm°”2‡ÏYN‚Ýð -ì€Y°ƒµ±g?XkcW`7DIM’]ö ó*ßö £(Áyd€J˜@¦’‡È'h=õÐäÔ` 3`œem’jdÔHsÑJ:Cý­ôátj„K’]žE¾‡Jì†S°C¥à<ޱ"zæÂØ¡¾×hï’ï’밞 §CIÔ@%ÏÂ.ˆ‡r('Y°Ê¡’mÑ~¡!™m!µ¸RãÊÄaž‹ª _ƒw¡œ �l˜ Qì2¬G¯Hvy,emvxM–%Aïe?ö–ì÷ÝWóÖdwrï;¾Æ(rÌ~»?heLÓÍ›c‹i›¼ŸEî'^Ý~êõ|þc7?Oî=rlqLr €-˜1$¹÷ÈñÅû±W|2ÙíNî]0D½'VÝϼû™·pÆþ˜Ù¥1�+�{ú?®ÌéŸ Jy--e»�€ ÑG�";HÈ~éØ:L!µ¥µ=”ÖöÖö´`«Ûêu[Ý¥üKI„ÿ ^+›¿ÿöa)ÁÜ›èXv¢ ×ç ‡^RG‚^6Pêôµ¤Þæ2Aßà )Ë¥øÛý-þ–tP.v´w´+¼õ²Õ–cÍIóš‘'¬ -¸3BœŽä‰ÅVÅ–™Ñ7ÛêÉrÓ±÷�YÎ/òäCQÓ÷޽¯ñÁS§Ž½1xNâŸÐ¶Ê‘£Q*G‹Q}Vß³£ ùYþ?ÍÛ¢Ýè©=G´€®£•`…1¾`I6°’:s³þ„l�$ÐÙ”Ö–öŒtH½ØÑÞúŽU ãó*  Å1(Æši(SI³úÀ‡+>ëX‹Æ*c­¶iH`*9¬k¦ã^”™â¤ëY±:V83ÀPyó-¦•à€H(ðÅAA†*ý)ä ’ªƒÐëaÕÁÍAõQG*ú -#mÊð(¥£ÝßÞbµåähÜ»¨\V.+—Uö!‡Ûaìrt123Ã&«ØÉ´ØáØKÅÇËæŸ|€ßࣘ+~×DŸÚ´~¯‚§O‘^{«_ÎkII(#òñ¿œÚõâ~᫚ùD:�V‚‘�é‹d`¯6Û«uÍæzt’œˆ²ÚŒÃœ$ ÷•áÒê'Ÿ¬Þòä“[.}wí«K×®‘Ï>þ°í“OÚ>üxÿ€ÿÿœŸGÉ(¹PŠ ¿€¤h‚8_°ˆá é9ȈDA2ŽÒ›•Övÿ;ªvkjž†ì!�×eug¹ñê&té7¯ò?¡ÏPíÏ~¾£õùד€ ìær”µ�zûœ&Y‡à­³èê ›,õ6½ì2B–Mñ·vùhåòµ÷ôì,D ØVEòÄÆ•=p¢´æ!¾;ÿÝŒæ�í÷Ý÷Ì2¤Ñoã_~Õ[ósèÉz‚_˜î ˜Z Ûá„„R2ʈ$6 -Fd³Òš{±ÝŸÛ.ˆÉ¸èWÙ趺b-7Êtx �P™1*㟣è¦&:ßZSCòñàKª®ÐZ ÁÐÛª7 Hª¶6›N–`D�^2µ %䔚{±£Ýê³z¬šCºå¿iÄ¡­­jjJaéo_Ä;GàƒuO¼öÛÎ�tÆ 3f®êæ%Z¬ú ^¾`©Žâ:ØD¯c(]&.è#\O†``ªq—Ó‚Ý•«ç)çtn?ÃÚùðÆÎìîx`“쪟Mó…wûÙzs3ÚNT;Ìj3b@†UíÝNV¸%O–¹;b† .õóÄJdJS“p²—¾z{Î6nÙ´~}UÕúõ›È9<ø_í[ÆOB�YQö$nüðãO[Û>ùXз€gm`„8Ÿ]W‡Oa“A’‰‹¥ë‘ ÒL*�jÈ̽˜áoO δºV·Õ³ù N÷ëG=û:thÀËk~ûÎ�~‡6l�~ü�¹GŠ«N Œ‹Á™-™³äüáÄQ�k÷”<øú®#'¢6¬ìÛ§)>~ܸŒ­�ü†§¶­Ã}ña&WD¼žØª‚CôÕ®�j ©îÕ천L8qO|H¦a’Íæ~�ÒÑÐnåâÅ�H¥Mä‡9ªž÷È‚í"›ˆ×|Ò@ÜCù�Y™dÊÆµŸ¨Ù´zcÓå¿�Ú3~VÃàg6õ~¶¬å«¯ZÕ¦6ᜳ}töìŸ>æösdÄÁ”Þ»öëVMŸŠú#éPÿ‰SžÒô5€îbm C¤Ï,©VŽúôg:á~…bt´ghöí±ºSéRž|†'±¶Æëm,éV‹ Óïгz:a:6K ê™fN3zlÍ´jvÜmÞq'›.yìñC‡Ò_|hï è¡hBÍðÊ»^˜Y"\ X@uìW é¾P3ÓYÈA°¢ºƒ�Q�)HŠÍlWZs[ü¹-ZüèÈmiꕆT/u[±â¹hŸ>½âìçgyJb¿â'j:~6këž3xF ºWÄH:޵�¬�àsHuúMPg‘À¢—I†)]v)i¶®t,°d{š7¦¯U‰s{¬Áªe'"+zn¾}ú&Ì(AÑ~”7òs{n áhä�+X*š¯á�ñgDÉ…  €–ÓJˆ…_ûâCm=•!*B’¦êÒq"L‘ÁjÑ�–Ь£-E‘¡£Ã _� ›�Îh—N�eƒÓíÊ�r…Œ®hê€*tœÚ«ÇC«­´ÚÛl­Oˆ2£#d!™ eÉ[� ™áEav]¥†Â¯ŠÌÊæTÝ�šG›¿±:sdõ}r,êβDúâ°K·Œ3«O*NAY}úff„�wÇ4Œ_U9õµ›·´0þà‚yG'<ºáª®`ç/>~{ÊšóJJÊ}ãGŽð˜Ãw¬ÚsÄãiÎÊš=yM:6Go]ýÜ>w·ßŽWýv_8S�IwPBÕ°Ý,�0à`ôL -²o×p£”Ë6¡âO¬…›å˜Ñøs³G£µ|u“Pð_–ìõ÷Í›]ãO%çjŠšD»0¼.j6ÉF-F‡šô¤Ú¢¯vÔ[š#¶‡�Í6,Ô$Iá=*¡ž1ºgÝÓ£Šwx¬™¤v“Vûlê¼Ð{ûÜ·ÿ~éLI}JSN >ø‘qÅü4ÿÿšŸš4~‹h= 8@‹Ô�è ä º:ú{bz5 ÉÔ¢t‹š‡Ü‘ˆ¸îSdyçüDçÃø˜…ÈF†6v^hÔ|È(ºžÎ#¼èΜ’,Q'¡²ø`aDœ#£œzFƒ¬“õN�NÎ7ÈQœ`80Â…:©À¤t´øE£% �bFùA5sÛ÷ɱdµšqé‘$ÏEóååh¥,ÉH–%ƒÃПö1L¡ ºihš{ôÈ£G™zD§órÔÔÆ›ø¡6ÔÄËßA‰(žÎèü{gz�çáá8”/DÏh´–ò‰t-�6hð9ÍA¢l3b½ÉI¶:m`SœćU 2YœfsP¾f}µ|Òj>lU,Ad›ÎVh.[¥SQ½yNŽíGi6¤è™ýl¢ §Êrë¬:[˜),(Îgég-´Ú&¦Á4$ÉX6£$”%B¹ 4“LI6;6åñ©O—Ý7us�BÃN¢ÒŠcüûþEEÛ¦·Ð"ÿÓdQW¯&Ÿf³6 ê3bÍ\€]„ª�žtP:ZÒD�FV6û/cmÿ*„.à/P:PÂ.Œ¢@L:•†2­tÉïGéülw~7‚]�xø_¾�ªòºŽÈíÊW½r¼l>´ÎŠ^†çi�·ÖZŸàÒœP\DŽ9Ý.çĦ%(~‘ôÜæ„´T°« -8 ícrìüR@2&2F‚_w¸%ÚÓ-Å¥"á—z ¿Ô1õÐôš=eÏ,øà8ÿÞ?¿uáÒwKë+žZôþQôÙÄf¶ëݹëš]ê MÿàÕ¶¿&'T8dså’å1a©Í oýw< ( etH0Ç—Hœ”QìD˜‰‚%��@ÊÇN0‰Œ-„YéhW-âbÆ]udrì�x,ôß,Ó¥ {1ž†¦ ñ#OÉ1T€†ãCgø'�½7A1¤Q ÑQ@0€®dm`‚õ¾Þ:L°,º#=Æ(ß š0:¯™^'(4HM5H�¤ÍöÛ3º[jïBëÈÜÖ»èÅt½…§.T‡Iœ.Qßå�¾º~z³E¶È =(½†«:†È@Ð)­þ‘zúEn‚ÜÂ1;Üè,záÊ^,Ùkþå¯QuüZ ÿdµ~—m’¡N¯óH.dTZ…ꪥl‡h zÝV–åÍ FfÔŸ¿„ƾ�úúßj¤£šF\o øÜg¨‡]�H¸Ï—‘^&±Ð°pâŒðJËW¬ÏÕÙk)ÔaP \ÎX…ôŠRü-þöãǵüE,ØñN—©æÁ¾qfLŽõŠRº/dß‹´ªPKø©Ã.Éf„*ðKþŠ#(4«dèÖ5¼µdÞ›3?AÆÉ%ýÚO¡”{­³ê‰üÁï¤g\úÃŒãË})zªSø·wñ’D¯1ÁK(aªSZµ¦ŒÆK«;K¤°óâ+W$û÷©‘¨à%VcX…š7C’/Õ)P§ßdS :L�eõ³‚KŸiתMM}T–"k Àõº4 Y=¨æ«ê_îØÂG¡W®#ÌoÞøêm–Úyöéõë·î¹ðÉŸÿ«ó-Žæ‰"Ù!¬ÐÏŪuè QZÌÛÉ ÝI›Q‡õØB%3Ø„ud´´Z®jcB‹çL5»¤¹bk¦Ãƒ‹ùItõåßð¯¦Lij²“/jnTŸ<¿c•ô›Kš|·Þ¼@²6ˆ‚DŸÓBl@‘¾.´^A›\—5» M펫…¯VŠ§ê±„ðÄW!2áÇRÐÖ3&KÌʉ“q[Loç Ío\0¿qpA<�<ë7•M �›; lê"rÍ_úÅëyú÷pï)�5¢OÉÚ "a�¯Ÿ^'ƒä%”0/¥$_¢à ÔQ§·×m2Rf ÑKÄ@¬i&†° jM·\¦´(-¿˜ZE¾lÕ:•í­í¶ñ{Ë¡u¥‰.ä ö�$äeUE'u‹_´xÜ™?]9ûõ3¨á’žë|ÿÏO=Q÷$~Ý^¾‡—¢•ÏMëÜÌÚþòÁÓGðäÎË�mX»°Ÿh¼º—á »`/Ý%1E…MçªU•ª†¢=X~?�ççx޶AÍÍ 4Y•Í@_,•£Âëdk•ò„½.HdUAõr£‹¸ÀéB†XP¢]ÂèZڕ˪RhaIá-¶-¿¦;Ül„Ñ�Å�-I“zÿ)üÂw+NM=<óùW�<ß¶¡"ÿzJ±ðË_µó+11ïf¤ïßÕpÀë¢ö F±+Zÿ|áä7z[�ËTZëªïåpEHnˆˆµ¸Üѽ{{k/�Vëå4߇©�ŠRq*I¥©,UJ•Su©úTCª1òPÎ#y4�åIyrž.OŸgÈ3Ž�1h cc|Dâ wÂN´ï$;éN¶SÚ)ïÔíÔï4ì4îƒ}hÞGöÑ}lŸ´OÞ§Û§ßgØg<ÇÐ1|Œ£ÇØ1é˜|LwLÌpÌ8ôÇ� ,E¤²¥åuêÅÂ?¨×44 ©5…VlÊ‘V÷lº¢ £ûö;&§ßÈõ[ªª¶ =‚rÏ]ÇîµÛ·¯}lûvþ÷ò¼!ß=úíÐ�y;šùZ~ˆ¿Æµ;6†…¢P5Ú€Þã×þ*z¤7/Ðlv`˜/‚ë†*ýž :)º*fOd�§Vªw¼˜ ÄæŠS\$6Ú®�NTü--þöV-˜)¢@ ø�Ë9iwÉQµørgÐ&º­;ø×Wç}8oî³ö8ðì¶mU;žÚ0¹¹tå -?Fl3‰Žó™÷¾Žëu:«Oí–Çê÷±mÛ{z5.£­üsü-J&êUòkØ%Š¢@õê;j~™†2ÄŒ®ùOm›�RÏòµhµÓ‡“èfÖ„ú „"Ø$Äd¥õayïd䤩ý¯£·ð§ø/ ·X[çyTÅ+p²€Ñ@¨=ŸS¾þ:§^Ç$&;%‰é�뜲Ž`æ”&˜ŠnA¾ŽaBNÀvƒ$,EÒ#I¢óÑÞžÑUý\¼£ó¡ûF¦Ý}QÈÊ¢�'a�.‡²P]îÃúê†â¹¸/g&=Ñ鈓†²0)\Õ%�x–  h6Ë‘³u#H¡ý2!qØ ¸è~ö,!\päÀD_ª+;*!6ÒAô¿°Äþ"{kÂ/Rž²l%¿�ŒHŠvEI‡ &¯¡�1Ú�d꯴ˆn»r™k‘B5ÍË×.óÀ.ˆj®bÿó–¯ÔâCW/Å#§÷Çoã¦ùE£.U4cÓßÒ””ŒÃ7äÃ=Ô–èwÎ3zѢѣnlÚè«HNN?¼acÊ+Z°pôèE Æl<”–’º,oýá×Pø ´kÆcæ/=zá‚¢�‡Ò’“+m8Ô¤ú[M—i<0Ѓ×¬Û%© -½×@(D!9J2(­þV¿ª×�-PUµ‰ÈYUõòûNÞäç„~ž ’Úôú‚ j�ÖI e— Ùz“ÒÚµM'JÃÀFE`[õ4ÈßD9þ“(‡¿ÉÚo¬nl¤kµØà {Õ\ÇÏú��ègx•½ŒJ^ƨÞK :/1 ¯�À‹�C>¹í'›ôL¯“%5VèYªÁ¨|ªu9r/úÛ»¡@Lû×c¤�LÔn˜,P5@ 2bJLT/Kº h32q«Í*7ñàÒ6ÔÈ�>·¸óê¢sÌÓIÉKדÐz^)詸y�NíÊ¡}Áú: ©sÔZêC!ÃÔWʰe…vW^Ú~Wþ˜™a î1&›7n«ß¸±~ÛÆóßuv^ûÎßù¾„ -Q8ÿ’¿Æ›ø—( òGùôs´ mDk¸8]ˆ°�Gáf) -Ø^Cð*е&šâGÝQÄÍ{¥¨ïA'ØVß¼@‡ªøö‚¾Ø` êB~«U™žPêb¥ºÈÚØzo°DPt¬ÞeŠ ‹ö*þ‹íþön®‰n½8Ô¥ð{Q“ -›UÝ+ËêcËŒ±‰\)6OX»uëÚ ›6~ž÷Äèã§Rÿñ›þÑoùŸù×…OãÚûwþýï^Úß¹ù°7¹QXÉBdèøo¤ç�ór¾‘/�ºø§á„¯6i[e.’}$Q•ˆ,XÛ%v¸?:ƒÏùKX›Úùœ™Q{JŸû†0‰é zjЃр6 ’W™ñjGf¼Ú‘o�#3¯üØ‘ÿ�™ÑŽÊÈÚəɱBõBݦ‹#-ÑQ�$DaÔÏ0OaF§1ßC¼ô– KÒ{�q¦,ÜŸdÑþl€®¿¾�±¯iL@Sp1™D'²¤äqºIúbã4Ó<]©i%YNWê—=Ó û g`NÕ4žß[sê³cgÞ>ÆÚn !±þOióõ$²Â/N€næãh4]¡î7dú"»÷š-õ'ÃND©» ÃÀf»÷Ö©€žg¯zºCtû©ÕƒFm\¿~óæõë7âðäú9§/ýýí’ú”C‡p’ØrhûäãÎÇÇOFÙÈŠBPÿIãkþuM�Ç�ü[R!Ù ¢}il7É@l„Äy” í¸•–%ì°Ûœž8¡jÙ¤býºuëêž~ºN²]ä¾ü‚÷ÿò2:ù×ÏPK; 4•Kâ»àÊ®ŒŒ:¥6£Yiõ«›“]á>Äæ°cÙÓ×–Õ£©*̆õëÖI¶vžûÙç<·ýïè� Ñ]çN«þ±ÎçÖyµøí•˜¨á•@œF·5(Ç»š”·©ŽˆËTèÈ(™…0§.ŽÅéúâ¡ø~/lÚ‹óESÁ‘gÓY ‡b_$g×tN,òœƒp‚d:‚T`{†� -¢×Ò�ߨì~:Á9G_ÒOW@Fè&‘bݲ@WAÕ¦»ó,ä¾@’;Wáuþ#x]ç3tÖ þOk‰WÅx=ÇË€€åUhBpê;ªî,zîF*/;V‹³ãH#Y­îqÈå33´™Â&P,QјlÿTÝèÈmÏP¯ø%«_:÷këlÃIâXœ3ÇgU_¦I6JDh%2"Ô®’¶¯¨j¤•xˆÚ¤gÏ9ÎÉ=Ä·£9�M\íÅo¡+é -�Àí³‰Î?0úú�,á -ñ²âïʦD¿/KäSHG^?ȧïáÓ_Ca…4âf•.C6õˆ!b×F�!"´ü÷¶uÅyIú�Œ0$P±n{F÷ºz,–¥+ý/‘qB Èëü8?ùÚµíñ(çæzŠ]�{ ^öͲ*Øfqš‚LfgP�)¹7NI{�™}²ú²ôl'B�ŸmÒKˆÉ–ô PH"±rz�-Öí­sÕÚêå H@²DÜ&ÍNr‡&DXÜ4X—`sGè‚”ˆ›£Ÿòi{‹¿EyCKðD}¢&y�ã¯]þð=Q¬©5Ë]·„zì°‰f‹(jRQ¦¨XœžxáA”3];Ó·Ž ÊjÝ£õ[³±5ÄÇ´{ÄÈÆ¶¢ñ‡ü‘ùxUFÚ›¿´nè€U3—ôï;õ�·¶ß3µw„G!U�çÒkKc†ÊñÏý³ø‹²¡CPÐ;›¿*þø°Ú—B�¯Å{=`íÙÂ_O­{3Ôiqiº xzÓ=¯m}Ð’{¢µàü‰¤ï»>o<Þ‰X³N¡Ònjò¹ŒG‰Øyãñ›vÖ¬EÒ?ˆžƒR˜‹@%4‹S³p6‹S…Pà$\‚JØ UpÖC%¤ÂIX›¡ Úà$¼§`”úô%¨‚(†‰è,\ƒgÑ8‡a+Ô KPëa.C„ú ÐŒ¶ÂphG»Á�¶ÂiðB¶Áj‘ÀfÔˆ¦Âf$`�@ã0…b¬@1ºâà8Žìh:Ú‹ÇáZü易>¤”4�·¨Bsécô0KcO³ƒì²” Í’þ.O—·Éÿ¥Stt~}ˆ¾·¾QÅiø™áW†·�±Æ!ÆŸ›À4×´Éôaж ?šCÍ»,Ø2ÃÒªLPVž¶Ú¬}­‡­mŠí[“íýà{‚‡`�´·/³jÿÖaw;;žtt|ìø6$4ä •Ãã± ’`!H€A�z!6 Y�UÿÚåq €¨(_Åß}hc1ÐcÐÁ_cÒã:í1f -_ÆDŒu‹Âc#ôG¹�qPpZ›¡Ô¾C9,�•ð0̇yP -Ë `6$B d@¤A&ÄÀ,X 1�óa,…eð0Ì�™P½! -a1̆ˆ�A°A Œë†µTý6–Âx–Ã(�0À˜ `&L„ -ˆ�ÙP -3a1ÌSgÆÀL~ ̇ÅK fÁ"˜³!J Ê`¦zïN8ãU(Âh(‡ÅPùPå°&ªë/…ùêuAY -dBömÏw=Ýõìí°çªW5Š–¨.ƒ%ÐREÏ%09T@ -,…r¨€‡a6ÌQŸ}X¥.ÃXC{@뢶‹ë?䲸'8(fÍ‚9°Êa$ª<ÿÿ‡“B&†»®¬qn&Ä܆óµÆÉÿƒ_±úÿ MŒù74ÏpQÈ\\2<{B ”ÃÜ‹‹ l¬ -¯L…vK5Ø¥ê½9ºæ©«. üœ¹êÝ9Ý«iÖ´IÜ_å*†‹Õç—ô\[¡fÁ²€„Åk^€–ÙNwÁ\¦bq»ŽÏ„Ùê¼2X€ÞAÌÖp×4iŽj5šÇöÐ’XUrâÙõSÐ^³a>Ì Ð§éàl¨€2ŠÀuY7æÂ|XÐã„no­ ì]à¿ Vô\¬x‹'âÊxÊ¡*Tüø -ºàÃlX*�'+T(Um~Y€3BÞ·SÔÿ–†/íÆ¶BåaïÒcÁ—[²¾e¿K¡T½r7:zwÓ™ªú�²fìù®Þ.ýŸ¦º‹s¶šžiÞ®u·(Z¡ò£ì?Z¡Ëæª>sq€BMG4hBS%å*6KUN,€90[…§Íé©Ç‹^²KB‚rAÁüny,…þªuN<5fA¹ênÉ §/ºÅ�z/\¡eKo›Ûe+Kîêz>'¨¶­IJøùÛuMã†æÉgþ„<dÍ_Ù—©Ÿ·üÇ"‹e°RÅw®êì”Û8õSÏ -ž¬ìÆ_¬.x.l¹Ë£ Ü…ž>Ü}EÃTð´‹J!ÏžZ׿Ä*¿*`‘úíEâYÁÙy-Ôè�‹TjJ×îáCu&K»×¸“?Kÿ-M=}\Ém&(½;?�ÉíëÝÉ—»á¨qq±º’ äǽº&%ñ.ð+» nו¥ÝšÙe7wF‘9'0¾µÒ -•ªõùØ»ÄÅØnºï|BÌ±=´M³�QwÄÁ-6uá*´aQI,‡r˜ŽÍ�GT>kÚ;–À’@Ö/¢M×=å¯áüÓ#ä(î‰Ï¥Å:?¥/uwóáân…:ëvÇþd¾{› ÿ¿Ú¬ð±‹ºcö-«ë²(‘Ah¶'â’_î„(ž™ a¦:G@Öâ¢Ðªæÿ'<Ö�S¥eZE\œÛÍ©áP ®3Š`‚ºÎ -` ‚qê½B10ÆÁ˜…0 -`ˆ*—Aêq?VµÆIP¨B÷«°4ã`� -{2Ĩ°E¦Z¤~ …PCÔg  X]£Æ«PÇÀ8öh £ P]SË1‹`0Œ‚ûaˆ:¦f£ÚzE0FýóG«¸h˜N€1=V½+y|7f£¡ÆÁ`¸;ò¡P…'ðëUÇEÝx `:Hå‘€,`†ûa”úM\½ÆÁXãU~ -ÈCØ©4 …qZ -T 4Ih †10&«3†Áp˜ b!Vš˜)¾OPé’­®:R½ªa6& e1¾EÔbM Áÿ‰Ý+�Wé£TÞ -zÇ«+À Ý ·Kw†©Þ7îWéøª -âžà¢àç¨î™ãzHEÈt�*7�¹x^P"82þ®”tA»]:wÓŽ®,!7Á©Qêìñ0 -`° -I»¢éc¡Jëào5˜šÞk:¡ÍÕpò)R%{ܘ¡Á»“ -ÍBþ·¨Ð$0(ð>¸ÏnI_@8wá#´YhÙ¹"ìO`"f -ߺ¸ tLHIÃ\³m�.9ÞÐÏ.Ë+ºƒ¿]vÔ5ï?ñ¬®µo— à§à“†¡æIŠþ#¸šï*€GT¿·$×–þ r÷Ìoe¥=óÏÞ=|mÏL@óÂÃÔ¹ewÌ»uUóÏZ̺UóôÌáªäÞwd¿]ه滵ڨgö[¢æéZ.¸´;+ÑâGywf"²-cèªZD5(âËíõÞRu]�2m­ÂÒòK1O[mé]¸ùSêÎ -Qà"x$ ¯PÇ¢—¤e 3Õ9b®¸þèU±FÃ.ƒ.ZþÿÅÕ¥j¹è|•Ã"ŸL À}¸»>»ÅÁ­»Uv‡ÔoiŸ€Öÿy¨àÁ¼˜‹úNË1D^!Ö4üúk©*¿Â|HUqÏ>)j¾RïÈ(ž…úsóç0%Ði¿ýg<Ü÷Ãpé0%`Å’a܉0 ’ FÂÙP “ ƪB$À0l`…¾0Ì�÷‚àƒL ý ¢ ‚Á 3Á! A,È`Q=á1Ð� zC/È€!R¡?L#˜ ˆ�i�¯ö“Ý`€hÐÂk�ãÀÓÓØ Hä€Z ÈkÔÿ³…AÁê» l@�U+ê»¶Afutàëal�Á* È^ È@�A…§WgéÀ ÉêXRç0uLÕëD½‚Õ+È7™ÎIç*âçä'×3È¿Ž�ïW‘ï®U³ï8ùî8½vu2»VM®­¡W;âØÕÉäª�vÄ‘~›Êþy�|›Jþ›“+œü#ƒ\¶“ojIû×ÃX;'íM7ÏùnÒ¯‡‘¯.•°¯jÉ¥òwNþöeû'_F�/8¹¸�\à俎�ÏÿÆ>¿NþF>«%áäÏœ|ú‰ƒ}ÊÉ'òq-ùÓìOœüq‹‘ýÑA>ZE>ìOÚ¶Y[ÒÊÉù ì<'È9NÞçäìãVv6’¼BÞåä�Zr¦ÊËÎpò6'§W‘·8y““789µ-ˆµpr’“œ¼ÎÉñ-FvÜNŽ™HóްfNþptûÃò‡5ôè/;:�õÑ#^r˜“Cµ¤©f{�“ƒ5ƒØÁëäÕmAìN^.!JÈïÍd¿�ìãä%îë$¿ãd/'¿µ‘FN^|ÁÌ^Ì /˜Éó{¬ìù²ÇJ~³;™ýfÙ�L~ÍÉ.Nžã¤agk(!;¥°�aäW -ù¥�ìàdû¶ ¶�“mA¤þÙVÏɳ)¤®f««%µÏaµœ<óô4öÌòÌúô“^öô4ò´�nåäœ<õ¤—=u„<é%5U^V3ˆ<±ÅÈž°“-FR]åeÕ%¤êq+«ò’Ç­d3'›8ÙÈɆõV¶�“õVò¿8YÇÉcÖ|öØx²–“5��Õ?_ÅVsòóUd•‹üŒ“J3y”“œ,ç¤b™‰UXHEßÇt™‰,;N—ÚÈR}˜“‡8YÂIùâñ¬¼–,.K`‹Ç“²²ˆ“…d'ó3Héu2ï™ËÉNJ8™=ËÅfs2 6ËEfr2ƒ“9™>ÅȦ›É´2õ-òÀ#{ÀN¦ÉdNŠíd'9¹?"ŒÝŸA&p2ž“qœÜ·ŠŒådŒ�q2%³ÑœŒ:BF&�…¡lD6)lc…¡dxA(ÎɰÁ66¬„ -eC��‚P2d°� É&ƒó­l°� nÂ>Ÿžæ²°|+ÉoÂàÓÓA>3d!ƒšÐqŸžúòLÌg&¾&´Æ§§y&=Ë3‘¼&äó•Ð{9ˆ’ÙÀë$—“ ¤?'9Ö|–SBú¥‡³~#I6'}“í¬/'Y#IŸ´pÖg$ÉL g™œdXóY'éÉv–NÒÂIj²�¥†’}K9B’{³d;InÂbÙÞŠ•õ&½ºµ4é/Kâä}»ÇKq–ÈI'ñœÄYˆ7$Ÿy H/ ñpk±°XNÜ1É̽ŠÄ$“è‘ÄeÍg.N¢8‰Œc‘œD€Â"ÂH8'aœ„râ ÉgΡ$Ä‘ÌBò‰Ã®0G2±+$l'6k>³qbEÉÌšO‹…)V¢h¼³˜MÌb!�wæ 3›ˆYã]�IÏ‚ $¨ ù^¡&=1 ÝʦFN úfàDBt -‘9‘P2“8avBpF®Œ’îO( %PjB%ë· ¤ÿw~àÿ6ÿß(øß� “ñ +xœÝ¼ xTÕÝ0þ;Û½³eæÎd&“u’É0Y Ù !!˜! ,! K€°„ S +”�5ÁhÑÄ-‘RÔÔ +E‹ai@*¢"’h«Vë µE#åµ-Lßsî�„€Kûüßÿ÷|Ïó%ÌÌ™{Ïý�ß¾�€Ö�´9¯ˆ¹\/›àN›·t~ùxѧ¸^˜¿xÕ¼›[Ö¸ÈÓÉ5esg•Ê·àS€ô>п¬lî,]3¦éÓ OYùŠG¢ÅÔ¤¯€çWÌ™õ)ùb@F‚ø^>ë‘¥ì_4 ã]ˆY2«|î§ $ ã*€ã±¥ËWÈ_êöŒÏ¿±tÙÜ¥¹¯Ÿ�ŠFÈÐ gÕWzša4Ã&¼pÏo3œ‚³€ÕyÍè,Ú‚ŽÀYØ~8 ëákd ¯£lX-PBÝpja—úd-ùT’cpÎÀGPIþ†rÈ8‹.€} +Ͱåö*¤¶À)ÒU¤…” hT{Ñ‹PͨÖà*hÆã¡Þ¦çàmØ›`;ì… +x[Ål=zþ /C5tÂÓø2L…—ᜦnà`ÖÖ@ípÖà&<σj8 µ°v õÐË) pøŒµã$Ø /Ã.˜ »X;{Zðƒµ³vvö@”Ô,Ùeº òm:†Òq1\@¨‚‰dyˆ|„6P]I.C-2Â9Ö.Ù¡Vö@­4­¢3Õß*A^Ig¢&¸,ÙåÙä[¨Ân8 »TŠ^ÆãY1+¦çaì‚]ê{­ö.)ð6¹ëá ÌÑ:ŒäC-TÑÑð4ì€x¨€ +’ ¡ªØ6íš  ’Ù6R‡«4n L<váy¨jñux*ÈPȆyÅ®Àô²d�WÃrÖ`‡Wd‰Q‚ô�Q`oQéß}%1oLq'÷½ëkŒ"Ç€q‚VÅ4ߺ5®„F°)XäâÕ ^Ïg?tó³ä¾£Æ•Ä4#gáÐØÂ™C“ûŽšPr{Å·¡SÜîä¾…CÕ{bÕÌ{€y‹fˆ™S³UÙêÉݪÌÍM e¼Ž–±½@@†èc@‘$d?„tl=¦�ÚÚÖ‘J[G[GZ°Õmõº­î2 +þå$ÂÿW^'›¿ýz™”€à4-fí`„D_ˆTOq=lÖÕÓßÓ§ËÄ™&Åß‘áomM‡ÔŽŽÎåJZ°Ûá¶^§ÉÃ]ñc]ËðqÿJÖÞć5u]lÒ`� èL0Âó¾Ì)Éu*‹FFĉ12:�Á©7 ña4È:YïÔéäƒLÕÁI†#\¤“ +MJg«¿ÕêÌI‡Ô¼KΜ´QJd…}%+ºÀKŒïü>%ö l@0ÝçÒ#Iž‡È£U²$#Y– C.íg˜J'tÓÑt=öè‘G�2õˆÎਹ�7óÃí¨™W¼…Q<�Ùõ÷®fô*ÏÇ#p(_„ž´b¨ºu‘–Ð*p@$úâ „ Cµ~›rI5AèÕ°šà– †(‚#}ˆE‘6eD”ÒÙáïhµÚrrÒA¹ÔÙqI¹¢\Q:¯Ør¬9iÈávØC23úg;ÌÈV23lr +òÄJ2-ñ_<þbɉò§à7ù‡(æêûß4Ó'6oxAÁ3¦J¯¼1 畤$”ƒ‚‘ ùø'§÷<` 8uë"õÒ*ƒT_¸©:è„Õa'BjˆR£o! áÁ6HÕÎÖ ¡C—:;ÞyE¹v%ÍÛ�…;#ÄéPÑàG½#1žûùGÈ‹è};Š‹¶Oÿí‘£/Ì|zpNR€ìÈŽÜÓ÷ÕÁ¹y÷ÜgïºñÖÇ ÔgJG‘‹¤C?Iñwt¤Cꥎ´àL¡`œÅçý¥¬ýF{“àó–[éZFp‚Ç,ÕØ ÆÔbkÕÛ,C‰Íqo¨ÊÔêWÒP7–Yýââ3lV{b±U±á²šÇ¯ÙöøãÛ.sý‹Ëׯ“O?|¿ý£�Úßÿp�ÿÿŒ_@É(¹PŠÀ·€”ì`„Ó¾\�S¯c“�’ÄôN‚uNYG0sJ L�„àÄœ„�IÇ(‘ôH’†‚ÐÞŽŽŒ€öv\ºK{u_É´Gw§ÄÔÉM÷�—°N‚CY¨. ÷cýuÃð<\‰f&=Ñ鈓†²0)\Õ%�x– $i6Ë‘³u#I‘þÚ�¹‰B;ªF�Aõ¨-A YýÏ�)âçø;ü o�v£'ö _ƒÐõ´ +¬0Ö,ÉFVRonÑŸ” ’:›ÒÖÚ‘!ôª³£í-«@ÇçU@AŠ5bPŒ5 ÒP¦’fõ� Q|Öq0�SÆYmÓ‘¦êV�5Óq/ÊÌqÒõ-záÐáÃ)Ç×}¸?Y•rÏßêº@g~´rM¬HxC ŸD'Ò*P 2}‘ ìá5f{�®ÅÜ€N‘“QV›q¸“‚„‡ /�‘¡©ì%Ui­99iÞžõ4��Cýâz,­<|8¥¡ôìßþþæ¼tuÓ†�[·nܰi[×ÉP;a2�ÁÿÁÏLF×Þÿð£ö¶�?Ôüq5ÆÚAå¾Ha„%Y*�1�—uLB2¶ÒtÙ +i!«ðJ©y9-¥gÄkJìA'zçÄ¡r"Ž“È“q)^(WâGeC¨‡¥a¨HšŒæ£2I'tÍ�¬™V7²zª oOÝ®;ÅÚofÒ·o$Ñ·of‚È5�ž§3Á„¬¾B#&Ø 7‚ FeTÏ•œ²NfNÊt:; 6� 9ÁT``˜èˆ'�:“Ñ ×i‘Ü(Cê[š™uæ‰p¡’ð�(qFVt�”YÔ(QcÔSc4D£(N"i‹ÔGÂ�Ѧ8ˆC‰8Ž%J‰²G××”ƒû³)GÎÔå™ +uEúaÆ‘¦IºýdãÓ<¼€Ì£ ØBý\ãÃøQöˆî'úeÆd‹! G“hÆ¢ ц$œÄîÅ÷²<ÃÃÃB¼€•ªð²Š®¡�²ŸÖB§£éÖÌ$þ!�y�jüÅžS‡ø�/<@gúWâ‚®²åf#ž×µC“s#5HÑq¾`=Ã!Óirˆ‰‚d­7+mþ·TéjbNCö��Èá‰�˲º³ÜxÍS>¸üëßó?¡OQÝO~º«í$ù×〠üÖErŒµƒúúœ&Y‡à ­·èê ›- 6½ì2B–Mñ·uÛ¾råú;zv– ,`[ÉWþÀɲڇøz<üÂ73[uÜwßSgÉÐ&¿�þE_Í~С’ô)¾0Ý!0µvÂI ¢d´Il4Œ2Èf¥-ïR‡?O„ŒŽŒK~Õ嫉I–ÛêF™ô*÷/Aåü3ÝÜLgúSkkIrYðê� U }}¡z3‚¤k‹é¤a Fé%ã0»°Pa ©y—:;¬NÁ1«Çªäm¿@#/|h]ussúsËó<>Ô5ªì•ßtm¢3Ÿ›9ç3U6—h‰jƒ}|Á�|‹þNÇ�šlõ¦—!˜zWªå¹L*º¦á¹];ÏŠ,kDSWvOÞa“쪟Ió…÷ø™s ÚIT3Üj3r� á;zœŒ0KO–¹Ç‡ îP鉕ÈÔæfád.ñæÜܲyÆêê 6“óxÈ¿:¶M˜Œ"²¢ìÉÜøþ‡·µô¡ o ¡æ“q>»®ÿŽÂfƒ$K×#¤iÙ¤êŠó.eøµ(/аº­ž-gqâÙ³]œeí]»pé�$üzWNÀwݺHÓÙUƒ_xØKpðŽøœa‚t)-\@U¯üHÔ¡écö<À?ã§P>Šz`Ϙ‘M“N·¶ž.y¾(+1Õ¡¥"Ü$&žäãïò·ù;ü]ß èÑÉþ�Ùùý:Óñ½:cý7:#Ù»öªJƒaí‹Ô£æ<‰°Äw�A†ðS¨E†C¡r�Í]s<ª¦�È�‚P( 3$ÓÐ*9î½GéìhB×\yë¥N¿`Š�½5Ç–cµå¤ù¢Ò¢ÓbÒÜi±�Јq£¡Ñ¸'¤ÑÙÚÖnžÞ+ËËÊèJ\V¿þQ––ˆfi!Ñ…pË g~õèâ§_D‡|iíoÞºùÏoÐÆí3N<0ïhIõéAq18ó¡¥s—^8’8ºkݾÒ_ÝsôdÔÆUýû5ÇÇ�Ÿ±=�GóÔ u„/>Ì䊈×[upˆ¾ÆRc!5}Z\–S 'ï‰É4\²ÙÜ#îQ:[Ú­\ºÔª©´‹¼#GÕó^±3Ø.¢i¼æ“á^ÊïÌÊ$S7­ÛôXíæ5›š¯ümô¾ ³‡<µ¹ïÓå­_|Ѻ¸.µçœûàƒsçþô!ÿ³Ÿû##¥ôÝs@·zÆ4”‹d¤C¹“¦>¡ék*ÝÃÚA†HŸYÒÜ\â‚\¦îW(FgG†fß«;•.çÉgykoºÑÎ’4"W� 3îÒ³:i:6K ê™fN—2zlÍ´jvÜcÞq§š-ýÙÖÇӟè…çÐsBÑ„šáU7÷<7«T¸&@°€êØ/!Ò}¡f¦³�C`E'u‡ :£S�›Ù®´åµúóZ3´øÑ™×Ú!Ô+ ©^êŽ8bÅóÐ>cFå¹ÏÎ5ñv”Ä~ÉOÖv5þdöö}gñÌZt¯ÈçèxÖ:°B‚Ï!Õë7C½E‹^&¦tÙ¥¤ÙºÓ‘À’iÞ˜þV%Îí±«–�ˆ¬èe¸õæ™[0³MBCù1ÞÄÏﻉF Q7o®d©üI¾–ÿŒ?%Ê}å´‚VA,üÊj³è© Q’ì0ÕÄ�–ˆ“aŠ V‹nŒTlc)Ž ^èQ:G0MuÀ:ñ�’Ã~ëÄ€)þ</›šeä]êÌœ°æäˆlÃ7<�¦±4)MNÓ¥éÓ iÆü�|g~h~X~x~D~d~T¾k-YKײµÒZy­n­~­a­±6¤ÖYZV^QYUëò éHµ°0ÔËyÜyðÞØ#7U<—5lÜÀçrFå<û¬{Nþè¹äʈÂóüÓ®•xÝWË«þÚµ¯»ºT|Ò™3óò‡ ^´ßºH%ZñPéó™°ÙèŒvéôX68]Ñ®‚(W¨Á芦¨F'¨½Úq"´ÆJk¼-Ö†„(ƒ1:B†±’¹H–ì±… š^f×]Ò*üš¨mNÕݨy¤ù+«3GVß§Ä¢žJR”Z»tÛ8³ú¥â”Õ¯fFy{lã„ÕUÓ^¹e[Ç{-œl⣯é +wÿüÃ7§î£9/§¤Ü7aÔH�9|×ê}G=ž–¬¬9SÖ¦csôö5Ïìw÷øíxÕo÷ó…3™t‡$T;ÍÒI–AϤ ‹ñN 1J¹’a*îðÄJQ(`±Yn��??g ZÇ×4 þ%ÉÞpßü9µþTr¾¶¸Y´úë¢7 ÖŽjŒ5éI�E_ãh°´Dì ›mx¨I’Â{U½ct_W=ïðX3IÝf-÷ßÜu±ïÎyoþýòÙÒ†”æfœHüñ#ãKøþþ%?=yÂ6ÑöBPÆ'Ñut&Ø ÑWä4‰tÛˆõ&Q¹Z�6°)N‹âꙃ,N³9¨@ ³¾F>e5Ÿ ¶*– ƒ ²Mg+2‹@£VµŠê…rrl?Ø—²×ÊÛ6QF„Såaë¬:[˜),(Îg`-²Ù¦¦Ãt$ÉX6£$”%B�¨X3ÉÔ”ásbS¶N{²ü¾iÃùØSh4~ +•Uçßæï˜ÑJ‹ýO’ÅšO›w«€f³v ê3bµÍØE¨ÚK¥³5M$ÖdU‹ÿÊqÖþ¯r@è2þ+JÊ!؃QˆéB*i(ÓêA—ý~”ÎÏõä%#ÙUˆ‡ÿå¤Ú�×0 ot´«@µäxÉþlh½½ÏÒzo�µ!Á¥O\DŽ9Ý.çĦ%(~¬ï0-…é®^†£}ˆöüR@2&2F‚_w™ímNq©HØSaO�ÓϨÝWþÔÂ÷Nðoý Ú-»¬¡©ò‰ÅïCAŸNja{Þ˜·á¡9ežÐô÷~ßþ—ääІn©ZúpLXjKãÿJh9� Ìõ%'e;fâƒ` $ä� +0�“Lb#F‹ PV:;ÔÂìRÆ÷êȔ؃ñXTafA˜Žè(eØ‹ñt4=XˆyJ�£B4ì8_ö�éŸH^¸ÙJà!ºŠn#ÄûìðŒ5²gdbÂá"uáɤ´åiuB`ˆXª%[ñ1ô>ä9>£ÛùÐ&1hBÇÁ$ºŠµƒ 6øúê0Á²¨JFzŒQ�AÏ:/™^'(4HM5H�¤­@§'£§UkN­’¾£æìÃt½…§.T‡Iœ.Qßå�þºz³E¶È =$½‚Áïu ‘A SÚü­"eò‹˜ŠÜ¡8ÜèzîêU^"Ùkÿå¯Uuüz o`9=5 Û,C½^ç‘\<Ȩ´ ÕUK°NÑtöº­,Ë«¶ï�åòѸ7QÿM´rtóHµ“'à> @=ì*DÂ}¾Dˆô2‰…†…g„W’X�b}6¨Þ^G¡ƒbÀÈàrÆ*¤O”âoõwœ8¡Å]±`ç[Ýz¤šûÊ™1%Ö+JÀþ�}/Òª-Q¥»$›ªÄ/ú+�¢Ð¬ÒaÛ×>ðÆÒù¯Ïú§”hojj:�Rî}´~ìêÇ +†¼•žqù3O¬ü¹è1Må_ÜÍKr½Â/a�„©NiÓ¦/­î,‘zÌK®^•ìß~R+QÁK¬öÛ+Õ|'’|¡¨^�zýf›bÐa +,#h€\úL»V%iꣲY…™×-¨ IÈêAµ_Ôüb×6>½|a~ëæo²Ô®sOnذ}ßÅ�þü_]ÏiñçŸDÉA`…¾(ÈP£C‡ˆÒjÞINêNÙŒ:¬Ç*™Á&¬#£µ5Ð’V j-1ÕPì’æŠ­™.á§Ðµ—~Í¿˜:µ¹ÙNþZ{³æÔ…]«¥__Öä»ýÖE:ˆµC$úœbŠôõ¡ +Ú첸¬éØij·P-Ø´ì5�¼:U�%„'¾ +‘ ?–‚¶Ÿ5YbVMšüˆÛbz3gXAÓÂMC +sñ ò´ßT>=l`^ÞÀ°i‹ÉuÙ__͘›;ðÞÓjE‰µC0DÂBß½N&ÉK(a^JI�DÁA¨£^o¯Úl¤Ì¢—ˆ�X!ÒL aÔšn7¸LiQZy.0µŠ<Ϫu˜:Ú:l9â÷¶CëNo\Èì!)HÈ˪ŠNê%þ¶xÉø³:8¦jΫgQãu$=Óõx¬þqüª½b/C«ž™Þµ…µòÞ“Gñ”®+?Û¸n `->Ñxuÿ'„÷À t�ÄP6�§Vªв:°ü~ÏÏó5l‚Ú[i²*›A¾X*G…×ËÖjå1{}�¨U‚ä&q�Ó… ± D»„ѵv(WT¥ÐÂ’Â[m9Z#L v¸#Ø£;‡;»Z“&÷ý;RøÅoVž.žvdÖ³¿?úì};†‰.ÆŠ…_ù¢ƒ_�‰y;#ýÀžÆƒ^/µÞÍ®j=~dð…“_ëmõ.S}h�«¡�Ã!¹!"ÖârG÷»m¼ZmWÒ|ï§B*JÅ©$•¦²T)UNÕ¥êS ©Æ|ÈGù8ŸäÓ|–/åËùº|}¾!ß8Æ¢±x¬a¬ñAx=ˆ4È””Ô=¨ ÿ >ÓÑt¤æÂZ’([E:Ø{c]ÓÀ¸±9FmØV]½í±êêÇþqíÚ?þÑÙ‰¯d�—= x4ÞÅßågø›ü]”†ú£l”ÖÈáëøÏø#h3ú)Zƒ6«63OÔI¬0A�/‘ $¨ˆQ®gˆlÖ#“\:*YL}ÌŠß/tO5‰KbÔmÝ‘N�Ü$S85èâOy"úÀýÅ믟éÚÄ¢ü_’·ý™{ù.Tz\èg ê «ˆ " ÎgCFj3m ³A£1Ìñ‘ŠÚdló絉uDi�Ä.Yl¼ð½ú!N‘7ÓU£jÇN}(Ä8f~æØmEÅ?Ÿ�U:ÒäX1}Øbzq`v¦�ºC濘×?$š²†þ*ÝÁ–ƒúÁR_zBRŸp'1›ôýÈ~§~¿Éßg’Óµ?=)+>HJ0�”d‡ð “Ý�dJNÉR>îð·*<¯UQw?D°RZÛÄ¥ÖöÖ+Ê•qMû—æ +”�Ákík’�s¯~Åí¦‹Ú£·´vVÿlçíÞ–ÍAÍk-Z·nÑ¢µ5�{×�æÂ…gÆmìsà‰ëüÏh$²õ_œ“–_•Ëwòéè”wþv¯Û¹sÝÏvîä¯Èúõ±c_”¿«…¯ã‡ù+üQ»cSX(zÕ �è~ý/¢·wë"ÍfW!†û!¸Þa¨Öï ª—¢«cöEÖ{ê¤Çó‰!Á@ìa®8ÅEb£íúèDÅßÚêïhÓ‚™" +›€ÿ¸’“ö=9ª_îÚD·}ÿòÚü÷çÏ{mö¾ƒŸÞ±£z×§´”­úCчˆm!Ññ¯?õΗq}Îdõ«Ûö³†}�–/¯JH8óÑï«Äõ´зY D@4Œô¥E:åa ¹úš`‹Ñ튊Œu†Û¬ŠÅd2èÅîF.Ùc”¶ÀŽB[^ž?O¼·ftdd¤!’œI2nõå öO°;Ë­¾�‡dâÊ®-h\ÐÉÿ6ñÿ´¬qÁõ»Ë8G‰ùu”Z†t×&^g-|ÚÍgíàølôKñj@Å;Ðî®×ùAÀÐ @v\ U¾±Ó!3“ä #cæ +ˆ +g˜JaˆVª-ÛLõÁuÑÝRLXˆž!�ÑAúÄ Š!Ñ‘³µ ×Ù£‡jBuåºØî}Ûš“Ó�°R-­R?¦Ä"OV¿þùèδJ¸$ 2£(DD^ðBË ‰SïM]_^|pöŒãeGþº¾ ŒRD0Kˆ1�]N ‘Ó”6g^‡3ßסø/]I‡Ô×2ZUµ{íº¶!i 4%�U¥&ÞjF{ˆ­…::­jó!;+ÓéB¢soU2~yÉO–~RVYÞVŠæ�™]zvÎo^8^ŠÆî™xÿ3ãÞùãåcx(/&+J§Ï?�~A—ΘTzóJf)‰/ß[€Ñ›Ñ‡ê~qÔüå—ÌþÛ¤TÊï‹>¹cÇ;z5.£íü3ü5JU÷Å�äW°G"E�$êÕ·Ôü2 e:ˆ']÷ŸÞ1¥žãëÐ-¦� ÏÑ-¬$õE°Y&ˆÉJÛ[Âò:ßÊÈISÏ6x~½q�?Á~½ÁÚ». j^‰“Åú{aYE= A¸ÏĈ^�z˜€, L‡€â@Yz„ö¢vž„’ùêá3ÆóÇ‘ ‰CbÀÀ @°§Ááà‚{ &ùR]ÙQ ±‘–¢ÿ¹%öçÙÛ~žò„e;ùyhdDR´+J28Œ`0y ýŒÑ†$S®Ò*:¥Ê®yKU=¯\¿ÂlUeÅÞÕm¡ùÈî>ŠGNïßÆÍ ŠÇ,Z<ºxÁ¦æ�¾å))G6m>ÄGx¨-Ñï\0vÌâÅcÆ,ÚÔ¼ÉW™œœ~dã¦f”_¼pј1‹ŽÝt8-%uEþ†#¯ ð™hÏÌ¿Ž]°h̘E ‹7NKN®¼ñp³ês4yÒx` ¯/X·GR…ú‚�PˆBr”dPÚüm~U¶�í+U¼Dämªˆƒüþ€”Éëü¼�ó*©{,^_°A=±Cë%†²‰K†l½IiëÞbåQ ÉØ;Cñ×QŽÿÊ᯳ö¦›kššè:Í?zè j¼7ÀÓ¾ÁàE jz/£²—QÉËÕ{‰Aç%ä5x1b("×£d³žéu²¤úK=K5•�µJ?ï’¿£;4‚´½FjGH&jGȨ…Z 1%&ª—%ÝF´‹ÍdDÜjÃÆM<¸¬5ñß]CgÎ/麶ø<ótQòâ�$´�W z*o]¤ÓºóH_°¾ÞBêu–†PÈ0õ—2lY¡=Õ‡vV¤;‡Ḛ̂÷“-›v4lÚÔ°cÓ…oºº®ãïú_FE(œÎ_áÍüs†Šø£|-ú)ÚŒ6¡µ\œJDØÆ£p‹l¯ ø=еF’âKÝ Â-/HQß‚N°0¬¹u‘Sñí}±ÁÔ‡üF ª6=¦ÔÇJõ‘u± Þ`‰ èX½ËíUü—:Ôã2�íVÑi'‡ºÞa!j`µYÕ}ެ~¶Ì›ÈbãðÄuÛ·¯Û¸yÓgù��9q:µiÉ¿úç'ˆ~ÍÿÌ¿,z×Ù»÷Èï~ûâ�®-G¼ñÈ�ÂJ!Cç#=ßÊ+ø&¾<º÷íÕþÈg¾¡LbzƒžôÄ`4`„�FƒäÛö^mÛÞ«mÛ{{mÛ¿üCÛöþÞ¶×¶ëem÷~JìÁP½P›b[=Ú 2í$ƒHò¦â©Ìè4Æá{ˆ—ÞÃtIz¯1Δ…sIÍeu¹ú~Æþ¦‰0MÅ%d2�Ä��Çë&ëKŒÓMóue¦UäaºJÿ°Ñ3zöá‰Ø‡?]Ûtá…ÚÓŸ?ûæqÖ~s(‰õL[n$‘•~qt O£éJµç›é‹ìéù¶X"N…�ŒR;¾ÃÁf»÷öÎlïó½Ýºs“ÊêA£7mذeˆ ›pxrÃÜ3—ÿþfiCÊáÃ8I´}Û?ú°kë„)(YQÊ�<¡ö_×ÕØÒÄ¿&•’ ‚ Úg‘vÁNs� Ä&A¨Aœ ÈÐŽ|¨!F»Íé‰*“M*7¬_¿¡±þÉ'ë%Û%>ðó¿òÜϯ SùµvBÓø×$¾®,àÊȨƒPj3š•6¿ºAÔºBl;–=ýmYý0š¦Âlܰ~½dëàyŸ~Æó:þŽ^»x ½Ö½—|Fõsõ>·Î«�¹òJL;\/ÎV¡ÛËʉî†Ûª#š¥TèÈh™…0§.ŽÅéúãaø~3C[(lÖÅM¶Ž�Õ¦}^G†ê@Å/YóâùY{W;N/Àâœ9>§ž-Ô �$›¤�"D j‡DÛÛQ5ÒJ—pëü˜¾hÔ}Ÿw+ÕYwr8öGó•Ø;døÿÕf…�]ܳo[]·E‰ B³=—´ør7DñÌX³Ô9²…V}7ÿø?á±~˜*-ÓÒ¸(ââ¼N�€Bu�±P ÕuÆÂ0˜“a0ŒWïÁˆ�q0ÆÂ$(‚¡PCU¹ Vïˆû±ª5N†"âX¸_…¥ÁƒUØS F…-2ÕbõÛ((‚bª>[%ê…0A…:Æ«°ÇÀ8 EêšZŽY C`4ÜCÕñp5ÕÖ+†±ê§˜?FÅEÃt"Œíµê�X Èz0…0†ÀˆÀÝÁPE*<�¿X˜:.îÁsXÓÁ*�dsÜ£Õoâêý0ÆÁX˜ òS@À¶X¥aŒÐR¨b IBÃhŒ…q0E�1FÀD ±ÒÄÀLñ}¢J��ÌuÕQêU ³±)‹ñm(¢kjxþOêYy‚Jÿh­òVÐ;A]¡Ø¸Ýº3\… ðÖ¸q¿JŸÀ¯H¥PÀ÷?G÷ÌßK*B¦ƒU¹ ÌÅó‚Á‘ ßKI7´;¥ó}Úѽ‚€%ä&85Z�=ÆA! Q!iW4},Rià­SÓ{M'´¹NB>Ūdïƒû34xwS¡YˆÀÿ6šÞ‡ôâÙmé ˆçn|„6 -û.W„ý LÄ,¡â[7„Ž )i˜kö¢­Ñ-ÇûúÙmyÅwñ·ÛŽºçý'¾CƒÕ½ö�ü|Ò0Ô� åäÒ"r‘“ÿ:J>ûKûìùKù´Ž|ÂÉŸ9ùø#û˜“�äÃ:ò§?:ØŸ8ùã6#û£ƒ|°š¼ŸKÚ·Y{.iãäÂ{v�“÷ ä<'ïrrn«•�‹$ï„�·9y«Žœ­ö²³œ¼ÉÉ™Õä N^çä5NNïb­œœâä$'¯rrb›‘�°“ã&Òò‡£¬…“?›Îþp”üa-=vÔËŽM'Ç|ô¨—áäpi®Ì^áäPí`vèùýŽ ö2'/•’ƒ¥äwfrÀFösò"÷u‘ßrò'¿±‘&NžÎÌžÏ Ï™É³û¬ìÙ²ÏJ~½7™ýz5Ù›L~ÅÉNžá¤qwk,%»©°Ýaä— +ù…�ìâdçŽ ¶““A¤áéÖÀÉÓ)¤¾v0«¯#uOeuœ<õätöÔQòÔZúäã^öätò¤�nçäçœ<ñ¸—=q”<î%µÕ^V;˜<¶Íȳ“mFRSíe5¥¤z«•U{ÉV+ÙÂÉfN6q²qƒ•mädƒ•ü/NÖsò3kûÙ²Ž“µ��5?]ÍÖpòÓÕdµ‹ü„“*3y”“•œ<ÌIå +«´�Êf¾é +Yq‚.·‘å>ºŒ“‡8YÊIÅ’ ¬¢Ž,)O`K&�ò²˜“Ed!' 2HÙ 2ÿ(™ÇÉ\NJ9™3ÛÅæp26ÛEfq2““9™1ÕÈf˜ÉôR2í òÀT#{ÀN¦ÉNJìd2'“8¹?"ŒÝŸA&r2�“ñœÜ·šŒãd¬�s2%³1œŒ>JF%�‘E¡ld6)bcE¡dDa(ÁÉð!66¼” + eÃŽ’ÂP2tˆ� Í&C +¬lˆ� iÆ>Ÿž ¶°+)hÆàÓÓÁ>3l!ƒ›Ñ ŸžúòMÌg&¾f´Ö§§ù&=Ë7‘üfäó•Ò{9„’Ù $�“� $—“kË)%ÒÃÙ€Q$›“þÉvÖŸ“¬Q¤_Z8ë7Šd¦…³LN2¬,ƒ“ôd;K'iá$5ÙÎRCIŠ>„¥%É}ƒY²�$7c±l_ÅÊú“¾Ý:št�—%qr�>„Ýã%‰8—%r’ÀI<'qâ )`ÞBÒÇB<œÄZ,,–wL2s¯&1É$zqY ˜‹“(N"#ÂX$' °ˆ0ÎI'¡œ8C +˜s q$³�â°+Ì‘Lì + …Û‰ÍZÀlœXQ2³ÅbaŠ•(ï,f³XˆEã�9ÈÀÌ&bÖxdÒ³  jF¾—©IOLB·²©‘ƒ>„8ч�BdN$”Ì$N˜�œËÈ ‚Q2ù�ÂP2… fTºaJúçþo#ð?ü‰‚ÿ ž@’ò endstream endobj -405 0 obj +400 0 obj <> stream xœ{áá endstream endobj -406 0 obj +401 0 obj <> stream xœmQËjÃ0¼ë+¶ArHý¥%CãÄàC4¡=;ÒÚÄ’�äƒÿ¾H¶“Rz�ÄìÎîÌ®èÓé¼xçꊋås hUg.ò}¥ ¥[ź¥; räSÖ®@Å,:ÈËm)…#”–’Ý:Žç?Ê!¯yg�j ¥án¸‚Ù€à JŽÒ ×C<'”~¢±BÉ$„Ò�ä¹j½9K¢Q¢“QìŒj!¹•àêuI’Ì�(ܬ­t(>÷Öa[ÊZÁr`ñN�L€èa�éaŒÍ�c=dކ£²�ÙdöWòÜi}CoâEÉÃùáU‹�ߣã”��d°ÈG«+†¦’ ’uÇqë¢(ŠÌ+þɧCÕµfß• ì$ƒušì^³€R�^6o¡vdù.~YwÛ¬3¥ » @@ -1381,7 +1353,7 @@ x 'üÖôñ‹yÍ* endstream endobj -407 0 obj +402 0 obj <> stream xœ%�OhAÅgM²‰é4Å�¡ù3H=$i‚ˆJ/5$Rh#بH’ši²wewÒèEò�è2»Ý$Ĉ –^zÝ‹"ÞjO9z(=õ(EØ• VÖ\Þ÷¾Ç{—œNÀ0Œ?�뙵µ"©Äïàr­Zí4gΛa @@ -1391,125 +1363,131 @@ x ¥Š -X²™Ìûm$Nõ›õÃ÷Ùâtó“ÎX?ÐtGàšylÆ‚tØ´w,ÿ—”áÚ6Bòëö I›´Ý‘›ÛV(e¹,ÿFûU·C[žÆ°5Š¡É˜�º{ìh8Å̱rÿw »Á,Ûhµ±ÉØJ˜c÷¨5lD³ìÑ×Ãïû?÷¯Þ> stream -xœûññ +xœûÿÿ endstream endobj -409 0 obj -<> +404 0 obj +<> stream -xœmR=oà Ýý+®R2¤Æq»D‘¥Ö©%ùPµ³g)xð¿¯ÀvRU½»w÷ÞäéT­Þ¸ºâ*}¦pF«zÃp•ïk²S¬ïPº"G>gí´QÌ¢ƒ¼Ü•R¸ˆ�R²[ÏqæüGyÇVÈÁk@Þ[§ºˆ�‹p7ÜÀb @ð%Gé„€.#B>ÑX¡ä’ˆ�ÉsÕys6Š' ˆOF± -4Br3)ÁÕëFɸ`nBag]­Cq5X‡])éÈ⽞˜ñ[a�`Œ-�c3fކ£²…ÅlöW²êµ¾¡7 4DQòpÆ~øCÝ!ÄÓÀ÷è4%$�ÐeÐ85ˆ¿öŠÏ -2ÅÑêš¡©e‹Ñ–RJ3ØEQd^ñO>«® û®M`'l)}M³€Ö#¢#JzIC§©Æ÷ôWw‚õÆ táæ‚coOH¼?�VÚW…Þnþ‹p`Ï  +xœmRËnÂ0¼ç+¶Kp qå€P¤)Ôžƒ½PKĶlçÀßW¶¨ª’hvgwfì�—ýqòÎÕ'ù+…ZÕ†“rÓè„�µb]‹Òm9ò¡k �b”õº–Â%„Ô’Ý:Žç?Ê +¯B> ^ÊÎ:Õ&„œ„»áF±ÁÔ¥îtœò‰Æ +%�%„|H^ªÖ›³IÚk@º7ŠÑÁEHnz%8{Ý$›Ìõ(¼YÛè0|¼[‡m-/ +òÈâ�î™é¯Â:s‡Q06Ž—ØÙŽFÈ+Œ³¿šÇNëz“@C%ßÔ‡ß6-BÚ~Tû”�=K§»Æ~AúµQ|Y´ÈG«†¦‘WL–”RZÀ²ªªªðŠúó8u¾°ïÆvVÀ’ÒYY4 h^E”G´ŠhÐ[Ñ[D4¢yÜ’Í~»W÷‡üˆË:cPºpÆ!›"$>.K+í§Ânyøa<ÚU?øè×× endstream endobj -410 0 obj -<> +405 0 obj +<> stream -xœÍX{pT×yÿ�ýîÑû±»Z„ V�Eô€‹ØîÊ’À²„$ô”àI»z­v­•™Cmǘ¨“T¡®ã‡Š±C:¶’¢umw¦iÆm]›?Ü$u\'™´£ahÆI<rÕùιû��±'i'Ýéž{Ï9¿ï÷ý¾ïœóÝ…�Ž£ ¬ï=0ê¾Ðð­µ^ÄC}áþà}«ïl>ßìïÛúÖW¾ØfÛÆ�@·?ÅÄ?Ò `óÀ@ ;õ¢ø% ÷(Ž’ÿ%ÒùyiC¡Þnñmü�Çù>Ø}(lØèG€ü*÷pw0ðó¢ä¯ò°äÕp(2:÷Sœ–°6<7í|º -X~0>U¢X¼(Nâ"lÖ÷ªhÆ^¦‰bQ*ŠÅ2Q,R°×ÈÅx{­Q{qÐXF/‹bQ…GÑ#ŠaŠbÕÛE22Ѓ #ƒÞCÆYzƒT=×l§moØNÃ&€IØð ^Ä÷qgð2¦ð�ð`¯ �Ø€§D¥(Æ5ØD¥¸"ÒD5zè ´á"&q/ Ί$D È+x ïá-\•WäLÊ+òм†û„`eÒt’+¹WE³Ø%œ˜Åßá?m~ÚKOŠ»p9©Ïö„í5cŸúpÕ¶×vØöÞ3ö‰óx7É…I<ˆ'‚Ípâ Úb4áC¼ þ”†ó´IžÔ_á)xK^±ÝŽÃÌR^ÃiªÃí -ñÏÉ“IY¢2ùyo"¸€_|79Id(sÛ§lžÿ”oç÷?t–—-¸uÛ“ÝSh�ÊwOÏ͵î1–Ë®)¹bŠ<)S†§ø½�ê|¯¼¬±u�{ê•ú: µ~_]yYcûž)›‡ïêº - ËËêëT�’ž)éiØ7åîpŸ°Ÿ(ÞzÂØZØ0`Nò,ÉÈ÷e—‘tY¤È›�Ê×ßžÙûÛ3oϬÏq:<…ŽÂ×#´üúÏ͉ä¬5’t ŽÍ½oì’×PаïŽÜ%¶¥®R”feÛN™™”zr\¥0Ò -Ž­ †óÓŽ¥†2ÃIÃù#kJs\(±§®)É]ºÊž»’ŠÖد¿>s}ægguuuõØöÁÌ3ö«¿¹êXZ½¾±}O²=뎥ÕÖ¥«HTˆMKª¼¹K¢¸(i‰+w•(K\FaÑêRG�¨ònÞ´qu©0ß}Jï÷ÿSàs¯ïÛ?ÒþÐΛ¿6zwàÀO†‚‡Z›l§;/=õÃ_VV˜?­Ý¶«õŽ�ÖßùoçþãÝMÅ†Ž¶Þ®ÚÀJÖk0Ë+HAÊ|KEØŽpªß™b³§Af®r ;u…Ë~}Æ{}Æ¡�¨ü€M¥ØSè6˜_±£Pü`üñ±±ÇÍ}âÏÅ&‘mþ·ùÃaóã'æÝ=ãã=þø·¿ýñïTZ -œ™{ߨ–×° ¾üeÇÊ S汌�=œ:L#ù9…X•´"Ÿ Ï$ê¶Þ“%ŠÝpØQɶÄå¬ònÞbTo{¢ÓüWóUq‡¨è|²®étÓäsÏM6�nZWR"N‰Cb\œ*)1§·Õ˜s¿»nÎÕlÓ\Ûg§/Û‹þösÙ·ý«RÔÂyëÕuD¯×ƒ×ß‘ï¤t@@wZó’ƒæJÀxózÐüP¾£�?Âx8†IœQ÷E8ƒ·E¾eÓ°e`H‚ vø™^%�à]!'@F*€Ë€Õpã²Õ¶!ÿnµ kñ «m$´%ò„Ýj'aµXcµSP$š­v:¶Š°ÕÎÌY-Î[í, ¸þµ!ŒqŒ`ýÀ(ÜXƒ^Ü7¼X�õ¨‚=‡wb£ˆ`# A”Á� £p£C‚m1¬ˆº ‚FpøQ�4Ô!€{Ñ�]ƒ½@7†Ñ¯FºÑ­ðÝÄ0Üc = zá†!Ñ­úâ´+FØ�†Â�aþ�çŽ�Ü¥˜F0¨zXƒ -TaË<„èüèìò�°Ó§úµ -£–b¬Ê(ÂØŠJTÂo�?€1T ‚Æ0‚^ÔÜ¥H†À(¶% EŠFêÆÈp«Î£zÀB8ˆ[TœþwÔç8¦-jYkØ ÷<Î7fZÊÿ€/[ÿcd¯ûc|´Tä˜óŽ1k6‚ýp#„¾�åžµ*¼ B‹g£ÆP}˯~e…Uf~ŒÓ§z1k:Â:›¸Te<Ïáùa+ãµ…z0jE˜ÿú-_z-¥£˜£ŠÅüïF¯DØB�"ðhÍ]gR@­�ÁE YR¤"Çsýêʾ‡Ð‹At[þéìÅ‚ -…¹ŽÆôéà †¬<^ã·ÀkŸù�â •çl1® ? c!ø1¦xÆÙø•±Aô`Lñ‰ëðÑ�uèÅÆŠÖä Ê�µæG-e8Þó=ŠâÇ3<c;¦4,Kˆ·Y—x¬ãë7‚õd1?Êb~Vª}Ç­�õzÐØƒ–ªó£s¯£Êi¶:Ï´‡ó³.îÑA¥GðYˆ®†>µg[êÑhœ)ìIH±‰(%îE½ -O�IÌã!k—ŒFˆ=gcñˆ`«Z�Ö¬nô ¤v†x ÷¢¸7î|r0.gYdÞØèZ /º$Îc¯xmëHñ>??×´z'ï¾I<Yïû ºÆ÷�O‹QŒ+¾}j`ìŠyJÝl.k2ãÏÖYs^ËÑ�¹sžŽÄžh¦¬iÔKŽgbÖEÏ/¶¢õÃ�º‹{ÄsYÙ~+ µ¿ýRÞ XÏFöPöN3‰Äl,Ô'ò±>%îqþyÆž.ÎàæLæÛ[¨ËbµŠÃÊ{òÑ»ºŽÿg~Áy¸Ñ'‘XfF×ÍÂS$`íwÌ8né òʯæ-r.Åü^8ƒÇGOÝ¢„lÓk§iÁ9úè³)Ê•³a(!Âà"ŠpH鬳·a„­SŒW?Ÿ6щñלo¾b8ŽÜÇ׈őíÜ,_´w‹íáÜ;¦FÍW¸è¦õJѼþ¾k6bÕ¿úÌŽ¯ºèŠâ -B¯=>—ôù²‘çôb?ºÕFÖ碮ÏÖÿ;ÖG{¥+-­"Ÿ‹}1¥îB½²Ó‚ft(;-؆ìF ÚT_ÚáF+ÚЂ]h@êQ§âR£z¸¿H­ÆÝhPˆ-èTX£ 5 -» n…Í•j³ºkDšQ§æÖc�²Q�v…Ú‚6…½­hBƒ²©kÌfÔ¢ �¨SííªÕöšÑ¢®<~‡â¢™v %Áê|VŒÜc¶õhC-î²zkp'ógûÛT»9Æs›Å´FiÄÈŒY‹N4©;~Ú‰6´¢íJOF®³Ø6+¶¡Íò¥^1БЌjÑ‚Vt©Ûq: ¶Ôa�äûåGf‡²Ú¨žjf-V”¹Gá÷¶©y°þ»b–Û•ÿMhRÚ²¿íÊB=j°#†Í�í -�yk5:•̯AyÈÜÇ*²žM±‘m Qá˜Ö¨¸1sžÏž°"í‹zE›�Ų#j�±8n¬T“ÝŽVÔ£V!é':”¯µ–¶Sç½Î =Vsâø4«ÈîD§5Bã-ôB¯æ÷BG Æú_› Y<úŒÈœ£|8›9ËnT…×3áQœ|U�sŒ£¤™ëõ¢mDãØiågtå5/Ð7ºŽ¢ã>ÉÞ¡±¢¶çG�õd�4C½“4"\½wÕã�Ú÷ÂÖ¹¹áäN¬ãUibýY–°×&Vzޮƌ‹?Õû³>³âï<‰5Üb'Wô-¹lAõ­>ôÞ­ß�«_¿ªÓu-‰U%úüÅ*®þuÅ}ká·A>_æ¿ïE”]í™¶u#–®/yœ¶YDÍ›�P ß™ kÄÈU›KÒC·Ãcùùý ÞŠµŸ<Q_>N~Q§(×¢ƒJa®'+,Ü‘ØûY\V@ÿº\õxö1ÚÖêPÖ ?�9¿ßéƒë -¶™öü¾V©ôÞ�AT*Ž<÷*TF傊’[WŸ¹/àÓÖ/¾ó?ü+ïfTa50m;ê½lÒ¥KôýKô½Yúî,]üÎvyñ}g;]ðÒßLз½ô-?MMÐK/æÈ—öÓ‹9ô×9ôM“Î#SžŸ¥odÒ Ï?&_0é…WŒçÏuÉç£ç�çž[-ÏuÑ9ŸñÜj:kÒ_yir =ûÌvù¬IÏNϽé›3žyºF>³�ž®¡§¾î•Oí§¯{éI“þr–ž˜¥¿0錓¾æ¡‰<úŠI_6éq“þ̤Ó»<}„N�tÉS¹tò1»<é¢Çìô¥¾ù%/�È G�_’�štü‘{äñKtü¨ñÈ=ò‘{èŸñE=üP¶|x=”MNПšt,`—Ǽtô�yÔOäÐ&舟>ßN‡û -äa/ݰËû½4žG‡ú -ä!?4é€I£‘Lɤ‘û*äˆI÷UP¸¯@†�P(�†ƒ—ä°IÁ¡{dð�Cƒ9t ùŒýûéÞA�¼÷ úæ<4ÐW üÔßW ûý԰˾ -ØÉoR¯I=&u¡}&}ÖO{?ã’{MúŒ‹>í¥®r§ìÊ¥=¹´N¹Û¤]^ê4©£=]vØ©=�ÚvæÊ¶ ÚÙj—;s©ÕN-&5ïðËæ Úá§&“Mº»!GÞ=A 9t×,mŸ¥mG¨¾.GÖ¡ºªÍ£š,ú/Ýá ÛoË’·›tÛ§ÒåmYô©tÚZ½Tn� ê[ÓeõRª>jÜšN·úŒ-›óä–-´¹Ü)7çѦ�yrS#m¬rÉ�yTå"ï†<éõÓ†r§Ü�Gë+ó|¹r}UæQE¹SVPy™C–;©|Úæó¥eë²e™ƒÊ¦mð¥ëÖfÉuÙ´nZ¼âK5Ö&¥ÉµY´vZõí6ni¤5ÙTÚH«Kòäêò”äIO#•À)Kò¨ØEE+\²ÈK…î�²ðrÃ)ÝiÕr—\•OË]²À¤•+\r¥—V¸hy~Ž\î¢å¼6R�üe™ŸCùšÓ²”l¹ÌA˘Ón#ÏEK)N™;AK¶�k 则3KN/9ì^é˜%;œÒî¥ì¬=2ûeÁ)³öPfJ¶Ì, Œôl™Q@éÙ”§LIÎ�)Ù”¢=LNJ“ɔ̦I2U&¥QÒ´ð]0d*Éiß2Ø ²eJ* [& 8¥( 8IL ÿÃ'źÿ×üm¯üî�/„ +xœÍX{p\Õyÿ�ýîY½¥}Y/Ûò®¤µŒ­—W~ »+$ÙÉ’¬‡m%†XÒ®´²µÚE+ÙŽc»@xch§ +¥„‡Š q2FI ˜ñP 3¥©›Rð”¤Ä…<:£xL†4Œ*®:眻ÉÂ0M;éjì½÷žs~ßïû}ßùÎw @ŽƒPÙ{hÄùBÃ÷×x`w÷…ûƒwl¨>˜¼¾Û?8Þ×µ9í5À4�/àïö%ëøÀÜ +`S àïNy‘ý0ß 8K2±ó÷XC½Ý&̯ˆû`÷XXãô`þGΡî ÿ…IßÌ3À²×¡È6³`Å€Êð°?Ü´ëÉ*`ÅÏíVÅŠØ9v/Âdü]aÍØ‡#ô+b%¬ˆå±"–Œ}Z:+ÂEì3fíÃa-�^aE¬ +÷£‡AgEr´'Ф¥£Z:]FîÁ3t‘î’#WM§LM§`bÀ$L¸ çð2ÎàQ¼‚)|ÌܘÄëÌÍÖã VÁŠp&VÁ.±TV�ºˆ6¼ˆI<ƒ¿c`Ï03"ø%¼ŽËxWø%þ(&ù%~‰_ÅL°ÒÌ©®llß›ÄßL²$¿ÙUhwY™+…¹X’Õu޹Ù~Ö«ïe¯ê¯è}ú{fÇÜOØQýöOo6¥ï×;†óh»ùU” ìÝ–½Ì”ã(AIf–Åjãv Ämw”@K-8±2ä +ç§žH e„ÍCùÃkJì[RÖg笲d¯¤Â5–¹7fæf>´Úª«««•PBªÿ¼b5HZ2ß´æT_]…¬œmÜP\åÉα–³"©ç*VÀ–94WáêkSê–0ýý'˜öAÿ?ù¿úÆþƒÃíw{á¬þ;ý·¡÷‡~6km2�ê<ÿÄ�]Q®ÿ¼vûîÖm»ÖWÞü¯gþýý�ØúŽ¶Þ®ZÿJãI@;Â/!v”zsXØ‚pŠÏ–l²¤‚»2VY‘•²Âa™›ñÌÍX•‹ŒcVE¥Èírj‚_‘ÕÅÞdtô}?û ¶‘eéé?ÒßÕ~¦ßÚ3>ÞóÉOÿûŸ~*·1ãóhÕü*òPîÍÏ;�Pv˜2N¤‡,á”!η»Ò±Ê¼"_žIÔ­Ò�ÉŠœ"±\Q‘L˶*ϦÍZõöÇ:õÑ_cÛXyçãuM§š&OŸžl:Õ´®¸˜=ÄÆØ8{¨¸XŸÞ^£Ï:§Ï×lW\ÓíÓG™3é«Y7ý«’e¡yûµuG¿ç‚sïòw“;À �uIA}% ½5Ô?áïJ¤ÄÓÞB¢ŸÃ LâQ…؆¯áeVÉÙäŠ$S:ÖÁ3L°À+,Ð󬢚¦á˜–à`\38qÁ¸6!ÿf\Öâ—Æµ–pÍ‘Ë,Ƶ«Ùã:…¬Ù¸NÃ6®3ì«ÙYã:Ç?£!„1Ža  ŒÀ‰5èÅ pƒJT¢ +Nô`NÜŒŒ ‚ Ã�nQ +'0„^”É bN´Å°"òÎ�üÆ!øáC9RQ? »1 +'z@7†Ð/g:Ñ-ñ�Àœc=Äzá„!Ñ-Çã´K�°! !„› |Ÿ;Ï›¹[2�`@Ž ÊQ…Í ¢ë£«Ë>ÃNŸW*ŒŠ UFÆT >cþ!Œ¢„0ŠaôÂ/×KEÊ1?F°=-ªP4R×FFŒ ÕŬø1ˆã§ÿõES—´¬4ì†sçk3-eÀŸ°þÇÈ^ççø<`¨(b.žˆ ͆qN„Ð÷¹\„g­/(ÑâÙ¨°rÌoøÕ/­•?�Ó'Gý1k*Â*›ÄøˆÌx±F¬¯,„Ѓ#Ââ_¿áK¯¡tsD²X˜ãÝè•ó‚èQ1[qW™ä—ûGepaB–Êȉµ>ù-|¡è6üS9Ø‹Q%Šà:Ó§4òxMŒcÜ‚Øû‚ÿy.,Æ5OÂF>ŒJžq6>é�ˆØz0*ùÄuøl ]èЋAŒJ¥Éa™¹çG eD¼zÅ�gx$ÆvTjXšq-t‰Ç:¾#È'KùQó³BÖ§DVûAaª.Œþõ½Ž*§Øª×§Äç[�aÂÓ¥\ŸÉB{‹uYŠ£RqHZž|vUWQÿ ~Á¸Ñ'‘XfF÷ÍâSÄoÔ;Á8né°ôÊ'×.q.Æü^¼BÌ�žº… Ù¦öNÓ¢sFè¢Î¦(W‘ ƒ ‘8„–PÌ�1©³ÊÞn„6N1±ûÅi]‘Åùú;FÄQŒ‰ïˆÁQع^¾(ï–ªábtTÎZ¨páuû•Â1üŸîÙˆÑÿª3;¾ë¢;Jtjï‰sI�/‹Åš^D·œ#�Õ¹¨úóÅýÇÿEÅúl¯T§¥Tçb_L©[P/í´ ÒN ¶£{Pƒ69Ö€v8ÑŠ6´`7P‡zÔɸÔÈ1^(wã4HÄtJ,…ц‰Ý§Ä�j³¼kDšQ'×Öc¯´Q�v‰Ú‚6‰½­hBƒ´©zÌfÔ¢ �¨“×;d7ªì5£E~‹ù;%Å´- V²Èí1f;Q�6Ôâc´7£Aâ þÂþvyÝã¹Ý`Z#5ȳ�h’wâi'ÚЊ´K=r�Á¶Yú°m†/õ’�Š„bT‹´¢KÎØ�[Ð!YKÆLqß!ý‘Ù)­6ʧŠY‹eqGï¦â!ôß³Ü.ýoB“ÔVøÛ.-Ô£;c¸ÑÜÙ!o¥F§ôOðk� + 1&Tz6Åf¶%DEÄ´FÆM0ë…'B‘ö%=‰¢-ŒÎRÙµ °DÜ„RMrv;ZQ�Z‰¤ž¨|l�¾ÖÚ*L•÷*'Ô\ÅIħYFv:� +o±j‡þq/TjŒÿk4‹G_ +ÎQ>"›E–]«ŠØ‚‰˜%²@ÜEU9&¢¤˜«ý¢lDãØiägtç5/Ò7º�¢ó¾HíPXQÛ #(ô:)†ª’4!\U»ê1&ë^Ø8×"ל܉Ýc¼+Mì?Kjmb' ªð97¸h^ü©ªÏêÌŠ¿ó$öpK�\Ñ·äÒEÝo´ûPµ[½%v¿>Ù§«^0ëJÔùŠu&¢ûWCô­E¼ Šóeáû^DÚUž)[×b©þRÌSÖ"K¨y½jñ¢à"4È‡åµø-Iu ÝrŽ˜+žß¹è­XùðÅcõåóôO#ò½è€TXô“åîpìý,®‰P@ýº\õxö ´-×ô¡BƒþæâýNõ¢¯6Sÿ€ß×*¤Þ1€ +ÉQ¬C¹ìÂèXÔQŠßØågþëø²ñkóÂO€ +´¡›P…ÕÓ¦ãÞ‘ :�?O/Ÿ§—féG³ôâwðÏÓwÐ ú› ú�‡¾ï£© zþœ�?�ÎÙé{vú®Ng¿“ÁÏÎÒw2è¹gäÏéôܫڳgºø³ҳǵ3§Wó3]tÆ«�^MÏèôך\FO?µƒ?­ÓÓÓóoyçµ§ž¬áOí 'kè‰o{øéÛz\§¿š¥Çfé/uzÔFßrÓD.ý¹N¦Ó#:=¬Ó)¿…Ÿ:J�tð‡²éäƒ~ÒAZè›}ü›z �î¿ï<¿_§ûî½�ßwžî;®Ýû 7¿÷6º×«}ÃM÷Ü�ÅïÉ£»³è® úS�Nø-ü„‡Ž³óã>:f§¯OÐQ}­�Žôð#ºÓoáwzh<—Æú +ø˜�ëtH§‘H�dÐðå|X§;Ê)ÜWÀÃG)”KCÁó|H§ààm¿…÷�ßB>�zuêÑ©û(í×évíûŠƒïÓé+ú²‡ºÊl¼+›öfÓØø�v{¨S§Žö4Þa¡ö4jÛ•ÍÛ&hW«…ïʦV µèÔ¼ÓÇ›'h§�štjÔéÖ;¿u‚ìtË,혥íG©¾ÎÎë�R��js©&“þÄCÛ¬´õ¦L¾U§›¾”Æoʤ/¥Ñ–ê¾e‚ªoLãÕ9T}\»1�nôj›7åòÍ›iS™�oÊ¥�rùÆFÚPåàr©ÊAžõ¹Üã£õe6¾>—*+r½Ù¼²Ž*r©¼ÌÆË ¨¬ÔÊËlT6mòzS´ÒuY¼ÔJ¥Ó&xS´uk3ùº,Z7Í^õ¦hkÍ©|m&­�fǽ{´iM•4Òêâ\¾º˜ÜŹÜÝHŰñâ\*rPá +/ô�˹�»¶‘6îÜ@«–;øª|*Xîà:­\áà+=´ÂAËóí|¹ƒ–‹½‘¢åçYy¾�ò§¼ä,žg¥<Ái�–ë œFʆ�gOвÍäØLvVÀí³dó�ÕâáÖY²ÀÆ-ÊÊÜ˳ŽR&l> +406 0 obj +<> stream -xœí}]×$·qÞ=ÅP”(¾· -_²"Û¢�ÄŠ$Û¡îì\h÷x™ä,7Îzs|üïsª?Ð�éénÌÌò4/¸�~gzª«€B¡>žúæ¯?|ü_oÿüæãå·øö³ÿ{‘q—Wü�# ÎywyóÃ7oÄåÍ¿ñÁ{”Ú8×ý•ºüÛ›÷Ý×~¸h¯­6qy7 “ÞÅ�}÷ÙÿüìígÿøÙßþáÛoF*~ýëoþôÿú/ßüþÏÿñþßÇßüæ·“…´”N^œô€ÍD›”Ò²L¤Þ åõEIo„uº#RjéõEJPV3Åñ-ouGczÉŒ‰ýî_ÿüþ׿þæßþÝß\Ä7¿ÿóûï¿ú—÷/b…­lB,)©,j¦­#%‰ojòBzô~öÛ?]ÄåO¾y+.R_þô6�¸üé‡úꟅÿ,„þÅá_õâÆ?Ñð¯þ5/ÿãO¿ûìoÿTxYyA �¶¾ø&¨ºyà/ó_ðÔPý”¾‰¼ø›^d|‹¤¯ò7þµÝ¿¯“'|,~füëû~$Uá o»ÿˆøòÊæÌ'‡ÇËø!(⟠Áñmôcá¹8¼6„áLxéïãxŸ^FÑTpäRÿà)—‡ŸI–)Q ¼œUäu`]�®Œá—"Ȕ֔ÙÖQîc%’g~ˆŸ<ˆvÎ�ñ»ùýü=Sy¤üŸæ÷È;©D¾†³·SÃ/*•®è[õ¨õ&[ÐÎkRVMÑv×6ÒõÒ"x©”ï”ý4’,�º“¯6èyèÃ}šÕ%ëdŠ:Mϗ¡Òè)ÞŒÀØa'ê®ìHW± ÑqF�2 �uR]¬Ó̉횼ªÿÒUª#]–ê¬q¥Œ³KïœÖ�5ýK}/.ßÿÛÍ3™+üÞ—wáZ:�Ì©nŒ×;v|KZ -:–JeÀX‰•áz•ÆY°âh^D¥–@J¡ÄD.É€÷Ò‹?Œ{Dên¹/‘z8W÷ ¿1©“Zµä ÿ Vaˆ¶Ó«1�&Á sù�N8m•�¯†¿‹Ë›‹#±#¾¿"p²Ÿ ÃÕ½ˆHÅ6~?xÕ�˜2o0i�†éì念þÛãH€‘-Éè*þ\ý&&àÝE‚ÒYÅ[C÷Œîãɽþóoúu(@ƒÙ¨äí|T$*×­þ[¤þax·‘s)W¼7Ç=['õãñ%¯3}|l:šˆyw�Q£ÜÆÑÈn#…Äîeã{©íš�J+C;¹jA[ÊFVcñ[jéì…;P Nw°8\¿¾Ô�º¨œ“è†;ý„GõÃþ+onÁHÜð@>k;w‘@¨IvBÖãô×o¡áÅ�Ù₨æ‡JÎlÁ]4œÝ^^±Qç½ñº|ÂÏüã/�î¦@ÝøÜù/3ÅRŒ>!‘yRYzæLóuÙ1%첑jò3Hͤ§S·™´‘ÔpOQOn—„…ÛØÁ4Љþ sZ®{,×›8yš®kç'¦+ó4\ŸÔpÕêÓn]ozizíä>­ÖeÖ�Fë’Ѫ—C§‘õ£t{ØÖÐÁ5óg �v¤Žâf&Ž„¨V7ˆ_ÉÌÞÄ)Ò¢,¾È¡†ÜJÃÍh¬½Í­·Ôô^Þ`îcüÄ�¹Y\2¥‡ðâ‡,<ªŠÏ�®—dkS�äà2o"¡œc9'ˇ -¹ OU‡†ÀtÊ›#írà3>�fù³üF‘Ž!dÀ*Þ EhXÏáƒZèÇ“é}PHa+åçybݺR„§ó@ñ)(H€ñšÔy¤Xo“•ÌïÓ¾•yç©béTáV�*”æìÕí IuKotKUH“ËÖ©Ÿ‘lYíZ’ºHò‘Öif�¿]t¼í¼1&ûEç„`‰Ãïã³HâZÎÌær¦âøE[òM/�P¦£Ð+9ÆB"éÂq¨’,jS�³“œpª• §Çáß,»2nÝqd`1:³ÿ°©t1~3[BngHÛK"Ë“äÖ ßbH§":Y�4`e3¹…’q¤xØÍsj¯Ç»ÂäE‘rZç1�òó¾•E߯ Þ�š47sšYÝ¿—ú”Ió­ß¯!ÖD(,�òí¼0QðóëGï„nµ|40Þ�v ]2g~ª-‡I!kl¯Å0Ó6‹x¶Í²Î»RWꕉ™nY9Á‡ÂÖ¸ä@[Šh¿�'M)©9RݹZÌÕÞø…¼(¢&@] ó †Í&ÖÇ*…�ôb <[ªaHfs¶[è ÒT¤cÛ°]REHHÕn}Öœ›� ^µ¯šŠâå•ä�JŒž¹3¸{Ê¥¥W,VZ�®O­~Þü4z׉°aî†Å_‘�«IÈJ�í&Ô²!ÝÏ­Ÿ•ÿ˜Y�‰ ¿¨㌚·×òF2�Pò­¨²è˹zý2‘ÂÏ—� W'_E^¾&/#Á‹v¦Ä�J_mâå‚ù=Ó;ãêÜ›ïH£µ0ª,.òº¢È©Èd7ý}YfX;|ÍuQìžh»� „¿/O½Ú¦ƒ²R%CȤVÔõêÝÔmA×7�±ŠO-ÆŽ/¢¢¹”}-LOŠç›\.ÖšŒ”ñ‡ÓJÑqÎ|Ì™™²>Ü—«×.Ä‚óÍöæª&eyÏí�vÛ*[gÇ{€ß…k© ÷—�W{ -¯$Oq4…±iC ÑzýtŒÔœ1šUË~aK µ3cÓ8:–ÎÝ_$ó ¶@êboÈÒé, 8"¶:ŒûUa7}ñ—Cá·Iÿ …¯œ�÷8CáŸB(œ€QLË _Ìe–©dzŸ‘ð­Ì;#áK‘p,@rh@¥yѲªÍs�®„ÄaT‚WêP//úß7Ÿ›”a­4Ÿ”Aµ�èÓ ÊùHŒã™ÚSÇÙSÑä<í©'·§”o¼4ýwTkt†må 3R{ê¬VÚÆºÓšZ´¦ -5ö~rþ �Ý/5ÊÏHkÝõ�qÕîß_]dz¯ŠÄ ‚RŸ†‘·�èÓÈ«xÍn’þiå­›�’¯N+ï“ðš!‚ìh9�¼µŽ”à’é}zͶ2ï´óí<ªxÍ$+…gõš}BÕ6¢OƒjÙkv›ð^J¼‘ðÓ\·ªNCðr÷�–à­>«Ó<Šw§¸hêš¿Ovhâ¦Yg–¯š•f¾å$ø<Ã>JuÝ缜üÔœw·}ÚšçÝMÒ?m¶•³S�?Ñ_> ç�p ýi²ÝâÐÓzÀœÓh«pï4ÛÍ6Sqß NÿV÷Ý'dRm#ú4©–½`§EÕÀ vZTŸ�ì4©nõäÌ-ª3ëm#ïN{jÑžšƒŠ�'$;¿žÑ "†PZ>ªmDŸÕÌC‹€š´T·JÿáÑ­”Ÿ¶àÊuuÚ‚On jZÑ OSp] ]©Ì¨3NïÚQÜ;­ÁEkÐÕ‚¢B�lˆPœBZI;°Qºm©j¬ªžÈ`Žo -ÈŽíKTÆÏË?_/ÎÈ`¸æM?*HR¾"+í8×p‘·/ꬽ“}Ǹ71ò41WÎN§ÁÚËÔÓļC—Éê41¯„ ™erõô> Ì -ïNûr±�µXŽÞj‡@˜MÀg‰ÞÞ¶£>Iôö´§Ž‰ÞžæTƒèíiN}BÑÛÓžº5yšSG±î´¦­)Yó9 Û5Â)tnš#‹ä®9lÔË8fŸ?ù±P*×½y -k²´”gUÞFš¹×3ñ…†V˜÷È]©I1Ê/7ù¥p Ðèþ8à’f\k1¡¹J++x½‹Fv•Øí"Dš*ÈH -ÔWªnô¼„³¿·’úÿ2y¨‹/qEǦٜ£Êš—¶KôìÆös¨ÜA¤Úòú–õ4o@Q]Mµâ.m H´¾#¢n É2ùz§sÜ x<Ïr»}ã7ðñ<Ë­œ›Ú�”ҟ韂oÜ X‰}×…ó0·ÎÁkHÊdË8Os›xwç�s•Ò&­‰ Ò3 û4ÞñÓ69ÄÏ|‹iòø”ÖmtŸ&Õº%ušTŸ’ü´©nöòž&ÕA¬;-ªE‹ÊÖÜ@%“ªA>kÚà•\_+ýÓ«¹àŠE¡�?]OûÌ;‰ JúS3ð¶R~šx+×Õiã=½�'Qƒ'7hÁÓÆ[Ç3Z‹�g©‘w–-meÞiæ-šyóª%©$X×qñ=gRD¼mc=m«9 "´Ÿœiµ�ðÓ²Z¹ªNËêù-+eÄ|X§eµŽg¤4xºÏäÝiX-VócIL©áUÛÜ–úÄÞ¾¼2à½÷Æë()4K«ŠÉ§yµê1e…x?ô²õ(_^I±·;Ë�½wS¶ë˜þš~=É1+;_W; -¾ŽëÖ±˜zÅ#ùeDÞ‡<»ïexÿ¼(þUúÄ>Uö‹ëY}$+òDVKÙl2ÇkÌ×àgÿº¢nŸ -™¾PZ”ªø·VºÛ-V„�[Ž+ZƒèÙLP„°é²yÖB¸­dŸç¬BÔDIÚ0ÎËÚ ŠÜ`6W9,Ou`Ñ´'o/Z°#%}WÊs ½8F^ÊÕ'¼ó¼²Ì¼ó¼²t^¡yÍNç]ë¸ØÚ@ÜSÜ"s3¹b>΋|<)û¤Ö£7`•`ãö´Âöy»˰;&œVØqVX4?O#ìÙ�0ïØÅß ë4ÂÖqÌ" ËŒ°Óg¼‘w§ ¶hƒÍKo%ƒ3ëŽ�w2ÂGéÜe|ÍÍùö¶tÌ-žZÛ -�ƒ§S:ð”íýkkã¥eI+åû™FR‚í¦Éxµ§Tš9�×ÍÐ�B ÆöaùþÊŽ„õ ÕúT¨�â½Õ:žu²+ÎO êÈAÝ­Þaª M^HoÒY'.¾:ç^Èg³kÀ‡Â씵@ðâ`Y+^ZëmÇÖh´Gæ‚…É›} ˆÀÄ‘å}¹“¸òL)IÏ+^G”ج¡»èÒm˜´þbIâ¶X-GL yò95‡Â3èìt—âŒÄ9ß\�TÑ_Ò€ÉòwÌüÓƒÊy &"þŠä¯i.úûÊYÓ-Kœ›àÍXŒ2S¥*fÈ �¼ÒˆX’¾¼.BÄŒ‘1Œ?;®Ûñ³jdoù‰ÓçÇqòìá}^Ço¡T²i\ˆ¯IJÙèU;L’ ÕÆ÷£Œ³ —”Nà�Æw´û4"ËU‡J¼û a¢Ñ�H†ØNönQ‹ŠFÔž·9qw�˜/™géh=·EÇf“º\óqç”Õ¬Ìx¿wÊ¢ä–ZuÓbì™°äÀyãð~VV&,)P"£æ›íÚ„½$*üuI�_–o~H¶ûŸg>ì>ËÚ]c1\’"WfÈ�+ø'ñ.ûEòFWÖpå…Teº)¶þuk"^ó³4 J6êì}sͰS °$QÅmožR O3L’Ûjªhi934¥æi´À4o‚[ ²æ~oAôX~Íc×Bqíþ4³ãR»udËû5êágÅ´¨á®˜ÊT}3ž$VÇÇ…F,Ë&üã5 -wgD/ð¹5Šò¬°ÖÜO£T\Ê#0+¶ú‚Vœ’dñ¼:îÿ‘™ùy:gÆU£¢9Óù TNwÕýÎKeMÊ¡P‚rBèòûßAÕô¯ó‹Ò›þ¤\ -Ÿ ¨¦§æaQVXP9'+'Á(jew_1p%9” oxåsÇTò¢•qàQ¥ÀÁ×WkœCPvÑOh[�¦8Ž àEYJÙmJ„hí ôÆÑmȰ¦|laúØ×Ð Ss!ÑX€wÚ8[&´ì}5þCrüŽÖBüÍ9ì %v†J�¥¾O¡š -#ÑÔ3Wƒ¬àÛ&p�|ðuɶ–ü -@h£j«@{0[/Œ)OiŠM -XÜãÆ'V¼ÝÜè7…‘»_ŽÍ…¾69‹NŸ÷¬”„æ¹ï4�%À¶ȬõapÌ›ðÍB›Jp% -!„³8¨š=åE�ᬢHë3Š®n)X±à¼—R=…¨‹�:‘飿²~•××¥mçÆ¡õœºåžVÚN‚èžb]Û¹qè:�ZG^[YO1·AÌ 1·„Þ‚ÏY(°Úh|RqK¡Á‹ž¾ÇË»Ô&²§^·ø‚Ó­"íR‡ Öp‡ˆfÒžegÍÛºÄî�̦#ýÒÆ8w·tƒ°ºf �«�jÕÖ:�ÿCzy%uf¯åÉeÉ eª¡]cVÛ¹QfœíÌêÒ‹Á³ÑdYY†Óå-¯ùM,;±ìä¸Ïç©”!�zÚä7¥äœÀÆÉoÖV’ß()R±–ü6:;¥šçpœZ³Çxd <ÓlÏ;¸çGø,›.á�«LÁ‘mâê€K\NùkuÕ±šáÖŽ÷;31.™Cî¥bAj‘¦àœe<ë9)H+næä3ÀVm%ý¬@Z»¶�ÝÛ©ª:K�žª‰{Ô‘î�¯t¼·žEH <ó 4<3Šbé,ß̽³i©É°«$ÿdÇÆ¶a,ŠB]‘Ø5¯AÇîBi€„6�ü¿——ïÿí¶”ŠQûðáWu§�puéiYÅwÚGƒEi<™Ð„¿„oM÷XM# ‚ý&š%8ÝePFíXÛ‡Çúþƒ&úÝpëͧÁ»èWÃM1=RD¿/±xN8Qtæíþ9±Ú=—žŒc„€Åã�›»¥æuÈçÇf³9Ÿ¶¸é¢ã‚¢×Yß‹xή=¹ïØ¢[õï¦�ç9?zê¦Á†ÓûH*:ÆZw4¥Ò�äˆdçc¯÷ÐIHºA I¨´žÛ¶u¤N£=ÄJ!|Ÿjð„\µÊ¡!}ÄLå„mA¨û#Ú4:l®NÔKÄÎØæë"­ÇÍØˆÞýSv+o­�ËŽFäGçÓú¢cãâ´Ñy¤B¢K—‹øÏ_Uö¬yh¤+Që9ì IÝÎSÅŒ›¤€»ËÕûIå ¨Â§­uêÁüão*ï¡k’pŒêñ‚({3CMæ¬#xæõ¤¤‚?Êéúr^ÙU3µ*)éh côÄ~)eï\*/ck’·†ÏMû _OÉû²T;:Ò uÕ_TóW·Ðº +ÉE^‘¼ç\�íÆ‚¤´�ë0ký—‰©žÐ4?[jÐì7ÚIÒš”»úÄ[f·/œç¤fW‰kÇæ¥”¼�÷Ÿƒºé+0Õ^VŽ¶à•‰¡ñU8ï;B+©~k³Y;@>}6Û?Öa°¤möò5¯jâŸ_K/ÍæåË…ðÛŠ ¯û]W$¾jC;Bœ¹·&ñTÑ${iºªJ¢)»Æöñ…º;Í“@’iÇÁ0y—qA&ƒ&þÛû´âv–«´Š¼ac¬pgnìH#2Ó¶•e/Êå)6·[¤Ñ`•%ßxÞ½LT•'8ôÚFQc\vZɃð¾ª0Hí]³CW\RùåÕÒˆ`yÉöÖúR )J~]ÅX™tÄ[_UIåâØÁw®r 9¦Ú\HkPf¥(ä…g†É;p4K[É%ìž+¬.$hϹæYX]HÊ´<{Iû;°z:í‹6ï"œáÕÞ¥êià¦|Ê¥.“Cße­–”¢vÈG�¶Ù!?©æ¤õþ4)ª‡yDÆnn¥Ø¯Ù—+^›…ÓwV-œï %ó©Põ?ëËÂö‘=vL“Ÿ�@Ö-÷ð隌ª'©ÀßÌåRi•T#¹R,�‚@yÛìüYÂÐèfS…^)j,Vg%‡§s�3&+”Ló3—¼I!) ÎøÌUpmŽÉ‚õ 8ò|ÛË€ëư.Tʼn*e ˈ3¶„Lj\]j�‘-–~r<ùg[án•Shí”/=™z#ïí`Y›mœûQsÿjIwÏ�ázµäj­Î4Z=K§€¼èc¤ x÷Ջį¶�ÛËÕå³Úê%÷uŒ(œogë”H §Y€ðRÀ·«JdÈ„©XpMˆ'‰<5—ì:Ó]Ü\C¢‰ü˜x«¿\Ê4 › -–Ís°´�·Ç55Ê“¹KM‰¥µ“|d’|–b)yL€B"lÊÒŽÈ´Æ3%¬`$h©´4Ï»‚û€;3Y+X1+ç½2wƒ¦§©?‚ñ|àP®=7×”'J,l:V�Ñr‰Äà kÔU -¤%@išÄQÄM0Q$MÙ[F ™G%×E¾Ñq'#oÅON8ûÊ:%ƒ¿Xïݳ–uJCs—uJ¬ÕuJmÁZL'äqu�ø‚Áàדì3¿LŒf7ƒÃäMðÉ %püÒi¹¶T+åž’¼V­¼,yúQê3–GœղçÇËtÕÆM•ë)(k�ùŒ=IaЗu×wM˜Ú(p]¢ñ^a^3ìý²a¯JA7 F®•m>ËÊο…Èà u Êð‚�í�òq 5Ç+G)U°¬x—cˆÍ^†ñIéªÙÔÈù§²]öMÜ}kæaÜîËÝÛÁ‹Ñx�“\¨¶µºÀxp¤ºBÏwÓàø‚(Æ‚Bí…§£i=º$Êjð’K蟞§ Zåµ1öùIU„UŸ–R¯AimýkŠçº0žºbØwñ°¹¬«ezZ[�Úýkëž¼=`}Ý“ÜýkìÔNŽ” �4¢]ºmצW`Œõž¡ \2ü!|'Üâòó0ˆ«ÏÃÍP)>=2Ô‘‡ŸlW{.ÕÜ›ƒ!’€m£�Ý—Õ&Dp—|¡ÅͶxÕ6¯q8y34¨€œ›, i@Ym;@Ù®=9¡�¤  ßšîñÚ˜Fñâ˜î†¹<=6Ìôéw[.S;~ §30�c�ß©^LI+äy«f1!í{¼MìihÉ¢^¤ð/*äί,’$wέ=Â:<©Ø¾=×ÍžuS8Çz î‡¼n - ïµäüõ‡/šBosÃüðü¶íÙVÛŽ mƧíXhæP;X®:JÊõR¼JJœxqûs÷íÍBq•.Ã’Ÿ:ævSêöf¯ÁP†³v?C•­9¦ì1JFWvæö|Ã�ó¹hv-SÙ˜»hìÒ¾üøã*Ûrk¦}Üäuì;Pt‡åò#uŒš�¾cjc‘WR$ M¸ƒæ gŸòK?“sfC½¾–7™<%-#É1=×Y�q®ìÇk…x…¶Ü�¡Ž†§fyá•äß}†¥ÓÜ’�ú¬¦sͯ^ó…Þç“Ei™»n{•Àu'¸Ù—kqJ}£ÔU%Ó¢±Ô¿Ø—hqŠ|£Èi9Í¢±Ä]ÙÜ+k»†œöÞ{{Ås’‚-§ûüRýÑúò† -ž”§PE¸o µœtxÆo]Yµ€‰qÜâ˜!Ú¬­ÿTY[vymF{ê…Ýdq•@æ3×c€Í+ád0P«aË)é”ÎS¼r×R1Œ0¾?žŸKeýRq•¥¢=¯¹³x+sSÚ}ææ)ö�b÷s³½Ø·%ÖM&ç)ömb·bÙäl/uU)¶´ˆö@Äú¨ÍΘ×Rçøyz£:tãõïà -Ç9_´åΔ¦;?œ ä†Rs¾�çˆÚiEÚ·žBß(ôšï¥­Ð±o<%¾Qâ×K[�¿ªl�Ï‹ܸØY{”ìyPW´ìxÑ~a{+Á’äxa³¼Õú†9GÍ ßsçÏÎ4r )×§e�KmýR«ùbH€±Jê†Ix;ã§Ü·ÊÝÖ6ÕÆr_n„#­[Ö²$A f Ÿ6ZöÃ,¼üv¥ŠË·ÞîSfÊ�·JR÷žç¤¾aRûŠ2SÈH—6ß8R™½Ý§ÊN©o”ºUÖ\ê{ØO‡„Sî[å.—O ­Åþ›]uð§È·Š—Ëà[‹ü/w›Ÿ"ß*rµ\kÞ\¹¿ÞUi~Ê|«Ìi¹Ð¼µÌÿjùlRhvÎ&»ÉºŠ8yäh¨>Þtéïå=ö)î©íÚÅO�žY®£°ý_l\Gîuua”ÔQ„»SExìTG~·å4.ô™A¢çm»yr‡uÖ­†?ë - g”«�°¢×ëéΉwðóI.×±�·É¥é$«Z¸g…* d’i¬|z:%‚Ö›g'Ô8ÞïŽg("X/X_‰éz�®s‰0?›C~N¤îž£w¤uÿ<½±ûçê2­GÍW©à ´²gÅÙ­&E!PãÉ‹uš´Qü±B›êr»þÁž´:¥¾Uê¿6`ÏÔÆbÿÉò�ÈÏ=¯èÔ :�eÛõ�.„˜£T®+=5^oÉ€N¿#mTvP,YH P]LE[×ÂË -Ÿ­)œhgšËrÏö©«ÌFÓzÜ -¬L—S'¬Ö +;�qàüöB ë1¹s#8e¾I檶´º«lTQOÆ3B³F,TwÖÑ*š®„ùIün±Û".OËs¡ªJ_W¸ª=xëš#�ŽœÃù†–5™ß¹h×5‚;Â� -ÁT6ÍÍ븙l…pÙ¹œ"ß&r[ÛËüŸ?lºB0�åúF¡ŽýŠ@ëu{¡³‰¿¼ùûÚ6%ArGÏÆG“a_}=?.ž¶ÖîúYÖŸ,fÿ À‰að6¶K„ܹ?’a¬l·p~Ì€f(De›$ Zë†�-éY)%¬p°GîùÜ)óˆ²G@š¡(1QƒòŠRêž&›•+Œ3çŠÙ¹b -'M¥A -ã샗Lá°I‚�OÐ?Á’)Úˆ{Üy|0ÛLe›& ^¸æ½™—÷Ù·qôßÝŠë²ÊÑšž×ƒ«¸rGa+$‚}›•ÓкU‡HYÑ! ™ß4Œ³ µŒkG“ˆ²‡ØYRÕŽ&­ù¶ ):œœKfÏ’¡ÚÙä¡kF×Î&_3¦r6iÍ6�Âjv¶`m'p¡=z<$ØfÅ -äƒ ±hþ‘�9BfúTm·Ì<ãy=º¾AÑñÜûåË+‰)6h ZéC✠9:u3/ -/æ½Õº?ÊÞöûzŸíb<·Üpª�—Ã=Y£k…a:”„[¬…à VÂáfP˜á‰A›†l©�ý²Ñb¸5 ±Ûæ¯×5àˆñžáÂWV ,t¥À(rÉíTóO—5 ¬@eÁ8e±%G÷Ù3¼yxŽ;�ËhÓ2‚‰M Ånë']G»Û -=Ã:*˜†VyoÍÖQ†f“’VIçaÊ´ôíÊ«Rüíñä “4¸Yß©G„“Ñ÷‚¦b ÎiwnÓNÛ°s/i%öe:¨Á¢4ÞóßMøKøÖt�uÌ4Š•ÌtwÒ2᱓š ¿ÛRÏT²„Œµà5»qâèWËÒè¶qÈ‚ª;Ì�s�*báìE -1®}ûÉ ‡é ²D”ÖÚQÇ2n|ÃÖƒ÷òÊ€÷Þ?ä>¾�#2³†Eó€×Ümý¡ -æ·Ú¿»ßA^c}%¨`Ø V…Cæ@~Û¶É(!À8î�b,�ñiÈF‡r9DK¬E.¢Sœà°•Ò\7× ^u£wÞ`6Ò »ÛßMGý·Ç‘#5Z’ÑUü¹þúMLÀ»‹!¤³ŠíàîÝÇ“{ýçßôêP€³QÿÈÛkû” PBÞÊHþöÈÁnï'8pÇÎJF2AN8mÌ©�oÒ�œìk(‡«ûQXýà •Qæé|@ðÞXoôbn?ž^êÚt›Ž&bÞ]ñ8ãÆÑ8QŒ¼aÄS¦Ÿo[¸—=;�z'[-hKÙÁj #~M-�½�Ž/ÔEƒÓÝ,×o†/õ£nñ(çØëïô?Õû¯¼¹M#qÃÙêpî"�P÷o©Ç7è¯ßByôî¢Áúî;ý ®{ÉáAýp¤¬m_½Èá°Î=r².ò¥æàWwWjX¿ìhDY+„eAÇ—ý:Kª¿à%aŒ÷èÙˆR@¾wŸäÕ@ݬæ.Q·èµG.¡Ï PÎô_é/ßăwñÃû["zŒž¿i†óùD‘íx&“¼:Ë8ãž)çŒ4N%—Ã'z¦©îªS+d•SL2àpü•ñíÍ0Bð�nìGŠÁ¨»¯ORÀÙØýOô×o†gô£wñOô·Dô 1üÄ‘Ìûö»%íðÝ·ä?]þýB—?ýðip(ÈôÝ©ö]É -S¤CÁ&¶ê´lK3l¹Ru­¼¥ä³Ä ïÓÎÚ®©eóp+#Okeíô<­•ç·V¤b=¬�ÓZYÇ3"¯ ÆJýxvÚ*K¬;M•eSeÑTÒƒ´¾S±mL•¸üÍ¡ƒ`8�éÌ…¾É�¬*pF³M {}ƒÀ,GÝ”ªø-µ-íöN£+3solÇ™Dᦠ-E¤ ÕqÊJž›GïæO{¿r±â -VT�Ë#Òš$[ËåQvê­ÓŽÝª†u¥¼…ŸßÄd‹BL)ËåJ!&4†¸¤�µ™ã;+ ¤Òw^ ¸fYå*Å�ÆwÑHJ°�¾¯v@­¥fôižÍÊêL(•FO�š•aG\eGºú‹EmPv£§­¼äð¾Kèé¨AVƒ]y8¯4¤É ®N&‰¸øZ°_0tìÐSôeœ )Ô˜n¶R…Ù9C¤mÆFÑ›�ù¬âK=0ß4B $D/’p½ïRk äy‡8šRN¢îx.wÐI¾;—<žPÏ;ý°/Fƒ-ÀŒVt‰1û'€÷œÜnú¨08Jü�Òýò/zŒô™ˆ¿LçqÂêWz Ó«»35nµ9YKYé\5}WŧIŒS¶–`Qü�¼8åjù¥Íø<ÇÊ -‰Ô9w8r'eÕsâÖ6×QÚkë¥ý#=+’¨å½¶ž�¸ ÄVk°Rh{J}«Ô 9îÚ‚˜ÚTê¿Ü$r£��ÑÚO‘oyÁ)d t©…mþ«M·¤²Ä[â)ðM/¸Û¸3�²íûÇe#ƒJ¥&ΔðͰ4ü}+€ÔïSó³ÜjtURg†{º9ÏÒXódTY&¯b“®1™[ tÁ®&LNPX#Æe ¥F×)êCöúËèÙoËh° -¬½½WSK‘P㵩ðZ{Åx€ ‘×Gó€ *t$ˆônzù\¤¸yÆ‚fH­ü”®ù¹H (µtÍøx@”J{dt³vÚ?ꚪ”¯jG µÑÏÑ• µ¨-tGà…o Aus/®µ®ÛA4×ÊÖ0UÖ˜j5•†'¬f¨©Ðl³N«3ÆÒ*n̺ÖÞbÎï·lÚF¾fãÑXc]×íÔR»ˆ)–Û|¢šÁÍðžpà2[ŠJøUi›wسéO²®q[Õ¸­Y£šûF¯¯÷Ùë7·]åž„Pc¢ÅîFÈ'%ûÝ�„®Ë´" - ßšîñî6�âÝmº¶¢é±a£š~·á²»‘×e¶ÙÝ~’¬ªÕ1TmÕ¦záô (ï²â?×%èê¼Ô­™z«É`kJƒ jw6øñÚ ®ÆUn”;Ö 7©ßWµ¼�ã“Ù _.œúCÊÌ‹ Y9 Ñº=·"ÀW}�«è9½]Ú6\ý|!Ù#³®¥-ûfpôïW™eÓ -YtÒŒŸS›¦z®@Ñ%}73ãŠN“º±ôókVþ °ªbö Ì®ü^¦zšà„Ý.Å0kÊöz™Á¿Êز³c�ž´ú´²3¯a­qf*i²Z0¦ã)>SbƒQ•Ć„ä‡Xf†*™ 9Ú3ôõ¾‚sm[Dº’?ð¤«ÈTp³ž`Ù -nVóUô¶BXÕìè·ÃÓÔ7W7�#rOÙhÀ妱,�p²Fyé#jç¥5�S3 Éw•�%Å×4 ð>£ƒÓ>UÿBm´¥/ÐÈ>%57Ø’®û»™PÀ½,Œ°p7F;)Íð» µ¦­4A"§Àu�”æ_&gÓÚŒ¶¥–Hœ•Ê¥t>DSÚ‚§<2ÄsC6–Ú籠Õ|Å䈫²[¡(Ïû¨MQáìt�¸Ã¿,W2ŒÂIQÎ�Ùù™/%Ü©h‚äT SÕlR541h�@rO jtMÕÄt>FÕ˜šªiÇÆrvtJZÍÇ̤yM­Ú>޾ÌÁ÷»äºÙXg¹ÂW�FWkº¯6÷j†- ÆQß¼®a×ìÔ�™ºÙQææê,m¸QHÚ‘ô™j"IÓœÀÖE‘Ö/EY0ʤ?¬*²˜,0jH±?™·\Siéä¶b<»fXœ[m[æ/YMžÑ}úü%§½æ�´ý0M_î éKÃÈzá´ï³—†›“Ô„~z¨?6ýh¸Õï­á1ñÞ:ÜÓy�ß[šD®`Å[ ¢cjiÝ¢6Øt@·¾áî¬wTJjÉ1n�/¬¦~œÚå”�4vœØyõ¸˜WÌKUJ¾Ý©*IÙ�Û* ÁJòºwòM£kGbAè¡–üé‰쥖Â~ -Ä*§…z0>;±Æ€uŸ©ä@†ûhEž„jbµç�0G).’v"¶´ õ½uZ�Q[w¡õ ­uZ�PZ÷¡ô�uR�QY-i G> ¬‘í�½"Ç»ãläÒ³—žM\z¶èÒ³s—ž�»ôô\z®’¸@ -Ár¶iZé/ÆàkíÈQj êG�^LæC:0ºR²�½v\ì誀0¸‚#TëqCR -PÚ^5qF…<ÎR£¿åØiÚ®hr÷ítý+ ÒP»Þ¬ÊÄ6š²à¤×ص;pá/SVF¸×¥e„Q’—î†5==6¬øéw[ª‰ -n ¡£U‹žè·ª [S1™�Q®¦&Úq1€¥UH+Áµˆ!Ýêñœó%d V!cPµçÜfh‘QÕJ†\ÔYkHu®deEßóy9p“)5 –V°/Ãt 7ìµ+±ß‘ û;‹l�ÂÝÿ·±~¤sÉ}Qö1ެБqú¸§B¿U¡ûšÝ×Á"ãvËà0…î«v_LæcÔRÕîkÇÅ -ÝëšB<çLM¡·æÜ‡�ê¼WÂf[4”ÙgÅó·is[Óæ%þ¨ÍçÁÃÍHª£.—ì À†�†ÜÊÜU”¹Ð€J -÷xeîkÊ<&ó*I QSæí¸x]™+!kÊüñœÃš2¿7çnWçÁ¦yð÷µÎ•P5}^bá¡ú|È¥z{dsgxèð8uúm:]‰J®¥ò„ôWéJèŠJ�©|Œ^2�ÞŽ‡kº­(ôÇóÍUôys¾!íTç‚û"HùHmî+Ú¼ÄÀc�ó¥ÆÑ;Kƒ•'PÒ7DÏüQ+tY©ÓQÎtÍ�ÍÃ5º”5�“ùÕ$±¦ÒÛqq…N—ª¦ÓÏ9ª)õæœ;]è¬|pT>·ªu%�“SG½F7ªu©kj½ÄÂõú«L™§¡cÒNï4Hát»RÌ·Š¯DI•µ ½}x�TÉZ�4¦ò1jª#mÇÃ5ú½"}8ß°!mη�7&í1ÃZ»³vÇZ€´ÄÁC�ö{âu¬ÍUZˆ¿×|·Ìm‹íÀ…̉r -+SewôíÛV=T¹c-`š�ù-U ˜6äb@ÕÚ©¦,·Â¶}}Ûc" -«Fh‰…‡ê©Ød´;?îÔIÆwó>­Í-©fmjîÉL=ÐÁc5RÕÜŒÉ|ŒFªÚ›í¸x ÷CaÕÜ|8ßTÕÞlÍ7>èîÓ䯀v&mU~gM^h¥iò �µ8Óö2Bíõh dÉžÚ|“6¯5ZWäÁ•CU楶ë“2�¨|ŒNªZ—ÍxxU•—ºfOªüá\«¥â5æÚowjqmA�*çæXŸ#­Ä¾YÀ4ºU‹×2ñJìk¬Ä;¶ðcPùqjž -ýV…^IÊS$ÀjÄÇ{ƒK}z#�‘ùåTj)©ôf\  ùÒjIyOÀ¹ZR^{ÎeÝxSÒTM§“)È4ke±±UâyëÒ*¾Ø©Z•¡Ï\ŠMºµÔø3èV%A�µëÕ­¥Î™“n�É|Œ†¨¦Çµãbß0­BW59îñl«fÇÝ•m·ÌÜÐF÷ZçA¹q¥&�“½\bß�ó·qâÔwiwÚ¯jz ŸÚüVm^j†´9"7�}8…*5—œ”yDåC”R©ã¤Ë›ñðš*/5:œTùÙVM‰kË´¬­ùíšœ[t�Hé[�1á"lž0¸Q‘—:ûMмÀ½c+VFØÒ±xèÔs7Μ8NÍ 0ã„=(nÕòµp%³XºÇG+KM'-Qù…U V6ãáú_W¥†“®’ -ȶkh0[CCÒ1Ý#=Á@C2øçÛ‚w`¸Ùæ'òˆý@^±ŸÈëHì'òˆ}~�×@ê'òhý@^Ùµª4Zý €¼F´>=ÈkDëÓƒ¼N´>?ÈkD듃¼F”>;ÈkDêÓƒ¼*!&CëyÝ|ô*t…VA(˼}”WU踬¤…®ÃÐ{0Ê«*ôøíÜÖø¦\ §œ -is?›"5nJÍ�^Wž¿2`×´«&Wˆn9ŒM:âxÝ£"¨¦"žáUZG*âÑ8¥ªÐ8RÍqJ³¬è”´¹gK¡I‚ž�qsÏ–RìvõJÝŸq«M©IÅîx=¨~±Ð2Xqš�mðe"f¨#Á1b®;Õü ûºCÍšGjþYp_U¡Yp¤æ�^ª -Í‚#5ß÷µ¦æ í‚'5ÿxÆQMÍ?%ìk¤äwÀ¾q-ôµ�4üÝA_UÚ†/-aO›>ïÕù'<ì.¥ojJÿYðaU¡ùp¤ôŽrZèì)ýæ(§U¥ï+JÿáŒ+´6�”~sÆe9ü·«ý'€‡-´\�4cxØ¿‰óÞ§äÉ�ÕE“R?ña÷(õBã®I©? @l¡qפÓtZèÛ5©ôæ@§hRJ™^Öè�g›©(ôÖlÛkÄï@‡=ÈQSèR5)óöè°³Ö ‰“~°Þ÷©ö)vŸjw5Õþ4P±…ža‘n8ài¡gX¤ÜÛžV´{¡פÝÏ8¬©÷öŒ£}~Rì~šBתHÁ7ƉýEä~™lu[uÊïC��Ôþ‰»Gíº‰EjÿYàc �Å"­ÿhÔB_±Hé7‡�­½:vM:ÿál«…_›³m,c¤ñ÷ Çä¡)4·Št~kôØ•q^ µS£7ÇŒý1kt*´‹4ú³€ÆR¡½X¤Ò K…öb‘No[QêThÛ5)õÇ3®mmϸm-"µ¾mW�¤øÐé•0ºM­S¡ÁU¤Ö£íf-¦2Ö4¶:~j§ª?¡xw(úZ„õi°x©Ðv,Rô�Æ”¥Bß±HÑ7Ç”­*úJ„õñŒ+´–Š}{0^µSÑïã=Æ)O…¾W‘¢o Æû—Y"�-{opg͉лKÉz�EJþI z©Ð†,Òñ›¥B²HÅ7†è­jøBs¯IÃ?œmÕˆks¶‰�ú}LïQú½tm Ó›uÍh§áOÄÞ= -¾w}È^*4"‹5üƒ�g©Ð‰,Vñž¥B‹¯HÇ?œqÕ¸k{Æíõ“i¹Ç�±S¡ýU¬å ,lS•fÆ”bïÒî…Þc‘vÐ`*ô÷Š´û£Ño©Ðt*Òî�Ño¯h÷Z„õñŒ«†X›3NÉ�Ú}rðI5T臩öƸÁ?+{âƒG~4ëéØZ×ö¸Â?fØ*ô(‹4þ“ S¡ X¤ðŒ‘K…¶T‘¾o‹‘û·;UÖˆÜcÒB¨Ð0+ÒZ­Ar•N*5ßî„Á• ®P`­£Mé6Ò"x©”zç�#)ÁRÇÔáj_ÀérN æù§,“¥¨[1|)*�ž" -5˺æÝpeGÂú‹EIÀ¤»ic%Pƒ°‚’“GGj¦‡Å!€4y!½I%-.¾–Ño_Œ*g÷¿/žG¦R®Ñ-eâ¤ÑðW[€TÒ$ÌïãßYø&—àUôŸ^žjè$8ïeºDnÐ|´]´+E¥mÈ^Ðy )nÏŒ1¢·œX�Ya˜ %ÆûÓil¼ÕÆÆAroNóøÄi_°å¶\‚F¾çhAàGnË¡L=_ YÉKJq¹#‰`´å„âv[ôO+[t©! �0VaK†Ž›Ì2.•º‹iÞä„Í8×—læ]×±;fTŠý_Y© ™EÞ¬9‚Á†­€E-µ\GB¥dÖ9«[s÷넵£e¡“»çû2qˆ©lÚX€‚õ�êÔ±’‚ØÞ† -m×JÐ=}¥ÝìèSêë |/Ë K©-™§¼ñíW§ÈŒ¤[nÈ–µ^›·fËö‹ö¡ø¿<µR.Pe‹·huŠìu Ö®‘¬Lsܽ>f Ál!êCV3Áy¼ õ`¸ÂC¹¥¶j–@ù²¸Žm<Ÿ¥Æ2«Y‹ÀÚl+å -(Ôw˜n‹ bµkŠá�-™}3�xa‰ÁÀÁatëL(x|…;Øz*”›ïþt4‹R#$ø -«s£à$&hX¶ÙÜ_'MóH ó•Cš@Âú'=£>Ò¨”k:LNDÛy.¢›žØë&@iöUtƒWÝèÝE�7˜�4Èn²öwÓQÿíq$ÀH�–dt®¿~ðî"Aé¬âs^÷Œîãɽþóoúu(@ƒÙ¨ä¯ -*�ÖÜÊȉà†w9—rÁ{cq¼Ñ³ubQ?_ò:ÓÇǦ£‰˜w×5Êm�ìF0RðÑ6f|/µ-¾ª0=8JϦZЖ²²›1Œø%µtöb@:¾P \3G@–™ÚÕÏ _êGÝTÎq ¾¿Óÿ@xT?ì¿òæ6 ŒÄ d­àÜE¡&ÙɘãÊ1|ý&Ê#vÎYß}§¿aÀu/9<¨Ž”õ£í+@éa¹HV¼š}·£8ž Õv: vtñX+„¨“Ëþìç.x9ã=û„ÅEQüùnÜ}’Wu3r˜·DÅkÆ£wÑ3ˆËSú¯ô—oâÁ»øáý-=F Ïß2»»–¼eŽ¿®�Ýl@7pL9g¤q*¹>ѳLuW�B!«œâŸG@e⯌7øko†ûœùõû‘åu÷õéA -¬£á'úë7Ã3úÑ»ø'ú["z�~â@Ö}ûÝë¾ûö�ü§Ë¿_èò‡À > ‘¾[#ôϾ+Ù&¥ö¡ÈýB:.Îm“‡Øä4� é”|!ÝõX©+R†ì ‘Z˜éäÙ¤™û>;(ž³Šƒ>(Ÿ2³«²Z~óû?¿ÿþ«yÿRŒÐÖ9%áܹÒèýöHEÍ ¬qù•¦íœ<«$6z§ÙA?®Fy¡ «r@R{Y¦øÈSŦ⠈¡Öª%ðæ`£!Ðèíl #”€ž´ê´Î4Øf d2*yÖ}qU¨;ƒíÝŽÝ…ê̤ábéð[ê^‹žß…#ŽÊ€2Òm�‡×¿—ñ0k„UæR»‰E]Õ-Îÿœ~¯??ÿ*~ÈIV²*Ǹ§ÏˆÚÒ(dÛiŠsDÊL<Ѓð_g{Gÿÿ÷5‚Me¢g3ŒéýI,‘/Š�æ9tŽDDÙ H¾ŸÕITÕ±­x$¤§5>«K‚UŽ1�Ä+¡R+Ù„-²¯é¼¯ ºàz" $-HúÀÝ«}+tÕBR  G…÷ÒU‰ -†ìž²†¬°²Ð` u7WÔ‚Ô›|ÒÆOo³xUÕ4…]Þkô´Amžb ú‰¡çàoÑ­×àÚä°”âRm)Iƒæ^óç/Šç¥ñÜ"ëñ®ômJð(]^ª3wXÀºG’eU³ --°¦�EpCu¢Éy··>ÚÕ2ƶà‡Ú LB ôœX¼÷ Ö'…ÔH,%ü0¢Ë¬hÎäÏsN×H-läÚ�è²á›s3âç®ýýÏT;Æš'<*Ù–<(ö%±JoÀm«V»G«ô4'°uk¡‡XHb•Î�T¬eZ$±ŽáR¡_l¶A…D­èO¦œØ:œFÕ‚}mvE:j¡CÖ4i,‚EÁ1…fêu¨!)œcƒ�4üM�'ßšÉWè¤ÅÖ³1Vàþ÷¹É=ú!]ÁÃËdwgë]Vœªã©³ýº®ßW›ˆž“ɘ9N€gpÆ�·õnæ¹eoeä `û·éBN(BÓ¡‚‘LÃ'[e‡ñæ�ëBb¼ºågÄ{岆•LªuΘ÷Sż¹„¦‹ wkÀoûgÔ{‘gFxAÏÈ-×òì |W¸w†¾CߥF¤Â€RþîÖ]-ø=kœÇ¨—"Ù/RÌòV£ç‡ß¬ÀŸã z�w°ç»÷ªÚç'”%@öÎŒª7jôVªõ¤á”nÍ«© ½¯WN¤ì9"joVpK) ÞŠ#^íZ•O¥¾«Ð“�pÖ ÖC­x~•ªrÕ™ÖÎP{vý]…°R¼ˆ³Ö½rͧè09Ýt´ý²Þ§a“Wp¼¸¯æjp•c»Ðp½%ôŒàÀ‚ɼJ†7ZyËë¿[)±)Ͼ™èÅ/Ý;{~žùÆû3çÏhÆ5’-¦¤ä„û*º,„ÜéË$b|E÷¼¾LÂ9�­}™…™“/Si¶ò] _æe¡æžÖ¸,5ñºúÙº³Ðrsš)ˆ@^¡Ÿ33B¢/Œdg¡)hÈŒXà_³ú²A{ʪ.Ó•üˆ2ÁwJ�(ô û »îK÷žYÓ³7m%E¢7*ÏCƒ<ë•yŽ•T0 6_Jy²ìj¯M€‚ùè¬`Zºœ - -‘› vÚ–Ó,;=Dájê©ÔëR H!ØÕÓ~A è¯$~µ¢ÖÅÚé¤þú뢽º&¾ÔL“(!ñ.Jð§Qâfxó/Lµ4µÔÔÒ�Ѓ—E¥z_Jg‘­ÌVó+ŸMirÛÂádo=>iж³ç Sæ‘åø…†�œ+ã;úŠüo×")s -ô5MÉ/)Öp2¿1w˜?ùxÑSšû T¢‚2f%MP ¬hƒhöMºƒL‹b7Í.wuûY1sHT_aX”zlrÚ›Ô~‰ä'²,q5ŠeRw‰ÿœïb·M˦�_RúúŽI×¥ž�V�°zI]¶ƒx¸ÙÑ$4H…Êé§õ4 U °±«IhW“7@HÊ5ð4}ž)ÿq…gÉq27Q*Þ#]h¶Äï¸nSë–5 ÁK–mšÕ°MâäMý»ð¿ùç–­ð¿¿K–4TüU�G›³áõ»yTWã å)u{ØKÐVëöŒeP±mKY”tJÎ4’ÔXkã§·jY'Ay¥µ~œQ¯ -Q"h¦Ï*ð®Y��½ðRêKSmئ/�Ÿ“ª.ô·ìÊ›¥4z/Yktë­K«ÞéÁk2ØŠ‹U5·Ú J !>ÅJ*ôæD£A+*2ñ)ÚŽ¥/P0n¼-ÉÚ¶Ó`žê1˜Ýþy+¾ÕbŽˆñq‹·&eSÁÑg8ÇÎî›�¹×h«„M§€È· mC -ÀÌg?ŽSÔæ4çlgü\wÞ*ÚÖ(à§M[j -­:á¦o3˜NšÃJ�Æe—Ÿ[Æî*jgé[bcŸ²£6½l^) Â#b+‡ ¥áCRL4š²G–.4#�¬«"õ-:Ûüæ–±4Éð0BiÎÃ={©Ý ᯠÝT9ÇÎX"½ -ÕZGz2Þ"§r`Jæ#zëèB#O4,e¨%GëP-“VhâÉËÖZaŸ€s…FžŒGìÐÜ�oµ#^¡‡': Þù$º -‘M}».ôÉD�`•tG0ðÊQCšÜèÁ´×7¤ð�[�„—Y>Õ -¨ ]êÉéøÚ²Úm¾É•ª®ˆ´ÖFGç}3zw ®Lê¯lþ) -Ɖa ÙªýlX“#3¾k‰Íâºcpîš�Éo׃ÊëRïKáÁ9ãxïuŠgg|Y /­º(ç¸:oƒ}®ùB¨ûøâ4ºÑ>/5딜—Ëìlâ· À2S|û øR+MNåaŸÖšbÕöTjÜÈxš;Z9†ŸÍto¨<˜9˜P¿¼’cs’ÐìsÉs¡ï� Dd¸äF¹‹õ†;[šÇ%eèB'K" ^»±ÝiÑÔfÚÜ^#Fù–(ï0Óâ~['€Õ@Îû]òW$)ϯÂçÌ0ºUþs«’¬ב×XþY"Xè¶‘%fŒŸªM‰¹å§¥£¸õAó91ó‡.Ô‡_¶µT…Ì—Ò²’Ötca™.´jœô²õ�‡Zž¥®lxáÄiÐ7öhžÞ[2xÀ6$Á†ÎcåÝ@ ñs[;� =IXÐh˜ ä~?ºU7Ôdªëd~„L™�2×–±ùV,´¤d‰cGy°Ê`»ÆÂ+O9³èé+Ì�lBÇÍ!½)¿CËÐâR÷º‚Ý/÷‡­Ùî°ÒóÛ1½ŽI°Ô…Æ�d¹Í¢·ú)æWe^Úu’× ”á ¼Õ¼Zá,´ë$o�Ü!„5©‡Ó…~–Z2,…wÍé¾õ¤¥/ü>mM¼ë Ǩi ÏF7.§BŸM-fÞÓ=–SÖ<*Ü*ø>®Ne.ôÍÔ†£˜ͽÚÍ[8±5’vd¿÷¤Ðµ-œ•­ê[‹?t /õ»¬kŒ‚éÇáa䊷â{ÝKýÎM&"c%ªý„­l7áhößb^�™É(°H¾/ÿé–3a¡3$ ÖV½%›œ -å¢Uçí4ûÃX¨§=è)‘“×ú˜Wh½5óP�1LØÝŽy€ƒGU–¤kg�Hü²”Íý¬¸bÝÇ!æ4?†,…/‚‡ïg•5¤eeÒIŽ3n›,òÿ4ÛøçØlťťTÝ{î¯i]ðÇjaÒífÅUmCbÉ_F>ÅѱÜO«N¬¿çÿý¶ûtíe -þPÇݶx�5kˆ”Öά3¿}yeŠØ?/IòëE@¾÷kM•)/ºr¢'ôôÁ‰•ªÒpMºJu&�õèö¿Ý!¢¦šý6G×ÊZ&ŽäDa|�œØå\ðÂ~™7º¿aæ˜å™c<‚dš±vU›|y5p1¼ÏúˆeϾ‘*Þ·+Õï -,D]h®E^äîeñºµ6ØBÞN IúZiN£6x‡Ù‘fí\U»+D]¨a¨½¼¯, §@¨´õÐÃBZ]”{M�\8{L¬°4£A–-eÛ™ïŽO*�™Üs¢–´µÞRFßèп9}–l»—ŒæBß0åýH‚S~G�¦%ÅôÛ$cd¡†vðdÉ\!Ý!†ÖxŸÿ? ·d��J_~ìw·oÊ?ãÿýUØy¢<‹�†Ê:)ôA›$ÀU’“Ÿ›H QhI Ë´¡bPCÓ’÷ÅÔÇeÌÍ B{6I6,Îî`¸ê�?¾qÂÀŠ84‚C>¶\#_§µXÜÝúC¢ã’ݨwêüqëñazzÃÎÁš†Íâ} 0ý†ÚÝ4ä8mÔwóïEœÞ½ÖÝÁI)Z2 -‹I’÷þÎá1^oqyŒ¤²þU¨>Rµó ýÐGáÉI5œÆýGަÔs�Àè!Ÿ·ÓJ–M9鎘¬‚ã,—wãåA �ˆÜ?MÛyÀ½‘»§æœÆë“2Ý­Ô² Ö�Í%2qÔ¦swk;:£XÎma››JöÜáB–ÆEĬR}5Üã€ûóÓQ8 äØŒ«NP×*‹C¬|¨^€ËJyª+ƒBɦØ,ý¶öª²¢/ŒžC_ä9µµÊ �â(•|*HÁÓeM`¸Ð'Y ¯ñ€·»ª~SR?k䊭;‡§–Íe±*¢Ð‡˜ã_¨ì~×XÍc²}ê¤�²&?ŸþW{�Úæ¯ù}2࿇.fE±6u\š3œw}¨žþ -ý�§%¯ ´—íJì:è•pHŒRAôZ€ÐBSb-ØÅë½Ýý†Wçéßwÿ«‘WØü¥ƒ’Ls¤öódP.Xé‰-ðõ¾¤cMœ}è3ÜýrÐ Í•Cºæ6�¤S°ˆ#kfýKqnr}(žU¸»4',CùèÌåŸww¢›¿Ÿ.ÇoÉe¤å¹:²ÓýËB×ÎyÁ÷b¼¬u­N©{u˜J‚ZÄ�ýðÅÿøâýÿøÅßþþ»·#¿ýíÛ?ü¿þ§·¿ûÓÿûßÿ÷ÓŸÿù_ÿMB”Ô ^z�(ÍD›‰h Y&R ï„òú"€Ða�îˆÔD 5z}Ae5SßòVw4¦—üÁ˜ØïÿùO¯¿ýíÛß÷wso÷§×¿ù§×— +±ÂƒV6!–*+5S(­#…Ä75y�Þ0­_üõ.âò‡�oß‹ êËÞÇ¢—?üôß¾ù£â�Bàð¯þU/nü ÿêá_óòßÿð÷_üí +/‚•h´õÅ7‘ª›þ"@1ÿO ÕÿGé›àÅßô"ã[¼Hú&“á_ÛýûCò„OÅÏŒ}íG¨ +OxßýÿcÄÀ—76gæð8�ñB¤ˆj$DŽ/h£ Ï•ÃkË�09^úûr¼O/#‰ÒTpäRÿà�)—‡ŸIÆ”¨^Ή*ò:°®FWÆŽðK‘0¥5eöÇu†ûÃX‰ä™ã'¢�scün~?ÏT)ÿ§ù=òNA*‘¯áìíÔð‹J¥+úV=j=�É´óÄš”USt%»kéz´<*å;e?�ÁÒ¨;ùjƒž·�>9£O³ºd�,@Q§éùR8©´ôoF`ì°uWv¤«¿XÐèrF�2€Î:Të4sb»&¯ê¿t•êH—¥:k\)ãìÒ;ç€u`MÿR?ŠË�ÿróL�Ì~ïˇp��9Õ̓ñzÇŽoIj{4™„`9ÓOŒh´ƒTc-'¥>–TeÀX”¡áúv25)%Q x$Þ£T@$üˆÔýÒ_¢õÀ0Ñ{ÀX¢÷ i0©Xk‡YTl LJÛ騋HCpÂ\~âÇ€N[eã«áïâòî¢À ìˆï¯öSb¸ºÑI ØÞïoºSæ�ÌFÐ0�ýÝtÔ{ 0¨¥%Œ®âÏõ×ïb>\„@goÝ3º�'÷úÏ¿ëÔ @™�úGÞÎG…€R¹NÜ"ý@ðOû�œK¹*Á{cåx£gëÄ¢~<¾äu¦��MG1®3j”Û8Ù-Á @Ù½l`|/µ]³S‚ÒÊÐN®ZЖ²‘«eñ[jtöÂ& +_¨‹§»?X9\¿¾Ô�º¨œCé†;ý„GõÃþ+ïnÁHÜð@>w;wA © ;!ëñ úëw�P±¡f}÷�þ†×½äð ~8RÖ�¶.é�„ê„eÀk2kÝVúÏZ!¬�:¹ì?À +p¸àõ`Œ÷Ò³~T@¾wŸä¥@Ý”&.Q§9µ—ÞEÏ PÎô_é/ßŃñÃû["zŒž¿az+Bè^i0Z­f™gÜÀ3åœAãTr9|¢gšê®:�BV9ÅH�ÊÄ_oð×Þ #>€0ú‘åu÷õéA +¬£á'úëwÃ3úчø'ú["z�~âHæ}÷ý’nøþ»à?]þõB—ßýôyp(Èôéñ}á ¦æö•šLW�"òM +@öó‘â�F’ڹ‰™'J^˜-¾(YpÕ|RÉù-¸Ž†sÜË6ê¼7^—Oû™¯bü¥Ñõ¨Ÿ;ÿe¦Åè™Ç!õ—¥çÏô7(;©„]ö(RM~F‚¤fÒÓ© m$5¹Ž§RO.˜„…ÛÛÁ4Ð ±Î48-׊åz'OÓuíü$�éÊ< ×'5\µ×{N»u�é¥赓û´Z—Yw­±ÑºÖ;Y?‚Ɇ˜‹DpZYÁ„|ˆF¢ìÖŸˆ !=§�À1m«é¬ÞâU å¶0ï¢)if[ Ò¿@ð¡ÆäJã[šÑ`|Ÿ[�©ùþ¼˜¼áÈ!ã'~ÊMó’9?„;?fáZU|î,�¾,![›î¤ÀjëU3å,ËYY>Ùà‚@U9>"å)sŽ<�ÍyçÙ`çÙàFá–!nÁûŒФa;Ä0B|£OöÿAq�­”Ÿ‡šuëJi°„þ<Ö|Ç⼎$Éâ<Ø\³ÎI€ ŒwØÓ#¿™{çéfß醼¶^?î€ã*E ÉØvç›<°Âzö•óM�Þ#mçì¸ð~Ñcþé¶ãИc‚�\Œ”¼ÆG¥ÄûžõåÄÎñ‹¶ä¾_:@M'µ78†`BÞmE^(jó_viムÄŽ�SFèðo–‹ä¶î¬4ʯ¿ÚVºášÎT!6$9¦?Rs“Tà ÞbЫ"O¬ÉKªÕE6›éÅÓxž„|=(¦ÿ(�”Ù:|•Ÿ¿ð­,D9¦<Ԥɬ3¬Ü[аè$¯-cÔyBÞfd£!PJÜÊÈ'8!o¥üÈyw�—2Öp^;„Æ‚'É‹¶µ¹d}§…~¯+¬ájæ�� ¬â�°iòÖ`9*{=Ì’ÐNËn`ãyBS»0æHÏžƒ��5Öë +ë�g‹ÄŠV¾€pöŽ076™î–&If¾g•H¼B§é¾ž‘Þš›yÀk§'�ÐÙÚ: à§2€­©Ç%`´ÃÓü½Î1§ÝÀ1¥Ù±}æ¾íåÝiÿ.Ú¿…<-l’`sãe1»j“Ùâ�D‡tÚ-;íÞWÇõo´[ïrÜJùiq­]Y§Éõì&—— p\§ÉµŽc™Q“ët9neÞis-Ú\óÌkoÁPÏÅûØ\Y:ÅÖ(¯pཤ/¤S�K Ây¢5�W`ëÃk$pžD„J€Ó¨ågf}#I0Nw.ÏGÏ9OõA"Nã]f†l2‰Åð¹V,àûé„YOž¤3¾ZxX{5Yó�[ÒÉfþýk¹-ãk¼Ø´ª? ÃØJ° ËmÒ×ãRUâ–mmC›Ì�,ehL¾«E8d  5ÅW"몔xyƒœ<,„£ˆç kyiU÷”KI[¡HW0Ä“«Ÿ9¿ˆÞu"l˜½!�³"¢jÊ ðµÙœZÎüì§×—å?fyŽII\nžD ý”üe " %ߊ�C¿Jy<ÝåðËå¼Ö«Ó¯"1S“˜fÀelx¾ väW›x¹�0:S=ãúÜËE7dGe ‹Ë¼®*r*2ÙM¯È¬V2iØBÄÖ[Ù@økyêU7WÀT ‹ªð6tî'Õ-SŸbôªeØët¿þTúZØk)ɱ‹P¬xñøÃ�YÉɪqÇß�œ€ò¬Wÿî÷Tú„¼ ÖHËÛ.n«T xGì¹ù®QAïæ¯ö@ª +>Y'Ç‘(%X/úãw¸ÞA¦& h�|:Fj ΘîDµ[ÖØ•¨:3“Ž£cÉÜ/ð%:úDë~©7dét�œÌ·žèõ6ªÏðÛreù�ò?£X+ç'ÿ‚ML�3†õœ•弌8cX7”F3Ë”H¼…gk3÷Î(ÖRK΃JƒT] -h“©Ø«=@â³°*uPêNQ¿~ùÃÿºùä¤kÑ|^FÕFªO£*gd×$‚§þiShSEÓ󴩞ܦR¼ñhú=î4ªÖ( Úâ 42›êÌÅÞȻӢZDÏ/@”øà]+˜T‡æ¤0öz[„kåäp”È¥Ÿ“5¶•ìÓ›qÒƒW’ÓqNsì8s,žŸ§=öäö˜s\ª?,�Ó[Ç1‡4pìtqļÓ[´ÇæI™^�¦Ž‹­Í±Ã Æ÷á[” Dšò¬æÙ6¢O㬀¼Iú§q¶nv + äVvŸÆÙC�(A¸Ó8»%„Æ=ä]¼5žÆÙVæ�ÆÙ¢q&+áGA º*žgŒ?~FÕ6¢O‹j9úx›ð¨°‘ðÓ\·ªNKðs +›ž¦à­¡¿Ó<Šw§!¸hªZÔT0Ô?4©£›uÈêÓ– +ójÅ©8mŸ÷N{Ö}¶æ6¢O[sÙ{w›ôO›måìä—²»{˜Ÿ6Û¼w¼´á“þi³­õ@1ÏdÙ:�¶­Ì;­¶E«�–ÝwÚ Ðò9«>'‹jѧEµè; ªN°Ó úœœ`§Eu³'gnP�µÛXwšS‹æÔÿ‹48�hÔ3ÚSäÀ�ÔŸ—‡jѧ=5sÏJ�š4ª[¥ÿðpèVÊOSpåº:MÁg7µ­hP‚§%¸Še¨Ì¨5NßÚ1Ì;�ÁEcÐT"¢%c°A鈓k'äà F1CÍ OͪÔ¶õÆp¬P)t#eí+Í>@tM`´fý™¸©>mÜ9#;eu³øOKqíôKÜiO“wšS ’àNsê3Ê�;í©[ó¸Nsê Ö�ÖTlM­�!G® HÖ<®91ÍA~ ‚dòÊFßûTÓϱúu™ä†ýÊ[¼NMyCCëñÆkþɼÈ6{rÌc$ˆŽnôì=: ¼�êÓ~ž'$X%nÿi@¯�ž§ýä4j�‚N ú&–”ƒÖHMè3¼•y§½ä’$YÌâP$鎦ÞnÌãëcª¡Æhm@�oôžyvb’³š£Ë¼«zžò˜@Æ|½Í$„ìO +ȈT¶w>Í+ÂQx ž¾¹DŽ<ý�p¶Ÿn¯•É3¯¶BéÁ9![Ož€%THýaÿ2ŠþNM>T�É€Z,7`DÔ>]ßìL» Ú:¥ª�çœmy7qò<謜ŸÊ�52YVç9çI/H�2*’Õy̹–<@ +Äêé}žr*¼;O9‹§[I¼P”Ì&à³ä]œ¶ÉA9 ·™&�/<ßJùiT­[X§Qõ¥_œVÕ­9§QuëN›jѦªVàŒªEç©�Ü_+ +F÷Ù”X�zÎdRr¾Ï+ „6þô>펲K †-%ýùÙxÛi?­¼•«ë4óžÝÌC©Á“Táiæ­b™­ÅÀ²ÔÎ;s¶2ï´ô-½yÙ*nVÓqñùÜg¨Œ”òÖmõ´®æœt IûW[I?m«•kë´­žÞ¶R4Žkà´­V±Ì¢‘§í@Þ�¦Õ’i¥çÅAHL)g]6w¢¥Ž±÷/o xï½ñ:.¬Éò«òç•BR�y+’«œ<µ¢^âËëúëe‰r£ oªKˆÒ¯'Éfe/âøä¬Ÿß0þ!C˜”ÅLÐ+žÉ¯" +?æ™~/ fš/é#ûtÙËõ?-+"åôL�ÍD:y`cî‡ëø×ðPº�í‹ ÑJÆ•-¼Æ-G–nÏvKG&tË©Ek°Bz6ЂaËç3(ÛHõyÔ*ÄNcÙÝ*þó¸²vzJp„igØó¼òTçmAûÏ-— œÇ•+s€Þ CŠ÷´Ó¼‘wçieñ´2¯Ø1¼ì˜ØÚ6ÜSä‚u„÷äç¥>^‚$RöI Go¸ÎœíÚÓÛåì,Âî€pZ`‡Y`Ñì< °g7À¼cçþ°Nl ÇUzv‚x:Å¢¬åðÁs+Ås\¦!Ú¶Š¥âVPÒ€22­h9P±Lêbv¸•Éý¨iØkºxÆ3ã0k¾™ÒZ¾œ.»ü•SY]…F]A9!t™ ­ÕÎøBß–Þö—y§ãtA†ñüxÔU…•ã´B Î2˜kFß5ò2dG—ñuï¥q6™Š¦ +ÐXÛ +Žk(Ëñ€)¾·¥á†ÇUò¢��À»`èE ií ÇÑm}ñlùdÃô•¹×ÎiSrÿ[€wÚ8[¤³ES¼»ècbaá䈿9ï„7ë•7†ŽÃÉbmSoŠ.§Þ�[¢·  y1Š8Ø A¨Šð|e Hvþ™V¹—¯ ¡×Ó½ÐÍ=StÓ(�’ÂðRàµvöq+ÝÍO-Æ‚ëÈ+ +áAKÝÍ�®Kªw¾Ýd™¢i±BOÈš[ýNƒ1‡�Å¢’~‘²7ËdÍMFç�,Õ|ie…aIZAP^ᤚE¾•`D5B%fE}jö”=†9óøuÂZ6¤Sœu¦Ô“ZÒ#(% =®K®ÓËÖ@™}ÇéHMÊ0·*²+tˆÕ`É#ê2½ítÅzÔ!ç=¢z +qÏ�?íA2}Ô\ÞoSÕ¼çV õœêëžVÞÁ éžcuÏí0§@õä5–öQq)èSì ˆ¥\eª�–O*p¼èè{¼ÄýÜ–BaAõô5ù¢‹µ"oY,Ó²†[Ÿ7“÷ tÀäÙ‘ºœÏ²0©TµuK¯s¯j†�%0ZhÛèœص¤—78Úc©W=>ðÆ'Ù€ +»tZJÞtn¡Y ÎvÇ�Ò‹ÁSÒd™{¥ÖxËk¾‰eË)!÷y·¥1àQè§Í�”†æ6H�\k‡DIi48¯Rïîj…ÉyÿÞË¡œ&Œ<Ÿ–�ö�Ó`Ia ` šé»Hí8›<åÛ úR_H·b‡ § pª,§‚ ìÀKÛ•®•(>*õ4Ç9øá ?©ˆ,Ç,üîWÞ¯‘"I‚uF7Êï;eÖ®UðǪÓY…I9Y|Á·Ú^áEN2_—á�µ¾ÛP PZq3'Ÿ¡ÍVÒÏjß•k‹ H™©ª³Ü÷©Ê}Q8 Ý/NÚxß< ~xæAh9ðLK££ˆôYñ»™{gÉïRɯ/$�"ÿdÇÆ¶a9�â¾Qè4¯AÇÎV-@zÛǰÄË�ÿr[ÆÑ¨}Øc º£[¸ºôŠG´¬â;í£ÁJ4žÏ™Ò„¿„oM÷XM# ‚=Nš%8Ýu€¨kûðXßÐD¿n½»tDzàÇ +¿nŠé‘"úÍx‰%s¢Ð3Rò׸|÷œ¸Áµ‰åt¼åã Š‚‡SóBäSw³éâw[<œÓùKiÖï½ÒúQÄ“ví©�xËݲÿ0 µF]Þ¤Ûs´·œ`{ä€l …š’sçI«”´‡œ‘mºTjP]ã¬öœÛ– #•+¸Ĺjv­š‚?Vi@aœ}ô²)dh‘`LoéŸaÙj1:'§—í—f¬NÇ$î`¨ýšù™÷l©yœf0q^á�…^I=·s,77í­agAY×QidåÌøÃµ|ôä)im^ø¼Î—W |º†8d}…ŸÖ +'š!ÙÔË*6ºHGÓ qõo\÷NTlKãÀyÓ0¦/7){)ù˜Ãæ)óM2/œ'$�ìyÚVè¿ÚfK0ÂzsJ|£Ä ç4E „õºµÄÿÝòæîTe3âB'jXüy{0…áO7ú¥ÂÎ%\þ µ‘ ¸y ½âoÞ? çrõ³à\Z7,-ªl ÚƒqÛk⮬¬?¯¬,][Y‚SWz¿l“¥Uj@’ÅÏCÅxZ,Ö[Ý΂’fõ©Ý<åÜí[(Ú‚„z.”Š©-4�Ú¸âÔNKóú6¡Ûš©ÙZê‚vZ›§Ô·IÝÕÌͶRÿEeS¬ù>º>Ö]kç&›bO‘ƒ‘ê�ö爑!¯«9ÖëB¬%Ù¹ŒÎ%²~‰øšß…¤aÀ©FŠñuçfx +}£Ð«Ž—ÆRÿvç^x +}£Ð«¾—ÆB»¼úšó…�Û­ß§óÀ<®!W´pzÑ~aŸ+A>åPŒ³ú«úÎ9oÆrVxÀoܹ­r6’é[Ûžk통VsÆ( BcÈÿÞhÆ)ômB×µ]µ­Ô¡¢_ME¿* $¶Ÿ�®è×�³Øòû•Ê-ƒ1|¿W� PóÏ}ÃŒ¶5ÆúbWoÚk®2±W��Bß$tWScÍ¥nwN©o“º¯�ÚJý/6‰œ$(Éï§È7‰\Š‚ë‡XÆfl-ò¿Ü–])A(:%¾Yâ¿�V@O[kv±- Ý0¾“ç~¾Yè¿�áj'ek©ÿÕâ±DŠšÛg'UW1|o€pÐ9›Ž JXn¦ ÛÏ^Ô ¼�¶¯ZEèÉ‘å +ÛÿÅÆ5á^WCFI E¸;ÕP„ÇN5áw[Îá¹?E ¶ãl³)òH0kP’5%II-`ÜpwB�Üž£ñÄÎpã3o`†_Îm¹Ž#¿ó,.p`Á©ÆoXµ´T`¤ÇV ^]CÎ}‡ñSêÛ¤^Í[i,ö_VvïZ9 *ð®]ÖB$J;¸ÒRã‡-‰zéwÐF¹±Å¼ÚTaêbÚĪÎRÔRE�Å> ½Éf‚ÅSÔRfçNÀµÞý§NX¯°’²a¼ò=\ÿœÞ¹œBß&ôZÊFc©ÿÙò>€rY?1U®a›ÍÛUwÖÏ*ú®„TKN‰™¥—QäûšÞÇÊéØ8˽cGGæÉùž–5˜ß·Gà†÷9U *¡’d`¬e¼W�T—ûv�SäE^K1h-ó®§ú®àÜ)ö�b7•à\{±ã2ƪD[Ù¨¬+[!žÏ·?Ì�‡‹G®µ[–£‚Å\•s=±ÞÇÆ‰À�;¤Õ`Œo—‘õsà‘è*û¤q€Ú5LÆKÏK)a¾‚ZSöô)E´ª9ß6fÿ̪sÉìY2+˜U]3RV «¿fÔ2bÕcÙF•mÚ8î¼�Ͷi}mŸ}G­Ü­«¼­é¡=ø‹kgpY©]7šQ!„2­!ŠÊ°“áW¬Ñ4 uÆgnU”•¨œÑ„ô¢•[î¯+˽f•kÊ¡n†®ŒäJ¼$ƒûaÁ^?¸ƒû|ÃdÎ'fû¨%&rjÚ¢3„ —Ü®5ù58 +\øûA˜- ZL(lÃì–Ÿµµå+JD!¸–� +>¨T¢v@‰({ˆ±¥°v@iÍ·�HÓå\3{ÖŒ’µÊC�ª�P¾h¨rBi̶O²j¶¶’ 5n§ë6HŒít<)ØfÅŠ2Ý gcþ‘OyånfúÔlU)ñ3Rr66òÂ~ýòe +eWù˜xhC¶NÝÌ‹¢ŒyCËî�8Ø~ßì´^$‚ä‹VŠX:0Æêô°ô`­0L†ãýð•p‹•pÄ:8Ü ú2<1(Óðƒ-p¥6Рê:n´KÉcÓJE“ícm‰” €E.¥·�VþuEý•ª¯,§¬lÈÍ}¦ oÞ¢>ЦD¥ò+ Ê[¤g\AT0·�ÒÜèá+ˆ +ö œeMû”A.¤”ÕRy�¥lçŠI bÇã~0FÒ¨f}w ñG‹4hp àNT/î/$Zq$�AËm@;Í¢¹ø‘O\¤  ßšî±r™F±v™îNê%Nh±¬X´—`¼0wsœgÓ,¼»u™0Îw2å¥�‚Êê°4¤´Ä[åEt‹ÁõSRsÆnð¦}¸(ðFf# ܶôÃp7õßG‚±ü¤%Œ®âÏõ×ïb>\„@gòºgtOîõŸ×ø=™8id6êy{ÿHVŒJà­ŒìµÌð6¬aÀ H³¾Q`� rÂi«ì0ߤp+¡áê~”Vÿ4He”y:$xo¬oôbn?ž^êÚt›Ž&b>\ñ8ãÆÑ8Q$lÅS¦Ÿo[¸:.,í  {¹jA[ÊF¬–aÄo©‘c€Ž/Ô…«kº?X9\¿¾Ô�ºµ£8ßÚ wú�ê‡ýWÞÝ&‚‘¸á�lY;wA¶x;!ëñ úëw�P}¸h°¾ûNÃp¯æéAýp¤¬m_¼’Ï<ð*.LeMä»ÝØñl®Ô°zìxN°V+¤N.ût‡…þ‚'JÏçDñç»q÷I^ ÔÍÉaæuK^{É�ÆÃ3”3ýWúËwñàCüðþ–ˆ#†çošß|Wd;–Q2¿ë,àŒx¦œ3hœJ.‡OôLSÝU§TÈ*§˜ R™ø+ã þÚ»a$Áwš±)P^w_Ÿ¤À:~¢¿~7<£}ˆ¢¿%¢‰á'ŽdÞwß/)‡ï¿ûþÓå_/tù}àÐOŸ‡‚L?¬‘úßÍ0,"§xdd¢¶vØþÃA´ä}ZYÛ5rÆž½•‘§­²rzž¶ÊóÛ*¨X?Kà´UV±Œ€ˆëàf¦JýhvZ*K¬; •eCefTè­ïlCeÌrÙ¤CiÚ±ËÔ˜3ÃÿÆP‰VËQ4íu_6Ñ °\É2Ô•‚&ËÛhSOÄ$Ê<•ÞJ +åKyÆ[òÜ<:=Úë: ¼š7¸C�ñ@l“EL5‚]ù�Šë4d·.„a}‰·°ôML9ÄôÁ#œ¥(f˜V1ÜHÏÓÎÒãðÚÆ™Mñ´¬y•âxú‡h„ éÚiááêö­kÒk]kÓ”>ÍsZY�ÉÅI¥¹ÃÍD c{}Õ_Ù‘®þbQ%¢}]ôÈ2=<«ÍˆžŽɺä°Þ�&/Лtžˆ‹¯ÆM_dhŸ §jºqM˜d.Á›ÎjÜwÎÒà°3ézû£ˆw–µÅ*Ðè-±Jþ�¤¢I¸Þ2YR‰#™!ýúPR9ŽºSF¸ÜC(Z0V«„zÞïÇàæ4Ø@¬#°‚“¿˜Þs݆é3üÂà(ùJ˜eJ�ÿDç~ù—é×–k¾™©m¥þf[[ $•w§È·Š¼à28�¶ù2ߨܭTÜñü”ùF™œnÖ€V¶½Ð?VìŒRñ¬gÊ�ÖÞ¶ªž]òû}ªÀ®¿¦éŽåÎ�«’;sOØØV÷å�ï½7^á‚3'c ¯bSã²ô �ÛÞ?ù +—°áˆsBI©åp +i’`=û}ô8;¶·7ÐÉЗ#j̶Uf èš §˜KÁ_V¥·�.ºÞª¤wÓËG#%ý¢µï+ª¡�é- HÔèšññ�xcM kWSú³®ï±•9ëØø'é—d±¶ÒÙ!ª}s˜µ-�’Ö¼n‹]7[¡“¬¬qV 8çt#³àëš&Í6í´Zc,… â­kÍ\æ ?áN¸ûkö«*¼#Žó£µíúÓ¥ …ó™VhÕ5Ã4[<Ìl**a´¥Ý·¿Ý³÷O²®q›jÜv\˜8øìïξÞmØäv8s<Â�éÍÆ&ÛIðÚ(ì·9"F¸.ûŠ(ü%|kºÇÛÜ4Š·¹énØ“¦Ç†kúÝ–Ûœ^ÞæÈ ÒœiÔfŸUø¸ÞDºw¨ S/%¼èî@yîÉ™Pþ‡º-Xß$�:ÇusÆÞj@¸šò°ä6#ûY¾ÆY£A¢íC”M°+Tm7/äÿd6ÃW ž€�Kó‚!—"ðZ·ÿVXáª5®jŽÝn¾fà¬ÁÊ ‚©EËΆY'†×U†Ú´NÝ7ãçÔfÏ‚«�7ˆ ÇÝÛ9ËÊ"€8ËÇ,²Y…t°Ér´–Ù/ ênp‰¹Ú ƒglP3—XÞ—ð‡eÿYÆ—� «Hi°‚|·HÏœ‡µÖš«dÒ’t€^Ù'ÊypTÉyˆé}ˆ‰æt%ç¡7ƹ/»à\AÛV�©$<ã²ȸÇ/!W�Œk¾„²7)eUÃ[:ÐdZººé(‘;ÎFë-·Ž±tÈÉZDfVeýÔ´&ââ«f4z�V·ó�qÆÒ»šx§Ñ�\\9¦„6Q™ +¼�ûŒa©¹¿' ¾ÿ2�á…{^%`xán †7Daú‚§$#qIß�‰åæ“)eU22/L³†'ó6‚SÈ8;d'Nò¯ +– ©sÒ—ó£v~ì‹¡9wªá@êû•œªæfUSóJ Á=±Ý¨SS5™�Q5¶¦jš118›*”UÝÍAŠVšfôhà%ÏÍÆJÌë4ÞZÓ{µ‰W3n•GðŠaÛv�Oýˆ‘µ»—v,ÜRN‚öýÏT/©œ˜ظ`R ±\0©¬ç Ù&“Åô�O r¡Û JË*·ÍÃuªŒfÀ!_Ë0/ 3›¬&Ï@}f“Ó^ómÿ™&6 ÷†Ä¦adAzá´ï󚆛¡Ô$ýôP?~lúÑp«ßYÃcâ�u¸)¦'ò¿·8� +6¼E[KÓèÅÁ†ƒt×5ÇbÝlJjÉ3n�/­¦S>‹…¥0í! �‚qgååÃÂHªêQ•sw*KÃöÁÀ‡mUŽ$Á"yÝûù¦Ñ�uŽ#±ä@ 5¸,Ÿ�XéÁ¹ÞEôô´"iNù ˆ•^�PF¹Ï‚XËm”SŸ±šseÿë‰‰Õ +œ7Â¥ºíDl7hAë1šë>´¢¸îCê1zë.´¤¶îCë1Zë>´£´ZÒ~Æ€ð‹Úøô&ÏûãläÓ³ŸžM|z¶èÓ³sŸž�ûôt{Ÿž•Ü¥=?K6M4R~dfr§D¼à¬O;—^Lå#:�*QÊX Á¥×އ}P³BVÁªõ¨ãµ2Ö´sG…|ÎRƒËåjÚ²krøísü+mÏNÊfJB™ØDSz-»†.üeÊÌ÷ºÔŒ0Jr3Âݰ¢§Ç†õ>ýnK%QuQäÁ�FØcµ„«i‰˜ÌǨ _Sí¸òc—IÞ‹r®Ï9,A�h°Jºç6c�ŒºÖ‚•ÏcZ9),ãxHoX•Xx`3§$¥ÿW£ƒn§F'F%à wjô kf/}/íÃ:V;ˆÊÇh¥ªÙ׌‡kÔ¹©ªóGóÍVµyc¾eÉ6·+sr€B¥Éÿëã ¡?+«¿M™»ª2ŸsðÐÆ|YˆåýN=®ƒÿ5�§¿U�ûŠW4¸ªÇ¥¨éñˆÊ‡è#‰5=ÞŒ‡+ô¸”5=þp¾©š¿3ßn×ãÊ�ËÔä�mrI55^`à¡j|NË»ÇvÖr¯aÎ$©÷rŸ +ýF….+9–JJ�V<ƒF75�“ùÕdk*½×ètWÓé�眯)õöœ;µºäd´”À;ku%jZ½ÄÁ#Õzšú:$AíUè´x*ôM +]Uês¸+šÐÎ?\Ÿ+YÓç•QJJÕÔy3®ÐæŠjÚüá|Ó5eÞ˜oŸöjrdnêÏ£8uT(at«*75U^àß�šümš¢2SGì˜Hh¯µŽjœ£§n¿U·×⢢kˆðø°¨ª†E#*££ªQÑf<\¡Û©}4ߨmÍ·¬ŽìvíŽ2SžwVîT�ˆx¬÷%ÔZdúÜf {b§~�lÃî˜?ëì8ª„I¥'0Êllj;LÃS-Nš�ùUU ”6äâ¸ÔÔN]%$ˆLÜ9àG5C´ÈÁC••J�Ï�ûT’ô¼2 ëÖ6'UlNé¸ù�ÆÇk¤šÍSù…T³9Ûñð:܇Ò5›óá|Ó5›³9ßÔN=ÎzÇ)£©È ]Ö#E^àà±z<8 øß_ìTãNñiñˆÊÇh£ªYÙŒ‡k´x-ÿîñ|«åß5æÛw;U¸S`¤Æm™Ô†{[pI[wP £[Ux-ù®Ä¾–*¼ãéA>®MÔ¨vÎûy«óJž4ì¼�Û‘ÏÓ祶½“>�É|ˆb*u˜�z;.@íÂjyxOÀ·Z"^s¾å­ySÒ¨¦Í�¥µh‡£¾­gâtëRä.;5«Ñ ãßœšuƒf-µ šU[°Õã ”K-4'Í“ù QˇkÈÅBç”®Z2ܰ­– w_¶Ýn*s!yi=,®Ô¬q2•Kü;ÔVÎÚ놦K{s&Cø3n›B/µÅ +�h'Äãz©Åä¤Ðc2¢™J]'…ÞŽ‹×z©ßá¤Ð϶ZB\k¶e�Îo×èÜAËã¶’VŒ' nÕçÕ0d‰}ÇŽz|¨\Q:Âqü˜åM¥ëÉ€kW›ø³Nž(5[ š^yPÆÙÇ™—º,Nš>&ó1*««lÇÅŽ®_,ÓUjö7©*åÁJ”í:Ûæé°Yÿ½Ðï�æUÊnS Þ�QÖ}à®�ØÏÜ5û€»Z?pבØÏÜ5û9€»b?pWEœã/­þ À]#ZŸÜ5¢õÙÁ]#RŸÜu¢õùÁ]#ZŸÜ5¢õéÁ]•“±u‚»n=�ZBwÙÌÊ2kŸݵÐlY¡%ÝTúPt×Bs_®âVÖø–<[+.Ó5wµ)R£–oïºò–Á¹¦ 5$vËQlÒ'¬ë.õ kêáip] Í�#ýðptÒB/àHA´G'UÒæ¾-ÅíIÐ30nîÚRŠý®^©û3nµ5騰®1z+"°Ã ª-¬ë”�Úã©Ä3?�ÍN=‚½îÑó…Á±ž´×B‹àXÍ?µ´Ð"8Öò­Ñ^+J¾Ð"8Rò�f›®êø§{�Tü°×CB®…f¶±‚¿/ÔkèàÐgŸÏªØÇtÊ=í$'�ÃîÒù¶¦óŸ¶Ðs8Òù�F8-4ô�t~s„Óe�O…¾³“Î0Û¨ÐÍ4Òù�Ùö~§Æ8,,:¬F*¿-,ìßÄ�òÁ§óºS�Ÿx°;ô8úsEzüYa©Ð¡+Rä�†5¥B‹®H“7‡5Íà’RÒLE•?žq¶¦Ë›3n·¿ö ºREê¼5ì¬[Cæ¾ ÷½*þDˆÝ£â}MÅ? D,z„EþÁP§Th)øÖ±5ý^è¼5é÷‡³MÕÔ{c¶½îÕí{bpÎP¡?U¤ÚÛâÃ~›d½ÛrT6÷ÃïD��þ‰»C߇EúþI`c©ÐD,Ò÷†?¥B±Hß7‡�].y§Bs®Iß?œmÕ�kk¶mCbŒ4þÔØƒœ3…VV‘Êo�;1æP;µysŒØŸµ:/ô›ÔùÓ€ÄR¡™Ø¤ÏK…nb“Bo[Óè…>]A£?ãjÖæŒû´S£ïÀÖU�”gâY!„Ñ­½am�­›uy˜ªVÓHêø©}zþÞݧçkÕgAÞ¥B±HÍ?A– +íÅ"-ßA¶¢ä m»&%ÿh¶zHE:¾9`±Ý§äwïä…/4¸Š´|[àÝ¿L•zHžÉœ6rg’ä È»G»zŒEÚýIy©Ðo,ÒîF–¥B¿±H»·Fä­j÷J�õñl«ÅXÛ³�vj÷=˜¼Gi÷ZŒµ=&oîuo¥àOŒÞ]¾f}�^*´‹Tü£Áf©Ðw,Òñ�›¥BG¯IÉ?žqµPk{Æí­vbåC¨Ü¡×©Ðç*Ró%¶Á^ϲà�Éw?q‚wi÷B“±H»? P0:yEÚýш·Th.i÷ƈ·W´{%®úŒ«VÛ3Né�Ú}Zð!¹4…ÎW‘noŒüõ‚~lÎ9OŠcËZ› ÿœÁM¨Ð�,ÒøÏ‚$L…–_‘Æ4$.QE¿1$îßîÔZ{qJ)ôÈŠôVsLÜ€¨"3üÛ­¸·8àÞ*B:»)¹­�Jù¡YÞ8BK_‡« À{˜Wº9�š§ ²L–¢nÕð¥pRié)¢Pƒ±¬q> Wv$¬¿Xv?º›9¶¿PRØ$•¿#‡mzrXH“èM*kqñ59Û£2\ûazM N',™!ò¤±d™}š’Ê/•¼Æ¿³ðM!²Í0eœ©L5ÁVœ§ÔAwƒö£¬¢‘]rî6zÐŒ”(Qƒ1b€n²K;0ƈÞ~âj9+ Ó¡Äx:”�·º3Ù8HŽdãÍiŸ8mÏã¶Ü� àÏR€ïXZ’ø‘›óT™>œÑ?•Ê\RzË­H:Jém·Kÿº²K—:‘c•lÉÎŽ®Ë2]¥Žbš·8Öƒ»éºB6ª©€ö¬c°±  º¿~]‘}©ñ˜•¼1Xsw (é5”¯°·Ð… ÞöZs7l\„@gŸîºgtOîõŸ×¨#@�42õ�ÜàL‘ +К[9üÓðn#çR®JðÞX9ÞèÙ:±¨�/y�éãcÓÑḊëŒå6ŽFvK0(ø@3¾—ÚU˜žW$ìcªm)Iv0†¿¤Fg/Ðñ…ºhpºûƒ•Ãõ»áKý¨›€Ê9ŽÂ÷wú�ê‡ýWÞÝ&�‘¸á�¬œ» §Øv2æ ò@ _¿ „òˆ}rÖwßéopÝKê‡#eýhû +ànà +0ÞÇ`®¼œ}·™8ž Õ69;zv¬ +©“ËþìÞ.x=þ oÙ·Dñç»q÷I^ +ÔMÉaâ]//Ù#žA œé¿Ò_¾‹â‡÷·Dô1<Ëô–’ëÚ{–qÁÍJ¥ÁƃqË”s�SÉåð‰žgª»êT +Yåÿ¾©Lü•ñíÝ0bg3¿?R ¼î¾>=H�u4üDýnxF?úÿDKDÃOÉ»ï¾_âÝ÷ßýÿéò¯ºü>pè§ÏƒCA¦ÖHý‹ï‹æIÁ9# XÇl,˜' ίï“sXŠh?w„t׿I"Æ9Lƒ*6¨M ‡ÖÏ÷Ù¹øcñ¨˜$§ÀAù€™½XÅ–µòíïþôúã7ÿôúR ÏÖ:%áÜYçü»!FQ;³YµüJÓŽn5(©z,»ï4;ã�ô×Ì¥ž«Êq_�eŠ�~*œÖjgÓB»®0i¼oE8Ú5WÀ¤½ÂßÇ`}M›º|ñÑÃ+äþ·ºÉÝ<6SÒ‰©œÝ�­z¬8©ÇDñnôÛºŽ_m\wýo…¼ ° ¥q ˆÎ‹¿!íF‚•öfNж�.¨ã„"iº²^vj±ºN[e‡ñqç�ë‚Ab¼º#égÁÚµÅÇ-Ñ÷–?3 ž2“@ žã"Èug*Áužá]P0F€pq„¥Î´3› Æ¾3Ÿ`1Ÿ Ô.UPÊßÝÄ«e„ÜÓYbü•ô€³Dàèùá7kVpÁùd hïåLûδ­¼K=Q-�”ÂÞY€Q=L�^»|Rr–ñ…E+rX9g$eÆé Q{±‚{JYÀov­lªR-WèÛɧ8ë„£fïˆúÅ"QºÐ²“Kø´v†š3ëï*t•‚Z\à•k==‡‰é¦£íWõÀP8 gEÎR¿¸oæp)"�2 àÈð”Ðå÷7‚=í&s-Þbñ–·¿,ÇÎÃ;Ϊãw¶ó¨}tòü¤K,u©3H-ë/Ë3EËSüh=÷94­`¸J¹1åèMã +6vhêBÿÎàÐ4-ÛvMšv¿€Ö¸.‡þCõ³UG¦.ô “…ÍH{ûœy%Új+‰¢ íKCbI‘{ +õB3Y‰gëBKÓ)½¤Dò}‚•ºÐ(4d—ì%k…?=ðÎæy}5^úJrI+^Tè(�ä9¯ÌS¬£B{MidG`ë…” ‡°Eì…n›ÒXÁT

    ‘ñ¨ˆËw¬×;0º.µ $Ëv�/«ú⢧„ÀQ­auYI¶ƒÄX+wÏæ$cîu�·u.lèERÞ�ôÉ}­�H…ž$,›ÐÅ:ͬháCºdê>ϰ«Ïf¸µ‰IÑ[ˆ¢ \Éræ(Õ½/üïÂÿ +Ÿ\lHÃÿþ}’FšîÕL÷BãQâµk´”»yTWßß®!oný’µ ‰\{ &Ò�˜¶Ò˜››º+“§ýö˜˜èÍÖ²Fuî�6|©™¦w ;òŒê€õsu L韄$ÃszS~�;M Ý6Iqçãï&캂½}}Zpi0Rùvœ¬j»•ë‰ÈsJ¨~†õTèÂIA +¥eóµ½Q[ú#Çq¸ˆÄSwu)IzîN¼¿ŒâÁ7�ÌAD>mñÓ¤Œš›PšKZÚ2Ÿ¬×ˆÓ•�GH4)’ûQÄmôçU›aœFlÒœ²mQò‰|¾µæéðÿ§ó ÑœÀÖœBÑ連,XÃ)Ä ¢äËG˜àÉ;¥­$áé.-5A ¦–$Ð>õ±®«ìèøjS}—ó9}W3¶ +¯Ð"�³ÉBP ý˾ž(\ï58{ÐÝØó@:Œ’bØbVI{gÀQ ‰t¡Á(ÛˆF‘P •�èG¤ ýEI'}K†d¤ +eãÕ 2l\?œo³Ôh ß™[­ù&¨BÙÜ$‹ ·Ÿ°u= Ö²ëBI²ˆs™÷óïÊ�”vÖWyW�k;Røæ-^Ã/ò¦ÄŠÈ`¡…¥ÖH¶‚Zïs¥š†+‚µÃ ¼¥f’;ðW¦î°ý“ÁQ]Ë}ß\z&»s «Ðä“È2ÖŒ)ʪI+Ô ™p… Ä=d”²ªÙ4[ái+ôÕ$K`�²r7]kÒ +3ïwž W›*èB»G-½ÙùÖËø˜\-Ó±}ÇBÓ|¨$îÔÚ�^ÃèÆ…VèJ©…2ÊÞa¡Q0ÖÉþuÄa¬ÐÖ²Û¤¼k®óWY¥¶‘aS”fOx«M4”‹Ì<†R¿¼A�gt,9¢ô’ºx{ÒÚ)œkbˆö»gØ@òþäµ[Û]ÖMmžm4À83'°u4 Ðü2DŒe�šÄVÝ€“¹ž˜OSÔN™[Îʾ;ýƒ‚…Æœ!(`Œ2Â?ð88ªâŠ:)t𜂥Wh,^JÆ_WeýÕ¹†�õÞš}³ë gC¡“'Yî4Êþ«'˜^µiUð©z J†5j4­Vx +m6É[ w]­Š Ý&5›Ò»ÖktßrÒhÀ ¿SWs“Ž‘î¸GEݺš + ˆÈ <Ýa5ábé]Ñ©ðqu†z¡¥6´ÒÜy¥Ý¼ƒsý(¥"î=)|eלb +½ƒ—¾VuF¡i&‘-¹n±øfwÒÀ…vYDÆ¢Tû [¡‚#cá?厼CKÑUV’oÇÏÿvËÉЖ"¬œócX—Hlr4|»h›Åb;mò ØL{ÖãÙ}­O{…6[Ói�K–�O¥ßö´÷iû9E=~ŸÎ L´©çdV@3ºÃú…óæ§àâ›Â׿¬­¢J⥑ŒBÚªNáßE\\h¦|I¹3*·.ÊísÇxUŸ\³Ztèin7+®*jÌÏ¿Œ´JÈ�Æ�Rô;þßwݧk/Sp�:ÂòY¯©XCð»vv�‰øýËÞ{oü혡ð§Â,-ÆO‰ã¥*lW™ö�™,š ¿möôÁÈ®®îݾl Y/Ýþ·;Düã�p*N¦A†�–õàLœÊ©ÒHÏo‰†.xd¿švé[§N¡Ö4u„!}»¨k;VÈ—7'Ã+­Ïm©p9ÿFª€ß¯TÃ+À,u¡¹y q¼—ËëÖgp,$eUA­ +]¾4Êy‡I’æd]UÁ+Ä]¨T©½¼Z^!Ú{°žmut0ÉüÌ=©¯Ÿ�Ý\"nP 4yb8ÛΜw|t鬿ž^4ÐÖzK=ª||£ƒqçiN¢îþ]²¡K­Ä¼Hs4Í®U…‹’ú.K&Y,ž-SJÊð¯(£¨Œ³<ýwœêY˜6÷Däéüïoß³»íﯦÐaظGH­Ï¨.u›äÂ>A�ä2×wiÏ×´õètÚŸK³^ÃSrïÍÍ+Å2¬Ø°R8„áȇþ ñ�VŠ©HÄxÐdÚ®”×Ùú˜xÜßüý0ÁF +ïÂ×Ýÿ‡­g�èA§ðt“Àó¾?ùö9ó À îlÇ©þ"Nõ_ë"á”�Êõ3a¡d3¡s’Œ×[Ü$#©J�ÔÆ¤ +Íÿý!ñ¹Iåªm¹ºèpR=W‹ŒÞõip;±œz¬Ø�pÀlåø7ܹ|/âèDäþyz"÷ÏÐöD07çD^Ÿ•éÖU®äì—¹¶ ½N┲ó’k{G£@Э¥œ7ªÿ”ôBù�¥AþÚ‚!k[aqn¨÷à£T87ä�«Ž[×JÍÇgÉò)|C-婯ð” XÓ.Û0äŒÇ\|-[?Mo¢)•×*t�f9C—™¼?ï‘Ó<�_ÏNà© ]ðcSíͰ"0eÀKÎ]j{œÎ'ÞËqC‘Ô:xÚµ¹’€­~MÐrpMo6<ûÎøè€S)nããt=ÜHøÙópݪ L¦gÎŽ‡OÕñ�áå”`hkMÞ`”ht6<\d™Ö³Ö 0&©³8ûnæÞÙîp©Ý¡.´éÖŠ«}î`ÌŠ ©IYԷÉ5ç¤áÔÍœÓJ2‹œi.õùBZ¨k +­Ÿµ–`.�|ŸRrSèò¬5�ÓìãÜMØU;`*™úªÆ�›×–"ÐŒæû ¥å+"”–KoåƒWÖ¹fšÇþ³X¯Y“QëŽÂœú2"àˆÙUYL¥nêAè‡àÛˆ¢4áëþ’›§9�§GMóRƒõÀ\ÁÀAbÏIhí<Ÿ¥ñÇ“©ûß?†9V˜[³ æ\¹¯6mÖÄÜfóþ¿:ó_¥²v¬n¥æñ£PøѤ€À +å§×©QX&P޽–s�ž¨�ø¢ñùÙ®ö–Ÿ5we3Üâb÷kÞ–dX Ž­ì…:CŽÉ�âk"(¥ÞèžἺ‹äÃÛöEÖcüU¨ÁþûiwÚÜq¾ÆS™ý¶¯aowvi§yÛ�îeþK�îB€5xAÂí'ü,BShLÎ{¼'ƒe +›@ÎϬ.jiñ„Õ8áóÇoùÿÙ„kõ endstream endobj -412 0 obj +407 0 obj <> stream xœ}�¿KqÆ?×U–X 94%MQKS�†Nø#Ô¦óüQ vÝ÷BšË¡©hˆFk ¢ÙÆú‚ ! @@ -1517,438 +1495,433 @@ x ô’0l+ϽߣÈy7½®Ó;¯×«É¥º;QŽ?V.ø_îtFÀà3LËEÆK¶)y ðëz”80eÅIPö¤Ÿkñ‰äT‹/%[Ñp” å:8ÕÁ…ü¶¼+%¿÷dбÐŒ"ÂÿG¦·™ `d_¿{Ù¹ÙÖ–gzžçm\‡Ð8rœÏSÇiœ�úµ­öþfæë ´½Ô1\íÃÈCÛóU`¨ ÕS·ô¦¥]Ù ¨ŸÃ@†oÁ½ö ãâ_± endstream endobj -413 0 obj -<> +408 0 obj +<> endobj -414 0 obj +409 0 obj <> stream -Typst 0.15.1en2026-10-01T12:44:14-03:002026-10-01T12:44:14-03:001application/pdfCJLc6tBfdOjtrdLwMNqm3Q==CJLc6tBfdOjtrdLwMNqm3Q==proof1.7 +Typst 0.15.1en2026-10-01T12:57:20-03:002026-10-01T12:57:20-03:001application/pdfDzyaajGJifpizox+vCC3sA==DzyaajGJifpizox+vCC3sA==proof1.7 endstream endobj -415 0 obj -<>/ViewerPreferences<>/Outlines 16 0 R>> +410 0 obj +<>/ViewerPreferences<>/Outlines 16 0 R>> endobj xref -0 416 +0 411 0000000000 65535 f 0000000016 00000 n 0000000069 00000 n 0000000161 00000 n 0000000268 00000 n 0000000349 00000 n -0000000440 00000 n -0000000534 00000 n -0000000622 00000 n -0000000726 00000 n -0000000826 00000 n -0000000920 00000 n -0000001014 00000 n -0000001102 00000 n -0000001188 00000 n -0000001274 00000 n -0000001369 00000 n -0000001437 00000 n -0000001604 00000 n -0000006330 00000 n -0000006435 00000 n -0000006516 00000 n -0000006659 00000 n -0000006816 00000 n -0000006884 00000 n -0000006965 00000 n -0000007036 00000 n -0000007138 00000 n -0000007206 00000 n -0000007349 00000 n -0000007420 00000 n -0000007591 00000 n -0000007659 00000 n -0000007753 00000 n -0000007850 00000 n -0000007918 00000 n -0000008074 00000 n -0000008239 00000 n -0000008307 00000 n -0000008400 00000 n -0000008511 00000 n -0000008667 00000 n -0000008823 00000 n -0000008891 00000 n -0000008985 00000 n -0000009079 00000 n -0000009147 00000 n -0000009306 00000 n -0000009465 00000 n -0000009533 00000 n -0000009627 00000 n -0000009733 00000 n -0000009801 00000 n -0000009957 00000 n -0000010119 00000 n -0000010187 00000 n -0000010280 00000 n -0000010363 00000 n -0000010440 00000 n -0000010580 00000 n -0000010649 00000 n -0000010719 00000 n -0000010806 00000 n -0000010874 00000 n -0000010943 00000 n -0000011041 00000 n -0000011109 00000 n -0000011213 00000 n -0000011300 00000 n -0000011377 00000 n -0000011533 00000 n -0000011689 00000 n -0000011757 00000 n -0000011851 00000 n -0000011945 00000 n -0000012013 00000 n -0000012169 00000 n -0000012239 00000 n -0000012408 00000 n -0000012476 00000 n -0000012570 00000 n -0000012640 00000 n -0000012710 00000 n -0000012827 00000 n -0000012895 00000 n -0000013051 00000 n -0000013122 00000 n -0000013193 00000 n -0000013268 00000 n -0000013453 00000 n -0000013521 00000 n -0000013616 00000 n -0000013715 00000 n -0000013783 00000 n -0000013940 00000 n -0000014011 00000 n -0000014183 00000 n -0000014251 00000 n -0000014358 00000 n -0000014430 00000 n -0000014502 00000 n -0000014575 00000 n -0000014648 00000 n -0000014721 00000 n -0000014857 00000 n -0000014949 00000 n -0000015024 00000 n -0000015097 00000 n -0000015170 00000 n -0000015284 00000 n -0000015471 00000 n -0000015630 00000 n -0000015702 00000 n -0000015819 00000 n -0000015916 00000 n -0000015988 00000 n -0000016171 00000 n -0000016334 00000 n -0000016406 00000 n -0000016511 00000 n -0000016608 00000 n -0000016680 00000 n -0000016839 00000 n -0000016998 00000 n -0000017070 00000 n -0000017175 00000 n -0000017272 00000 n -0000017344 00000 n -0000017511 00000 n -0000017670 00000 n -0000017742 00000 n -0000017843 00000 n -0000017940 00000 n -0000018012 00000 n -0000018191 00000 n -0000018358 00000 n -0000018430 00000 n -0000018531 00000 n -0000018632 00000 n -0000018704 00000 n -0000018867 00000 n -0000019030 00000 n -0000019102 00000 n -0000019207 00000 n -0000019304 00000 n -0000019376 00000 n -0000019555 00000 n -0000019718 00000 n -0000019790 00000 n -0000019887 00000 n -0000019988 00000 n -0000020060 00000 n -0000020239 00000 n -0000020402 00000 n -0000020474 00000 n -0000020591 00000 n -0000020688 00000 n -0000020760 00000 n -0000020923 00000 n -0000021094 00000 n -0000021166 00000 n -0000021263 00000 n -0000021360 00000 n -0000021432 00000 n -0000021635 00000 n -0000021705 00000 n -0000021791 00000 n -0000021978 00000 n -0000022051 00000 n -0000022230 00000 n -0000022302 00000 n -0000022399 00000 n -0000022508 00000 n -0000022580 00000 n -0000022747 00000 n -0000022922 00000 n -0000022994 00000 n -0000023111 00000 n -0000023212 00000 n -0000023284 00000 n -0000023451 00000 n -0000023610 00000 n -0000023682 00000 n -0000023787 00000 n -0000023888 00000 n -0000023960 00000 n -0000024067 00000 n -0000024177 00000 n -0000024344 00000 n -0000024503 00000 n -0000024575 00000 n -0000024688 00000 n -0000024785 00000 n -0000024857 00000 n -0000025032 00000 n -0000025191 00000 n -0000025263 00000 n -0000025376 00000 n -0000025473 00000 n -0000025545 00000 n -0000025720 00000 n -0000025879 00000 n -0000025951 00000 n -0000026064 00000 n -0000026161 00000 n -0000026233 00000 n -0000026408 00000 n -0000026567 00000 n -0000026639 00000 n -0000026744 00000 n -0000026841 00000 n -0000026913 00000 n -0000027088 00000 n -0000027247 00000 n -0000027319 00000 n -0000027432 00000 n -0000027529 00000 n -0000027601 00000 n -0000027776 00000 n -0000027935 00000 n -0000028007 00000 n -0000028120 00000 n -0000028217 00000 n -0000028289 00000 n -0000028464 00000 n -0000028623 00000 n -0000028695 00000 n -0000028800 00000 n -0000028897 00000 n -0000028969 00000 n -0000029140 00000 n -0000029205 00000 n -0000029372 00000 n -0000029531 00000 n -0000029603 00000 n -0000029716 00000 n -0000029813 00000 n -0000029885 00000 n -0000030060 00000 n -0000030219 00000 n -0000030291 00000 n -0000030404 00000 n -0000030501 00000 n -0000030573 00000 n -0000030748 00000 n -0000030907 00000 n -0000030979 00000 n -0000031092 00000 n -0000031189 00000 n -0000031261 00000 n -0000031436 00000 n -0000031595 00000 n -0000031667 00000 n -0000031780 00000 n -0000031877 00000 n -0000031949 00000 n -0000032124 00000 n -0000032283 00000 n -0000032355 00000 n -0000032468 00000 n -0000032565 00000 n -0000032637 00000 n -0000032812 00000 n -0000032971 00000 n -0000033043 00000 n -0000033156 00000 n -0000033253 00000 n -0000033325 00000 n -0000033492 00000 n -0000033651 00000 n -0000033723 00000 n -0000033886 00000 n -0000033951 00000 n -0000034024 00000 n -0000034121 00000 n -0000034193 00000 n -0000034266 00000 n -0000034392 00000 n -0000034464 00000 n -0000034536 00000 n -0000034615 00000 n -0000034697 00000 n -0000034787 00000 n -0000034859 00000 n -0000034931 00000 n -0000035004 00000 n -0000035081 00000 n -0000035154 00000 n -0000035276 00000 n -0000035348 00000 n -0000035463 00000 n -0000035553 00000 n -0000035626 00000 n -0000035699 00000 n -0000035772 00000 n -0000035845 00000 n -0000035975 00000 n -0000036064 00000 n -0000036136 00000 n -0000036209 00000 n -0000036282 00000 n -0000036355 00000 n -0000036505 00000 n -0000036577 00000 n -0000036676 00000 n -0000036759 00000 n -0000036832 00000 n -0000036905 00000 n -0000036978 00000 n -0000037104 00000 n -0000037185 00000 n -0000037258 00000 n -0000037331 00000 n -0000037489 00000 n -0000037570 00000 n -0000037643 00000 n -0000037716 00000 n -0000037842 00000 n -0000037944 00000 n -0000038017 00000 n -0000038090 00000 n -0000038163 00000 n -0000038277 00000 n -0000038391 00000 n -0000038550 00000 n -0000038713 00000 n -0000038785 00000 n -0000038882 00000 n -0000038983 00000 n -0000039055 00000 n -0000039214 00000 n -0000039287 00000 n -0000039462 00000 n -0000039534 00000 n -0000039631 00000 n -0000039728 00000 n -0000039800 00000 n -0000039959 00000 n -0000040032 00000 n -0000040207 00000 n -0000040279 00000 n -0000040376 00000 n -0000040449 00000 n -0000040522 00000 n -0000040639 00000 n -0000040711 00000 n -0000040870 00000 n -0000040943 00000 n -0000041114 00000 n -0000041186 00000 n -0000041301 00000 n -0000041431 00000 n -0000041504 00000 n -0000041581 00000 n -0000041675 00000 n -0000042036 00000 n -0000042073 00000 n -0000042124 00000 n -0000042175 00000 n -0000042227 00000 n -0000042279 00000 n -0000042331 00000 n -0000042382 00000 n -0000042434 00000 n -0000042486 00000 n -0000042538 00000 n -0000042590 00000 n -0000042643 00000 n -0000042693 00000 n -0000042745 00000 n -0000042795 00000 n -0000042845 00000 n -0000042896 00000 n -0000042946 00000 n -0000043149 00000 n -0000043306 00000 n -0000043859 00000 n -0000044073 00000 n -0000044232 00000 n -0000044687 00000 n -0000044906 00000 n -0000045066 00000 n -0000045839 00000 n -0000046058 00000 n -0000046198 00000 n -0000046414 00000 n +0000000436 00000 n +0000000530 00000 n +0000000618 00000 n +0000000722 00000 n +0000000822 00000 n +0000000916 00000 n +0000001010 00000 n +0000001098 00000 n +0000001184 00000 n +0000001270 00000 n +0000001365 00000 n +0000001433 00000 n +0000001600 00000 n +0000006505 00000 n +0000006610 00000 n +0000006691 00000 n +0000006834 00000 n +0000006991 00000 n +0000007059 00000 n +0000007140 00000 n +0000007237 00000 n +0000007305 00000 n +0000007448 00000 n +0000007617 00000 n +0000007685 00000 n +0000007779 00000 n +0000007894 00000 n +0000007962 00000 n +0000008118 00000 n +0000008283 00000 n +0000008351 00000 n +0000008444 00000 n +0000008555 00000 n +0000008711 00000 n +0000008870 00000 n +0000008938 00000 n +0000009032 00000 n +0000009126 00000 n +0000009194 00000 n +0000009353 00000 n +0000009515 00000 n +0000009583 00000 n +0000009677 00000 n +0000009789 00000 n +0000009857 00000 n +0000010013 00000 n +0000010175 00000 n +0000010243 00000 n +0000010336 00000 n +0000010434 00000 n +0000010511 00000 n +0000010651 00000 n +0000010720 00000 n +0000010790 00000 n +0000010883 00000 n +0000010951 00000 n +0000011020 00000 n +0000011118 00000 n +0000011186 00000 n +0000011290 00000 n +0000011376 00000 n +0000011454 00000 n +0000011611 00000 n +0000011768 00000 n +0000011836 00000 n +0000011931 00000 n +0000012026 00000 n +0000012094 00000 n +0000012251 00000 n +0000012322 00000 n +0000012494 00000 n +0000012562 00000 n +0000012657 00000 n +0000012728 00000 n +0000012799 00000 n +0000012920 00000 n +0000012988 00000 n +0000013145 00000 n +0000013216 00000 n +0000013396 00000 n +0000013464 00000 n +0000013559 00000 n +0000013658 00000 n +0000013726 00000 n +0000013883 00000 n +0000013954 00000 n +0000014126 00000 n +0000014194 00000 n +0000014301 00000 n +0000014372 00000 n +0000014443 00000 n +0000014514 00000 n +0000014585 00000 n +0000014656 00000 n +0000014788 00000 n +0000014880 00000 n +0000014955 00000 n +0000015028 00000 n +0000015101 00000 n +0000015215 00000 n +0000015402 00000 n +0000015561 00000 n +0000015633 00000 n +0000015750 00000 n +0000015847 00000 n +0000015919 00000 n +0000016102 00000 n +0000016265 00000 n +0000016337 00000 n +0000016442 00000 n +0000016539 00000 n +0000016611 00000 n +0000016770 00000 n +0000016929 00000 n +0000017001 00000 n +0000017106 00000 n +0000017203 00000 n +0000017275 00000 n +0000017442 00000 n +0000017601 00000 n +0000017673 00000 n +0000017774 00000 n +0000017871 00000 n +0000017943 00000 n +0000018122 00000 n +0000018289 00000 n +0000018361 00000 n +0000018462 00000 n +0000018563 00000 n +0000018635 00000 n +0000018798 00000 n +0000018961 00000 n +0000019033 00000 n +0000019138 00000 n +0000019235 00000 n +0000019307 00000 n +0000019486 00000 n +0000019649 00000 n +0000019721 00000 n +0000019818 00000 n +0000019919 00000 n +0000019991 00000 n +0000020170 00000 n +0000020333 00000 n +0000020405 00000 n +0000020522 00000 n +0000020619 00000 n +0000020691 00000 n +0000020854 00000 n +0000021037 00000 n +0000021109 00000 n +0000021206 00000 n +0000021303 00000 n +0000021375 00000 n +0000021578 00000 n +0000021648 00000 n +0000021734 00000 n +0000021921 00000 n +0000021994 00000 n +0000022173 00000 n +0000022245 00000 n +0000022342 00000 n +0000022451 00000 n +0000022523 00000 n +0000022690 00000 n +0000022865 00000 n +0000022937 00000 n +0000023054 00000 n +0000023155 00000 n +0000023227 00000 n +0000023394 00000 n +0000023553 00000 n +0000023625 00000 n +0000023730 00000 n +0000023831 00000 n +0000023903 00000 n +0000024010 00000 n +0000024120 00000 n +0000024287 00000 n +0000024446 00000 n +0000024518 00000 n +0000024631 00000 n +0000024728 00000 n +0000024800 00000 n +0000024975 00000 n +0000025134 00000 n +0000025206 00000 n +0000025319 00000 n +0000025416 00000 n +0000025488 00000 n +0000025663 00000 n +0000025822 00000 n +0000025894 00000 n +0000026007 00000 n +0000026104 00000 n +0000026176 00000 n +0000026351 00000 n +0000026510 00000 n +0000026582 00000 n +0000026687 00000 n +0000026784 00000 n +0000026856 00000 n +0000027031 00000 n +0000027190 00000 n +0000027262 00000 n +0000027375 00000 n +0000027472 00000 n +0000027544 00000 n +0000027719 00000 n +0000027878 00000 n +0000027950 00000 n +0000028063 00000 n +0000028160 00000 n +0000028232 00000 n +0000028407 00000 n +0000028566 00000 n +0000028638 00000 n +0000028743 00000 n +0000028840 00000 n +0000028912 00000 n +0000029083 00000 n +0000029148 00000 n +0000029315 00000 n +0000029474 00000 n +0000029546 00000 n +0000029659 00000 n +0000029756 00000 n +0000029828 00000 n +0000030003 00000 n +0000030162 00000 n +0000030234 00000 n +0000030347 00000 n +0000030444 00000 n +0000030516 00000 n +0000030691 00000 n +0000030850 00000 n +0000030922 00000 n +0000031035 00000 n +0000031132 00000 n +0000031204 00000 n +0000031379 00000 n +0000031538 00000 n +0000031610 00000 n +0000031723 00000 n +0000031820 00000 n +0000031892 00000 n +0000032067 00000 n +0000032226 00000 n +0000032298 00000 n +0000032411 00000 n +0000032508 00000 n +0000032580 00000 n +0000032755 00000 n +0000032914 00000 n +0000032986 00000 n +0000033099 00000 n +0000033196 00000 n +0000033268 00000 n +0000033435 00000 n +0000033594 00000 n +0000033666 00000 n +0000033829 00000 n +0000033894 00000 n +0000033967 00000 n +0000034064 00000 n +0000034136 00000 n +0000034209 00000 n +0000034335 00000 n +0000034407 00000 n +0000034479 00000 n +0000034558 00000 n +0000034640 00000 n +0000034730 00000 n +0000034802 00000 n +0000034874 00000 n +0000034947 00000 n +0000035020 00000 n +0000035093 00000 n +0000035223 00000 n +0000035295 00000 n +0000035410 00000 n +0000035500 00000 n +0000035573 00000 n +0000035646 00000 n +0000035719 00000 n +0000035792 00000 n +0000035922 00000 n +0000036011 00000 n +0000036083 00000 n +0000036156 00000 n +0000036229 00000 n +0000036302 00000 n +0000036452 00000 n +0000036524 00000 n +0000036623 00000 n +0000036706 00000 n +0000036779 00000 n +0000036852 00000 n +0000036925 00000 n +0000037051 00000 n +0000037132 00000 n +0000037205 00000 n +0000037278 00000 n +0000037444 00000 n +0000037525 00000 n +0000037598 00000 n +0000037671 00000 n +0000037797 00000 n +0000037899 00000 n +0000037972 00000 n +0000038045 00000 n +0000038118 00000 n +0000038232 00000 n +0000038346 00000 n +0000038505 00000 n +0000038668 00000 n +0000038740 00000 n +0000038837 00000 n +0000038938 00000 n +0000039010 00000 n +0000039169 00000 n +0000039242 00000 n +0000039417 00000 n +0000039489 00000 n +0000039586 00000 n +0000039683 00000 n +0000039755 00000 n +0000039914 00000 n +0000039987 00000 n +0000040162 00000 n +0000040234 00000 n +0000040331 00000 n +0000040404 00000 n +0000040525 00000 n +0000040597 00000 n +0000040756 00000 n +0000040829 00000 n +0000041000 00000 n +0000041072 00000 n +0000041187 00000 n +0000041317 00000 n +0000041390 00000 n +0000041467 00000 n +0000041561 00000 n +0000041921 00000 n +0000041958 00000 n +0000042009 00000 n +0000042060 00000 n +0000042111 00000 n +0000042163 00000 n +0000042216 00000 n +0000042267 00000 n +0000042319 00000 n +0000042371 00000 n +0000042423 00000 n +0000042475 00000 n +0000042526 00000 n +0000042578 00000 n +0000042630 00000 n +0000042681 00000 n +0000042731 00000 n +0000042782 00000 n +0000042832 00000 n +0000043035 00000 n +0000043192 00000 n +0000043735 00000 n +0000043949 00000 n +0000044108 00000 n +0000044563 00000 n +0000044782 00000 n +0000044942 00000 n +0000045685 00000 n +0000045904 00000 n +0000046044 00000 n +0000046260 00000 n +0000046499 00000 n 0000046653 00000 n -0000046807 00000 n -0000047015 00000 n -0000047226 00000 n -0000047371 00000 n -0000047591 00000 n -0000047843 00000 n -0000047971 00000 n -0000048053 00000 n -0000048656 00000 n -0000053218 00000 n -0000053299 00000 n -0000053850 00000 n -0000057595 00000 n -0000057677 00000 n -0000058386 00000 n -0000065259 00000 n -0000065341 00000 n -0000066130 00000 n -0000079207 00000 n -0000079284 00000 n -0000079724 00000 n -0000080366 00000 n -0000080443 00000 n -0000080886 00000 n -0000084832 00000 n -0000104457 00000 n -0000104864 00000 n -0000104977 00000 n -0000106050 00000 n +0000046861 00000 n +0000047072 00000 n +0000047217 00000 n +0000047437 00000 n +0000047691 00000 n +0000047819 00000 n +0000047901 00000 n +0000048504 00000 n +0000052996 00000 n +0000053077 00000 n +0000053628 00000 n +0000057373 00000 n +0000057455 00000 n +0000058166 00000 n +0000065019 00000 n +0000065101 00000 n +0000065887 00000 n +0000078973 00000 n +0000079050 00000 n +0000079490 00000 n +0000080132 00000 n +0000080209 00000 n +0000080667 00000 n +0000084870 00000 n +0000105798 00000 n +0000106205 00000 n +0000106318 00000 n +0000107391 00000 n trailer -<> +<> startxref -106237 +107578 %%EOF \ No newline at end of file diff --git a/docs/typ/cheatsheet.typ b/docs/typ/cheatsheet.typ index 1291d838..c4be1641 100644 --- a/docs/typ/cheatsheet.typ +++ b/docs/typ/cheatsheet.typ @@ -7,20 +7,21 @@ == The mouse #pairs( btn("B1"), [select, and focus the pane. On a tag: type there.], - btn("B2"), [*execute* the word or selection: a builtin, else a shell line.], - btn("B3"), [*look*: open the file, address, directory or URL, else find the word's next place. Resting the pointer tints what B3 would take.], - [sweep], [drag B2 or B3 to run or look at exactly what you swept.], + btn("B2"), [#word("Exec") the word or selection: a builtin, else a shell line.], + btn("B3"), [#word("Look"): open the file, address, directory or URL, else find the word's next place. Resting the pointer tints what #btn("B3") would take.], + [sweep], [drag #btn("B2") or #btn("B3") to #word("Exec") or #word("Look") exactly what you swept.], [grip], [drag the box left of a tag: up/down resizes, onto another column moves the pane. A column's right edge drags its width.], ) === Chords: hold the first, click the next #pairs( - chord("B1", "B2"), [cut the B1 selection], + chord("B1", "B2"), [cut the #btn("B1") selection], chord("B1", "B3"), [paste over it], - chord("B1", "B2", "B3"), [copy: cut, then paste back, B1 still down], - chord("B2", "B1"), [execute the word with the B1 selection as argument (#word("Grep") on a selected name)], + chord("B1", "B2", "B3"), [copy: cut, then paste back, #btn("B1") still down], + chord("B2", "B1"), [#word("Exec") the word with the #btn("B1") selection as argument (#word("Grep") on a selected name)], chord("B2", "B3"), [cancel the sweep (#chord("B3", "B2") too)], ) Over a program that takes the mouse, Shift swaps: #btn("B1", shift: true) selects, #btn("B2", shift: true) goes to the program. +One button: Alt/Option-click is #btn("B2"), Cmd/Super-click #btn("B3"), sweeps too (a terminal passes only Alt); Ctrl-click is a definition; a program that takes the mouse gets the plain click. == Tags #tag("Newcol Joincol Find Grep Help Changelog Tutor Dump Themes Config Debug Exit") @@ -28,17 +29,17 @@ Over a program that takes the mouse, Shift swaps: #btn("B1", shift: true) select #tag("Save Tty Collapse Del", path: "/home/me/notes.txt") #tag("Tty+bash Save Mode Filter Collapse Del", path: "/home/me/src") #tag("Tty PdfSections PdfTint Collapse Del", path: "manual.pdf [1/12]") -- #word("Del") over unsaved text refuses once; again discards. `Del j`: rows below. +- #word("Del") over unsaved text refuses once; again discards. #word("Del") `j`: rows below. - #word("Undo") #word("Redo") #word("Edit") #word("Mode") work typed anywhere. #doc("tags") -== Look addresses +== #word("Look") addresses Typed anywhere, then #btn("B3") or #key("Enter"): #pairs( addr("file:12"), [line 12], addr("file:12:5"), [line 12, byte column 5], addr("file:/re/"), [next match after the selection (`file:0/re/`: first)], addr(":40"), [the pane looked from, line 40 (`:40:5`, any address after `:`)], - addr("~/x"), [home; also in `Save`, `Restore`, `pardes ~/x`], + addr("~/x"), [home; also in #word("Save"), #word("Restore"), `pardes ~/x`], addr("@p3:12"), [pane 3 by serial, a terminal's lines too], addr("src/"), [a directory: `ls` in an idle terminal there, else a new one], ) @@ -63,7 +64,7 @@ Helix-style: motions *select*, then an edit acts on the selection. Mode box: bla [#key("|")], [pipe each selection through the shell], [#keys("g d", "g r")], [definition, references (language server)], [#keys("Ctrl-d", "Ctrl-u")], [half page down, up], - [#keys("Enter", "Tab")], [look, execute the selection (like #btn("B3"), #btn("B2"))], + [#keys("Enter", "Tab")], [#word("Look"), #word("Exec") the selection (like #btn("B3"), #btn("B2"))], [#key(":")], [to the pane's tag and back], ) #doc("keys") @@ -112,7 +113,7 @@ Helix-style: motions *select*, then an edit acts on the selection. Mode box: bla == Terminals and commands - #key("Ctrl-b"): raw (`$`) or normal. #word("Mode") cycles raw, normal, insert. #word("Filter"), #word("Tty+bash"). - #btn("B2") on a non-builtin line runs it in a *command pane*: #tag("Kill Save Collapse Del", path: "/home/me/src (make) exit 0") -- #word("Kill") `make` stops it; #word("Exit") quits. `Repl python`: `.py` clicks go to it. +- #word("Kill") `make` stops it; #word("Exit") quits. #word("Repl") `python`: `.py` clicks go to it. == Reviewing diffs `git diff` output is a diff: #btn("B3") on a file line, an `@@` or a line's `+`/`-` jumps there. #doc("tags", section: "reviewing-diffs") @@ -124,7 +125,7 @@ Helix-style: motions *select*, then an edit acts on the selection. Mode box: bla `pardes --detach=work`; `--attach=work` or #word("Attach") `work`; #word("Detach") leaves it running. #doc("detached") == Config -#word("Config") (#key("SPC f c")): `~/.config/pardes/init`, a builtin a line (`Theme atelier`). #word("DumpConfig"): every setting. #word("Dump") / #word("Restore"): the workspace. #doc("config") +#word("Config") (#key("SPC f c")): `~/.config/pardes/init`, a builtin a line (#word("Theme") `atelier`). #word("DumpConfig"): every setting. #word("Dump") / #word("Restore"): the workspace. #doc("config") == Themes #word("Themes") lists them; #word("Theme") `name`; #word("NextColor"); #word("ThemeFile") `x.zon`. #doc("themes") @@ -139,7 +140,7 @@ Pane shells get `$PARDES_9P` (the socket) and `$PARDES_PANE` (their own pane); a file("log"), [events; write `follow` to wait], file("pane/new"), [open to make a pane], file("pane/N/addr"), [an address; `data` reads/replaces it], - file("pane/N/ctl"), [builtins: `Save`, `Edit ...`], + file("pane/N/ctl"), [builtins: #word("Save"), #word("Edit") `...`], file("pane/N/body tag"), [its text (`>>` appends)], ) #cmd("echo notes.txt:12 > $m/pane/$n/look") diff --git a/docs/typ/guide.typ b/docs/typ/guide.typ index 7144c249..d07ab6cd 100644 --- a/docs/typ/guide.typ +++ b/docs/typ/guide.typ @@ -3,9 +3,10 @@ // keys on the cheatsheet. #import "style.typ": key, keys, btn, chord, word, tag, addr, file, cmd, doc, pairs, glossary -pardes reads the text on its screen as things to do. Right-click any text to *look* at it: open the `file:line`, address or URL it names, or -else find the text. Middle-click it to *execute* it: run the -builtin it names, or else run it as a shell line. Everything else is where +pardes reads the text on its screen as things to do, with two builtins. +#word("Look") (right-click): open the `file:line`, address or URL the text +names, or else find the text. #word("Exec") (middle-click): run the builtin +the text names, or else run it as a shell line. Everything else is where that happens: columns of panes, each a tag (a line of words) over a body that is a file you edit, a terminal, a PDF or an image, with a tag for each column and the workspace above. The keys are helix's, in modes, and every @@ -19,7 +20,7 @@ session is also a virtual filesystem, served over 9P, for scripts. [command pane], [a terminal that runs one command line and shows its output], [`+` names], [panes pardes makes, named in their directory: `+New` a scratch (text with no file yet), `+Search` a listing of places, `+Pager` paged text, `+Errors` output, `+Unsaved` the panes holding unsaved text], [serial], [a pane's number, never reused: the `3` in `@p3:12` and in 9P paths], - [message row], [the line where pardes says what happened, and asks: answer a prompt (a search, Save's path) with #key("Enter"), cancel it with #key("Esc")], + [message row], [the line where pardes says what happened, and asks: answer a prompt (a search, #word("Save")'s path) with #key("Enter"), cancel it with #key("Esc")], [the box], [left of a pane's tag: drag it to move or resize the pane; it shows the mode, and marks unsaved text (`*`, or filled in the window)], ) @@ -59,15 +60,17 @@ you out of raw mode first. #pairs( btn("B1"), [select; a click puts the cursor there and gives the pane the keyboard. In a tag it starts typing, in insert mode. A double click selects the word; at a line's start or end, the line; just inside a bracket or quote, up to its match.], - btn("B2"), [execute: a builtin word runs, anything else is a shell line.], - btn("B3"), [look: open the file, address, directory or URL, else find the word's next place.], + btn("B2"), [#word("Exec"): a builtin word runs, anything else is a shell line.], + btn("B3"), [#word("Look"): open the file, address, directory or URL, else find the word's next place.], ) +With one button, as on a trackpad, Alt-click (Option on a Mac) is #btn("B2") and Super-click (Cmd) is #btn("B3"), sweeps included; Ctrl-click stays the language server's definition, a program that takes the mouse gets the plain click, and in a terminal only Alt-click works, since Super never reaches pardes there. + A middle- or right-click with no drag takes the word under it: the run of letters, digits and `. - + / : @ _ ~`, a trailing `:` dropped. So #btn("B3") on `src/bar.c:12:5:` in a compiler's error opens `src/bar.c` at line 12, column 5. Drag to say exactly what you mean. #key("Enter") and -#key("Tab") in normal mode look and execute. +#key("Tab") in normal mode are #word("Look") and #word("Exec"). Hold the left button and click the middle one to cut the selection, the right one to paste over it, both one after the other to copy. #key("y") yanks and @@ -109,7 +112,7 @@ shell. A command pane's tag says `running`, then `exit N`: #tag("Kill Save Collapse Del", path: "/home/me/src (make) exit 0") The next command for that directory reuses a finished command pane. -#word("Kill") stops what pardes started (`Kill make`: those whose line +#word("Kill") stops what pardes started (#word("Kill") `make`: those whose line starts with `make`); #word("Exit") quits pardes. A pane word from a column tag (#word("Save"), #word("Del")) acts on that column's pane with the keyboard, or its first. @@ -117,8 +120,8 @@ keyboard, or its first. Every other new pane goes into the *active column*: the column you last typed or left-clicked in, or the one that got the last new pane. It takes the keyboard, except a listing, which opens below the pane that -asked and leaves it the keyboard, so #keys("n", "N") walk the listing. A -look moves the keyboard but not the active column: #btn("B3") on a file +asked and leaves it the keyboard, so #keys("n", "N") walk the listing. +#word("Look") moves the keyboard but not the active column: #btn("B3") on a file already open in another column jumps there, and the next new pane still lands in the old column until you type or click. #word("Placement") `pardes` picks other rules (#doc("reference", section: "placement")). @@ -127,7 +130,7 @@ A column can be empty: closing its last pane leaves it. #word("Delcol") and #word("Joincol") take columns away. Closing the session's last pane quits pardes. -= Looking += Look #btn("B3") (or #key("Enter")) on a path opens it, or goes to the pane that already shows it; `file:12` goes to line 12, `file:/re/` to the next @@ -135,7 +138,7 @@ match of `re`, and the other address forms are on the cheatsheet. #key("/"), text and #key("Enter") list the lines holding it in a `+Search` and go to the first; #keys("n", "N") step through the rest. A directory types `ls` into a terminal idle there, else opens one there. A URL opens in the browser. A relative path is -looked for in the looking pane's directory, then in the directory of each +found in the directory of the pane the #word("Look") came from, then of each pane on the jump list, most recent first. #word("Find") `name` lists the files below the pane's directory whose @@ -160,7 +163,7 @@ over unsaved panes too. #tag("Tty+bash Save Mode Filter Collapse Del", path: "/home/me/src") - #word("Tty") opens a terminal in the pane's directory, #key("Alt-n") one in - the session's directory; `Tty+bash` picks the shell. + the session's directory; #word("Tty+bash") picks the shell. - #word("Del") closes a terminal and its shell at once, running or not, and a shell that exits closes its pane. - #word("Save") writes the scrollback to a path it asks for. @@ -169,7 +172,7 @@ over unsaved panes too. - In raw mode Ctrl-V types what you yanked, Ctrl-Shift-V the clipboard. - A program that tracks the mouse gets #btn("B1") and the wheel; #btn("B2") and #btn("B3") stay pardes's. Hold Shift to swap. -- `Repl python` in its tag makes #btn("B2") on a `.py` pane send the text +- #word("Repl") `python` in its tag makes #btn("B2") on a `.py` pane send the text to that REPL. - Paged output (`git log`, `man`) opens in a `+Pager` pane (#doc("setup", section: "pager")). @@ -195,8 +198,8 @@ Motions select what they cross, and an edit acts on the selection: #key("w") then #key("d") deletes a word. #key("x") selects lines, #key("v") extends, #key(";") collapses to the cursor. #key("s") makes a cursor per regex match and every edit acts at each. #key("/") is a substring search; the regexes -are on #key("s") and #key("S"). #keys("n", "N") step through everything a -look would open, across panes. Line end is #key("g l"). #key("SPC") starts +are on #key("s") and #key("S"). #keys("n", "N") step through everything +#word("Look") would open, across panes. Line end is #key("g l"). #key("SPC") starts the leader, #key("SPC ?") lists every path, #word("Help") every key and builtin, and #word("Tutor") (#key("SPC h t")) practises them. The language keys (#keys("g d", "g r"), `SPC l`) work once a server is installed diff --git a/docs/typ/reference.typ b/docs/typ/reference.typ index 0f9a9341..e79f9c4d 100644 --- a/docs/typ/reference.typ +++ b/docs/typ/reference.typ @@ -9,7 +9,10 @@ not .L), in acme's manner: panes, columns, tags and the session are files. Paths here are the served ones (#file("/pane/2/body")); through a mount they sit under the session's directory (`$m`; #doc("scripting", section: "find-the-session") says how to find it). The served #file("/README") is a -one-screen summary of this page. +one-screen summary of this page. Two builtins carry the core: #word("Look") (right-click): open what the +text names, or else find it; #word("Exec") (middle-click): run the builtin +it names, or else run it as a shell line. The files #file("look") and +#file("exec") take a line each, as those clicks would. = The tree @@ -57,7 +60,7 @@ is not UTF-8 `\xNN`, so a name decodes to the bytes it is. *Failure.* A write fails whenever what it asked for fails, and logs one `err : ` record, with no `msg`; a write that succeeds logs none. A refused write says why in the log's last `err` record, found -with `grep '^err' log | tail -1`: after a refused Del, Exit or Restore the +with `grep '^err' log | tail -1`: after a refused #word("Del"), #word("Exit") or #word("Restore") the newest line may be `new N .../+Unsaved`. Only writes log: a refused open or truncation (an OTRUNC open such as `> data` after a failed `addr`), create or remove answers its error alone, as do a write to @@ -68,7 +71,7 @@ itself (`bad value in control message; takes on, off "maybe"`); a ctl refusal quotes the offending word alone (`wrong #args in control message "Newcol"`). Through 9ns the kernel sees an errno 9ns reads from those words (cloud9's `fs.enameErrno`): the first of these that the words hold, case aside, wins, and anything else is EIO (`Modified`, an -`Edit` command pardes leaves out): +#word("Edit") command pardes leaves out): #pairs( [`control message`], [EINVAL], @@ -94,8 +97,8 @@ words hold, case aside, wins, and anything else is EIO (`Modified`, an The `err` record has the words; a shell sees only the errno. -Not failures: a look that finds nothing (it answers nothing and logs one -`err`), an Edit `x` that matches nothing, #word("Undo") with nothing to +Not failures: a #word("Look") that finds nothing (it answers nothing and logs one +`err`), an #word("Edit") `x` that matches nothing, #word("Undo") with nothing to undo (a `msg`), and a command pane's command, which ends in its own time with an `exit` record. @@ -108,8 +111,8 @@ lines are skipped. A line runs at its newline; the last one, unended, runs after its open is closed, the close answered first, so its failure is only its `err` in the log: end a write with a newline when its result matters (#doc("building", section: "writes-through-a-mount")). `> exec` (a -truncating open) is fine through a mount. An `Edit` whose `{` or `a`/`c`/`i` text is still -open waits for the next write on that open. A line or Edit block over +truncating open) is fine through a mount. An #word("Edit") whose `{` or `a`/`c`/`i` text is still +open waits for the next write on that open. A line or #word("Edit") block over 1 MiB is refused once (EINVAL), and the rest of it, through its newline, is dropped. @@ -163,18 +166,17 @@ read-only, 0222 write-only. = look and exec -A line written to #file("look") is a right-click on it, on the line as +A line written to #file("look") is #word("Look") on it, on the line as written: its leading blanks are its own (` return x` finds that -indented line, and a diff's blank context line ` ` is a look too); only its +indented line, and a diff's blank context line ` ` is a #word("Look") too); only its newline and `\r` go. An #file("exec") line's blanks at either end are -trimmed. The guide says what a look opens and where it looks for a relative -path (#doc("tags", section: "looking")); here is what is particular to the +trimmed. The guide says what #word("Look") opens and where it finds a relative path (#doc("tags", section: "looking")); here is what is particular to the files. - `file:12` selects line 12, newline included; `file:12:5` puts the caret at line 12, byte column 5; `file:` takes any address (below), *evaluated from the file's dot*: `file:/re/` finds the next match after - the selection, `file:0/re/` the first. A bare `:N` or `:N:M` (or any `:addr`) addresses the pane looked from. + the selection, `file:0/re/` the first. A bare `:N` or `:N:M` (or any `:addr`) addresses the pane the #word("Look") came from. `@p:` addresses a pane by serial, a terminal's logical lines too. - A leading `~` is the home directory (`$HOME`, else the passwd entry's; @@ -194,9 +196,9 @@ files. second number is a section, `file.pdf:PAGE:SECTION`, and only such rows are checked against the outline: a section not there, or not on that page, is a miss. -- A plain word selects its next place after dot, wrapping. `LookWord list` +- A plain word selects its next place after dot, wrapping. #word("LookWord") `list` on the root ctl lists a row per line holding it in a `+Search` pane - instead; the next word looked at in that directory refills it. In a + instead; the next word given to #word("Look") in that directory refills it. In a terminal a word is always listed, rows spelled `@p3:12:5-9`. A miss logs `err look: ...` (`no match for "zzq:#3"` quoting what @@ -205,22 +207,22 @@ for a line past a file's end, ` has no page 99` for a PDF's page; `: no match for regexp` or `: address out of range` when an address fails), opens nothing, and leaves #file("look") reading empty; the write succeeds. A `./x` or `../x` that is not there is such a miss too -(`look: ./x: no such file`). A look whose address fails says so and leaves open no file -it opened. A look of `file:12:` reads as `file:12`: a trailing colon is +(`look: ./x: no such file`). A #word("Look") whose address fails says so and leaves open no file +it opened. A #word("Look") of `file:12:` reads as `file:12`: a trailing colon is dropped, as a click leaves it off. A path too long to repeat whole gives up its middle to `…`. -A line written to #file("exec") is a middle-click: +A line written to #file("exec") is #word("Exec"): - A builtin word runs (#file("/commands") lists them). A builtin that needs its argument (#word("Msg"), #word("Mount"), #word("Find")) written bare is `wrong #args in control message "Msg"`, and so is one that takes none - written with one (`Config extra`). + written with one (#word("Config") `extra`). - A line starting with `#` is a comment, as in a shell: it runs as nothing, silently, here and in every ctl. - The language server's words ask about a file pane's text at its cursor (set it with #file("addr") and `dot=addr` first): #word("Hover") fills - `+Hover`; `Rename new` renames the symbol in the file and says how many + `+Hover`; #word("Rename") `new` renames the symbol in the file and says how many ranges it changed (on the message row, and so in the log) without listing them, and fails when there is nothing to rename. One that reaches other files applies nothing: it opens a `+Search` preview of the edits, which @@ -253,8 +255,7 @@ reused pane's #file("body") keeps every earlier run From a pane whose directory is gone nothing runs: `exec:

    : no such directory` (ENOENT). The root's #file("look") and #file("exec") act at the pane with the keyboard and log as -that pane's (with no pane at all, in the session's directory: a look opens -its file, making a column as #word("New") does, and an exec runs its +that pane's (with no pane at all, in the session's directory: a #word("Look") opens its file, making a column as #word("New") does, and an exec runs its command there); #file("/pane//look") and #file("exec") at pane n; #file("/tagexec") and #file("/col//exec") click in the workspace's or that column's tag, run commands in the session's directory, and log as @@ -263,7 +264,7 @@ at #file("/tagexec") and a column's exec: `not a session control message "Undo": A background job (`&`) outlives a command that exits on its own; its output goes on below `exit N` until it lets go of the pty. #word("Kill") -(root ctl) stops the commands pardes started: bare, all; `Kill make ls`, +(root ctl) stops the commands pardes started: bare, all; #word("Kill") `make ls`, those whose line starts with one of the words. For a command pane it signals the whole line, `&` jobs included; for a line typed into a shell only the foreground job (SIGTERM), and the shell decides the rest. With @@ -271,9 +272,9 @@ nothing running, named or not, it says `Kill: nothing running` and the write succeeds; words that name none of what runs fail it (`Kill: no running command has that first word`). #word("Kill") does not reach a REPL's code: use `sig INT` on its #file("pty/ctl"). -== Look paths and mounts +== Paths and mounts -A look resolves the OS filesystem first, then the editor's own tree. +#word("Look") resolves the OS filesystem first, then the editor's own tree. Explicit paths skip that search: #pairs( @@ -283,25 +284,25 @@ Explicit paths skip that search: [`/n/peer/pane/2/body`], [a mounted session: the peer's #file("/pane/2/body")], ) -`--mount=peer=work` or `Mount peer ` mounts a dial: `unix!/path`, +`--mount=peer=work` or #word("Mount") `peer ` mounts a dial: `unix!/path`, `/path`, `tcp!!`, a session name, or with `-Dquic` `quic!…`; a missing socket is ENOENT, `no such socket`; -`Unmount peer` removes it. #word("Mount") dials at once and fails if +#word("Unmount") `peer` removes it. #word("Mount") dials at once and fails if nothing answers (`dial failed: no answer`, `timed out`, `hung up`); with no dial it is `wrong #args`, and any other `x!y` `bad dial address`, both EINVAL. There are eight named mounts; `os` and `self` are reserved. #word("Unmount") refuses a mount a pane, a working directory or a pending -Save still uses. Mounts are dumped. +#word("Save") still uses. Mounts are dumped. -A session may open its own tree through a mount (a look at `$m/pane/2/body` +A session may open its own tree through a mount (a #word("Look") of `$m/pane/2/body` from the editor serving `$m`): requests are answered on the connection's task while the editor waits in its syscall. Through QUIC that still hangs. = The root ctl Reading #file("/ctl") gives every setting, one a line, in the words a write -takes (`Theme orchard`, `Verbose on`, `Placement acme`, `DumpDir `, -`Shell /bin/bash`, ...), so writing back what it reads changes nothing. +takes (#word("Theme") `orchard`, #word("Verbose") `on`, #word("Placement") `acme`, #word("DumpDir") ``, +#word("Shell") `/bin/bash`, ...), so writing back what it reads changes nothing. Writes take settings and session builtins (`scope = .session` in `src/builtins.zig`), acting at the pane with the keyboard: @@ -322,30 +323,30 @@ Writes take settings and session builtins (`scope = .session` in word, except that #word("Delcol") opens no `+Unsaved` pane: it names the panes only in its `unsaved` records and its notice. - #word("Dump") writes `pardes--