static int cmdw = 0;
static int promptw = 0;
static int ret = 0;
-static int cursor = 0;
static int screen;
static unsigned int mw, mh;
+static unsigned int cursor = 0;
static unsigned int numlockmask = 0;
static Bool running = True;
static Display *dpy;
void
kpress(XKeyEvent * e) {
char buf[sizeof text];
- int i, num;
- unsigned int len;
+ int num;
+ unsigned int i, len;
KeySym ksym;
len = strlen(text);
return;
/* first check if a control mask is omitted */
if(e->state & ControlMask) {
- switch (ksym) {
+ switch(tolower(ksym)) {
default: /* ignore other control sequences */
return;
case XK_a:
- case XK_A:
ksym = XK_Home;
break;
case XK_c:
- case XK_C:
ksym = XK_Escape;
break;
case XK_e:
- case XK_E:
ksym = XK_End;
break;
case XK_h:
- case XK_H:
ksym = XK_BackSpace;
break;
case XK_i:
- case XK_I:
ksym = XK_Tab;
break;
case XK_j:
- case XK_J:
ksym = XK_Return;
break;
+ case XK_k:
+ text[cursor] = '\0';
+ break;
case XK_u:
- case XK_U:
memmove(text, text + cursor, sizeof text - cursor + 1);
cursor = 0;
match(text);
break;
case XK_w:
- case XK_W:
if(cursor > 0) {
i = cursor;
while(i-- > 0 && text[i] == ' ');
}
break;
case XK_BackSpace:
- if(cursor > 0) {
- for(i = 1; cursor - i > 0 && !IS_UTF8_1ST_CHAR(text[cursor - i]); i++);
- memmove(text + cursor - i, text + cursor, sizeof text - cursor + i);
- cursor -= i;
- match(text);
- }
+ if(cursor == 0)
+ return;
+ for(i = 1; cursor - i > 0 && !IS_UTF8_1ST_CHAR(text[cursor - i]); i++);
+ memmove(text + cursor - i, text + cursor, sizeof text - cursor + i);
+ cursor -= i;
+ match(text);
break;
case XK_Delete:
for(i = 1; cursor + i < len && !IS_UTF8_1ST_CHAR(text[cursor + i]); i++);
case XK_Escape:
ret = 1;
running = False;
- break;
+ return;
case XK_Home:
if(sel == item) {
cursor = 0;
fprintf(stdout, "%s", sel->text);
fflush(stdout);
running = False;
- break;
+ return;
case XK_Right:
case XK_Down:
if(cursor < len)