- dc->w = mw - dc->x;
- /* print input area */
- if(matches && lines == 0 && textw(dc, text) <= inputw)
- dc->w = inputw;
- drawtext(dc, text, normcol);
- drawrect(dc, textnw(dc, text, cursor) + dc->h/2 - 2, 2, 1, dc->h - 4, FG(dc, 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);
- for(item = curr; item != next; item = item->right) {
- dc->x += dc->w;
- dc->w = MIN(textw(dc, item->text), mw / 3);
- drawtext(dc, item->text, (item == sel) ? selcol : normcol);
+ dc->w = (lines > 0 || !matches) ? mw - dc->x : inputw;
+ dc_drawtext(dc, text, normcol);
+ if((curpos = dc_textnw(dc, text, cursor) + dc->h/2 - 2) < dc->w)
+ dc_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;
+ dc_drawtext(dc, item->text, (item == sel) ? selcol : normcol);
+ }
+ }
+ else if(matches) {
+ dc->x += inputw;
+ dc->w = dc_textw(dc, "<");
+ if(curr->left)
+ dc_drawtext(dc, "<", normcol);
+ for(item = curr; item != next; item = item->right) {
+ dc->x += dc->w;
+ dc->w = MIN(dc_textw(dc, item->text), mw - dc->x - dc_textw(dc, ">"));
+ dc_drawtext(dc, item->text, (item == sel) ? selcol : normcol);
+ }
+ dc->w = dc_textw(dc, ">");
+ dc->x = mw - dc->w;
+ if(next)
+ dc_drawtext(dc, ">", normcol);