]> gitweb.factorcode.org Git - factor.git/blob - basis/ui/tools/operations/operations.factor
parser, source-files: you need to bootstrap after this patch.
[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
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 GENERIC: com-stack-effect ( obj -- )
124
125 M: quotation com-stack-effect infer. ;
126
127 M: word com-stack-effect 1quotation com-stack-effect ;
128
129 : com-enter-in ( vocab -- ) vocab-name set-current-vocab ;
130
131 [ vocab? ] \ com-enter-in H{
132     { +listener+ t }
133 } define-operation
134
135 : com-use-vocab ( vocab -- ) vocab-name use-vocab ;
136
137 [ vocab-spec? ] \ com-use-vocab H{
138     { +secondary+ t }
139     { +listener+ t }
140 } define-operation
141
142 [ vocab-spec? ] \ run H{
143     { +listener+ t }
144 } define-operation
145
146 [ vocab? ] \ test H{
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-expand-macros ( quot -- ) expand-macros . ;
169
170 [ quotation? ] \ com-expand-macros H{
171     { +keyboard+ T{ key-down f { C+ } "m" } }
172     { +listener+ t }
173 } define-operation
174
175 ! Disposables
176 [ disposable? ] \ dispose H{ } define-operation
177
178 ! Disposables with a continuation
179 PREDICATE: tracked-disposable < disposable
180     continuation>> >boolean ;
181
182 PREDICATE: tracked-malloc-ptr < malloc-ptr
183     continuation>> >boolean ;
184
185 : com-creation-traceback ( disposable -- )
186     continuation>> traceback-window ;
187
188 [ tracked-disposable? ] \ com-creation-traceback H{ { +primary+ t } } define-operation
189 [ tracked-malloc-ptr? ] \ com-creation-traceback H{ { +primary+ t } } define-operation
190
191 ! Operations -> commands
192 interactor
193 "quotation"
194 "These commands operate on the entire contents of the input area."
195 [ ]
196 [ quot-action ]
197 define-operation-map