1 ! Copyright (C) 2006 Slava Pestov.
2 ! See http://factorcode.org/license.txt for BSD license.
4 USING: definitions gadgets gadgets-browser gadgets-dataflow
5 gadgets-help gadgets-listener gadgets-text gadgets-workspace
6 hashtables help inference kernel namespaces parser prettyprint
7 scratchpad sequences strings styles syntax test tools words
10 V{ } clone operations set-global
12 : define-operation ( class props -- )
13 <operation> operations get push-new ;
15 M: operation invoke-command ( target operation -- )
16 dup command-quot swap operation-listener?
17 [ curry call-listener ] [ call ] if ;
19 : modify-listener-operation ( quot operation -- operation )
20 clone t over set-operation-listener?
23 : modify-listener-operations ( operations quot -- operations )
24 swap [ modify-listener-operation ] map-with ;
30 { +quot+ [ inspect ] }
44 { +quot+ [ listener-gadget call-tool ] }
51 { +quot+ [ pathname-string edit-file ] }
56 { +quot+ [ pathname-string [ run-file ] curry call-listener ] }
63 { +keyboard+ T{ key-down f { A+ } "b" } }
64 { +quot+ [ browser call-tool ] }
69 { +keyboard+ T{ key-down f { A+ } "e" } }
74 { +name+ "Documentation" }
75 { +keyboard+ T{ key-down f { A+ } "h" } }
76 { +quot+ [ help-gadget call-tool ] }
81 { +keyboard+ T{ key-down f { A+ } "u" } }
88 { +keyboard+ T{ key-down f { A+ } "r" } }
100 { +name+ "Word dataflow" }
101 { +keyboard+ T{ key-down f { A+ } "d" } }
102 { +quot+ [ word-def show-dataflow ] }
109 { +quot+ [ browser call-tool ] }
113 { +name+ "Enter in" }
114 { +quot+ [ vocab-link-name [ set-in ] curry call-listener ] }
119 { +quot+ [ vocab-link-name [ use+ ] curry call-listener ] }
126 { +quot+ [ help-gadget call-tool ] }
136 { +quot+ [ reload ] }
140 { +name+ "Definition" }
141 { +quot+ [ link-name browser call-tool ] }
147 { +keyboard+ T{ key-down f { C+ A+ } "i" } }
148 { +quot+ [ infer . ] }
153 { +name+ "Quotation dataflow" }
154 { +keyboard+ T{ key-down f { C+ A+ } "d" } }
155 { +quot+ [ show-dataflow ] }
161 { +keyboard+ T{ key-down f { C+ A+ } "w" } }
168 { +keyboard+ T{ key-down f { C+ A+ } "t" } }
177 { +name+ "Show dataflow" }
178 { +quot+ [ dataflow-gadget call-tool ] }
183 { +quot+ [ inspect ] }
187 ! Define commands in terms of operations
191 \ word class-operations [ tile-definition ] modify-operations
192 [ command-name "Browse" = not ] subset
193 { "Close" f [ close-tile ] } add*
196 ! Interactor commands
197 : word-action ( target -- quot )
198 selected-word search ;
200 : quot-action ( interactor -- quot )
201 dup editor-text swap select-all parse ;
203 interactor "Word commands"
204 \ word class-operations
205 [ word-action ] modify-listener-operations
208 interactor "Quotation commands"
209 quotation class-operations
210 [ quot-action ] modify-listener-operations
213 help-gadget "Toolbar" {
214 { "Back" T{ key-down f { C+ } "b" } [ help-gadget-history go-back ] }
215 { "Forward" T{ key-down f { C+ } "f" } [ help-gadget-history go-forward ] }
216 { "Home" T{ key-down f { C+ } "h" } [ go-home ] }
218 link class-operations [ help-action ] modify-operations
219 [ command-name "Follow" = not ] subset