]> gitweb.factorcode.org Git - factor.git/commitdiff
readline-listener: implement pathname completion
authorJohn Benediktsson <mrjbq7@gmail.com>
Wed, 7 Dec 2022 00:42:15 +0000 (16:42 -0800)
committerJohn Benediktsson <mrjbq7@gmail.com>
Wed, 7 Dec 2022 00:42:15 +0000 (16:42 -0800)
extra/readline-listener/readline-listener.factor

index b40b070e8f1f2df07b3298596afacbaa0909305a..dd327c8f49b6e6dba6dbd4ed4daf16ca5f31411e 100644 (file)
@@ -43,12 +43,16 @@ M: readline-reader prompt.
 : prefixed-chars ( prefix -- chars )
     name-map keys prefixed ;
 
+: prefixed-paths ( prefix -- paths )
+    dup paths-matching keys prefixed ;
+
 : get-completions ( prefix -- completions )
     completions tget [ nip ] [
         completion-line " \r\n" split {
             { [ dup complete-vocab? ] [ drop prefixed-vocabs ] }
             { [ dup complete-char? ] [ drop prefixed-chars ] }
             { [ dup complete-color? ] [ drop prefixed-colors ] }
+            { [ dup complete-pathname? ] [ drop prefixed-paths ] }
             { [ dup complete-vocab-words? ] [ harvest second prefixed-vocab-words ] }
             [ drop prefixed-words ]
         } cond dup completions tset