summaryrefslogtreecommitdiff
path: root/src/Addon.zig
diff options
context:
space:
mode:
authorGabriel Schneider <[email protected]>2026-11-06 05:19:21 -0300
committerGabriel Schneider <[email protected]>2026-11-06 05:55:49 -0300
commitc8553032ef84aec74cbb5d07d07f934eecf3d4a9 (patch)
treee47d3dd72b83e0b95d53271df9f5932dab389959 /src/Addon.zig
parentde0447471febe1253b42a32fe9a1d6cdccc9d5b9 (diff)
downloadpardes-c8553032ef84aec74cbb5d07d07f934eecf3d4a9.tar.gz
pardes-c8553032ef84aec74cbb5d07d07f934eecf3d4a9.zip
kinds #9, the core's image code gone: src/image.zig (558 lines) and the static table go, so no kind is compiled in (Registry.init, Kind.image, compiledIn, `static` in /addons and "is compiled in" with them) and a test of the core's side of a kind's pane opens Kind.test_kind (a picture of one pixel, no library); a placement's fit (NativeGeometry, containGeometry) moves to surface.zig and a PDF's fit modes to pdf_view.zig; a terminal's kitty PNG decodes in TerminalImages.zig through wuffs as before, its downscale through stb_image_resize, the one part of zstbi the core keeps (stb_image patched out of it, the wuffs_images option, tag_image and image_exts gone); the image cases load the built image.so by path: test/panes.zig's and fs_namespace's through Addon.perform, T1 through Addon load (a new behaviour case: PNG, JPEG and PPM through 9P, the art words, a refused corrupt PNG, a dump's placeholder and its picture back, which replaces the decode unit test and ctl.zig's corrupt-image case), the snapshot, process and image harnesses by linking it into each session's data directory; images.snap unchanged
Co-Authored-By: Claude Fable 5.1 <[email protected]> Claude-Session: https://claude.ai/code/session_016Y9MNAtZenFv4weoMD3cge
Diffstat (limited to 'src/Addon.zig')
-rw-r--r--src/Addon.zig13
1 files changed, 6 insertions, 7 deletions
diff --git a/src/Addon.zig b/src/Addon.zig
index 4a387afa..6955741d 100644
--- a/src/Addon.zig
+++ b/src/Addon.zig
@@ -294,7 +294,7 @@ pub const Loaded = struct {
name: []const u8 = "",
version: u32 = 0,
abi: u32 = 0,
- /// The library file's BLAKE3; zero for a kind compiled in.
+ /// The library file's BLAKE3; zero for one never read.
hash: [32]u8 = @splat(0),
caps: Kind.Caps = .{},
path: []const u8 = "",
@@ -372,7 +372,7 @@ pub fn take(r: *Kind.Registry, l: Loaded, except: []const u8) ?[]const u8 {
r.n += 1;
return e.why.slice();
}
- e.why.set(if (e.compiledIn()) "static" else "loaded");
+ e.why.set("loaded");
r.ops[r.n] = if (tape.replaying()) null else @ptrFromInt(l.ops);
for (l.words) |w| {
r.words[r.nwords] = .{ .kind = r.n, .arg = w.arg, .opens = w.opens };
@@ -462,7 +462,7 @@ pub fn run(p: *Pardes, id: usize, arg: ?[]const u8) void {
if (a.len == 0) {
var w: std.Io.Writer = .fixed(&said);
w.writeAll("addons:") catch {};
- for (p.kinds.kinds[0..p.kinds.n]) |*e| if (!e.refused) w.print(" {s} {d}{s}", .{ e.nameOf(), e.version, if (e.compiledIn()) " (compiled in)" else "" }) catch {};
+ for (p.kinds.kinds[0..p.kinds.n]) |*e| if (!e.refused) w.print(" {s} {d}", .{ e.nameOf(), e.version }) catch {};
return p.setMessage(id, w.buffered());
}
const takes = "Addon takes load <path>, unload <name> or reload <name>";
@@ -478,7 +478,6 @@ pub fn run(p: *Pardes, id: usize, arg: ?[]const u8) void {
}
const k = p.kinds.byName(rest) orelse return p.reportFailure(id, std.fmt.bufPrint(&said, "Addon {t}: no addon brought kind {s}", .{ op, rest }) catch takes);
const e = &p.kinds.kinds[k];
- if (e.compiledIn()) return p.reportFailure(id, std.fmt.bufPrint(&said, "Addon {t}: {s} is compiled in", .{ op, rest }) catch takes);
if (op == .reload) return p.emit(.{ .addon = .{ .op = .reload, .pane = @intCast(id), .arg = .from(e.path.slice()) } });
const n = openPanes(p, rest);
if (n > 0) return p.reportFailure(id, std.fmt.bufPrint(&said, "Addon unload: {d} {s} pane{s} open", .{ n, rest, if (n == 1) " is" else "s are" }) catch takes);
@@ -551,7 +550,7 @@ pub fn reopenWaiting(p: *Pardes, name: []const u8) usize {
/// generation (a job the old one asked for is dropped as it answers).
fn swap(p: *Pardes, l: Loaded, why: *Why) bool {
const k = for (p.kinds.kinds[0..p.kinds.n], 0..) |*e, i| {
- if (!e.refused and !e.compiledIn() and std.mem.eql(u8, e.path.slice(), l.path)) break @as(u8, @intCast(i));
+ if (!e.refused and std.mem.eql(u8, e.path.slice(), l.path)) break @as(u8, @intCast(i));
} else return fail(why, "no addon was loaded from it", .{});
const name = p.kinds.kinds[k].nameOf();
if (l.why.len > 0) return fail(why, "{s}", .{l.why});
@@ -612,12 +611,12 @@ fn fail(why: *Why, comptime fmt: []const u8, args: anytype) bool {
}
/// /addons: `<kind> <version> <abi> <panes open> <path> <blake3>
-/// static|loaded|refused: why` a line (`-` for no path, no hash).
+/// loaded|refused: why` a line (`-` for no path, no hash).
pub fn list(p: *const Pardes, out: *std.ArrayList(u8), gpa: std.mem.Allocator) !void {
for (p.kinds.kinds[0..p.kinds.n]) |*e| {
const name = if (e.nameOf().len > 0) e.nameOf() else std.fs.path.basename(e.path.slice());
try out.print(gpa, "{s} {d} {d}.{d} {d} {s} ", .{ name, e.version, e.abi >> 16, e.abi & 0xffff, if (e.refused) 0 else openPanes(p, name), if (e.path.len > 0) e.path.slice() else "-" });
- if (e.compiledIn()) try out.append(gpa, '-') else try out.print(gpa, "{x}", .{e.hash});
+ if (std.mem.allEqual(u8, &e.hash, 0)) try out.append(gpa, '-') else try out.print(gpa, "{x}", .{e.hash});
try out.print(gpa, " {s}\n", .{e.why.slice()});
}
}