--- config.def.h | 3 +++ dmenu.1 | 3 +++ dmenu.c | 15 ++++++++++----- drw.c | 2 +- 4 files changed, 17 insertions(+), 6 deletions(-) diff --git a/config.def.h b/config.def.h index a9122f7..6d936b7 100644 --- a/config.def.h +++ b/config.def.h _AT_@ -15,3 +15,6 @@ static const char *outbgcolor = "#00ffff"; static const char *outfgcolor = "#000000"; /* -l option; if nonzero, dmenu uses vertical list with given number of lines */ static unsigned int lines = 0; + +static unsigned int lineheight = 0; /* -lh option; minimum height of a menu line */ + diff --git a/dmenu.1 b/dmenu.1 index d3ab805..9fe4434 100644 --- a/dmenu.1 +++ b/dmenu.1 _AT_@ -51,6 +51,9 @@ dmenu matches menu items case insensitively. .BI \-l " lines" dmenu lists items vertically, with the given number of lines. .TP +.BI \-lh " height" +dmenu uses a menu line of at least 'height' pixels tall, but no less than 8. +.TP .BI \-m " monitor" dmenu is displayed on the monitor number supplied. Monitor numbers are starting from 0. diff --git a/dmenu.c b/dmenu.c index a07f8e3..25832a7 100644 --- a/dmenu.c +++ b/dmenu.c _AT_@ -119,7 +119,7 @@ drawmenu(void) { int curpos; struct item *item; - int x = 0, y = 0, h = bh, w; + int x = 0, y = 0, fh = drw->fonts[0]->h, w; drw_setscheme(drw, &scheme[SchemeNorm]); drw_rect(drw, 0, 0, mw, mh, 1, 1, 1); _AT_@ -134,16 +134,16 @@ drawmenu(void) drw_setscheme(drw, &scheme[SchemeNorm]); drw_text(drw, x, 0, w, bh, text, 0); - if ((curpos = TEXTNW(text, cursor) + bh / 2 - 2) < w) { + if ((curpos = TEXTNW(text, cursor) + fh / 2 - 2) < w) { drw_setscheme(drw, &scheme[SchemeNorm]); - drw_rect(drw, x + curpos + 2, 2, 1, bh - 4, 1, 1, 0); + drw_rect(drw, x + curpos + 2, 2 + (bh-fh)/2, 1, fh - 4, 1, 1, 0); } if (lines > 0) { /* draw vertical list */ w = mw - x; for (item = curr; item != next; item = item->right) { - y += h; + y += bh; if (item == sel) drw_setscheme(drw, &scheme[SchemeSel]); else if (item->out) _AT_@ -544,6 +544,7 @@ setup(void) /* calculate menu geometry */ bh = drw->fonts[0]->h + 2; + bh = MAX(bh,lineheight); /* make a menu line AT LEAST 'lineheight' tall */ lines = MAX(lines, 0); mh = (lines + 1) * bh; #ifdef XINERAMA _AT_@ -608,7 +609,7 @@ setup(void) static void usage(void) { - fputs("usage: dmenu [-b] [-f] [-i] [-l lines] [-p prompt] [-fn font] [-m monitor]\n" + fputs("usage: dmenu [-b] [-f] [-i] [-l lines] [-p prompt] [-fn font] [-lh height] [-m monitor]\n" " [-nb color] [-nf color] [-sb color] [-sf color] [-v]\n", stderr); exit(1); } _AT_@ -641,6 +642,10 @@ main(int argc, char *argv[]) prompt = argv[++i]; else if (!strcmp(argv[i], "-fn")) /* font or font set */ fonts[0] = argv[++i]; + else if(!strcmp(argv[i], "-lh")) { /* minimum height of one menu line */ + lineheight = atoi(argv[++i]); + lineheight = MAX(lineheight,8); /* reasonable default in case of value too small/negative */ + } else if (!strcmp(argv[i], "-nb")) /* normal background color */ normbgcolor = argv[++i]; else if (!strcmp(argv[i], "-nf")) /* normal foreground color */ diff --git a/drw.c b/drw.c index 80e3c39..f4a741f 100644 --- a/drw.c +++ b/drw.c _AT_@ -291,7 +291,7 @@ drw_text(Drw *drw, int x, int y, unsigned int w, unsigned int h, const char *tex if (render) { th = curfont->ascent + curfont->descent; ty = y + (h / 2) - (th / 2) + curfont->ascent; - tx = x + (h / 2); + tx = x + (drw->fonts[0]->h / 2); XftDrawStringUtf8(d, invert ? &drw->scheme->bg->rgb : &drw->scheme->fg->rgb, curfont->xfont, tx, ty, (XftChar8 *)buf, len); } x += tex.w; -- 2.6.2Received on Thu Nov 12 2015 - 13:04:55 CET
This archive was generated by hypermail 2.3.0 : Thu Nov 12 2015 - 13:12:10 CET