all repos — dotfiles @ 44c1b8b751c98f9b1f38d40439d30c68ae2805d8

my *nix dotfiles

dmenu/patches/lineheight.diff (view raw)

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