replaced promptw
This commit is contained in:
parent
a7aee433cc
commit
06c18808b6
2
Makefile
2
Makefile
|
@ -26,7 +26,7 @@ clean:
|
||||||
dist: clean
|
dist: clean
|
||||||
@echo creating dist tarball
|
@echo creating dist tarball
|
||||||
@mkdir -p dmenu-${VERSION}
|
@mkdir -p dmenu-${VERSION}
|
||||||
@cp -R LICENSE Makefile README config.mk dmenu.1 dmenu.c dmenu_path dmenu_run dmenu-${VERSION}
|
@cp LICENSE Makefile README config.mk dmenu.1 dmenu.c dmenu_path dmenu_run dmenu-${VERSION}
|
||||||
@tar -cf dmenu-${VERSION}.tar dmenu-${VERSION}
|
@tar -cf dmenu-${VERSION}.tar dmenu-${VERSION}
|
||||||
@gzip dmenu-${VERSION}.tar
|
@gzip dmenu-${VERSION}.tar
|
||||||
@rm -rf dmenu-${VERSION}
|
@rm -rf dmenu-${VERSION}
|
||||||
|
|
7
dmenu.c
7
dmenu.c
|
@ -42,6 +42,7 @@ static void setup(void);
|
||||||
static void usage(void);
|
static void usage(void);
|
||||||
|
|
||||||
static char text[4096];
|
static char text[4096];
|
||||||
|
static int promptw;
|
||||||
static size_t cursor = 0;
|
static size_t cursor = 0;
|
||||||
static const char *prompt = NULL;
|
static const char *prompt = NULL;
|
||||||
static const char *normbgcolor = "#cccccc";
|
static const char *normbgcolor = "#cccccc";
|
||||||
|
@ -79,7 +80,7 @@ void
|
||||||
calcoffsetsh(void) {
|
calcoffsetsh(void) {
|
||||||
unsigned int w, x;
|
unsigned int w, x;
|
||||||
|
|
||||||
w = (prompt ? textw(dc, prompt) : 0) + inputw + textw(dc, "<") + textw(dc, ">");
|
w = promptw + inputw + textw(dc, "<") + textw(dc, ">");
|
||||||
for(x = w, next = curr; next; next = next->right)
|
for(x = w, next = curr; next; next = next->right)
|
||||||
if((x += MIN(textw(dc, next->text), mw / 3)) > mw)
|
if((x += MIN(textw(dc, next->text), mw / 3)) > mw)
|
||||||
break;
|
break;
|
||||||
|
@ -118,7 +119,7 @@ drawmenu(void) {
|
||||||
dc->y = topbar ? 0 : mh - dc->h;
|
dc->y = topbar ? 0 : mh - dc->h;
|
||||||
/* print prompt? */
|
/* print prompt? */
|
||||||
if(prompt) {
|
if(prompt) {
|
||||||
dc->w = textw(dc, prompt);
|
dc->w = promptw;
|
||||||
drawtext(dc, prompt, selcol);
|
drawtext(dc, prompt, selcol);
|
||||||
dc->x = dc->w;
|
dc->x = dc->w;
|
||||||
}
|
}
|
||||||
|
@ -506,7 +507,9 @@ setup(void) {
|
||||||
grabkeyboard();
|
grabkeyboard();
|
||||||
setcanvas(dc, win, mw, mh);
|
setcanvas(dc, win, mw, mh);
|
||||||
inputw = MIN(inputw, mw/3);
|
inputw = MIN(inputw, mw/3);
|
||||||
|
promptw = prompt ? MIN(textw(dc, prompt), mw/5) : 0;
|
||||||
XMapRaised(dc->dpy, win);
|
XMapRaised(dc->dpy, win);
|
||||||
|
text[0] = '\0';
|
||||||
match();
|
match();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user