1 ! Copyright (C) 2011 Erik Charlebois.
2 ! See http://factorcode.org/license.txt for BSD license.
3 USING: alien.strings destructors io.encodings.utf8 kernel libc
4 sequences macros quotations words compiler.units fry
6 QUALIFIED: readline.ffi
9 : readline ( prompt -- str )
11 readline.ffi:readline [
12 |free utf8 alien>string [
13 [ ] [ readline.ffi:add_history ] if-empty
18 MACRO: set-completion ( quot -- )
20 '[ @ [ utf8 malloc-string ] [ f ] if* ]
21 '[ _ readline.ffi:rl_compentry_func_t ]
22 (( -- alien )) define-temp
23 ] with-compilation-unit execute
24 '[ _ readline.ffi:set-rl_completion_entry_function ] ;