1
0

moved main, updated args

This commit is contained in:
Connor Lane Smith 2010-11-17 04:33:34 +00:00
parent da81f57f6d
commit 8d9ade36de
2 changed files with 53 additions and 48 deletions

View File

@ -7,6 +7,8 @@ dmenu \- dynamic menu
.RB [ \-i ] .RB [ \-i ]
.RB [ \-l .RB [ \-l
.IR lines ] .IR lines ]
.RB [ \-m
.IR monitor ]
.RB [ \-p .RB [ \-p
.IR prompt ] .IR prompt ]
.RB [ \-fn .RB [ \-fn
@ -51,6 +53,9 @@ dmenu matches menu items case insensitively.
.BI \-l " lines" .BI \-l " lines"
dmenu lists items vertically, with the given number of lines. dmenu lists items vertically, with the given number of lines.
.TP .TP
.BI \-m " monitor"
dmenu appears on the given Xinerama screen.
.TP
.BI \-p " prompt" .BI \-p " prompt"
defines the prompt to be displayed to the left of the input field. defines the prompt to be displayed to the left of the input field.
.TP .TP

96
dmenu.c
View File

@ -63,6 +63,52 @@ static Window root, win;
static int (*fstrncmp)(const char *, const char *, size_t) = strncmp; static int (*fstrncmp)(const char *, const char *, size_t) = strncmp;
int
main(int argc, char *argv[]) {
int i;
progname = "dmenu";
for(i = 1; i < argc; i++)
/* single flags */
if(!strcmp(argv[i], "-v")) {
fputs("dmenu-"VERSION", © 2006-2010 dmenu engineers, see LICENSE for details\n", stdout);
exit(EXIT_SUCCESS);
}
else if(!strcmp(argv[i], "-b"))
topbar = False;
else if(!strcmp(argv[i], "-i"))
fstrncmp = strncasecmp;
else if(i == argc-1)
usage();
/* double flags */
else if(!strcmp(argv[i], "-l"))
lines = atoi(argv[++i]);
else if(!strcmp(argv[i], "-m"))
monitor = atoi(argv[++i]);
else if(!strcmp(argv[i], "-p"))
prompt = argv[++i];
else if(!strcmp(argv[i], "-fn"))
font = argv[++i];
else if(!strcmp(argv[i], "-nb"))
normbgcolor = argv[++i];
else if(!strcmp(argv[i], "-nf"))
normfgcolor = argv[++i];
else if(!strcmp(argv[i], "-sb"))
selbgcolor = argv[++i];
else if(!strcmp(argv[i], "-sf"))
selfgcolor = argv[++i];
else
usage();
dc = initdc();
initfont(dc, font);
readstdin();
setup();
run();
return EXIT_FAILURE; /* should not reach */
}
void void
appenditem(Item *item, Item **list, Item **last) { appenditem(Item *item, Item **list, Item **last) {
if(!*last) if(!*last)
@ -490,53 +536,7 @@ setup(void) {
void void
usage(void) { usage(void) {
fputs("usage: dmenu [-b] [-i] [-l lines] [-p prompt] [-fn font] [-nb color]\n" fputs("usage: dmenu [-b] [-i] [-l lines] [-m monitor] [-p prompt] [-fn font]\n"
" [-nf color] [-sb color] [-sf color] [-v]\n", stderr); " [-nb color] [-nf color] [-sb color] [-sf color] [-v]\n", stderr);
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }
int
main(int argc, char *argv[]) {
int i;
progname = "dmenu";
for(i = 1; i < argc; i++)
/* single flags */
if(!strcmp(argv[i], "-v")) {
fputs("dmenu-"VERSION", © 2006-2010 dmenu engineers, see LICENSE for details\n", stdout);
exit(EXIT_SUCCESS);
}
else if(!strcmp(argv[i], "-b"))
topbar = False;
else if(!strcmp(argv[i], "-i"))
fstrncmp = strncasecmp;
else if(i == argc-1)
usage();
/* double flags */
else if(!strcmp(argv[i], "-l"))
lines = atoi(argv[++i]);
else if(!strcmp(argv[i], "-m"))
monitor = atoi(argv[++i]);
else if(!strcmp(argv[i], "-p"))
prompt = argv[++i];
else if(!strcmp(argv[i], "-fn"))
font = argv[++i];
else if(!strcmp(argv[i], "-nb"))
normbgcolor = argv[++i];
else if(!strcmp(argv[i], "-nf"))
normfgcolor = argv[++i];
else if(!strcmp(argv[i], "-sb"))
selbgcolor = argv[++i];
else if(!strcmp(argv[i], "-sf"))
selfgcolor = argv[++i];
else
usage();
dc = initdc();
initfont(dc, font);
readstdin();
setup();
run();
return EXIT_FAILURE; /* should not reach */
}