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