Word completion now adds the word's vocab to the USE: list
parent
cc8e049c02
commit
3697fa1aa3
|
@ -1,11 +1,12 @@
|
||||||
! Copyright (C) 2009 Slava Pestov.
|
! Copyright (C) 2009 Slava Pestov.
|
||||||
! See http://factorcode.org/license.txt for BSD license.
|
! See http://factorcode.org/license.txt for BSD license.
|
||||||
USING: accessors arrays assocs calendar colors documents fry kernel
|
USING: accessors arrays assocs calendar colors documents fry kernel
|
||||||
sets splitting math math.vectors models.delay models.filter
|
words sets splitting math math.vectors models.delay models.filter
|
||||||
combinators.short-circuit parser present sequences tools.completion
|
combinators.short-circuit parser present sequences tools.completion
|
||||||
|
generic generic.standard.engines.tuple
|
||||||
ui.commands ui.gadgets ui.gadgets.editors ui.gadgets.glass
|
ui.commands ui.gadgets ui.gadgets.editors ui.gadgets.glass
|
||||||
ui.gadgets.scrollers ui.gadgets.tables
|
ui.gadgets.scrollers ui.gadgets.tables ui.gadgets.theme
|
||||||
ui.gadgets.theme ui.gadgets.worlds ui.gadgets.wrappers ui.gestures
|
ui.gadgets.worlds ui.gadgets.wrappers ui.gestures
|
||||||
ui.render ui.tools.listener.history ;
|
ui.render ui.tools.listener.history ;
|
||||||
IN: ui.tools.listener.completion
|
IN: ui.tools.listener.completion
|
||||||
|
|
||||||
|
@ -53,11 +54,29 @@ M: completion-popup hide-glass-hook
|
||||||
: completion-loc/doc ( popup -- loc doc )
|
: completion-loc/doc ( popup -- loc doc )
|
||||||
interactor>> [ editor-caret ] [ model>> ] bi ;
|
interactor>> [ editor-caret ] [ model>> ] bi ;
|
||||||
|
|
||||||
|
GENERIC: completion-string ( object -- string )
|
||||||
|
|
||||||
|
M: object completion-string present ;
|
||||||
|
|
||||||
|
: method-completion-string ( word -- string )
|
||||||
|
"method-generic" word-prop present ;
|
||||||
|
|
||||||
|
M: method-body completion-string method-completion-string ;
|
||||||
|
|
||||||
|
M: engine-word completion-string method-completion-string ;
|
||||||
|
|
||||||
|
GENERIC# accept-completion-hook 1 ( item popup -- )
|
||||||
|
|
||||||
|
: insert-completion ( item popup -- )
|
||||||
|
[ completion-string ] [ completion-loc/doc ] bi*
|
||||||
|
one-word-elt set-elt-string ;
|
||||||
|
|
||||||
: accept-completion ( item table -- )
|
: accept-completion ( item table -- )
|
||||||
find-completion-popup
|
find-completion-popup
|
||||||
[ [ present ] [ completion-loc/doc ] bi* one-word-elt set-elt-string ]
|
[ insert-completion ]
|
||||||
[ hide-completion-popup ]
|
[ accept-completion-hook ]
|
||||||
bi ;
|
[ nip hide-completion-popup ]
|
||||||
|
2tri ;
|
||||||
|
|
||||||
: <completion-table> ( interactor quot -- table )
|
: <completion-table> ( interactor quot -- table )
|
||||||
<completion-model> <table>
|
<completion-model> <table>
|
||||||
|
|
|
@ -2,8 +2,8 @@
|
||||||
! See http://factorcode.org/license.txt for BSD license.
|
! See http://factorcode.org/license.txt for BSD license.
|
||||||
USING: accessors arrays assocs calendar combinators
|
USING: accessors arrays assocs calendar combinators
|
||||||
combinators.short-circuit compiler.units concurrency.flags
|
combinators.short-circuit compiler.units concurrency.flags
|
||||||
concurrency.mailboxes continuations destructors documents fry generic
|
concurrency.mailboxes continuations destructors documents
|
||||||
generic.standard.engines.tuple hashtables help help.markup io
|
fry hashtables help help.markup io
|
||||||
io.styles kernel lexer listener math models models.delay models.filter
|
io.styles kernel lexer listener math models models.delay models.filter
|
||||||
namespaces parser prettyprint quotations sequences strings threads
|
namespaces parser prettyprint quotations sequences strings threads
|
||||||
tools.vocabs ui ui.commands ui.gadgets ui.gadgets.buttons
|
tools.vocabs ui ui.commands ui.gadgets ui.gadgets.buttons
|
||||||
|
@ -255,17 +255,6 @@ M: listener-operation invoke-command ( target command -- )
|
||||||
: clear-stack ( listener -- )
|
: clear-stack ( listener -- )
|
||||||
[ clear ] swap (call-listener) ;
|
[ clear ] swap (call-listener) ;
|
||||||
|
|
||||||
GENERIC: word-completion-string ( word -- string )
|
|
||||||
|
|
||||||
M: word word-completion-string name>> ;
|
|
||||||
|
|
||||||
: method-completion-string ( word -- string )
|
|
||||||
"method-generic" word-prop word-completion-string ;
|
|
||||||
|
|
||||||
M: method-body word-completion-string method-completion-string ;
|
|
||||||
|
|
||||||
M: engine-word word-completion-string method-completion-string ;
|
|
||||||
|
|
||||||
: use-if-necessary ( word seq -- )
|
: use-if-necessary ( word seq -- )
|
||||||
2dup [ vocabulary>> ] dip and [
|
2dup [ vocabulary>> ] dip and [
|
||||||
2dup [ assoc-stack ] keep = [ 2drop ] [
|
2dup [ assoc-stack ] keep = [ 2drop ] [
|
||||||
|
@ -273,11 +262,10 @@ M: engine-word word-completion-string method-completion-string ;
|
||||||
] if
|
] if
|
||||||
] [ 2drop ] if ;
|
] [ 2drop ] if ;
|
||||||
|
|
||||||
: insert-word ( word -- )
|
M: word accept-completion-hook
|
||||||
get-listener input>>
|
interactor>> interactor-use use-if-necessary ;
|
||||||
[ [ word-completion-string ] dip user-input* drop ]
|
|
||||||
[ interactor-use use-if-necessary ]
|
M: object accept-completion-hook 2drop ;
|
||||||
2bi ;
|
|
||||||
|
|
||||||
: quot-action ( interactor -- lines )
|
: quot-action ( interactor -- lines )
|
||||||
[ history>> history-add drop ] [ control-value ] [ select-all ] tri
|
[ history>> history-add drop ] [ control-value ] [ select-all ] tri
|
||||||
|
|
Loading…
Reference in New Issue