diff options
author | okan <okan> | 2017-12-07 16:03:10 +0000 |
---|---|---|
committer | okan <okan> | 2017-12-07 16:03:10 +0000 |
commit | f0524fe07a3a671f706d7183bb0cfbc6c8f09780 (patch) | |
tree | 73e31cfbc735afcde2cc72ff569a2f78a9eb0892 /search.c | |
parent | b06ddae6249cca671046d04c0cf709cd0c48fd90 (diff) | |
download | cwm-f0524fe07a3a671f706d7183bb0cfbc6c8f09780.tar.gz cwm-f0524fe07a3a671f706d7183bb0cfbc6c8f09780.tar.xz cwm-f0524fe07a3a671f706d7183bb0cfbc6c8f09780.zip |
give command and group menus their own match callbacks
Diffstat (limited to 'search.c')
-rw-r--r-- | search.c | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/search.c b/search.c index a49d318..2c9a1be 100644 --- a/search.c +++ b/search.c @@ -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) { |