diff options
author | okan | 2017-12-07 16:03:10 +0000 |
---|---|---|
committer | okan | 2017-12-07 16:03:10 +0000 |
commit | c41a4e4f8740a3150cb0ed54c5972e075f503b74 (patch) | |
tree | 4ffc2414fccd85793b0fca6c60575d9b5a2bb3cf /search.c | |
parent | 119bed3cf0313cb028627872f7f85a232019991d (diff) | |
download | cwm-c41a4e4f8740a3150cb0ed54c5972e075f503b74.tar.gz |
give command and group menus their own match callbacks
Diffstat (limited to '')
-rw-r--r-- | search.c | 31 |
1 files changed, 30 insertions, 1 deletions
@@ -15,7 +15,7 @@ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * - * $OpenBSD: search.c,v 1.64 2017/12/07 15:40:54 okan Exp $ + * $OpenBSD: search.c,v 1.65 2017/12/07 16:03:10 okan Exp $ */ #include <sys/types.h> @@ -129,6 +129,35 @@ search_match_client(struct menu_q *menuq, struct menu_q *resultq, char *search) } } +void +search_match_cmd(struct menu_q *menuq, struct menu_q *resultq, char *search) +{ + struct menu *mi; + + TAILQ_INIT(resultq); + TAILQ_FOREACH(mi, menuq, entry) { + struct cmd_ctx *cmd = (struct cmd_ctx *)mi->ctx; + if (match_substr(search, cmd->name, 0)) + TAILQ_INSERT_TAIL(resultq, mi, resultentry); + } +} + +void +search_match_group(struct menu_q *menuq, struct menu_q *resultq, char *search) +{ + struct menu *mi; + char *s; + + TAILQ_INIT(resultq); + TAILQ_FOREACH(mi, menuq, entry) { + struct group_ctx *gc = (struct group_ctx *)mi->ctx; + xasprintf(&s, "%d %s", gc->num, gc->name); + if (match_substr(search, s, 0)) + TAILQ_INSERT_TAIL(resultq, mi, resultentry); + free(s); + } +} + static void match_path_type(struct menu_q *resultq, char *search, int flag) { |