summaryrefslogtreecommitdiff
path: root/src/tui
diff options
context:
space:
mode:
authorGabriel Schneider <[email protected]>2026-11-06 02:56:53 -0300
committerGabriel Schneider <[email protected]>2026-11-06 04:13:33 -0300
commitd1d5d3cfb18841604bba2057eeb3598f729b4475 (patch)
tree298c29ab8767852bf74eb86ad4d15acc4348f109 /src/tui
parent33037ece5af9ae1c7048819bbbae3fc5e6fc4ade (diff)
downloadpardes-d1d5d3cfb18841604bba2057eeb3598f729b4475.tar.gz
pardes-d1d5d3cfb18841604bba2057eeb3598f729b4475.zip
client #1, the views indexed: a view's share of the session is Pardes.View (the ~42 fields views.fields named: size, cell metrics, columns, rects, focus, jumps, pointer, gestures, prefixes, frontend), one of Pardes.views[4] (null when closed), the live one views[live] through Pardes.view() (index field `view` renamed `live`); going into another view is the index plus the panes' shares, which stay swapped (park and unpark now move only Pane.pv); views.zig loses fields, Part over Pardes, Parked, kept, emptied and the session half of every copy, and a pane closing leaves every view's layout at once (views.gone, at the two places a slot is freed) instead of the serials each parked view kept; drawOne and within put the drawn view's own share back whole; the views are in the digest now (tape's per-field parts name views[k].field), so a fresh view's col_x/col_w default to zeros, not undefined; the dump keeps every open view in the core and the panes' shares of the others under `shares`; an image from before (live view as the core's own fields, the rest under `views`) loads them into views[] once; the ~2,400 references rewritten mechanically from the compiler's errors (p.active is p.view().active, `const v = p.view()` hoisted in 823 places), Kind.zig (4 lines) and addon_test.zig (3) among them, macos.zig by pattern (not compiled here); tape's watched host writes read the live view's frontend and active; perf.zig's accessor lines change its harness hash, the debug baselines re-keyed to it (their numbers the base's); no golden changes; gates: core-test 956/956 both, unit-test 1487/1488 tui and 1530/1531 gui, behaviour-test 248/248 both, pane-test 171/172, snap all 105 ok, process-test 0 of 37 failed tui, replicas ok
Co-Authored-By: Claude Fable 5.1 <[email protected]> Claude-Session: https://claude.ai/code/session_016Y9MNAtZenFv4weoMD3cge
Diffstat (limited to 'src/tui')
-rw-r--r--src/tui/tui.zig48
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 = "",
};