[wiki] [sites] [dmenu][patch] fuzzyhighlight: new patch for fuzzy highlight || Chris Noxz
commit 953bf580174eba39f754febf72f654e4fe8e9279
Author: Chris Noxz <chris_AT_noxz.tech>
Date: Fri Apr 3 14:20:36 2020 +0200
[dmenu][patch] fuzzyhighlight: new patch for fuzzy highlight
diff --git a/tools.suckless.org/dmenu/patches/fuzzyhighlight/dmenu-fuzzyhighlight-4.9.diff b/tools.suckless.org/dmenu/patches/fuzzyhighlight/dmenu-fuzzyhighlight-4.9.diff
new file mode 100644
index 00000000..59360b3c
--- /dev/null
+++ b/tools.suckless.org/dmenu/patches/fuzzyhighlight/dmenu-fuzzyhighlight-4.9.diff
_AT_@ -0,0 +1,105 @@
+Author: Chris Noxz <chris_AT_noxz.tech>
+note: This patch is meant to be used together with fuzzymatch
+
+diff -upN dmenu-4.9/config.def.h dmenu-4.9-fuzzyhighlight/config.def.h
+--- dmenu-4.9/config.def.h 2019-02-02 13:55:02.000000000 +0100
++++ dmenu-4.9-fuzzyhighlight/config.def.h 2020-04-03 14:06:23.975230204 +0200
+_AT_@ -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 -upN dmenu-4.9/dmenu.c dmenu-4.9-fuzzyhighlight/dmenu.c
+--- dmenu-4.9/dmenu.c 2019-02-02 13:55:02.000000000 +0100
++++ dmenu-4.9-fuzzyhighlight/dmenu.c 2020-04-03 14:09:46.318532108 +0200
+_AT_@ -26,7 +26,9 @@
+ #define TEXTW(X) (drw_fontset_getwidth(drw, (X)) + lrpad)
+
+ /* enums */
+-enum { SchemeNorm, SchemeSel, SchemeOut, SchemeLast }; /* color schemes */
++enum { SchemeNorm, SchemeSel, SchemeNormHighlight, SchemeSelHighlight,
++ SchemeOut, SchemeLast }; /* color schemes */
++
+
+ struct item {
+ char *text;
+_AT_@ -113,9 +115,49 @@ cistrstr(const char *s, const char *sub)
+ return NULL;
+ }
+
++static void
++drawhighlights(struct item *item, int x, int y, int maxw)
++{
++ int i, indent;
++ char *highlight;
++ char c;
++
++ if (!(strlen(item->text) && strlen(text)))
++ return;
++
++ drw_setscheme(drw, scheme[item == sel
++ ? SchemeSelHighlight
++ : SchemeNormHighlight]);
++ for (i = 0, highlight = item->text; *highlight && text[i];) {
++ if (*highlight == text[i]) {
++ /* get indentation */
++ c = *highlight;
++ *highlight = '++ indent = TEXTW(item->text);
++ *highlight = c;
++
++ /* highlight character */
++ c = highlight[1];
++ highlight[1] = '++ drw_text(
++ drw,
++ x + indent - (lrpad / 2) - 1,
++ y,
++ MIN(maxw - indent, TEXTW(highlight) - lrpad),
++ bh, 0, highlight, 0
++ );
++ highlight[1] = c;
++ i++;
++ }
++ highlight++;
++ }
++}
++
++
+ static int
+ drawitem(struct item *item, int x, int y, int w)
+ {
++ int r;
+ if (item == sel)
+ drw_setscheme(drw, scheme[SchemeSel]);
+ else if (item->out)
+_AT_@ -123,7 +165,9 @@ drawitem(struct item *item, int x, int y
+ else
+ drw_setscheme(drw, scheme[SchemeNorm]);
+
+- return drw_text(drw, x, y, w, bh, lrpad / 2, item->text, 0);
++ r = drw_text(drw, x, y, w, bh, lrpad / 2, item->text, 0);
++ drawhighlights(item, x, y, w);
++ return r;
+ }
+
+ static void
+_AT_@ -724,6 +768,14 @@ main(int argc, char *argv[])
+ colors[SchemeSel][ColBg] = argv[++i];
+ else if (!strcmp(argv[i], "-sf")) /* selected foreground color */
+ colors[SchemeSel][ColFg] = argv[++i];
++ else if (!strcmp(argv[i], "-nhb")) /* normal hi background color */
++ colors[SchemeNormHighlight][ColBg] = argv[++i];
++ else if (!strcmp(argv[i], "-nhf")) /* normal hi foreground color */
++ colors[SchemeNormHighlight][ColFg] = argv[++i];
++ else if (!strcmp(argv[i], "-shb")) /* selected hi background color */
++ colors[SchemeSelHighlight][ColBg] = argv[++i];
++ else if (!strcmp(argv[i], "-shf")) /* selected hi foreground color */
++ colors[SchemeSelHighlight][ColFg] = argv[++i];
+ else if (!strcmp(argv[i], "-w")) /* embedding window id */
+ embed = argv[++i];
+ else
diff --git a/tools.suckless.org/dmenu/patches/fuzzyhighlight/fuzzyhighlight.png b/tools.suckless.org/dmenu/patches/fuzzyhighlight/fuzzyhighlight.png
new file mode 100644
index 00000000..fd833f76
Binary files /dev/null and b/tools.suckless.org/dmenu/patches/fuzzyhighlight/fuzzyhighlight.png differ
diff --git a/tools.suckless.org/dmenu/patches/fuzzyhighlight/index.md b/tools.suckless.org/dmenu/patches/fuzzyhighlight/index.md
new file mode 100644
index 00000000..4705a1c9
--- /dev/null
+++ b/tools.suckless.org/dmenu/patches/fuzzyhighlight/index.md
_AT_@ -0,0 +1,17 @@
+fuzzyhighlight
+==============
+
+Description
+-----------
+This patch make it so that fuzzy matches gets highlighted and is therefor meant
+to be used together with the patch fuzzymatch.
+
+[![Screenshot dmenu with the patch](fuzzyhighlight.png)](fuzzyhighlight.png)
+
+Download
+--------
+* [dmenu-fuzzyhighlight-4.9.diff](dmenu-fuzzyhighlight-4.9.diff)
+
+Authors
+-------
+* Chris Noxz - <chris_AT_noxz.tech>
Received on Fri Apr 03 2020 - 14:21:27 CEST
This archive was generated by hypermail 2.3.0
: Fri Apr 03 2020 - 14:24:47 CEST