summaryrefslogtreecommitdiff
path: root/patches/dmenu-highlight-4.9.diff
diff options
context:
space:
mode:
authorzachir <zachir@librem.one>2021-09-13 22:02:26 -0500
committerzachir <zachir@librem.one>2021-09-13 22:02:26 -0500
commit65aad46129921ce5824dee14e50ef8bfed350a26 (patch)
treeae876d4a1e305aae020313b2b068bfb12dfe8f64 /patches/dmenu-highlight-4.9.diff
parentf84336a06d7c660ec8864bd04ac2138ff3a54dbc (diff)
dmenu: complete rebase, add new patches plus fix old ones (no xresources)
Diffstat (limited to 'patches/dmenu-highlight-4.9.diff')
-rw-r--r--patches/dmenu-highlight-4.9.diff93
1 files changed, 0 insertions, 93 deletions
diff --git a/patches/dmenu-highlight-4.9.diff b/patches/dmenu-highlight-4.9.diff
deleted file mode 100644
index 04897ea..0000000
--- a/patches/dmenu-highlight-4.9.diff
+++ /dev/null
@@ -1,93 +0,0 @@
-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
-