mirror of
https://github.com/Cloudef/bemenu
synced 2025-02-19 00:06:50 +00:00
menu: reset cursor at end on set_filter
This commit is contained in:
parent
1607215d70
commit
7170c93f3a
@ -289,6 +289,8 @@ const char* bm_menu_get_prefix(struct bm_menu *menu);
|
||||
/**
|
||||
* Set filter text to bm_menu instance.
|
||||
*
|
||||
* The cursor will be automatically placed at the end of the new filter text.
|
||||
*
|
||||
* @param menu bm_menu instance where to set filter.
|
||||
* @param filter Null terminated C "string" to act as filter. May be set **NULL** for none.
|
||||
*/
|
||||
|
@ -169,8 +169,10 @@ bm_menu_set_filter(struct bm_menu *menu, const char *filter)
|
||||
assert(menu);
|
||||
|
||||
free(menu->filter);
|
||||
menu->filter = (filter && strlen(filter) > 0 ? bm_strdup(filter) : NULL);
|
||||
menu->filter_size = (filter ? strlen(filter) : 0);
|
||||
menu->filter = (menu->filter_size > 0 ? bm_strdup(filter) : NULL);
|
||||
menu->curses_cursor = (menu->filter ? bm_utf8_string_screen_width(menu->filter) : 0);
|
||||
menu->cursor = menu->filter_size;
|
||||
}
|
||||
|
||||
const char*
|
||||
@ -755,11 +757,8 @@ bm_menu_run_with_key(struct bm_menu *menu, enum bm_key key, uint32_t unicode)
|
||||
{
|
||||
const char *text;
|
||||
struct bm_item *highlighted = bm_menu_get_highlighted_item(menu);
|
||||
if (highlighted && (text = bm_item_get_text(highlighted))) {
|
||||
if (highlighted && (text = bm_item_get_text(highlighted)))
|
||||
bm_menu_set_filter(menu, text);
|
||||
menu->cursor = (menu->filter ? strlen(menu->filter) : 0);
|
||||
menu->curses_cursor = (menu->filter ? bm_utf8_string_screen_width(menu->filter) : 0);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user