summaryrefslogtreecommitdiff
path: root/src/tui/tui.zig
diff options
context:
space:
mode:
Diffstat (limited to 'src/tui/tui.zig')
-rw-r--r--src/tui/tui.zig16
1 files changed, 16 insertions, 0 deletions
diff --git a/src/tui/tui.zig b/src/tui/tui.zig
index 919eeded..3938c854 100644
--- a/src/tui/tui.zig
+++ b/src/tui/tui.zig
@@ -737,6 +737,8 @@ pub fn runClient(init: std.process.Init, opts: pardes.Options, path: []const u8,
.client = &client_link,
};
+ pardes.Kind.drawer = .{ .ctx = &sh, .go = Shell.draw };
+ defer pardes.Kind.drawer = null;
try startInput(&loop, &screen);
defer stopInput(io, &screen.thread);
(try std.Thread.spawn(.{}, winchWatch, .{&loop})).detach();
@@ -1073,6 +1075,8 @@ fn localSession(
const host = sh.host();
core.host = host;
+ pardes.Kind.drawer = .{ .ctx = &sh, .go = Shell.draw };
+ defer pardes.Kind.drawer = null;
// 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).
@@ -1831,6 +1835,8 @@ const Shell = struct {
.kind_job => |j| {
s.job_tasks.finish(s.io, j.id);
j.land(core);
+ // A client's draw done: its frame is its own to draw again.
+ if (s.client) |cl| cl.link.dirty = true;
},
}
return false;
@@ -2202,6 +2208,16 @@ const Shell = struct {
pardes.Stream.runHere(s.core, gen);
}
+ /// A draw (api.draw) on a worker, as a job is.
+ fn draw(ctx: ?*anyopaque, j: *host_io.KindJob) bool {
+ const s = of(ctx);
+ return (s.threads_ok or s.client != null) and host_io.KindJob.go(s.io, &s.job_tasks, j, s, struct {
+ fn deliver(c: ?*anyopaque, k: *host_io.KindJob) void {
+ of(c).loop.postEvent(.{ .kind_job = k }) catch k.drop();
+ }
+ }.deliver);
+ }
+
fn job(ctx: ?*anyopaque, pane: u8, serial: u32, token: u32) void {
const s = of(ctx);
if (!s.threads_ok) return host_io.KindJob.runHere(s.core, pane, serial, token);