diff options
| author | Gabriel Schneider <[email protected]> | 2026-11-17 00:32:48 -0300 |
|---|---|---|
| committer | Gabriel Schneider <[email protected]> | 2026-11-17 12:15:01 -0300 |
| commit | 1d382a3ed42788e82301d0ce2a16ebc35c79046c (patch) | |
| tree | 2da33a886055944f17dc7e6c53cdc0aa49735c97 /src/exec.zig | |
| parent | 9c2fc736b9ccd7b7eea11e7f544ed540d2d2a6c2 (diff) | |
| download | pardes-1d382a3ed42788e82301d0ce2a16ebc35c79046c.tar.gz pardes-1d382a3ed42788e82301d0ce2a16ebc35c79046c.zip | |
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
Diffstat (limited to 'src/exec.zig')
| -rw-r--r-- | src/exec.zig | 19 |
1 files changed, 15 insertions, 4 deletions
diff --git a/src/exec.zig b/src/exec.zig index d7fb19d8..23c624bd 100644 --- a/src/exec.zig +++ b/src/exec.zig @@ -669,7 +669,8 @@ pub fn takesCommandLine(p: *const Pardes, id: usize) bool { // idle, EMPTY prompt is typed at; otherwise a new pane runs the line. // (Text in pardes's own edit buffer is not the shell's yet: an exec of // it, or of anything, types only what it runs.) - if (panes.terminal.promptInputReady(pane) and !panes.terminal.promptInputEmpty(pane)) return false; + const at = panes.Term.prompt(pane.terminal); + if (at.input_ready and !at.input_empty) return false; return !p.hostTtyTaken(id); } @@ -710,9 +711,19 @@ pub fn executeFrom(p: *Pardes, id: usize, txt: []const u8, from_body: bool) ?usi // command pane in the session's directory, never typed into whichever // terminal has the keyboard. if (p.exec_header or !takesCommandLine(p, id)) return runCommand(p, id, cmd); - panes.terminal.padOutputBelowEdits(p, id); - panes.terminal.noteCommand(pane, cmd); - if (panes.terminal.queuePendingCommand(pane, cmd) catch |err| { + // At a prompt with typed text below it: the output area padded with + // newlines so the command's output does not overwrite the buffer. + if (pane.ovl) |o| if (pane.isTerminal()) if (pane.terminal) |state| if (panes.Term.prompt(state).at_prompt) { + // the buffer's LAST surface row: its lines may outnumber the shell + // rows it covers, and it is the bottom one output must clear + const max_row = o.row + @as(i32, @intCast(modal.lineCount(o.text))) - 1; + const grid = panes.Term.grid(state); + const cursor_abs = pane.surfRow(@as(i32, @intCast(grid.offset)) + @as(i32, grid.cursor_y)); + const pad = std.math.clamp(max_row - cursor_abs, 0, @as(i32, pane.rows)); + for (0..@intCast(pad)) |_| p.emitWrite(id, "\r"); + }; + pane.noteCommand(cmd); + if (pane.queuePendingCommand(cmd) catch |err| { p.reportError(id, "queue command", err); return id; }) return id; |
