diff options
author | Connor Lane Smith <cls@lubutu.com> | 2010-08-02 14:49:14 +0100 |
---|---|---|
committer | Connor Lane Smith <cls@lubutu.com> | 2010-08-02 14:49:14 +0100 |
commit | 06c18808b6f23bc5120533559e70fbcbff753e84 (patch) | |
tree | c5ee6eb7c44053a4a887be02308cd13329012d63 | |
parent | a7aee433ccfd2590e0785a7b93a89d8d0593a234 (diff) |
replaced promptw
-rw-r--r-- | Makefile | 2 | ||||
-rw-r--r-- | dmenu.c | 7 |
2 files changed, 6 insertions, 3 deletions
@@ -26,7 +26,7 @@ clean: | |||
26 | dist: clean | 26 | dist: 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} |
@@ -42,6 +42,7 @@ static void setup(void); | |||
42 | static void usage(void); | 42 | static void usage(void); |
43 | 43 | ||
44 | static char text[4096]; | 44 | static char text[4096]; |
45 | static int promptw; | ||
45 | static size_t cursor = 0; | 46 | static size_t cursor = 0; |
46 | static const char *prompt = NULL; | 47 | static const char *prompt = NULL; |
47 | static const char *normbgcolor = "#cccccc"; | 48 | static const char *normbgcolor = "#cccccc"; |
@@ -79,7 +80,7 @@ void | |||
79 | calcoffsetsh(void) { | 80 | calcoffsetsh(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 | ||