- dc.w = mw - dc.x;
- /* print input area */
- if(matches && lines == 0 && textw(&dc, text) <= inputw)
- dc.w = inputw;
- drawtext(&dc, text, normcol);
- drawline(&dc, textnw(&dc, text, cursor) + dc.h/2 - 2, 2, 1, dc.h-4, normcol);
- if(lines > 0)
- drawmenuv();
- else if(curr && (dc.w == inputw || curr->next))
- drawmenuh();
- commitdraw(&dc, win);
-}
-
-void
-drawmenuh(void) {
- Item *item;
-
- dc.x += inputw;
- dc.w = textw(&dc, "<");
- if(curr->left)
- drawtext(&dc, "<", normcol);
- dc.x += dc.w;
- for(item = curr; item != next; item = item->right) {
- dc.w = MIN(textw(&dc, item->text), mw / 3);
- if(item == sel)
- drawbox(&dc, selcol);
- drawtext(&dc, item->text, (item == sel) ? selcol : normcol);
- dc.x += dc.w;
+ dc->w = (lines > 0 || !matches) ? mw - dc->x : inputw;
+ drawtext(dc, text, normcol);
+ if((curpos = textnw(dc, text, cursor) + dc->h/2 - 2) < dc->w)
+ drawrect(dc, curpos, 2, 1, dc->h - 4, True, FG(dc, normcol));
+
+ if(lines > 0) {
+ dc->w = mw - dc->x;
+ for(item = curr; item != next; item = item->right) {
+ dc->y += dc->h;
+ drawtext(dc, item->text, (item == sel) ? selcol : normcol);
+ }