dmenu-lineheight-4.7.diff (2581B)
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 @@ -16,4 +16,5 @@ 6 /* -l option; if nonzero, dmenu uses vertical list with given number of lines */ 7 static unsigned int lines = 0; 8 +static unsigned int lineheight = 0; /* -h option; minimum height of a menu line */ 9 10 /* 11 diff --git a/dmenu.1 b/dmenu.1 12 index d3ab805..9fe4434 100644 13 --- a/dmenu.1 14 +++ b/dmenu.1 15 @@ -50,6 +50,9 @@ dmenu matches menu items case insensitively. 16 .BI \-l " lines" 17 dmenu lists items vertically, with the given number of lines. 18 .TP 19 +.BI \-h " height" 20 +dmenu uses a menu line of at least 'height' pixels tall, but no less than 8. 21 +.TP 22 .BI \-m " monitor" 23 dmenu is displayed on the monitor number supplied. Monitor numbers are starting 24 from 0. 25 diff --git a/dmenu.c b/dmenu.c 26 index a07f8e3..25832a7 100644 27 --- a/dmenu.c 28 +++ b/dmenu.c 29 @@ -130,7 +130,7 @@ drawmenu(void) 30 { 31 unsigned int curpos; 32 struct item *item; 33 - int x = 0, y = 0, w; 34 + int x = 0, y = 0, fh = drw->fonts->h, w; 35 36 drw_setscheme(drw, scheme[SchemeNorm]); 37 drw_rect(drw, 0, 0, mw, mh, 1, 1); 38 @@ -145,9 +145,9 @@ drawmenu(void) 39 drw_text(drw, x, 0, w, bh, lrpad / 2, text, 0); 40 41 drw_font_getexts(drw->fonts, text, cursor, &curpos, NULL); 42 if ((curpos += lrpad / 2 - 1) < w) { 43 drw_setscheme(drw, scheme[SchemeNorm]); 44 - drw_rect(drw, x + curpos, 2, 2, bh - 4, 1, 0); 45 + drw_rect(drw, x + curpos, 2 + (bh-fh)/2, 2, fh - 4, 1, 0); 46 } 47 48 if (lines > 0) { 49 @@ -676,7 +676,8 @@ setup(void) 50 utf8 = XInternAtom(dpy, "UTF8_STRING", False); 51 52 /* calculate menu geometry */ 53 bh = drw->fonts->h + 2; 54 + bh = MAX(bh,lineheight); /* make a menu line AT LEAST 'lineheight' tall */ 55 lines = MAX(lines, 0); 56 mh = (lines + 1) * bh; 57 #ifdef XINERAMA 58 @@ -754,6 +755,7 @@ setup(void) 59 usage(void) 60 { 61 fputs("usage: dmenu [-bfiv] [-l lines] [-p prompt] [-fn font] [-m monitor]\n" 62 + " [-h height]\n" 63 " [-nb color] [-nf color] [-sb color] [-sf color] [-w windowid]\n", stderr); 64 exit(1); 65 } 66 @@ -787,6 +789,10 @@ main(int argc, char *argv[]) 67 prompt = argv[++i]; 68 else if (!strcmp(argv[i], "-fn")) /* font or font set */ 69 fonts[0] = argv[++i]; 70 + else if(!strcmp(argv[i], "-h")) { /* minimum height of one menu line */ 71 + lineheight = atoi(argv[++i]); 72 + lineheight = MAX(lineheight,8); /* reasonable default in case of value too small/negative */ 73 + } 74 else if (!strcmp(argv[i], "-nb")) /* normal background color */ 75 normbgcolor = argv[++i]; 76 else if (!strcmp(argv[i], "-nf")) /* normal foreground color */