inspector: add sequence number to termio

This commit is contained in:
Mitchell Hashimoto
2023-10-24 21:26:34 -07:00
parent ff54c466cd
commit a72bfc4a31
2 changed files with 21 additions and 3 deletions

View File

@ -1046,6 +1046,7 @@ fn renderKeyboardWindow(self: *Inspector) void {
var it = self.key_events.iterator(.forward);
while (it.next()) |v| v.deinit(self.surface.alloc);
self.key_events.clear();
self.vt_stream.handler.current_seq = 1;
}
cimgui.c.igSeparator();
@ -1131,7 +1132,7 @@ fn renderTermioWindow(self: *Inspector) void {
_ = cimgui.c.igBeginTable(
"table_vt_events",
2,
3,
cimgui.c.ImGuiTableFlags_RowBg |
cimgui.c.ImGuiTableFlags_Borders,
.{ .x = 0, .y = 0 },
@ -1139,6 +1140,12 @@ fn renderTermioWindow(self: *Inspector) void {
);
defer cimgui.c.igEndTable();
cimgui.c.igTableSetupColumn(
"Seq",
cimgui.c.ImGuiTableColumnFlags_WidthFixed,
0,
0,
);
cimgui.c.igTableSetupColumn(
"Kind",
cimgui.c.ImGuiTableColumnFlags_WidthFixed,
@ -1159,9 +1166,11 @@ fn renderTermioWindow(self: *Inspector) void {
defer cimgui.c.igPopID();
cimgui.c.igTableNextRow(cimgui.c.ImGuiTableRowFlags_None, 0);
_ = cimgui.c.igTableSetColumnIndex(0);
_ = cimgui.c.igTableNextColumn();
cimgui.c.igText("%d", ev.seq);
_ = cimgui.c.igTableNextColumn();
cimgui.c.igText("%s", @tagName(ev.kind).ptr);
_ = cimgui.c.igTableSetColumnIndex(1);
_ = cimgui.c.igTableNextColumn();
cimgui.c.igText("%s", ev.str.ptr);
}
} // table

View File

@ -13,6 +13,9 @@ pub const VTEventRing = CircBuf(VTEvent, undefined);
/// VT event
pub const VTEvent = struct {
/// Sequence number, just monotonically increasing.
seq: usize = 1,
/// Kind of event, for filtering
kind: Kind,
@ -69,6 +72,9 @@ pub const VTHandler = struct {
/// True if the handler is currently recording.
active: bool = true,
/// Current sequence number
current_seq: usize = 1,
/// Exclude certain actions by tag.
filter_exclude: ActionTagSet = ActionTagSet.initMany(&.{.print}),
filter_text: *cimgui.c.ImGuiTextFilter,
@ -106,10 +112,13 @@ pub const VTHandler = struct {
// Build our event
const alloc = self.surface.alloc;
var ev = try VTEvent.init(alloc, action);
ev.seq = self.current_seq;
self.current_seq +%= 1;
errdefer ev.deinit(alloc);
// Check if the event passes the filter
if (!ev.passFilter(self.filter_text)) {
self.current_seq -= 1;
ev.deinit(alloc);
return true;
}