summaryrefslogtreecommitdiff
path: root/patches
diff options
context:
space:
mode:
Diffstat (limited to 'patches')
-rw-r--r--patches/dmenu-border-4.9.diff25
-rw-r--r--patches/dmenu-highlight-4.9.diff93
-rw-r--r--patches/dmenu-lineheight-4.9.diff94
3 files changed, 212 insertions, 0 deletions
diff --git a/patches/dmenu-border-4.9.diff b/patches/dmenu-border-4.9.diff
new file mode 100644
index 0000000..89b4437
--- /dev/null
+++ b/patches/dmenu-border-4.9.diff
@@ -0,0 +1,25 @@
+diff -up dmenu-4.9-b/config.def.h dmenu-4.9-a/config.def.h
+--- dmenu-4.9-b/config.def.h 2019-02-02 13:55:02.000000000 +0100
++++ dmenu-4.9-a/config.def.h 2019-05-19 02:10:12.740040403 +0200
+@@ -21,3 +21,6 @@ static unsigned int lines = 0;
+ * for example: " /?\"&[]"
+ */
+ static const char worddelimiters[] = " ";
++
++/* Size of the window border */
++static const unsigned int border_width = 5;
+diff -up dmenu-4.9-b/dmenu.c dmenu-4.9-a/dmenu.c
+--- dmenu-4.9-b/dmenu.c 2019-02-02 13:55:02.000000000 +0100
++++ dmenu-4.9-a/dmenu.c 2019-05-19 02:11:20.966710117 +0200
+@@ -654,9 +654,10 @@ setup(void)
+ swa.override_redirect = True;
+ swa.background_pixel = scheme[SchemeNorm][ColBg].pixel;
+ swa.event_mask = ExposureMask | KeyPressMask | VisibilityChangeMask;
+- win = XCreateWindow(dpy, parentwin, x, y, mw, mh, 0,
++ win = XCreateWindow(dpy, parentwin, x, y, mw, mh, border_width,
+ CopyFromParent, CopyFromParent, CopyFromParent,
+ CWOverrideRedirect | CWBackPixel | CWEventMask, &swa);
++ XSetWindowBorder(dpy, win, scheme[SchemeSel][ColBg].pixel);
+ XSetClassHint(dpy, win, &ch);
+
+ /* open input methods */
diff --git a/patches/dmenu-highlight-4.9.diff b/patches/dmenu-highlight-4.9.diff
new file mode 100644
index 0000000..04897ea
--- /dev/null
+++ b/patches/dmenu-highlight-4.9.diff
@@ -0,0 +1,93 @@
+From 16abaf4bbea01234abab27fbfdfc921aad2fc364 Mon Sep 17 00:00:00 2001
+From: Miles Alan <m@milesalan.com>
+Date: Tue, 14 Jan 2020 21:50:04 -0600
+Subject: [PATCH] Highlight matched text in a different color scheme
+
+---
+ config.def.h | 2 ++
+ dmenu.c | 42 ++++++++++++++++++++++++++++++++++++++++--
+ 2 files changed, 42 insertions(+), 2 deletions(-)
+
+diff --git a/config.def.h b/config.def.h
+index 1edb647..64eab2a 100644
+--- a/config.def.h
++++ b/config.def.h
+@@ -11,6 +11,8 @@ static const char *colors[SchemeLast][2] = {
+ /* fg bg */
+ [SchemeNorm] = { "#bbbbbb", "#222222" },
+ [SchemeSel] = { "#eeeeee", "#005577" },
++ [SchemeSelHighlight] = { "#ffc978", "#005577" },
++ [SchemeNormHighlight] = { "#ffc978", "#222222" },
+ [SchemeOut] = { "#000000", "#00ffff" },
+ };
+ /* -l option; if nonzero, dmenu uses vertical list with given number of lines */
+diff --git a/dmenu.c b/dmenu.c
+index 6b8f51b..c82bb6d 100644
+--- a/dmenu.c
++++ b/dmenu.c
+@@ -26,7 +26,7 @@
+ #define TEXTW(X) (drw_fontset_getwidth(drw, (X)) + lrpad)
+
+ /* enums */
+-enum { SchemeNorm, SchemeSel, SchemeOut, SchemeLast }; /* color schemes */
++enum { SchemeNorm, SchemeSel, SchemeOut, SchemeNormHighlight, SchemeSelHighlight, SchemeLast }; /* color schemes */
+
+ struct item {
+ char *text;
+@@ -113,6 +113,42 @@ cistrstr(const char *s, const char *sub)
+ return NULL;
+ }
+
++static void
++drawhighlights(struct item *item, int x, int y, int maxw)
++{
++ char restorechar, tokens[sizeof text], *highlight, *token;
++ int indentx, highlightlen;
++
++ drw_setscheme(drw, scheme[item == sel ? SchemeSelHighlight : SchemeNormHighlight]);
++ strcpy(tokens, text);
++ for (token = strtok(tokens, " "); token; token = strtok(NULL, " ")) {
++ highlight = fstrstr(item->text, token);
++ while (highlight) {
++ // Move item str end, calc width for highlight indent, & restore
++ highlightlen = highlight - item->text;
++ restorechar = *highlight;
++ item->text[highlightlen] = '\0';
++ indentx = TEXTW(item->text);
++ item->text[highlightlen] = restorechar;
++
++ // Move highlight str end, draw highlight, & restore
++ restorechar = highlight[strlen(token)];
++ highlight[strlen(token)] = '\0';
++ drw_text(
++ drw,
++ x + indentx - (lrpad / 2) - 1,
++ y,
++ MIN(maxw - indentx, TEXTW(highlight) - lrpad),
++ bh, 0, highlight, 0
++ );
++ highlight[strlen(token)] = restorechar;
++
++ if (strlen(highlight) - strlen(token) < strlen(token)) break;
++ highlight = fstrstr(highlight + strlen(token), token);
++ }
++ }
++}
++
+ static int
+ drawitem(struct item *item, int x, int y, int w)
+ {
+@@ -123,7 +159,9 @@ drawitem(struct item *item, int x, int y, int w)
+ else
+ drw_setscheme(drw, scheme[SchemeNorm]);
+
+- return drw_text(drw, x, y, w, bh, lrpad / 2, item->text, 0);
++ int r = drw_text(drw, x, y, w, bh, lrpad / 2, item->text, 0);
++ drawhighlights(item, x, y, w);
++ return r;
+ }
+
+ static void
+--
+2.23.1
+
diff --git a/patches/dmenu-lineheight-4.9.diff b/patches/dmenu-lineheight-4.9.diff
new file mode 100644
index 0000000..d12c77a
--- /dev/null
+++ b/patches/dmenu-lineheight-4.9.diff
@@ -0,0 +1,94 @@
+From 87f92a561c31246f6f9effc0e89ef92677c87746 Mon Sep 17 00:00:00 2001
+From: astier <aleksandrs.stier@uni-bielefeld.de>
+Date: Wed, 27 Feb 2019 21:44:55 +0100
+Subject: [PATCH] Add an option which defines the lineheight
+
+Despite both the panel and dmenu using the same font (a Terminus 12),
+dmenu is shorter and the panel is visible from under the dmenu bar.
+The appearance can be even more distracting when using similar colors
+for background and selections. With the option added by this patch,
+dmenu can be launched with a '-h 24', thus completely covering the panel.
+---
+ config.def.h | 1 +
+ dmenu.1 | 3 +++
+ dmenu.c | 10 ++++++++--
+ 3 files changed, 12 insertions(+), 2 deletions(-)
+
+diff --git a/config.def.h b/config.def.h
+index 1edb647..317fa2f 100644
+--- a/config.def.h
++++ b/config.def.h
+@@ -15,6 +15,7 @@ static const char *colors[SchemeLast][2] = {
+ };
+ /* -l option; if nonzero, dmenu uses vertical list with given number of lines */
+ static unsigned int lines = 0;
++static unsigned int lineheight = 0; /* -h option; minimum height of a menu line */
+
+ /*
+ * Characters not considered part of a word while deleting words
+diff --git a/dmenu.1 b/dmenu.1
+index 323f93c..7ef34d2 100644
+--- a/dmenu.1
++++ b/dmenu.1
+@@ -50,6 +50,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 6b8f51b..45d1946 100644
+--- a/dmenu.c
++++ b/dmenu.c
+@@ -131,7 +131,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);
+@@ -148,7 +148,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) {
+@@ -604,6 +604,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
+@@ -683,6 +684,7 @@ static void
+ usage(void)
+ {
+ fputs("usage: dmenu [-bfiv] [-l lines] [-p prompt] [-fn font] [-m monitor]\n"
++ " [-h height]\n"
+ " [-nb color] [-nf color] [-sb color] [-sf color] [-w windowid]\n", stderr);
+ exit(1);
+ }
+@@ -716,6 +718,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], "-h")) { /* 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 */
+ colors[SchemeNorm][ColBg] = argv[++i];
+ else if (!strcmp(argv[i], "-nf")) /* normal foreground color */
+--
+2.21.0
+