summaryrefslogtreecommitdiff
path: root/src/host_io.zig
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/host_io.zig
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/host_io.zig')
-rw-r--r--src/host_io.zig32
1 files changed, 16 insertions, 16 deletions
diff --git a/src/host_io.zig b/src/host_io.zig
index 1808d266..19cc920f 100644
--- a/src/host_io.zig
+++ b/src/host_io.zig
@@ -197,12 +197,12 @@ pub fn stopWorkers() void {
pub fn restoreCore(gpa: std.mem.Allocator, core: *pardes.Pardes, path: []const u8, peers: *replica.Peers, inotify_fd: c_int, watches: *file_watch.Table) ?*pardes.Pardes {
peers.dropAll(core);
const bytes = pardes.dump.restoreBytes(core, gpa, path) catch |err| {
- core.reportError(core.active, "Restore", err);
+ core.reportError(core.view().active, "Restore", err);
return null;
};
defer gpa.free(bytes);
const nc = pardes.dump.restore(core, bytes, path) catch |err| {
- core.reportError(core.active, "Restore", err);
+ core.reportError(core.view().active, "Restore", err);
return null;
};
file_watch.unwatchAll(inotify_fd, watches);
@@ -236,7 +236,7 @@ pub const Adoptions = struct {
pub fn adoptShell(a: *Adoptions, core: *pardes.Pardes, pid: libc.pid_t, fd: c_int) void {
if (pid == 0) {
var buf: [96]u8 = undefined;
- return core.setMessage(core.active, if (a.taken == 0) "Adopt: no shell of a session that died is waiting" else std.fmt.bufPrint(&buf, "Adopt: {d} shell{s} taken in; what they showed is gone", .{ a.taken, if (a.taken == 1) "" else "s" }) catch "Adopt: shells taken in");
+ return core.setMessage(core.view().active, if (a.taken == 0) "Adopt: no shell of a session that died is waiting" else std.fmt.bufPrint(&buf, "Adopt: {d} shell{s} taken in; what they showed is gone", .{ a.taken, if (a.taken == 1) "" else "s" }) catch "Adopt: shells taken in");
}
if (a.len < a.list.len) {
a.list[a.len] = .{ .pid = pid, .fd = fd, .pane = null };
@@ -251,7 +251,7 @@ pub const Adoptions = struct {
// No room for it: its master goes, and the shell with this session.
_ = libc.close(fd);
var buf: [96]u8 = undefined;
- core.setMessage(core.active, std.fmt.bufPrint(&buf, "Adopt: no room for shell {d}; it ends with this session", .{pid}) catch "Adopt: no room for a shell");
+ core.setMessage(core.view().active, std.fmt.bufPrint(&buf, "Adopt: no room for shell {d}; it ends with this session", .{pid}) catch "Adopt: no room for a shell");
}
/// The adopted shell pane `pane`'s spawn takes, off the list.
@@ -868,7 +868,7 @@ pub const Lsp = struct {
const job = try snapshot(gpa, core, .{
.id = 7,
.kind = .status,
- .pane = @intCast(core.active),
+ .pane = @intCast(core.view().active),
.offset = 0,
.arg = &needle,
});
@@ -883,7 +883,7 @@ pub const Lsp = struct {
try std.testing.expectEqualStrings("", job.path);
try std.testing.expectEqual(@as(usize, 0), job.source.len);
try std.testing.expectEqual(@as(u8, 0), job.source[0]);
- const pane = core.panes[core.active].?;
+ const pane = core.panes[core.view().active].?;
try std.testing.expectEqualStrings(pane.cwdSlice(), job.root);
if (job.root.len > 0) try std.testing.expect(job.root.ptr != pane.cwdSlice().ptr);
}
@@ -897,7 +897,7 @@ pub const Lsp = struct {
const job = try snapshot(gpa, p, .{
.id = 7,
.kind = .hover,
- .pane = @intCast(p.active),
+ .pane = @intCast(p.view().active),
.offset = 6,
.arg = "query",
});
@@ -921,7 +921,7 @@ pub const Lsp = struct {
const replacement = try gpa.dupe(u8, case.path);
gpa.free(pane.file.?.path);
pane.file.?.path = replacement;
- const job = try snapshot(gpa, core, .{ .id = 1, .kind = .hover, .pane = @intCast(core.active), .offset = 0, .arg = "" });
+ const job = try snapshot(gpa, core, .{ .id = 1, .kind = .hover, .pane = @intCast(core.view().active), .offset = 0, .arg = "" });
defer job.free(gpa);
try std.testing.expectEqualStrings(case.native, job.path);
try std.testing.expectEqualStrings(std.fs.path.dirname(case.native).?, job.root);
@@ -967,7 +967,7 @@ pub const Lsp = struct {
const job = try snapshot(gpa, core, .{
.id = 42,
.kind = .status,
- .pane = @intCast(core.active),
+ .pane = @intCast(core.view().active),
.offset = 0,
.arg = "",
});
@@ -1011,11 +1011,11 @@ pub const Lsp = struct {
var sink: Sink = .{ .core = core, .gpa = failing.allocator() };
for ([_]bool{ true, false }) |fail| {
failing.fail_index = std.math.maxInt(usize);
- core.lspRequest(core.active, kind, "renamed");
+ core.lspRequest(core.view().active, kind, "renamed");
const job = try snapshot(failing.allocator(), core, .{
.id = core.lsp_ask.wait.?.id,
.kind = kind,
- .pane = @intCast(core.active),
+ .pane = @intCast(core.view().active),
.offset = 6,
.arg = "renamed",
});
@@ -1084,7 +1084,7 @@ pub const Lsp = struct {
} };
const core = try pardes.Pardes.init(std.testing.allocator, .{ .tty_only = true });
defer core.deinit();
- const job = try snapshot(gpa, core, .{ .id = 37, .kind = .status, .pane = @intCast(core.active), .offset = 0, .arg = "" });
+ const job = try snapshot(gpa, core, .{ .id = 37, .kind = .status, .pane = @intCast(core.view().active), .offset = 0, .arg = "" });
var sink: Sink = .{};
work(std.testing.io, gpa, job, &sink, Sink.take);
if (sink.rows) |rows| gpa.free(rows);
@@ -2152,8 +2152,8 @@ pub const exec_command_max = pardes.exec.command_max;
pub fn ptyWinsize(core: ?*const pardes.Pardes, cols: u16, rows: u16) posix.winsize {
var ws: posix.winsize = .{ .row = rows, .col = cols, .xpixel = 0, .ypixel = 0 };
if (comptime pardes.pdf_enabled) if (core) |c| {
- ws.xpixel = std.math.cast(u16, @as(u32, cols) * c.cell_pixels.w) orelse 0;
- ws.ypixel = std.math.cast(u16, @as(u32, rows) * c.cell_pixels.h) orelse 0;
+ ws.xpixel = std.math.cast(u16, @as(u32, cols) * c.view().cell_pixels.w) orelse 0;
+ ws.ypixel = std.math.cast(u16, @as(u32, rows) * c.view().cell_pixels.h) orelse 0;
};
return ws;
}
@@ -3853,8 +3853,8 @@ test "LSP query answers, and a newer one cancels it" {
var queue: Inbox = .{ .io = std.testing.io, .gpa = gpa, .lsp_allocator = gpa };
defer queue.deinit();
for (0..2) |_| {
- core.lspRequest(core.active, .status, "");
- queue.startLsp(core, .{ .id = core.lsp_ask.wait.?.id, .kind = .status, .pane = @intCast(core.active), .offset = 0, .arg = "" });
+ core.lspRequest(core.view().active, .status, "");
+ queue.startLsp(core, .{ .id = core.lsp_ask.wait.?.id, .kind = .status, .pane = @intCast(core.view().active), .offset = 0, .arg = "" });
}
const last = core.lsp_ask.wait.?.id;
queue.lsp_task.?.future.await(io);