diff --git a/libs/arg.c b/libs/arg.c index 4a42294..db410a5 100644 --- a/libs/arg.c +++ b/libs/arg.c @@ -89,7 +89,7 @@ void moveup(Arg *arg) { void complete(Arg *arg) { if (hideitem) return; - strncpy(tx.text, sel->clntext, sizeof tx.text - 1); + strncpy(tx.text, sel->text, sizeof tx.text - 1); tx.text[sizeof tx.text - 1] = '\0'; sp.cursor = strlen(tx.text); diff --git a/libs/draw.c b/libs/draw.c index dbad6c2..5baa8d0 100644 --- a/libs/draw.c +++ b/libs/draw.c @@ -40,6 +40,7 @@ void drawhighlights(struct item *item, int x, int y, int w, int p, const char *i int drawitemtext(struct item *item, int x, int y, int w) { char buffer[MAXITEMLENGTH]; // buffer containing item text + char *ttext; int leftpadding = sp.lrpad / 2; // padding int wr, rd; // character int fg = 7; // foreground @@ -136,6 +137,9 @@ int drawitemtext(struct item *item, int x, int y, int w) { } #endif + ttext = malloc(sizeof(buffer)); + ttext[0] = '\0'; + // parse item text for (wr = 0, rd = 0; item->text[rd]; rd++) { if (item->text[rd] == '' && item->text[rd + 1] == '[') { @@ -151,6 +155,8 @@ int drawitemtext(struct item *item, int x, int y, int w) { draw_text(draw, x, y, MIN(w, TEXTW(buffer) - sp.lrpad) + leftpadding, sp.bh, leftpadding, isrtl ? fribidi_text : buffer, 0, pango_item ? True : False, fgcol, bgcol, fga, bga); drawhighlights(item, x, y, MIN(w, TEXTW(buffer) - sp.lrpad) + leftpadding, leftpadding, isrtl ? fribidi_text : buffer); + strcat(ttext, buffer); + // position and width x += MIN(w, TEXTW(buffer) - sp.lrpad) + leftpadding; w -= MIN(w, TEXTW(buffer) - sp.lrpad) + leftpadding; @@ -264,16 +270,15 @@ int drawitemtext(struct item *item, int x, int y, int w) { } buffer[wr] = '\0'; + strcat(ttext, buffer); + + item->text = ttext; // set item text to one without SGR sequences // now draw any non-colored text apply_fribidi(buffer); int r = draw_text(draw, x, y, w, sp.bh, leftpadding, isrtl ? fribidi_text : buffer, 0, pango_item ? True : False, fgcol, bgcol, fga, bga); if (!hidehighlight) drawhighlights(item, x, y, w, leftpadding, buffer); - // copy current buffer to item->clntext instead of item->text, this way SGR sequences aren't drawn - item->clntext = malloc(sizeof(buffer)); - memcpy(item->clntext, buffer, sizeof(buffer)); - if (!hidepowerline && powerlineitems && selitem) { if (itempwlstyle == 2) { draw_circle(draw, r, y, sp.plw, sp.bh, 1, col_menu, bgcol, alpha_menu, bga); diff --git a/spmenu.c b/spmenu.c index 83921b7..be79345 100644 --- a/spmenu.c +++ b/spmenu.c @@ -104,7 +104,6 @@ enum { struct item { char *text; - char *clntext; char *image; char *ex; struct item *left, *right;