refactor: add dropdown_keybinds configuration option

This commit is contained in:
CJ van den Berg 2025-12-23 21:45:06 +01:00
parent d59dc65e6b
commit c4301c40d9
Signed by: neurocyte
GPG key ID: 8EB1E1BB660E3FB9
3 changed files with 24 additions and 2 deletions

View file

@ -71,6 +71,7 @@ centered_view_min_screen_width: usize = 145,
lsp_output: enum { quiet, verbose } = .quiet, lsp_output: enum { quiet, verbose } = .quiet,
keybind_mode: KeybindMode = .normal, keybind_mode: KeybindMode = .normal,
dropdown_keybinds: DropdownKeybindMode = .standard,
include_files: []const u8 = "", include_files: []const u8 = "",
@ -158,6 +159,11 @@ pub const KeybindMode = enum {
ignore_alt_text_modifiers, ignore_alt_text_modifiers,
}; };
pub const DropdownKeybindMode = enum {
standard,
noninvasive,
};
pub const InitialFindQuery = enum { pub const InitialFindQuery = enum {
empty, empty,
selection, selection,

View file

@ -375,7 +375,7 @@
["right_control", "palette_menu_activate_quick"] ["right_control", "palette_menu_activate_quick"]
] ]
}, },
"overlay/dropdown": { "overlay/dropdown-noninvasive": {
"inherit": "normal", "inherit": "normal",
"press": [ "press": [
["alt+f9", "dropdown_next_widget_style"], ["alt+f9", "dropdown_next_widget_style"],
@ -388,6 +388,19 @@
["tab", "palette_menu_complete"] ["tab", "palette_menu_complete"]
] ]
}, },
"overlay/dropdown": {
"inherit": "normal",
"press": [
["alt+f9", "dropdown_next_widget_style"],
["ctrl+p", "palette_menu_up"],
["ctrl+n", "palette_menu_down"],
["escape", "palette_menu_cancel"],
["up", "palette_menu_up"],
["down", "palette_menu_down"],
["enter", "palette_menu_activate"],
["tab", "palette_menu_complete"]
]
},
"mini/numeric": { "mini/numeric": {
"press": [ "press": [
["ctrl+?", "toggle_keybind_hints"], ["ctrl+?", "toggle_keybind_hints"],

View file

@ -93,7 +93,10 @@ pub fn Create(options: type) type {
.query = .empty, .query = .empty,
.view_rows = get_view_rows(tui.screen()), .view_rows = get_view_rows(tui.screen()),
.entries = .empty, .entries = .empty,
.mode = try keybind.mode("overlay/dropdown", allocator, .{ .mode = try keybind.mode(switch (tui.config().dropdown_keybinds) {
.standard => "overlay/dropdown",
.noninvasive => "overlay/dropdown-noninvasive",
}, allocator, .{
.insert_command = "overlay_insert_bytes", .insert_command = "overlay_insert_bytes",
}), }),
.placement = if (@hasDecl(options, "placement")) options.placement else .top_center, .placement = if (@hasDecl(options, "placement")) options.placement else .top_center,