From 9557703fc9254d9eba112eb8b1726dcfaf7e77ef Mon Sep 17 00:00:00 2001 From: CJ van den Berg Date: Sun, 30 Nov 2025 15:03:42 +0100 Subject: [PATCH] WIP: render keybinding that match the current keybind prefix --- src/tui/tui.zig | 25 ++++++++++++++++++++----- 1 file changed, 20 insertions(+), 5 deletions(-) diff --git a/src/tui/tui.zig b/src/tui/tui.zig index 5aa5996..9d3822f 100644 --- a/src/tui/tui.zig +++ b/src/tui/tui.zig @@ -300,14 +300,29 @@ fn handle_input_idle(self: *Self) void { if (self.input_mode_) |mode| { const bindings = mode.current_key_event_sequence_bindings(self.allocator) catch return; defer self.allocator.free(bindings); - for (bindings) |binding| - self.logger.print(" {f} => {s}", .{ - keybind.key_event_sequence_fmt(binding.key_events), - binding.commands[0].command, - }); } } +fn render_keybind_matches(self: *Self) void { + var box = screen(); + // const anchor: Widget.Pos = .{}; + // box.y = @intCast(@max(pos.y, anchor.y) - anchor.y); + // box.x = @intCast(@max(pos.x, anchor.x) - anchor.x); + + // return if something is already rendering to the top layer + const top_layer_ = top_layer(box.to_layer()) orelse return; + const mode = self.input_mode_ orelse return; + + const bindings = mode.current_key_event_sequence_bindings(self.allocator) catch return; + defer self.allocator.free(bindings); + + for (bindings) |binding| + top_layer_.plane.print(" {f} => {s}", .{ + keybind.key_event_sequence_fmt(binding.key_events), + binding.commands[0].command, + }); +} + fn update_input_idle_timer(self: *Self) void { if (!self.enable_input_idle_timer) return; if (self.input_is_idle) blk: {