Linux 環境で Factor UI での日本語入力ですが、なんとか次のようなパッチで可能となります。
64bit 環境だと XwcLookupString がうまく動いていなかったのでその辺も対応しています。
できたらフォントまわりも設定可能にしたかったのですが、フォントをコピーすれば表示可能なのでやめました。
diff -ur factor-org/extra/x11/xim/xim.factor factor/extra/x11/xim/xim.factor
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 ;
SYMBOL: keysym
: prepare-lookup ( -- )
- buf-size "ulong" <c-array> keybuf set
+ buf-size "uint" <c-array> keybuf set
0 <KeySym> 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 -ur factor-org/extra/x11/xlib/xlib.factor factor/extra/x11/xlib/xlib.factor
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 ;
] unless* ;
: initialize-x ( display-string -- )
+ init-locale
dup [ string>char-alien ] when
XOpenDisplay check-display dpy set-global
dpy get XDefaultScreen scr set-global
factor/fonts/Makefile
MONO=/usr/share/fonts/truetype/vlgothic/VL-Gothic-Regular.ttf
PRO=/usr/share/fonts/truetype/vlgothic/VL-PGothic-Regular.ttf
all :
ln -fs $(PRO) Vera.ttf
ln -fs $(PRO) VeraBI.ttf
ln -fs $(PRO) VeraBd.ttf
ln -fs $(PRO) VeraIt.ttf
ln -fs $(MONO) VeraMoBI.ttf
ln -fs $(MONO) VeraMoBd.ttf
ln -fs $(MONO) VeraMoIt.ttf
ln -fs $(MONO) VeraMono.ttf
ln -fs $(PRO) VeraSe.ttf
ln -fs $(PRO) VeraSeBd.ttf
ls -l