From 8529d9a1c6746c2e7415caabef03153c2acaf3da Mon Sep 17 00:00:00 2001 From: okan Date: Sun, 12 Jul 2015 14:31:47 +0000 Subject: [PATCH] introduce 'groupsearch' for group menu search; matches on either group number/shortcut and/or name. --- app/cwm/calmwm.h | 4 +++- app/cwm/conf.c | 3 ++- app/cwm/cwmrc.5 | 6 ++++-- app/cwm/kbfunc.c | 27 ++++++++++++++++++++++++++- app/cwm/mousefunc.c | 8 +++----- app/cwm/search.c | 12 +++++++++++- 6 files changed, 49 insertions(+), 11 deletions(-) diff --git a/app/cwm/calmwm.h b/app/cwm/calmwm.h index dfb416dbd..d919602fd 100644 --- a/app/cwm/calmwm.h +++ b/app/cwm/calmwm.h @@ -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: calmwm.h,v 1.296 2015/06/30 18:54:12 okan Exp $ + * $OpenBSD: calmwm.h,v 1.297 2015/07/12 14:31:47 okan Exp $ */ #ifndef _CALMWM_H_ @@ -450,6 +450,7 @@ void search_match_text(struct menu_q *, struct menu_q *, char *); void search_print_client(struct menu *, int); void search_print_cmd(struct menu *, int); +void search_print_group(struct menu *, int); struct geom screen_apply_gap(struct screen_ctx *, struct geom); struct screen_ctx *screen_find(Window); @@ -496,6 +497,7 @@ void kbfunc_cwm_status(struct client_ctx *, union arg *); void kbfunc_exec(struct client_ctx *, union arg *); void kbfunc_lock(struct client_ctx *, union arg *); void kbfunc_menu_cmd(struct client_ctx *, union arg *); +void kbfunc_menu_group(struct client_ctx *, union arg *); void kbfunc_ssh(struct client_ctx *, union arg *); void kbfunc_term(struct client_ctx *, union arg *); void kbfunc_tile(struct client_ctx *, union arg *); diff --git a/app/cwm/conf.c b/app/cwm/conf.c index bd30dbc6b..e80a1ed92 100644 --- a/app/cwm/conf.c +++ b/app/cwm/conf.c @@ -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: conf.c,v 1.190 2015/07/01 14:36:42 okan Exp $ + * $OpenBSD: conf.c,v 1.191 2015/07/12 14:31:47 okan Exp $ */ #include @@ -360,6 +360,7 @@ static const struct { { "raise", kbfunc_client_raise, CWM_WIN, {0} }, { "search", kbfunc_client_search, 0, {0} }, { "menusearch", kbfunc_menu_cmd, 0, {0} }, + { "groupsearch", kbfunc_menu_group, 0, {0} }, { "hide", kbfunc_client_hide, CWM_WIN, {0} }, { "cycle", kbfunc_client_cycle, 0, {.i = CWM_CYCLE} }, { "rcycle", kbfunc_client_cycle, 0, {.i = CWM_RCYCLE} }, diff --git a/app/cwm/cwmrc.5 b/app/cwm/cwmrc.5 index 0e8a89d0b..13ec7e3b6 100644 --- a/app/cwm/cwmrc.5 +++ b/app/cwm/cwmrc.5 @@ -1,4 +1,4 @@ -.\" $OpenBSD: cwmrc.5,v 1.60 2015/05/31 23:07:36 okan Exp $ +.\" $OpenBSD: cwmrc.5,v 1.61 2015/07/12 14:31:47 okan Exp $ .\" .\" Copyright (c) 2004,2005 Marius Aamodt Eriksen .\" @@ -14,7 +14,7 @@ .\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF .\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. .\" -.Dd $Mdocdate: May 31 2015 $ +.Dd $Mdocdate: July 12 2015 $ .Dt CWMRC 5 .Os .Sh NAME @@ -251,6 +251,8 @@ Lock the screen. Launch window search menu. .It menusearch Launch application search menu. +.It groupsearch +Launch group search menu. .It exec Launch .Dq exec program diff --git a/app/cwm/kbfunc.c b/app/cwm/kbfunc.c index d3c54a03a..046c89846 100644 --- a/app/cwm/kbfunc.c +++ b/app/cwm/kbfunc.c @@ -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: kbfunc.c,v 1.112 2015/07/03 17:11:16 okan Exp $ + * $OpenBSD: kbfunc.c,v 1.113 2015/07/12 14:31:47 okan Exp $ */ #include @@ -187,6 +187,31 @@ kbfunc_menu_cmd(struct client_ctx *cc, union arg *arg) menuq_clear(&menuq); } +void +kbfunc_menu_group(struct client_ctx *cc, union arg *arg) +{ + struct screen_ctx *sc = cc->sc; + struct group_ctx *gc; + struct menu *mi; + struct menu_q menuq; + + TAILQ_INIT(&menuq); + TAILQ_FOREACH(gc, &sc->groupq, entry) { + if (group_holds_only_sticky(gc)) + continue; + menuq_add(&menuq, gc, "%d %s", gc->num, gc->name); + } + + if ((mi = menu_filter(sc, &menuq, "group", NULL, CWM_MENU_LIST, + search_match_text, search_print_group)) != NULL) { + gc = (struct group_ctx *)mi->ctx; + (group_holds_only_hidden(gc)) ? + group_show(gc) : group_hide(gc); + } + + menuq_clear(&menuq); +} + void kbfunc_client_cycle(struct client_ctx *cc, union arg *arg) { diff --git a/app/cwm/mousefunc.c b/app/cwm/mousefunc.c index 34c347f45..b27ef5ba3 100644 --- a/app/cwm/mousefunc.c +++ b/app/cwm/mousefunc.c @@ -16,7 +16,7 @@ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * - * $OpenBSD: mousefunc.c,v 1.95 2015/07/01 14:36:42 okan Exp $ + * $OpenBSD: mousefunc.c,v 1.96 2015/07/12 14:31:47 okan Exp $ */ #include @@ -182,13 +182,11 @@ mousefunc_menu_group(struct client_ctx *cc, union arg *arg) TAILQ_FOREACH(gc, &sc->groupq, entry) { if (group_holds_only_sticky(gc)) continue; - menuq_add(&menuq, gc, - (group_holds_only_hidden(gc)) ? "%d: [%s]" : "%d: %s", - gc->num, gc->name); + menuq_add(&menuq, gc, "%d %s", gc->num, gc->name); } if ((mi = menu_filter(sc, &menuq, NULL, NULL, CWM_MENU_LIST, - NULL, NULL)) != NULL) { + NULL, search_print_group)) != NULL) { gc = (struct group_ctx *)mi->ctx; (group_holds_only_hidden(gc)) ? group_show(gc) : group_hide(gc); diff --git a/app/cwm/search.c b/app/cwm/search.c index 44311fd96..7f64460ac 100644 --- a/app/cwm/search.c +++ b/app/cwm/search.c @@ -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.48 2015/07/01 14:36:42 okan Exp $ + * $OpenBSD: search.c,v 1.49 2015/07/12 14:31:47 okan Exp $ */ #include @@ -137,6 +137,16 @@ search_print_cmd(struct menu *mi, int i) (special) ? "[%s]" : "%s", cmd->name); } +void +search_print_group(struct menu *mi, int i) +{ + struct group_ctx *gc = (struct group_ctx *)mi->ctx; + + (void)snprintf(mi->print, sizeof(mi->print), + (group_holds_only_hidden(gc)) ? "%d: [%s]" : "%d: %s", + gc->num, gc->name); +} + void search_print_client(struct menu *mi, int list) {