summaryrefslogtreecommitdiff
path: root/src/ninep/ctl.zig
diff options
context:
space:
mode:
authorGabriel Schneider <[email protected]>2026-11-06 06:24:42 -0300
committerGabriel Schneider <[email protected]>2026-11-06 11:19:44 -0300
commitc1917b949b9580de8bf0977874a210f0266812da (patch)
tree447dd2235ea00634f662cd3becf4bceb8a895f41 /src/ninep/ctl.zig
parent76c55b5bce0f181b0b15b16596c900397dfef544 (diff)
downloadpardes-c1917b949b9580de8bf0977874a210f0266812da.tar.gz
pardes-c1917b949b9580de8bf0977874a210f0266812da.zip
kinds #14, the core's PDF code gone: pdf.zig and pdf_view.zig leave and every pdf_enabled branch with them; look, Jump, Recent, dumps (one from before the addon opens as its pane), the watch, mouse, keys, the rail and the tag go through Kind for any kind's pane; test/pdf.zig's behaviours are T1 cases over 9P (addons_pdf.zig) and pane cases (a Shadow over a replica, a file changed under it), the harnesses load pdf.so by path
Co-Authored-By: Claude Fable 5.1 <[email protected]> Claude-Session: https://claude.ai/code/session_016Y9MNAtZenFv4weoMD3cge
Diffstat (limited to 'src/ninep/ctl.zig')
-rw-r--r--src/ninep/ctl.zig54
1 files changed, 4 insertions, 50 deletions
diff --git a/src/ninep/ctl.zig b/src/ninep/ctl.zig
index 42d9f3bd..53128c5e 100644
--- a/src/ninep/ctl.zig
+++ b/src/ninep/ctl.zig
@@ -442,10 +442,9 @@ pub fn paneText(p: *Pardes, pane: *Pane, buf: []u8) []const u8 {
var idbuf: [48]u8 = undefined;
const id = exec_line.replId(&idbuf, pane);
if (id.len > 0) w.print("{s} ", .{id}) catch {};
- // Then what its tag does not say: Collapse, and a PDF's PdfFit and
- // PdfTint, in the words they take.
+ // Then what its tag does not say: Collapse, and a kind's own fields (a
+ // PDF's PdfFit and PdfTint, in the words they take).
if (pane.collapsed) w.writeAll("collapsed ") catch {};
- if (comptime pardes.pdf_enabled) if (pane.pdf) |pv| w.print("fit:{s} tint:{s} ", .{ @tagName(pv.fit), @tagName(pv.tint) }) catch {};
if (pane.addon != null) {
var fields: [128]u8 = undefined;
const kind_fields = pardes.Kind.ctlRead(pane, &fields);
@@ -1544,7 +1543,7 @@ test "an address looked at in an image pane names the image, never an empty subj
try testing.expect(th.logHas(p, "look: /tmp/pardes-pic.ppm is no text to address"));
}
-test "Save and Save path on an image pane are refused with why, never a silent success" {
+test "Save and Save path on a kind's pane (a picture) are refused with why, never a silent success" {
const p = try withFile(testing.allocator, "x\n");
defer p.deinit();
const id = p.freeSlot().?;
@@ -1552,7 +1551,7 @@ test "Save and Save path on an image pane are refused with why, never a silent s
for ([_][]const u8{ "Save\n", "Save /tmp/pardes-copy.ppm\n" }) |line| {
const r = wr(p, Node.of(doc.serial, .ctl), line);
try testing.expectEqual(Status.err, r.reply.status);
- try testing.expectEqualStrings("Save: an image pane has no text to save", r.reply.ename);
+ try testing.expectEqualStrings("Save: a test pane has no text to save", r.reply.ename);
}
}
@@ -1574,9 +1573,6 @@ test "a builtin for one kind of pane is refused on another, and still acts on it
try testing.expectEqual(Status.err, r.reply.status);
try testing.expectEqualStrings(case[1], r.reply.ename);
}
- if (pardes.pdf_enabled) for ([_][]const u8{ "PdfFit\n", "PdfTint\n", "PdfSections\n" }) |line| {
- try testing.expectEqual(Status.err, wr(p, Node.of(serial, .ctl), line).reply.status);
- };
const id = p.freeSlot().?;
// A picture shown: the core's art words follow the kind's prefix.
const doc = try pardes.Kind.open(p, id, pardes.Kind.test_kind.of(p), "/tmp/pardes-pic.ppm", "P6\n1 1\n255\n\x01\x02\x03");
@@ -2160,48 +2156,6 @@ test "a language server question that finds nothing, cannot be answered, or is a
try testing.expectEqual(E.INVAL, wr(p, Node.of(img.serial, .body), "text\n").errno());
}
-test "a truncated PDF fails its look with its path and why" {
- if (comptime !pardes.pdf_enabled) return;
- const p = try withFile(testing.allocator, "x\n");
- defer p.deinit();
- var tmp = testing.tmpDir(.{});
- defer tmp.cleanup();
- const bytes = try @import("mupdf").testFixture(testing.allocator, "links.pdf");
- defer testing.allocator.free(bytes);
- try tmp.dir.writeFile(testing.io, .{ .sub_path = "cut.pdf", .data = bytes[0..40] });
- var dir_buf: [4096]u8 = undefined;
- const dir = dir_buf[0..try tmp.dir.realPath(testing.io, &dir_buf)];
- var line: [4200]u8 = undefined;
- const r = wr(p, root_look, try std.fmt.bufPrint(&line, "{s}/cut.pdf\n", .{dir}));
- try testing.expectEqual(Status.err, r.reply.status);
- try testing.expect(std.mem.indexOf(u8, r.reply.ename, "cut.pdf: not a PDF pardes can read: ") != null);
-}
-
-test "a PDF's body reads its page's text layer, and takes no write" {
- if (comptime !pardes.pdf_enabled) return;
- const p = try withFile(testing.allocator, "x\n");
- defer p.deinit();
- var tmp = testing.tmpDir(.{});
- defer tmp.cleanup();
- const bytes = try @import("mupdf").testFixture(testing.allocator, "links.pdf");
- defer testing.allocator.free(bytes);
- try tmp.dir.writeFile(testing.io, .{ .sub_path = "doc.pdf", .data = bytes });
- var dir_buf: [4096]u8 = undefined;
- const dir = dir_buf[0..try tmp.dir.realPath(testing.io, &dir_buf)];
- var line: [4200]u8 = undefined;
- _ = wr(p, root_look, try std.fmt.bufPrint(&line, "{s}/doc.pdf\n", .{dir}));
- p.sync();
- const doc = p.panes[p.view().active].?;
- try testing.expect(doc.hasPdf());
- const body = Node.of(doc.serial, .body);
- try testing.expect(std.mem.indexOf(u8, rd(p, body, 0, 4096).bytes, "target.txt") != null);
- // Read from an offset, as a mount's chunked reads ask: the text from there.
- const whole = try testing.allocator.dupe(u8, rd(p, body, 0, 4096).bytes);
- defer testing.allocator.free(whole);
- try testing.expectEqualStrings(whole[3..], rd(p, body, 3, 4096).bytes);
- try testing.expectEqual(E.INVAL, wr(p, body, "more\n").errno());
-}
-
test "workspace symbols, Symbols and Diagnostics share their directory's one +Search" {
const p = try withFile(testing.allocator, "x\n");
defer p.deinit();