summaryrefslogtreecommitdiff
path: root/src/kinds
diff options
context:
space:
mode:
Diffstat (limited to 'src/kinds')
-rw-r--r--src/kinds/addon.zig6
-rw-r--r--src/kinds/pardes_addon.h14
2 files changed, 18 insertions, 2 deletions
diff --git a/src/kinds/addon.zig b/src/kinds/addon.zig
index 54f26893..557547f6 100644
--- a/src/kinds/addon.zig
+++ b/src/kinds/addon.zig
@@ -45,7 +45,9 @@ comptime {
/// `ctl`; `leader` is the keys after Space that run it ("ng": SPC n g).
pub const Word = struct { name: [:0]const u8, leader: ?[:0]const u8 = null, arg: enum(u8) { none, optional, required } = .none, opens: bool = false, doc: [:0]const u8 = "" };
/// `pictures`: its panes place pictures, and their tag says how they show.
-pub const Head = struct { name: []const u8, version: u32, exts: [:0]const u8 = "", words: []const Word = &.{}, pictures: bool = false };
+/// `plain`: PA_PLAIN, the kind is its extern struct and its step pure (the
+/// header says what that promises): a client runs it itself.
+pub const Head = struct { name: []const u8, version: u32, exts: [:0]const u8 = "", words: []const Word = &.{}, pictures: bool = false, plain: bool = false };
/// pardes's side, kept from init: about the pane of the current call.
pub var api: *const c.pa_api = undefined;
@@ -352,7 +354,7 @@ pub fn ops(comptime T: type) c.pa_ops {
if (T.head.name.len > 15) @compileError(@typeName(T) ++ "'s name " ++ T.head.name ++ " is over 15 bytes");
var name: [16]u8 = @splat(0);
@memcpy(name[0..T.head.name.len], T.head.name);
- 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 } };
+ 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) | (if (T.head.plain) c.PA_PLAIN 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" },
diff --git a/src/kinds/pardes_addon.h b/src/kinds/pardes_addon.h
index 9c101fee..586b03d3 100644
--- a/src/kinds/pardes_addon.h
+++ b/src/kinds/pardes_addon.h
@@ -275,6 +275,20 @@ typedef struct pa_tick {
/* head.flags: its panes show pictures, and the core says how in their tag
* (`petscii:on palette:commodore ascii:off`, Petscii, Palette, Ascii). */
#define PA_PICTURES 0x1u
+/* head.flags: its state is plain and its step pure. The kind's whole state
+ * is the one block its `open` allocates with api->alloc (any other alloc
+ * is refused): bytes with no pointer or handle in them, changed only by its
+ * calls, each a function of the block and what the call is handed (no
+ * statics, no clock, randomness or file of its own: the time is tick's
+ * `now`, a seed api->seed's; tick is never told PA_FRAMED, a frame being
+ * one view's). pardes keeps the block where its own state is (its digest, a
+ * client's rollback copy) and dumps it as it is, `dump` uncalled and `load`
+ * given it at a Restore; so a client of the session runs the kind itself
+ * from the session's very bytes, its keys at once
+ * and its pictures its own, and a client without the addon shows a line.
+ * A kind that breaks the promise is caught: the client's state is not the
+ * session's, and it joins again without the kind. */
+#define PA_PLAIN 0x2u
typedef struct pa_head {
uint32_t size, abi;