diff --git a/TODO.FACTOR.txt b/TODO.FACTOR.txt index 9814298fae..08a89a2410 100644 --- a/TODO.FACTOR.txt +++ b/TODO.FACTOR.txt @@ -5,8 +5,8 @@ new browser: - scroll to existing won't work - initial scroll dim is wrong - show callers -listener: -- show IN: + +- alternative way to invoke 2/3 buttons on one-button mice using modifiers - list of key bindings - RT_WORD should refer to XTs not word objects. - services do not launch if factor not running diff --git a/doc/handbook/tools.facts b/doc/handbook/tools.facts index e4b67856b1..5475253bd2 100644 --- a/doc/handbook/tools.facts +++ b/doc/handbook/tools.facts @@ -1,6 +1,6 @@ USING: definitions errors help image inspector io kernel listener memory modules parser prettyprint sequences test -words jedit ; +words jedit shells ; ARTICLE: "tools" "Development tools" "This section covers words which are used during development, and not usually invoked directly by user code." @@ -36,10 +36,9 @@ $terpri "Note that calls to " { $link .s } " can also be included inside words as a debugging aid, however a more convenient way to achieve this is to use the annotation facility. See " { $link "annotations" } "." $terpri "You can start a nested listener or exit a listener using the following words:" -{ $subsection listener } +{ $subsection tty } { $subsection bye } "The following variables can be rebound inside a nested scope to customize the behavior of a listener; this can be done to create a development tool with a custom interaction loop:" -{ $subsection listener-prompt } { $subsection listener-hook } "Finally, the multi-line expression reading word can be used independently of the rest of the listener:" { $subsection read-multiline } ; diff --git a/library/tools/inspector.factor b/library/tools/inspector.factor index d89865ad04..a48a9855fb 100644 --- a/library/tools/inspector.factor +++ b/library/tools/inspector.factor @@ -19,27 +19,21 @@ SYMBOL: inspector-stack dup summary print sheet sheet-numbers sheet. ; -: inspector-help ( -- ) - terpri - "Object inspector." print - terpri - "inspecting ( -- obj ) push current object" print - "go ( n -- ) inspect nth slot" print - "up -- return to previous object" print - "bye -- exit inspector" print ; - -: inspector ( obj -- ) - [ - inspector-help - terpri - "inspector " listener-prompt set - V{ } clone inspector-stack set - (inspect) - ] listener ; - -: inspect ( obj -- ) - inspector-stack get [ (inspect) ] [ inspector ] if ; - : go ( n -- ) 1- inspector-slots get nth (inspect) ; : up ( -- ) inspector-stack get dup pop* pop (inspect) ; + +: inspector-help ( -- ) + "Object inspector." print + terpri + "up -- return to previous object" [ up ] print-input + "inspecting ( -- obj ) push current object" [ inspecting ] print-input + "go ( n -- ) inspect nth slot" print ; + +: inspector ( obj -- ) + inspector-help + V{ } clone inspector-stack set + (inspect) ; + +: inspect ( obj -- ) + inspector-stack get [ (inspect) ] [ inspector ] if ; diff --git a/library/tools/listener.factor b/library/tools/listener.factor index 17fbac1385..0d26024148 100644 --- a/library/tools/listener.factor +++ b/library/tools/listener.factor @@ -4,13 +4,8 @@ IN: listener USING: errors hashtables io kernel math memory namespaces parser sequences strings styles vectors words ; -SYMBOL: listener-prompt SYMBOL: quit-flag - SYMBOL: listener-hook -SYMBOL: eval-hook - -"ok " listener-prompt set-global : bye ( -- ) quit-flag on ; @@ -31,21 +26,13 @@ SYMBOL: eval-hook ] with-parser in set ; : listen ( -- ) - listener-prompt get write flush [ + in get write "> " write flush [ listener-hook get call - read-multiline [ eval-hook get call ] [ drop bye ] if + read-multiline [ call ] [ drop bye ] if ] try ; -: (listener) ( -- ) - quit-flag get [ quit-flag off ] [ listen (listener) ] if ; - -: listener ( quot -- ) - [ - use [ clone ] change - [ call ] eval-hook set - call - (listener) - ] with-scope ; +: listener ( -- ) + quit-flag get [ quit-flag off ] [ listen listener ] if ; : print-banner ( -- ) "Factor " write version write @@ -53,7 +40,12 @@ SYMBOL: eval-hook IN: shells -: tty [ print-banner ] listener ; +: tty ( -- ) + [ + use [ clone ] change + print-banner + listener + ] with-scope ; IN: listener diff --git a/library/tools/listener.facts b/library/tools/listener.facts index 9c336f3681..4f2bbb3c80 100644 --- a/library/tools/listener.facts +++ b/library/tools/listener.facts @@ -1,11 +1,8 @@ IN: listener -USING: help kernel ; - -HELP: listener-prompt -{ $var-description "Variable holding a string printed before each line of input read by the listener." } ; +USING: help kernel shells ; HELP: quit-flag -{ $var-description "Variable set to true by " { $link bye } " word; it forces the next iteration of the " { $link (listener) } " loop to end." } ; +{ $var-description "Variable set to true by " { $link bye } " word; it forces the next iteration of the " { $link listener } " loop to end." } ; HELP: listener-hook { $var-description "Variable holding a quotation called by the listener before reading each line of input. The UI sets this variable to a quotation which updates the stack display in a listener gadget." } ; @@ -22,11 +19,11 @@ HELP: listen { $description "Prompts for an expression on the default stream and evaluates it. On end of file, " { $link quit-flag } " is set to terminate the listener loop." } { $errors "If the expression input by the user throws an error, the error is printed to the default stream and the word returns normally." } ; -HELP: (listener) -{ $description "Prompts for expressions on the default stream and evaluates them until end of file is reached. This is an internal word; call " { $link listener } " instead." } ; - -HELP: listener -{ $description "Starts a listener prompting for expressions on the default stream." } ; - HELP: print-banner { $description "Print Factor version, operating system, and CPU architecture." } ; + +HELP: listener +{ $description "Prompts for expressions on the default stream and evaluates them until end of file is reached. This is an internal word; call " { $link tty } " instead." } ; + +HELP: tty +{ $description "Starts a listener prompting for expressions on the default stream." } ;