]> gitweb.factorcode.org Git - factor.git/commitdiff
x11.xim: lookup-string, always use same buf and simplify 1523/head
authorJon Harper <jon.harper87@gmail.com>
Sat, 9 Jan 2016 19:21:13 +0000 (20:21 +0100)
committerJon Harper <jon.harper87@gmail.com>
Sat, 9 Jan 2016 19:21:13 +0000 (20:21 +0100)
basis/x11/xim/xim.factor

index b02d853f10e3f38489c6e5090bdf9e7765dc5c33..a7e4a6fa2662ef4ab06b45370b0b7803266f0329 100644 (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 ;