summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/ninep/ctl.zig8
-rw-r--r--src/ninep/pane.zig5
2 files changed, 12 insertions, 1 deletions
diff --git a/src/ninep/ctl.zig b/src/ninep/ctl.zig
index 7d8a370d..1fcd7a6d 100644
--- a/src/ninep/ctl.zig
+++ b/src/ninep/ctl.zig
@@ -4065,3 +4065,11 @@ test "a Save whose directory is missing because one above refuses says permissio
p.saveFailed(0, "/tmp/pardes-surely-missing-dir/f.txt", error.FileNotFound);
try testing.expect(th.logHas(p, "no such directory"));
}
+
+test "a body write to an image pane says its body takes none, not that terminals have no text" {
+ const p = try withFile(testing.allocator, "x\n");
+ defer p.deinit();
+ const doc = try p.newDocPane(p.freeSlot().?);
+ doc.image = .{ .path = try p.gpa.dupe(u8, "/tmp/pardes-pic.ppm") };
+ try testing.expectEqualStrings(pane_files.e_no_body, wr(p, Node.of(doc.serial, .body), "x").reply.ename);
+}
diff --git a/src/ninep/pane.zig b/src/ninep/pane.zig
index 3963c605..6a6b444f 100644
--- a/src/ninep/pane.zig
+++ b/src/ninep/pane.zig
@@ -662,7 +662,7 @@ 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) {
// An image's or a PDF's body is no text a write goes into.
- if (!pane.isTerminal()) return tree.failText(req.tag, E.INVAL, e_no_text);
+ if (!pane.isTerminal()) return tree.failText(req.tag, E.INVAL, e_no_body);
const take = wholeUtf8(req.data);
p.emitWrite(id, req.data[0..take]);
return .{ .tag = req.tag, .written = @intCast(take) };
@@ -760,6 +760,9 @@ pub fn applyTagTruncation(p: *Pardes, pane: *Pane) void {
/// A write only text takes, to a pane with none: said, as every EINVAL is.
pub const e_no_text = "invalid write: this pane has no text (a terminal, an image or a PDF)";
+/// A body write to a pane whose body is a picture: a terminal's takes one
+/// (its keys), so the word is not "no text".
+pub const e_no_body = "invalid write: an image's or a PDF's body takes no writes";
fn writeData(p: *Pardes, req: Req, pane: *Pane) Reply {
if (fileOf(pane) == null) return tree.failText(req.tag, E.INVAL, e_no_text);