! Copyright (C) 2005, 2009 Slava Pestov.
! See https://factorcode.org/license.txt for BSD license.
USING: accessors arrays assocs colors combinators
-combinators.short-circuit io.directories io.files io.files.info
-io.pathnames kernel make math math.order sequences
+combinators.short-circuit editors io.directories io.files
+io.files.info io.pathnames kernel make math math.order sequences
sequences.private sorting splitting splitting.monotonic unicode
unicode.data vocabs vocabs.hierarchy ;
IN: tools.completion
: colors-matching ( str -- seq )
named-colors dup zip completions ;
+: editors-matching ( str -- seq )
+ available-editors [ "editors." ?head drop ] map dup zip completions ;
+
: strings-matching ( str seq -- seq' )
dup zip completions keys ;
: complete-color? ( tokens -- ? ) "COLOR:" complete-token? ;
+: complete-editor? ( tokens -- ? ) "EDITOR:" complete-token? ;
+
<PRIVATE
: complete-string? ( tokens token -- ? )
C: <vocab-word-completion> vocab-word-completion
SINGLETONS: vocab-completion color-completion char-completion
-path-completion history-completion ;
+editor-completion path-completion history-completion ;
UNION: definition-completion word-completion
vocab-word-completion vocab-completion ;
UNION: code-completion definition-completion
-color-completion char-completion path-completion ;
+color-completion char-completion editor-completion
+path-completion ;
UNION: listener-completion code-completion history-completion ;
GENERIC: completion-quot ( interactor completion-mode -- quot )
M: vocab-word-completion completion-quot nip vocab-name>> '[ _ vocab-words-matching ] ;
M: vocab-completion completion-quot [ vocabs-matching ] (completion-quot) ;
M: color-completion completion-quot [ colors-matching ] (completion-quot) ;
+M: editor-completion completion-quot [ editors-matching ] (completion-quot) ;
M: char-completion completion-quot [ chars-matching ] (completion-quot) ;
M: path-completion completion-quot [ paths-matching ] (completion-quot) ;
M: history-completion completion-quot drop '[ _ history-completions ] ;
M: vocab-word-completion completion-banner drop "Words" ;
M: vocab-completion completion-banner drop "Vocabularies" ;
M: color-completion completion-banner drop "Colors" ;
+M: editor-completion completion-banner drop "Editors" ;
M: char-completion completion-banner drop "Unicode code point names" ;
M: path-completion completion-banner drop "Paths" ;
M: history-completion completion-banner drop "Input history" ;
{ [ dup complete-vocab? ] [ 2drop vocab-completion ] }
{ [ dup complete-char? ] [ 2drop char-completion ] }
{ [ dup complete-color? ] [ 2drop color-completion ] }
+ { [ dup complete-editor? ] [ 2drop editor-completion ] }
{ [ dup complete-pathname? ] [ 2drop path-completion ] }
{ [ dup complete-vocab-words? ] [ nip harvest second <vocab-word-completion> ] }
[ drop <word-completion> ]
! Copyright (C) 2011 Erik Charlebois.
! See https://factorcode.org/license.txt for BSD license.
-USING: accessors assocs colors combinators io kernel listener
-readline sequences sets splitting threads tools.completion
-unicode.data vocabs vocabs.hierarchy ;
+USING: accessors assocs colors combinators editors io kernel
+listener readline sequences sets splitting threads
+tools.completion unicode.data vocabs vocabs.hierarchy ;
IN: readline-listener
: prefixed-colors ( prefix -- colors )
named-colors prefixed ;
+: prefixed-editors ( prefix -- editors )
+ available-editors [ "editors." ?head drop ] map prefixed ;
+
: prefixed-chars ( prefix -- chars )
name-map keys prefixed ;
{ [ dup complete-vocab? ] [ drop prefixed-vocabs ] }
{ [ dup complete-char? ] [ drop prefixed-chars ] }
{ [ dup complete-color? ] [ drop prefixed-colors ] }
+ { [ dup complete-editor? ] [ drop prefixed-editors ] }
{ [ dup complete-pathname? ] [ drop prefixed-paths ] }
{ [ dup complete-vocab-words? ] [ harvest second prefixed-vocab-words ] }
[ drop prefixed-words ]