aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorConnor Lane Smith <cls@lubutu.com>2010-08-02 14:49:14 +0100
committerConnor Lane Smith <cls@lubutu.com>2010-08-02 14:49:14 +0100
commit06c18808b6f23bc5120533559e70fbcbff753e84 (patch)
treec5ee6eb7c44053a4a887be02308cd13329012d63
parenta7aee433ccfd2590e0785a7b93a89d8d0593a234 (diff)
replaced promptw
-rw-r--r--Makefile2
-rw-r--r--dmenu.c7
2 files changed, 6 insertions, 3 deletions
diff --git a/Makefile b/Makefile
index 7b21a25..1082697 100644
--- a/Makefile
+++ b/Makefile
@@ -26,7 +26,7 @@ clean:
26dist: clean 26dist: clean
27 @echo creating dist tarball 27 @echo creating dist tarball
28 @mkdir -p dmenu-${VERSION} 28 @mkdir -p dmenu-${VERSION}
29 @cp -R LICENSE Makefile README config.mk dmenu.1 dmenu.c dmenu_path dmenu_run dmenu-${VERSION} 29 @cp LICENSE Makefile README config.mk dmenu.1 dmenu.c dmenu_path dmenu_run dmenu-${VERSION}
30 @tar -cf dmenu-${VERSION}.tar dmenu-${VERSION} 30 @tar -cf dmenu-${VERSION}.tar dmenu-${VERSION}
31 @gzip dmenu-${VERSION}.tar 31 @gzip dmenu-${VERSION}.tar
32 @rm -rf dmenu-${VERSION} 32 @rm -rf dmenu-${VERSION}
diff --git a/dmenu.c b/dmenu.c
index 7dfc2d3..608023d 100644
--- a/dmenu.c
+++ b/dmenu.c
@@ -42,6 +42,7 @@ static void setup(void);
42static void usage(void); 42static void usage(void);
43 43
44static char text[4096]; 44static char text[4096];
45static int promptw;
45static size_t cursor = 0; 46static size_t cursor = 0;
46static const char *prompt = NULL; 47static const char *prompt = NULL;
47static const char *normbgcolor = "#cccccc"; 48static const char *normbgcolor = "#cccccc";
@@ -79,7 +80,7 @@ void
79calcoffsetsh(void) { 80calcoffsetsh(void) {
80 unsigned int w, x; 81 unsigned int w, x;
81 82
82 w = (prompt ? textw(dc, prompt) : 0) + inputw + textw(dc, "<") + textw(dc, ">"); 83 w = promptw + inputw + textw(dc, "<") + textw(dc, ">");
83 for(x = w, next = curr; next; next = next->right) 84 for(x = w, next = curr; next; next = next->right)
84 if((x += MIN(textw(dc, next->text), mw / 3)) > mw) 85 if((x += MIN(textw(dc, next->text), mw / 3)) > mw)
85 break; 86 break;
@@ -118,7 +119,7 @@ drawmenu(void) {
118 dc->y = topbar ? 0 : mh - dc->h; 119 dc->y = topbar ? 0 : mh - dc->h;
119 /* print prompt? */ 120 /* print prompt? */
120 if(prompt) { 121 if(prompt) {
121 dc->w = textw(dc, prompt); 122 dc->w = promptw;
122 drawtext(dc, prompt, selcol); 123 drawtext(dc, prompt, selcol);
123 dc->x = dc->w; 124 dc->x = dc->w;
124 } 125 }
@@ -506,7 +507,9 @@ setup(void) {
506 grabkeyboard(); 507 grabkeyboard();
507 setcanvas(dc, win, mw, mh); 508 setcanvas(dc, win, mw, mh);
508 inputw = MIN(inputw, mw/3); 509 inputw = MIN(inputw, mw/3);
510 promptw = prompt ? MIN(textw(dc, prompt), mw/5) : 0;
509 XMapRaised(dc->dpy, win); 511 XMapRaised(dc->dpy, win);
512 text[0] = '\0';
510 match(); 513 match();
511} 514}
512 515