diff options
author | Moritz Luedecke <ritze@skweez.net> | 2017-08-20 15:51:32 +0200 |
---|---|---|
committer | Moritz Luedecke <ritze@skweez.net> | 2017-08-20 15:51:32 +0200 |
commit | 2054d41f376b409e7b963bc332173f826a227ea3 (patch) | |
tree | 55739b43748e18cd9418dd6325f198523238957c | |
parent | 0a4dd1a85297c74a7a5998d439673f992cef1ec7 (diff) |
Add cursor
-rw-r--r-- | pinentry-dmenu.c | 15 |
1 files changed, 10 insertions, 5 deletions
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")); |