From 1be19cd1616635c07a4955a2619b9aeaa3efebc6 Mon Sep 17 00:00:00 2001 From: Rich Felker Date: Fri, 13 Oct 2006 09:34:52 +0000 Subject: try to support non-latin input.. does this work? --- xlib.c | 38 ++++++++++++++++++++++++++------------ 1 file changed, 26 insertions(+), 12 deletions(-) diff --git a/xlib.c b/xlib.c index 56f4955..66e70c7 100644 --- a/xlib.c +++ b/xlib.c @@ -112,9 +112,9 @@ int uudisp_open(struct uudisp *d) XMapWindow(p->display, p->window); - //XSetLocaleModifiers("@im=none"); - //p->im = XOpenIM(p->display, 0, 0, 0); - //p->ic = XCreateIC(p->im, XNInputStyle, XIMPreeditNothing|XIMStatusNothing); + XSetLocaleModifiers("@im=none"); + p->im = XOpenIM(p->display, 0, 0, 0); + if (p->im) p->ic = XCreateIC(p->im, XNInputStyle, XIMPreeditNothing|XIMStatusNothing); resize_window(d, px_w, px_h); @@ -233,6 +233,7 @@ void uudisp_next_event(struct uudisp *d, void *fds) unsigned char *s = d->inbuf; char tmp[32], mbtmp[sizeof(tmp)*MB_LEN_MAX]; wchar_t wtmp[sizeof(tmp)]; + int status; int i, n; int y1, y2; @@ -255,15 +256,20 @@ void uudisp_next_event(struct uudisp *d, void *fds) resize_window(d, ev.xconfigure.width, ev.xconfigure.height); break; case KeyPress: -#if 0 - // r = XmbLookupString(p->ic, (void *)&ev, s, l, &ks, &status); - switch(status) { - case XLookupChars: - case XLookupBoth: - // - } -#endif - r = XLookupString((void *)&ev, tmp, sizeof(tmp), &ks, 0); + if (p->ic) { + r = XmbLookupString(p->ic, (void *)&ev, tmp, sizeof(tmp), &ks, &status); + switch(status) { + case XLookupKeySym: + r = 0; + break; + case XLookupChars: + ks = 0; + case XLookupBoth: + break; + default: + continue; + } + } else r = XLookupString((void *)&ev, tmp, sizeof(tmp), &ks, 0); if (r>=sizeof(tmp)) continue; if ((ev.xkey.state & Mod1Mask) && l) { *s++ = '\033'; @@ -289,6 +295,14 @@ void uudisp_next_event(struct uudisp *d, void *fds) } if (!r) continue; + if (p->ic) { + if (r > l) continue; + memcpy(s, tmp, r); + s += r; + l -= r; + continue; + } + /* Deal with Latin-1 crap.. */ for (i=0; i<=r; i++) wtmp[i] = tmp[i]; r = wcstombs(mbtmp, wtmp, sizeof mbtmp); -- cgit v1.2.3