summaryrefslogtreecommitdiff
path: root/src/macos.zig
diff options
context:
space:
mode:
authorGabriel Schneider <[email protected]>2026-08-14 13:40:29 -0300
committerGabriel Schneider <[email protected]>2026-08-15 11:57:13 -0300
commitf67fec978a9296c651ec06bd2f43686d34ff86ee (patch)
treecbf5568883e5888398e0887093fc5afc524fd54d /src/macos.zig
parent9280c597b000eed661fd98793e182fdcb640f6cd (diff)
downloadpardes-f67fec978a9296c651ec06bd2f43686d34ff86ee.tar.gz
pardes-f67fec978a9296c651ec06bd2f43686d34ff86ee.zip
look: richer path/range parsing, pdf rendering, corner-drag and stepgrain snapshots
Diffstat (limited to 'src/macos.zig')
-rw-r--r--src/macos.zig20
1 files changed, 19 insertions, 1 deletions
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);