]> gitweb.factorcode.org Git - factor.git/blob - basis/ui/tools/deploy/deploy.factor
Deploy tool always uses optimizing compiler now
[factor.git] / basis / ui / tools / deploy / deploy.factor
1 ! Copyright (C) 2007, 2009 Slava Pestov.
2 ! See http://factorcode.org/license.txt for BSD license.
3 USING: colors kernel namespaces models tools.deploy.config
4 tools.deploy.config.editor tools.deploy vocabs
5 namespaces models.mapping sequences system accessors fry
6 ui.gadgets ui.render ui.gadgets.buttons ui.gadgets.packs
7 ui.gadgets.labels ui.gadgets.editors ui.gadgets.borders ui.gestures
8 ui.commands assocs ui.gadgets.tracks ui ui.tools.listener
9 ui.tools.browser ;
10 IN: ui.tools.deploy
11
12 TUPLE: deploy-gadget < pack vocab settings ;
13
14 : bundle-name ( parent -- parent )
15     deploy-name get <model-field>
16     "Executable name:" label-on-left add-gadget ;
17
18 : deploy-ui ( parent -- parent )
19     deploy-ui? get
20     "Include user interface framework" <checkbox> add-gadget ;
21
22 : io-settings ( parent -- parent )
23     "Input/output support:" <label> add-gadget
24     deploy-io get deploy-io-options <radio-buttons> add-gadget ;
25
26 : reflection-settings ( parent -- parent )
27     "Reflection support:" <label> add-gadget
28     deploy-reflection get deploy-reflection-options <radio-buttons> add-gadget ;
29
30 : advanced-settings ( parent -- parent )
31     "Advanced:" <label> add-gadget
32     deploy-math? get "Rational and complex number support" <checkbox> add-gadget
33     deploy-threads? get "Threading support" <checkbox> add-gadget
34     deploy-unicode? get "Unicode character literal support" <checkbox> add-gadget
35     deploy-word-props? get "Retain all word properties" <checkbox> add-gadget
36     deploy-word-defs? get "Retain all word definitions" <checkbox> add-gadget
37     deploy-c-types? get "Retain all C types" <checkbox> add-gadget ;
38
39 : deploy-settings-theme ( gadget -- gadget )
40     { 10 10 } >>gap
41     1 >>fill ;
42
43 : <deploy-settings> ( vocab -- control )
44     default-config [ <model> ] assoc-map
45         [
46             <pile>
47             bundle-name
48             deploy-ui
49             io-settings
50             reflection-settings
51             advanced-settings
52
53             deploy-settings-theme
54             namespace <mapping> >>model
55         ]
56     bind ;
57
58 : find-deploy-gadget ( gadget -- deploy-gadget )
59     [ deploy-gadget? ] find-parent ;
60
61 : find-deploy-vocab ( gadget -- vocab )
62     find-deploy-gadget vocab>> ;
63
64 : find-deploy-config ( gadget -- config )
65     find-deploy-vocab deploy-config ;
66
67 : find-deploy-settings ( gadget -- settings )
68     find-deploy-gadget settings>> ;
69
70 : com-revert ( gadget -- )
71     dup find-deploy-config
72     swap find-deploy-settings set-control-value ;
73
74 : com-save ( gadget -- )
75     dup find-deploy-settings control-value
76     swap find-deploy-vocab set-deploy-config ;
77
78 : com-deploy ( gadget -- )
79     [ com-save ]
80     [ find-deploy-vocab '[ _ deploy ] \ deploy call-listener ]
81     [ close-window ]
82     tri ;
83
84 : com-help ( -- )
85     "ui.tools.deploy" com-browse ;
86
87 \ com-help H{
88     { +nullary+ t }
89 } define-command
90
91 : com-close ( gadget -- )
92     close-window ;
93
94 deploy-gadget "misc" "Miscellaneous commands" {
95     { T{ key-down f f "ESC" } com-close }
96 } define-command-map
97
98 deploy-gadget "toolbar" f {
99     { T{ key-down f f "F1" } com-help }
100     { f com-revert }
101     { f com-save }
102     { T{ key-down f f "RET" } com-deploy }
103 } define-command-map
104
105 : <deploy-gadget> ( vocab -- gadget )
106     deploy-gadget new
107       over >>vocab
108       vertical >>orientation
109       swap <deploy-settings> >>settings
110       dup settings>> add-gadget
111       dup <toolbar> { 10 10 } >>gap add-gadget
112     deploy-settings-theme
113     dup com-revert ;
114     
115 : deploy-tool ( vocab -- )
116     vocab-name
117     [ <deploy-gadget> { 10 10 } <border> ]
118     [ "Deploying “" "”" surround ] bi
119     open-window ;