diff options
Diffstat (limited to 'src/tui/tui.zig')
| -rw-r--r-- | src/tui/tui.zig | 48 |
1 files changed, 24 insertions, 24 deletions
diff --git a/src/tui/tui.zig b/src/tui/tui.zig index 414fe776..860e96c8 100644 --- a/src/tui/tui.zig +++ b/src/tui/tui.zig @@ -1030,7 +1030,7 @@ test "on a terminal with no kitty graphics a program's 64x64 image over 8x4 cell defer art.deinit(gpa); try std.testing.expectEqual(@as(*const pardes.Surface, s), try art.frame(gpa, a, s, true, 16)); const shown = try art.frame(gpa, a, s, false, 16); - const r = core.rects[0]; + const r = core.view().rects[0]; const x0 = r.x + pardes.config.GUTTER + 7; const y0 = core.bodyTop(pane, r) + 1; var painted: usize = 0; @@ -1098,7 +1098,7 @@ test "host watch closes initial race and reloads rename-over PDF while idle" { } try std.testing.expect(std.mem.indexOf(u8, pane.msg[0..pane.msg_len], "reloaded") != null); - core.frontend.native_images = true; + core.view().frontend.native_images = true; var frame = std.heap.ArenaAllocator.init(gpa); defer frame.deinit(); const surface = try core.render(frame.allocator()); @@ -1124,14 +1124,14 @@ const PdfWheelTarget = struct { pane: usize, page: usize }; fn nativePdfWheelTarget(core: *const pardes.Pardes, mouse: vaxis.Mouse) ?PdfWheelTarget { if (comptime !pardes.pdf_enabled) return null; - if (!core.frontend.native_images or mouse.type != .press or + if (!core.view().frontend.native_images or mouse.type != .press or (mouse.button != .wheel_up and mouse.button != .wheel_down) or mouse.col < 0 or mouse.row < 0) return null; const col: u16 = @intCast(mouse.col); const row: u16 = @intCast(mouse.row); for (core.panes, 0..) |slot, id| { const pane = slot orelse continue; - const rect = core.rects[id]; + const rect = core.view().rects[id]; if (col < rect.x or col >= rect.x + rect.w or row < rect.y or row >= rect.y + rect.h) continue; const page = pane.pdfPage() orelse return null; @@ -1769,7 +1769,7 @@ fn localSession( sh.from = 0; if (live.on) startInput(loop, live) catch {}; if (live.on) clearNativeImages(&live.kitty, &live.vx, &live.tty); - nc.frontend.native_images = live.on and live.vx.caps.kitty_graphics; + nc.view().frontend.native_images = live.on and live.vx.caps.kitty_graphics; nc.unattended = !live.on; sh.peers.alone_unattended = !live.on; if (fs) |f| f.reset(nc); @@ -1977,7 +1977,7 @@ const Shell = struct { /// The live view's terminal (null in tests). fn term(s: *const Shell) ?*Screen { - return s.terms[s.core.view]; + return s.terms[s.core.live]; } fn attached(s: *const Shell) bool { @@ -2001,11 +2001,11 @@ const Shell = struct { fn detach(ctx: ?*anyopaque) void { const s = of(ctx); // A replica client's: its link ends. - if (s.peers.detach(s.core.view)) return; - if (!s.attached()) return s.core.reportFailure(s.core.active, "Detach: no terminal is attached"); + if (s.peers.detach(s.core.live)) return; + if (!s.attached()) return s.core.reportFailure(s.core.view().active, "Detach: no terminal is attached"); // One of several: its view goes, and the session stays on the rest. - if (pardes.views.count(s.core) > 1) return s.dropView(s.core.view, .detach); - if (!daemon.kept()) return s.core.reportFailure(s.core.active, "Detach: no pardes daemon keeps this session (it is its terminal's job)"); + if (pardes.views.count(s.core) > 1) return s.dropView(s.core.live, .detach); + 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(); } @@ -2023,7 +2023,7 @@ const Shell = struct { const screen = s.term() orelse return; stopInput(s.io, &screen.thread); screen.leave(); - s.core.frontend.native_images = false; + s.core.view().frontend.native_images = false; s.setAttended(false); // The stub's stdin, stdout and stderr were its terminal too. const null_fd = libc.open("/dev/null", .{ .ACCMODE = .RDWR, .CLOEXEC = true }, @as(libc.mode_t, 0)); @@ -2194,9 +2194,9 @@ const Shell = struct { if (rec.nttys == 0) { // The live view alone (never one kept for a rejoin) is the // session's own. - for (0..pardes.views.max) |k| if (k != core.view and pardes.views.isOpen(core, @intCast(k)) and !pardes.views.isAway(core, @intCast(k))) core.closeView(@intCast(k)); - s.terms[core.view] = primary; - primary.feed.view = core.view; + for (0..pardes.views.max) |k| if (k != core.live and pardes.views.isOpen(core, @intCast(k)) and !pardes.views.isAway(core, @intCast(k))) core.closeView(@intCast(k)); + s.terms[core.live] = primary; + primary.feed.view = core.live; return; } for (rec.ttys[0..rec.nttys]) |t| { @@ -2229,7 +2229,7 @@ const Shell = struct { s.terms[t.view] = sc; } for (0..pardes.views.max) |k| if (pardes.views.isOpen(core, @intCast(k)) and s.terms[k] == null and !pardes.views.isAway(core, @intCast(k))) core.closeView(@intCast(k)); - if (s.terms[core.view] == null) s.terms[core.view] = primary; + if (s.terms[core.live] == null) s.terms[core.live] = primary; } fn waitInput(ctx: ?*anyopaque, timeout_ms: u32) void { @@ -2427,7 +2427,7 @@ const Shell = struct { } // One of several: its view goes with it. if (pardes.views.count(core) > 1) { - s.dropView(core.view, .detach); + s.dropView(core.live, .detach); return true; } // The terminal went: a session the daemon keeps carries on @@ -2470,7 +2470,7 @@ const Shell = struct { .pty_read => |pr| { tookRead(s.io, pr.id); s.output_seen = true; - if (pr.id == core.active) s.focused_ns = @intCast(std.Io.Clock.awake.now(s.io).nanoseconds); + if (pr.id == core.view().active) s.focused_ns = @intCast(std.Io.Clock.awake.now(s.io).nanoseconds); if (s.gens[pr.id] == pr.gen) core.update(.{ .output = .{ .pane = @intCast(pr.id), .bytes = pr.bytes } }); s.gpa.free(pr.bytes); @@ -2541,7 +2541,7 @@ const Shell = struct { }, .lsp_status => |text| { var mbuf: [256]u8 = undefined; - core.setStatus(core.active, message.stamp(&mbuf, "lsp", text)); + core.setStatus(core.view().active, message.stamp(&mbuf, "lsp", text)); s.lsp_gpa.free(text); }, .pipe_done => |response_value| { @@ -2621,11 +2621,11 @@ const Shell = struct { }; const sc = s.term() orelse return; - s.core.frontend.native_image_patches = sc.feed.shm.load(.acquire); + s.core.view().frontend.native_image_patches = sc.feed.shm.load(.acquire); if (sc.caps_pending and sc.on and sc.vx.queries_done.load(.unordered)) { sc.caps_pending = false; sc.vx.enableDetectedFeatures(sc.tty.writer()) catch {}; - s.core.frontend.native_images = sc.vx.caps.kitty_graphics; + s.core.view().frontend.native_images = sc.vx.caps.kitty_graphics; if (sc.vx.caps.kitty_graphics) kittyShmProbe(sc.tty.writer(), &sc.feed); sc.vx.queueRefresh(); s.core.needs_frame = true; @@ -2759,7 +2759,7 @@ const Shell = struct { // The new shell starts before a running one goes: one that cannot // start leaves the running one be (pty/ctl's exec). const running = s.ptys[pane] != null; - const child = host_io.forkShell(s.core, pane, s.prompt_rcs, s.core.shellBin(), cwd, s.core.screen_h, s.core.screen_w) catch |err| { + const child = host_io.forkShell(s.core, pane, s.prompt_rcs, s.core.shellBin(), cwd, s.core.view().screen_h, s.core.view().screen_w) catch |err| { if (running) return s.core.restartFailed(pane, err); return s.core.shellFailed(pane, err); }; @@ -2924,7 +2924,7 @@ const Shell = struct { const s = of(ctx); if (!s.threads_ok) { s.core.update(.{ .pipe_resp = .{ .id = id, .success = false, .outputs = &.{} } }); - return s.core.reportError(s.core.active, "pipe", error.WorkersUnavailable); + return s.core.reportError(s.core.view().active, "pipe", error.WorkersUnavailable); } selection_pipe.start(s.io, s.gpa, s.core, &s.pipe_tasks, id, s, deliverPipe); } @@ -3023,11 +3023,11 @@ test "TTY worker setup failures finish matching LSP and pipe requests" { .inotify_fd = -1, .threads_ok = true, }; - core.lspRequest(core.active, .status, ""); + core.lspRequest(core.view().active, .status, ""); const req: host_io.Lsp.Request = .{ .id = core.lsp_ask.wait.?.id, .kind = .status, - .pane = @intCast(core.active), + .pane = @intCast(core.view().active), .offset = 0, .arg = "", }; |
