-! Copyright (C) 2005, 2007 Slava Pestov.
+! Copyright (C) 2005, 2008 Slava Pestov.
 ! See http://factorcode.org/license.txt for BSD license.
 USING: inspector ui.tools.interactor ui.tools.inspector
 ui.tools.workspace help.markup io io.streams.duplex io.styles

ui.gadgets.panes ui.gadgets.buttons ui.gadgets.scrollers
ui.gadgets.tracks ui.gestures ui.operations vocabs words
prettyprint listener debugger threads boxes concurrency.flags
math arrays ;
IN: ui.tools.listener

TUPLE: listener-gadget input output stack ;

: clear-stack ( listener -- )
    [ clear ] swap (call-listener) ;

GENERIC# word-completion-string 1 ( word listener -- string )

M: method-body word-completion-string
    >r "method-generic" word-prop r> word-completion-string ;

USE: generic.standard.engines.tuple

M: tuple-dispatch-engine-word word-completion-string
    >r "engine-generic" word-prop r> word-completion-string ;

M: word word-completion-string ( word listener -- string )
    >r [ word-name ] [ word-vocabulary ] bi dup vocab-words r>
    input>> interactor-use memq?
    [ drop ] [ [ "USE: " % % " " % % ] "" make ] if ;

: insert-word ( word -- )
    get-workspace
    workspace-listener
    [ word-completion-string ] keep
    input>> user-input ;

: quot-action ( interactor -- lines )
    dup control-value
