From 74b011cf7e4b82ef388e189a3f69c4880be4a825 Mon Sep 17 00:00:00 2001 From: CJ van den Berg Date: Wed, 1 Oct 2025 21:54:46 +0200 Subject: [PATCH] feat: add support for setting the initial query value in palettes --- src/tui/mode/overlay/palette.zig | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/tui/mode/overlay/palette.zig b/src/tui/mode/overlay/palette.zig index df64f59..28b2b5b 100644 --- a/src/tui/mode/overlay/palette.zig +++ b/src/tui/mode/overlay/palette.zig @@ -91,6 +91,12 @@ pub fn Create(options: type) type { if (@hasDecl(options, "restore_state")) options.restore_state(self) catch {}; try self.commands.init(self); + if (@hasDecl(options, "initial_query")) blk: { + const initial_query = options.initial_query(self, self.allocator) catch break :blk; + defer self.allocator.free(initial_query); + try self.inputbox.text.appendSlice(self.allocator, initial_query); + self.inputbox.cursor = tui.egc_chunk_width(self.inputbox.text.items, 0, 8); + } try self.start_query(0); try mv.floating_views.add(self.modal.widget()); try mv.floating_views.add(self.menu.container_widget);