all repos — dmenu @ 340b176de6db87471610c0a75450e0de9535b6ae

my build of dmenu

dinput with dmenu flags, fixed usage & -v, cosmetics
Connor Lane Smith cls@lubutu.com
Tue, 29 Jun 2010 16:07:31 +0100
commit

340b176de6db87471610c0a75450e0de9535b6ae

parent

18dcf738967a45208e880b72ce273afdd93ee6c7

2 files changed, 32 insertions(+), 14 deletions(-)

jump to
M dinput.cdinput.c

@@ -76,11 +76,11 @@ drawtext(&dc, NULL, normcol, False);

/* print prompt? */ if(prompt) { dc.w = promptw; - drawtext(&dc, prompt, selcol, False); + drawtext(&dc, prompt, normcol, False); dc.x += dc.w; } dc.w = mw - dc.x; - drawtext(&dc, *text ? text : NULL, normcol, False); + drawtext(&dc, *text ? text : NULL, selcol, False); drawcursor(); XCopyArea(dpy, dc.drawable, win, dc.gc, 0, 0, mw, mh, 0, 0); XFlush(dpy);

@@ -329,11 +329,15 @@

/* command line args */ progname = argv[0]; for(i = 1; i < argc; i++) - if(!strcmp(argv[i], "-b")) + if(!strcmp(argv[i], "-i")) + ; /* ignore flag */ + else if(!strcmp(argv[i], "-b")) topbar = False; else if(!strcmp(argv[i], "-e")) { if(++i < argc) parent = atoi(argv[i]); } + else if(!strcmp(argv[i], "-l")) + i++; /* ignore flag */ else if(!strcmp(argv[i], "-fn")) { if(++i < argc) font = argv[i]; }

@@ -352,13 +356,17 @@ }

else if(!strcmp(argv[i], "-sf")) { if(++i < argc) selfgcolor = argv[i]; } - else if(!strcmp(argv[i], "-v")) - eprint("dinput-"VERSION", © 2006-2010 dinput engineers, see LICENSE for details\n"); + else if(!strcmp(argv[i], "-v")) { + printf("dinput-"VERSION", © 2006-2010 dinput engineers, see LICENSE for details\n"); + exit(EXIT_SUCCESS); + } else if(!*text) strncpy(text, argv[i], sizeof text); - else - eprint("usage: dinput [-b] [-e <xid>] [-fn <font>] [-nb <color>] [-nf <color>]\n" - " [-p <prompt>] [-sb <color>] [-sf <color>] [-v] [<text>]\n"); + else { + fputs("usage: dinput [-b] [-e <xid>] [-fn <font>] [-nb <color>] [-nf <color>]\n" + " [-p <prompt>] [-sb <color>] [-sf <color>] [-v] [<text>]\n", stderr); + exit(EXIT_FAILURE); + } if(!setlocale(LC_CTYPE, "") || !XSupportsLocale()) fprintf(stderr, "dinput: warning: no locale support\n"); if(!(dpy = XOpenDisplay(NULL)))
M dmenu.cdmenu.c

@@ -49,6 +49,7 @@ #include "config.h"

#include "draw.h" /* variables */ +static char **argp = NULL; static char *maxname = NULL; static char *prompt = NULL; static char text[4096];

@@ -151,7 +152,9 @@

void dinput(void) { cleanup(); - execlp("dinput", "dinput", text, NULL); /* todo: argv */ + argp[0] = "dinput"; + argp[1] = text; + execvp("dinput", argp); eprint("cannot exec dinput\n"); }

@@ -587,11 +590,15 @@ }

else if(!strcmp(argv[i], "-sf")) { if(++i < argc) selfgcolor = argv[i]; } - else if(!strcmp(argv[i], "-v")) - eprint("dmenu-"VERSION", © 2006-2010 dmenu engineers, see LICENSE for details\n"); - else - eprint("usage: dmenu [-i] [-b] [-e <xid>] [-l <lines>] [-fn <font>] [-nb <color>]\n" - " [-nf <color>] [-p <prompt>] [-sb <color>] [-sf <color>] [-v]\n"); + else if(!strcmp(argv[i], "-v")) { + printf("dmenu-"VERSION", © 2006-2010 dmenu engineers, see LICENSE for details\n"); + exit(EXIT_SUCCESS); + } + else { + fputs("usage: dmenu [-i] [-b] [-e <xid>] [-l <lines>] [-fn <font>] [-nb <color>]\n" + " [-nf <color>] [-p <prompt>] [-sb <color>] [-sf <color>] [-v]\n", stderr); + exit(EXIT_FAILURE); + } if(!setlocale(LC_CTYPE, "") || !XSupportsLocale()) fprintf(stderr, "dmenu: warning: no locale support\n"); if(!(dpy = XOpenDisplay(NULL)))

@@ -599,6 +606,9 @@ eprint("cannot open display\n");

screen = DefaultScreen(dpy); if(!parent) parent = RootWindow(dpy, screen); + if(!(argp = malloc(sizeof *argp * (argc+2)))) + eprint("cannot malloc %u bytes\n", sizeof *argp * (argc+2)); + memcpy(argp + 2, argv + 1, sizeof *argp * argc); readstdin(); running = grabkeyboard();