inspector: show cell codepoints and wide property

This commit is contained in:
Mitchell Hashimoto
2024-04-19 09:33:43 -07:00
parent 915e09367a
commit 93f8db59ce

View File

@ -20,6 +20,9 @@ pub const Cell = struct {
/// The style of this cell. /// The style of this cell.
style: terminal.Style, style: terminal.Style,
/// Wide state of the terminal cell
wide: terminal.Cell.Wide,
pub fn init( pub fn init(
alloc: Allocator, alloc: Allocator,
pin: terminal.Pin, pin: terminal.Pin,
@ -37,6 +40,7 @@ pub const Cell = struct {
.codepoint = cell.codepoint(), .codepoint = cell.codepoint(),
.cps = cps, .cps = cps,
.style = style, .style = style,
.wide = cell.wide,
}; };
} }
@ -81,19 +85,43 @@ pub const Cell = struct {
cimgui.c.igTableNextRow(cimgui.c.ImGuiTableRowFlags_None, 0); cimgui.c.igTableNextRow(cimgui.c.ImGuiTableRowFlags_None, 0);
{ {
_ = cimgui.c.igTableSetColumnIndex(0); _ = cimgui.c.igTableSetColumnIndex(0);
cimgui.c.igText("Codepoint"); cimgui.c.igText("Codepoints");
} }
{ {
_ = cimgui.c.igTableSetColumnIndex(1); _ = cimgui.c.igTableSetColumnIndex(1);
if (self.codepoint == 0) { if (cimgui.c.igBeginListBox("##codepoints", .{ .x = 0, .y = 0 })) {
cimgui.c.igTextDisabled("(empty)"); defer cimgui.c.igEndListBox();
break :codepoint;
}
cimgui.c.igText("U+%X", @as(u32, @intCast(self.codepoint))); if (self.codepoint == 0) {
_ = cimgui.c.igSelectable_Bool("(empty)", false, 0, .{});
break :codepoint;
}
// Primary codepoint
var buf: [256]u8 = undefined;
{
const key = std.fmt.bufPrintZ(&buf, "U+{X}", .{self.codepoint}) catch
"<internal error>";
_ = cimgui.c.igSelectable_Bool(key.ptr, false, 0, .{});
}
// All extras
for (self.cps) |cp| {
const key = std.fmt.bufPrintZ(&buf, "U+{X}", .{cp}) catch
"<internal error>";
_ = cimgui.c.igSelectable_Bool(key.ptr, false, 0, .{});
}
}
} }
} }
// Character width property
cimgui.c.igTableNextRow(cimgui.c.ImGuiTableRowFlags_None, 0);
_ = cimgui.c.igTableSetColumnIndex(0);
cimgui.c.igText("Width Property");
_ = cimgui.c.igTableSetColumnIndex(1);
cimgui.c.igText(@tagName(self.wide));
// If we have a color then we show the color // If we have a color then we show the color
cimgui.c.igTableNextRow(cimgui.c.ImGuiTableRowFlags_None, 0); cimgui.c.igTableNextRow(cimgui.c.ImGuiTableRowFlags_None, 0);
_ = cimgui.c.igTableSetColumnIndex(0); _ = cimgui.c.igTableSetColumnIndex(0);