diff --git a/TODO b/TODO index 2765b24..a7da1be 100644 --- a/TODO +++ b/TODO @@ -2,7 +2,6 @@ - Mouse bind array (mouse.h) - Add configuration file using (probably) libconfig -- Fix arrow drawing (not sure what went wrong yet) - Use higher level libraries, MD5() is deprecated as of OpenSSL 3 but it has been temporarily silenced. This might also improve compatibility for people who don't use OpenSSL. - Contextual completions - Use cairo for text drawing over Xft diff --git a/libs/draw.c b/libs/draw.c index d4b6fda..979c799 100644 --- a/libs/draw.c +++ b/libs/draw.c @@ -160,9 +160,12 @@ drawitem(int x, int y, int w) int numberWidth = 0; int modeWidth = 0; + int larrowWidth = 0; int rarrowWidth = 0; // add width + if (!hidelarrow) larrowWidth = pango_leftarrow ? TEXTWM(leftarrow) : TEXTW(leftarrow); + if (!hiderarrow) rarrowWidth = pango_rightarrow ? TEXTWM(rightarrow) : TEXTW(rightarrow); if (!hidemode) modeWidth = pango_mode ? TEXTWM(modetext) : TEXTW(modetext); if (!hiderarrow) rarrowWidth = pango_rightarrow ? TEXTWM(rightarrow) : TEXTW(rightarrow); if (!hidematchcount) numberWidth = pango_numbers ? TEXTWM(numbers) : TEXTW(numbers); @@ -209,12 +212,12 @@ drawitem(int x, int y, int w) } else if (matches) { x += inputw; - drawlarrow(x, y, w); + x = drawlarrow(x, 0, larrowWidth); for (item = curr; item != next; item = item->right) // draw items x = drawitemtext(item, x, 0, MIN(pango_item ? TEXTWM(item->text) : TEXTW(item->text), mw - x - rarrowWidth - numberWidth - modeWidth)); - drawrarrow(x, y, w, numberWidth, modeWidth, rarrowWidth); + x = drawrarrow(x, 0, rarrowWidth + numberWidth + modeWidth); } return x; @@ -277,28 +280,26 @@ drawinput(int x, int y, int w) int drawlarrow(int x, int y, int w) { - if (hidelarrow) { - return x; - } + if (hidelarrow) return x; if (curr->left) { // draw left arrow drw_setscheme(drw, scheme[SchemeLArrow]); drw_text(drw, x, 0, w, bh, lrpad / 2, leftarrow, 0, pango_leftarrow ? True : False); + x += w; } - x += w; - return x; } int -drawrarrow(int x, int y, int w, int numberWidth, int modeWidth, int rarrowWidth) +drawrarrow(int x, int y, int w) { - if (next && !hiderarrow) { // draw right arrow - w = rarrowWidth; - drw_setscheme(drw, scheme[SchemeRArrow]); + if (hiderarrow) return x; + if (next) { // draw right arrow + drw_setscheme(drw, scheme[SchemeRArrow]); drw_text(drw, mw - w, 0, w, bh, lrpad / 2, rightarrow, 0, pango_rightarrow ? True : False); + x += w; } return x; diff --git a/libs/draw.h b/libs/draw.h index 9f259c0..336aebf 100644 --- a/libs/draw.h +++ b/libs/draw.h @@ -5,4 +5,4 @@ static int drawinput(int x, int y, int w); static int drawnumber(int x, int y, int w, int numberWidth, int modeWidth); static int drawmode(int x, int y, int w, int numberWidth, int modeWidth); static int drawlarrow(int x, int y, int w); -static int drawrarrow(int x, int y, int w, int numberWidth, int modeWidth, int rarrowWidth); +static int drawrarrow(int x, int y, int w);