summaryrefslogtreecommitdiff
path: root/src/ninep/ctl.zig
diff options
context:
space:
mode:
Diffstat (limited to 'src/ninep/ctl.zig')
-rw-r--r--src/ninep/ctl.zig31
1 files changed, 15 insertions, 16 deletions
diff --git a/src/ninep/ctl.zig b/src/ninep/ctl.zig
index 699b7833..49fe661d 100644
--- a/src/ninep/ctl.zig
+++ b/src/ninep/ctl.zig
@@ -366,7 +366,7 @@ pub fn readResults(p: *Pardes, req: Req) Reply {
const looking = if (tree.Node.target(req.node)) |t| switch (t) {
.top => |f| f == .look,
.pane => |pt| pt.file == .look,
- .col => false,
+ .col, .port => false,
} else false;
for (kept) |serial| if (!looking or p.paneBySerial(serial) != null)
out.print(p.gpa, "{d}\n", .{serial}) catch return Reply.fail(req.tag, E.NOMEM);
@@ -426,7 +426,7 @@ pub fn paneText(p: *Pardes, pane: *Pane, buf: *[pane_text_cap]u8) []const u8 {
pane.serial,
if (pane_files.tagOf(p, pane)) |tag| tag.len else |_| 0, // a length, as a stat's: none when the tag cannot be made
// A terminal's body is its history, read whole on an open's first read.
- if (pane.isTerminal()) panes.terminal.screenTextLen(pane) else pane_files.bodyOf(pane).len,
+ if (pane.isTerminal()) pardes.Term.scrollbackLen(pane.terminal) else pane_files.bodyOf(pane).len,
// A directory pane is one, as acme's isdir says.
@intFromBool(if (pane.file) |f| f.listing != null else false),
@intFromBool(pane_files.dirtyOf(pane)),
@@ -699,7 +699,7 @@ pub fn writePager(p: *Pardes, req: Req) Reply {
/// The text a /pager open wrote after its directory (`held`), a program's
/// output for a terminal, put in the +Pager `serial` as `pardes -` once
-/// wrote it to the body: through ghostty-vt (pager.zig), its colours kept
+/// wrote it to the body: through the terminal's parse (Term.page), its colours kept
/// as the pane's spans, one undo step, and left
/// clean. Reads of the pane are its plain text. The held bytes go either way.
pub fn fillPager(p: *Pardes, serial: u32, held: *std.ArrayList(u8)) error{OutOfMemory}!void {
@@ -708,7 +708,7 @@ pub fn fillPager(p: *Pardes, serial: u32, held: *std.ArrayList(u8)) error{OutOfM
const id = p.paneBySerial(serial) orelse return;
const pane = p.panes[id].?;
const f = if (pane.file) |*file| file else return;
- const page = try pardes.pager.parse(p.gpa, held.items);
+ const page = try pardes.Term.page(p.gpa, held.items);
held.clearAndFree(p.gpa);
if (page.text.len == 0 and f.content.len == 0) return page.deinit(p.gpa);
if (!pane.fs.nomark) panes.File.pushUndo(p, pane) catch |err| {
@@ -718,17 +718,7 @@ 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 in the +Pager's place, the +Pager closed. The keyboard stays
- // where it was, as a page's.
- if (f.pager_diff) {
- const keyboard = p.view().active;
- if (panes.Output.openDiff(p, id, f.path, f.content)) |hid| {
- // ponytail: the text is gone with it; Diff on the +Diff says no such file.
- p.removePane(id, hid) catch |err| p.reportError(id, "pager", err);
- } else |_| {}
- if (p.panes[keyboard] != null) p.view().active = keyboard;
- }
+ pardes.Plumb.paged(p, id);
}
/// The editor's step: the text of /pager opens closed unread goes in.
@@ -1889,6 +1879,7 @@ test "Mount dials its peer and fails, mounting nothing, when none answers; a loo
}
test "Term in a directory that is not there fails and makes no pane; a shell that never started answers a run" {
+ if (pardes.Term.ops == null) return error.SkipZigTest; // a shell
const p = try withFile(testing.allocator, "x\n");
defer p.deinit();
const serial = serialOf(p);
@@ -1981,6 +1972,7 @@ test "a script's Grep and Find fill the pane's one query pane, a row a line unde
}
test "a terminal told the directory it already goes by logs no rename" {
+ if (pardes.Term.ops == null) return error.SkipZigTest; // a shell
const p = try withFile(testing.allocator, "x\n");
defer p.deinit();
_ = wr(p, Node.of(serialOf(p), .name), "/tmp/f.txt\n");
@@ -2029,6 +2021,7 @@ test "a terminal with text typed at its prompt is never typed into: a look at it
}
test "a command line from a missing directory fails ENOENT and makes no pane; a command whose shell never started ends 127" {
+ if (pardes.Term.ops == null) return error.SkipZigTest; // a command pane
const p = try withFile(testing.allocator, "x\n");
defer p.deinit();
p.host = .{ .vtable = &th.starting };
@@ -2188,6 +2181,7 @@ test "a failure said while a 9P write waits on it posts no msg, only the write's
}
test "with no pane at all, the root look opens its file and the root exec runs in the session's directory" {
+ if (pardes.Term.ops == null) return error.SkipZigTest; // a command pane
const p = try withFile(testing.allocator, "x\n");
defer p.deinit();
var tmp = testing.tmpDir(.{});
@@ -2248,6 +2242,7 @@ test "a restored pane whose file is gone from disk comes back dirty, and Del ask
test "a focus moved over 9P tells the programs that asked for focus reports, as a click does" {
+ if (pardes.Term.ops == null) return error.SkipZigTest; // a shell
const p = try Pardes.init(testing.allocator, .{ .cols = 90, .rows = 30, .shells = 2 });
defer p.deinit();
while (p.nextEffect()) |_| {}
@@ -2376,6 +2371,7 @@ test "/recent shows a name as /index does, a newline in it escaped" {
}
test "size is monotonic: growing is never refused, and a size once taken is taken again" {
+ if (pardes.Term.ops == null) return error.SkipZigTest; // a shell
const p = try Pardes.init(testing.allocator, .{ .tty_only = true, .cols = 160, .rows = 60 });
defer p.deinit();
while (p.nextEffect()) |_| {}
@@ -2612,6 +2608,7 @@ test "@p<terminal>:<address> takes any address over the terminal's lines, select
}
test "what a /pager open writes after its directory is the text: plain in the body, its colours the pane's, clean, in by the read" {
+ if (pardes.Term.ops == null) return error.SkipZigTest; // the emulator's parse of colours
const p = try withFile(testing.allocator, "x\n");
defer p.deinit();
const pager = @backingInt(tree.TopFile.pager);
@@ -2648,7 +2645,7 @@ test "what a /pager open writes after its directory is the text: plain in the bo
try testing.expectEqual(@as(usize, 0), e.off);
try testing.expectEqual(@as(usize, 0), e.removed.len);
try testing.expectEqual(f.content.len, e.ins);
- // An edit drops the colours (pager.zig's ponytail).
+ // An edit drops the colours (Term.page's ponytail).
try testing.expectEqual(Status.ok, call(p, .{ .tag = 6, .op = .write, .node = Node.of(pn.serial, .body), .data = "more\n" }).reply.status);
try testing.expectEqual(@as(usize, 0), f.pager_spans.len);
// Undone back to the paged text: the text comes back, its colours
@@ -2680,6 +2677,7 @@ test "what a /pager open writes after its directory is the text: plain in the bo
}
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" {
+ if (pardes.Term.ops == null) return error.SkipZigTest; // a command pane
const p = try withFile(testing.allocator, "x\n");
defer p.deinit();
const exec = Node.of(serialOf(p), .exec);
@@ -2727,6 +2725,7 @@ test "a body write to an image pane says its body takes none, not that terminals
}
test "Term+bash on a pane ctl is Term with its argument, as exec and the tag take it" {
+ if (pardes.Term.ops == null) return error.SkipZigTest; // a shell
const p = try withFile(testing.allocator, "x\n");
defer p.deinit();
// Tty+sh too: Term's old name, as a saved tag holds it.