diff options
| author | Mark Edgar <medgar123@gmail.com> | 2013-10-05 11:45:17 +0200 |
|---|---|---|
| committer | Roberto E. Vargas Caballero <k0ga@shike2.com> | 2013-10-07 20:56:51 +0200 |
| commit | 02ae3ce6fdc178ca6eb9b10b6447bb56a6513a27 (patch) | |
| tree | 43139a5428d7611793677c5ff26652659542bec4 | |
| parent | 7a4eefe87cb7661c8a77286d05b6c3afb467f806 (diff) | |
| download | st-02ae3ce6fdc178ca6eb9b10b6447bb56a6513a27.tar.gz st-02ae3ce6fdc178ca6eb9b10b6447bb56a6513a27.zip | |
Simplify Mod1 logic in kpress(), eliminating locals and a memcpy.
| -rw-r--r-- | st.c | 23 |
1 files changed, 10 insertions, 13 deletions
| @@ -3563,8 +3563,8 @@ void | |||
| 3563 | kpress(XEvent *ev) { | 3563 | kpress(XEvent *ev) { |
| 3564 | XKeyEvent *e = &ev->xkey; | 3564 | XKeyEvent *e = &ev->xkey; |
| 3565 | KeySym ksym; | 3565 | KeySym ksym; |
| 3566 | char xstr[31], buf[32], *customkey, *cp = buf; | 3566 | char buf[32], *customkey; |
| 3567 | int len, ret; | 3567 | int len; |
| 3568 | long c; | 3568 | long c; |
| 3569 | Status status; | 3569 | Status status; |
| 3570 | Shortcut *bp; | 3570 | Shortcut *bp; |
| @@ -3572,7 +3572,7 @@ kpress(XEvent *ev) { | |||
| 3572 | if(IS_SET(MODE_KBDLOCK)) | 3572 | if(IS_SET(MODE_KBDLOCK)) |
| 3573 | return; | 3573 | return; |
| 3574 | 3574 | ||
| 3575 | len = XmbLookupString(xw.xic, e, xstr, sizeof(xstr), &ksym, &status); | 3575 | len = XmbLookupString(xw.xic, e, buf, sizeof buf, &ksym, &status); |
| 3576 | e->state &= ~Mod2Mask; | 3576 | e->state &= ~Mod2Mask; |
| 3577 | /* 1. shortcuts */ | 3577 | /* 1. shortcuts */ |
| 3578 | for(bp = shortcuts; bp < shortcuts + LEN(shortcuts); bp++) { | 3578 | for(bp = shortcuts; bp < shortcuts + LEN(shortcuts); bp++) { |
| @@ -3586,26 +3586,23 @@ kpress(XEvent *ev) { | |||
| 3586 | if((customkey = kmap(ksym, e->state))) { | 3586 | if((customkey = kmap(ksym, e->state))) { |
| 3587 | len = strlen(customkey); | 3587 | len = strlen(customkey); |
| 3588 | memcpy(buf, customkey, len); | 3588 | memcpy(buf, customkey, len); |
| 3589 | /* 3. hardcoded (overrides X lookup) */ | 3589 | /* 3. composed string from input method */ |
| 3590 | } else { | 3590 | } else { |
| 3591 | if(len == 0) | 3591 | if(len == 0) |
| 3592 | return; | 3592 | return; |
| 3593 | 3593 | ||
| 3594 | if(len == 1 && e->state & Mod1Mask) { | 3594 | if(len == 1 && e->state & Mod1Mask) { |
| 3595 | if(IS_SET(MODE_8BIT)) { | 3595 | if(IS_SET(MODE_8BIT)) { |
| 3596 | if(*xstr < 0177) { | 3596 | if(*buf < 0177) { |
| 3597 | c = *xstr | 0x80; | 3597 | c = *buf | 0x80; |
| 3598 | ret = utf8encode(&c, cp); | 3598 | len = utf8encode(&c, buf); |
| 3599 | cp += ret; | ||
| 3600 | len = 0; | ||
| 3601 | } | 3599 | } |
| 3602 | } else { | 3600 | } else { |
| 3603 | *cp++ = '\033'; | 3601 | buf[1] = buf[0]; |
| 3602 | buf[0] = '\033'; | ||
| 3603 | len = 2; | ||
| 3604 | } | 3604 | } |
| 3605 | } | 3605 | } |
| 3606 | |||
| 3607 | memcpy(cp, xstr, len); | ||
| 3608 | len = cp - buf + len; | ||
| 3609 | } | 3606 | } |
| 3610 | 3607 | ||
| 3611 | ttywrite(buf, len); | 3608 | ttywrite(buf, len); |
