From 1d382a3ed42788e82301d0ce2a16ebc35c79046c Mon Sep 17 00:00:00 2001 From: Gabriel Schneider Date: Tue, 17 Nov 2026 00:32:48 -0300 Subject: Term: prompt and commands through the interface: Term.prompt is the plain record of where the shell is in its command cycle (its phase, commands started, prompts drawn, lines declined, a continuation, the last command to finish and its status, input ready, input empty, the cursor at a prompt), Term.commandOutput what the newest command printed and Term.endOutputHere ends a command's output at the cursor; the pending command queue is the core's (Pane.pending_command, Pane.queuePendingCommand and Pane.releasePendingCommand, released at the shell's start or its prompt where Core.zig hears of them), and so are Pane.greeting, Pane.noteCommand, Kill's "the command pardes typed runs" (builtins.zig) and the newlines that keep a command's output below the edit copy (exec.zig); /pty/status, /pty/run and predicted echo read the record; promptInputReady, promptInputEmpty, commandRunning, armShellSpawn, shellSpawned, deinitPendingCommand and padOutputBelowEdits go; nothing else changes --- src/Core.zig | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) (limited to 'src/Core.zig') diff --git a/src/Core.zig b/src/Core.zig index 700ab7ab..55848aa9 100644 --- a/src/Core.zig +++ b/src/Core.zig @@ -993,7 +993,16 @@ pub fn acknowledgeShell(p: *Pardes, id: usize, executable: []const u8, prompt_ma } else |_| {} } }; - if (id < MAX_PANES) pardes.panes.terminal.shellSpawned(p, id, prompt_marks); + // The lines queued for it go when it can take them: at its first + // prompt, or now when it draws no marks to wait for. + if (id < MAX_PANES) if (p.panes[id]) |pane| if (pane.isTerminal() and pane.pending_command.wait == .spawn) { + if (prompt_marks) { + pane.pending_command.wait = .input; + } else { + pane.greet = false; + pane.releasePendingCommand(p, id, true); + } + }; if (p.settings.shell.effective.set(executable)) p.settings.shell.pending = false; } @@ -1874,15 +1883,19 @@ pub fn sync(p: *Pardes) void { // A directory pane's entries follow its width, as acme's // columns do (Dir.fit). if (pane.file) |file| if (file.listing != null and r.h > pane.tag_rows) pardes.panes.Dir.fit(p, pane, pane.cols); - pardes.panes.terminal.releasePendingCommandIfReady(p, id, pane); + if (pane.pending_command.wait == .input) pane.releasePendingCommand(p, id, tape.value(.prompt, struct { + fn ready(at: *const Pane) bool { + return pardes.Term.prompt(at.terminal).input_ready; + } + }.ready, .{pane})); // Which bands a pane shows is the step's, as its geometry is: // what is drawn under them, and where a click lands, read it. Messages.collectNotices(p, pane, r, id); // The greeting `ls` of a new terminal in a directory is typed at // its shell's FIRST prompt, or never: typed later it would land // in whatever runs then, or in the middle of a line someone - // typed (panes.terminal.greeting). - if (pane.greet and pane.isTerminal() and p.resize_count > 0) switch (tape.value(.prompt, pardes.panes.terminal.greeting, .{pane})) { + // typed (Pane.greeting). + if (pane.greet and pane.isTerminal() and p.resize_count > 0) switch (tape.value(.prompt, Pane.greeting, .{pane})) { .wait => {}, .never => pane.greet = false, .now => { -- cgit v1.3