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.files io.styles
7 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 ;
12 IN: ui.tools.operations
14 V{ } clone operations set-global
17 [ drop t ] \ inspect H{
22 : com-prettyprint ( obj -- ) . ;
24 [ drop t ] \ com-prettyprint H{
28 : com-push ( obj -- obj ) ;
30 [ drop t ] \ com-push H{
34 : com-unparse ( obj -- ) unparse listener-input ;
36 [ drop t ] \ com-unparse H{ } define-operation
40 : com-input ( obj -- ) string>> listener-input ;
42 [ input? ] \ com-input H{
48 [ restart? ] \ restart H{
55 [ continuation? ] \ traceback-window H{
61 : edit-file ( pathname -- ) edit ;
63 [ pathname? ] \ edit-file H{
64 { +keyboard+ T{ key-down f { C+ } "E" } }
70 UNION: definition word method-spec link vocab vocab-link ;
72 [ definition? ] \ edit H{
73 { +keyboard+ T{ key-down f { C+ } "E" } }
77 : com-forget ( defspec -- )
78 [ forget ] with-compilation-unit ;
80 [ definition? ] \ com-forget H{ } define-operation
83 [ word? ] \ insert-word H{
87 [ topic? ] \ com-follow H{
88 { +keyboard+ T{ key-down f { C+ } "H" } }
92 : com-usage ( word -- )
93 get-workspace swap show-word-usage ;
95 [ word? ] \ com-usage H{
96 { +keyboard+ T{ key-down f { C+ } "U" } }
100 { +keyboard+ T{ key-down f { C+ } "F" } }
104 [ word? ] \ watch H{ } define-operation
106 [ word? ] \ breakpoint H{ } define-operation
108 GENERIC: com-stack-effect ( obj -- )
110 M: quotation com-stack-effect infer. ;
112 M: word com-stack-effect def>> com-stack-effect ;
114 [ word? ] \ com-stack-effect H{
119 : com-vocab-words ( vocab -- )
120 get-workspace swap show-vocab-words ;
122 [ vocab? ] \ com-vocab-words H{
124 { +keyboard+ T{ key-down f { C+ } "B" } }
127 : com-enter-in ( vocab -- ) vocab-name set-in ;
129 [ vocab? ] \ com-enter-in H{
130 { +keyboard+ T{ key-down f { C+ } "I" } }
134 : com-use-vocab ( vocab -- ) vocab-name use+ ;
136 [ vocab-spec? ] \ com-use-vocab H{
141 [ vocab-spec? ] \ run H{
142 { +keyboard+ T{ key-down f { C+ } "R" } }
147 { +keyboard+ T{ key-down f { C+ } "T" } }
151 [ vocab-spec? ] \ deploy-tool H{ } define-operation
154 [ quotation? ] \ com-stack-effect H{
155 { +keyboard+ T{ key-down f { C+ } "i" } }
159 [ quotation? ] \ walk H{
160 { +keyboard+ T{ key-down f { C+ } "w" } }
164 [ quotation? ] \ time H{
165 { +keyboard+ T{ key-down f { C+ } "t" } }
169 : com-show-profile ( workspace -- )
170 profiler-gadget call-tool ;
172 : com-profile ( quot -- ) profile f com-show-profile ;
174 [ quotation? ] \ com-profile H{
175 { +keyboard+ T{ key-down f { C+ } "r" } }
179 ! Profiler presentations
180 [ dup usage-profile? swap vocab-profile? or ]
181 \ com-show-profile H{ { +primary+ t } } define-operation
183 ! Operations -> commands
186 "These commands operate on the Factor word named by the token at the caret position."
189 [ dup search [ ] [ no-word ] ?if ]
194 "These commands operate on the entire contents of the input area."
197 [ [ parse-lines ] with-compilation-unit ]