1 ! Copyright (C) 2006, 2007 Slava Pestov.
2 ! See http://factorcode.org/license.txt for BSD license.
3 USING: continuations definitions ui.tools.browser
4 ui.tools.interactor ui.tools.listener ui.tools.profiler
5 ui.tools.search ui.tools.traceback ui.tools.workspace generic
6 help.topics stack-checker summary inspector io.pathnames
7 io.styles kernel namespaces parser prettyprint quotations
8 tools.annotations editors tools.profiler tools.test tools.time
9 tools.walker ui.commands ui.gadgets.editors ui.gestures
10 ui.operations ui.tools.deploy vocabs vocabs.loader words
11 sequences tools.vocabs classes compiler.units accessors
13 IN: ui.tools.operations
16 [ drop t ] \ inspect H{
21 : com-prettyprint ( obj -- ) . ;
23 [ drop t ] \ com-prettyprint H{
27 : com-push ( obj -- obj ) ;
29 [ drop t ] \ com-push H{
33 : com-unparse ( obj -- ) unparse listener-input ;
35 [ drop t ] \ com-unparse H{ } define-operation
39 : com-input ( obj -- ) string>> listener-input ;
41 [ input? ] \ com-input H{
47 [ restart? ] \ restart H{
54 [ continuation? ] \ traceback-window H{
60 : edit-file ( pathname -- ) edit ;
62 [ pathname? ] \ edit-file H{
63 { +keyboard+ T{ key-down f { C+ } "E" } }
69 UNION: definition word method-spec link vocab vocab-link ;
71 [ definition? ] \ edit H{
72 { +keyboard+ T{ key-down f { C+ } "E" } }
76 : com-forget ( defspec -- )
77 [ forget ] with-compilation-unit ;
79 [ definition? ] \ com-forget H{ } define-operation
82 [ word? ] \ insert-word H{
86 [ topic? ] \ com-follow H{
87 { +keyboard+ T{ key-down f { C+ } "H" } }
91 : com-usage ( word -- )
92 get-workspace swap show-word-usage ;
94 [ word? ] \ com-usage H{
95 { +keyboard+ T{ key-down f { C+ } "U" } }
99 { +keyboard+ T{ key-down f { C+ } "F" } }
103 [ word? ] \ watch H{ } define-operation
105 [ word? ] \ breakpoint H{ } define-operation
107 GENERIC: com-stack-effect ( obj -- )
109 M: quotation com-stack-effect infer. ;
111 M: word com-stack-effect def>> com-stack-effect ;
113 [ word? ] \ com-stack-effect H{
118 : com-vocab-words ( vocab -- )
119 get-workspace swap show-vocab-words ;
121 [ vocab? ] \ com-vocab-words H{
123 { +keyboard+ T{ key-down f { C+ } "B" } }
126 : com-enter-in ( vocab -- ) vocab-name set-in ;
128 [ vocab? ] \ com-enter-in H{
129 { +keyboard+ T{ key-down f { C+ } "I" } }
133 : com-use-vocab ( vocab -- ) vocab-name use+ ;
135 [ vocab-spec? ] \ com-use-vocab H{
140 [ vocab-spec? ] \ run H{
141 { +keyboard+ T{ key-down f { C+ } "R" } }
146 { +keyboard+ T{ key-down f { C+ } "T" } }
150 [ vocab-spec? ] \ deploy-tool H{ } define-operation
153 [ quotation? ] \ com-stack-effect H{
154 { +keyboard+ T{ key-down f { C+ } "i" } }
158 [ quotation? ] \ walk H{
159 { +keyboard+ T{ key-down f { C+ } "w" } }
163 [ quotation? ] \ time H{
164 { +keyboard+ T{ key-down f { C+ } "t" } }
168 : com-show-profile ( workspace -- )
169 profiler-gadget call-tool ;
171 : com-profile ( quot -- ) profile f com-show-profile ;
173 [ quotation? ] \ com-profile H{
174 { +keyboard+ T{ key-down f { C+ } "r" } }
178 ! Profiler presentations
179 [ dup usage-profile? swap vocab-profile? or ]
180 \ com-show-profile H{ { +primary+ t } } define-operation
182 ! Operations -> commands
185 "These commands operate on the Factor word named by the token at the caret position."
188 [ dup search [ ] [ no-word ] ?if ]
193 "These commands operate on the entire contents of the input area."
196 [ [ parse-lines ] with-compilation-unit ]