summaryrefslogtreecommitdiff
path: root/core/Core.zig
diff options
context:
space:
mode:
authorGabriel Schneider <[email protected]>2026-11-19 09:40:26 -0300
committerGabriel Schneider <[email protected]>2026-11-19 10:20:27 -0300
commitec4956d7b4fe097cd7a9488329a14fa28a79fb7a (patch)
tree565787f9d2637149cf6c8a72c1ba5dc692cbd500 /core/Core.zig
parent2d30f3781ab40c38710835806a1029359509d27b (diff)
downloadpardes-ec4956d7b4fe097cd7a9488329a14fa28a79fb7a.tar.gz
pardes-ec4956d7b4fe097cd7a9488329a14fa28a79fb7a.zip
tape: a core holds its tape as it holds its allocator, `p.tape` (the handle's step 0, P19/P20, pardes-handle-sizing section 1): Pardes.tape: *Tape, never null, set when a core is made (Options.tape for init, else tape.on's, else tape.none; tape.adoptCore for a client's join, tape.adopt for a Restore, the tape's own apply for a replay's init and restore, replica.zig's Peers when a session's first client joins and when its last leaves), tape.none the tape of a session nobody records (Tape.through: every call goes through, nothing is taped, nothing writes it), Tape.io Zig's io for a site's body (the process's, as every global read of it was), the entry points as methods on the tape (site, value, authority, over, replaying, stray, stepping, screenReplica, screenAuthority, poison, authorityOnly, viewOnly, touchTerminal, adopt, current, forget; `speculating` and `screen_state` are its fields; `diverged` stays free, its name being the field it writes) and the free functions kept beside them, each now the method on `on orelse &none`, so every caller exercises the methods; the field is this process's own, in no digest, dump or tape (Pardes.replica.local, Options.replica.local) and no rollback copy (rollback.zig's `unsaved`), with a test that neither the digest nor the dump moves with it and that a copy put back leaves it as set; a safe build checks at every entry that a core's field is the tape `on` steps it on (or, with none on, an idle one): it found that a client's own frame drawn between its steps (Replica.draw, an entry with `on` null) is entered on its idle tape, which `enter` must not record into once it reads the field (step 9), and that a replay's dump check loaded its core on the session's tape through its options (now on none); Core.zig names the module `pardes.tape` (82 lines), its import `tape` colliding with the field; `init` and dump's `initFromDump` leave the tape once, deferred, with the core made or none (they left it twice, one per way out: the owner's reading); Stepping's swap and the three tests' save-and-restore stay: the free functions still read `on`, so a replica's step needs it pointed at its tape until the last of them goes. The five numbers: (1) functions that gained the parameter 0 (row: 0); (2) perfops 97 counts within 0.1%, largest image-frame on large +0.0215% (the base's own spread), none on a per-row path gained anything; (3) nothing stopped compiling for want of an io (none was removed); (4) global io uses 11 plus the tape's field default, calls into the free functions 93 (each now a method's), machine_lines tape.zig 10 -> 11 (the io field); (5) lines changed: tests 32, code about 580 (164 of them Core.zig's module name, about 250 bodies moved into methods; tape.zig 1533 -> 1623 lines). Gate: tui core-test 837/980 (143 skipped), shell-test 1015/1018, pane-test 183/184, behaviour-test 275/275 and --replay 20 seeds 0 failures, process-test lspcomplete and lspcompletemoved (the base's), replicas --clients 5 diverged 0, unequal 0, deltas wrong 0 (1646/0, 1620/0, 1737/0), quiet 484/0, 554/0, 651/0; daemon.py plain, --far, --games, --window-clients pass; semantics 2f615168fe07b35f (unmoved); frames 77/77 byte-identical in Debug, gui unit-test 1613/1617, perfab corpus2x +0.028% pictures identical in all 10 runs, perfops PASS
Co-Authored-By: Claude Opus <[email protected]> Claude-Session: https://claude.ai/code/session_016Y9MNBECMWcJD5pdS4SR6T
Diffstat (limited to 'core/Core.zig')
-rw-r--r--core/Core.zig191
1 files changed, 101 insertions, 90 deletions
diff --git a/core/Core.zig b/core/Core.zig
index 0e37f945..5bb0809e 100644
--- a/core/Core.zig
+++ b/core/Core.zig
@@ -78,7 +78,6 @@ const recent_files = @import("recent.zig");
const sel_slot = pardes.sel_slot;
const syntax = pardes.syntax;
const tagline = pardes.tagline;
-const tape = pardes.tape;
const test_api = pardes.test_api;
const themes = pardes.themes;
const turn = &pardes.turn;
@@ -195,6 +194,13 @@ image_gpa: std.mem.Allocator,
kinds: pardes.Kind.Registry = .{},
tree_sitter_gpa: std.mem.Allocator,
opts: Options,
+/// The tape this core's steps record on, replay from or go through (a
+/// session nobody records: `tape.none`), as `gpa` is its allocator: this
+/// process's own, in no digest, dump or rollback copy (`replica.local`,
+/// rollback.zig's `unsaved`). Set when the core is made (`Options.tape`;
+/// `tape.adoptCore` for a client's join, `tape.adopt` for a Restore) and
+/// by the session's clients (replica.zig `Peers`).
+tape: *pardes.tape.Tape,
resize_count: usize = 0,
panes: [MAX_PANES]?*Pane = @splat(null),
@@ -446,6 +452,7 @@ pub const replica = .{
// How this process was started, and the last dump it made for
// its host to write: a session loaded elsewhere has its own.
"opts", "dump_out", "dump_export",
+ "tape",
},
.derived = .{ "shell_rows", "diff_output", "locations_cache", "retired_panes", "tty_filter_palette", "body_chrome" },
// The host's handles, the 9P server's fids and log, the state file
@@ -514,6 +521,9 @@ pub fn create(gpa: std.mem.Allocator, opts: Options) !*Pardes {
.kinds = .started(opts.addons),
.tree_sitter_gpa = opts.tree_sitter_allocator orelse gpa,
.opts = opts,
+ // The global still set beside the field (P20): a core made while
+ // a tape records (PARDES_RECORD, a replica's step) is its.
+ .tape = opts.tape orelse pardes.tape.on orelse &pardes.tape.none,
.tty_toggle = opts.tty_toggle,
.views = .{ View{
.frontend = .{ .windowed = opts.windowed },
@@ -538,14 +548,13 @@ pub fn create(gpa: std.mem.Allocator, opts: Options) !*Pardes {
/// A new session, its tape written from here when PARDES_RECORD asks.
pub fn init(gpa: std.mem.Allocator, opts: Options) !*Pardes {
- tape.startFromEnv();
- const taped = tape.enter(null, .{ .init = opts });
- const p = initSession(gpa, opts) catch |err| {
- tape.leave(null, taped);
- return err;
- };
- tape.leave(p, taped);
- return p;
+ pardes.tape.startFromEnv();
+ const taped = pardes.tape.enter(null, .{ .init = opts });
+ // The tape adopts the core made, none on a failure.
+ var made: ?*Pardes = null;
+ defer pardes.tape.leave(made, taped);
+ made = try initSession(gpa, opts);
+ return made.?;
}
fn initSession(gpa: std.mem.Allocator, opts: Options) !*Pardes {
@@ -700,7 +709,7 @@ pub fn recentGpa(_: *const Pardes) std.mem.Allocator {
pub fn loadRecent(p: *Pardes) void {
// A replica's Recent is its own, in memory: the recording session's
// state file is every session's of its user (core/tape.zig).
- if (tape.replaying()) p.db.kind = .off;
+ if (pardes.tape.replaying()) p.db.kind = .off;
p.db.readRecent(p);
}
@@ -763,11 +772,11 @@ pub fn recentDot(pane: *const Pane) ?struct { path: []const u8, line: u32, col:
/// reads them: its process's options, so the authority's
/// (`tape.authority`); a replica's are its own process's.
pub fn configDir(p: *Pardes) ?[]const u8 {
- return tape.authority(optsConfigDir, .{p});
+ return pardes.tape.authority(optsConfigDir, .{p});
}
pub fn startupPath(p: *Pardes) ?[]const u8 {
- return tape.authority(optsStartupPath, .{p});
+ return pardes.tape.authority(optsStartupPath, .{p});
}
fn optsConfigDir(p: *Pardes) ?[]const u8 {
@@ -782,7 +791,7 @@ fn optsStartupPath(p: *Pardes) ?[]const u8 {
/// in scratch. Recent is the authority's (every window of its user
/// writes it): a replica has its answer (`tape.authority`).
pub fn recentByHash(p: *Pardes, hash: u64) ?recent_files.Entry {
- return tape.authority(recentFound, .{ p, hash });
+ return pardes.tape.authority(recentFound, .{ p, hash });
}
fn recentFound(p: *Pardes, hash: u64) ?recent_files.Entry {
@@ -795,9 +804,9 @@ fn recentFound(p: *Pardes, hash: u64) ?recent_files.Entry {
}
pub fn deinit(p: *Pardes) void {
- const taped = tape.enter(p, .{ .deinit = tape.current(p) });
- tape.forget(p);
- defer tape.leave(null, taped);
+ const taped = pardes.tape.enter(p, .{ .deinit = pardes.tape.current(p) });
+ pardes.tape.forget(p);
+ defer pardes.tape.leave(null, taped);
if (std.c.getenv("PARDES_FRAMES")) |path| p.frames.dump(std.mem.span(path));
// Every file open now is closed with its dot, and the list kept.
for (p.panes) |slot| if (slot) |pane| p.noteClosed(pane);
@@ -863,8 +872,8 @@ pub fn endSession(p: *Pardes) void {
/// shell feedback after write_dump: remember where the dump landed (the
/// topbar grows a `Restore <path>` word pointing at it)
pub fn setLastDump(p: *Pardes, path: []const u8) void {
- const taped = tape.enter(p, .{ .set_last_dump = path });
- defer tape.leave(p, taped);
+ const taped = pardes.tape.enter(p, .{ .set_last_dump = path });
+ defer pardes.tape.leave(p, taped);
p.pointRestoreAt(path);
ctlfs.events.notePath(p, "dump", path);
}
@@ -892,8 +901,8 @@ pub fn pointRestoreAt(p: *Pardes, path: []const u8) void {
/// the shell polls this each frame: a pending Restore's dump path, or null
pub fn takeRestore(p: *Pardes) ?[]const u8 {
- const taped = tape.enter(p, .take_restore);
- defer tape.leave(p, taped);
+ const taped = pardes.tape.enter(p, .take_restore);
+ defer pardes.tape.leave(p, taped);
const r = p.restore_req;
p.restore_req = null;
return r;
@@ -917,7 +926,7 @@ fn reportFocus(p: *Pardes) void {
// session's step makes the write, off the tape on both sides
// (tape.hostCall's pty_write), so the switch shows at once and the
// program hears of it a round trip later.
- if (tape.speculating() and tape.screenState()) return;
+ if (pardes.tape.speculating() and pardes.tape.screenState()) return;
if (v.focus_told) |old| if (p.panes[old.id]) |pane| {
if (pane.serial == old.serial and pardes.Term.modes(pane.terminal).focus) p.emitWrite(old.id, "\x1b[O");
};
@@ -969,8 +978,8 @@ pub fn parkPendingWrite(p: *Pardes, id: usize, bytes: []const u8) void {
/// The shell reports the spawned pane's working directory (and later cwd
/// changes it observes, e.g. via /proc/<pid>/cwd before each frame).
pub fn setCwd(p: *Pardes, id: usize, cwd: []const u8) void {
- const taped = tape.enter(p, .{ .set_cwd = .{ .id = id, .cwd = cwd } });
- defer tape.leave(p, taped);
+ const taped = pardes.tape.enter(p, .{ .set_cwd = .{ .id = id, .cwd = cwd } });
+ defer pardes.tape.leave(p, taped);
const pane = p.panes[id] orelse return;
// A command pane stays the directory's it was run for (newCommand).
if (pane.command != null) return;
@@ -1005,8 +1014,8 @@ pub fn shellBin(p: *const Pardes) []const u8 {
/// or null with no room. An input, as every host write into the core
/// is: a replica of the session makes the same pane.
pub fn adoptShell(p: *Pardes) ?u8 {
- const taped = tape.enter(p, .adopt_shell);
- defer tape.leave(p, taped);
+ const taped = pardes.tape.enter(p, .adopt_shell);
+ defer pardes.tape.leave(p, taped);
var newest: u32 = 0;
for (p.panes) |slot| if (slot) |pn| {
newest = @max(newest, pn.serial);
@@ -1022,16 +1031,16 @@ pub fn adoptShell(p: *Pardes) ?u8 {
/// A terminal's reader failed (no end of file: the host closed its pty):
/// its pane takes keys again, and why is said.
pub fn readerFailed(p: *Pardes, id: u8, err: anyerror) void {
- const taped = tape.enter(p, .{ .reader_failed = .{ .id = id, .err = err } });
- defer tape.leave(p, taped);
+ const taped = pardes.tape.enter(p, .{ .reader_failed = .{ .id = id, .err = err } });
+ defer pardes.tape.leave(p, taped);
const pane = p.panes[id] orelse return;
pane.body.mode = .normal;
p.reportError(id, "terminal reader", err);
}
pub fn acknowledgeShell(p: *Pardes, id: usize, executable: []const u8, prompt_marks: bool) void {
- const taped = tape.enter(p, .{ .acknowledge_shell = .{ .id = id, .executable = executable, .prompt_marks = prompt_marks } });
- defer tape.leave(p, taped);
+ const taped = pardes.tape.enter(p, .{ .acknowledge_shell = .{ .id = id, .executable = executable, .prompt_marks = prompt_marks } });
+ defer pardes.tape.leave(p, taped);
if (id < MAX_PANES) if (p.panes[id]) |pane| {
ctlfs.pty.shellGone(p, pane, true); // a respawn replaced whatever ran
pane.shell_failed = false;
@@ -1068,8 +1077,8 @@ pub fn acknowledgeShell(p: *Pardes, id: usize, executable: []const u8, prompt_ma
/// them and a terminal's replica of a window's session must step as
/// the window does.
pub fn takeFontRequest(p: *Pardes) ?[]const u8 {
- const taped = tape.enter(p, .take_font_request);
- defer tape.leave(p, taped);
+ const taped = pardes.tape.enter(p, .take_font_request);
+ defer pardes.tape.leave(p, taped);
if (!p.settings.font.pending or p.font_request_taken) return null;
const path = p.settings.font.requested_path.get();
if (path.len == 0) return null;
@@ -1083,8 +1092,8 @@ pub fn observeFont(
effective_size_hundredths: u16,
unit: config.Runtime.FontSizeUnit,
) bool {
- const taped = tape.enter(p, .{ .observe_font = .{ .name = effective_name, .size = effective_size_hundredths, .unit = unit } });
- defer tape.leave(p, taped);
+ const taped = pardes.tape.enter(p, .{ .observe_font = .{ .name = effective_name, .size = effective_size_hundredths, .unit = unit } });
+ defer pardes.tape.leave(p, taped);
if (!p.settings.font.effective_name.set(effective_name)) return false;
p.settings.font.effective_size_hundredths = effective_size_hundredths;
p.settings.font.effective_size_unit = unit;
@@ -1099,8 +1108,8 @@ pub fn acknowledgeFont(
effective_size_hundredths: u16,
unit: config.Runtime.FontSizeUnit,
) bool {
- const taped = tape.enter(p, .{ .acknowledge_font = .{ .name = effective_name, .size = effective_size_hundredths, .unit = unit } });
- defer tape.leave(p, taped);
+ const taped = pardes.tape.enter(p, .{ .acknowledge_font = .{ .name = effective_name, .size = effective_size_hundredths, .unit = unit } });
+ defer pardes.tape.leave(p, taped);
if (!p.settings.font.pending or !p.font_request_taken) return false;
const changed = !std.mem.eql(
u8,
@@ -1116,8 +1125,8 @@ pub fn acknowledgeFont(
}
pub fn rejectFont(p: *Pardes) void {
- const taped = tape.enter(p, .reject_font);
- defer tape.leave(p, taped);
+ const taped = pardes.tape.enter(p, .reject_font);
+ defer pardes.tape.leave(p, taped);
if (!p.settings.font.pending or !p.font_request_taken) return;
p.settings.font.pending = false;
p.font_request_taken = false;
@@ -1144,8 +1153,8 @@ pub inline fn view(p: anytype) if (@typeInfo(@TypeOf(p)).pointer.attrs.@"const")
/// `pardes --attach`ed), as the live one is laid out; null at
/// Views.max. Not live until `toView`.
pub fn openView(p: *Pardes) ?u8 {
- const taped = tape.enter(p, .open_view);
- defer tape.leave(p, taped);
+ const taped = pardes.tape.enter(p, .open_view);
+ defer pardes.tape.leave(p, taped);
// Every view taken: one kept for a client that has not come back
// for it (Views.away) goes first. ponytail: no timer lets one go;
// until its place is wanted it costs a parked slot, and a terminal
@@ -1166,8 +1175,8 @@ pub fn openView(p: *Pardes) ?u8 {
/// The client of view `k` gone: its view goes, the others stay. The
/// last one stays the session's own.
pub fn closeView(p: *Pardes, k: u8) void {
- const taped = tape.enter(p, .{ .close_view = k });
- defer tape.leave(p, taped);
+ const taped = pardes.tape.enter(p, .{ .close_view = k });
+ defer pardes.tape.leave(p, taped);
Views.close(p, k);
p.sync();
// What its sync queued (a terminal it sized, sized again) done here,
@@ -1181,8 +1190,8 @@ pub fn closeView(p: *Pardes, k: u8) void {
/// goes, and the session's own is laid out as it was (Views.closeKeeping),
/// which the client's rejoin copies. Settled as `closeView` is.
pub fn leaveView(p: *Pardes, k: u8) void {
- const taped = tape.enter(p, .{ .leave_view = k });
- defer tape.leave(p, taped);
+ const taped = pardes.tape.enter(p, .{ .leave_view = k });
+ defer pardes.tape.leave(p, taped);
Views.closeKeeping(p, k);
p.sync();
p.settle();
@@ -1191,8 +1200,8 @@ pub fn leaveView(p: *Pardes, k: u8) void {
/// The client of view `k` gone, to join again for it (an Upgrade's
/// rejoin, a divergence's): its view kept as it is (Views.away).
pub fn awayView(p: *Pardes, k: u8) void {
- const taped = tape.enter(p, .{ .away_view = k });
- defer tape.leave(p, taped);
+ const taped = pardes.tape.enter(p, .{ .away_view = k });
+ defer pardes.tape.leave(p, taped);
Views.away(p, k);
}
@@ -1200,8 +1209,8 @@ pub fn awayView(p: *Pardes, k: u8) void {
/// as it left it; false when it was let go meanwhile. Settled as
/// `openView` is, for the join's dump next.
pub fn rejoinView(p: *Pardes, k: u8) bool {
- const taped = tape.enter(p, .{ .rejoin_view = k });
- defer tape.leave(p, taped);
+ const taped = pardes.tape.enter(p, .{ .rejoin_view = k });
+ defer pardes.tape.leave(p, taped);
if (!Views.isAway(p, k)) return false;
p.views_away &= ~(@as(u8, 1) << @intCast(k));
p.settle();
@@ -1212,8 +1221,8 @@ pub fn rejoinView(p: *Pardes, k: u8) bool {
/// Into view `k`, before the input its client sent.
pub fn toView(p: *Pardes, k: u8) void {
if (k == p.live) return;
- const taped = tape.enter(p, .{ .to_view = k });
- defer tape.leave(p, taped);
+ const taped = pardes.tape.enter(p, .{ .to_view = k });
+ defer pardes.tape.leave(p, taped);
Views.to(p, k);
}
@@ -1221,14 +1230,14 @@ pub fn toView(p: *Pardes, k: u8) void {
/// file reloading under it, a theme file rewritten on disk. `pump` draws
/// only when it has a reason to, and this is the reason.
pub fn invalidate(p: *Pardes) void {
- const taped = tape.enter(p, .invalidate);
- defer tape.leave(p, taped);
+ const taped = pardes.tape.enter(p, .invalidate);
+ defer pardes.tape.leave(p, taped);
p.needs_frame = true;
}
pub fn reloadWatchedFile(p: *Pardes, id: u8, bytes: []const u8) bool {
- const taped = tape.enter(p, .{ .reload_watched_file = .{ .id = id, .bytes = bytes } });
- defer tape.leave(p, taped);
+ const taped = pardes.tape.enter(p, .{ .reload_watched_file = .{ .id = id, .bytes = bytes } });
+ defer pardes.tape.leave(p, taped);
p.invalidate();
look.invalidateLookHover(p, id);
const applied = p.applyWatchedFileChanged(id, bytes);
@@ -1245,8 +1254,8 @@ pub fn emit(p: *Pardes, e: Effect) void {
}
pub fn nextEffect(p: *Pardes) ?Effect {
- const taped = tape.enter(p, .next_effect);
- defer tape.leave(p, taped);
+ const taped = pardes.tape.enter(p, .next_effect);
+ defer pardes.tape.leave(p, taped);
p.refillPendingWrites();
if (p.effects_len == 0) {
p.effects_head = 0;
@@ -1331,8 +1340,8 @@ pub fn hostKillJob(p: *const Pardes, id: usize) bool {
/// on it, or written to it from now on, hears `error shell gone`
/// rather than wait for a prompt that never comes.
pub fn shellFailed(p: *Pardes, id: u8, err: anyerror) void {
- const taped = tape.enter(p, .{ .shell_failed = .{ .id = id, .err = err } });
- defer tape.leave(p, taped);
+ const taped = pardes.tape.enter(p, .{ .shell_failed = .{ .id = id, .err = err } });
+ defer pardes.tape.leave(p, taped);
const pane = p.panes[id] orelse return;
pane.shell_failed = true;
ctlfs.pty.shellGone(p, pane, false);
@@ -1354,8 +1363,8 @@ pub fn shellFailed(p: *Pardes, id: u8, err: anyerror) void {
/// A shell started again in a terminal whose shell runs (pty/ctl's
/// exec) did not start: the host kept the running one, so only said.
pub fn restartFailed(p: *Pardes, id: u8, err: anyerror) void {
- const taped = tape.enter(p, .{ .restart_failed = .{ .id = id, .err = err } });
- defer tape.leave(p, taped);
+ const taped = pardes.tape.enter(p, .{ .restart_failed = .{ .id = id, .err = err } });
+ defer pardes.tape.leave(p, taped);
if (p.panes[id] == null) return;
p.sayShellFailure(id, err);
}
@@ -1368,7 +1377,7 @@ fn sayShellFailure(p: *Pardes, id: u8, err: anyerror) void {
// The script is there; the program its `#!` names is not.
var said: pardes.Kind.Buf(320) = .{};
var interp: [256]u8 = undefined;
- const name = tape.value(.interpreter, missingInterpreter, .{ pane.shell orelse p.shellBin(), &interp });
+ const name = pardes.tape.value(.interpreter, missingInterpreter, .{ pane.shell orelse p.shellBin(), &interp });
p.reportFailure(id, if (name) |n| said.print("shell: interpreter {s} not found", .{n}) else "shell: interpreter not found");
} else {
p.reportError(id, "shell", err);
@@ -1393,13 +1402,13 @@ fn parentTrouble(path: []const u8, err: anyerror) struct { dir: []const u8, kind
const local = filesystem.localPath(dir);
const kind: ?std.Io.File.Kind = if (local) |l| exec.kindOf(l) else .directory;
const missing = err == error.FileNotFound or err == error.NotDir or kind != .directory;
- const denied = missing and (if (local) |l| tape.value(.denied, filesystem.deniedAbove, .{l}) else false);
+ const denied = missing and (if (local) |l| pardes.tape.value(.denied, filesystem.deniedAbove, .{l}) else false);
return .{ .dir = dir, .kind = kind, .missing = missing, .denied = denied };
}
pub fn saveFailed(p: *Pardes, id: u8, path: []const u8, err: anyerror) void {
- const taped = tape.enter(p, .{ .save_failed = .{ .id = id, .path = path, .err = err } });
- defer tape.leave(p, taped);
+ const taped = pardes.tape.enter(p, .{ .save_failed = .{ .id = id, .path = path, .err = err } });
+ defer pardes.tape.leave(p, taped);
if (p.panes[id]) |pane| if (pane.file) |*f| {
// The `-%` spelling fs.zig already uses for "make this dirty".
f.saved_revision = f.revision -% 1;
@@ -1422,8 +1431,8 @@ pub fn saveFailed(p: *Pardes, id: u8, path: []const u8, err: anyerror) void {
/// Save's does.
pub fn dumpFailed(p: *Pardes, path: []const u8, err: anyerror) void {
const v = p.view();
- const taped = tape.enter(p, .{ .dump_failed = .{ .path = path, .err = err } });
- defer tape.leave(p, taped);
+ const taped = pardes.tape.enter(p, .{ .dump_failed = .{ .path = path, .err = err } });
+ defer pardes.tape.leave(p, taped);
var what: [limits.host_path_cap + 8]u8 = undefined;
const operation = std.fmt.bufPrint(&what, "Dump {s}", .{path[0..@min(path.len, limits.host_path_cap)]}) catch unreachable; // cap + 5 fits cap + 8
// Into a DumpDir that is not there: said so, ENOENT, as a Save is;
@@ -1465,8 +1474,8 @@ pub fn animationActive(p: *const Pardes) bool {
pub fn pump(p: *Pardes, host: Host) !void {
p.host = host;
- const taped = tape.enter(p, .pump);
- defer tape.leave(p, taped);
+ const taped = pardes.tape.enter(p, .pump);
+ defer pardes.tape.leave(p, taped);
// The host as the tape sees it, while it records.
const h = p.host;
const v = h.vtable;
@@ -1550,8 +1559,8 @@ pub fn settle(p: *Pardes) void {
/// authority's tape of it to read the same. The session's own pump
/// draws it after.
pub fn step(p: *Pardes) void {
- const taped = tape.enter(p, .step);
- defer tape.leave(p, taped);
+ const taped = pardes.tape.enter(p, .step);
+ defer pardes.tape.leave(p, taped);
p.settle();
}
@@ -1562,8 +1571,8 @@ pub fn step(p: *Pardes) void {
/// that changes a pane costs a frame, which is why a round trip on a
/// local socket costs microseconds and not a vsync.
pub fn serveFs(p: *Pardes, req: ctlfs.Req) ctlfs.Reply {
- const taped = tape.enter(p, .{ .serve_fs = req });
- defer tape.leave(p, taped);
+ const taped = pardes.tape.enter(p, .{ .serve_fs = req });
+ defer pardes.tape.leave(p, taped);
// The held write of an Edit whose commands run, asked again by a
// retry of its park: still waiting, or its answer, never run twice.
if (p.fs.edit_hold) |*h| if (h.names(req)) {
@@ -1604,8 +1613,8 @@ pub fn serveFs(p: *Pardes, req: ctlfs.Req) ctlfs.Reply {
pub fn update(p: *Pardes, ev: Event) void {
const v = p.view();
- const taped = tape.enter(p, .{ .update = ev });
- defer tape.leave(p, taped);
+ const taped = pardes.tape.enter(p, .{ .update = ev });
+ defer pardes.tape.leave(p, taped);
defer pardes.panes.File.syncTwins(p);
defer p.reportFocus();
// A tick with no deadline due is the one event that cannot change
@@ -1756,15 +1765,15 @@ fn fsReport(p: *Pardes) void {
pub fn readSessionFacts(p: *Pardes) void {
// A dump made since carries them all: its shell is never empty.
if (p.session_shell_len != 0) return;
- if (p.session_dir_len == null) if (tape.value(.env, processDir, .{&p.session_dir})) |dir| {
+ if (p.session_dir_len == null) if (pardes.tape.value(.env, processDir, .{&p.session_dir})) |dir| {
std.mem.copyForwards(u8, &p.session_dir, dir);
p.session_dir_len = @intCast(dir.len);
};
- if (tape.value(.env, filesystem.processHome, .{})) |home| if (home.len <= p.session_home.len) {
+ if (pardes.tape.value(.env, filesystem.processHome, .{})) |home| if (home.len <= p.session_home.len) {
@memcpy(p.session_home[0..home.len], home);
p.session_home_len = @intCast(home.len);
};
- const shell = tape.value(.env, config.defaultShell, .{});
+ const shell = pardes.tape.value(.env, config.defaultShell, .{});
const kept = shell[0..@min(shell.len, p.session_shell.len)];
@memcpy(p.session_shell[0..kept.len], kept);
p.session_shell_len = @intCast(kept.len);
@@ -1808,8 +1817,8 @@ pub const SavePath = Effect.Buf(effect_path_cap);
/// What was said of a failure just now on pane `id` is also the waiting
/// 9P write's (9p_io, `fs.late_failure`).
pub fn noteLateFailure(p: *Pardes, id: usize) void {
- const taped = tape.enter(p, .{ .note_late_failure = id });
- defer tape.leave(p, taped);
+ const taped = pardes.tape.enter(p, .{ .note_late_failure = id });
+ defer pardes.tape.leave(p, taped);
// Said by reportFailure just now: its words fitted whole, the
// reason kept; else what the message row has.
const said = if (p.fs.said_at == p.fs.failures and p.fs.said_len > 0)
@@ -1824,8 +1833,8 @@ pub fn noteLateFailure(p: *Pardes, id: usize) void {
/// under it now, a drag's moving end and a look-hover's word.
pub fn presented(p: *Pardes) void {
const v = p.view();
- const taped = tape.enter(p, .presented);
- defer tape.leave(p, taped);
+ const taped = pardes.tape.enter(p, .presented);
+ defer pardes.tape.leave(p, taped);
if (v.pointer_inside and v.drag != .none) {
v.hover_col = v.pointer_raw_col;
v.hover_row = v.pointer_raw_row;
@@ -1837,8 +1846,8 @@ pub fn presented(p: *Pardes) void {
/// The window's answer to a WindowOpacity: done, or `failure` says why
/// not, `applied` the opacity it keeps.
pub fn windowOpacityDone(p: *Pardes, applied: u8, failure: ?[]const u8) void {
- const taped = tape.enter(p, .{ .window_opacity_done = .{ .applied = applied, .failure = failure } });
- defer tape.leave(p, taped);
+ const taped = pardes.tape.enter(p, .{ .window_opacity_done = .{ .applied = applied, .failure = failure } });
+ defer pardes.tape.leave(p, taped);
p.settings.window_opacity_pending = false;
const reason = failure orelse return;
// Do not claim a value the compositor refused; an explicit retry of
@@ -1970,7 +1979,7 @@ pub fn sync(p: *Pardes) void {
// A directory pane's entries follow its width, as acme's
// columns do (Dir.fit).
if (pane.file) |file| if (file.listing != null and r.h > pane.tag_rows) pardes.panes.Dir.fit(p, pane, pane.cols);
- if (pane.pending_command.wait == .input) pane.releasePendingCommand(p, id, tape.value(.prompt, struct {
+ if (pane.pending_command.wait == .input) pane.releasePendingCommand(p, id, pardes.tape.value(.prompt, struct {
fn ready(at: *const Pane) bool {
return pardes.Term.prompt(at.terminal).input_ready;
}
@@ -1982,7 +1991,7 @@ pub fn sync(p: *Pardes) void {
// its shell's FIRST prompt, or never: typed later it would land
// in whatever runs then, or in the middle of a line someone
// typed (Pane.greeting).
- if (pane.greet and pane.isTerminal() and p.resize_count > 0) switch (tape.value(.prompt, Pane.greeting, .{pane})) {
+ if (pane.greet and pane.isTerminal() and p.resize_count > 0) switch (pardes.tape.value(.prompt, Pane.greeting, .{pane})) {
.wait => {},
.never => pane.greet = false,
.now => {
@@ -2107,8 +2116,8 @@ pub fn nextWake(p: *const Pardes) ?u64 {
/// the look-hover delay) is jumped to its end in one step and drawn
/// once. Idle, time is not banked: the next wait starts from now.
pub fn advance(p: *Pardes, now_ns: u64) void {
- const taped = tape.enter(p, .{ .advance = now_ns });
- defer tape.leave(p, taped);
+ const taped = pardes.tape.enter(p, .{ .advance = now_ns });
+ defer pardes.tape.leave(p, taped);
// The first time a shell's clock is seen, core time starts there.
const started = p.clock.started;
p.clock.started = true;
@@ -2119,7 +2128,7 @@ pub fn advance(p: *Pardes, now_ns: u64) void {
// The session's ticks are the recording session's: a picture still
// decoding or a fade still moving asks for frames the way a message
// waiting to go does, and a replica that draws nothing has none.
- while (tape.value(.wake, nextWake, .{p})) |due| {
+ while (pardes.tape.value(.wake, nextWake, .{p})) |due| {
if (due > now_ns) break;
// Only waiting until `due`: its counters move there at once.
const held = (due - p.clock.stepped_ns) / frame;
@@ -2241,9 +2250,9 @@ pub const Boot = enum {
};
pub const Options = struct {
- /// Not taped: the client's list of distrusted kinds, and where its
- /// runner keeps its frame statistics.
- pub const replica = .{ .local = .{ "distrusted", "frames" } };
+ /// Not taped: the client's list of distrusted kinds, where its runner
+ /// keeps its frame statistics, and the core's tape.
+ pub const replica = .{ .local = .{ "distrusted", "frames", "tape" } };
tty_only: bool = false,
/// The first view's frontend is a window (`Pardes.frontend`), as a
/// window's build says: an option, taped with the rest, so that a
@@ -2288,6 +2297,8 @@ pub const Options = struct {
/// A client's: the kinds it caught breaking PA_PLAIN, its frontend's
/// list, which outlives each core it joins with. In no tape and no dump.
distrusted: ?*pardes.Addon.Distrusted = null,
+ /// The core's tape (`Pardes.tape`); null: `tape.on`'s, or `tape.none`.
+ tape: ?*pardes.tape.Tape = null,
/// What the host's scan of the addon directories found (Addon.scan).
addons: []const pardes.Kind.Loaded = &.{},
tree_sitter_allocator: ?std.mem.Allocator = null,