mirror of
https://github.com/leahneukirchen/cwm.git
synced 2023-08-10 21:13:12 +03:00
cvsimport
This commit is contained in:
36
kbfunc.c
36
kbfunc.c
@@ -41,6 +41,7 @@ extern sig_atomic_t xev_quit;
|
||||
void
|
||||
kbfunc_client_lower(struct client_ctx *cc, union arg *arg)
|
||||
{
|
||||
client_ptrsave(cc);
|
||||
client_lower(cc);
|
||||
}
|
||||
|
||||
@@ -151,13 +152,8 @@ kbfunc_client_search(struct client_ctx *cc, union arg *arg)
|
||||
old_cc = client_current();
|
||||
|
||||
TAILQ_INIT(&menuq);
|
||||
|
||||
TAILQ_FOREACH(cc, &Clientq, entry) {
|
||||
mi = xcalloc(1, sizeof(*mi));
|
||||
(void)strlcpy(mi->text, cc->name, sizeof(mi->text));
|
||||
mi->ctx = cc;
|
||||
TAILQ_INSERT_TAIL(&menuq, mi, entry);
|
||||
}
|
||||
TAILQ_FOREACH(cc, &Clientq, entry)
|
||||
menuq_add(&menuq, cc, "%s", cc->name);
|
||||
|
||||
if ((mi = menu_filter(sc, &menuq, "window", NULL, 0,
|
||||
search_match_client, search_print_client)) != NULL) {
|
||||
@@ -182,17 +178,12 @@ kbfunc_menu_search(struct client_ctx *cc, union arg *arg)
|
||||
struct menu_q menuq;
|
||||
|
||||
TAILQ_INIT(&menuq);
|
||||
|
||||
TAILQ_FOREACH(cmd, &Conf.cmdq, entry) {
|
||||
mi = xcalloc(1, sizeof(*mi));
|
||||
(void)strlcpy(mi->text, cmd->label, sizeof(mi->text));
|
||||
mi->ctx = cmd;
|
||||
TAILQ_INSERT_TAIL(&menuq, mi, entry);
|
||||
}
|
||||
TAILQ_FOREACH(cmd, &Conf.cmdq, entry)
|
||||
menuq_add(&menuq, cmd, "%s", cmd->name);
|
||||
|
||||
if ((mi = menu_filter(sc, &menuq, "application", NULL, 0,
|
||||
search_match_text, NULL)) != NULL)
|
||||
u_spawn(((struct cmd *)mi->ctx)->image);
|
||||
u_spawn(((struct cmd *)mi->ctx)->path);
|
||||
|
||||
menuq_clear(&menuq);
|
||||
}
|
||||
@@ -238,8 +229,9 @@ kbfunc_exec(struct client_ctx *cc, union arg *arg)
|
||||
{
|
||||
#define NPATHS 256
|
||||
struct screen_ctx *sc = cc->sc;
|
||||
char **ap, *paths[NPATHS], *path, *pathcpy, *label;
|
||||
char **ap, *paths[NPATHS], *path, *pathcpy;
|
||||
char tpath[MAXPATHLEN];
|
||||
const char *label;
|
||||
DIR *dirp;
|
||||
struct dirent *dp;
|
||||
struct menu *mi;
|
||||
@@ -284,12 +276,8 @@ kbfunc_exec(struct client_ctx *cc, union arg *arg)
|
||||
/* check for truncation etc */
|
||||
if (l == -1 || l >= (int)sizeof(tpath))
|
||||
continue;
|
||||
if (access(tpath, X_OK) == 0) {
|
||||
mi = xcalloc(1, sizeof(*mi));
|
||||
(void)strlcpy(mi->text,
|
||||
dp->d_name, sizeof(mi->text));
|
||||
TAILQ_INSERT_TAIL(&menuq, mi, entry);
|
||||
}
|
||||
if (access(tpath, X_OK) == 0)
|
||||
menuq_add(&menuq, NULL, "%s", dp->d_name);
|
||||
}
|
||||
(void)closedir(dirp);
|
||||
}
|
||||
@@ -360,9 +348,7 @@ kbfunc_ssh(struct client_ctx *cc, union arg *arg)
|
||||
if (p - buf + 1 > sizeof(hostbuf))
|
||||
continue;
|
||||
(void)strlcpy(hostbuf, buf, p - buf + 1);
|
||||
mi = xcalloc(1, sizeof(*mi));
|
||||
(void)strlcpy(mi->text, hostbuf, sizeof(mi->text));
|
||||
TAILQ_INSERT_TAIL(&menuq, mi, entry);
|
||||
menuq_add(&menuq, NULL, hostbuf);
|
||||
}
|
||||
free(lbuf);
|
||||
(void)fclose(fp);
|
||||
|
||||
Reference in New Issue
Block a user