USING: alien.c-types alien.data alien.libraries alien.strings destructors io io.encodings.utf8 kernel libc locals sequences tools.completion namespaces vocabs accessors prettyprint fry math threads ; QUALIFIED: readline.ffi IN: readline : readline ( prompt -- str ) [ readline.ffi:readline [ |free utf8 alien>string [ [ ] [ readline.ffi:add_history ] if-empty ] keep ] when* ] with-destructors ; SYMBOL: completions : prefixed-words ( prefix -- words ) '[ name>> _ head? ] all-words swap filter [ name>> ] map ; : word-completion ( -- alien ) [| name state | state dup zero? [ name prefixed-words dup completions tset ] [ completions tget ] if ?nth [ utf8 malloc-string ] [ f completions tset f ] if* ] readline.ffi:rl_compentry_func_t ; word-completion "rl_completion_entry_function" "readline" load-library dlsym-raw 0 void* set-alien-value