commit b01120a33612dcb7fb9383b1417b4266ad398dd6
parent 7b8f6cba18380f3bba0df578644fa4003b16855a
Author: Erik Letson <hmagellan@hmagellan.com>
Date: Fri, 21 Aug 2020 14:30:06 -0500
Added highlight (missed it going alphabetically, oops)
Diffstat:
2 files changed, 99 insertions(+), 0 deletions(-)
diff --git a/patches/highlight/USAGE b/patches/highlight/USAGE
@@ -0,0 +1,28 @@
+highlight - Highlight matching text in dmenu entries
+Source: https://tools.suckless.org/dmenu/patches/highlight/dmenu-highlight-4.9.diff
+Original Author: Miles Alan m@milesalan.com
+
+Description from source:
+ """
+ This patch highlights the individual characters of matched text for each dmenu list entry.
+ """
+
+== YOU MUST ==
+(1). Place the patch file in /etc/portage/patches/x11-misc/dmenu/
+(2). Add the following lines to the 'colors' array in your savedconfig file:
+
+ [SchemeSelHighlight] = { "#ffc978", "#005577" },
+ [SchemeNormHighlight] = { "#ffc978", "#222222" },
+
+ Set the scheme colors to whatever you want.
+(3). Run 'emerge dmenu'
+
+== YOU PROBABLY SHOULD ==
+No further action is required.
+
+== PATCH MODIFICATIONS ==
+(1). Removed lines relating to 'config.def.h'
+(2). Changed C++ style comments to C style
+
+== INCOMPATIBILITIES ==
+No known specific incompatibilities.
diff --git a/patches/highlight/highlight.patch b/patches/highlight/highlight.patch
@@ -0,0 +1,71 @@
+diff --git a/dmenu.c b/dmenu.c
+index 6b8f51b..d5e1991 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,43 @@ 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';
++ if (indentx - (lrpad / 2) - 1 < maxw)
++ 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 +160,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
+