summaryrefslogtreecommitdiff
path: root/src/Terminal.zig
diff options
context:
space:
mode:
Diffstat (limited to 'src/Terminal.zig')
-rw-r--r--src/Terminal.zig23
1 files changed, 23 insertions, 0 deletions
diff --git a/src/Terminal.zig b/src/Terminal.zig
index 0bec3ce8..cd292e5f 100644
--- a/src/Terminal.zig
+++ b/src/Terminal.zig
@@ -214,6 +214,29 @@ pub fn armShellSpawn(pane: *Pane) void {
pane.pending_command.wait = .spawn;
}
+/// Remembers a line pardes types into this terminal as the command it
+/// started, for Kill: it runs from the shell's next C mark to its D.
+/// ponytail: of several lines queued for a shell not up yet, only the last
+/// is remembered, as the first of them.
+pub fn noteCommand(pane: *Pane, line: []const u8) void {
+ if (comptime !enabled) return;
+ const state = pane.terminal orelse return;
+ const word = std.mem.trim(u8, line, " \t")[0 .. std.mem.indexOfAny(u8, std.mem.trim(u8, line, " \t"), " \t") orelse std.mem.trim(u8, line, " \t").len];
+ var sent: @typeInfo(@FieldType(Pane, "sent_command")).optional.child = .{ .seq = state.stream.handler.started +% 1 };
+ sent.len = @intCast(@min(word.len, sent.word.len));
+ @memcpy(sent.word[0..sent.len], word[0..sent.len]);
+ pane.sent_command = sent;
+}
+
+/// Whether the command pardes last typed here is running now.
+pub fn commandRunning(pane: *const Pane) bool {
+ if (comptime !enabled) return false;
+ const state = pane.terminal orelse return false;
+ const sent = pane.sent_command orelse return false;
+ const marks = &state.stream.handler;
+ return marks.phase == .running and marks.started == sent.seq;
+}
+
pub fn queuePendingCommand(pane: *Pane, command: []const u8) !bool {
if (pane.pending_command.wait == .none) return false;
const old_len = pane.pending_command.bytes.len;