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