[wiki] [sites] [dmenu][patch][fuzzyhighlight] Some fixes: || Oleh Kopeykin

From: <git_AT_suckless.org>
Date: Sat, 04 Feb 2023 23:50:11 +0100

commit da0c9f724bf305875b9e4975671b67a8ac5ce842
Author: Oleh Kopeykin <olehkopeykin_AT_yandex.by>
Date: Sun Feb 5 01:43:16 2023 +0300

    [dmenu][patch][fuzzyhighlight] Some fixes:
    
    * Fixed the shift of highlighted symbols
    * Supported case-insensitive item matching behavior.

diff --git a/tools.suckless.org/dmenu/patches/fuzzyhighlight/dmenu-fuzzyhighlight-caseinsensitive-4.9.diff b/tools.suckless.org/dmenu/patches/fuzzyhighlight/dmenu-fuzzyhighlight-caseinsensitive-4.9.diff
new file mode 100644
index 00000000..026b3d29
--- /dev/null
+++ b/tools.suckless.org/dmenu/patches/fuzzyhighlight/dmenu-fuzzyhighlight-caseinsensitive-4.9.diff
_AT_@ -0,0 +1,164 @@
+From 2de2780bef245ae44d677abd20c589160f0d984b Mon Sep 17 00:00:00 2001
+From: Oleh Kopeykin <olehkopeykin_AT_yandex.by>
+Date: Sun, 5 Feb 2023 01:15:35 +0300
+Subject: [PATCH] Adds the fuzzyhighlight patch
+
+---
+ config.def.h | 2 ++
+ dmenu.1 | 20 ++++++++++++++++++
+ dmenu.c | 57 +++++++++++++++++++++++++++++++++++++++++++++++++---
+ 3 files changed, 76 insertions(+), 3 deletions(-)
+
+diff --git a/config.def.h b/config.def.h
+index 51612b9..0103bda 100644
+--- a/config.def.h
++++ b/config.def.h
+_AT_@ -12,6 +12,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.1 b/dmenu.1
+index 323f93c..472b179 100644
+--- a/dmenu.1
++++ b/dmenu.1
+_AT_@ -20,6 +20,14 @@ dmenu \- dynamic menu
+ .IR color ]
+ .RB [ \-sf
+ .IR color ]
++.RB [ \-nhb
++.IR color ]
++.RB [ \-nhf
++.IR color ]
++.RB [ \-shb
++.IR color ]
++.RB [ \-shf
++.IR color ]
+ .RB [ \-w
+ .IR windowid ]
+ .P
+_AT_@ -75,6 +83,18 @@ defines the selected background color.
+ .BI \-sf " color"
+ defines the selected foreground color.
+ .TP
++.BI \-nhb " color"
++defines the normal highlight background color.
++.TP
++.BI \-nhf " color"
++defines the normal highlight foreground color.
++.TP
++.BI \-shb " color"
++defines the selected highlight background color.
++.TP
++.BI \-shf " color"
++defines the selected highlight foreground color.
++.TP
+ .B \-v
+ prints version information to stdout, then exits.
+ .TP
+diff --git a/dmenu.c b/dmenu.c
+index 96ddc98..442d707 100644
+--- a/dmenu.c
++++ b/dmenu.c
+_AT_@ -27,7 +27,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_@ -115,9 +117,47 @@ 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 (!fstrncmp(&text[i], highlight, 1)) {
++ c = highlight[1];
++ highlight[1] = '++
++ /* get indentation */
++ indent = TEXTW(item->text);
++
++ /* highlight character */
++ drw_text(
++ drw,
++ x + indent - lrpad,
++ 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_@ -125,7 +165,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);
++ r = drw_text(drw, x, y, w, bh, lrpad / 2, item->text, 0);
++ drawhighlights(item, x, y, w);
++ return r;
+ }
+
+ static void
+_AT_@ -770,7 +812,8 @@ static void
+ usage(void)
+ {
+ fputs("usage: dmenu [-bfiv] [-l lines] [-p prompt] [-fn font] [-m monitor]
"
+- " [-nb color] [-nf color] [-sb color] [-sf color] [-w windowid]
", stderr);
++ " [-nb color] [-nf color] [-sb color] [-sf color]
"
++ " [-nhb color] [-nhf color] [-shb color] [-shf color] [-w windowid]
", stderr);
+ exit(1);
+ }
+
+_AT_@ -813,6 +856,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
+--
+2.39.1
+
diff --git a/tools.suckless.org/dmenu/patches/fuzzyhighlight/index.md b/tools.suckless.org/dmenu/patches/fuzzyhighlight/index.md
index 2f02e7e5..9e7725ed 100644
--- a/tools.suckless.org/dmenu/patches/fuzzyhighlight/index.md
+++ b/tools.suckless.org/dmenu/patches/fuzzyhighlight/index.md
_AT_@ -21,6 +21,12 @@ Download
 --------
 * [dmenu-fuzzyhighlight-4.9.diff](dmenu-fuzzyhighlight-4.9.diff)
 
+This patch fixes the shift of highlighted symbols, it also supports case-insensitive
+item matching behavior.
+
+* [dmenu-fuzzyhighlight-caseinsensitive-4.9.diff](dmenu-fuzzyhighlight-caseinsensitive-4.9.diff)
+
 Authors
 -------
 * Chris Noxz - <chris_AT_noxz.tech>
+* Oleh Kopeykin - <olehkopeykin_AT_yandex.by> (case-insensitive)
Received on Sat Feb 04 2023 - 23:50:11 CET

This archive was generated by hypermail 2.3.0 : Sun Feb 05 2023 - 00:01:35 CET