renderer: semantic prompt overlay

This commit is contained in:
Mitchell Hashimoto
2026-01-31 11:07:26 -08:00
parent a4b7a766fe
commit f14a1306cd
2 changed files with 263 additions and 25 deletions

View File

@@ -48,24 +48,76 @@ pub const Info = struct {
) void {
if (!open) return;
cimgui.c.ImGui_SeparatorText("Overlays");
cimgui.c.ImGui_SetNextItemOpen(true, cimgui.c.ImGuiCond_Once);
if (!cimgui.c.ImGui_CollapsingHeader("Overlays", cimgui.c.ImGuiTreeNodeFlags_None)) return;
// Hyperlinks
{
var hyperlinks: bool = self.features.contains(.highlight_hyperlinks);
_ = cimgui.c.ImGui_Checkbox("Overlay Hyperlinks", &hyperlinks);
cimgui.c.ImGui_SameLine();
widgets.helpMarker("When enabled, highlights OSC8 hyperlinks.");
cimgui.c.ImGui_SeparatorText("Hyperlinks");
self.overlayHyperlinks(alloc);
cimgui.c.ImGui_SeparatorText("Semantic Prompts");
self.overlaySemanticPrompts(alloc);
}
if (!hyperlinks) {
_ = self.features.swapRemove(.highlight_hyperlinks);
} else {
self.features.put(
alloc,
.highlight_hyperlinks,
.highlight_hyperlinks,
) catch log.warn("error enabling hyperlink overlay feature", .{});
}
fn overlayHyperlinks(self: *Info, alloc: Allocator) void {
var hyperlinks: bool = self.features.contains(.highlight_hyperlinks);
_ = cimgui.c.ImGui_Checkbox("Overlay Hyperlinks", &hyperlinks);
cimgui.c.ImGui_SameLine();
widgets.helpMarker("When enabled, highlights OSC8 hyperlinks.");
if (!hyperlinks) {
_ = self.features.swapRemove(.highlight_hyperlinks);
} else {
self.features.put(
alloc,
.highlight_hyperlinks,
.highlight_hyperlinks,
) catch log.warn("error enabling hyperlink overlay feature", .{});
}
}
fn overlaySemanticPrompts(self: *Info, alloc: Allocator) void {
var semantic_prompts: bool = self.features.contains(.semantic_prompts);
_ = cimgui.c.ImGui_Checkbox("Overlay Semantic Prompts", &semantic_prompts);
cimgui.c.ImGui_SameLine();
widgets.helpMarker("When enabled, highlights OSC 133 semantic prompts.");
// Handle the checkbox results
if (!semantic_prompts) {
_ = self.features.swapRemove(.semantic_prompts);
} else {
self.features.put(
alloc,
.semantic_prompts,
.semantic_prompts,
) catch log.warn("error enabling semantic prompt overlay feature", .{});
}
// Help
cimgui.c.ImGui_Indent();
defer cimgui.c.ImGui_Unindent();
cimgui.c.ImGui_TextDisabled("Colors:");
const prompt_rgb = renderer.Overlay.Color.semantic_prompt.rgb();
const input_rgb = renderer.Overlay.Color.semantic_input.rgb();
const prompt_col: cimgui.c.ImVec4 = .{
.x = @as(f32, @floatFromInt(prompt_rgb.r)) / 255.0,
.y = @as(f32, @floatFromInt(prompt_rgb.g)) / 255.0,
.z = @as(f32, @floatFromInt(prompt_rgb.b)) / 255.0,
.w = 1.0,
};
const input_col: cimgui.c.ImVec4 = .{
.x = @as(f32, @floatFromInt(input_rgb.r)) / 255.0,
.y = @as(f32, @floatFromInt(input_rgb.g)) / 255.0,
.z = @as(f32, @floatFromInt(input_rgb.b)) / 255.0,
.w = 1.0,
};
_ = cimgui.c.ImGui_ColorButton("##prompt_color", prompt_col, cimgui.c.ImGuiColorEditFlags_NoTooltip);
cimgui.c.ImGui_SameLine();
cimgui.c.ImGui_Text("Prompt");
_ = cimgui.c.ImGui_ColorButton("##input_color", input_col, cimgui.c.ImGuiColorEditFlags_NoTooltip);
cimgui.c.ImGui_SameLine();
cimgui.c.ImGui_Text("Input");
}
};