From f67fec978a9296c651ec06bd2f43686d34ff86ee Mon Sep 17 00:00:00 2001 From: Gabriel Schneider Date: Fri, 14 Aug 2026 13:40:29 -0300 Subject: look: richer path/range parsing, pdf rendering, corner-drag and stepgrain snapshots --- src/macos.zig | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) (limited to 'src/macos.zig') diff --git a/src/macos.zig b/src/macos.zig index dce136f4..100019ef 100644 --- a/src/macos.zig +++ b/src/macos.zig @@ -415,6 +415,9 @@ fn initCore(runtime: ?*const Runtime, cols_arg: u16, rows_arg: u16) !void { .runtime = if (runtime) |r| r.* else .{}, }; const st = &state.?; + // the core's one way to ask about this host's ptys, pulled at the Exec that + // cares rather than pushed with the cwd above + core.tty_query = .{ .ctx = st, .taken = &ttyTakenAt }; // The real grid, delivered as an EVENT and not as Options.cols/rows: the // core defers each shell's greeting until it has seen a resize, and the @@ -546,6 +549,9 @@ export fn pardes_theme_bg() u32 { /// can have changed one — a `cd` is a command, and a shell that ran a command /// writes at least its next prompt. So an idle session costs nothing at all, /// and a busy one costs one libproc call per pane per burst. +/// +/// Whether a shell's tty is still that shell is NOT refreshed here: nothing +/// draws it, so the core pulls it instead (see `ttyTakenAt`). fn refreshCwds(st: *State) void { for (&st.cwd_stale, 0..) |*stale, id| { if (!stale.*) continue; @@ -556,6 +562,17 @@ fn refreshCwds(st: *State) void { } } +/// The core's `tty_query`, asked only where a command line is about to be typed: +/// is a program holding this pane's tty instead of the prompt we forked? +/// `look.ttyTaken` answers `false` on darwin until it grows a libproc +/// implementation, so this host behaves exactly as it did — the wiring is here +/// so it cannot rot, and it costs nothing until then. +fn ttyTakenAt(ctx: ?*anyopaque, pane: usize) bool { + const st: *const State = @ptrCast(@alignCast(ctx orelse return false)); + const pt = st.ptys[pane] orelse return false; + return look.ttyTaken(pt.pid, pt.file.handle); +} + /// Drain what the reader tasks collected into the core, then perform whatever /// the core queued in response. Returns whether this tick did any IO. /// @@ -1074,7 +1091,8 @@ fn drainEffects(st: *State, threads_ok: bool) bool { .gen = gen, .reader = .{ .any_future = null, .result = {} }, }; - // Report the pane's starting directory back to the core (tags). + // Report the pane's starting directory back to the core (tags); + // the slot needs no occupancy reset, nothing is remembered. var lbuf: [1024]u8 = undefined; if (look.shellCwd(child.pid, &lbuf)) |wd| core.setCwd(sp.pane, wd); if (threads_ok) if (st.ptys[sp.pane]) |*pt| startReader(st, pt, sp.pane); -- cgit v1.3