pinentry-dmenu

a pinentry program based on dmenu
git clone anongit@rnpnr.xyz:pinentry-dmenu.git
Log | Files | Refs | Feed | README | LICENSE

Commit: e2dd7745e15d3a5c1709c8078d39a0af0dd6982a
Parent: 07b14f1e91beb96591b210bc7b1cd75a516d646d
Author: Moritz Luedecke
Date:   Sun, 24 Sep 2017 23:59:51 +0200

Add key bindings from dmenu

Diffstat:
Mpinentry-dmenu.c | 44++++++++++++++++++++++++++++++++++++++++----
1 file changed, 40 insertions(+), 4 deletions(-)

diff --git a/pinentry-dmenu.c b/pinentry-dmenu.c @@ -392,13 +392,25 @@ keypress_confirm(XKeyEvent *ev, KeySym ksym) { case XK_N: sel = No; return 1; + case XK_g: + case XK_G: case XK_Escape: pinentry->canceled = 1; sel = No; return 1; + case XK_h: + case XK_j: + case XK_Home: case XK_Left: + case XK_Prior: + case XK_Up: sel = No; break; + case XK_k: + case XK_l: + case XK_Down: + case XK_End: + case XK_Next: case XK_Right: sel = Yes; break; @@ -409,13 +421,34 @@ keypress_confirm(XKeyEvent *ev, KeySym ksym) { static int keypress_pin(XKeyEvent *ev, KeySym ksym, char* buf, int len) { + int old; + if (ev->state & ControlMask) { switch(ksym) { + case XK_a: ksym = XK_Home; break; + case XK_b: ksym = XK_Left; break; + case XK_c: ksym = XK_Escape; break; + case XK_d: ksym = XK_Delete; break; + case XK_e: ksym = XK_End; break; + case XK_f: ksym = XK_Right; break; + case XK_g: ksym = XK_Escape; break; + case XK_h: ksym = XK_BackSpace; break; + case XK_k: + old = cursor; + cursor = strlen(pin); + insert(NULL, old - cursor); + break; + case XK_u: + insert(NULL, -cursor); + break; case XK_v: XConvertSelection(dpy, (ev->state & ShiftMask) ? clip : XA_PRIMARY, utf8, utf8, win, CurrentTime); return 0; - case XK_c: + case XK_Return: + case XK_KP_Enter: + break; + case XK_bracketleft: pinentry->canceled = 1; return 1; default: @@ -439,9 +472,6 @@ keypress_pin(XKeyEvent *ev, KeySym ksym, char* buf, int len) { case XK_Escape: pinentry->canceled = 1; return 1; - //Cleanup(); - //exit(1); - break; case XK_Left: if (cursor > 0) { cursor = nextrune(cursor, -1); @@ -452,6 +482,12 @@ keypress_pin(XKeyEvent *ev, KeySym ksym, char* buf, int len) { cursor = nextrune(cursor, +1); } break; + case XK_Home: + cursor = 0; + break; + case XK_End: + cursor = strlen(pin); + break; case XK_Return: case XK_KP_Enter: return 1;