USING: alien alien.c-types alien.data alien.strings arrays
byte-arrays hashtables io io.encodings.string kernel math
namespaces sequences strings continuations x11 x11.xlib
-accessors io.encodings.utf8 ;
+accessors io.encodings.utf8 literals ;
IN: x11.xim
SYMBOL: xim
[ "XCreateIC() failed" throw ] unless* ;
CONSTANT: buf-size 100
-
-SYMBOL: keybuf
-SYMBOL: keysym
-
-: prepare-lookup ( -- )
- buf-size <byte-array> keybuf set
- 0 KeySym <ref> keysym set ;
-
-: finish-lookup ( len -- string keysym )
- keybuf get swap head utf8 decode
- keysym get *KeySym ;
+CONSTANT: buf $[ buf-size <byte-array> ]
: lookup-string ( event xic -- string keysym )
- [
- prepare-lookup
- swap keybuf get buf-size keysym get 0 int <ref>
- Xutf8LookupString
- finish-lookup
- ] with-scope ;
+ swap buf buf-size { KeySym } [ 0 int <ref>
+ Xutf8LookupString buf swap head utf8 decode
+ ] with-out-parameters ;