From 2054d41f376b409e7b963bc332173f826a227ea3 Mon Sep 17 00:00:00 2001 From: Moritz Luedecke Date: Sun, 20 Aug 2017 15:51:32 +0200 Subject: Add cursor --- pinentry-dmenu.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) (limited to 'pinentry-dmenu.c') diff --git a/pinentry-dmenu.c b/pinentry-dmenu.c index 57db1c7..fa39b3f 100644 --- a/pinentry-dmenu.c +++ b/pinentry-dmenu.c @@ -139,9 +139,10 @@ insert(const char *str, ssize_t n) { static void drawwin(void) { unsigned int curpos; - int x = 0, pb = 0, pbw = 0, i; + int x = 0, pb, pbw = 0, i; size_t asterlen = strlen(asterisk); size_t pdesclen; + int leftinput; char* desc; char* censort = ecalloc(1, asterlen * sizeof(text)); @@ -179,10 +180,8 @@ drawwin(void) { drw_setscheme(drw, scheme[SchemeDesc]); drw_text(drw, pb, 0, pbw, bh, lrpad / 2, desc, 0); } else { - pb = 0; + pbw = 0; } - } else { - pb = 0; } } @@ -195,9 +194,15 @@ drawwin(void) { } censort[i+1] = '\n'; - drw_text(drw, x, 0, mw - x - pbw, bh, lrpad / 2, censort, 0); + leftinput = mw - x - pbw; + drw_text(drw, x, 0, leftinput, bh, lrpad / 2, censort, 0); drw_font_getexts(drw->fonts, censort, cursor * asterlen, &curpos, NULL); free(censort); + + if ((curpos += lrpad / 2 - 1) < leftinput) { + drw_setscheme(drw, scheme[SchemeNormal]); + drw_rect(drw, x + curpos, 2, 2, bh - 4, 1, 0); + } } else { x += TEXTW(" "); x = drawitem("No", (sel == No), x, 0, TEXTW("No")); -- cgit v1.2.3