diff options
author | arg@10ksloc.org <unknown> | 2006-08-07 07:30:13 +0200 |
---|---|---|
committer | arg@10ksloc.org <unknown> | 2006-08-07 07:30:13 +0200 |
commit | ee03052e73c344cac6840d379a792fb135dce371 (patch) | |
tree | 7b5b892e0ad31f03bb00f6f960206612c0afc8c9 | |
parent | 62a7d4074671ac8dd37d3c2640eae5e488741a16 (diff) |
removed -t title crap from dmenu
-rw-r--r-- | dmenu.1 | 7 | ||||
-rw-r--r-- | main.c | 62 |
2 files changed, 12 insertions, 57 deletions
@@ -4,8 +4,6 @@ dmenu \- dynamic menu | |||
4 | .SH SYNOPSIS | 4 | .SH SYNOPSIS |
5 | .B dmenu | 5 | .B dmenu |
6 | .RB [ \-v ] | 6 | .RB [ \-v ] |
7 | .RB [ \-t | ||
8 | .IR title ] | ||
9 | .SH DESCRIPTION | 7 | .SH DESCRIPTION |
10 | .SS Overview | 8 | .SS Overview |
11 | .B dmenu | 9 | .B dmenu |
@@ -17,11 +15,6 @@ It supports arbitrary, user defined menu contents. | |||
17 | .TP | 15 | .TP |
18 | .B \-v | 16 | .B \-v |
19 | prints version information to stdout, then exits. | 17 | prints version information to stdout, then exits. |
20 | .TP | ||
21 | .BI \-t " title" | ||
22 | displays | ||
23 | .I title | ||
24 | above the menu. | ||
25 | .SS Usage | 18 | .SS Usage |
26 | .B dmenu | 19 | .B dmenu |
27 | reads a list of newline-separated items from stdin and creates a menu. | 20 | reads a list of newline-separated items from stdin and creates a menu. |
@@ -24,13 +24,11 @@ struct Item { | |||
24 | 24 | ||
25 | /* static */ | 25 | /* static */ |
26 | 26 | ||
27 | static char *title, text[4096]; | 27 | static char text[4096]; |
28 | static int mx, my, mw, mh; | 28 | static int mx, my, mw, mh; |
29 | static int ret = 0; | 29 | static int ret = 0; |
30 | static int nitem = 0; | 30 | static int nitem = 0; |
31 | static unsigned int cmdw = 0; | 31 | static unsigned int cmdw = 0; |
32 | static unsigned int tw = 0; | ||
33 | static unsigned int cw = 0; | ||
34 | static Bool done = False; | 32 | static Bool done = False; |
35 | static Item *allitems = NULL; /* first of all items */ | 33 | static Item *allitems = NULL; /* first of all items */ |
36 | static Item *item = NULL; /* first of pattern matching items */ | 34 | static Item *item = NULL; /* first of pattern matching items */ |
@@ -82,18 +80,10 @@ drawmenu() | |||
82 | drawtext(NULL, False, False); | 80 | drawtext(NULL, False, False); |
83 | 81 | ||
84 | /* print command */ | 82 | /* print command */ |
85 | if(!title || text[0]) { | 83 | if(cmdw && item) |
86 | cmdw = cw; | ||
87 | if(cmdw && item) | ||
88 | dc.w = cmdw; | ||
89 | drawtext(text, False, False); | ||
90 | } | ||
91 | else { | ||
92 | cmdw = tw; | ||
93 | dc.w = cmdw; | 84 | dc.w = cmdw; |
94 | drawtext(title, False, False); | 85 | drawtext(text[0] ? text : NULL, False, False); |
95 | } | 86 | dc.x += cmdw; |
96 | dc.x += dc.w; | ||
97 | 87 | ||
98 | if(curr) { | 88 | if(curr) { |
99 | dc.w = SPACE; | 89 | dc.w = SPACE; |
@@ -127,11 +117,6 @@ input(char *pattern) | |||
127 | if(!pattern) | 117 | if(!pattern) |
128 | return; | 118 | return; |
129 | 119 | ||
130 | if(!title || *pattern) | ||
131 | cmdw = cw; | ||
132 | else | ||
133 | cmdw = tw; | ||
134 | |||
135 | plen = strlen(pattern); | 120 | plen = strlen(pattern); |
136 | item = j = NULL; | 121 | item = j = NULL; |
137 | nitem = 0; | 122 | nitem = 0; |
@@ -308,30 +293,15 @@ int | |||
308 | main(int argc, char *argv[]) | 293 | main(int argc, char *argv[]) |
309 | { | 294 | { |
310 | char *maxname; | 295 | char *maxname; |
311 | int i; | ||
312 | XEvent ev; | 296 | XEvent ev; |
313 | XSetWindowAttributes wa; | 297 | XSetWindowAttributes wa; |
314 | 298 | ||
315 | /* command line args */ | 299 | if(argc == 2 && !strncmp("-v", argv[1], 3)) { |
316 | for(i = 1; i < argc; i++) { | 300 | fputs("dmenu-"VERSION", (C)opyright MMVI Anselm R. Garbe\n", stdout); |
317 | if (argv[i][0] == '-') | 301 | exit(EXIT_SUCCESS); |
318 | switch (argv[i][1]) { | ||
319 | case 'v': | ||
320 | fputs("dmenu-"VERSION", (C)opyright MMVI Anselm R. Garbe\n", stdout); | ||
321 | exit(EXIT_SUCCESS); | ||
322 | break; | ||
323 | case 't': | ||
324 | if(++i < argc) { | ||
325 | title = argv[i]; | ||
326 | break; | ||
327 | } | ||
328 | default: | ||
329 | eprint("usage: dmenu [-v] [-t <title>]\n"); | ||
330 | break; | ||
331 | } | ||
332 | else | ||
333 | eprint("usage: dmenu [-v] [-t <title>]\n"); | ||
334 | } | 302 | } |
303 | else if(argc != 1) | ||
304 | eprint("usage: dmenu [-v]\n"); | ||
335 | 305 | ||
336 | dpy = XOpenDisplay(0); | 306 | dpy = XOpenDisplay(0); |
337 | if(!dpy) | 307 | if(!dpy) |
@@ -371,17 +341,9 @@ main(int argc, char *argv[]) | |||
371 | dc.gc = XCreateGC(dpy, root, 0, 0); | 341 | dc.gc = XCreateGC(dpy, root, 0, 0); |
372 | 342 | ||
373 | if(maxname) | 343 | if(maxname) |
374 | cw = textw(maxname); | 344 | cmdw = textw(maxname); |
375 | if(cw > mw / 3) | 345 | if(cmdw > mw / 3) |
376 | cw = mw / 3; | 346 | cmdw = mw / 3; |
377 | |||
378 | if(title) { | ||
379 | tw = textw(title); | ||
380 | if(tw > mw / 3) | ||
381 | tw = mw / 3; | ||
382 | } | ||
383 | |||
384 | cmdw = title ? tw : cw; | ||
385 | 347 | ||
386 | text[0] = 0; | 348 | text[0] = 0; |
387 | input(text); | 349 | input(text); |