mirror of
https://github.com/ghostty-org/ghostty.git
synced 2026-04-14 11:35:48 +00:00
inspector: add more cursor state
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
const cimgui = @import("dcimgui");
|
||||
const terminal = @import("../terminal/main.zig");
|
||||
const widgets = @import("widgets.zig");
|
||||
|
||||
/// Render cursor information with a table already open.
|
||||
pub fn renderInTable(
|
||||
@@ -11,6 +12,8 @@ pub fn renderInTable(
|
||||
{
|
||||
_ = cimgui.c.ImGui_TableSetColumnIndex(0);
|
||||
cimgui.c.ImGui_Text("Position (x, y)");
|
||||
cimgui.c.ImGui_SameLine();
|
||||
widgets.helpMarker("The current cursor position in the terminal grid (0-indexed).");
|
||||
}
|
||||
{
|
||||
_ = cimgui.c.ImGui_TableSetColumnIndex(1);
|
||||
@@ -23,6 +26,8 @@ pub fn renderInTable(
|
||||
{
|
||||
_ = cimgui.c.ImGui_TableSetColumnIndex(0);
|
||||
cimgui.c.ImGui_Text("Style");
|
||||
cimgui.c.ImGui_SameLine();
|
||||
widgets.helpMarker("The visual style of the cursor (block, underline, bar, etc.).");
|
||||
}
|
||||
{
|
||||
_ = cimgui.c.ImGui_TableSetColumnIndex(1);
|
||||
@@ -30,22 +35,29 @@ pub fn renderInTable(
|
||||
}
|
||||
}
|
||||
|
||||
if (cursor.pending_wrap) {
|
||||
{
|
||||
cimgui.c.ImGui_TableNextRow();
|
||||
{
|
||||
_ = cimgui.c.ImGui_TableSetColumnIndex(0);
|
||||
cimgui.c.ImGui_Text("Pending Wrap");
|
||||
cimgui.c.ImGui_Text("Hyperlink");
|
||||
cimgui.c.ImGui_SameLine();
|
||||
widgets.helpMarker("The active OSC8 hyperlink for newly printed characters.");
|
||||
}
|
||||
{
|
||||
_ = cimgui.c.ImGui_TableSetColumnIndex(1);
|
||||
cimgui.c.ImGui_Text("%s", if (cursor.pending_wrap) "true".ptr else "false".ptr);
|
||||
if (cursor.hyperlink) |link| {
|
||||
cimgui.c.ImGui_Text("%.*s", link.uri.len, link.uri.ptr);
|
||||
} else {
|
||||
cimgui.c.ImGui_TextDisabled("(none)");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// If we have a color then we show the color
|
||||
cimgui.c.ImGui_TableNextRow();
|
||||
_ = cimgui.c.ImGui_TableSetColumnIndex(0);
|
||||
cimgui.c.ImGui_Text("Foreground Color");
|
||||
cimgui.c.ImGui_SameLine();
|
||||
widgets.helpMarker("The foreground (text) color for newly printed characters.");
|
||||
_ = cimgui.c.ImGui_TableSetColumnIndex(1);
|
||||
switch (cursor.style.fg_color) {
|
||||
.none => cimgui.c.ImGui_Text("default"),
|
||||
@@ -85,6 +97,8 @@ pub fn renderInTable(
|
||||
cimgui.c.ImGui_TableNextRow();
|
||||
_ = cimgui.c.ImGui_TableSetColumnIndex(0);
|
||||
cimgui.c.ImGui_Text("Background Color");
|
||||
cimgui.c.ImGui_SameLine();
|
||||
widgets.helpMarker("The background color for newly printed characters.");
|
||||
_ = cimgui.c.ImGui_TableSetColumnIndex(1);
|
||||
switch (cursor.style.bg_color) {
|
||||
.none => cimgui.c.ImGui_Text("default"),
|
||||
@@ -121,22 +135,60 @@ pub fn renderInTable(
|
||||
},
|
||||
}
|
||||
|
||||
// Boolean styles
|
||||
const styles = .{
|
||||
"bold", "italic", "faint", "blink",
|
||||
"inverse", "invisible", "strikethrough",
|
||||
const style_flags = .{
|
||||
.{ "bold", "Text will be rendered with bold weight." },
|
||||
.{ "italic", "Text will be rendered in italic style." },
|
||||
.{ "faint", "Text will be rendered with reduced intensity." },
|
||||
.{ "blink", "Text will blink (if supported by the renderer)." },
|
||||
.{ "inverse", "Foreground and background colors are swapped." },
|
||||
.{ "invisible", "Text will be invisible (hidden)." },
|
||||
.{ "strikethrough", "Text will have a line through it." },
|
||||
};
|
||||
inline for (styles) |style| style: {
|
||||
if (!@field(cursor.style.flags, style)) break :style;
|
||||
inline for (style_flags) |entry| entry: {
|
||||
const style = entry[0];
|
||||
const help = entry[1];
|
||||
if (!@field(cursor.style.flags, style)) break :entry;
|
||||
|
||||
cimgui.c.ImGui_TableNextRow();
|
||||
{
|
||||
_ = cimgui.c.ImGui_TableSetColumnIndex(0);
|
||||
cimgui.c.ImGui_Text(style.ptr);
|
||||
cimgui.c.ImGui_SameLine();
|
||||
widgets.helpMarker(help);
|
||||
}
|
||||
{
|
||||
_ = cimgui.c.ImGui_TableSetColumnIndex(1);
|
||||
cimgui.c.ImGui_Text("true");
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
cimgui.c.ImGui_TableNextRow();
|
||||
{
|
||||
_ = cimgui.c.ImGui_TableSetColumnIndex(0);
|
||||
cimgui.c.ImGui_Text("Pending Wrap");
|
||||
cimgui.c.ImGui_SameLine();
|
||||
widgets.helpMarker("The 'last column flag' (LCF). If set, the next character will force a soft-wrap to the next line.");
|
||||
}
|
||||
{
|
||||
_ = cimgui.c.ImGui_TableSetColumnIndex(1);
|
||||
var value: bool = cursor.pending_wrap;
|
||||
_ = cimgui.c.ImGui_Checkbox("##pending_wrap", &value);
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
cimgui.c.ImGui_TableNextRow();
|
||||
{
|
||||
_ = cimgui.c.ImGui_TableSetColumnIndex(0);
|
||||
cimgui.c.ImGui_Text("Protected");
|
||||
cimgui.c.ImGui_SameLine();
|
||||
widgets.helpMarker("If enabled, new characters will have the protected attribute set, preventing erasure by certain sequences.");
|
||||
}
|
||||
{
|
||||
_ = cimgui.c.ImGui_TableSetColumnIndex(1);
|
||||
var value: bool = cursor.protected;
|
||||
_ = cimgui.c.ImGui_Checkbox("##protected", &value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -58,7 +58,7 @@ pub const Window = struct {
|
||||
|
||||
if (cimgui.c.ImGui_CollapsingHeader(
|
||||
"Cursor",
|
||||
cimgui.c.ImGuiTreeNodeFlags_DefaultOpen,
|
||||
cimgui.c.ImGuiTreeNodeFlags_None,
|
||||
)) {
|
||||
{
|
||||
_ = cimgui.c.ImGui_BeginTable(
|
||||
@@ -78,7 +78,7 @@ pub const Window = struct {
|
||||
|
||||
if (cimgui.c.ImGui_CollapsingHeader(
|
||||
"Keyboard",
|
||||
cimgui.c.ImGuiTreeNodeFlags_DefaultOpen,
|
||||
cimgui.c.ImGuiTreeNodeFlags_None,
|
||||
)) {
|
||||
{
|
||||
_ = cimgui.c.ImGui_BeginTable(
|
||||
@@ -145,7 +145,7 @@ pub const Window = struct {
|
||||
|
||||
if (cimgui.c.ImGui_CollapsingHeader(
|
||||
"Kitty Graphics",
|
||||
cimgui.c.ImGuiTreeNodeFlags_DefaultOpen,
|
||||
cimgui.c.ImGuiTreeNodeFlags_None,
|
||||
)) kitty_gfx: {
|
||||
if (!screen.kitty_images.enabled()) {
|
||||
cimgui.c.ImGui_TextDisabled("(Kitty graphics are disabled)");
|
||||
@@ -226,7 +226,7 @@ pub const Window = struct {
|
||||
|
||||
if (cimgui.c.ImGui_CollapsingHeader(
|
||||
"Internal Terminal State",
|
||||
cimgui.c.ImGuiTreeNodeFlags_DefaultOpen,
|
||||
cimgui.c.ImGuiTreeNodeFlags_None,
|
||||
)) {
|
||||
const pages = &screen.pages;
|
||||
|
||||
@@ -277,7 +277,7 @@ pub const Window = struct {
|
||||
//
|
||||
if (cimgui.c.ImGui_CollapsingHeader(
|
||||
"Active Page",
|
||||
cimgui.c.ImGuiTreeNodeFlags_DefaultOpen,
|
||||
cimgui.c.ImGuiTreeNodeFlags_None,
|
||||
)) {
|
||||
inspector.page.render(&pages.pages.last.?.data);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user