forked from RepoMirrors/bemenu
Make it possible to set filter text manually.
This commit is contained in:
parent
71beb7583f
commit
8e0dd1ab39
16
lib/bemenu.h
16
lib/bemenu.h
@ -400,6 +400,22 @@ void bmItemSetUserdata(bmItem *item, void *userdata);
|
|||||||
*/
|
*/
|
||||||
void* bmItemGetUserdata(bmItem *item);
|
void* bmItemGetUserdata(bmItem *item);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set filter text to bmMenu instance.
|
||||||
|
*
|
||||||
|
* @param menu bmMenu instance where to set filter.
|
||||||
|
* @param filter Null terminated C "string" to act as filter.
|
||||||
|
*/
|
||||||
|
void bmMenuSetFilter(bmMenu *menu, const char *filter);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get filter text from bmMenu instance.
|
||||||
|
*
|
||||||
|
* @param menu bmMenu instance where to get filter.
|
||||||
|
* @return Const pointer to current filter text, may be **NULL** if empty.
|
||||||
|
*/
|
||||||
|
const char* bmMenuGetFilter(bmMenu *menu);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set text to bmItem instance.
|
* Set text to bmItem instance.
|
||||||
*
|
*
|
||||||
|
30
lib/menu.c
30
lib/menu.c
@ -116,6 +116,36 @@ void* bmMenuGetUserdata(bmMenu *menu)
|
|||||||
return menu->userdata;
|
return menu->userdata;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set filter text to bmMenu instance.
|
||||||
|
*
|
||||||
|
* @param menu bmMenu instance where to set filter.
|
||||||
|
* @param filter Null terminated C "string" to act as filter.
|
||||||
|
*/
|
||||||
|
void bmMenuSetFilter(bmMenu *menu, const char *filter)
|
||||||
|
{
|
||||||
|
assert(menu);
|
||||||
|
|
||||||
|
if (!filter) {
|
||||||
|
memset(menu->filter, 0, sizeof(menu->filter));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
strncpy(menu->filter, filter, sizeof(menu->filter));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get filter text from bmMenu instance.
|
||||||
|
*
|
||||||
|
* @param menu bmMenu instance where to get filter.
|
||||||
|
* @return Const pointer to current filter text, may be **NULL** if empty.
|
||||||
|
*/
|
||||||
|
const char* bmMenuGetFilter(bmMenu *menu)
|
||||||
|
{
|
||||||
|
assert(menu);
|
||||||
|
return menu->filter;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set active filter mode to bmMenu instance.
|
* Set active filter mode to bmMenu instance.
|
||||||
*
|
*
|
||||||
|
Loading…
Reference in New Issue
Block a user