X-Git-Url: https://git.danieliu.xyz/?a=blobdiff_plain;f=dmenu.c;h=076cffef4b082a093859876996fb5adce398d04c;hb=115c01b74ebd57382679bec5c6e1ff5604370cbf;hp=b460701ae963cbfd7cbce3d16025df4303d22cca;hpb=da7a79912124743e7fbbef81c2450aeaf4ccca87;p=dmenu.git diff --git a/dmenu.c b/dmenu.c index b460701..076cffe 100644 --- a/dmenu.c +++ b/dmenu.c @@ -24,6 +24,7 @@ static void calcoffsetsv(void); static char *cistrstr(const char *s, const char *sub); static void cleanup(void); static void dinput(void); +static void drawitem(const char *s, unsigned long col[ColLast]); static void drawmenuh(void); static void drawmenuv(void); static void match(void); @@ -139,6 +140,7 @@ drawbar(void) { /* print prompt? */ if(prompt) { dc.w = promptw; + drawbox(&dc, selcol); drawtext(&dc, prompt, selcol); dc.x += dc.w; } @@ -154,9 +156,14 @@ drawbar(void) { commitdraw(&dc, win); } +void +drawitem(const char *s, unsigned long col[ColLast]) { + drawbox(&dc, col); + drawtext(&dc, s, col); +} + void drawmenuh(void) { - unsigned long *col; Item *i; dc.x += cmdw; @@ -165,9 +172,7 @@ drawmenuh(void) { dc.x += dc.w; for(i = curr; i != next; i = i->right) { dc.w = MIN(textw(&dc, i->text), mw / 3); - col = (sel == i) ? selcol : normcol; - drawbox(&dc, col); - drawtext(&dc, i->text, col); + drawitem(i->text, (sel == i) ? selcol : normcol); dc.x += dc.w; } dc.w = textw(&dc, ">"); @@ -183,7 +188,7 @@ drawmenuv(void) { dc.y = topbar ? dc.h : 0; dc.w = mw - dc.x; for(i = curr; i != next; i = i->right) { - drawtext(&dc, i->text, (sel == i) ? selcol : normcol); + drawitem(i->text, (sel == i) ? selcol : normcol); dc.y += dc.h; } if(!XGetWindowAttributes(dpy, win, &wa))