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