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