mirror of
https://github.com/leahneukirchen/cwm.git
synced 2023-08-10 21:13:12 +03:00
give command and group menus their own match callbacks
This commit is contained in:
parent
b06ddae624
commit
f0524fe07a
4
calmwm.h
4
calmwm.h
@ -444,6 +444,10 @@ void search_match_path(struct menu_q *, struct menu_q *,
|
|||||||
char *);
|
char *);
|
||||||
void search_match_text(struct menu_q *, struct menu_q *,
|
void search_match_text(struct menu_q *, struct menu_q *,
|
||||||
char *);
|
char *);
|
||||||
|
void search_match_cmd(struct menu_q *, struct menu_q *,
|
||||||
|
char *);
|
||||||
|
void search_match_group(struct menu_q *, struct menu_q *,
|
||||||
|
char *);
|
||||||
void search_print_client(struct menu *, int);
|
void search_print_client(struct menu *, int);
|
||||||
void search_print_cmd(struct menu *, int);
|
void search_print_cmd(struct menu *, int);
|
||||||
void search_print_group(struct menu *, int);
|
void search_print_group(struct menu *, int);
|
||||||
|
9
kbfunc.c
9
kbfunc.c
@ -460,14 +460,13 @@ kbfunc_menu_cmd(void *ctx, struct cargs *cargs)
|
|||||||
if ((strcmp(cmd->name, "lock") == 0) ||
|
if ((strcmp(cmd->name, "lock") == 0) ||
|
||||||
(strcmp(cmd->name, "term") == 0))
|
(strcmp(cmd->name, "term") == 0))
|
||||||
continue;
|
continue;
|
||||||
/* search_match_text() needs mi->text */
|
menuq_add(&menuq, cmd, NULL);
|
||||||
menuq_add(&menuq, cmd, "%s", cmd->name);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((mi = menu_filter(sc, &menuq,
|
if ((mi = menu_filter(sc, &menuq,
|
||||||
(m) ? NULL : "application", NULL,
|
(m) ? NULL : "application", NULL,
|
||||||
((m) ? CWM_MENU_LIST : 0),
|
((m) ? CWM_MENU_LIST : 0),
|
||||||
search_match_text, search_print_cmd)) != NULL) {
|
search_match_cmd, search_print_cmd)) != NULL) {
|
||||||
cmd = (struct cmd_ctx *)mi->ctx;
|
cmd = (struct cmd_ctx *)mi->ctx;
|
||||||
u_spawn(cmd->path);
|
u_spawn(cmd->path);
|
||||||
}
|
}
|
||||||
@ -488,12 +487,12 @@ kbfunc_menu_group(void *ctx, struct cargs *cargs)
|
|||||||
TAILQ_FOREACH(gc, &sc->groupq, entry) {
|
TAILQ_FOREACH(gc, &sc->groupq, entry) {
|
||||||
if (group_holds_only_sticky(gc))
|
if (group_holds_only_sticky(gc))
|
||||||
continue;
|
continue;
|
||||||
menuq_add(&menuq, gc, "%d %s", gc->num, gc->name);
|
menuq_add(&menuq, gc, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((mi = menu_filter(sc, &menuq,
|
if ((mi = menu_filter(sc, &menuq,
|
||||||
(m) ? NULL : "group", NULL, (CWM_MENU_LIST),
|
(m) ? NULL : "group", NULL, (CWM_MENU_LIST),
|
||||||
search_match_text, search_print_group)) != NULL) {
|
search_match_group, search_print_group)) != NULL) {
|
||||||
gc = (struct group_ctx *)mi->ctx;
|
gc = (struct group_ctx *)mi->ctx;
|
||||||
(group_holds_only_hidden(gc)) ?
|
(group_holds_only_hidden(gc)) ?
|
||||||
group_show(gc) : group_hide(gc);
|
group_show(gc) : group_hide(gc);
|
||||||
|
29
search.c
29
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
|
static void
|
||||||
match_path_type(struct menu_q *resultq, char *search, int flag)
|
match_path_type(struct menu_q *resultq, char *search, int flag)
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user