tools.completion: better paths-matching.
parent
3049d187f6
commit
6b34719f63
|
@ -2,10 +2,10 @@
|
||||||
! See http://factorcode.org/license.txt for BSD license.
|
! See http://factorcode.org/license.txt for BSD license.
|
||||||
|
|
||||||
USING: accessors arrays assocs colors.constants combinators
|
USING: accessors arrays assocs colors.constants combinators
|
||||||
combinators.short-circuit fry io io.directories kernel locals
|
combinators.short-circuit fry io.directories io.files
|
||||||
make math math.order namespaces sequences sorting splitting
|
io.files.info io.pathnames kernel locals make math math.order
|
||||||
strings unicode.case unicode.categories unicode.data vectors
|
sequences sorting splitting unicode.categories unicode.data
|
||||||
vocabs vocabs.hierarchy words ;
|
vectors vocabs vocabs.hierarchy ;
|
||||||
|
|
||||||
IN: tools.completion
|
IN: tools.completion
|
||||||
|
|
||||||
|
@ -107,8 +107,23 @@ PRIVATE>
|
||||||
: colors-matching ( str -- seq )
|
: colors-matching ( str -- seq )
|
||||||
named-colors dup zip completions ;
|
named-colors dup zip completions ;
|
||||||
|
|
||||||
: paths-matching ( str path -- seq )
|
<PRIVATE
|
||||||
directory-files dup zip completions ;
|
|
||||||
|
: directory-paths ( directory -- paths )
|
||||||
|
dup '[
|
||||||
|
[
|
||||||
|
[ _ prepend-path ]
|
||||||
|
[ file-info directory? [ path-separator append ] when ]
|
||||||
|
bi
|
||||||
|
] map
|
||||||
|
] with-directory-files ;
|
||||||
|
|
||||||
|
PRIVATE>
|
||||||
|
|
||||||
|
: paths-matching ( str -- seq )
|
||||||
|
dup file-directory [ ?head drop ] keep
|
||||||
|
dup { [ exists? ] [ file-info directory? ] } 1&&
|
||||||
|
[ directory-paths dup zip completions ] [ 2drop { } ] if ;
|
||||||
|
|
||||||
<PRIVATE
|
<PRIVATE
|
||||||
|
|
||||||
|
@ -150,3 +165,5 @@ PRIVATE>
|
||||||
: complete-CHAR:? ( tokens -- ? ) "CHAR:" complete-token? ;
|
: complete-CHAR:? ( tokens -- ? ) "CHAR:" complete-token? ;
|
||||||
|
|
||||||
: complete-COLOR:? ( tokens -- ? ) "COLOR:" complete-token? ;
|
: complete-COLOR:? ( tokens -- ? ) "COLOR:" complete-token? ;
|
||||||
|
|
||||||
|
: complete-P"? ( tokens -- ? ) "P\"" complete-token? ;
|
||||||
|
|
Loading…
Reference in New Issue