diff options
-rw-r--r-- | config.h | 3 | ||||
-rw-r--r-- | dmenu.c | 44 |
2 files changed, 3 insertions, 44 deletions
@@ -13,10 +13,7 @@ static const char *colors[SchemeLast][2] = { | |||
13 | /* fg bg */ | 13 | /* fg bg */ |
14 | [SchemeNorm] = { "#bbbbbb", "#222222" }, | 14 | [SchemeNorm] = { "#bbbbbb", "#222222" }, |
15 | [SchemeSel] = { "#eeeeee", "#005577" }, | 15 | [SchemeSel] = { "#eeeeee", "#005577" }, |
16 | [SchemeSelHighlight] = { "#ffc978", "#005577" }, | ||
17 | [SchemeNormHighlight] = { "#ffc978", "#222222" }, | ||
18 | [SchemeOut] = { "#000000", "#00ffff" }, | 16 | [SchemeOut] = { "#000000", "#00ffff" }, |
19 | [SchemeOutHighlight] = { "#ffc978", "#00ffff" }, | ||
20 | }; | 17 | }; |
21 | 18 | ||
22 | static const unsigned int alphas[SchemeLast][2] = { | 19 | static const unsigned int alphas[SchemeLast][2] = { |
@@ -31,7 +31,8 @@ | |||
31 | #define OPAQUE 0xffU | 31 | #define OPAQUE 0xffU |
32 | 32 | ||
33 | /* enums */ | 33 | /* enums */ |
34 | enum { SchemeNorm, SchemeSel, SchemeOut, SchemeNormHighlight, SchemeSelHighlight, SchemeOutHighlight, SchemeLast }; /* color schemes */ | 34 | enum { SchemeNorm, SchemeSel, SchemeOut, SchemeLast }; /* color schemes */ |
35 | |||
35 | struct item { | 36 | struct item { |
36 | char *text; | 37 | char *text; |
37 | struct item *left, *right; | 38 | struct item *left, *right; |
@@ -145,43 +146,6 @@ cistrstr(const char *h, const char *n) | |||
145 | return NULL; | 146 | return NULL; |
146 | } | 147 | } |
147 | 148 | ||
148 | static void | ||
149 | drawhighlights(struct item *item, int x, int y, int maxw) | ||
150 | { | ||
151 | char restorechar, tokens[sizeof text], *highlight, *token; | ||
152 | int indentx, highlightlen; | ||
153 | |||
154 | drw_setscheme(drw, scheme[item == sel ? SchemeSelHighlight : item->out ? SchemeOutHighlight : SchemeNormHighlight]); | ||
155 | strcpy(tokens, text); | ||
156 | for (token = strtok(tokens, " "); token; token = strtok(NULL, " ")) { | ||
157 | highlight = fstrstr(item->text, token); | ||
158 | while (highlight) { | ||
159 | // Move item str end, calc width for highlight indent, & restore | ||
160 | highlightlen = highlight - item->text; | ||
161 | restorechar = *highlight; | ||
162 | item->text[highlightlen] = '\0'; | ||
163 | indentx = TEXTW(item->text); | ||
164 | item->text[highlightlen] = restorechar; | ||
165 | |||
166 | // Move highlight str end, draw highlight, & restore | ||
167 | restorechar = highlight[strlen(token)]; | ||
168 | highlight[strlen(token)] = '\0'; | ||
169 | if (indentx - (lrpad / 2) - 1 < maxw) | ||
170 | drw_text( | ||
171 | drw, | ||
172 | x + indentx - (lrpad / 2) - 1, | ||
173 | y, | ||
174 | MIN(maxw - indentx, TEXTW(highlight) - lrpad), | ||
175 | bh, 0, highlight, 0 | ||
176 | ); | ||
177 | highlight[strlen(token)] = restorechar; | ||
178 | |||
179 | if (strlen(highlight) - strlen(token) < strlen(token)) break; | ||
180 | highlight = fstrstr(highlight + strlen(token), token); | ||
181 | } | ||
182 | } | ||
183 | } | ||
184 | |||
185 | static int | 149 | static int |
186 | drawitem(struct item *item, int x, int y, int w) | 150 | drawitem(struct item *item, int x, int y, int w) |
187 | { | 151 | { |
@@ -192,9 +156,7 @@ drawitem(struct item *item, int x, int y, int w) | |||
192 | else | 156 | else |
193 | drw_setscheme(drw, scheme[SchemeNorm]); | 157 | drw_setscheme(drw, scheme[SchemeNorm]); |
194 | 158 | ||
195 | int r = drw_text(drw, x, y, w, bh, lrpad / 2, item->text, 0); | 159 | return drw_text(drw, x, y, w, bh, lrpad / 2, item->text, 0); |
196 | drawhighlights(item, x, y, w); | ||
197 | return r; | ||
198 | } | 160 | } |
199 | 161 | ||
200 | static void | 162 | static void |