x11.xim: lookup-string, always use same buf and simplify
parent
2f92f29d2a
commit
3e84d30760
|
@ -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 ;
|
||||
|
|
Loading…
Reference in New Issue