fix: right/left arrow drawing

This commit is contained in:
speedie 2023-03-29 22:01:45 +02:00
parent dea326e173
commit 158b89335c
3 changed files with 13 additions and 13 deletions

1
TODO
View file

@ -2,7 +2,6 @@
- Mouse bind array (mouse.h) - Mouse bind array (mouse.h)
- Add configuration file using (probably) libconfig - 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. - 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 - Contextual completions
- Use cairo for text drawing over Xft - Use cairo for text drawing over Xft

View file

@ -160,9 +160,12 @@ drawitem(int x, int y, int w)
int numberWidth = 0; int numberWidth = 0;
int modeWidth = 0; int modeWidth = 0;
int larrowWidth = 0;
int rarrowWidth = 0; int rarrowWidth = 0;
// add width // 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 (!hidemode) modeWidth = pango_mode ? TEXTWM(modetext) : TEXTW(modetext);
if (!hiderarrow) rarrowWidth = pango_rightarrow ? TEXTWM(rightarrow) : TEXTW(rightarrow); if (!hiderarrow) rarrowWidth = pango_rightarrow ? TEXTWM(rightarrow) : TEXTW(rightarrow);
if (!hidematchcount) numberWidth = pango_numbers ? TEXTWM(numbers) : TEXTW(numbers); if (!hidematchcount) numberWidth = pango_numbers ? TEXTWM(numbers) : TEXTW(numbers);
@ -209,12 +212,12 @@ drawitem(int x, int y, int w)
} else if (matches) { } else if (matches) {
x += inputw; x += inputw;
drawlarrow(x, y, w); x = drawlarrow(x, 0, larrowWidth);
for (item = curr; item != next; item = item->right) // draw items 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)); 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; return x;
@ -277,28 +280,26 @@ drawinput(int x, int y, int w)
int int
drawlarrow(int x, int y, int w) drawlarrow(int x, int y, int w)
{ {
if (hidelarrow) { if (hidelarrow) return x;
return x;
}
if (curr->left) { // draw left arrow if (curr->left) { // draw left arrow
drw_setscheme(drw, scheme[SchemeLArrow]); drw_setscheme(drw, scheme[SchemeLArrow]);
drw_text(drw, x, 0, w, bh, lrpad / 2, leftarrow, 0, pango_leftarrow ? True : False); drw_text(drw, x, 0, w, bh, lrpad / 2, leftarrow, 0, pango_leftarrow ? True : False);
x += w;
} }
x += w;
return x; return x;
} }
int 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 if (hiderarrow) return x;
w = rarrowWidth;
drw_setscheme(drw, scheme[SchemeRArrow]);
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); drw_text(drw, mw - w, 0, w, bh, lrpad / 2, rightarrow, 0, pango_rightarrow ? True : False);
x += w;
} }
return x; return x;

View file

@ -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 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 drawmode(int x, int y, int w, int numberWidth, int modeWidth);
static int drawlarrow(int x, int y, int w); 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);