confirm mode confirmed
This commit is contained in:
parent
377dc49065
commit
2df401ad8c
3 changed files with 74 additions and 37 deletions
1
BUGS
Normal file
1
BUGS
Normal file
|
@ -0,0 +1 @@
|
|||
* Xorg error when trying to intiate promptwin second time in one session
|
1
TODO
1
TODO
|
@ -1,3 +1,4 @@
|
|||
* replace pinentry's code with our own talker to gpg-agent
|
||||
* look over code and see what I broke while copypasting code from dmenu
|
||||
* get licenses in order
|
||||
* fallback TTY mode
|
43
spine.c
43
spine.c
|
@ -31,6 +31,8 @@ const char *str_ERRNOTIMP = "ERR4100 not implemented yet\n";
|
|||
|
||||
/* enums */
|
||||
enum { SchemeNorm, SchemeSel, SchemeLast }; /* color schemes */
|
||||
enum {WinPin, WinConfirm}; /* window modes */
|
||||
enum {Ok, NotOk, Cancel}; /* return status */
|
||||
|
||||
static char text[2048] = "";
|
||||
static int bh, mw, mh;
|
||||
|
@ -50,6 +52,9 @@ static int sw, sh;
|
|||
|
||||
static int timed_out;
|
||||
|
||||
static int confirmed;
|
||||
static int winmode;
|
||||
|
||||
pinentry_t pinentry;
|
||||
|
||||
#include "config.h"
|
||||
|
@ -123,11 +128,14 @@ drawwin(void){
|
|||
seccursor = n;
|
||||
}
|
||||
}
|
||||
|
||||
if (winmode==WinPin) {
|
||||
drw_text(drw, x, y, mw, bh, sectext, 0);
|
||||
if((curpos = TEXTNW(sectext, seccursor) + bh/2 - 2) < w) {
|
||||
drw_rect(drw, x + curpos + 2, y + 2, 1 , bh-4 , True, 1, 0);
|
||||
}
|
||||
} else {
|
||||
drw_text(drw, x, y, mw, bh, "(y/n)", 0);
|
||||
}
|
||||
|
||||
drw_map(drw, win, 0, 0, mw, mh);
|
||||
}
|
||||
|
@ -190,6 +198,25 @@ keypress(XKeyEvent *ev) {
|
|||
len = XmbLookupString(xic, ev, buf, sizeof buf, &ksym, &status);
|
||||
if (status == XBufferOverflow)
|
||||
return 0;
|
||||
if (winmode == WinConfirm){
|
||||
switch(ksym){
|
||||
case XK_KP_Enter:
|
||||
case XK_Return:
|
||||
case XK_y:
|
||||
confirmed = 1;
|
||||
return 1;
|
||||
break;
|
||||
case XK_n:
|
||||
confirmed = 0;
|
||||
return 1;
|
||||
break;
|
||||
case XK_Escape:
|
||||
pinentry->canceled = 1;
|
||||
confirmed = 0;
|
||||
return 1;
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
switch(ksym){
|
||||
default:
|
||||
if (!iscntrl(*buf))
|
||||
|
@ -206,8 +233,10 @@ keypress(XKeyEvent *ev) {
|
|||
insert(NULL, nextrune(cursor, -1) - cursor);
|
||||
break;
|
||||
case XK_Escape:
|
||||
cleanup();
|
||||
exit(1);
|
||||
pinentry->canceled = 1;
|
||||
return 1;
|
||||
/*cleanup();
|
||||
exit(1);*/
|
||||
break;
|
||||
case XK_Left:
|
||||
if(cursor > 0) {
|
||||
|
@ -224,6 +253,7 @@ keypress(XKeyEvent *ev) {
|
|||
return 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
drawwin();
|
||||
return 0;
|
||||
}
|
||||
|
@ -299,7 +329,9 @@ catchsig(int sig)
|
|||
|
||||
static int
|
||||
password (void) {
|
||||
winmode = WinPin;
|
||||
promptwin();
|
||||
if (pinentry->canceled) return -1;
|
||||
char *buf = secmem_malloc(strlen(text));
|
||||
strcpy(buf, text);
|
||||
pinentry_setbuffer_use (pinentry, buf, 0);
|
||||
|
@ -308,7 +340,10 @@ password (void) {
|
|||
|
||||
static int
|
||||
confirm(void) {
|
||||
return 1;
|
||||
winmode = WinConfirm;
|
||||
confirmed = 0;
|
||||
promptwin();
|
||||
return confirmed;
|
||||
}
|
||||
|
||||
int
|
||||
|
|
Loading…
Reference in a new issue