]> gitweb.factorcode.org Git - factor.git/blob - basis/ui/tools/operations/operations.factor
ui.gadgets.editors: implement Ctrl-A/E/K to be more compatible.
[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: continuations definitions generic help.topics threads
4 stack-checker summary io.pathnames io.styles kernel namespaces
5 parser prettyprint quotations tools.crossref tools.annotations
6 editors tools.profiler tools.test tools.time tools.walker vocabs
7 vocabs.loader words sequences classes compiler.errors
8 compiler.units accessors vocabs.parser macros.expander ui
9 ui.tools.browser ui.tools.listener ui.tools.listener.completion
10 ui.tools.profiler ui.tools.inspector ui.tools.traceback
11 ui.commands ui.gadgets.editors ui.gestures ui.operations
12 ui.tools.deploy models help.tips source-files.errors destructors
13 libc libc.private ;
14 IN: ui.tools.operations
15
16 ! Objects
17 [ drop t ] \ inspector H{
18     { +primary+ 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 ! Models
38 [ model? ] \ inspect-model H{
39     { +primary+ t }
40 } define-operation
41
42 ! Input
43 : com-input ( obj -- ) string>> listener-input ;
44
45 [ input? ] \ com-input H{
46     { +primary+ t }
47     { +secondary+ t }
48 } define-operation
49
50 ! Restart
51 [ restart? ] \ restart H{
52     { +primary+ t }
53     { +secondary+ t }
54     { +listener+ t }
55 } define-operation
56
57 ! Continuation
58 [ continuation? ] \ traceback-window H{
59     { +primary+ t }
60     { +secondary+ t }
61 } define-operation
62
63 ! Thread
64 : com-thread-traceback-window ( thread -- )
65     thread-continuation traceback-window ;
66
67 [ thread? ] \ com-thread-traceback-window H{
68     { +primary+ t }
69     { +secondary+ t }
70 } define-operation
71
72 ! Pathnames
73 : edit-file ( pathname -- ) edit ;
74
75 [ pathname? ] \ edit-file H{
76     { +keyboard+ T{ key-down f { C+ } "b" } }
77     { +primary+ t }
78     { +secondary+ t }
79     { +listener+ t }
80 } define-operation
81
82 [ definition? ] \ edit H{
83     { +keyboard+ T{ key-down f { C+ } "b" } }
84     { +listener+ t }
85 } define-operation
86
87 ! Source file error
88 [ source-file-error? ] \ edit-error H{
89     { +primary+ t }
90     { +secondary+ t }
91     { +listener+ t }
92 } define-operation
93
94 : com-reload ( error -- )
95     file>> run-file ;
96
97 [ compiler-error? ] \ com-reload H{
98     { +listener+ t }
99 } define-operation
100
101 ! Definitions
102 : com-forget ( defspec -- )
103     [ forget ] with-compilation-unit ;
104
105 [ definition? ] \ com-forget H{ } define-operation
106
107 [ topic? ] \ com-browse H{
108     { +keyboard+ T{ key-down f { C+ } "h" } }
109     { +primary+ t }
110 } define-operation
111
112 [ word? ] \ usage. H{
113     { +keyboard+ T{ key-down f { C+ } "u" } }
114     { +listener+ t }
115 } define-operation
116
117 [ word? ] \ fix H{
118     { +keyboard+ T{ key-down f { C+ } "f" } }
119     { +listener+ t }
120 } define-operation
121
122 [ word? ] \ watch H{ } define-operation
123
124 [ word? ] \ breakpoint H{ } define-operation
125
126 GENERIC: com-stack-effect ( obj -- )
127
128 M: quotation com-stack-effect infer. ;
129
130 M: word com-stack-effect 1quotation com-stack-effect ;
131
132 : com-enter-in ( vocab -- ) vocab-name set-current-vocab ;
133
134 [ vocab? ] \ com-enter-in H{
135     { +listener+ t }
136 } define-operation
137
138 : com-use-vocab ( vocab -- ) vocab-name use-vocab ;
139
140 [ vocab-spec? ] \ com-use-vocab H{
141     { +secondary+ t }
142     { +listener+ t }
143 } define-operation
144
145 [ vocab-spec? ] \ run H{
146     { +listener+ t }
147 } define-operation
148
149 [ vocab? ] \ test H{
150     { +listener+ t }
151 } define-operation
152
153 [ vocab-spec? ] \ deploy-tool H{ } define-operation
154
155 ! Quotations
156 [ quotation? ] \ com-stack-effect H{
157     { +keyboard+ T{ key-down f { C+ } "i" } }
158     { +listener+ t }
159 } define-operation
160
161 [ quotation? ] \ walk H{
162     { +keyboard+ T{ key-down f { C+ } "w" } }
163     { +listener+ t }
164 } define-operation
165
166 [ quotation? ] \ time H{
167     { +keyboard+ T{ key-down f { C+ } "t" } }
168     { +listener+ t }
169 } define-operation
170
171 [ quotation? ] \ com-profile H{
172     { +keyboard+ T{ key-down f { C+ } "o" } }
173     { +listener+ t }
174 } define-operation
175
176 : com-expand-macros ( quot -- ) expand-macros . ;
177
178 [ quotation? ] \ com-expand-macros H{
179     { +keyboard+ T{ key-down f { C+ } "m" } }
180     { +listener+ t }
181 } define-operation
182
183 ! Disposables
184 [ disposable? ] \ dispose H{ } define-operation
185
186 ! Disposables with a continuation
187 PREDICATE: tracked-disposable < disposable
188     continuation>> >boolean ;
189
190 PREDICATE: tracked-malloc-ptr < malloc-ptr
191     continuation>> >boolean ;
192
193 : com-creation-traceback ( disposable -- )
194     continuation>> traceback-window ;
195
196 [ tracked-disposable? ] \ com-creation-traceback H{ { +primary+ t } } define-operation
197 [ tracked-malloc-ptr? ] \ com-creation-traceback H{ { +primary+ t } } define-operation
198
199 ! Operations -> commands
200 interactor
201 "quotation"
202 "These commands operate on the entire contents of the input area."
203 [ ]
204 [ quot-action ]
205 define-operation-map