From 8abf8733086bd5d8b5686c4ad60121cc17470659 Mon Sep 17 00:00:00 2001 From: Sam Chudnick Date: Sun, 26 Feb 2023 18:50:16 -0500 Subject: Revert highlight patch --- config.h | 3 --- dmenu.c | 44 +++----------------------------------------- 2 files changed, 3 insertions(+), 44 deletions(-) diff --git a/config.h b/config.h index bf22598..5893d0b 100644 --- a/config.h +++ b/config.h @@ -13,10 +13,7 @@ static const char *colors[SchemeLast][2] = { /* fg bg */ [SchemeNorm] = { "#bbbbbb", "#222222" }, [SchemeSel] = { "#eeeeee", "#005577" }, - [SchemeSelHighlight] = { "#ffc978", "#005577" }, - [SchemeNormHighlight] = { "#ffc978", "#222222" }, [SchemeOut] = { "#000000", "#00ffff" }, - [SchemeOutHighlight] = { "#ffc978", "#00ffff" }, }; static const unsigned int alphas[SchemeLast][2] = { diff --git a/dmenu.c b/dmenu.c index 431e84f..0dc940b 100644 --- a/dmenu.c +++ b/dmenu.c @@ -31,7 +31,8 @@ #define OPAQUE 0xffU /* enums */ -enum { SchemeNorm, SchemeSel, SchemeOut, SchemeNormHighlight, SchemeSelHighlight, SchemeOutHighlight, SchemeLast }; /* color schemes */ +enum { SchemeNorm, SchemeSel, SchemeOut, SchemeLast }; /* color schemes */ + struct item { char *text; struct item *left, *right; @@ -145,43 +146,6 @@ cistrstr(const char *h, const char *n) 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 : item->out ? SchemeOutHighlight : 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) { @@ -192,9 +156,7 @@ drawitem(struct item *item, int x, int y, int w) else drw_setscheme(drw, scheme[SchemeNorm]); - int r = drw_text(drw, x, y, w, bh, lrpad / 2, item->text, 0); - drawhighlights(item, x, y, w); - return r; + return drw_text(drw, x, y, w, bh, lrpad / 2, item->text, 0); } static void -- cgit v1.2.3