mirror of
https://github.com/ghostty-org/ghostty.git
synced 2026-04-17 21:12:39 +00:00
terminal: move semantic prompt state into its own field in screen
This commit is contained in:
@@ -4295,7 +4295,7 @@ fn clickMoveCursor(self: *Surface, to: terminal.Pin) !void {
|
||||
// This flag is only set if we've seen at least one semantic prompt
|
||||
// OSC sequence. If we've never seen that sequence, we can't possibly
|
||||
// move the cursor so we can fast path out of here.
|
||||
if (!t.screens.active.flags.semantic_content) return;
|
||||
if (!t.screens.active.semantic_prompt.seen) return;
|
||||
|
||||
// Get our path
|
||||
const from = t.screens.active.cursor.page_pin.*;
|
||||
|
||||
@@ -363,7 +363,7 @@ pub fn internalStateTable(
|
||||
cimgui.c.ImGui_SameLine();
|
||||
widgets.helpMarker("Whether semantic prompt markers (OSC 133) have been seen.");
|
||||
_ = cimgui.c.ImGui_TableSetColumnIndex(1);
|
||||
var value: bool = screen.flags.semantic_content;
|
||||
var value: bool = screen.semantic_prompt.seen;
|
||||
_ = cimgui.c.ImGui_Checkbox("##semantic_content", &value);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -74,12 +74,12 @@ kitty_images: if (build_options.kitty_graphics)
|
||||
else
|
||||
struct {} = .{},
|
||||
|
||||
/// Semantic prompt (OSC133) state.
|
||||
semantic_prompt: SemanticPrompt = .disabled,
|
||||
|
||||
/// Dirty flags for the renderer.
|
||||
dirty: Dirty = .{},
|
||||
|
||||
/// Packed flags for the screen, internal state.
|
||||
flags: Flags = .{},
|
||||
|
||||
/// See Terminal.Dirty. This behaves the same way.
|
||||
pub const Dirty = packed struct {
|
||||
/// Set when the selection is set or unset, regardless of if the
|
||||
@@ -91,15 +91,30 @@ pub const Dirty = packed struct {
|
||||
hyperlink_hover: bool = false,
|
||||
};
|
||||
|
||||
/// A set of internal state that we pack for memory size.
|
||||
pub const Flags = packed struct {
|
||||
pub const SemanticPrompt = struct {
|
||||
/// This is flipped to true when any sort of semantic content is
|
||||
/// seen. In particular, this is set to true only when a `prompt` type
|
||||
/// is ever set on our cursor.
|
||||
///
|
||||
/// This is used to optimize away semantic content operations if we know
|
||||
/// we've never seen them.
|
||||
semantic_content: bool = false,
|
||||
seen: bool,
|
||||
|
||||
/// This is set on any `cl` or `click_events` option set on the
|
||||
/// most recent OSC 133 commands to specify how click handling in a
|
||||
/// prompt is handling.
|
||||
click: SemanticClick,
|
||||
|
||||
pub const disabled: SemanticPrompt = .{
|
||||
.seen = false,
|
||||
.click = .none,
|
||||
};
|
||||
|
||||
pub const SemanticClick = union(enum) {
|
||||
none,
|
||||
click_events,
|
||||
cl: osc.semantic_prompt.Click,
|
||||
};
|
||||
};
|
||||
|
||||
/// The cursor position and style.
|
||||
@@ -378,7 +393,7 @@ pub fn reset(self: *Screen) void {
|
||||
self.charset = .{};
|
||||
self.kitty_keyboard = .{};
|
||||
self.protected_mode = .off;
|
||||
self.flags = .{};
|
||||
self.semantic_prompt = .disabled;
|
||||
self.clearSelection();
|
||||
}
|
||||
|
||||
@@ -2362,7 +2377,7 @@ pub fn cursorSetSemanticContent(self: *Screen, t: union(enum) {
|
||||
},
|
||||
|
||||
.prompt => |kind| {
|
||||
self.flags.semantic_content = true;
|
||||
self.semantic_prompt.seen = true;
|
||||
cursor.semantic_content = .prompt;
|
||||
cursor.semantic_content_clear_eol = false;
|
||||
cursor.page_row.semantic_prompt = switch (kind) {
|
||||
|
||||
Reference in New Issue
Block a user