diff --git a/dmenu.c b/dmenu.c index 65f25ce..d9e490a 100644 --- a/dmenu.c +++ b/dmenu.c @@ -30,6 +30,7 @@ enum { SchemeNorm, SchemeSel, SchemeOut, SchemeLast }; /* color schemes */ struct item { char *text; + char *stext; struct item *left, *right; int out; }; @@ -123,7 +124,7 @@ drawitem(struct item *item, int x, int y, int w) else drw_setscheme(drw, scheme[SchemeNorm]); - return drw_text(drw, x, y, w, bh, lrpad / 2, item->text, 0); + return drw_text(drw, x, y, w, bh, lrpad / 2, item->stext, 0); } static void @@ -165,7 +166,7 @@ drawmenu(void) } x += w; for (item = curr; item != next; item = item->right) - x = drawitem(item, x, 0, MIN(TEXTW(item->text), mw - x - TEXTW(">"))); + x = drawitem(item, x, 0, MIN(TEXTW(item->stext), mw - x - TEXTW(">"))); if (next) { w = TEXTW(">"); drw_setscheme(drw, scheme[SchemeNorm]); @@ -534,6 +535,10 @@ readstdin(void) *p = '\0'; if (!(items[i].text = strdup(buf))) die("cannot strdup %u bytes:", strlen(buf) + 1); + if ((p = strchr(buf, '\t'))) + *p = '\0'; + if (!(items[i].stext = strdup(buf))) + die("cannot strdup %u bytes:", strlen(buf) + 1); items[i].out = 0; drw_font_getexts(drw->fonts, buf, strlen(buf), &tmpmax, NULL); if (tmpmax > inputw) {