From 495401e1538ca2ca4df980d633b8e5dfc398fb3f Mon Sep 17 00:00:00 2001 From: speedie Date: Mon, 7 Aug 2023 18:59:13 +0200 Subject: [PATCH] Use simpler highlighting --- libs/draw.c | 72 +++++++++++++++++++++++++++-------------------------- 1 file changed, 37 insertions(+), 35 deletions(-) diff --git a/libs/draw.c b/libs/draw.c index e6cb890..6e0dea0 100644 --- a/libs/draw.c +++ b/libs/draw.c @@ -1,44 +1,51 @@ /* See LICENSE file for copyright and license details. */ void drawhighlights(struct item *item, int x, int y, int w, int p, char *itemtext) { - int i, indent; - char *highlight; - char c; + char restorechar, text[sizeof tx.text], *highlight, *ctext; + int indent, highlightlen; - // limitation in order to prevent highlighting from drawing when the text isn't visible - if (columns > 5 && lines > 1) + if ((columns > 5 && lines > 1) || (!(strlen(itemtext) && strlen(tx.text))) || strstr(itemtext, "index)) { return; + } - if (!(strlen(itemtext) && strlen(tx.text))) - return; + strcpy(text, tx.text); - if (strstr(itemtext, "index)) { - selitem = (lines ? 1 : selitem); bgcol = col_itemmarkedbg; fgcol = col_itemmarkedfg; fga = alpha_itemmarkedfg; @@ -144,7 +148,7 @@ int drawitemtext(struct item *item, int x, int y, int w) { } // apply extra padding - if ((selitem && !priitem) && lines) { + if ((!priitem) && lines) { leftpadding += selitempadding; } else if (priitem && lines) { leftpadding += priitempadding; @@ -166,7 +170,7 @@ int drawitemtext(struct item *item, int x, int y, int w) { obgcol = bgcol; oleftpadding = leftpadding; - if (!hidepowerline && powerlineitems && selitem) { + if (!hidepowerline && powerlineitems) { if (itempwlstyle == 2) { draw_circle(draw, x - sp.plw, y, sp.plw, sp.bh, 0, col_menu, bgcol, alpha_menu, bga); } else { @@ -200,11 +204,9 @@ int drawitemtext(struct item *item, int x, int y, int w) { apply_fribidi(buffer); draw_text(draw, x, y, w, sp.bh, leftpadding, isrtl ? fribidi_text : buffer, 0, pango_item ? True : False, fgcol, bgcol, fga, bga); - // position and width x += MIN(w, TEXTW(buffer) - sp.lrpad + leftpadding); w -= MIN(w, TEXTW(buffer) - sp.lrpad + leftpadding); - // no highlighting if colored text leftpadding = 0; char *c_character = item->text + escape + 1; // current character @@ -310,7 +312,7 @@ int drawitemtext(struct item *item, int x, int y, int w) { if (!hidehighlight) drawhighlights(item, ox, oy, ow, oleftpadding, item->nsgrtext); - if (!hidepowerline && powerlineitems && selitem) { + if (!hidepowerline && powerlineitems) { if (itempwlstyle == 2) { draw_circle(draw, ret, y, sp.plw, sp.bh, 1, col_menu, obgcol, alpha_menu, obga); } else {