dmenu/patch/fuzzyhighlight.c

46 lines
937 B
C
Raw Normal View History

2020-04-04 09:58:35 +02:00
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 FUZZYMATCH_PATCH
if (!fstrncmp(&(*highlight), &text[i], 1))
#else
if (*highlight == text[i])
#endif // FUZZYMATCH_PATCH
{
2020-04-04 09:58:35 +02:00
/* get indentation */
c = *highlight;
*highlight = '\0';
indent = TEXTW(item->text);
*highlight = c;
/* highlight character */
c = highlight[1];
highlight[1] = '\0';
drw_text(
drw,
x + indent - (lrpad / 2),
2020-04-04 09:58:35 +02:00
y,
MIN(maxw - indent, TEXTW(highlight) - lrpad),
bh, 0, highlight, 0
2020-06-13 15:32:41 +02:00
#if PANGO_PATCH
, True
#endif // PANGO_PATCH
2020-04-04 09:58:35 +02:00
);
highlight[1] = c;
i++;
}
highlight++;
}
}