aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoreug-vs <eug-vs@keemail.me>2021-03-28 16:52:40 +0300
committereug-vs <eug-vs@keemail.me>2021-03-28 16:52:40 +0300
commitb8eea543af9a3591fb1aaf5dd50cb5dd0ae6864d (patch)
treed9da5a3d8aef7ed67f34def6d89f458a1567cf04
parentf0f6ed867683e78fd4340a1f80a3ae7f18e96f0c (diff)
downloaddmenu-b8eea543af9a3591fb1aaf5dd50cb5dd0ae6864d.tar.gz
feat: add line-height patch
-rw-r--r--Makefile2
-rw-r--r--config.def.h3
-rw-r--r--dmenu.15
-rw-r--r--dmenu.c11
4 files changed, 17 insertions, 4 deletions
diff --git a/Makefile b/Makefile
index a03a95c..fe864c3 100644
--- a/Makefile
+++ b/Makefile
@@ -29,7 +29,7 @@ stest: stest.o
$(CC) -o $@ stest.o $(LDFLAGS)
clean:
- rm -f dmenu stest $(OBJ) dmenu-$(VERSION).tar.gz
+ rm -f dmenu stest $(OBJ) dmenu-$(VERSION).tar.gz config.h
dist: clean
mkdir -p dmenu-$(VERSION)
diff --git a/config.def.h b/config.def.h
index 1edb647..1f41f42 100644
--- a/config.def.h
+++ b/config.def.h
@@ -15,6 +15,9 @@ static const char *colors[SchemeLast][2] = {
};
/* -l option; if nonzero, dmenu uses vertical list with given number of lines */
static unsigned int lines = 0;
+/* -h option; minimum height of a menu line */
+static unsigned int lineheight = 32;
+static unsigned int min_lineheight = 8;
/*
* Characters not considered part of a word while deleting words
diff --git a/dmenu.1 b/dmenu.1
index 323f93c..f2a82b4 100644
--- a/dmenu.1
+++ b/dmenu.1
@@ -6,6 +6,8 @@ dmenu \- dynamic menu
.RB [ \-bfiv ]
.RB [ \-l
.IR lines ]
+.RB [ \-h
+.IR height ]
.RB [ \-m
.IR monitor ]
.RB [ \-p
@@ -50,6 +52,9 @@ dmenu matches menu items case insensitively.
.BI \-l " lines"
dmenu lists items vertically, with the given number of lines.
.TP
+.BI \-h " 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 96b2581..b7f8843 100644
--- a/dmenu.c
+++ b/dmenu.c
@@ -136,7 +136,7 @@ drawmenu(void)
{
unsigned int curpos;
struct item *item;
- int x = 0, y = 0, w;
+ int x = 0, y = 0, fh = drw->fonts->h, w;
drw_setscheme(drw, scheme[SchemeNorm]);
drw_rect(drw, 0, 0, mw, mh, 1, 1);
@@ -153,7 +153,7 @@ drawmenu(void)
curpos = TEXTW(text) - TEXTW(&text[cursor]);
if ((curpos += lrpad / 2 - 1) < w) {
drw_setscheme(drw, scheme[SchemeNorm]);
- drw_rect(drw, x + curpos, 2, 2, bh - 4, 1, 0);
+ drw_rect(drw, x + curpos, 2 + (bh - fh) / 2, 2, fh - 4, 1, 0);
}
if (lines > 0) {
@@ -619,6 +619,7 @@ setup(void)
/* calculate menu geometry */
bh = drw->fonts->h + 2;
+ bh = MAX(bh,lineheight); /* make a menu line AT LEAST 'lineheight' tall */
lines = MAX(lines, 0);
mh = (lines + 1) * bh;
#ifdef XINERAMA
@@ -699,7 +700,7 @@ setup(void)
static void
usage(void)
{
- fputs("usage: dmenu [-bfiv] [-l lines] [-p prompt] [-fn font] [-m monitor]\n"
+ fputs("usage: dmenu [-bfiv] [-l lines] [-h height] [-p prompt] [-fn font] [-m monitor]\n"
" [-nb color] [-nf color] [-sb color] [-sf color] [-w windowid]\n", stderr);
exit(1);
}
@@ -762,6 +763,10 @@ main(int argc, char *argv[])
/* these options take one argument */
else if (!strcmp(argv[i], "-l")) /* number of lines in vertical list */
lines = atoi(argv[++i]);
+ else if (!strcmp(argv[i], "-h")) { /* minimum height of one menu line */
+ lineheight = atoi(argv[++i]);
+ lineheight = MAX(lineheight, min_lineheight);
+ }
else if (!strcmp(argv[i], "-m"))
mon = atoi(argv[++i]);
else if (!strcmp(argv[i], "-p")) /* adds prompt to left of input field */