mirror of
https://github.com/ghostty-org/ghostty.git
synced 2026-04-19 05:50:27 +00:00
terminal: remove last semantic_prompt usage from Terminal
This commit is contained in:
@@ -1189,19 +1189,6 @@ pub const SemanticPrompt = enum {
|
||||
command,
|
||||
};
|
||||
|
||||
/// Mark the current semantic prompt information. Current escape sequences
|
||||
/// (OSC 133) only allow setting this for wherever the current active cursor
|
||||
/// is located.
|
||||
pub fn markSemanticPrompt(self: *Terminal, p: SemanticPrompt) void {
|
||||
//log.debug("semantic_prompt y={} p={}", .{ self.screens.active.cursor.y, p });
|
||||
self.screens.active.cursor.page_row.semantic_prompt = switch (p) {
|
||||
.prompt => .prompt,
|
||||
.prompt_continuation => .prompt_continuation,
|
||||
.input => .input,
|
||||
.command => .command,
|
||||
};
|
||||
}
|
||||
|
||||
/// Returns true if the cursor is currently at a prompt. Another way to look
|
||||
/// at this is it returns false if the shell is currently outputting something.
|
||||
/// This requires shell integration (semantic prompt integration).
|
||||
@@ -2360,19 +2347,15 @@ pub fn eraseDisplay(
|
||||
);
|
||||
while (it.next()) |p| {
|
||||
const row = p.rowAndCell().row;
|
||||
switch (row.semantic_prompt) {
|
||||
switch (row.semantic_prompt2) {
|
||||
// If we're at a prompt or input area, then we are at a prompt.
|
||||
.prompt,
|
||||
.prompt_continuation,
|
||||
.input,
|
||||
=> break,
|
||||
|
||||
// If we have command output, then we're most certainly not
|
||||
// at a prompt.
|
||||
.command => break :at_prompt,
|
||||
|
||||
// If we don't know, we keep searching.
|
||||
.unknown => {},
|
||||
.no_prompt => break :at_prompt,
|
||||
}
|
||||
} else break :at_prompt;
|
||||
|
||||
|
||||
@@ -153,7 +153,7 @@ pub const Handler = struct {
|
||||
.full_reset => self.terminal.fullReset(),
|
||||
.start_hyperlink => try self.terminal.screens.active.startHyperlink(value.uri, value.id),
|
||||
.end_hyperlink => self.terminal.screens.active.endHyperlink(),
|
||||
.semantic_prompt => try self.semanticPrompt(value),
|
||||
.semantic_prompt => try self.terminal.semanticPrompt(value),
|
||||
.mouse_shape => self.terminal.mouse_shape = value,
|
||||
.color_operation => try self.colorOperation(value.op, &value.requests),
|
||||
.kitty_color_report => try self.kittyColorOperation(value),
|
||||
@@ -209,44 +209,6 @@ pub const Handler = struct {
|
||||
}
|
||||
}
|
||||
|
||||
fn semanticPrompt(
|
||||
self: *Handler,
|
||||
cmd: Action.SemanticPrompt,
|
||||
) !void {
|
||||
switch (cmd.action) {
|
||||
.fresh_line_new_prompt => {
|
||||
const kind = cmd.readOption(.prompt_kind) orelse .initial;
|
||||
switch (kind) {
|
||||
.initial, .right => {
|
||||
self.terminal.markSemanticPrompt(.prompt);
|
||||
if (cmd.readOption(.redraw)) |redraw| {
|
||||
self.terminal.flags.shell_redraws_prompt = redraw;
|
||||
}
|
||||
},
|
||||
.continuation, .secondary => {
|
||||
self.terminal.markSemanticPrompt(.prompt_continuation);
|
||||
},
|
||||
}
|
||||
},
|
||||
|
||||
.end_prompt_start_input => self.terminal.markSemanticPrompt(.input),
|
||||
.end_input_start_output => self.terminal.markSemanticPrompt(.command),
|
||||
.end_command => self.terminal.screens.active.cursor.page_row.semantic_prompt = .input,
|
||||
|
||||
// All of these commands weren't previously handled by our
|
||||
// semantic prompt code. I am PR-ing the parser separate from the
|
||||
// handling so we just ignore these like we did before, even
|
||||
// though we should handle them eventually.
|
||||
.end_prompt_start_input_terminate_eol,
|
||||
.new_command,
|
||||
.fresh_line,
|
||||
.prompt_start,
|
||||
=> {},
|
||||
}
|
||||
|
||||
try self.terminal.semanticPrompt(cmd);
|
||||
}
|
||||
|
||||
fn setMode(self: *Handler, mode: modes.Mode, enabled: bool) !void {
|
||||
// Set the mode on the terminal
|
||||
self.terminal.modes.set(mode, enabled);
|
||||
|
||||
@@ -610,8 +610,9 @@ pub fn clearScreen(self: *Termio, td: *ThreadData, history: bool) !void {
|
||||
// send a FF (0x0C) to the shell so that it can repaint the screen.
|
||||
// Mark the current row as a not a prompt so we can properly
|
||||
// clear the full screen in the next eraseDisplay call.
|
||||
self.terminal.markSemanticPrompt(.command);
|
||||
assert(!self.terminal.cursorIsAtPrompt());
|
||||
// TODO: fix this
|
||||
// self.terminal.markSemanticPrompt(.command);
|
||||
// assert(!self.terminal.cursorIsAtPrompt());
|
||||
self.terminal.eraseDisplay(.complete, false);
|
||||
}
|
||||
|
||||
|
||||
@@ -1071,26 +1071,10 @@ pub const StreamHandler = struct {
|
||||
cmd: Stream.Action.SemanticPrompt,
|
||||
) !void {
|
||||
switch (cmd.action) {
|
||||
.fresh_line_new_prompt => {
|
||||
const kind = cmd.readOption(.prompt_kind) orelse .initial;
|
||||
switch (kind) {
|
||||
.initial, .right => {
|
||||
self.terminal.markSemanticPrompt(.prompt);
|
||||
if (cmd.readOption(.redraw)) |redraw| {
|
||||
self.terminal.flags.shell_redraws_prompt = redraw;
|
||||
}
|
||||
},
|
||||
.continuation, .secondary => {
|
||||
self.terminal.markSemanticPrompt(.prompt_continuation);
|
||||
},
|
||||
}
|
||||
},
|
||||
|
||||
.end_prompt_start_input => self.terminal.markSemanticPrompt(.input),
|
||||
.end_input_start_output => {
|
||||
self.terminal.markSemanticPrompt(.command);
|
||||
self.surfaceMessageWriter(.start_command);
|
||||
},
|
||||
|
||||
.end_command => {
|
||||
// The specification seems to not specify the type but
|
||||
// other terminals accept 32-bits, but exit codes are really
|
||||
@@ -1103,12 +1087,11 @@ pub const StreamHandler = struct {
|
||||
self.surfaceMessageWriter(.{ .stop_command = code });
|
||||
},
|
||||
|
||||
// All of these commands weren't previously handled by our
|
||||
// semantic prompt code. I am PR-ing the parser separate from the
|
||||
// handling so we just ignore these like we did before, even
|
||||
// though we should handle them eventually.
|
||||
// Handled by Terminal, no special handling by us
|
||||
.end_prompt_start_input,
|
||||
.end_prompt_start_input_terminate_eol,
|
||||
.fresh_line,
|
||||
.fresh_line_new_prompt,
|
||||
.new_command,
|
||||
.prompt_start,
|
||||
=> {},
|
||||
|
||||
Reference in New Issue
Block a user