diff options
Diffstat (limited to 'dev/gui/gui.zig')
| -rw-r--r-- | dev/gui/gui.zig | 60 |
1 files changed, 9 insertions, 51 deletions
diff --git a/dev/gui/gui.zig b/dev/gui/gui.zig index ab33abe9..fa480665 100644 --- a/dev/gui/gui.zig +++ b/dev/gui/gui.zig @@ -379,7 +379,6 @@ fn sdlWake(_: ?*anyopaque) void { sev.type = c.SDL_EVENT_USER; _ = c.SDL_PushEvent(&sev); } -const PipeTasks = selection_pipe.Tasks; const output_capacity = Queue.output_capacity; const Gui = struct { @@ -991,7 +990,6 @@ const Own = struct { g: *Gui, test_mode: bool, detached: bool, - pipe_tasks: PipeTasks = .{}, shell: Shell = undefined, const Session = session_loop.Loop(Own); @@ -1024,7 +1022,6 @@ const Own = struct { .lsp_allocator = l.allocs.lsp, .ptys = &l.ptys, .queue = &l.inbox, - .pipe_tasks = &o.pipe_tasks, .watches = &l.watches, .fs = l.fs, .test_mode = o.test_mode, @@ -1044,15 +1041,10 @@ const Own = struct { return host; } - pub fn close(o: *Own, l: *Session) void { - const io = l.io; + pub fn close(o: *Own, _: *Session) void { o.shell.fs = null; host_io.setExitWake(null, null); pardes.Kind.drawer = null; - o.shell.job_tasks.cancelAll(io); - o.pipe_tasks.cancelAll(io); - // Its worker may be waiting on the queue for room. - l.core.stream.cancelTask(); o.g.hit_core = null; } @@ -1084,7 +1076,6 @@ const Own = struct { } pub fn restoring(o: *Own, nc: *pardes.Pardes) void { - o.pipe_tasks.cancelAll(o.shell.io); // One view, the window's (host_io.restoreCore). o.shell.gview = 0; o.g.cells.clearImages(); @@ -1415,7 +1406,6 @@ fn clientSession(init: std.process.Init, g: *Gui, opts_in: pardes.Options, test_ var queue: Queue = .{ .io = io, .gpa = gpa, .lsp_allocator = start.allocs.lsp, .wake_fn = sdlWake }; defer queue.deinit(); var ptys: host_io.Ptys = .{ .queue = &queue, .prompt_rcs = undefined }; - var pipe_tasks: PipeTasks = .{}; var no_watches: file_watch.Watches = .{ .io = io, .gpa = gpa, .queue = &queue }; var no_peers: replica.Peers = .{}; var shell: Shell = .{ @@ -1426,7 +1416,6 @@ fn clientSession(init: std.process.Init, g: *Gui, opts_in: pardes.Options, test_ .lsp_allocator = start.allocs.lsp, .ptys = &ptys, .queue = &queue, - .pipe_tasks = &pipe_tasks, .watches = &no_watches, .test_mode = test_mode, .client = &window, @@ -1435,7 +1424,6 @@ fn clientSession(init: std.process.Init, g: *Gui, opts_in: pardes.Options, test_ window.shell = &shell; pardes.Kind.drawer = .{ .ctx = &shell, .go = kindDraw }; defer pardes.Kind.drawer = null; - defer shell.job_tasks.cancelAll(io); g.no_blink = test_mode; defer g.hit_core = null; _ = c.SDL_StartTextInput(g.window); @@ -2351,8 +2339,6 @@ const Shell = struct { queue: *Queue, /// What drainQueue takes each wakeup, kept rather than rebuilt. batch: Queue.Batch = .{}, - pipe_tasks: *PipeTasks, - job_tasks: PipeTasks = .{}, /// The session's file watches (runtime/session.zig's); a client's, /// none. watches: *file_watch.Watches, @@ -2561,10 +2547,7 @@ const Shell = struct { fn takeDraws(s: *Shell) bool { s.queue.takeInto(&s.batch); for (s.batch.slice()) |m| switch (m) { - .kind_job => |j| { - s.job_tasks.finish(s.io, j.id); - j.land(s.core); - }, + .kind_job => s.queue.land(s.core, m), else => m.deinit(s.gpa, s.lsp_allocator), }; return s.batch.slice().len > 0; @@ -2580,33 +2563,10 @@ const Shell = struct { for (msgs.slice()) |m| switch (m) { .output => |o| s.ptys.output(s.core, o), .eof => |e| s.ptys.eof(s.core, e), - .lsp, .lsp_status => s.queue.landLsp(s.core, m), - .pipe => |response_value| { - var response = response_value; - s.core.update(.{ .pipe_resp = .{ - .id = response.id, - .success = response.success, - .outputs = response.outputs, - .failure = response.failure, - } }); - response.deinit(s.gpa); - s.pipe_tasks.finish(s.io, response_value.id); - }, - .search => |b| { - s.core.update(.{ .search = b }); - b.deinit(s.gpa); - }, - .handed => |h| { - s.core.update(.{ .handed = .{ .seq = h.seq, .to = if (h.ok) h.words else "", .failure = if (h.ok) null else h.words } }); - s.gpa.free(h.words); - }, - .kind_job => |j| { - s.job_tasks.finish(s.io, j.id); - j.land(s.core); - }, .files_changed => check_files = true, .fs_ready => {}, .adopted => |a| s.ptys.adoptions.adoptShell(s.core, a.pid, a.fd), + else => s.queue.land(s.core, m), }; if (check_files) s.watches.reload(s.core); } @@ -3178,7 +3138,7 @@ fn lsp(ctx: ?*anyopaque, req: host_io.Lsp.Request) void { fn pipe(ctx: ?*anyopaque, id: u32) void { const s = shellOf(ctx); - if (s.threads_ok) return selection_pipe.start(s.io, s.gpa, s.core, s.pipe_tasks, id, s.queue, Queue.pushPipe); + if (s.threads_ok) return selection_pipe.start(s.io, s.gpa, s.core, &s.queue.pipe_tasks, id, s.queue, Queue.pushPipe); s.core.update(.{ .pipe_resp = .{ .id = id, .success = false, .outputs = &.{} } }); s.core.reportError(.at(s.core.view().active), "pipe", error.WorkersUnavailable); } @@ -3186,13 +3146,13 @@ fn pipe(ctx: ?*anyopaque, id: u32) void { /// A draw (api.draw) on a worker, as a job is. fn kindDraw(ctx: ?*anyopaque, j: *host_io.KindJob) bool { const s = shellOf(ctx); - return (s.threads_ok or s.client != null) and host_io.KindJob.go(s.io, &s.job_tasks, j, s.queue, Queue.pushJob); + return (s.threads_ok or s.client != null) and host_io.KindJob.go(s.io, &s.queue.job_tasks, j, s.queue, Queue.pushJob); } fn kindJob(ctx: ?*anyopaque, id: pardes.Pane.Id, serial: u32, token: u32) void { const pane = id.index(); const s = shellOf(ctx); - if (s.threads_ok) return host_io.KindJob.start(s.io, s.core, &s.job_tasks, pane, serial, token, s.queue, Queue.pushJob); + if (s.threads_ok) return host_io.KindJob.start(s.io, s.core, &s.queue.job_tasks, pane, serial, token, s.queue, Queue.pushJob); host_io.KindJob.runHere(s.core, pane, serial, token); } @@ -5976,7 +5936,6 @@ test "GUI worker setup failures finish matching LSP and pipe requests" { .lsp_allocator = failing.allocator(), }; defer queue.deinit(); - var tasks: PipeTasks = .{}; core.lspRequest(core.view().active, .status, ""); const req: host_io.Lsp.Request = .{ .id = core.lsp_ask.wait.?.id, @@ -6008,11 +5967,11 @@ test "GUI worker setup failures finish matching LSP and pipe requests" { core.update(.{ .key = .{ .cp = 't', .text = "tr a-z A-Z" } }); core.update(.{ .key = .{ .cp = pardes.Key.enter } }); const pipe_id = core.pipe.wait.?.id; - selection_pipe.start(failing_io, failing.allocator(), core, &tasks, pipe_id, &queue, Queue.pushPipe); + selection_pipe.start(failing_io, failing.allocator(), core, &queue.pipe_tasks, pipe_id, &queue, Queue.pushPipe); try std.testing.expect(core.pipe.wait == null); try std.testing.expectEqualStrings("abc", pane.file.?.content); try std.testing.expect(queue.lsp_task == null); - try std.testing.expectEqual(@as(usize, 0), tasks.len); + try std.testing.expectEqual(@as(usize, 0), queue.pipe_tasks.len); try std.testing.expectEqual(@as(usize, 0), queue.len); } } @@ -7676,9 +7635,8 @@ test "a detached GUI authority follows terminal directory changes with no window const rcs: host_io.Shell.PromptFiles = .{}; var ptys: host_io.Ptys = .{ .queue = &queue, .prompt_rcs = &rcs, .gens = @splat(1) }; defer ptys.deinit(); - var pipes: PipeTasks = .{}; var no_peers: replica.Peers = .{}; - var shell: Shell = .{ .core = core, .io = io, .gpa = gpa, .lsp_allocator = gpa, .ptys = &ptys, .queue = &queue, .pipe_tasks = &pipes, .watches = undefined, .peers = &no_peers }; + var shell: Shell = .{ .core = core, .io = io, .gpa = gpa, .lsp_allocator = gpa, .ptys = &ptys, .queue = &queue, .watches = undefined, .peers = &no_peers }; const child = try host_io.forkShell(null, 0, &rcs, "/bin/sh", start, 24, 80); ptys.slots[0] = .{ .fd = child.file.handle, .pid = child.pid }; try std.testing.expect(host_io.writeFd(child.file.handle, "cd child\n")); |
