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 > _ head? ] all-words swap filter [ name>> ] map ; : clear-completions ( -- ) f completions tset ; : get-completions ( prefix -- completions ) completions tget dup [ nip ] [ drop prefixed-words dup completions tset ] if ; PRIVATE> : readline ( prompt -- str ) [ readline.ffi:readline [ |free utf8 alien>string [ [ ] [ readline.ffi:add_history ] if-empty ] keep ] [ f ] if* ] with-destructors ; : word-completion ( -- alien ) [| name state | state name get-completions ?nth [ utf8 malloc-string ] [ clear-completions f ] if* ] readline.ffi:rl_compentry_func_t ; word-completion readline.ffi:set-rl_completion_entry_function