From bd0806de0887039ccba401d889b0aed38a92c7f0 Mon Sep 17 00:00:00 2001 From: Andreev Gregory Date: Wed, 2 Apr 2025 14:04:50 +0300 Subject: [PATCH] Fixed tsv bug (noe we complete and match and calculate offsets with item->stext). Also the cleanupo function gave me spooks so I deleted it's scary part --- dmenu.c | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/dmenu.c b/dmenu.c index 2c4e88e..92dae7d 100644 --- a/dmenu.c +++ b/dmenu.c @@ -99,10 +99,10 @@ calcoffsets(void) n = mw - (promptw + inputw + TEXTW("<") + TEXTW(">")); /* calculate which items will begin the next page and previous page */ for (i = 0, next = curr; next; next = next->right) - if ((i += (lines > 0) ? bh : textw_clamp(next->text, n)) > n) + if ((i += (lines > 0) ? bh : textw_clamp(next->stext, n)) > n) break; for (i = 0, prev = curr; prev && prev->left; prev = prev->left) - if ((i += (lines > 0) ? bh : textw_clamp(prev->left->text, n)) > n) + if ((i += (lines > 0) ? bh : textw_clamp(prev->left->stext, n)) > n) break; } @@ -110,8 +110,8 @@ static int max_textw(void) { int len = 0; - for (struct item *item = items; item && item->text; item++) - len = MAX(TEXTW(item->text), len); + for (struct item *item = items; item && item->stext; item++) + len = MAX(TEXTW(item->stext), len); return len; } @@ -123,8 +123,8 @@ cleanup(void) XUngrabKey(dpy, AnyKey, AnyModifier, root); for (i = 0; i < SchemeLast; i++) free(scheme[i]); - for (i = 0; items && items[i].text; ++i) - free(items[i].text); + //for (i = 0; items && items[i].stext; ++i) + // free(items[i].text); free(items); drw_free(drw); XSync(dpy, False); @@ -277,16 +277,16 @@ match(void) matches = lprefix = lsubstr = matchend = prefixend = substrend = NULL; textsize = strlen(text) + 1; - for (item = items; item && item->text; item++) { + for (item = items; item && item->stext; item++) { for (i = 0; i < tokc; i++) - if (!fstrstr(item->text, tokv[i])) + if (!fstrstr(item->stext, tokv[i])) break; if (i != tokc) /* not all tokens match */ continue; /* exact matches go first, then prefixes, then substrings */ - if (!tokc || !fstrncmp(text, item->text, textsize)) + if (!tokc || !fstrncmp(text, item->stext, textsize)) appenditem(item, &matches, &matchend); - else if (!fstrncmp(tokv[0], item->text, len)) + else if (!fstrncmp(tokv[0], item->stext, len)) appenditem(item, &lprefix, &prefixend); else appenditem(item, &lsubstr, &substrend); @@ -593,8 +593,8 @@ insert: case XK_Tab: if (!sel) return; - cursor = strnlen(sel->text, sizeof text - 1); - memcpy(text, sel->text, cursor); + cursor = strnlen(sel->stext, sizeof text - 1); + memcpy(text, sel->stext, cursor); text[cursor] = '\0'; match(); break;