summaryrefslogtreecommitdiff
path: root/src/ninep/ctl.zig
diff options
context:
space:
mode:
authorGabriel Schneider <[email protected]>2026-10-06 19:06:32 -0300
committerGabriel Schneider <[email protected]>2026-10-22 10:03:15 -0300
commit046979b877f02a91cf52cc86b84c5619cb9363d3 (patch)
treeb0a4696329949029aef88be34e242a45b1babfc4 /src/ninep/ctl.zig
parentd65ec3394ff619118d9208718477469c673a5598 (diff)
downloadpardes-046979b877f02a91cf52cc86b84c5619cb9363d3.tar.gz
pardes-046979b877f02a91cf52cc86b84c5619cb9363d3.zip
Def and Refs in a language-served file's tag, a diff viewer's tinted word edits, context rows that hold still under a scroll, and the pardes skill
Def and Refs (gd, gr, Ctrl-click; chorded 2-1 at the selection) for a file a language server speaks for; hunks.zig stacks a unified diff as a diff viewer does, its changed words on a tinted ground as delta's do; the tree-sitter context rows stay put while the body glides under a scroll; .agents/skills gains the pardes skill beside pardes-9p.
Diffstat (limited to 'src/ninep/ctl.zig')
-rw-r--r--src/ninep/ctl.zig41
1 files changed, 33 insertions, 8 deletions
diff --git a/src/ninep/ctl.zig b/src/ninep/ctl.zig
index c9ce41e1..e6e738a5 100644
--- a/src/ninep/ctl.zig
+++ b/src/ninep/ctl.zig
@@ -682,7 +682,7 @@ pub fn readRoot(p: *Pardes, req: Req) Reply {
}
/// /pager, `pardes -`'s: the directory written (empty, or not absolute: the
-/// session's) gets its one +Pager, made or emptied; the serial is what a
+/// session's) gets a new +Pager; the serial is what a
/// read of this same open answers, never another client's. What the open
/// writes after that line is the text, held by tree.zig for `fillPager`.
pub fn writePager(p: *Pardes, req: Req) Reply {
@@ -742,6 +742,16 @@ pub fn fillPager(p: *Pardes, serial: u32, held: *std.ArrayList(u8)) error{OutOfM
panes.File.setContent(p, f, page.text);
f.pager_spans = page.spans;
f.saved_revision = f.revision;
+ // A diff paged (`git show`, difftui's patches): its hunks stacked in a
+ // +Diff (DiffLook hunks), the +Pager folded to its tag under it for
+ // Diff to bring back. The keyboard stays where it was, as a page's.
+ if (f.pager_diff and p.settings.diff_look == .hunks) {
+ const keyboard = p.active;
+ if (panes.Output.openDiff(p, id, f.path, f.content)) |_| {
+ if (!pane.collapsed) pardes.layout.toggleCollapse(p, id);
+ } else |_| {}
+ if (p.panes[keyboard] != null) p.active = keyboard;
+ }
}
/// The editor's step: the text of /pager opens closed unread goes in.
@@ -2258,7 +2268,8 @@ test "a builtin for one kind of pane is refused on another, and still acts on it
.{ "Petscii\n", "Petscii: only an image or a terminal pane takes it" },
.{ "Palette\n", "Palette: only an image pane takes it" },
.{ "Ascii\n", "Ascii: only an image pane takes it" },
- .{ "Filter\n", "Filter: only a terminal pane takes it" },
+ .{ "Filter\n", "Filter: only a terminal or a +Pager pane takes it" },
+ .{ "Diff\n", "Diff: only a diff or a +Diff pane takes it" },
.{ "Togglettymode\n", "Togglettymode: only a terminal pane takes it" },
};
for (cases) |case| {
@@ -4607,10 +4618,15 @@ test "pager answers its +Pager on the open that asked, whatever another client e
try testing.expectEqual(E.INVAL, call(p, .{ .tag = 8, .op = .write, .node = pager, .handle = refused, .data = "relative\n" }).errno());
try testing.expectEqualStrings("", call(p, .{ .tag = 9, .op = .read, .node = pager, .handle = refused, .size = 64 }).bytes);
_ = call(p, .{ .tag = 10, .op = .release, .node = pager, .handle = refused, .opened = true });
- // Resolved: `/tmp/../tmp/.` is /tmp's +Pager, the one made above.
+ // Resolved: `/tmp/../tmp/.` is /tmp, a +Pager of its own beside the
+ // one made above, which keeps its page.
const resolved = call(p, .{ .tag = 11, .op = .open, .node = pager, .omode = 2 }).reply.handle;
try testing.expectEqual(Status.ok, call(p, .{ .tag = 12, .op = .write, .node = pager, .handle = resolved, .data = "/tmp/../tmp/.\n" }).reply.status);
- try testing.expectEqualStrings(want, call(p, .{ .tag = 13, .op = .read, .node = pager, .handle = resolved, .size = 64 }).bytes);
+ const second = call(p, .{ .tag = 13, .op = .read, .node = pager, .handle = resolved, .size = 64 }).bytes;
+ try testing.expect(!std.mem.eql(u8, want, second));
+ const second_pane = p.panes[p.paneBySerial(try std.fmt.parseInt(u32, std.mem.trim(u8, second, "\n"), 10)).?].?;
+ try testing.expectEqualStrings("/tmp/+Pager", second_pane.file.?.path);
+ try testing.expect(p.paneBySerial(paged) != null);
_ = call(p, .{ .tag = 14, .op = .release, .node = pager, .handle = resolved, .opened = true });
// One that may not be written is refused, permission denied.
try testing.expectEqual(E.PERM, wr(p, pager, "/proc/1\n").errno());
@@ -4667,15 +4683,24 @@ test "what a /pager open writes after its directory is the text: plain in the bo
// PagerColor off, and an open closed with no read: the same text, plain,
// in at the editor's next step (a close through a mount never waits).
p.settings.pager_color = false;
+ const kept = try testing.allocator.dupe(u8, f.content);
+ defer testing.allocator.free(kept);
const shut = call(p, .{ .tag = 7, .op = .open, .node = pager, .omode = 1 }).reply.handle;
try testing.expectEqual(Status.ok, call(p, .{ .tag = 8, .op = .write, .node = pager, .handle = shut, .data = "/tmp\n" }).reply.status);
try testing.expectEqual(Status.ok, call(p, .{ .tag = 9, .op = .write, .node = pager, .handle = shut, .data = "\x1b[1;32mgreen\x1b[m\n" }).reply.status);
_ = call(p, .{ .tag = 10, .op = .release, .node = pager, .handle = shut, .opened = true });
- try testing.expectEqualStrings("", f.content);
+ // A new +Pager: the first keeps its page.
+ try testing.expectEqualStrings(kept, f.content);
+ const next = for (p.panes) |slot| {
+ const other = slot orelse continue;
+ if (other == pn) continue;
+ if (other.file) |*of| if (std.mem.eql(u8, of.path, "/tmp/+Pager")) break of;
+ } else return error.NoPager;
+ try testing.expectEqualStrings("", next.content);
fillClosedPagers(p);
- try testing.expectEqualStrings("green\n", f.content);
- try testing.expectEqual(@as(usize, 0), f.pager_spans.len);
- try testing.expectEqual(f.revision, f.saved_revision);
+ try testing.expectEqualStrings("green\n", next.content);
+ try testing.expectEqual(@as(usize, 0), next.pager_spans.len);
+ try testing.expectEqual(next.revision, next.saved_revision);
}
test "a command pane an exec open was answered is leased to it while it stays open: another client's command gets a pane of its own" {