summaryrefslogtreecommitdiff
path: root/src/exec.zig
diff options
context:
space:
mode:
Diffstat (limited to 'src/exec.zig')
-rw-r--r--src/exec.zig19
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;