diff options
Diffstat (limited to 'src/kinds/addon.zig')
| -rw-r--r-- | src/kinds/addon.zig | 18 |
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]); |
