mirror of
https://github.com/mintycube/dmenu.git
synced 2024-10-22 14:05:48 +02:00
Aligning variables between exact and fuzzy highlighting
This commit is contained in:
parent
9a1d207eae
commit
a3a5229059
@ -6,12 +6,10 @@ drawhighlights(struct item *item, int x, int y, int maxw)
|
|||||||
#endif // EMOJI_HIGHLIGHT_PATCH
|
#endif // EMOJI_HIGHLIGHT_PATCH
|
||||||
{
|
{
|
||||||
char restorechar, tokens[sizeof text], *highlight, *token;
|
char restorechar, tokens[sizeof text], *highlight, *token;
|
||||||
int indentx, highlightlen;
|
int indent, highlightlen;
|
||||||
|
|
||||||
#if FUZZYMATCH_PATCH
|
#if FUZZYMATCH_PATCH
|
||||||
char c;
|
int i;
|
||||||
int i, indent;
|
|
||||||
int utf8charlen;
|
|
||||||
#endif // FUZZYMATCH_PATCH
|
#endif // FUZZYMATCH_PATCH
|
||||||
|
|
||||||
#if EMOJI_HIGHLIGHT_PATCH
|
#if EMOJI_HIGHLIGHT_PATCH
|
||||||
@ -39,22 +37,22 @@ drawhighlights(struct item *item, int x, int y, int maxw)
|
|||||||
#if FUZZYMATCH_PATCH
|
#if FUZZYMATCH_PATCH
|
||||||
if (fuzzy) {
|
if (fuzzy) {
|
||||||
for (i = 0, highlight = itemtext; *highlight && text[i];) {
|
for (i = 0, highlight = itemtext; *highlight && text[i];) {
|
||||||
utf8charlen = utf8len(highlight);
|
highlightlen = utf8len(highlight);
|
||||||
#if FUZZYMATCH_PATCH
|
#if FUZZYMATCH_PATCH
|
||||||
if (!fstrncmp(&(*highlight), &text[i], utf8charlen))
|
if (!fstrncmp(&(*highlight), &text[i], highlightlen))
|
||||||
#else
|
#else
|
||||||
if (*highlight == text[i])
|
if (*highlight == text[i])
|
||||||
#endif // FUZZYMATCH_PATCH
|
#endif // FUZZYMATCH_PATCH
|
||||||
{
|
{
|
||||||
/* get indentation */
|
/* get indentation */
|
||||||
c = *highlight;
|
restorechar = *highlight;
|
||||||
*highlight = '\0';
|
*highlight = '\0';
|
||||||
indent = TEXTW(itemtext) - lrpad;
|
indent = TEXTW(itemtext) - lrpad;
|
||||||
*highlight = c;
|
*highlight = restorechar;
|
||||||
|
|
||||||
/* highlight character */
|
/* highlight character */
|
||||||
c = highlight[utf8charlen];
|
restorechar = highlight[highlightlen];
|
||||||
highlight[utf8charlen] = '\0';
|
highlight[highlightlen] = '\0';
|
||||||
drw_text(
|
drw_text(
|
||||||
drw,
|
drw,
|
||||||
x + indent + (lrpad / 2),
|
x + indent + (lrpad / 2),
|
||||||
@ -65,8 +63,8 @@ drawhighlights(struct item *item, int x, int y, int maxw)
|
|||||||
, True
|
, True
|
||||||
#endif // PANGO_PATCH
|
#endif // PANGO_PATCH
|
||||||
);
|
);
|
||||||
highlight[utf8charlen] = c;
|
highlight[highlightlen] = restorechar;
|
||||||
i += utf8charlen;
|
i += highlightlen;
|
||||||
}
|
}
|
||||||
highlight++;
|
highlight++;
|
||||||
}
|
}
|
||||||
@ -82,18 +80,18 @@ drawhighlights(struct item *item, int x, int y, int maxw)
|
|||||||
highlightlen = highlight - itemtext;
|
highlightlen = highlight - itemtext;
|
||||||
restorechar = *highlight;
|
restorechar = *highlight;
|
||||||
itemtext[highlightlen] = '\0';
|
itemtext[highlightlen] = '\0';
|
||||||
indentx = TEXTW(itemtext);
|
indent = TEXTW(itemtext);
|
||||||
itemtext[highlightlen] = restorechar;
|
itemtext[highlightlen] = restorechar;
|
||||||
|
|
||||||
// Move highlight str end, draw highlight, & restore
|
// Move highlight str end, draw highlight, & restore
|
||||||
restorechar = highlight[strlen(token)];
|
restorechar = highlight[strlen(token)];
|
||||||
highlight[strlen(token)] = '\0';
|
highlight[strlen(token)] = '\0';
|
||||||
if (indentx - (lrpad / 2) - 1 < maxw)
|
if (indent - (lrpad / 2) - 1 < maxw)
|
||||||
drw_text(
|
drw_text(
|
||||||
drw,
|
drw,
|
||||||
x + indentx - (lrpad / 2) - 1,
|
x + indent - (lrpad / 2) - 1,
|
||||||
y,
|
y,
|
||||||
MIN(maxw - indentx, TEXTW(highlight) - lrpad),
|
MIN(maxw - indent, TEXTW(highlight) - lrpad),
|
||||||
bh, 0, highlight, 0
|
bh, 0, highlight, 0
|
||||||
#if PANGO_PATCH
|
#if PANGO_PATCH
|
||||||
, True
|
, True
|
||||||
|
Loading…
Reference in New Issue
Block a user