diff options
| author | Gabriel Schneider <[email protected]> | 2026-09-28 13:18:44 -0300 |
|---|---|---|
| committer | Gabriel Schneider <[email protected]> | 2026-10-01 00:12:14 -0300 |
| commit | 905fd5a87a94b1183779494380dfb8d3d75e2926 (patch) | |
| tree | 287d045cccf072d61f388dcad4be5dacec380384 /src/ninep | |
| parent | 41fb292f314844d1f47e608fbdd4a34cfc8d5618 (diff) | |
| download | pardes-905fd5a87a94b1183779494380dfb8d3d75e2926.tar.gz pardes-905fd5a87a94b1183779494380dfb8d3d75e2926.zip | |
A terminal's body stats as long as it reads
stat said a terminal's body was 0 bytes while a read gave its screen and
history, and the docs promise real sizes; a client that sizes its read from
stat got nothing. The length is now that of the text a read answers, counted
the way the pane's ctl line already counts it.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Diffstat (limited to 'src/ninep')
| -rw-r--r-- | src/ninep/pane.zig | 18 |
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: { |
