summaryrefslogtreecommitdiff
path: root/src/Term.zig
diff options
context:
space:
mode:
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,
+};