diff options
Diffstat (limited to 'src/Addon.zig')
| -rw-r--r-- | src/Addon.zig | 21 |
1 files changed, 11 insertions, 10 deletions
diff --git a/src/Addon.zig b/src/Addon.zig index 5219f2b1..030da7d4 100644 --- a/src/Addon.zig +++ b/src/Addon.zig @@ -351,11 +351,10 @@ pub fn loadedOf(ops: *const Kind.Ops, path: []const u8, hash: [32]u8, words: *[6 .ops = @intFromPtr(ops), .caps = .{ .tick = ops.tick != null, .key = ops.key != null, .mouse = ops.mouse != null, .ctl = ops.ctl != null, .jobs = ops.job_run != null, .load = ops.load != null, - // 2.1's: a library of 2.0 has no `search` to read, and Esc leaves it. - .search = h.abi & 0xffff >= 1 and ops.search != null, - .esc = h.abi & 0xffff >= 1 and ops.key != null, + .search = ops.search != null, .address = ops.address != null, - .v22 = h.abi & 0xffff >= 2, + .view = ops.view != null, + .pictures = h.flags & Kind.c.PA_PICTURES != 0, }, }; } @@ -560,13 +559,12 @@ pub fn landed(p: *Pardes, op: Op, pane: u8, l: Loaded) void { /// The panes of kind `name` that waited for it (placeholders), opened. pub fn reopenWaiting(p: *Pardes, name: []const u8) usize { - const k = p.kinds.byName(name) orelse return 0; + if (p.kinds.byName(name) == null) return 0; var n: usize = 0; + // Each from its file, as a Restore's (a file not here: it waits on). for (p.panes, 0..) |slot, id| if (slot) |pane| if (pane.addon) |s| if (!s.live and s.is(name)) { - s.ops = p.kinds.ops[k]; - s.gen = p.kinds.kinds[k].gen; - s.refused = .{}; - if (Kind.reopen(p, id, s, null)) n += 1; + dump.reviveSlot(p, id, s); + n += @intFromBool(s.live); }; return n; } @@ -607,7 +605,10 @@ fn swap(p: *Pardes, l: Loaded, why: *Why) bool { n.where_text.set(Kind.where(s, &place)); if (o.dump != null and l.caps.load) n.record = dump.slotRecord(s) catch return fail(why, "out of memory", .{}); } - if (!Kind.reopen(p, id, n, null)) return fail(why, "refused: a pane of it would not open again: {s}", .{n.refused.slice()}); + // From its file as it is, the record its small state. + const bytes: ?[]u8 = if (new_ops != null and n.path.len > 0) @import("fs.zig").read(p, n.path) catch null else null; + defer if (bytes) |b| p.gpa.free(b); + if (!Kind.reopen(p, id, n, bytes)) return fail(why, "refused: a pane of it would not open again: {s}", .{n.refused.slice()}); }; // Every pane opened: the old states go, the new take their slots. for (p.panes, 0..) |pslot, id| if (pslot) |pane| if (pane.addon) |s| if (fresh[id]) |n| { |
