aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorarg@10ksloc.org <unknown>2006-08-07 07:30:13 +0200
committerarg@10ksloc.org <unknown>2006-08-07 07:30:13 +0200
commitee03052e73c344cac6840d379a792fb135dce371 (patch)
tree7b5b892e0ad31f03bb00f6f960206612c0afc8c9
parent62a7d4074671ac8dd37d3c2640eae5e488741a16 (diff)
removed -t title crap from dmenu
-rw-r--r--dmenu.17
-rw-r--r--main.c62
2 files changed, 12 insertions, 57 deletions
diff --git a/dmenu.1 b/dmenu.1
index da69047..4dbef65 100644
--- a/dmenu.1
+++ b/dmenu.1
@@ -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
19prints version information to stdout, then exits. 17prints version information to stdout, then exits.
20.TP
21.BI \-t " title"
22displays
23.I title
24above the menu.
25.SS Usage 18.SS Usage
26.B dmenu 19.B dmenu
27reads a list of newline-separated items from stdin and creates a menu. 20reads a list of newline-separated items from stdin and creates a menu.
diff --git a/main.c b/main.c
index 32b08b9..f151819 100644
--- a/main.c
+++ b/main.c
@@ -24,13 +24,11 @@ struct Item {
24 24
25/* static */ 25/* static */
26 26
27static char *title, text[4096]; 27static char text[4096];
28static int mx, my, mw, mh; 28static int mx, my, mw, mh;
29static int ret = 0; 29static int ret = 0;
30static int nitem = 0; 30static int nitem = 0;
31static unsigned int cmdw = 0; 31static unsigned int cmdw = 0;
32static unsigned int tw = 0;
33static unsigned int cw = 0;
34static Bool done = False; 32static Bool done = False;
35static Item *allitems = NULL; /* first of all items */ 33static Item *allitems = NULL; /* first of all items */
36static Item *item = NULL; /* first of pattern matching items */ 34static 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
308main(int argc, char *argv[]) 293main(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);