summaryrefslogtreecommitdiff
path: root/src/host_io.zig
diff options
context:
space:
mode:
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);