X-Git-Url: https://git.xinqibao.xyz/dmenu.git/blobdiff_plain/ee03052e73c344cac6840d379a792fb135dce371..dd902868dfbb32f3520abe30c640f06bedf4ca9b:/main.c?ds=sidebyside diff --git a/main.c b/main.c index f151819..14581c4 100644 --- a/main.c +++ b/main.c @@ -77,39 +77,38 @@ drawmenu() dc.y = 0; dc.w = mw; dc.h = mh; - drawtext(NULL, False, False); + drawtext(NULL, False); /* print command */ if(cmdw && item) dc.w = cmdw; - drawtext(text[0] ? text : NULL, False, False); + drawtext(text[0] ? text : NULL, False); dc.x += cmdw; if(curr) { dc.w = SPACE; - drawtext((curr && curr->left) ? "<" : NULL, False, False); + drawtext((curr && curr->left) ? "<" : NULL, False); dc.x += dc.w; /* determine maximum items */ for(i = curr; i != next; i=i->right) { - dc.border = False; dc.w = textw(i->text); if(dc.w > mw / 3) dc.w = mw / 3; - drawtext(i->text, sel == i, sel == i); + drawtext(i->text, sel == i); dc.x += dc.w; } dc.x = mw - SPACE; dc.w = SPACE; - drawtext(next ? ">" : NULL, False, False); + drawtext(next ? ">" : NULL, False); } XCopyArea(dpy, dc.drawable, win, dc.gc, 0, 0, mw, mh, 0, 0); XFlush(dpy); } static void -input(char *pattern) +match(char *pattern) { unsigned int plen; Item *i, *j; @@ -173,18 +172,16 @@ kpress(XKeyEvent * e) return; break; case XK_h: + case XK_H: ksym = XK_BackSpace; break; - case XK_U: case XK_u: + case XK_U: text[0] = 0; - input(text); + match(text); drawmenu(); return; break; - case XK_bracketleft: - ksym = XK_Escape; - break; } } switch(ksym) { @@ -201,7 +198,7 @@ kpress(XKeyEvent * e) if(!sel) return; strncpy(text, sel->text, sizeof(text)); - input(text); + match(text); break; case XK_Right: if(!(sel && sel->right)) @@ -233,9 +230,9 @@ kpress(XKeyEvent * e) prev_nitem = nitem; do { text[--i] = 0; - input(text); + match(text); } while(i && nitem && prev_nitem == nitem); - input(text); + match(text); } break; default: @@ -245,14 +242,14 @@ kpress(XKeyEvent * e) strncat(text, buf, sizeof(text)); else strncpy(text, buf, sizeof(text)); - input(text); + match(text); } } drawmenu(); } static char * -readinput() +readstdin() { static char *maxname = NULL; char *p, buf[1024]; @@ -309,7 +306,7 @@ main(int argc, char *argv[]) screen = DefaultScreen(dpy); root = RootWindow(dpy, screen); - maxname = readinput(); + maxname = readstdin(); /* grab as early as possible, but after reading all items!!! */ while(XGrabKeyboard(dpy, root, True, GrabModeAsync, @@ -319,7 +316,6 @@ main(int argc, char *argv[]) /* style */ dc.bg = getcolor(BGCOLOR); dc.fg = getcolor(FGCOLOR); - dc.border = getcolor(BORDERCOLOR); setfont(FONT); wa.override_redirect = 1; @@ -346,7 +342,7 @@ main(int argc, char *argv[]) cmdw = mw / 3; text[0] = 0; - input(text); + match(text); XMapRaised(dpy, win); drawmenu(); XSync(dpy, False);