From d2a066ea4ffe4388fe0da71bd8389649ac59b73f Mon Sep 17 00:00:00 2001 From: Gabriel Schneider Date: Thu, 5 Nov 2026 00:49:57 -0300 Subject: host_io: the image, PDF and syntax subsystems a session draws with start and stop in one place (startWorkers, stopWorkers), where the tty's local session, the window's session and its test grid each started them and deferred their stop in eleven lines of their own Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_016Y9MNAtZenFv4weoMD3cge --- src/host_io.zig | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'src/host_io.zig') diff --git a/src/host_io.zig b/src/host_io.zig index 97e6cbbc..d6b9b72e 100644 --- a/src/host_io.zig +++ b/src/host_io.zig @@ -75,6 +75,27 @@ pub fn testClock() ?u64 { return if (libc.getenv("PARDES_TEST_CLOCK")) |v| (if (std.mem.span(v).len != 0) 0 else null) else null; } +/// The image, PDF and syntax subsystems a frontend's session draws with, +/// on `allocs` (pardes.memory.init); PDF pages render on lanes off the +/// loop (pdf_view.workers). `stopWorkers` is its defer. +pub fn startWorkers(io: std.Io, allocs: pardes.memory.Allocators) void { + pardes.image.start(io, allocs.image); + if (comptime pardes.pdf_enabled) { + pardes.pdf.start(allocs.pdf); + pardes.panes.Pdf.workers = io; + } + pardes.syntax.start(allocs.tree_sitter); +} + +pub fn stopWorkers() void { + pardes.image.stop(); + if (comptime pardes.pdf_enabled) { + pardes.panes.Pdf.dropKept(); + pardes.pdf.stop(); + } + pardes.syntax.stop(); +} + pub const Fallback = struct { pub const dump_path = "pardes.dump"; -- cgit v1.3