Xinqi Bao's Git
projects
/
dmenu.git
/ blobdiff
summary
|
log
|
commit
|
diff
|
tree
raw
|
inline
| side by side
fast grab patch (thanks Rob)
[dmenu.git]
/
dmenu.c
diff --git
a/dmenu.c
b/dmenu.c
index
d8ef88f
..
2193f82
100644
(file)
--- a/
dmenu.c
+++ b/
dmenu.c
@@
-64,6
+64,7
@@
static int (*fstrncmp)(const char *, const char *, size_t) = strncmp;
int
main(int argc, char *argv[]) {
int
main(int argc, char *argv[]) {
+ Bool fast = False;
int i;
progname = "dmenu";
int i;
progname = "dmenu";
@@
-77,6
+78,8
@@
main(int argc, char *argv[]) {
topbar = False;
else if(!strcmp(argv[i], "-i"))
fstrncmp = strncasecmp;
topbar = False;
else if(!strcmp(argv[i], "-i"))
fstrncmp = strncasecmp;
+ else if(!strcmp(argv[i], "-f"))
+ fast = True;
else if(i == argc-1)
goto usage;
/* double flags */
else if(i == argc-1)
goto usage;
/* double flags */
@@
-101,13
+104,21
@@
main(int argc, char *argv[]) {
dc = initdc();
initfont(dc, font);
dc = initdc();
initfont(dc, font);
- readstdin();
- setup();
+
+ if(fast) {
+ setup();
+ readstdin();
+ }
+ else {
+ readstdin();
+ setup();
+ }
+ match();
run();
return EXIT_FAILURE;
usage:
run();
return EXIT_FAILURE;
usage:
- fputs("usage: dmenu [-b] [-i] [-l lines] [-m monitor] [-p prompt] [-fn font]\n"
+ fputs("usage: dmenu [-b] [-
f] [-
i] [-l lines] [-m monitor] [-p prompt] [-fn font]\n"
" [-nb color] [-nf color] [-sb color] [-sf color] [-v]\n", stderr);
return EXIT_FAILURE;
}
" [-nb color] [-nf color] [-sb color] [-sf color] [-v]\n", stderr);
return EXIT_FAILURE;
}
@@
-440,9
+451,9
@@
readstdin(void) {
if((p = strchr(buf, '\n')))
*p = '\0';
if(!(item = calloc(1, sizeof *item)))
if((p = strchr(buf, '\n')))
*p = '\0';
if(!(item = calloc(1, sizeof *item)))
- eprintf("cannot malloc %u bytes
\n
", sizeof *item);
+ eprintf("cannot malloc %u bytes
:
", sizeof *item);
if(!(item->text = strdup(buf)))
if(!(item->text = strdup(buf)))
- eprintf("cannot strdup %u bytes
\n
", strlen(buf)+1);
+ eprintf("cannot strdup %u bytes
:
", strlen(buf)+1);
inputw = MAX(inputw, textw(dc, item->text));
}
}
inputw = MAX(inputw, textw(dc, item->text));
}
}
@@
-530,5
+541,4
@@
setup(void) {
inputw = MIN(inputw, mw/3);
promptw = prompt ? textw(dc, prompt) : 0;
XMapRaised(dc->dpy, win);
inputw = MIN(inputw, mw/3);
promptw = prompt ? textw(dc, prompt) : 0;
XMapRaised(dc->dpy, win);
- match();
}
}