add option to start vim bindings in normal mode

This commit is contained in:
Pablo Arias 2023-11-21 19:05:45 +01:00 committed by Jari Vetoniemi
parent b0751f7ddc
commit f82eda732f
3 changed files with 13 additions and 0 deletions

View File

@ -188,6 +188,7 @@ usage(FILE *out, const char *name)
" --scrollbar display scrollbar. (none (default), always, autohide)\n" " --scrollbar display scrollbar. (none (default), always, autohide)\n"
" --counter display a matched/total items counter. (none (default), always)\n" " --counter display a matched/total items counter. (none (default), always)\n"
" -e, --vim-esc-exits exit bemenu when pressing escape in normal mode for vim bindings\n" " -e, --vim-esc-exits exit bemenu when pressing escape in normal mode for vim bindings\n"
" -N, --vim-normal-mode start in normal mode for vim bindings\n"
" --accept-single immediately return if there is only one item.\n" " --accept-single immediately return if there is only one item.\n"
" --ifne only display menu if there are items.\n" " --ifne only display menu if there are items.\n"
" --single-instance force a single menu instance.\n" " --single-instance force a single menu instance.\n"
@ -283,6 +284,7 @@ do_getopt(struct client *client, int *argc, char **argv[])
{ "scrollbar", required_argument, 0, 0x100 }, { "scrollbar", required_argument, 0, 0x100 },
{ "counter", required_argument, 0, 0x10a }, { "counter", required_argument, 0, 0x10a },
{ "vim-esc-exits",no_argument, 0, 'e' }, { "vim-esc-exits",no_argument, 0, 'e' },
{ "vim-normal-mode",no_argument, 0, 'N'},
{ "accept-single",no_argument, 0, 0x11a }, { "accept-single",no_argument, 0, 0x11a },
{ "auto-select", no_argument, 0, 0x11b }, { "auto-select", no_argument, 0, 0x11b },
{ "ifne", no_argument, 0, 0x117 }, { "ifne", no_argument, 0, 0x117 },
@ -388,6 +390,9 @@ do_getopt(struct client *client, int *argc, char **argv[])
case 'e': case 'e':
client->vim_esc_exits = true; client->vim_esc_exits = true;
break; break;
case 'N':
client->vim_init_mode_normal = true;
break;
case 0x11a: case 0x11a:
client->accept_single = true; client->accept_single = true;
break; break;
@ -559,6 +564,10 @@ menu_with_options(struct client *client)
if (!(menu = bm_menu_new(NULL))) if (!(menu = bm_menu_new(NULL)))
return NULL; return NULL;
if (client->vim_init_mode_normal) {
menu->vim_mode = 'n';
}
client->fork = (client->force_fork || (bm_renderer_get_priorty(bm_menu_get_renderer(menu)) != BM_PRIO_TERMINAL)); client->fork = (client->force_fork || (bm_renderer_get_priorty(bm_menu_get_renderer(menu)) != BM_PRIO_TERMINAL));
bm_menu_set_font(menu, client->font); bm_menu_set_font(menu, client->font);

View File

@ -31,6 +31,7 @@ struct client {
bool fixed_height; bool fixed_height;
bool counter; bool counter;
bool vim_esc_exits; bool vim_esc_exits;
bool vim_init_mode_normal;
bool accept_single; bool accept_single;
bool auto_select; bool auto_select;
bool ifne; bool ifne;

View File

@ -117,6 +117,9 @@ list of executables under PATH and the selected items are executed.
*-e, --vim-esc-exits* *-e, --vim-esc-exits*
Exit bemenu when pressing escape in normal mode for vim bindings. Exit bemenu when pressing escape in normal mode for vim bindings.
*-N, --vim-normal-mode*
Start in normal mode for vim bindings.
*-F, --filter* *-F, --filter*
Filter items for a given string before showing the menu. Filter items for a given string before showing the menu.
Affects *--ifne* and *--accept-single* Affects *--ifne* and *--accept-single*