Return to repo list

suckless-gf-dmenu

Gentoo-friendly patches for Suckless's dmenu.
Return to HMagellan.com

lineheight.patch (2144B)


      1 diff --git a/dmenu.1 b/dmenu.1
      2 index 323f93c..7ef34d2 100644
      3 --- a/dmenu.1
      4 +++ b/dmenu.1
      5 @@ -50,6 +50,9 @@ dmenu matches menu items case insensitively.
      6  .BI \-l " lines"
      7  dmenu lists items vertically, with the given number of lines.
      8  .TP
      9 +.BI \-h " height"
     10 +dmenu uses a menu line of at least 'height' pixels tall, but no less than 8.
     11 +.TP
     12  .BI \-m " monitor"
     13  dmenu is displayed on the monitor number supplied. Monitor numbers are starting
     14  from 0.
     15 diff --git a/dmenu.c b/dmenu.c
     16 index 6b8f51b..45d1946 100644
     17 --- a/dmenu.c
     18 +++ b/dmenu.c
     19 @@ -131,7 +131,7 @@ drawmenu(void)
     20  {
     21  	unsigned int curpos;
     22  	struct item *item;
     23 -	int x = 0, y = 0, w;
     24 +	int x = 0, y = 0, fh = drw->fonts->h, w;
     25  
     26  	drw_setscheme(drw, scheme[SchemeNorm]);
     27  	drw_rect(drw, 0, 0, mw, mh, 1, 1);
     28 @@ -148,7 +148,7 @@ drawmenu(void)
     29  	curpos = TEXTW(text) - TEXTW(&text[cursor]);
     30  	if ((curpos += lrpad / 2 - 1) < w) {
     31  		drw_setscheme(drw, scheme[SchemeNorm]);
     32 -		drw_rect(drw, x + curpos, 2, 2, bh - 4, 1, 0);
     33 +		drw_rect(drw, x + curpos, 2 + (bh-fh)/2, 2, fh - 4, 1, 0);
     34  	}
     35  
     36  	if (lines > 0) {
     37 @@ -604,6 +604,7 @@ setup(void)
     38  
     39  	/* calculate menu geometry */
     40  	bh = drw->fonts->h + 2;
     41 +	bh = MAX(bh,lineheight);	/* make a menu line AT LEAST 'lineheight' tall */
     42  	lines = MAX(lines, 0);
     43  	mh = (lines + 1) * bh;
     44  #ifdef XINERAMA
     45 @@ -683,6 +684,7 @@ static void
     46  usage(void)
     47  {
     48  	fputs("usage: dmenu [-bfiv] [-l lines] [-p prompt] [-fn font] [-m monitor]\n"
     49 +	      "             [-h height]\n"
     50  	      "             [-nb color] [-nf color] [-sb color] [-sf color] [-w windowid]\n", stderr);
     51  	exit(1);
     52  }
     53 @@ -716,6 +718,10 @@ main(int argc, char *argv[])
     54  			prompt = argv[++i];
     55  		else if (!strcmp(argv[i], "-fn"))  /* font or font set */
     56  			fonts[0] = argv[++i];
     57 +		else if(!strcmp(argv[i], "-h")) { /* minimum height of one menu line */
     58 +			lineheight = atoi(argv[++i]);
     59 +			lineheight = MAX(lineheight,8); /* reasonable default in case of value too small/negative */
     60 +		}
     61  		else if (!strcmp(argv[i], "-nb"))  /* normal background color */
     62  			colors[SchemeNorm][ColBg] = argv[++i];
     63  		else if (!strcmp(argv[i], "-nf"))  /* normal foreground color */
     64 -- 
     65 2.21.0
     66