summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRich Felker <dalias@aerifal.cx>2006-10-13 09:34:52 +0000
committerRich Felker <dalias@aerifal.cx>2006-10-13 09:34:52 +0000
commit1be19cd1616635c07a4955a2619b9aeaa3efebc6 (patch)
tree88daae574de79dae9c190734858f070e47ee8959
parentd1f8097ce218ee19500b7ed551fe67fbb5d2c01c (diff)
downloaduuterm-1be19cd1616635c07a4955a2619b9aeaa3efebc6.tar.gz
try to support non-latin input.. does this work?
-rw-r--r--xlib.c38
1 files 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);