static struct menu * menu_complete_path(struct menu_ctx *mc) { struct screen_ctx *sc = mc->sc; struct menu *mi, *mr; struct menu_q menuq; int mflags = (CWM_MENU_DUMMY); mr = xcalloc(1, sizeof(*mr)); TAILQ_INIT(&menuq); if ((mi = menu_filter(sc, &menuq, mc->searchstr, NULL, mflags, search_match_path, search_print_text)) != NULL) { mr->abort = mi->abort; mr->dummy = mi->dummy; if (mi->text[0] != '\0') snprintf(mr->text, sizeof(mr->text), "%s \"%s\"", mc->searchstr, mi->text); else if (!mr->abort) strlcpy(mr->text, mc->searchstr, sizeof(mr->text)); } menuq_clear(&menuq); return(mr); }
static struct menu * menu_complete_path(struct menu_ctx *mc) { struct menu *mi, *mr; struct menu_q menuq; char *path = NULL; path = xcalloc(1, sizeof(mr->text)); mr = xcalloc(1, sizeof(*mr)); TAILQ_INIT(&menuq); if ((mi = menu_filter(mc->sc, &menuq, mc->searchstr, NULL, CWM_MENU_DUMMY, search_match_path_any, NULL)) != NULL) { mr->abort = mi->abort; mr->dummy = mi->dummy; strlcpy(path, mi->text, sizeof(mi->text)); } menuq_clear(&menuq); if (path[0] != '\0') snprintf(mr->text, sizeof(mr->text), "%s \"%s\"", mc->searchstr, path); else if (!mr->abort) strlcpy(mr->text, mc->searchstr, sizeof(mr->text)); free(path); return (mr); }
void mousefunc_menu_cmd(struct client_ctx *cc, union arg *arg) { struct screen_ctx *sc = cc->sc; struct cmd *cmd; struct menu *mi; struct menu_q menuq; TAILQ_INIT(&menuq); TAILQ_FOREACH(cmd, &Conf.cmdq, entry) menuq_add(&menuq, cmd, "%s", cmd->name); if (TAILQ_EMPTY(&menuq)) return; if ((mi = menu_filter(sc, &menuq, NULL, NULL, 0, NULL, NULL)) != NULL) u_spawn(((struct cmd *)mi->ctx)->path); menuq_clear(&menuq); }
void mousefunc_menu_unhide(struct client_ctx *cc, union arg *arg) { struct screen_ctx *sc = cc->sc; struct client_ctx *old_cc; struct menu *mi; struct menu_q menuq; char *wname; old_cc = client_current(); TAILQ_INIT(&menuq); TAILQ_FOREACH(cc, &Clientq, entry) if (cc->flags & CLIENT_HIDDEN) { wname = (cc->label) ? cc->label : cc->name; if (wname == NULL) continue; menuq_add(&menuq, cc, "(%d) %s", cc->group->shortcut, wname); } if (TAILQ_EMPTY(&menuq)) return; if ((mi = menu_filter(sc, &menuq, NULL, NULL, 0, NULL, NULL)) != NULL) { cc = (struct client_ctx *)mi->ctx; client_unhide(cc); if (old_cc != NULL) client_ptrsave(old_cc); client_ptrwarp(cc); } menuq_clear(&menuq); }