summaryrefslogtreecommitdiff
path: root/src/kinds/addon.zig
diff options
context:
space:
mode:
authorGabriel Schneider <[email protected]>2026-11-12 10:56:42 -0300
committerGabriel Schneider <[email protected]>2026-11-17 12:15:01 -0300
commitf2b02c455f2bcdfb905a015eefbb630a28b4b12e (patch)
treec344c7ad42ec288dd5e1ebd0eb6d25f5aa2fbccc /src/kinds/addon.zig
parentfc38c73c59f7855a4caad8aa4d3bb8e023309c13 (diff)
downloadpardes-f2b02c455f2bcdfb905a015eefbb630a28b4b12e.tar.gz
pardes-f2b02c455f2bcdfb905a015eefbb630a28b4b12e.zip
addons: an addon can hand the frontend a GPU scene (ABI 3.1), and a snake drawn by shaders does; a commit's patch keeps its own +Diff pane; a real ZLS checked through the window build
ABI 3.1 appends an optional `gpu` callback and its context to pa_paint: one self-contained sketchbook SGPU v1 scene for the pane, at most 4 MiB, copied during the call, the last successful call winning. The SDL frontend runs it on its own GPU through sketchbook's executor and composites its target texture into the pane; replicas carry the scene beside the authoritative pane frame; cells and rasters stay the fallback for terminals, older hosts and frontends without an executor. addons/snake_shader is such an addon (`zig build snake-shader`, the SnakeShader word: a board that follows its pane, buffered turns, a CRT look), with test/gpu_snake.py, test/gpu_snake_interaction.py and test/gpu_upgrade.py. Commit patches open as `+Diff-<short-hash>` and reuse only their own commit's pane, so another paged patch no longer replaces one already open. The language-server client looks in the standard per-user bin directory, which desktop launchers often leave out of PATH, and takes an empty answer that beats the startup progress notification onto the wire; test/real_zls.py checks imports, hover, references, rename previews, diagnostics and completion against a real ZLS from a private home. The dump's schema reader skips two fields older builds persisted, and a replica's shadow of a kind ticks when the authority's does. The reference, the guide, the building and setup notes and the changelog say so. The working copy as it stood on 2026-11-12; message written by Claude from the diff, at the author's request.
Diffstat (limited to 'src/kinds/addon.zig')
-rw-r--r--src/kinds/addon.zig18
1 files changed, 12 insertions, 6 deletions
diff --git a/src/kinds/addon.zig b/src/kinds/addon.zig
index 11635f7a..54f26893 100644
--- a/src/kinds/addon.zig
+++ b/src/kinds/addon.zig
@@ -36,9 +36,9 @@ pub const c = @import("pardes_addon");
const Allocator = std.mem.Allocator;
/// The ABI this file speaks: a header of another needs it brought along.
-pub const abi = 0x30000;
+pub const abi = 0x30001;
comptime {
- if (c.PA_ABI != abi) @compileError("addon.zig speaks ABI 3.0 and the header another");
+ if (c.PA_ABI != abi) @compileError("addon.zig speaks ABI 3.1 and the header another");
}
/// A word the kind brings: `opens` a pane of it, else goes to the pane's
@@ -157,6 +157,12 @@ pub const Window = struct {
/// as the header has them.
pub const Paint = struct {
out: *c.pa_paint,
+ /// Optional display data; always paint a text/raster fallback too.
+ pub fn gpu(p: Paint, bytes: []const u8) bool {
+ if (api.abi < 0x00030001 or bytes.len > 4 << 20) return false;
+ const emit = p.out.gpu orelse return false;
+ return emit(p.out.gpu_ctx, bytes.ptr, @intCast(bytes.len)) == c.PA_OK;
+ }
/// A picture over the cells (pa_placement), lowest first.
pub fn place(p: Paint, at: c.pa_placement) void {
if (p.out.n == p.out.cap) return;
@@ -349,10 +355,10 @@ pub fn ops(comptime T: type) c.pa_ops {
var o: c.pa_ops = .{ .init = F.init, .open = F.open, .paint = F.paint, .head = .{ .size = @sizeOf(c.pa_head), .abi = c.PA_ABI, .name = name, .version = T.head.version, .flags = if (T.head.pictures) c.PA_PICTURES else 0, .exts = T.head.exts, .words = &F.words, .nwords = F.words.len } };
// The kind's function, then the pa_ops field its wrapper fills.
const fns = .{
- .{ "close", "close" }, .{ "tick", "tick" }, .{ "prefix", "tick" }, .{ "view", "view" }, .{ "key", "key" },
- .{ "mouse", "mouse" }, .{ "body", "body_len" }, .{ "body", "body" }, .{ "address", "address" }, .{ "where", "where" },
- .{ "ctl", "ctl" }, .{ "ctlRead", "ctl_read" }, .{ "jobRun", "job_run" }, .{ "jobDone", "job_done" }, .{ "dump", "dump" },
- .{ "load", "load" }, .{ "search", "search" },
+ .{ "close", "close" }, .{ "tick", "tick" }, .{ "prefix", "tick" }, .{ "view", "view" }, .{ "key", "key" },
+ .{ "mouse", "mouse" }, .{ "body", "body_len" }, .{ "body", "body" }, .{ "address", "address" }, .{ "where", "where" },
+ .{ "ctl", "ctl" }, .{ "ctlRead", "ctl_read" }, .{ "jobRun", "job_run" }, .{ "jobDone", "job_done" }, .{ "dump", "dump" },
+ .{ "load", "load" }, .{ "search", "search" },
};
inline for (fns) |m| if (@hasDecl(T, m[0])) {
@field(o, m[1]) = @field(F, m[1]);