summaryrefslogtreecommitdiff
path: root/core
diff options
context:
space:
mode:
Diffstat (limited to 'core')
-rw-r--r--core/Addon.zig18
-rw-r--r--core/Effect.zig7
-rw-r--r--core/Kind.zig2
-rw-r--r--core/exec.zig3
-rw-r--r--core/replica.zig27
-rw-r--r--core/root.zig4
-rw-r--r--core/tape.zig3
7 files changed, 48 insertions, 16 deletions
diff --git a/core/Addon.zig b/core/Addon.zig
index c60f2430..aa3195f9 100644
--- a/core/Addon.zig
+++ b/core/Addon.zig
@@ -567,9 +567,11 @@ pub fn loadedOf(ops: *const Kind.Ops, path: []const u8, hash: [32]u8, words: *[6
/// This process's code for a kind a session's core lists, which a client
/// runs itself: PA_PLAIN, of the same name, version, ABI and functions (a
-/// compiled-in addon's library hash is 0: never by the hash), and not
-/// caught breaking its promise here (`distrusted`, the client's). Null: its
-/// panes say so.
+/// compiled-in addon's library hash is 0: never by the hash), or else the
+/// library at the session's path when its bytes are the session's (P51: a
+/// client on its machine; never bytes the session sent), and not caught
+/// breaking its promise here (`distrusted`, the client's). Null: its panes
+/// say so.
pub fn plainOps(e: *const Kind.Entry, distrusted: ?*const Distrusted) ?*const Kind.Ops {
if (!e.caps.plain or e.refused) return null;
// A client scans for its addons only when its session has a plain kind.
@@ -582,6 +584,16 @@ pub fn plainOps(e: *const Kind.Entry, distrusted: ?*const Distrusted) ?*const Ki
if (l.ops == 0) l.ops = loadListed(i, &why) orelse return null;
return @ptrFromInt(l.ops);
};
+ var words: [64]LoadedWord = undefined;
+ var why: Why = .{};
+ var data_buf: [4096]u8 = undefined;
+ const l = read(dataDir(&data_buf), e.path.slice(), &words, &why);
+ if (l.why.len > 0) return null;
+ const ops: *const Kind.Ops = @ptrFromInt(l.ops);
+ if (std.mem.eql(u8, &l.hash, &e.hash)) return ops;
+ const lib = libOf(ops).?;
+ lib.refs -= 1;
+ closeIdle(lib);
return null;
}
diff --git a/core/Effect.zig b/core/Effect.zig
index abfe4711..bdf41e66 100644
--- a/core/Effect.zig
+++ b/core/Effect.zig
@@ -256,9 +256,10 @@ fn performInner(p: *Pardes, e: Effect) void {
.dump_themes => |d| _ = p.tape.host(p, .dump_themes, .{d.pane}),
.detach => |d| p.tape.host(p, .detach, .{}) orelse p.reportError(d.pane, "detach", error.NotAttached),
// dlopen is the same on every host, so none has a method of its
- // own; a replica's core holds no library (what it brought comes in
- // the event this taped).
- .addon => |a| if (!p.tape.replaying()) @import("Addon.zig").perform(p, a.op, a.pane.index(), a.arg.slice()),
+ // own; a replica's core holds no library: what it brought is the
+ // event inside this call, recorded there and applied by a replay
+ // (its code a client's own, Addon.plainOps); a speculation waits.
+ .addon => |a| if (!p.tape.authorityOnly("an addon's load")) p.tape.value(.landing, @import("Addon.zig").perform, .{ p, a.op, a.pane.index(), a.arg.slice() }),
.job => |j| p.tape.host(p, .job, .{ j.pane, j.serial, j.token }) orelse if (!p.tape.replaying()) host_io.KindJob.runHere(p, j.pane.index(), j.serial, j.token),
// the loop's own condition; a host tears down after its own loop
.quit => p.endSession(),
diff --git a/core/Kind.zig b/core/Kind.zig
index 81997afb..49076f78 100644
--- a/core/Kind.zig
+++ b/core/Kind.zig
@@ -424,7 +424,7 @@ pub fn draw(p: *Pardes, s: *surface.Surface, arena: std.mem.Allocator, pane: *Pa
if (slot.ops == null and slot.live) {
// A client: a plain kind runs where it is shown, and this one lacks
// it; any other runs in its session alone.
- const why = if (caps(p, slot).plain) "it is not in its addons, or it broke its promise here" else "its state is not plain (PA_PLAIN), so it runs in the session alone";
+ const why = if (caps(p, slot).plain) "it is not in its addons nor the session's library at its path here, or it broke its promise here" else "its state is not plain (PA_PLAIN), so it runs in the session alone";
var line: [200]u8 = undefined;
_ = s.print(x, y, cols, std.fmt.bufPrint(&line, "addon {s} {d} does not run in this client: {s}", .{ slot.nameOf(), slot.version, why }) catch &line, .{ .fg = fg, .bg = bg });
return;
diff --git a/core/exec.zig b/core/exec.zig
index 52f54541..99868434 100644
--- a/core/exec.zig
+++ b/core/exec.zig
@@ -20,7 +20,6 @@ const python_lang = blk: {
@setEvalBranchQuota(20_000);
break :blk @import("grammar_manifest.zig").byName("python").?;
};
-const font_picker = pardes.font_picker;
const fonts = pardes.fonts;
const Pane = panes.Pane;
const MAX_COLS = pardes.MAX_COLS;
@@ -1014,7 +1013,7 @@ pub fn applySettingBuiltin(p: *Pardes, setting: config.Settings.Setting, arg: ?[
return p.reportFailure(v.active, text.print("Theme: no theme \"{s}\"; like it: {s}; Themes lists all", .{ shown, colors.themesNear(near[0..@min(room, near.len)], want) }));
},
.font => {
- if (comptime !font_picker) return;
+ if (comptime !pardes.builtins.capabilities.font_picker) return;
const spec = config.Settings.FontSpec.parse(arg orelse return) orelse return;
// The session's machine's fonts, a question to its disk: a
// client's replay takes the session's answer, never its own.
diff --git a/core/replica.zig b/core/replica.zig
index 3aac5e82..71a8de71 100644
--- a/core/replica.zig
+++ b/core/replica.zig
@@ -1361,6 +1361,12 @@ pub const Peer = struct {
again: bool = false,
/// ...or that its window was closed (Peers.closed).
close: bool = false,
+ /// It said a bye: none, and the session let it go with no word of its
+ /// own (`closing`, `cut`), is a client that died (killed: P48).
+ bye: bool = false,
+ /// A pair's first client (`Joining.own`): the terminal its session
+ /// keeps is its (`Peers.pair_left`).
+ pair: bool = false,
/// Inputs read (each one's seq, as the client numbered them).
seq: u32 = 0,
/// The `stamp` frame its next input came with (its reader's).
@@ -1643,6 +1649,7 @@ pub const Peer = struct {
const b = (wire.decodeClient(tag, payload) catch return false).bye;
peer.again = b.again;
peer.close = b.close;
+ peer.bye = true;
return false;
},
.ping => {
@@ -1775,6 +1782,14 @@ pub const Peers = struct {
/// hung up) and the session is a pair's not kept (daemon.sessionState): it
/// ends there (runtime/session.zig).
closed: bool = false,
+ /// Its pair's first client left (P48): with no word at all (killed),
+ /// true; its session's frontend puts the user's terminal back then,
+ /// and lets it go either way (tui.zig `Own.sent`), and clears this.
+ pair_left: ?bool = null,
+ /// Its pair's first client's terminal or window found again (a focus
+ /// in): the session asks whether a newer build is installed, as its own
+ /// frontend asks at its own (runtime/session.zig), and clears this.
+ pair_focused: bool = false,
/// An Upgrade told its clients so (`refuseAll`): a connection handed
/// over before its exec is told the same, never closed by the exec
/// unanswered. Its exec failed: the next boundary takes joins again.
@@ -1896,6 +1911,7 @@ pub const Peers = struct {
const t0 = nowNs();
defer if (ps.samples) ps.input_ns.append(ps.gpa, nowNs() - t0) catch {};
core.toView(peer.view);
+ if (peer.pair and in.event == .focus and in.event.focus) ps.pair_focused = true;
ps.t.stamp = stampOf(in);
core.update(in.event);
core.step();
@@ -2000,7 +2016,7 @@ pub const Peers = struct {
core.gpa.free(bytes);
return daemon.refuseReplica(fd, "out of memory");
};
- peer.* = .{ .peers = ps, .fd = fd, .id = ps.next_id, .view = .at(k), .dump = bytes, .blobs = blobs, .dump_gpa = core.gpa };
+ peer.* = .{ .peers = ps, .fd = fd, .id = ps.next_id, .view = .at(k), .dump = bytes, .blobs = blobs, .dump_gpa = core.gpa, .pair = joining.own };
ps.next_id +%= 1;
if (ps.next_id == 0) ps.next_id = 1;
// The session's digest as dumped, for the joiner to check its load by
@@ -2075,6 +2091,7 @@ pub const Peers = struct {
ps.closeViewOf(core, peer, peer.again or peer.cut);
if (ps.count() == 0) core.unattended = ps.detached;
if (ps.count() == 0 and peer.close and daemon.sessionState() == .pair) ps.closed = true;
+ if (peer.pair) ps.pair_left = !peer.bye and !peer.closing and !peer.cut;
ps.seq += 1;
ps.unit(0, ps.seq);
ps.letGo(peer);
@@ -6169,12 +6186,10 @@ const may_wait = [_]Wait{
.{ .what = "*", .on = .addon, .stop = "a kind's close", .why = "a kind's pane closed: its state let go on the session" },
.{ .what = "*", .on = .addon, .stop = "a kind's word", .why = "a word to a kind (a key it takes as one): its own state" },
.{ .what = "*", .on = .addon, .stop = "a kind's open", .why = "a kind's pane opened (`Life`): its state made on the session" },
-} ++ (if (pardes.font_picker) [_]Wait{
- // A window's view (the font words are a window's).
+} ++ (if (pardes.builtins.capabilities.font_picker) [_]Wait{
+ // A window's view's words, which a terminal's build has too: a window
+ // client of its session runs them.
.{ .what = "Font *", .on = .any, .stop = "fonts", .why = "the session's machine's fonts, its disk" },
-} else [_]Wait{}) ++ (if (pardes.builtins.capabilities.font_picker) [_]Wait{
- // ...and Fonts a terminal's build has too, which a window client of its
- // session runs (exec.zig's Font, a window build's alone, does not).
.{ .what = "Fonts", .on = .any, .stop = "fonts", .why = "the session's machine's fonts, its disk" },
} else [_]Wait{});
diff --git a/core/root.zig b/core/root.zig
index 3cc9a90f..3bca5e03 100644
--- a/core/root.zig
+++ b/core/root.zig
@@ -118,7 +118,9 @@ const Loc = Jump.Loc;
pub const can_attach = platform == .tui or platform == .gui;
-pub const fonts = if (font_picker) @import("dev").fonts else struct {};
+/// The machine's fonts: every desktop build's, which steps a window's Font
+/// as the window does (builtins.capabilities), and the Mac's.
+pub const fonts = if (builtins.capabilities.font_picker) @import("dev").fonts else struct {};
pub const Pane = panes.Pane;
const Text = panes.Text;
diff --git a/core/tape.zig b/core/tape.zig
index 1cbf8aed..dc53a7c9 100644
--- a/core/tape.zig
+++ b/core/tape.zig
@@ -140,6 +140,9 @@ pub const Site = enum(u16) {
/// A kitty image's medium as a terminal's emulator read it (a file, a
/// temporary file, shared memory: Term.media), its bytes or its failure.
medium,
+ /// An addon's library loaded or let go (Addon.perform): what it brought
+ /// is the `addon` event inside it, which a replica applies from here.
+ landing,
};
/// What the sites return. wire.semantics hashes their shape with the