Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 276 lines (256 sloc) 10.596 kB
4c5e6d4 first commit
megaannum authored
1
2 function! forms#example#slider#Make()
3 function! S2HSliderAction(...) dict
4 let value = "".a:1
5 call self.editor.setText(value)
6 endfunction
7
8 function! S2EditorAction(...) dict
9 let value = a:1 + 0
10 try
11 call self.hslider.setRangeValue(value)
12 catch /.*/
13 " call forms#log("S2EditorAction.execute: exception=" . v:exception)
14 endtry
15 endfunction
16
17 let hsa1 = forms#newAction({ 'execute': function("S2HSliderAction")})
18 let ea1 = forms#newAction({ 'execute': function("S2EditorAction")})
19 let attrs = {
20 \ 'size' : 2,
21 \ 'on_move_action' : hsa1,
22 \ 'range' : [0,10]
23 \ }
24 let hs1 = forms#newHSlider(attrs)
25 let ea1.hslider = hs1
26 let b1 = forms#newBox({ 'body': hs1} )
27 let sp1 = forms#newHSpace({ 'size': 1} )
28 let e1 = forms#newFixedLengthField({
29 \ 'size': 2,
30 \ 'on_selection_action' : ea1,
31 \ 'init_text': '0'})
32 let hsa1.editor = e1
33 let hpoly1 = forms#newHPoly({ 'children': [b1, sp1, e1], 'alignment': 'C' })
34
35 let hsa2 = forms#newAction({ 'execute': function("S2HSliderAction")})
36 let ea2 = forms#newAction({ 'execute': function("S2EditorAction")})
37 let attrs = {
38 \ 'size' : 2,
39 \ 'resolution' : 2,
40 \ 'on_move_action' : hsa2,
41 \ 'range' : [0,10]
42 \ }
43 let hs2 = forms#newHSlider(attrs)
44 let ea2.hslider = hs2
45 let b2 = forms#newBox({ 'body': hs2} )
46 let sp2 = forms#newHSpace({ 'size': 1} )
47 let e2 = forms#newFixedLengthField({
48 \ 'size': 2,
49 \ 'on_selection_action' : ea2,
50 \ 'init_text': '0'})
51 let hsa2.editor = e2
52 let hpoly2 = forms#newHPoly({ 'children': [b2, sp2, e2], 'alignment': 'C' })
53
54 let hsa3 = forms#newAction({ 'execute': function("S2HSliderAction")})
55 let ea3 = forms#newAction({ 'execute': function("S2EditorAction")})
56 let attrs = {
57 \ 'size' : 3,
58 \ 'resolution' : 2,
59 \ 'on_move_action' : hsa3,
60 \ 'range' : [0,10]
61 \ }
62 let hs3 = forms#newHSlider(attrs)
63 let ea3.hslider = hs3
64 let b3 = forms#newBox({ 'body': hs3} )
65 let sp3 = forms#newHSpace({ 'size': 1} )
66 let e3 = forms#newFixedLengthField({
67 \ 'size': 2,
68 \ 'on_selection_action' : ea3,
69 \ 'init_text': '0'})
70 let hsa3.editor = e3
71 let hpoly3 = forms#newHPoly({ 'children': [b3, sp3, e3], 'alignment': 'C' })
72
73 let hsa4 = forms#newAction({ 'execute': function("S2HSliderAction")})
74 let ea4 = forms#newAction({ 'execute': function("S2EditorAction")})
75 let attrs = {
76 \ 'size' : 5,
77 \ 'resolution' : 2,
78 \ 'on_move_action' : hsa4,
79 \ 'range' : [0,10]
80 \ }
81 let hs4 = forms#newHSlider(attrs)
82 let ea4.hslider = hs4
83 let b4 = forms#newBox({ 'body': hs4} )
84 let sp4 = forms#newHSpace({ 'size': 1} )
85 let e4 = forms#newFixedLengthField({
86 \ 'size': 2,
87 \ 'on_selection_action' : ea4,
88 \ 'init_text': '0'})
89 let hsa4.editor = e4
90 let hpoly4 = forms#newHPoly({ 'children': [b4, sp4, e4], 'alignment': 'C' })
91
92 let hsa5 = forms#newAction({ 'execute': function("S2HSliderAction")})
93 let ea5 = forms#newAction({ 'execute': function("S2EditorAction")})
94 let attrs = {
95 \ 'size' : 5,
96 \ 'resolution' : 3,
97 \ 'on_move_action' : hsa5,
98 \ 'range' : [0,20]
99 \ }
100 let hs5 = forms#newHSlider(attrs)
101 let ea5.hslider = hs5
102 let b5 = forms#newBox({ 'body': hs5} )
103 let sp5 = forms#newHSpace({ 'size': 1} )
104 let e5 = forms#newFixedLengthField({
105 \ 'size': 2,
106 \ 'on_selection_action' : ea5,
107 \ 'init_text': '0'})
108 let hsa5.editor = e5
109 let hpoly5 = forms#newHPoly({ 'children': [b5, sp5, e5], 'alignment': 'C' })
110
111 let hsa6 = forms#newAction({ 'execute': function("S2HSliderAction")})
112 let ea6 = forms#newAction({ 'execute': function("S2EditorAction")})
113 let attrs = {
114 \ 'size' : 5,
115 \ 'resolution' : 4,
116 \ 'on_move_action' : hsa6,
117 \ 'range' : [0,32]
118 \ }
119 let hs6 = forms#newHSlider(attrs)
120 let ea6.hslider = hs6
121 let b6 = forms#newBox({ 'body': hs6} )
122 let sp6 = forms#newHSpace({ 'size': 1} )
123 let e6 = forms#newFixedLengthField({
124 \ 'size': 2,
125 \ 'on_selection_action' : ea6,
126 \ 'init_text': '0'})
127 let hsa6.editor = e6
128 let hpoly6 = forms#newHPoly({ 'children': [b6, sp6, e6], 'alignment': 'C' })
129
130 let vpolyh = forms#newVPoly({ 'children': [
131 \ hpoly1,
132 \ hpoly2,
133 \ hpoly3,
134 \ hpoly4,
135 \ hpoly5,
136 \ hpoly6
137 \ ] })
138
139 "....................
140
141 let vsa1 = forms#newAction({ 'execute': function("S2HSliderAction")})
142 let vea1 = forms#newAction({ 'execute': function("S2EditorAction")})
143 let attrs = {
144 \ 'size' : 2,
145 \ 'on_move_action' : vsa1,
146 \ 'range' : [0,10]
147 \ }
148 let vs1 = forms#newVSlider(attrs)
149 let vea1.hslider = vs1
150 let b1 = forms#newBox({ 'body': vs1} )
151 let sp1 = forms#newVSpace({ 'size': 1} )
152 let e1 = forms#newFixedLengthField({
153 \ 'size': 2,
154 \ 'on_selection_action' : vea1,
155 \ 'init_text': '0'})
156 let vsa1.editor = e1
157 let vpoly1 = forms#newVPoly({ 'children': [b1, sp1, e1], 'alignment': 'C' })
158
159 let vsa2 = forms#newAction({ 'execute': function("S2HSliderAction")})
160 let vea2 = forms#newAction({ 'execute': function("S2EditorAction")})
161 let attrs = {
162 \ 'size' : 2,
163 \ 'resolution' : 2,
164 \ 'on_move_action' : vsa2,
165 \ 'range' : [0,10]
166 \ }
167 let vs2 = forms#newVSlider(attrs)
168 let vea2.hslider = vs2
169 let b2 = forms#newBox({ 'body': vs2})
170 let sp2 = forms#newVSpace({ 'size': 1})
171 let e2 = forms#newFixedLengthField({
172 \ 'size': 2,
173 \ 'on_selection_action' : vea2,
174 \ 'init_text': '0'})
175 let vsa2.editor = e2
176 let vpoly2 = forms#newVPoly({ 'children': [b2, sp2, e2], 'alignment': 'C' })
177
178 let vsa3 = forms#newAction({ 'execute': function("S2HSliderAction")})
179 let vea3 = forms#newAction({ 'execute': function("S2EditorAction")})
180 let attrs = {
181 \ 'size' : 3,
182 \ 'resolution' : 2,
183 \ 'on_move_action' : vsa3,
184 \ 'range' : [0,10]
185 \ }
186 let vs3 = forms#newVSlider(attrs)
187 let vea3.hslider = vs3
188 let b3 = forms#newBox({ 'body': vs3})
189 let sp3 = forms#newVSpace({ 'size': 1})
190 let e3 = forms#newFixedLengthField({
191 \ 'size': 2,
192 \ 'on_selection_action' : vea3,
193 \ 'init_text': '0'})
194 let vsa3.editor = e3
195 let vpoly3 = forms#newVPoly({ 'children': [b3, sp3, e3], 'alignment': 'C' })
196
197 let vsa4 = forms#newAction({ 'execute': function("S2HSliderAction")})
198 let vea4 = forms#newAction({ 'execute': function("S2EditorAction")})
199 let attrs = {
200 \ 'size' : 5,
201 \ 'resolution' : 2,
202 \ 'on_move_action' : vsa4,
203 \ 'range' : [0,10]
204 \ }
205 let vs4 = forms#newVSlider(attrs)
206 let vea4.hslider = vs4
207 let b4 = forms#newBox({ 'body': vs4})
208 let sp4 = forms#newVSpace({ 'size': 1})
209 let e4 = forms#newFixedLengthField({
210 \ 'size': 2,
211 \ 'on_selection_action' : vea4,
212 \ 'init_text': '0'})
213 let vsa4.editor = e4
214 let vpoly4 = forms#newVPoly({ 'children': [b4, sp4, e4], 'alignment': 'C' })
215
216 let vsa5 = forms#newAction({ 'execute': function("S2HSliderAction")})
217 let vea5 = forms#newAction({ 'execute': function("S2EditorAction")})
218 let attrs = {
219 \ 'size' : 5,
220 \ 'resolution' : 3,
221 \ 'on_move_action' : vsa5,
222 \ 'range' : [0,20]
223 \ }
224 let vs5 = forms#newVSlider(attrs)
225 let vea5.hslider = vs5
226 let b5 = forms#newBox({ 'body': vs5})
227 let sp5 = forms#newVSpace({ 'size': 1})
228 let e5 = forms#newFixedLengthField({
229 \ 'size': 2,
230 \ 'on_selection_action' : vea5,
231 \ 'init_text': '0'})
232 let vsa5.editor = e5
233 let vpoly5 = forms#newVPoly({ 'children': [b5, sp5, e5], 'alignment': 'C' })
234
235 let vsa6 = forms#newAction({ 'execute': function("S2HSliderAction")})
236 let vea6 = forms#newAction({ 'execute': function("S2EditorAction")})
237 let attrs = {
238 \ 'size' : 5,
239 \ 'resolution' : 4,
240 \ 'on_move_action' : vsa6,
241 \ 'range' : [0,32]
242 \ }
243 let vs6 = forms#newVSlider(attrs)
244 let vea6.hslider = vs6
245 let b6 = forms#newBox({ 'body': vs6})
246 let sp6 = forms#newVSpace({ 'size': 1})
247 let e6 = forms#newFixedLengthField({
248 \ 'size': 2,
249 \ 'on_selection_action' : vea6,
250 \ 'init_text': '0'})
251 let vsa6.editor = e6
252 let vpoly6 = forms#newVPoly({ 'children': [b6, sp6, e6], 'alignment': 'C' })
253
254 "....................
255 let hpoly = forms#newHPoly({ 'children': [
256 \ vpolyh,
257 \ vpoly1,
258 \ vpoly2,
259 \ vpoly3,
260 \ vpoly4,
261 \ vpoly5,
262 \ vpoly6],
263 \ 'alignment': 'C' })
264
265 let b = forms#newBorder({ 'body': hpoly })
266 let bg = forms#newBackground({ 'body': b} )
267 let form = forms#newForm({'body': bg })
268 call form.run()
269 endfunction
270
ee21b40 Better support for both 'light' and 'dard' backgrounds.
megaannum authored
271 function! forms#example#slider#MakeTest()
272 call forms#AppendInput({'type': 'Sleep', 'time': 5})
273 call forms#AppendInput({'type': 'Exit'})
274 call forms#example#slider#Make()
275 endfunction
Something went wrong with that request. Please try again.