]> gitweb.factorcode.org Git - factor.git/blob - basis/ui/tools/operations/operations.factor
c31492833bb6239b776a22e5c41c39375cdf94c3
[factor.git] / basis / ui / tools / operations / operations.factor
1 ! Copyright (C) 2006, 2009 Slava Pestov.
2 ! See http://factorcode.org/license.txt for BSD license.
3 USING: accessors combinators.short-circuit compiler.errors
4 compiler.units continuations definitions destructors editors
5 help.topics io.pathnames io.styles kernel libc.private
6 macros.expander models parser prettyprint quotations see
7 source-files.errors stack-checker threads tools.annotations
8 tools.crossref tools.test tools.time tools.walker ui.commands
9 ui.gestures ui.operations ui.tools.browser ui.tools.deploy
10 ui.tools.inspector ui.tools.listener ui.tools.traceback vocabs
11 vocabs.loader vocabs.parser words ;
12 IN: ui.tools.operations
13
14 ! Objects
15 [ drop t ] \ inspector H{
16     { +primary+ t }
17 } define-operation
18
19 : com-prettyprint ( obj -- ) . ;
20
21 [ drop t ] \ com-prettyprint H{
22     { +listener+ t }
23 } define-operation
24
25 : com-push ( obj -- obj ) ;
26
27 [ drop t ] \ com-push H{
28     { +listener+ t }
29 } define-operation
30
31 : com-unparse ( obj -- ) unparse listener-input ;
32
33 [ drop t ] \ com-unparse H{ } define-operation
34
35 ! Models
36 [ { [ model? ] [ ref>> ] } 1&& ] \ inspect-model H{
37     { +primary+ t }
38 } define-operation
39
40 ! Input
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? ] \ continue-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 ! Thread
62 : com-thread-traceback-window ( thread -- )
63     thread-continuation traceback-window ;
64
65 [ thread? ] \ com-thread-traceback-window H{
66     { +primary+ t }
67     { +secondary+ t }
68 } define-operation
69
70 [ pathname? ] \ edit-file H{
71     { +keyboard+ T{ key-down f { C+ } "e" } }
72     { +primary+ t }
73     { +secondary+ t }
74     { +listener+ t }
75 } define-operation
76
77 [ definition-mixin? ] \ edit H{
78     { +keyboard+ T{ key-down f { C+ } "e" } }
79     { +listener+ t }
80 } define-operation
81
82 ! Source file error
83 [ source-file-error? ] \ edit-error H{
84     { +primary+ t }
85     { +secondary+ t }
86     { +listener+ t }
87 } define-operation
88
89 : com-reload ( error -- )
90     path>> run-file ;
91
92 [ compiler-error? ] \ com-reload H{
93     { +listener+ t }
94 } define-operation
95
96 ! Definitions
97 : com-forget ( defspec -- )
98     [ forget ] with-compilation-unit ;
99
100 [ definition-mixin? ] \ com-forget H{ } define-operation
101
102 [ topic? ] \ com-browse H{
103     { +keyboard+ T{ key-down f { C+ } "h" } }
104     { +primary+ t }
105 } define-operation
106
107 [ word? ] \ usage. H{
108     { +keyboard+ T{ key-down f { C+ } "u" } }
109     { +listener+ t }
110 } define-operation
111
112 [ word? ] \ fix H{
113     { +keyboard+ T{ key-down f { C+ } "f" } }
114     { +listener+ t }
115 } define-operation
116
117 [ annotated? not ] \ watch H{ } define-operation
118
119 [ annotated? ] \ reset H{ } define-operation
120
121 [ word? ] \ breakpoint H{ } define-operation
122
123 [ word? ] \ see H{
124     { +listener+ t }
125 } define-operation
126
127 GENERIC: com-stack-effect ( obj -- )
128
129 M: quotation com-stack-effect infer. ;
130
131 M: word com-stack-effect 1quotation com-stack-effect ;
132
133 : com-enter-in ( vocab -- ) vocab-name set-current-vocab ;
134
135 [ vocab? ] \ com-enter-in H{
136     { +listener+ t }
137 } define-operation
138
139 : com-use-vocab ( vocab -- ) vocab-name use-vocab ;
140
141 [ vocab-spec? ] \ com-use-vocab H{
142     { +secondary+ t }
143     { +listener+ t }
144 } define-operation
145
146 [ vocab-spec? ] \ run H{
147     { +listener+ t }
148 } define-operation
149
150 [ vocab? ] \ test H{
151     { +listener+ t }
152 } define-operation
153
154 [ vocab-spec? ] \ deploy-tool H{ } define-operation
155
156 ! Quotations
157 [ quotation? ] \ com-stack-effect H{
158     { +keyboard+ T{ key-down f { C+ } "i" } }
159     { +listener+ t }
160 } define-operation
161
162 [ quotation? ] \ walk H{
163     { +keyboard+ T{ key-down f { C+ } "w" } }
164     { +listener+ t }
165 } define-operation
166
167 [ quotation? ] \ time H{
168     { +keyboard+ T{ key-down f { C+ } "t" } }
169     { +listener+ t }
170 } define-operation
171
172 : com-expand-macros ( quot -- ) expand-macros . ;
173
174 [ quotation? ] \ com-expand-macros H{
175     { +keyboard+ T{ key-down f { C+ } "m" } }
176     { +listener+ t }
177 } define-operation
178
179 ! Disposables
180 [ disposable? ] \ dispose H{ } define-operation
181
182 ! Disposables with a continuation
183 PREDICATE: tracked-disposable < disposable
184     continuation>> >boolean ;
185
186 PREDICATE: tracked-malloc-ptr < malloc-ptr
187     continuation>> >boolean ;
188
189 : com-creation-traceback ( disposable -- )
190     continuation>> traceback-window ;
191
192 [ tracked-disposable? ] \ com-creation-traceback H{
193     { +primary+ t }
194 } define-operation
195
196 [ tracked-malloc-ptr? ] \ com-creation-traceback H{
197     { +primary+ t }
198 } define-operation
199
200 ! Operations -> commands
201 interactor
202 "quotation"
203 "These commands operate on the entire contents of the input area."
204 [ ]
205 [ quot-action ]
206 define-operation-map