diff options
Diffstat (limited to 'src/tui')
| -rw-r--r-- | src/tui/tui.zig | 29 |
1 files changed, 15 insertions, 14 deletions
diff --git a/src/tui/tui.zig b/src/tui/tui.zig index 7aebeb7a..1c6a3b7f 100644 --- a/src/tui/tui.zig +++ b/src/tui/tui.zig @@ -582,10 +582,10 @@ fn surfaceHasKittyKey(surface: *const pardes.Surface, key: u64) bool { /// Where a session's terminal comes from: /dev/tty, as a plain `pardes` /// opens it; one open already (a session forked off its stub, -/// daemon.forkSession); or none, until one is attached (`--detach`). +/// daemon.forkSession); or none, detached until one is attached (`--detach`). /// The terminal a session starts on: /dev/tty, one its stub opened (an /// upgraded session's is raw already, `termios` the cooked one), or none. -pub const Term = union(enum) { open, fd: struct { fd: posix.fd_t, termios: ?posix.termios = null }, none }; +pub const Term = union(enum) { open, fd: struct { fd: posix.fd_t, termios: ?posix.termios = null }, detached }; pub fn run(init: std.process.Init, opts: pardes.Options, term: Term) !void { const io = init.io; @@ -608,7 +608,7 @@ pub fn run(init: std.process.Init, opts: pardes.Options, term: Term) !void { switch (term) { .open => try screen.enter(try vaxis.Tty.init(io, &tty_buf)), .fd => |t| try screen.enter(try Screen.ttyOn(io, &tty_buf, t.fd, t.termios)), - .none => {}, + .detached => {}, } defer screen.leave(); @@ -1076,7 +1076,7 @@ fn localSession( // An upgraded session's terminals, its own again. if (comptime !builtin.is_test) if (upgrade.resumed) |*rec| sh.resumeTerminals(rec); // Nobody to see it, and nobody to size it: `size` sets it (ctl.zig). - sh.setAttended(sh.attached()); + sh.setAttended(!sh.detached()); while (core.nextEffect()) |effect| core.perform(effect); // ...and its shells, once a fresh session's own has a directory to // adopt them in. @@ -1130,7 +1130,7 @@ fn localSession( if (live.on) clearNativeImages(&live.kitty, &live.vx, &live.tty); nc.view().frontend.native_images = live.on and live.vx.caps.kitty_graphics; nc.unattended = !live.on; - sh.peers.alone_unattended = !live.on; + sh.peers.detached = !live.on; if (fs) |f| f.reset(nc); core.deinit(); core = nc; @@ -1264,7 +1264,7 @@ const Shell = struct { /// Whether anyone looks at the session: a terminal here, or a replica /// client (Peers keeps it attended while one is there). fn setAttended(s: *Shell, on: bool) void { - s.peers.alone_unattended = !on; + s.peers.detached = !on; s.core.unattended = !on and s.peers.count() == 0; } @@ -1333,14 +1333,15 @@ const Shell = struct { return if (s.core.live == s.own) s.screen else null; } - fn attached(s: *const Shell) bool { - const screen = s.screen orelse return true; - return screen.on; + /// No terminal of its own (a test's, with none at all, is not detached). + fn detached(s: *const Shell) bool { + const screen = s.screen orelse return false; + return !screen.on; } /// Drawn only while a terminal shows it. fn watched(ctx: ?*anyopaque) bool { - return of(ctx).attached(); + return !of(ctx).detached(); } /// Detach: the terminal put back and let go, the stub told (it ends, @@ -1349,7 +1350,7 @@ const Shell = struct { const s = of(ctx); // A replica client's: its link ends. if (s.peers.detach(s.core.live)) return; - if (!s.attached()) return s.core.reportFailure(s.core.view().active, "Detach: no terminal is attached"); + if (s.detached()) return s.core.reportFailure(s.core.view().active, "Detach: no terminal is attached"); if (!daemon.kept()) return s.core.reportFailure(s.core.view().active, "Detach: no pardes daemon keeps this session (it is its terminal's job)"); s.leaveTerminal(); } @@ -1538,7 +1539,7 @@ const Shell = struct { if (s.moving()) wait = 1; // Detached, nobody's key dismisses a message: they go on the clock // (the pump's, after this wait), which wakes it. - if (!s.attached()) { + if (s.detached()) { for (s.core.panes) |slot| if (slot) |pane| if (pane.msg_len > 0) { wait = if (wait == 0) 100 else @min(wait, 100); break; @@ -1714,7 +1715,7 @@ const Shell = struct { // waits on it) is not started yet: started here. daemon.watch(s.loop, deliverNote); if (daemon.kept()) { - if (s.attached()) s.leaveTerminal(); + if (!s.detached()) s.leaveTerminal(); return true; } core.quit = true; @@ -1744,7 +1745,7 @@ const Shell = struct { s.feed(.pointer_leave); s.feed(.{ .focus = false }); }, - .winsize => |ws| if (s.attached()) s.resized(s.screen, ws), + .winsize => |ws| if (!s.detached()) s.resized(s.screen, ws), .pty_read => |pr| { tookRead(s.io, pr.id); s.output_seen = true; |
