method for cleaning the pinentry description changed
This commit is contained in:
parent
b0a27f8c3c
commit
50e628e185
@ -48,7 +48,8 @@ static int lrpad;
|
|||||||
static size_t cursor;
|
static size_t cursor;
|
||||||
static int screen;
|
static int screen;
|
||||||
|
|
||||||
static int bottom = 0, center = 0;
|
static int bottom = 0,
|
||||||
|
center = 0;
|
||||||
|
|
||||||
static char* pin;
|
static char* pin;
|
||||||
static int pin_len;
|
static int pin_len;
|
||||||
@ -223,6 +224,29 @@ insert(const char *str, ssize_t n) {
|
|||||||
pin[len + n] = '\0';
|
pin[len + n] = '\0';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
clear_string(char *str)
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
char *dest = str;
|
||||||
|
|
||||||
|
/* remove new lines */
|
||||||
|
for (i = 0; i < strlen(str); i++) {
|
||||||
|
if (str[i] == '\n') {
|
||||||
|
str[i] = ' ';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* remove multiple spaces */
|
||||||
|
while (*str != '\0') {
|
||||||
|
while (*str == ' ' && *(str + 1) == ' ')
|
||||||
|
str++;
|
||||||
|
|
||||||
|
*dest++ = *str++;
|
||||||
|
}
|
||||||
|
*dest = '\0';
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
drawwin(void) {
|
drawwin(void) {
|
||||||
unsigned int curpos;
|
unsigned int curpos;
|
||||||
@ -253,29 +277,22 @@ drawwin(void) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (pinentry_info->description) {
|
if (pinentry_info->description) {
|
||||||
pb = mw - x;
|
clear_string(pinentry_info->description);
|
||||||
pdesclen = strlen(pinentry_info->description);
|
pdesclen = strlen(pinentry_info->description);
|
||||||
|
pb = mw - x;
|
||||||
|
|
||||||
if (pb > 0) {
|
if (pb > 0) {
|
||||||
pb -= (winmode == WinPin) ? censortl : confirml;
|
pb -= (winmode == WinPin) ? censortl : confirml;
|
||||||
pbw = MINDESCLEN * pdescw / pdesclen;
|
pbw = MIN(MINDESCLEN * pdescw / pdesclen, pdescw);
|
||||||
pbw = MIN(pbw, pdescw);
|
|
||||||
|
|
||||||
if (pb >= pbw) {
|
if (pb >= pbw) {
|
||||||
pbw = MAX(pbw, pdescw);
|
pbw = MIN(MAX(pbw, pdescw), pb);
|
||||||
pbw = MIN(pbw, pb);
|
|
||||||
pb = mw - pbw;
|
pb = mw - pbw;
|
||||||
|
|
||||||
for (i = 0; i < pdesclen; i++) {
|
|
||||||
if (pinentry_info->description[i] == '\n') {
|
|
||||||
pinentry_info->description[i] = ' ';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
drw_setscheme(drw, scheme[SchemeDesc]);
|
drw_setscheme(drw, scheme[SchemeDesc]);
|
||||||
if (center) {
|
if (center) {
|
||||||
drw_text(drw, promptw + ppromptw, lineheight, centerwidth,
|
drw_text(drw, promptw + ppromptw, lineheight, centerwidth,
|
||||||
bh + borderwidth, lrpad / 2,
|
bh + borderwidth * 2, lrpad / 2,
|
||||||
pinentry_info->description, 0);
|
pinentry_info->description, 0);
|
||||||
} else {
|
} else {
|
||||||
drw_text(drw, pb, 0, pbw, bh, lrpad / 2,
|
drw_text(drw, pb, 0, pbw, bh, lrpad / 2,
|
||||||
@ -339,8 +356,7 @@ setup(void) {
|
|||||||
utf8 = XInternAtom(dpy, "UTF8_STRING", False);
|
utf8 = XInternAtom(dpy, "UTF8_STRING", False);
|
||||||
|
|
||||||
/* Calculate menu geometry */
|
/* Calculate menu geometry */
|
||||||
bh = drw->fonts->h + 2;
|
bh = MAX(drw->fonts->h + 2, lineheight); /* at least line height */
|
||||||
bh = MAX(bh,lineheight); /* make a menu line AT LEAST 'lineheight' tall */
|
|
||||||
mh = (center) ? bh * 2 : bh;
|
mh = (center) ? bh * 2 : bh;
|
||||||
#ifdef XINERAMA
|
#ifdef XINERAMA
|
||||||
info = XineramaQueryScreens(dpy, &n);
|
info = XineramaQueryScreens(dpy, &n);
|
||||||
@ -383,8 +399,8 @@ setup(void) {
|
|||||||
y = info[i].y_org + ((info[i].height - mh) / 2);
|
y = info[i].y_org + ((info[i].height - mh) / 2);
|
||||||
} else {
|
} else {
|
||||||
x = info[i].x_org;
|
x = info[i].x_org;
|
||||||
y = info[i].y_org + (bottom ? info[i].height - mh - (borderwidth * 2) : 0);
|
y = info[i].y_org + (bottom ? info[i].height - mh : 0);
|
||||||
mw = info[i].width - (borderwidth * 2);
|
mw = info[i].width;
|
||||||
}
|
}
|
||||||
|
|
||||||
XFree(info);
|
XFree(info);
|
||||||
@ -401,8 +417,8 @@ setup(void) {
|
|||||||
y = (wa.height - mh) / 2;
|
y = (wa.height - mh) / 2;
|
||||||
} else {
|
} else {
|
||||||
x = 0;
|
x = 0;
|
||||||
y = bottom ? wa.height - mh - (borderwidth * 2) : 0;
|
y = bottom ? wa.height - mh : 0;
|
||||||
mw = wa.width - (borderwidth * 2);
|
mw = wa.width;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user