Simplify Mod1 logic in kpress(), eliminating locals and a memcpy.
This commit is contained in:
parent
7a4eefe87c
commit
02ae3ce6fd
23
st.c
23
st.c
|
@ -3563,8 +3563,8 @@ void
|
||||||
kpress(XEvent *ev) {
|
kpress(XEvent *ev) {
|
||||||
XKeyEvent *e = &ev->xkey;
|
XKeyEvent *e = &ev->xkey;
|
||||||
KeySym ksym;
|
KeySym ksym;
|
||||||
char xstr[31], buf[32], *customkey, *cp = buf;
|
char buf[32], *customkey;
|
||||||
int len, ret;
|
int len;
|
||||||
long c;
|
long c;
|
||||||
Status status;
|
Status status;
|
||||||
Shortcut *bp;
|
Shortcut *bp;
|
||||||
|
@ -3572,7 +3572,7 @@ kpress(XEvent *ev) {
|
||||||
if(IS_SET(MODE_KBDLOCK))
|
if(IS_SET(MODE_KBDLOCK))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
len = XmbLookupString(xw.xic, e, xstr, sizeof(xstr), &ksym, &status);
|
len = XmbLookupString(xw.xic, e, buf, sizeof buf, &ksym, &status);
|
||||||
e->state &= ~Mod2Mask;
|
e->state &= ~Mod2Mask;
|
||||||
/* 1. shortcuts */
|
/* 1. shortcuts */
|
||||||
for(bp = shortcuts; bp < shortcuts + LEN(shortcuts); bp++) {
|
for(bp = shortcuts; bp < shortcuts + LEN(shortcuts); bp++) {
|
||||||
|
@ -3586,26 +3586,23 @@ kpress(XEvent *ev) {
|
||||||
if((customkey = kmap(ksym, e->state))) {
|
if((customkey = kmap(ksym, e->state))) {
|
||||||
len = strlen(customkey);
|
len = strlen(customkey);
|
||||||
memcpy(buf, customkey, len);
|
memcpy(buf, customkey, len);
|
||||||
/* 3. hardcoded (overrides X lookup) */
|
/* 3. composed string from input method */
|
||||||
} else {
|
} else {
|
||||||
if(len == 0)
|
if(len == 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if(len == 1 && e->state & Mod1Mask) {
|
if(len == 1 && e->state & Mod1Mask) {
|
||||||
if(IS_SET(MODE_8BIT)) {
|
if(IS_SET(MODE_8BIT)) {
|
||||||
if(*xstr < 0177) {
|
if(*buf < 0177) {
|
||||||
c = *xstr | 0x80;
|
c = *buf | 0x80;
|
||||||
ret = utf8encode(&c, cp);
|
len = utf8encode(&c, buf);
|
||||||
cp += ret;
|
|
||||||
len = 0;
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
*cp++ = '\033';
|
buf[1] = buf[0];
|
||||||
|
buf[0] = '\033';
|
||||||
|
len = 2;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
memcpy(cp, xstr, len);
|
|
||||||
len = cp - buf + len;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ttywrite(buf, len);
|
ttywrite(buf, len);
|
||||||
|
|
Loading…
Reference in New Issue
Block a user