diff options
| -rw-r--r-- | dmenu.c | 50 |
1 files changed, 25 insertions, 25 deletions
| @@ -80,13 +80,13 @@ calcoffsets(void) { | |||
| 80 | if(lines > 0) | 80 | if(lines > 0) |
| 81 | n = lines * bh; | 81 | n = lines * bh; |
| 82 | else | 82 | else |
| 83 | n = mw - (promptw + inputw + textw(dc, "<") + textw(dc, ">")); | 83 | n = mw - (promptw + inputw + dc_textw(dc, "<") + dc_textw(dc, ">")); |
| 84 | 84 | ||
| 85 | for(i = 0, next = curr; next; next = next->right) | 85 | for(i = 0, next = curr; next; next = next->right) |
| 86 | if((i += (lines > 0) ? bh : MIN(textw(dc, next->text), mw/3)) > n) | 86 | if((i += (lines > 0) ? bh : MIN(dc_textw(dc, next->text), mw/3)) > n) |
| 87 | break; | 87 | break; |
| 88 | for(i = 0, prev = curr; prev && prev->left; prev = prev->left) | 88 | for(i = 0, prev = curr; prev && prev->left; prev = prev->left) |
| 89 | if((i += (lines > 0) ? bh : MIN(textw(dc, prev->left->text), mw/3)) > n) | 89 | if((i += (lines > 0) ? bh : MIN(dc_textw(dc, prev->left->text), mw/3)) > n) |
| 90 | break; | 90 | break; |
| 91 | } | 91 | } |
| 92 | 92 | ||
| @@ -98,41 +98,41 @@ drawmenu(void) { | |||
| 98 | dc->x = 0; | 98 | dc->x = 0; |
| 99 | dc->y = 0; | 99 | dc->y = 0; |
| 100 | dc->h = bh; | 100 | dc->h = bh; |
| 101 | drawrect(dc, 0, 0, mw, mh, True, BG(dc, normcol)); | 101 | dc_drawrect(dc, 0, 0, mw, mh, True, BG(dc, normcol)); |
| 102 | 102 | ||
| 103 | if(prompt) { | 103 | if(prompt) { |
| 104 | dc->w = promptw; | 104 | dc->w = promptw; |
| 105 | drawtext(dc, prompt, selcol); | 105 | dc_drawtext(dc, prompt, selcol); |
| 106 | dc->x = dc->w; | 106 | dc->x = dc->w; |
| 107 | } | 107 | } |
| 108 | dc->w = (lines > 0 || !matches) ? mw - dc->x : inputw; | 108 | dc->w = (lines > 0 || !matches) ? mw - dc->x : inputw; |
| 109 | drawtext(dc, text, normcol); | 109 | dc_drawtext(dc, text, normcol); |
| 110 | if((curpos = textnw(dc, text, cursor) + dc->h/2 - 2) < dc->w) | 110 | if((curpos = dc_textnw(dc, text, cursor) + dc->h/2 - 2) < dc->w) |
| 111 | drawrect(dc, curpos, 2, 1, dc->h - 4, True, FG(dc, normcol)); | 111 | dc_drawrect(dc, curpos, 2, 1, dc->h - 4, True, FG(dc, normcol)); |
| 112 | 112 | ||
| 113 | if(lines > 0) { | 113 | if(lines > 0) { |
| 114 | dc->w = mw - dc->x; | 114 | dc->w = mw - dc->x; |
| 115 | for(item = curr; item != next; item = item->right) { | 115 | for(item = curr; item != next; item = item->right) { |
| 116 | dc->y += dc->h; | 116 | dc->y += dc->h; |
| 117 | drawtext(dc, item->text, (item == sel) ? selcol : normcol); | 117 | dc_drawtext(dc, item->text, (item == sel) ? selcol : normcol); |
| 118 | } | 118 | } |
| 119 | } | 119 | } |
| 120 | else if(matches) { | 120 | else if(matches) { |
| 121 | dc->x += inputw; | 121 | dc->x += inputw; |
| 122 | dc->w = textw(dc, "<"); | 122 | dc->w = dc_textw(dc, "<"); |
| 123 | if(curr->left) | 123 | if(curr->left) |
| 124 | drawtext(dc, "<", normcol); | 124 | dc_drawtext(dc, "<", normcol); |
| 125 | for(item = curr; item != next; item = item->right) { | 125 | for(item = curr; item != next; item = item->right) { |
| 126 | dc->x += dc->w; | 126 | dc->x += dc->w; |
| 127 | dc->w = MIN(textw(dc, item->text), mw/3); | 127 | dc->w = MIN(dc_textw(dc, item->text), mw/3); |
| 128 | drawtext(dc, item->text, (item == sel) ? selcol : normcol); | 128 | dc_drawtext(dc, item->text, (item == sel) ? selcol : normcol); |
| 129 | } | 129 | } |
| 130 | dc->w = textw(dc, ">"); | 130 | dc->w = dc_textw(dc, ">"); |
| 131 | dc->x = mw - dc->w; | 131 | dc->x = mw - dc->w; |
| 132 | if(next) | 132 | if(next) |
| 133 | drawtext(dc, ">", normcol); | 133 | dc_drawtext(dc, ">", normcol); |
| 134 | } | 134 | } |
| 135 | mapdraw(dc, win, mw, mh); | 135 | dc_map(dc, win, mw, mh); |
| 136 | } | 136 | } |
| 137 | 137 | ||
| 138 | char * | 138 | char * |
| @@ -396,7 +396,7 @@ readstdin(void) { | |||
| 396 | if(!(item->text = strdup(buf))) | 396 | if(!(item->text = strdup(buf))) |
| 397 | eprintf("cannot strdup %u bytes\n", strlen(buf)+1); | 397 | eprintf("cannot strdup %u bytes\n", strlen(buf)+1); |
| 398 | item->next = item->left = item->right = NULL; | 398 | item->next = item->left = item->right = NULL; |
| 399 | inputw = MAX(inputw, textw(dc, item->text)); | 399 | inputw = MAX(inputw, dc_textw(dc, item->text)); |
| 400 | } | 400 | } |
| 401 | } | 401 | } |
| 402 | 402 | ||
| @@ -437,10 +437,10 @@ setup(void) { | |||
| 437 | root = RootWindow(dc->dpy, screen); | 437 | root = RootWindow(dc->dpy, screen); |
| 438 | utf8 = XInternAtom(dc->dpy, "UTF8_STRING", False); | 438 | utf8 = XInternAtom(dc->dpy, "UTF8_STRING", False); |
| 439 | 439 | ||
| 440 | normcol[ColBG] = getcolor(dc, normbgcolor); | 440 | normcol[ColBG] = dc_color(dc, normbgcolor); |
| 441 | normcol[ColFG] = getcolor(dc, normfgcolor); | 441 | normcol[ColFG] = dc_color(dc, normfgcolor); |
| 442 | selcol[ColBG] = getcolor(dc, selbgcolor); | 442 | selcol[ColBG] = dc_color(dc, selbgcolor); |
| 443 | selcol[ColFG] = getcolor(dc, selfgcolor); | 443 | selcol[ColFG] = dc_color(dc, selfgcolor); |
| 444 | 444 | ||
| 445 | /* menu geometry */ | 445 | /* menu geometry */ |
| 446 | bh = dc->font.height + 2; | 446 | bh = dc->font.height + 2; |
| @@ -478,9 +478,9 @@ setup(void) { | |||
| 478 | CWOverrideRedirect | CWBackPixmap | CWEventMask, &wa); | 478 | CWOverrideRedirect | CWBackPixmap | CWEventMask, &wa); |
| 479 | 479 | ||
| 480 | grabkeyboard(); | 480 | grabkeyboard(); |
| 481 | resizedraw(dc, mw, mh); | 481 | dc_resize(dc, mw, mh); |
| 482 | inputw = MIN(inputw, mw/3); | 482 | inputw = MIN(inputw, mw/3); |
| 483 | promptw = prompt ? MIN(textw(dc, prompt), mw/5) : 0; | 483 | promptw = prompt ? MIN(dc_textw(dc, prompt), mw/5) : 0; |
| 484 | XMapRaised(dc->dpy, win); | 484 | XMapRaised(dc->dpy, win); |
| 485 | text[0] = '\0'; | 485 | text[0] = '\0'; |
| 486 | match(); | 486 | match(); |
| @@ -528,8 +528,8 @@ main(int argc, char *argv[]) { | |||
| 528 | else | 528 | else |
| 529 | usage(); | 529 | usage(); |
| 530 | 530 | ||
| 531 | dc = initdraw(); | 531 | dc = dc_init(); |
| 532 | initfont(dc, font); | 532 | dc_font(dc, font); |
| 533 | readstdin(); | 533 | readstdin(); |
| 534 | setup(); | 534 | setup(); |
| 535 | run(); | 535 | run(); |
