Instantly share code, notes, and snippets.
Created
February 6, 2012 22:28
-
Star
(1)
1
You must be signed in to star a gist -
Fork
(1)
1
You must be signed in to fork a gist
-
Save runiq/1755434 to your computer and use it in GitHub Desktop.
dmenu 4.5 height patch (use -h <pixels>) -- normal and Xft versions
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff -aur a/dmenu.1 b/dmenu.1 | |
--- a/dmenu.1 2012-01-08 13:18:43.000000000 +0100 | |
+++ b/dmenu.1 2012-02-07 12:14:30.420865167 +0100 | |
@@ -8,6 +8,8 @@ | |
.RB [ \-i ] | |
.RB [ \-l | |
.IR lines ] | |
+.RB [ \-h | |
+.IR height ] | |
.RB [ \-p | |
.IR prompt ] | |
.RB [ \-fn | |
@@ -49,6 +51,9 @@ | |
.BI \-l " lines" | |
dmenu lists items vertically, with the given number of lines. | |
.TP | |
+.BI \-h " height" | |
+defines the height of the bar in pixels. | |
+.TP | |
.BI \-p " prompt" | |
defines the prompt to be displayed to the left of the input field. | |
.TP | |
diff -aur a/dmenu.c b/dmenu.c | |
--- a/dmenu.c 2012-01-08 13:18:43.000000000 +0100 | |
+++ b/dmenu.c 2012-02-07 12:12:28.353854342 +0100 | |
@@ -49,7 +49,7 @@ | |
static const char *normfgcolor = "#bbbbbb"; | |
static const char *selbgcolor = "#005577"; | |
static const char *selfgcolor = "#eeeeee"; | |
-static unsigned int lines = 0; | |
+static unsigned int lines, line_height = 0; | |
static unsigned long normcol[ColLast]; | |
static unsigned long selcol[ColLast]; | |
static Atom clip, utf8; | |
@@ -88,6 +88,8 @@ | |
/* 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 single line */ | |
+ line_height = atoi(argv[++i]); | |
else if(!strcmp(argv[i], "-p")) /* adds prompt to left of input field */ | |
prompt = argv[++i]; | |
else if(!strcmp(argv[i], "-fn")) /* font or font set */ | |
@@ -177,8 +179,8 @@ | |
/* draw input field */ | |
dc->w = (lines > 0 || !matches) ? mw - dc->x : inputw; | |
drawtext(dc, text, normcol); | |
- if((curpos = textnw(dc, text, cursor) + dc->h/2 - 2) < dc->w) | |
- drawrect(dc, curpos, 2, 1, dc->h - 4, True, FG(dc, normcol)); | |
+ if((curpos = textnw(dc, text, cursor) + dc->font.height/2) < dc->w) | |
+ drawrect(dc, curpos, (dc->h - dc->font.height)/2 + 1, 1, dc->font.height - 1, True, FG(dc, normcol)); | |
if(lines > 0) { | |
/* draw vertical list */ | |
@@ -533,7 +535,7 @@ | |
utf8 = XInternAtom(dc->dpy, "UTF8_STRING", False); | |
/* calculate menu geometry */ | |
- bh = dc->font.height + 2; | |
+ bh = (line_height > dc->font.height + 2) ? line_height : dc->font.height + 2; | |
lines = MAX(lines, 0); | |
mh = (lines + 1) * bh; | |
#ifdef XINERAMA | |
@@ -601,7 +603,7 @@ | |
void | |
usage(void) { | |
- fputs("usage: dmenu [-b] [-f] [-i] [-l lines] [-p prompt] [-fn font]\n" | |
+ fputs("usage: dmenu [-b] [-f] [-i] [-l lines] [-h height] [-p prompt] [-fn font]\n" | |
" [-nb color] [-nf color] [-sb color] [-sf color] [-v]\n", stderr); | |
exit(EXIT_FAILURE); | |
} | |
diff -aur a/draw.c b/draw.c | |
--- a/draw.c 2012-01-08 13:18:43.000000000 +0100 | |
+++ b/draw.c 2012-02-07 12:12:28.357187594 +0100 | |
@@ -42,7 +42,7 @@ | |
void | |
drawtextn(DC *dc, const char *text, size_t n, unsigned long col[ColLast]) { | |
int x = dc->x + dc->font.height/2; | |
- int y = dc->y + dc->font.ascent+1; | |
+ int y = dc->y + dc->font.ascent + (dc->h - dc->font.height)/2; | |
XSetForeground(dc->dpy, dc->gc, FG(dc, col)); | |
if(dc->font.set) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff -aur a/dmenu.1 b/dmenu.1 | |
--- a/dmenu.1 2012-02-07 12:25:31.528055083 +0100 | |
+++ b/dmenu.1 2012-02-07 12:24:27.999603205 +0100 | |
@@ -8,6 +8,8 @@ | |
.RB [ \-i ] | |
.RB [ \-l | |
.IR lines ] | |
+.RB [ \-h | |
+.IR height ] | |
.RB [ \-p | |
.IR prompt ] | |
.RB [ \-fn | |
@@ -49,6 +51,9 @@ | |
.BI \-l " lines" | |
dmenu lists items vertically, with the given number of lines. | |
.TP | |
+.BI \-h " height" | |
+defines the height of the bar in pixels. | |
+.TP | |
.BI \-p " prompt" | |
defines the prompt to be displayed to the left of the input field. | |
.TP | |
diff -aur a/dmenu.c b/dmenu.c | |
--- a/dmenu.c 2012-02-07 12:25:31.528055083 +0100 | |
+++ b/dmenu.c 2012-02-07 12:23:05.058292037 +0100 | |
@@ -51,7 +51,7 @@ | |
static const char *normfgcolor = "#bbbbbb"; | |
static const char *selbgcolor = "#005577"; | |
static const char *selfgcolor = "#eeeeee"; | |
-static unsigned int lines = 0; | |
+static unsigned int lines, line_height = 0; | |
static ColorSet *normcol; | |
static ColorSet *selcol; | |
static Atom clip, utf8; | |
@@ -92,6 +92,8 @@ | |
/* 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 single line */ | |
+ line_height = atoi(argv[++i]); | |
else if(!strcmp(argv[i], "-p")) /* adds prompt to left of input field */ | |
prompt = argv[++i]; | |
else if(!strcmp(argv[i], "-fn")) /* font or font set */ | |
@@ -193,8 +195,8 @@ | |
/* draw input field */ | |
dc->w = (lines > 0 || !matches) ? mw - dc->x : inputw; | |
drawtext(dc, text, normcol); | |
- if((curpos = textnw(dc, text, cursor) + dc->h/2 - 2) < dc->w) | |
- drawrect(dc, curpos, 2, 1, dc->h - 4, True, normcol->FG); | |
+ if((curpos = textnw(dc, text, cursor) + dc->font.height/2) < dc->w) | |
+ drawrect(dc, curpos, (dc->h - dc->font.height)/2 + 1, 1, dc->font.height -1, True, normcol->FG); | |
if(lines > 0) { | |
/* draw vertical list */ | |
@@ -546,7 +548,7 @@ | |
utf8 = XInternAtom(dc->dpy, "UTF8_STRING", False); | |
/* calculate menu geometry */ | |
- bh = dc->font.height + 2; | |
+ bh = (line_height > dc->font.height + 2) ? line_height : dc->font.height + 2; | |
lines = MAX(lines, 0); | |
mh = (lines + 1) * bh; | |
#ifdef XINERAMA | |
@@ -614,7 +616,7 @@ | |
void | |
usage(void) { | |
- fputs("usage: dmenu [-b] [-f] [-i] [-l lines] [-p prompt] [-fn font]\n" | |
+ fputs("usage: dmenu [-b] [-f] [-i] [-l lines] [-h height] [-p prompt] [-fn font]\n" | |
" [-nb color] [-nf color] [-sb color] [-sf color] [-v]\n", stderr); | |
exit(EXIT_FAILURE); | |
} | |
diff -aur a/draw.c b/draw.c | |
--- a/draw.c 2012-02-07 12:25:31.528055083 +0100 | |
+++ b/draw.c 2012-02-07 12:23:05.058292037 +0100 | |
@@ -39,7 +39,7 @@ | |
void | |
drawtextn(DC *dc, const char *text, size_t n, ColorSet *col) { | |
int x = dc->x + dc->font.height/2; | |
- int y = dc->y + dc->font.ascent+1; | |
+ int y = dc->y + dc->font.ascent + (dc->h - dc->font.height)/2; | |
XSetForeground(dc->dpy, dc->gc, col->FG); | |
if(dc->font.xft_font) { |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment