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