diff options
author | Okan Demirmen <okan@cvs.openbsd.org> | 2015-06-30 18:54:13 +0000 |
---|---|---|
committer | Okan Demirmen <okan@cvs.openbsd.org> | 2015-06-30 18:54:13 +0000 |
commit | e9617680714e071ae8c544c33eb01cb5013dd61d (patch) | |
tree | 1cc98aca931e90f6de1fed5ac533ef3c6419bc7c | |
parent | e69673aeb383cd33b022fe5bc4e880c0d06397c0 (diff) |
Introduce a callback for cmd menu printing, special-casing 'lock' and
'term'.
-rw-r--r-- | app/cwm/calmwm.h | 3 | ||||
-rw-r--r-- | app/cwm/kbfunc.c | 4 | ||||
-rw-r--r-- | app/cwm/mousefunc.c | 4 | ||||
-rw-r--r-- | app/cwm/search.c | 16 |
4 files changed, 21 insertions, 6 deletions
diff --git a/app/cwm/calmwm.h b/app/cwm/calmwm.h index 2553dd7cf..dfb416dbd 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.295 2015/06/26 17:17:46 okan Exp $ + * $OpenBSD: calmwm.h,v 1.296 2015/06/30 18:54:12 okan Exp $ */ #ifndef _CALMWM_H_ @@ -449,6 +449,7 @@ void search_match_path_any(struct menu_q *, struct menu_q *, 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); struct geom screen_apply_gap(struct screen_ctx *, struct geom); struct screen_ctx *screen_find(Window); diff --git a/app/cwm/kbfunc.c b/app/cwm/kbfunc.c index 714d37f6c..872af3ae0 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.109 2015/06/29 14:24:40 okan Exp $ + * $OpenBSD: kbfunc.c,v 1.110 2015/06/30 18:54:12 okan Exp $ */ #include <sys/types.h> @@ -181,7 +181,7 @@ kbfunc_menu_cmd(struct client_ctx *cc, union arg *arg) menuq_add(&menuq, cmd, "%s", cmd->name); if ((mi = menu_filter(sc, &menuq, "application", NULL, 0, - search_match_text, NULL)) != NULL) + search_match_text, search_print_cmd)) != NULL) u_spawn(((struct cmd *)mi->ctx)->path); menuq_clear(&menuq); diff --git a/app/cwm/mousefunc.c b/app/cwm/mousefunc.c index 5733f0aa7..10a03a5db 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.92 2015/06/26 17:17:46 okan Exp $ + * $OpenBSD: mousefunc.c,v 1.93 2015/06/30 18:54:12 okan Exp $ */ #include <sys/types.h> @@ -239,7 +239,7 @@ mousefunc_menu_cmd(struct client_ctx *cc, union arg *arg) menuq_add(&menuq, cmd, "%s", cmd->name); if ((mi = menu_filter(sc, &menuq, NULL, NULL, CWM_MENU_LIST, - NULL, NULL)) != NULL) + NULL, search_print_cmd)) != NULL) u_spawn(((struct cmd *)mi->ctx)->path); menuq_clear(&menuq); diff --git a/app/cwm/search.c b/app/cwm/search.c index a4046cb32..d04221d7b 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.45 2015/06/30 18:42:50 okan Exp $ + * $OpenBSD: search.c,v 1.46 2015/06/30 18:54:12 okan Exp $ */ #include <sys/types.h> @@ -124,6 +124,20 @@ search_match_client(struct menu_q *menuq, struct menu_q *resultq, char *search) } void +search_print_cmd(struct menu *mi, int i) +{ + struct cmd *cmd = (struct cmd *)mi->ctx; + int special = 0; + + if ((strcmp(cmd->name, "lock") == 0) || + (strcmp(cmd->name, "term") == 0)) + special = 1; + + (void)snprintf(mi->print, sizeof(mi->print), + (special) ? "[%s]" : "%s", cmd->name); +} + +void search_print_client(struct menu *mi, int list) { struct client_ctx *cc = (struct client_ctx *)mi->ctx; |