readline-listener: fix tab completion to complete from where the pointer is.

db4
John Benediktsson 2012-09-25 14:13:42 -07:00
parent 61fa05942b
commit 2f4573b6f4
2 changed files with 4 additions and 1 deletions

View File

@ -39,7 +39,7 @@ M: readline-reader prompt.
: get-completions ( prefix -- completions ) : get-completions ( prefix -- completions )
completions tget [ nip ] [ completions tget [ nip ] [
current-line " \r\n" split { completion-line " \r\n" split {
{ [ dup complete-vocab? ] [ drop prefixed-vocabs ] } { [ dup complete-vocab? ] [ drop prefixed-vocabs ] }
{ [ dup complete-CHAR:? ] [ drop prefixed-chars ] } { [ dup complete-CHAR:? ] [ drop prefixed-chars ] }
{ [ dup complete-COLOR:? ] [ drop prefixed-colors ] } { [ dup complete-COLOR:? ] [ drop prefixed-colors ] }

View File

@ -18,6 +18,9 @@ IN: readline
: current-line ( -- str ) : current-line ( -- str )
readline.ffi:rl_line_buffer ; readline.ffi:rl_line_buffer ;
: completion-line ( -- str )
current-line readline.ffi:rl_point head ;
: has-readline? ( -- ? ) : has-readline? ( -- ? )
"readline" dup load-library dlsym-raw >boolean ; "readline" dup load-library dlsym-raw >boolean ;