forked from RepoMirrors/bemenu
Add --filter option.
This commit is contained in:
parent
4cbc0343c3
commit
7523af7d18
@ -168,6 +168,7 @@ usage(FILE *out, const char *name)
|
||||
" -h, --help display this help and exit.\n"
|
||||
" -v, --version display version.\n"
|
||||
" -i, --ignorecase match items case insensitively.\n"
|
||||
" -F, --filter filter entries for a given string.\n"
|
||||
" -w, --wrap wraps cursor selection.\n"
|
||||
" -l, --list list items vertically with the given number of lines.\n"
|
||||
" -p, --prompt defines the prompt text to be displayed.\n"
|
||||
@ -221,6 +222,7 @@ do_getopt(struct client *client, int *argc, char **argv[])
|
||||
{ "version", no_argument, 0, 'v' },
|
||||
|
||||
{ "ignorecase", no_argument, 0, 'i' },
|
||||
{ "filter", required_argument, 0, 'F' },
|
||||
{ "wrap", no_argument, 0, 'w' },
|
||||
{ "list", required_argument, 0, 'l' },
|
||||
{ "prompt", required_argument, 0, 'p' },
|
||||
@ -274,6 +276,9 @@ do_getopt(struct client *client, int *argc, char **argv[])
|
||||
case 'i':
|
||||
client->filter_mode = BM_FILTER_MODE_DMENU_CASE_INSENSITIVE;
|
||||
break;
|
||||
case 'F':
|
||||
client->initial_filter = optarg;
|
||||
break;
|
||||
case 'w':
|
||||
client->wrap = true;
|
||||
break;
|
||||
@ -424,6 +429,7 @@ run_menu(const struct client *client, struct bm_menu *menu, void (*item_cb)(cons
|
||||
{
|
||||
bm_menu_set_highlighted_index(menu, client->selected);
|
||||
bm_menu_grab_keyboard(menu, true);
|
||||
bm_menu_set_filter(menu, client->initial_filter);
|
||||
|
||||
if (client->ifne && !bm_menu_get_items(menu, NULL))
|
||||
return BM_RUN_RESULT_CANCEL;
|
||||
|
@ -11,6 +11,7 @@ struct client {
|
||||
const char *title;
|
||||
const char *prefix;
|
||||
const char *font;
|
||||
const char *initial_filter;
|
||||
uint32_t line_height;
|
||||
uint32_t lines;
|
||||
uint32_t selected;
|
||||
|
Loading…
Reference in New Issue
Block a user