]> gitweb.factorcode.org Git - factor.git/blob - basis/ui/tools/operations/operations.factor
e3c3d46904c3c36ff16f971c22954466b17d4bd2
[factor.git] / basis / ui / tools / operations / operations.factor
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
13
14 V{ } clone operations set-global
15
16 ! Objects
17 [ drop t ] \ inspect H{
18     { +primary+ t }
19     { +listener+ t }
20 } define-operation
21
22 : com-prettyprint ( obj -- ) . ;
23
24 [ drop t ] \ com-prettyprint H{
25     { +listener+ t }
26 } define-operation
27
28 : com-push ( obj -- obj ) ;
29
30 [ drop t ] \ com-push H{
31     { +listener+ t }
32 } define-operation
33
34 : com-unparse ( obj -- ) unparse listener-input ;
35
36 [ drop t ] \ com-unparse H{ } define-operation
37
38 ! Input
39
40 : com-input ( obj -- ) string>> listener-input ;
41
42 [ input? ] \ com-input H{
43     { +primary+ t }
44     { +secondary+ t }
45 } define-operation
46
47 ! Restart
48 [ restart? ] \ restart H{
49     { +primary+ t }
50     { +secondary+ t }
51     { +listener+ t }
52 } define-operation
53
54 ! Continuation
55 [ continuation? ] \ traceback-window H{
56     { +primary+ t }
57     { +secondary+ t }
58 } define-operation
59
60 ! Pathnames
61 : edit-file ( pathname -- ) edit ;
62
63 [ pathname? ] \ edit-file H{
64     { +keyboard+ T{ key-down f { C+ } "E" } }
65     { +primary+ t }
66     { +secondary+ t }
67     { +listener+ t }
68 } define-operation
69
70 UNION: definition word method-spec link vocab vocab-link ;
71
72 [ definition? ] \ edit H{
73     { +keyboard+ T{ key-down f { C+ } "E" } }
74     { +listener+ t }
75 } define-operation
76
77 : com-forget ( defspec -- )
78     [ forget ] with-compilation-unit ;
79
80 [ definition? ] \ com-forget H{ } define-operation
81
82 ! Words
83 [ word? ] \ insert-word H{
84     { +secondary+ t }
85 } define-operation
86
87 [ topic? ] \ com-follow H{
88     { +keyboard+ T{ key-down f { C+ } "H" } }
89     { +primary+ t }
90 } define-operation
91
92 : com-usage ( word -- )
93     get-workspace swap show-word-usage ;
94
95 [ word? ] \ com-usage H{
96     { +keyboard+ T{ key-down f { C+ } "U" } }
97 } define-operation
98
99 [ word? ] \ fix H{
100     { +keyboard+ T{ key-down f { C+ } "F" } }
101     { +listener+ t }
102 } define-operation
103
104 [ word? ] \ watch H{ } define-operation
105
106 [ word? ] \ breakpoint H{ } define-operation
107
108 GENERIC: com-stack-effect ( obj -- )
109
110 M: quotation com-stack-effect infer. ;
111
112 M: word com-stack-effect def>> com-stack-effect ;
113
114 [ word? ] \ com-stack-effect H{
115     { +listener+ t }
116 } define-operation
117
118 ! Vocabularies
119 : com-vocab-words ( vocab -- )
120     get-workspace swap show-vocab-words ;
121
122 [ vocab? ] \ com-vocab-words H{
123     { +secondary+ t }
124     { +keyboard+ T{ key-down f { C+ } "B" } }
125 } define-operation
126
127 : com-enter-in ( vocab -- ) vocab-name set-in ;
128
129 [ vocab? ] \ com-enter-in H{
130     { +keyboard+ T{ key-down f { C+ } "I" } }
131     { +listener+ t }
132 } define-operation
133
134 : com-use-vocab ( vocab -- ) vocab-name use+ ;
135
136 [ vocab-spec? ] \ com-use-vocab H{
137     { +secondary+ t }
138     { +listener+ t }
139 } define-operation
140
141 [ vocab-spec? ] \ run H{
142     { +keyboard+ T{ key-down f { C+ } "R" } }
143     { +listener+ t }
144 } define-operation
145
146 [ vocab? ] \ test H{
147     { +keyboard+ T{ key-down f { C+ } "T" } }
148     { +listener+ t }
149 } define-operation
150
151 [ vocab-spec? ] \ deploy-tool H{ } define-operation
152
153 ! Quotations
154 [ quotation? ] \ com-stack-effect H{
155     { +keyboard+ T{ key-down f { C+ } "i" } }
156     { +listener+ t }
157 } define-operation
158
159 [ quotation? ] \ walk H{
160     { +keyboard+ T{ key-down f { C+ } "w" } }
161     { +listener+ t }
162 } define-operation
163
164 [ quotation? ] \ time H{
165     { +keyboard+ T{ key-down f { C+ } "t" } }
166     { +listener+ t }
167 } define-operation
168
169 : com-show-profile ( workspace -- )
170     profiler-gadget call-tool ;
171
172 : com-profile ( quot -- ) profile f com-show-profile ;
173
174 [ quotation? ] \ com-profile H{
175     { +keyboard+ T{ key-down f { C+ } "r" } }
176     { +listener+ t }
177 } define-operation
178
179 ! Profiler presentations
180 [ dup usage-profile? swap vocab-profile? or ]
181 \ com-show-profile H{ { +primary+ t } } define-operation
182
183 ! Operations -> commands
184 source-editor
185 "word"
186 "These commands operate on the Factor word named by the token at the caret position."
187 \ selected-word
188 [ selected-word ]
189 [ dup search [ ] [ no-word ] ?if ] 
190 define-operation-map
191
192 interactor
193 "quotation"
194 "These commands operate on the entire contents of the input area."
195 [ ]
196 [ quot-action ]
197 [ [ parse-lines ] with-compilation-unit ]
198 define-operation-map