diff --git a/extra/x11/xim/xim.factor b/extra/x11/xim/xim.factor index 6fb6ada3ae..35e1906b2b 100755 --- a/extra/x11/xim/xim.factor +++ b/extra/x11/xim/xim.factor @@ -7,9 +7,15 @@ IN: x11.xim SYMBOL: xim +: (init-xim) ( classname medifier -- im ) + XSetLocaleModifiers [ "XSetLocaleModifiers() failed" throw ] unless + dpy get f rot dup XOpenIM ; + : init-xim ( classname -- ) - dpy get f rot dup XOpenIM - [ "XOpenIM() failed" throw ] unless* xim set-global ; + dup "" (init-xim) + [ nip ] + [ "@im=none" (init-xim) [ "XOpenIM() failed" throw ] unless* ] if* + xim set-global ; : close-xim ( -- ) xim get-global XCloseIM drop f xim set-global ; @@ -32,11 +38,11 @@ SYMBOL: keybuf SYMBOL: keysym : prepare-lookup ( -- ) - buf-size "ulong" keybuf set + buf-size "uint" keybuf set 0 keysym set ; : finish-lookup ( len -- string keysym ) - keybuf get swap c-ulong-array> >string + keybuf get swap c-uint-array> >string keysym get *KeySym ; : lookup-string ( event xic -- string keysym ) diff --git a/extra/x11/xlib/xlib.factor b/extra/x11/xlib/xlib.factor index 70006c9f64..752c6c442e 100755 --- a/extra/x11/xlib/xlib.factor +++ b/extra/x11/xlib/xlib.factor @@ -1339,10 +1339,28 @@ FUNCTION: int XwcLookupString ( XIC ic, XKeyPressedEvent* event, ulong* buffer_r FUNCTION: int Xutf8LookupString ( XIC ic, XKeyPressedEvent* event, char* buffer_return, int bytes_buffer, KeySym* keysym_return, Status* status_return ) ; +! !!! category of setlocale +: LC_ALL 0 ; inline +: LC_COLLATE 1 ; inline +: LC_CTYPE 2 ; inline +: LC_MONETARY 3 ; inline +: LC_NUMERIC 4 ; inline +: LC_TIME 5 ; inline + +FUNCTION: char* setlocale ( int category, char* name ) ; + +FUNCTION: Bool XSupportsLocale ( ) ; + +FUNCTION: char* XSetLocaleModifiers ( char* modifier_list ) ; + SYMBOL: dpy SYMBOL: scr SYMBOL: root +: init-locale ( -- ) + LC_ALL "" setlocale [ "setlocale() failed" throw ] unless + XSupportsLocale [ "XSupportsLocale() failed" throw ] unless ; + : flush-dpy ( -- ) dpy get XFlush drop ; : x-atom ( string -- atom ) dpy get swap 0 XInternAtom ; @@ -1353,6 +1371,7 @@ SYMBOL: root ] unless* ; : initialize-x ( display-string -- ) + init-locale dup [ string>char-alien ] when XOpenDisplay check-display dpy set-global dpy get XDefaultScreen scr set-global