summaryrefslogtreecommitdiff
path: root/src/Term.zig
diff options
context:
space:
mode:
authorGabriel Schneider <[email protected]>2026-11-17 00:32:48 -0300
committerGabriel Schneider <[email protected]>2026-11-17 12:15:01 -0300
commit1d382a3ed42788e82301d0ce2a16ebc35c79046c (patch)
tree2da33a886055944f17dc7e6c53cdc0aa49735c97 /src/Term.zig
parent9c2fc736b9ccd7b7eea11e7f544ed540d2d2a6c2 (diff)
downloadpardes-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/Term.zig')
-rw-r--r--src/Term.zig45
1 files changed, 45 insertions, 0 deletions
diff --git a/src/Term.zig b/src/Term.zig
index 504aef7a..ba0a2307 100644
--- a/src/Term.zig
+++ b/src/Term.zig
@@ -121,3 +121,48 @@ pub const Modes = struct {
/// It has the alternate screen (1049).
alternate: bool = false,
};
+
+// ---- prompt and commands ----
+
+/// Where its shell is in its command cycle (`Prompt`).
+pub const prompt = terminal.prompt;
+/// What the newest finished command printed (`CommandOutput`), read from
+/// at most so many rows above its end.
+pub const commandOutput = terminal.commandOutput;
+/// The shell exited in the middle of a command: its output ends at the
+/// cursor.
+pub const endOutputHere = terminal.endOutputHere;
+
+/// Where a shell is in its command cycle, as pardes's own OSC 133 marks
+/// tell it (marks carrying its `aid` alone: a nested shell's pass it by),
+/// and what is at its cursor. All zero without a terminal.
+pub const Prompt = struct {
+ phase: enum { none, prompt, input, running } = .none,
+ /// Commands started (C at the input phase), prompts drawn (B), and D
+ /// marks outside a running command (a line the shell handled without
+ /// starting it).
+ started: u32 = 0,
+ prompts: u32 = 0,
+ declined: u32 = 0,
+ /// The newest prompt continues an unfinished line (bash's PS2).
+ continuation: bool = false,
+ /// The newest command to end: which one, and its status if given.
+ finished: ?struct { seq: u32, status: ?i32 } = null,
+ /// The cursor is at a prompt's input, on either screen.
+ input_ready: bool = false,
+ /// ...and nothing is typed on its line up to the cursor.
+ input_empty: bool = false,
+ /// The cursor is on a prompt's row or at its input, on the primary
+ /// screen.
+ at_prompt: bool = false,
+};
+
+/// What a command printed. `text` is the caller's.
+pub const CommandOutput = struct {
+ text: [:0]const u8,
+ /// Whether `text` starts where the command did. It does not when that
+ /// start is not there to read: cut off by the rows asked for, scrolled
+ /// out of the history or erased from it (ED 3), erased under it while
+ /// it ran, or never marked (a C or D on the alternate screen).
+ whole: bool,
+};