summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/ninep/pane.zig18
1 files changed, 17 insertions, 1 deletions
diff --git a/src/ninep/pane.zig b/src/ninep/pane.zig
index 6b6d5728..77be80c6 100644
--- a/src/ninep/pane.zig
+++ b/src/ninep/pane.zig
@@ -194,6 +194,20 @@ pub fn spliceBody(p: *Pardes, pane: *Pane, q0: usize, q1: usize, bytes: []const
return take;
}
+test "a terminal's body stats as long as it reads" {
+ const gpa = testing.allocator;
+ const p = try pardes.Pardes.init(gpa, .{ .tty_only = true, .cols = 80, .rows = 24 });
+ defer p.deinit();
+ while (p.nextEffect()) |_| {}
+ const pane = p.panes[0].?;
+ try testing.expect(pane.isTerminal());
+ p.update(.{ .output = .{ .pane = 0, .bytes = "$ ls\r\nalpha beta\r\n$ " } });
+ const body = Node.of(pane.serial, .body);
+ const whole = rd(p, body, 0, 1 << 16);
+ try testing.expect(whole.bytes.len > 0);
+ try testing.expectEqual(@as(u64, whole.bytes.len), call(p, .{ .tag = 1, .op = .getattr, .node = body }).reply.attr.size);
+}
+
// ---- what stat reports ----
/// A range file's text: acme's addr format, two right-aligned offsets, so
@@ -204,7 +218,9 @@ pub fn fileSize(p: *Pardes, id: usize, f: PaneFile) u64 {
const pane = p.panes[id] orelse return 0;
const pf = &pane.fs;
return switch (f) {
- .body, .data, .xdata => bodyOf(pane).len,
+ // A terminal's body reads its screen and history, as text.
+ .body => if (pane.file == null and pane.isTerminal()) panes.Terminal.screenTextLen(pane) else bodyOf(pane).len,
+ .data, .xdata => bodyOf(pane).len,
.tag => tagOf(p, pane).len,
.name => nameOf(pane).len + 1,
.ctl => ctl: {