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
15 V{ } clone operations set-global
18 [ drop t ] \ inspect H{
23 : com-prettyprint ( obj -- ) . ;
25 [ drop t ] \ com-prettyprint H{
29 : com-push ( obj -- obj ) ;
31 [ drop t ] \ com-push H{
35 : com-unparse ( obj -- ) unparse listener-input ;
37 [ drop t ] \ com-unparse H{ } define-operation
41 : com-input ( obj -- ) string>> listener-input ;
43 [ input? ] \ com-input H{
49 [ restart? ] \ restart H{
56 [ continuation? ] \ traceback-window H{
62 : edit-file ( pathname -- ) edit ;
64 [ pathname? ] \ edit-file H{
65 { +keyboard+ T{ key-down f { C+ } "E" } }
71 UNION: definition word method-spec link vocab vocab-link ;
73 [ definition? ] \ edit H{
74 { +keyboard+ T{ key-down f { C+ } "E" } }
78 : com-forget ( defspec -- )
79 [ forget ] with-compilation-unit ;
81 [ definition? ] \ com-forget H{ } define-operation
84 [ word? ] \ insert-word H{
88 [ topic? ] \ com-follow H{
89 { +keyboard+ T{ key-down f { C+ } "H" } }
93 : com-usage ( word -- )
94 get-workspace swap show-word-usage ;
96 [ word? ] \ com-usage H{
97 { +keyboard+ T{ key-down f { C+ } "U" } }
101 { +keyboard+ T{ key-down f { C+ } "F" } }
105 [ word? ] \ watch H{ } define-operation
107 [ word? ] \ breakpoint H{ } define-operation
109 GENERIC: com-stack-effect ( obj -- )
111 M: quotation com-stack-effect infer. ;
113 M: word com-stack-effect def>> com-stack-effect ;
115 [ word? ] \ com-stack-effect H{
120 : com-vocab-words ( vocab -- )
121 get-workspace swap show-vocab-words ;
123 [ vocab? ] \ com-vocab-words H{
125 { +keyboard+ T{ key-down f { C+ } "B" } }
128 : com-enter-in ( vocab -- ) vocab-name set-in ;
130 [ vocab? ] \ com-enter-in H{
131 { +keyboard+ T{ key-down f { C+ } "I" } }
135 : com-use-vocab ( vocab -- ) vocab-name use+ ;
137 [ vocab-spec? ] \ com-use-vocab H{
142 [ vocab-spec? ] \ run H{
143 { +keyboard+ T{ key-down f { C+ } "R" } }
148 { +keyboard+ T{ key-down f { C+ } "T" } }
152 [ vocab-spec? ] \ deploy-tool H{ } define-operation
155 [ quotation? ] \ com-stack-effect H{
156 { +keyboard+ T{ key-down f { C+ } "i" } }
160 [ quotation? ] \ walk H{
161 { +keyboard+ T{ key-down f { C+ } "w" } }
165 [ quotation? ] \ time H{
166 { +keyboard+ T{ key-down f { C+ } "t" } }
170 : com-show-profile ( workspace -- )
171 profiler-gadget call-tool ;
173 : com-profile ( quot -- ) profile f com-show-profile ;
175 [ quotation? ] \ com-profile H{
176 { +keyboard+ T{ key-down f { C+ } "r" } }
180 ! Profiler presentations
181 [ dup usage-profile? swap vocab-profile? or ]
182 \ com-show-profile H{ { +primary+ t } } define-operation
184 ! Operations -> commands
187 "These commands operate on the Factor word named by the token at the caret position."
190 [ dup search [ ] [ no-word ] ?if ]
195 "These commands operate on the entire contents of the input area."
198 [ [ parse-lines ] with-compilation-unit ]