x11.xim: lookup-string, always use same buf and simplify

db4
Jon Harper 2016-01-09 20:21:13 +01:00
parent 2f92f29d2a
commit 3e84d30760
1 changed files with 5 additions and 18 deletions

View File

@ -3,7 +3,7 @@
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
@ -35,22 +35,9 @@ 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 ;