| dmenu-lineheight-4.6.diff - sites - public wiki contents of suckless.org | |
| git clone git://git.suckless.org/sites | |
| Log | |
| Files | |
| Refs | |
| --- | |
| dmenu-lineheight-4.6.diff (3503B) | |
| --- | |
| 1 diff --git a/config.def.h b/config.def.h | |
| 2 index a9122f7..6d936b7 100644 | |
| 3 --- a/config.def.h | |
| 4 +++ b/config.def.h | |
| 5 @@ -15,3 +15,6 @@ static const char *outbgcolor = "#00ffff"; | |
| 6 static const char *outfgcolor = "#000000"; | |
| 7 /* -l option; if nonzero, dmenu uses vertical list with given number of… | |
| 8 static unsigned int lines = 0; | |
| 9 + | |
| 10 +static unsigned int lineheight = 0; /* -lh option; minimum heig… | |
| 11 + | |
| 12 diff --git a/dmenu.1 b/dmenu.1 | |
| 13 index d3ab805..9fe4434 100644 | |
| 14 --- a/dmenu.1 | |
| 15 +++ b/dmenu.1 | |
| 16 @@ -51,6 +51,9 @@ dmenu matches menu items case insensitively. | |
| 17 .BI \-l " lines" | |
| 18 dmenu lists items vertically, with the given number of lines. | |
| 19 .TP | |
| 20 +.BI \-lh " height" | |
| 21 +dmenu uses a menu line of at least 'height' pixels tall, but no less th… | |
| 22 +.TP | |
| 23 .BI \-m " monitor" | |
| 24 dmenu is displayed on the monitor number supplied. Monitor numbers are … | |
| 25 from 0. | |
| 26 diff --git a/dmenu.c b/dmenu.c | |
| 27 index a07f8e3..25832a7 100644 | |
| 28 --- a/dmenu.c | |
| 29 +++ b/dmenu.c | |
| 30 @@ -119,7 +119,7 @@ drawmenu(void) | |
| 31 { | |
| 32 int curpos; | |
| 33 struct item *item; | |
| 34 - int x = 0, y = 0, h = bh, w; | |
| 35 + int x = 0, y = 0, fh = drw->fonts[0]->h, w; | |
| 36 | |
| 37 drw_setscheme(drw, &scheme[SchemeNorm]); | |
| 38 drw_rect(drw, 0, 0, mw, mh, 1, 1, 1); | |
| 39 @@ -134,16 +134,16 @@ drawmenu(void) | |
| 40 drw_setscheme(drw, &scheme[SchemeNorm]); | |
| 41 drw_text(drw, x, 0, w, bh, text, 0); | |
| 42 | |
| 43 - if ((curpos = TEXTNW(text, cursor) + bh / 2 - 2) < w) { | |
| 44 + if ((curpos = TEXTNW(text, cursor) + fh / 2 - 2) < w) { | |
| 45 drw_setscheme(drw, &scheme[SchemeNorm]); | |
| 46 - drw_rect(drw, x + curpos + 2, 2, 1, bh - 4, 1, 1, 0); | |
| 47 + drw_rect(drw, x + curpos + 2, 2 + (bh-fh)/2, 1, fh - 4,… | |
| 48 } | |
| 49 | |
| 50 if (lines > 0) { | |
| 51 /* draw vertical list */ | |
| 52 w = mw - x; | |
| 53 for (item = curr; item != next; item = item->right) { | |
| 54 - y += h; | |
| 55 + y += bh; | |
| 56 if (item == sel) | |
| 57 drw_setscheme(drw, &scheme[SchemeSel]); | |
| 58 else if (item->out) | |
| 59 @@ -544,6 +544,7 @@ setup(void) | |
| 60 | |
| 61 /* calculate menu geometry */ | |
| 62 bh = drw->fonts[0]->h + 2; | |
| 63 + bh = MAX(bh,lineheight); /* make a menu line AT LEAST 'l… | |
| 64 lines = MAX(lines, 0); | |
| 65 mh = (lines + 1) * bh; | |
| 66 #ifdef XINERAMA | |
| 67 @@ -608,7 +609,7 @@ setup(void) | |
| 68 static void | |
| 69 usage(void) | |
| 70 { | |
| 71 - fputs("usage: dmenu [-b] [-f] [-i] [-l lines] [-p prompt] [-fn … | |
| 72 + fputs("usage: dmenu [-b] [-f] [-i] [-l lines] [-p prompt] [-fn … | |
| 73 " [-nb color] [-nf color] [-sb color] [-sf co… | |
| 74 exit(1); | |
| 75 } | |
| 76 @@ -641,6 +642,10 @@ main(int argc, char *argv[]) | |
| 77 prompt = argv[++i]; | |
| 78 else if (!strcmp(argv[i], "-fn")) /* font or font set … | |
| 79 fonts[0] = argv[++i]; | |
| 80 + else if(!strcmp(argv[i], "-lh")) { /* minimum height of… | |
| 81 + lineheight = atoi(argv[++i]); | |
| 82 + lineheight = MAX(lineheight,8); /* reasonable d… | |
| 83 + } | |
| 84 else if (!strcmp(argv[i], "-nb")) /* normal background… | |
| 85 normbgcolor = argv[++i]; | |
| 86 else if (!strcmp(argv[i], "-nf")) /* normal foreground… | |
| 87 diff --git a/drw.c b/drw.c | |
| 88 index 80e3c39..f4a741f 100644 | |
| 89 --- a/drw.c | |
| 90 +++ b/drw.c | |
| 91 @@ -291,7 +291,7 @@ drw_text(Drw *drw, int x, int y, unsigned int w, uns… | |
| 92 if (render) { | |
| 93 th = curfont->ascent + curfont-… | |
| 94 ty = y + (h / 2) - (th / 2) + c… | |
| 95 - tx = x + (h / 2); | |
| 96 + tx = x + (drw->fonts[0]->h / 2); | |
| 97 XftDrawStringUtf8(d, invert ? &… | |
| 98 } | |
| 99 x += tex.w; |