--- Andy Gozas. diff --git a/x.c b/x.c index 2a3bd38..c8de29b 100644 --- a/x.c +++ b/x.c _AT_@ -1833,9 +1833,9 @@ void kpress(XEvent *ev) { XKeyEvent *e = &ev->xkey; - KeySym ksym; - char buf[64], *customkey; - int len; + KeySym ksym = NoSymbol; + char buf[64], *p = NULL, *customkey; + int len, overflow = 0; Rune c; Status status; Shortcut *bp; _AT_@ -1843,10 +1843,12 @@ kpress(XEvent *ev) if (IS_SET(MODE_KBDLOCK)) return; - if (xw.ime.xic) + if (xw.ime.xic) { len = XmbLookupString(xw.ime.xic, e, buf, sizeof buf, &ksym, &status); - else + overflow = status == XBufferOverflow ? len : 0; + } else { len = XLookupString(e, buf, sizeof buf, &ksym, NULL); + } /* 1. shortcuts */ for (bp = shortcuts; bp < shortcuts + LEN(shortcuts); bp++) { if (ksym == bp->keysym && match(bp->mod, e->state)) { _AT_@ -1862,21 +1864,33 @@ kpress(XEvent *ev) } /* 3. composed string from input method */ + if (overflow) { + p = xmalloc(overflow); + len = XmbLookupString(xw.ime.xic, e, p, overflow, &ksym, &status); + if (status == XBufferOverflow) { + free(p); + return; + } + } else { + p = buf; + } if (len == 0) return; if (len == 1 && e->state & Mod1Mask) { if (IS_SET(MODE_8BIT)) { - if (*buf < 0177) { - c = *buf | 0x80; - len = utf8encode(c, buf); + if (*p < 0177) { + c = *p | 0x80; + len = utf8encode(c, p); } } else { - buf[1] = buf[0]; - buf[0] = '\033'; + p[1] = p[0]; + p[0] = '\033'; len = 2; } } - ttywrite(buf, len, 1); + ttywrite(p, len, 1); + if (overflow) + free(p); } voidReceived on Mon Oct 24 2022 - 14:16:58 CEST
This archive was generated by hypermail 2.3.0 : Mon Oct 24 2022 - 14:24:36 CEST