changeset: 288:9c5ad5303c3c
tag: tip
user: anselm_AT_garbe.us
date: Mon Mar 22 07:50:26 2010 +0000
files: dmenu.c
description:
applied cls' patch, thanks Connor!
diff -r 5ad866449f7a -r 9c5ad5303c3c dmenu.c
--- a/dmenu.c Sun Mar 07 08:32:16 2010 +0000
+++ b/dmenu.c Mon Mar 22 07:50:26 2010 +0000
@@ -372,7 +372,7 @@
void
kpress(XKeyEvent * e) {
- char buf[32];
+ char buf[sizeof text];
int i, num;
unsigned int len;
KeySym ksym;
@@ -457,25 +457,23 @@
char *c;
if(!(fp = (FILE*)popen("sselp", "r")))
eprint("dmenu: Could not popen sselp\n");
- c = fgets(text + len, sizeof(text) - len, fp);
+ c = fgets(buf, sizeof buf, fp);
pclose(fp);
if(c == NULL)
return;
}
- len = strlen(text);
- if(len && text[len-1] == '\n')
- text[--len] = '\0';
- match(text);
- drawmenu();
- return;
+ num = strlen(buf);
+ if(num && buf[num-1] == '\n')
+ buf[--num] = '\0';
+ break;
}
}
switch(ksym) {
default:
+ num = MIN(num, sizeof text - cursor);
if(num && !iscntrl((int) buf[0])) {
- buf[num] = 0;
- memmove(text + cursor + num, text + cursor, sizeof text - cursor);
- strncpy(text + cursor, buf, sizeof text - cursor);
+ memmove(text + cursor + num, text + cursor, sizeof text - cursor - num);
+ memmove(text + cursor, buf, num);
cursor+=num;
match(text);
}
@@ -487,6 +485,10 @@
match(text);
}
break;
+ case XK_Delete:
+ memmove(text + cursor, text + cursor + 1, sizeof text - cursor);
+ match(text);
+ break;
case XK_End:
if(!item)
return;
Received on Mon Mar 22 2010 - 07:50:31 UTC
This archive was generated by hypermail 2.2.0 : Mon Mar 22 2010 - 08:00:09 UTC