|
1
by Stuart P. Bentley
initial scripts add+commit |
1 |
------------------------------------------------
|
2 |
--Sandpad
|
|
3 |
--by Stuart P. Bentley (stuart@testtrack4.com)
|
|
4 |
--http://sandpad.luaforge.net
|
|
5 |
local version="1.0" |
|
|
13
by Stuart P. Bentley
the top box autorun toggle works just about correctly now. it resets if you change, which is pretty much just the way I was planning, although I can see it being considered the "wrong" behavior. |
6 |
local pushed="8/26.2009" |
|
1
by Stuart P. Bentley
initial scripts add+commit |
7 |
------------------------------------------------
|
8 |
||
9 |
-------------------------------------------------------------------------------
|
|
|
4
by Stuart P. Bentley
more pages and a rearranged about dialog |
10 |
-- !!! USE ONLY LOCALS ABOVE setfenv(1,shadowbox(_G)) !!! --
|
|
1
by Stuart P. Bentley
initial scripts add+commit |
11 |
-------------------------------------------------------------------------------
|
12 |
||
|
4
by Stuart P. Bentley
more pages and a rearranged about dialog |
13 |
local shadowmt, shadowtable, fakeglobal, shadowbox, defaultenv |
|
1
by Stuart P. Bentley
initial scripts add+commit |
14 |
do
|
|
4
by Stuart P. Bentley
more pages and a rearranged about dialog |
15 |
function shadowmt(source) |
16 |
--table for variables that should return nil
|
|
17 |
--and not look for a value in the source table
|
|
18 |
local deleted={} |
|
19 |
return { |
|
20 |
__index=function(t,k) |
|
21 |
if deleted[k] then |
|
22 |
return nil |
|
23 |
elseif type(source[k])=="table" then |
|
24 |
t[k]=setmetatable({},shadowmt(source[k])) |
|
25 |
return t[k] |
|
26 |
else
|
|
27 |
return source[k] |
|
28 |
end
|
|
29 |
end, |
|
30 |
__newindex=function(t,k,v) |
|
31 |
if not v and source[k] then |
|
32 |
deleted[k]=true |
|
33 |
else
|
|
34 |
deleted[k]=nil |
|
35 |
end
|
|
36 |
rawset(t,k,v) |
|
37 |
end
|
|
38 |
}
|
|
39 |
end
|
|
40 |
||
41 |
function shadowtable(uptable) |
|
42 |
return setmetatable({},shadowmt(uptable)) |
|
43 |
end
|
|
44 |
||
|
1
by Stuart P. Bentley
initial scripts add+commit |
45 |
function fakeglobal(upenv) |
46 |
local fake_G={} |
|
47 |
fake_G._G=fake_G |
|
48 |
||
49 |
return fake_G |
|
50 |
end
|
|
|
4
by Stuart P. Bentley
more pages and a rearranged about dialog |
51 |
|
52 |
--returns a shadow sandbox global environment
|
|
53 |
function shadowbox(upenv) |
|
|
5
by Stuart P. Bentley
branched off leftboxcontrols and internalfenv |
54 |
global=setmetatable(fakeglobal(upenv),shadowmt(upenv)) |
55 |
||
56 |
--delete setfenv/getfenv
|
|
|
10
by Stuart P. Bentley
moved branding/htdocs into own series |
57 |
--(reimplementation development in internalfenv branch)
|
|
5
by Stuart P. Bentley
branched off leftboxcontrols and internalfenv |
58 |
global.setfenv=nil |
59 |
global.getfenv=nil |
|
60 |
||
61 |
return global |
|
|
4
by Stuart P. Bentley
more pages and a rearranged about dialog |
62 |
end
|
63 |
||
64 |
--save clean default environment for use in boxes
|
|
65 |
defaultenv=_G |
|
66 |
end
|
|
|
5
by Stuart P. Bentley
branched off leftboxcontrols and internalfenv |
67 |
|
|
1
by Stuart P. Bentley
initial scripts add+commit |
68 |
--set new global environment shadowing original _G
|
|
4
by Stuart P. Bentley
more pages and a rearranged about dialog |
69 |
--except setfenv(0,shadowbox(_G)) causes iup to fail to index itself
|
|
1
by Stuart P. Bentley
initial scripts add+commit |
70 |
--so right now we do the next best thing
|
71 |
--and set this chunk's environment instead
|
|
72 |
setfenv(1,shadowbox(_G)) |
|
73 |
||
|
5
by Stuart P. Bentley
branched off leftboxcontrols and internalfenv |
74 |
--get the original environment's setfenv and getfenv
|
75 |
--so we can set environments for boxes
|
|
76 |
setfenv=defaultenv.setfenv |
|
77 |
getfenv=defaultenv.getfenv |
|
78 |
||
|
1
by Stuart P. Bentley
initial scripts add+commit |
79 |
-------------------------------------------------------------------------------
|
|
4
by Stuart P. Bentley
more pages and a rearranged about dialog |
80 |
-- !!! DON'T MODIFY THE GLOBAL ENVIRONMENT ABOVE THIS LINE !!! --
|
|
1
by Stuart P. Bentley
initial scripts add+commit |
81 |
-------------------------------------------------------------------------------
|
82 |
||
83 |
require "iuplua" |
|
|
4
by Stuart P. Bentley
more pages and a rearranged about dialog |
84 |
|
|
2
by Stuart P. Bentley
icons and the files to use 'em |
85 |
local icon=(io.open "sandpad.ico") |
86 |
if icon and pcall(require,"iupluaim") then |
|
87 |
icon:close() |
|
88 |
icon=iup.LoadImage "sandpad.ico" |
|
89 |
else
|
|
90 |
icon = iup.image { |
|
91 |
{ 1,1,1,1,1,1,1,2,1,1,1,1,1,1,1,1 }, |
|
92 |
{ 1,1,1,1,1,1,1,2,1,1,1,1,1,1,1,1 }, |
|
93 |
{ 1,1,1,1,1,1,1,2,1,1,1,1,1,1,1,1 }, |
|
94 |
{ 1,1,1,1,1,1,1,2,1,1,1,1,1,1,1,1 }, |
|
95 |
{ 1,1,1,1,1,1,3,2,3,1,1,1,1,1,1,1 }, |
|
96 |
{ 1,1,1,1,3,3,2,2,2,3,3,3,1,1,1,1 }, |
|
97 |
{ 1,1,3,3,3,3,2,2,2,3,3,3,3,3,1,1 }, |
|
98 |
{ 1,3,3,3,2,2,2,2,2,2,2,3,3,3,3,1 }, |
|
99 |
{ 2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2 }, |
|
100 |
{ 1,3,3,3,2,2,2,2,2,2,2,3,3,3,3,1 }, |
|
101 |
{ 1,1,3,3,3,3,2,2,2,3,3,3,3,1,1,1 }, |
|
102 |
{ 1,1,1,1,3,3,2,2,2,3,3,1,1,1,1,1 }, |
|
103 |
{ 1,1,1,1,1,1,3,2,3,1,1,1,1,1,1,1 }, |
|
104 |
{ 1,1,1,1,1,1,1,2,1,1,1,1,1,1,1,1 }, |
|
105 |
{ 1,1,1,1,1,1,1,2,1,1,1,1,1,1,1,1 }, |
|
106 |
{ 1,1,1,1,1,1,1,2,1,1,1,1,1,1,1,1 } |
|
107 |
-- Sets star image colors
|
|
108 |
; colors = { "BGCOLOR", "255 255 255", "0 0 0" } |
|
109 |
}
|
|
110 |
end
|
|
|
1
by Stuart P. Bentley
initial scripts add+commit |
111 |
|
112 |
tabwidth=2 |
|
113 |
blankoutput="" |
|
114 |
rundelay=500 |
|
115 |
||
116 |
require "strings" |
|
117 |
require "urls" |
|
118 |
||
119 |
colors={ |
|
120 |
red="255 0 0", |
|
121 |
black="0 0 0", |
|
122 |
white="255 255 255" |
|
123 |
}
|
|
124 |
||
125 |
values={ |
|
126 |
printbg="217 240 252", |
|
127 |
printblank="230 240 252" |
|
128 |
}
|
|
129 |
||
|
4
by Stuart P. Bentley
more pages and a rearranged about dialog |
130 |
if true then |
|
1
by Stuart P. Bentley
initial scripts add+commit |
131 |
values.editfont="Consolas::8" |
132 |
values.printfont="Consolas::20" |
|
133 |
printalign="ACENTER" |
|
|
4
by Stuart P. Bentley
more pages and a rearranged about dialog |
134 |
else
|
|
1
by Stuart P. Bentley
initial scripts add+commit |
135 |
values.editfont="Consolas,Monospace, 8" |
136 |
values.printfont="Consolas,Monospace, 20" |
|
137 |
printalign="ACENTER:ACENTER" |
|
138 |
--also play around with "FORMATTING" and "AUTOHIDE"
|
|
139 |
end
|
|
140 |
||
141 |
--set all controls in a table to a specific state
|
|
142 |
function actable(cls,state) |
|
143 |
if cls then |
|
144 |
for _,v in pairs(cls) do |
|
145 |
v.active=state |
|
146 |
end
|
|
147 |
end
|
|
148 |
end
|
|
149 |
||
|
10.1.1
by Stuart P. Bentley
Multiprint appears to be working |
150 |
--deactivate all boxes after and including the argument index
|
|
1
by Stuart P. Bentley
initial scripts add+commit |
151 |
function deactivate_down(laters) |
152 |
for i=laters, #boxes do |
|
153 |
actable(boxes[i].cls,"NO") |
|
154 |
boxes[i].text.active="NO" |
|
155 |
end
|
|
156 |
end
|
|
157 |
||
158 |
--reactivate an individual box
|
|
159 |
function reactivate_box(box) |
|
160 |
if box.cls then |
|
161 |
for _,v in pairs(box.cls) do |
|
162 |
v.active=box.states[v] |
|
163 |
end
|
|
164 |
end
|
|
165 |
box.text.active="YES" |
|
166 |
end
|
|
167 |
||
168 |
--set the state of a control in a box
|
|
169 |
function setactive(box,clst,state) |
|
170 |
box=boxes[box] |
|
171 |
if type(clst)=="string" then |
|
172 |
box.states[box.cls[clst]]=state |
|
173 |
box.cls[clst].active=state |
|
174 |
elseif type(clst)=="table" then |
|
175 |
for _,clstring in pairs(clst) do |
|
176 |
box.states[box.cls[clstring]]=state |
|
177 |
box.cls[clstring].active=state |
|
178 |
end
|
|
179 |
end
|
|
180 |
end
|
|
181 |
||
182 |
function clearbox(box) |
|
183 |
box=boxes[box] |
|
184 |
box.text.value="" |
|
185 |
box:eval() |
|
186 |
end
|
|
187 |
||
188 |
function clearallboxes() |
|
189 |
for _,box in ipairs(boxes) do |
|
190 |
box.text.value="" |
|
191 |
end
|
|
192 |
--will exec and clear all futher boxes' functions
|
|
193 |
boxes[1]:eval() |
|
194 |
end
|
|
195 |
||
196 |
--change the color of returndata to a set of colors
|
|
197 |
function coloretdata(colort) |
|
198 |
returndata.bgcolor=colort.bg |
|
199 |
returndata.fgcolor=colort.fg |
|
|
10
by Stuart P. Bentley
moved branding/htdocs into own series |
200 |
--BUG: outermost 1 pixel not updating
|
|
1
by Stuart P. Bentley
initial scripts add+commit |
201 |
end
|
202 |
||
|
13
by Stuart P. Bentley
the top box autorun toggle works just about correctly now. it resets if you change, which is pretty much just the way I was planning, although I can see it being considered the "wrong" behavior. |
203 |
function boxtextbox(i, bgcolor) |
204 |
return iup.multiline{expand="YES", |
|
205 |
font=values.editfont, tabsize=tabwidth, |
|
206 |
tip=strings.tips.boxes[i],tipfont="SYSTEM", |
|
207 |
bgcolor=bgcolor} |
|
208 |
end
|
|
209 |
||
210 |
local topboxchanged=false |
|
211 |
local function topboxunauto() |
|
212 |
topboxchanged=true |
|
213 |
end
|
|
214 |
--gets set after the function is creates
|
|
215 |
local topboxauto |
|
216 |
||
|
1
by Stuart P. Bentley
initial scripts add+commit |
217 |
boxes={ --individual box definitions |
|
10.1.1
by Stuart P. Bentley
Multiprint appears to be working |
218 |
[0]={env=defaultenv,prints={}}, |
|
1
by Stuart P. Bentley
initial scripts add+commit |
219 |
{--1 |
|
13
by Stuart P. Bentley
the top box autorun toggle works just about correctly now. it resets if you change, which is pretty much just the way I was planning, although I can see it being considered the "wrong" behavior. |
220 |
text=boxtextbox(1), |
|
1
by Stuart P. Bentley
initial scripts add+commit |
221 |
color={ |
|
4
by Stuart P. Bentley
more pages and a rearranged about dialog |
222 |
fParse={ --soon this color will not come into play (String/Lua toggling) |
|
1
by Stuart P. Bentley
initial scripts add+commit |
223 |
bg="255 192 192", |
224 |
fg=colors.red |
|
225 |
},
|
|
226 |
fExec={ |
|
227 |
bg="255 128 0", |
|
228 |
fg=colors.red |
|
229 |
}
|
|
230 |
},
|
|
231 |
cls={ |
|
|
10
by Stuart P. Bentley
moved branding/htdocs into own series |
232 |
--development branched to leftboxcontrols
|
|
1
by Stuart P. Bentley
initial scripts add+commit |
233 |
}
|
234 |
},
|
|
235 |
{--2 |
|
|
13
by Stuart P. Bentley
the top box autorun toggle works just about correctly now. it resets if you change, which is pretty much just the way I was planning, although I can see it being considered the "wrong" behavior. |
236 |
text=boxtextbox(2,"255 250 223"), |
|
1
by Stuart P. Bentley
initial scripts add+commit |
237 |
color={ |
238 |
fParse={ |
|
239 |
bg="255 255 128", |
|
240 |
fg=colors.red |
|
241 |
},
|
|
242 |
fExec={ |
|
243 |
bg="255 255 0", |
|
244 |
fg=colors.red |
|
245 |
}
|
|
246 |
},
|
|
247 |
cls={ |
|
248 |
artog=iup.toggle{title="",value="ON",tip=strings.tips.auto.run; |
|
249 |
action=function(self,state) |
|
250 |
if state==1 then |
|
251 |
boxes[2].cls.run.title=strings.buttons.autorun |
|
252 |
setactive(2,"run","NO") |
|
|
13
by Stuart P. Bentley
the top box autorun toggle works just about correctly now. it resets if you change, which is pretty much just the way I was planning, although I can see it being considered the "wrong" behavior. |
253 |
boxes[2].text.action=topboxauto |
|
1
by Stuart P. Bentley
initial scripts add+commit |
254 |
else
|
255 |
boxes[2].cls.run.title=strings.buttons.run |
|
256 |
setactive(2,"run","YES") |
|
|
13
by Stuart P. Bentley
the top box autorun toggle works just about correctly now. it resets if you change, which is pretty much just the way I was planning, although I can see it being considered the "wrong" behavior. |
257 |
boxes[2].text.action=topboxunauto |
|
1
by Stuart P. Bentley
initial scripts add+commit |
258 |
end
|
259 |
end
|
|
260 |
},
|
|
|
11
by Stuart P. Bentley
clear buttons now focus on cleared form rather than not focusing on click (which doesn't work in the current IUP3 RC anyway) |
261 |
run=iup.button{title=strings.buttons.autorun, |
|
1
by Stuart P. Bentley
initial scripts add+commit |
262 |
expand="HORIZONTAL",active="NO",--size="x14"; |
263 |
action=function() |
|
|
13
by Stuart P. Bentley
the top box autorun toggle works just about correctly now. it resets if you change, which is pretty much just the way I was planning, although I can see it being considered the "wrong" behavior. |
264 |
if topboxchanged then |
265 |
boxes[2]:eval() |
|
266 |
topboxchanged=false |
|
267 |
else
|
|
268 |
boxes[2]:run() |
|
269 |
end
|
|
|
1
by Stuart P. Bentley
initial scripts add+commit |
270 |
end
|
271 |
},
|
|
|
11
by Stuart P. Bentley
clear buttons now focus on cleared form rather than not focusing on click (which doesn't work in the current IUP3 RC anyway) |
272 |
clear=iup.button{title=strings.buttons.clear, |
|
4
by Stuart P. Bentley
more pages and a rearranged about dialog |
273 |
expand="HORIZONTAL", |
|
1
by Stuart P. Bentley
initial scripts add+commit |
274 |
action=function() |
275 |
clearbox(2) |
|
|
11
by Stuart P. Bentley
clear buttons now focus on cleared form rather than not focusing on click (which doesn't work in the current IUP3 RC anyway) |
276 |
iup.SetFocus(boxes[2].text) |
|
1
by Stuart P. Bentley
initial scripts add+commit |
277 |
end
|
278 |
}
|
|
279 |
}
|
|
280 |
},
|
|
281 |
{--3 |
|
282 |
text=iup.text{expand="HORIZONTAL",font=values.editfont,tabsize=tabwidth, |
|
283 |
tip=strings.tips.boxes[3],tipfont="SYSTEM" |
|
284 |
},
|
|
285 |
color={ |
|
286 |
fParse={ |
|
287 |
bg=values.printblank, |
|
288 |
fg=colors.red |
|
289 |
},
|
|
290 |
fExec={ |
|
291 |
bg=values.printbg, |
|
292 |
fg=colors.red |
|
293 |
},
|
|
294 |
normal={ |
|
295 |
bg=values.printbg, |
|
296 |
fg=colors.black |
|
297 |
},
|
|
298 |
blank={ |
|
299 |
bg=values.printblank, |
|
300 |
fg="192 192 192" |
|
301 |
}
|
|
302 |
},
|
|
303 |
cls={ |
|
|
11
by Stuart P. Bentley
clear buttons now focus on cleared form rather than not focusing on click (which doesn't work in the current IUP3 RC anyway) |
304 |
clear=iup.button{title=strings.buttons.x,padding="3x"; |
|
1
by Stuart P. Bentley
initial scripts add+commit |
305 |
action=function() |
306 |
clearbox(3) |
|
|
11
by Stuart P. Bentley
clear buttons now focus on cleared form rather than not focusing on click (which doesn't work in the current IUP3 RC anyway) |
307 |
iup.SetFocus(boxes[3].text) |
|
1
by Stuart P. Bentley
initial scripts add+commit |
308 |
end
|
309 |
}
|
|
310 |
}
|
|
311 |
}
|
|
312 |
}
|
|
313 |
||
|
4
by Stuart P. Bentley
more pages and a rearranged about dialog |
314 |
if iup2 then |
315 |
boxes[1].cls.save.size="x14"; |
|
316 |
boxes[1].cls.nameclear.size="x14"; |
|
317 |
boxes[2].cls.clear.size="x14"; |
|
318 |
boxes[3].cls.clear.size="x14"; |
|
319 |
end
|
|
320 |
||
|
1
by Stuart P. Bentley
initial scripts add+commit |
321 |
for iBox, curBox in ipairs(boxes) do |
|
10.1.1
by Stuart P. Bentley
Multiprint appears to be working |
322 |
|
323 |
--allow chaining on initial boxes to do nothing
|
|
324 |
function curBox.f() end |
|
325 |
||
326 |
--set up chaining
|
|
327 |
--called before executing a box's function
|
|
328 |
--and at the end of these definitions
|
|
329 |
function curBox:rechain() |
|
330 |
--create a new environment for this iteration
|
|
331 |
--from the previous box's
|
|
332 |
self.env=shadowbox(boxes[iBox-1].env) |
|
333 |
setfenv(self.f,self.env) |
|
334 |
--internal environment function hookup
|
|
335 |
self.env.print = self.print |
|
336 |
end
|
|
337 |
||
338 |
function curBox:continue() |
|
339 |
curBox.prints={unpack(boxes[iBox-1].prints)} |
|
340 |
end
|
|
|
1
by Stuart P. Bentley
initial scripts add+commit |
341 |
|
342 |
--initialize stored control states
|
|
343 |
curBox.states={} |
|
344 |
if curBox.cls then |
|
345 |
for _,v in pairs(curBox.cls) do |
|
346 |
curBox.states[v]=v.active |
|
347 |
end
|
|
348 |
end
|
|
349 |
||
|
10.1.1
by Stuart P. Bentley
Multiprint appears to be working |
350 |
--run: execute the box's function
|
351 |
--the box's function's environment may be coming from the last run
|
|
352 |
--of the previous box's function if this is being called in chain
|
|
353 |
--or it might be operating on itself
|
|
354 |
function curBox:run() |
|
355 |
--if the box is being run then it is active
|
|
356 |
reactivate_box(self) |
|
357 |
self:continue() |
|
358 |
||
359 |
local ok, r=pcall(self.f) |
|
360 |
if not ok then |
|
361 |
self:fExec(r) |
|
362 |
else --call next box's chain which will run from the environment |
|
363 |
--left by this call and call chain itself (hence the name "chain")
|
|
364 |
||
365 |
--if the final box's run weren't redefined at the end of the loop
|
|
366 |
--then you would only want to call this if iBox~=#boxes
|
|
367 |
boxes[iBox+1]:chain() |
|
368 |
end
|
|
369 |
end
|
|
370 |
||
|
1
by Stuart P. Bentley
initial scripts add+commit |
371 |
function curBox:eval(newcode) |
|
10.1.1
by Stuart P. Bentley
Multiprint appears to be working |
372 |
--if newcode wasn't passed then it's a situation where it hasn't
|
373 |
--been being passed
|
|
|
1
by Stuart P. Bentley
initial scripts add+commit |
374 |
newcode=newcode or self.text.value |
|
10.1.1
by Stuart P. Bentley
Multiprint appears to be working |
375 |
local message |
376 |
self.f, message=loadstring(newcode,strings.boxnames[iBox]) |
|
377 |
if self.f then |
|
378 |
self:chain() |
|
|
1
by Stuart P. Bentley
initial scripts add+commit |
379 |
else
|
|
10.1.1
by Stuart P. Bentley
Multiprint appears to be working |
380 |
--reactivate so the user can fix the parse error
|
381 |
--(which could have been present before a prior box had an error
|
|
382 |
--and disabled all further boxes)
|
|
383 |
reactivate_box(self) |
|
|
1
by Stuart P. Bentley
initial scripts add+commit |
384 |
self:fParse(message) |
385 |
end
|
|
386 |
end
|
|
387 |
||
|
10.1.1
by Stuart P. Bentley
Multiprint appears to be working |
388 |
--chain: run from the previous box's environment
|
389 |
function curBox:chain() |
|
390 |
self:rechain() |
|
391 |
self:run() |
|
392 |
end
|
|
393 |
||
|
1
by Stuart P. Bentley
initial scripts add+commit |
394 |
function curBox.text:action(c,newcode) |
|
10
by Stuart P. Bentley
moved branding/htdocs into own series |
395 |
if c==string.byte"\n" or c==string.byte"\r" |
396 |
and tonumber(self.caretpos)==#self.value |
|
397 |
and string.sub(self.value, -2)=="\n\n" then |
|
398 |
curBox:run() |
|
399 |
--ignore the new newline
|
|
400 |
return iup.IGNORE |
|
401 |
else
|
|
402 |
curBox:eval(newcode) |
|
|
1
by Stuart P. Bentley
initial scripts add+commit |
403 |
end
|
404 |
end
|
|
405 |
||
406 |
if not curBox.fParse then |
|
407 |
function curBox:fParse(message) |
|
|
10
by Stuart P. Bentley
moved branding/htdocs into own series |
408 |
returndata.font=values.editfont |
|
1
by Stuart P. Bentley
initial scripts add+commit |
409 |
coloretdata(self.color.fParse) |
|
10
by Stuart P. Bentley
moved branding/htdocs into own series |
410 |
returndata.value= |
411 |
message:gsub('%[string "(.-)"%]:(%d-):', |
|
412 |
string.format("%%1:%%2: %s:",strings.errors.parse)) |
|
|
1
by Stuart P. Bentley
initial scripts add+commit |
413 |
deactivate_down(iBox+1) |
414 |
end
|
|
415 |
end
|
|
416 |
||
417 |
if not curBox.fExec then |
|
418 |
function curBox:fExec(message) |
|
419 |
coloretdata(self.color.fExec) |
|
|
10
by Stuart P. Bentley
moved branding/htdocs into own series |
420 |
returndata.font=values.editfont |
421 |
returndata.value= |
|
422 |
message:gsub('%[string "(.-)"%]:(%d-):', |
|
423 |
string.format("%%1:%%2: %s:",strings.errors.run)) |
|
|
1
by Stuart P. Bentley
initial scripts add+commit |
424 |
deactivate_down(iBox+1) |
425 |
end
|
|
426 |
end
|
|
|
10.1.1
by Stuart P. Bentley
Multiprint appears to be working |
427 |
|
428 |
--internal environment functions
|
|
429 |
if not curBox.print then |
|
430 |
--using upvalues because this is called from the environment
|
|
431 |
function curBox.print(...) |
|
432 |
local tostrings={} |
|
433 |
arg={n=select('#',...),...} |
|
434 |
for i=1,arg.n do |
|
435 |
tostrings[i]=tostring(arg[i]) |
|
436 |
end
|
|
437 |
curBox.prints[#curBox.prints+1]=table.concat(tostrings,"\t") |
|
438 |
end
|
|
439 |
end
|
|
440 |
||
441 |
--link everything up
|
|
442 |
curBox:rechain() |
|
443 |
curBox:continue() |
|
|
1
by Stuart P. Bentley
initial scripts add+commit |
444 |
end
|
|
13
by Stuart P. Bentley
the top box autorun toggle works just about correctly now. it resets if you change, which is pretty much just the way I was planning, although I can see it being considered the "wrong" behavior. |
445 |
topboxauto=boxes[2].text.action |
|
1
by Stuart P. Bentley
initial scripts add+commit |
446 |
|
|
4
by Stuart P. Bentley
more pages and a rearranged about dialog |
447 |
--print box run setup
|
|
10.1.1
by Stuart P. Bentley
Multiprint appears to be working |
448 |
boxes[#boxes].eval=function(self,newcode) |
449 |
--if newcode wasn't passed then it's a situation where it hasn't
|
|
450 |
--been being passed
|
|
|
1
by Stuart P. Bentley
initial scripts add+commit |
451 |
newcode=newcode or self.text.value |
452 |
if newcode:find"%S" then |
|
453 |
newcode="return "..newcode |
|
|
10.1.1
by Stuart P. Bentley
Multiprint appears to be working |
454 |
end
|
455 |
local message |
|
|
12
by Stuart P. Bentley
merging multiprint |
456 |
self.f, message=loadstring(newcode,strings.boxnames[#boxes]) |
|
10.1.1
by Stuart P. Bentley
Multiprint appears to be working |
457 |
if self.f then |
458 |
self:chain() |
|
459 |
else
|
|
460 |
--reactivate so the user can fix the parse error
|
|
461 |
--(which could have been present before a prior box had an error
|
|
462 |
--and disabled all further boxes)
|
|
463 |
reactivate_box(self) |
|
464 |
self:fParse(message) |
|
465 |
end
|
|
466 |
end
|
|
467 |
||
468 |
--this is *partly* because i don't know a better way to preserve
|
|
|
13
by Stuart P. Bentley
the top box autorun toggle works just about correctly now. it resets if you change, which is pretty much just the way I was planning, although I can see it being considered the "wrong" behavior. |
469 |
--the return arguments from pcall (what with the possible nils).
|
|
10.1.1
by Stuart P. Bentley
Multiprint appears to be working |
470 |
local function outputwith(self,success,...) |
471 |
if not success then |
|
472 |
self:fExec(...) |
|
473 |
else
|
|
474 |
if select('#',...)>0 then |
|
475 |
self.print(...) |
|
476 |
--if #{...}>0 then
|
|
477 |
coloretdata(self.color.normal) |
|
478 |
elseif #self.prints >0 then |
|
479 |
coloretdata(self.color.normal) |
|
480 |
else --ain't nothing going to get printed nohow |
|
|
1
by Stuart P. Bentley
initial scripts add+commit |
481 |
coloretdata(self.color.blank) |
482 |
end
|
|
|
10.1.1
by Stuart P. Bentley
Multiprint appears to be working |
483 |
--set the good print font since it will be
|
484 |
--the small one after an error
|
|
485 |
returndata.font=values.printfont |
|
486 |
returndata.value=table.concat(self.prints,'\n') |
|
|
1
by Stuart P. Bentley
initial scripts add+commit |
487 |
end
|
488 |
end
|
|
489 |
||
|
10.1.1
by Stuart P. Bentley
Multiprint appears to be working |
490 |
boxes[#boxes].run=function(self) |
491 |
reactivate_box(self) |
|
492 |
self:continue() |
|
493 |
outputwith(self,pcall(self.f)) |
|
494 |
end
|
|
495 |
||
|
10
by Stuart P. Bentley
moved branding/htdocs into own series |
496 |
returndata=iup.multiline{font=values.printfont, bgcolor=values.printblank, |
497 |
alignment="ACENTER", border="YES", wordwrap="YES", expand="YES", |
|
|
13
by Stuart P. Bentley
the top box autorun toggle works just about correctly now. it resets if you change, which is pretty much just the way I was planning, although I can see it being considered the "wrong" behavior. |
498 |
readonly="YES", value=blankoutput, scrollbar="AUTOHIDE", |
|
10
by Stuart P. Bentley
moved branding/htdocs into own series |
499 |
appendnewline="NO", tip=strings.tips.output, tipfont="SYSTEM"} |
|
1
by Stuart P. Bentley
initial scripts add+commit |
500 |
|
|
4
by Stuart P. Bentley
more pages and a rearranged about dialog |
501 |
local function cheapsettingform(var) |
502 |
return " ".._G[var].." "..string.format(strings.settings.cheapformat,var) |
|
503 |
end
|
|
504 |
||
505 |
dialogs={ |
|
506 |
settings=iup.dialog{title=strings.settings.title; |
|
507 |
iup.hbox{ |
|
508 |
iup.label{title=strings.settings.delay}, |
|
509 |
iup.label{title=cheapsettingform"rundelay"} |
|
510 |
}
|
|
511 |
;margin="4x4" |
|
512 |
},
|
|
513 |
||
514 |
about=iup.dialog{title=strings.about.title; |
|
515 |
iup.vbox{ |
|
516 |
iup.hbox{ |
|
517 |
iup.vbox{ |
|
518 |
iup.label{title=strings.appname,font=values.printfont}, |
|
519 |
iup.label{title=strings.formats.version:format(version)}, |
|
520 |
iup.label{title=strings.about.byline}, |
|
521 |
iup.label{title=strings.formats.pushed:format(pushed)}, |
|
522 |
},
|
|
523 |
iup.fill{size=64}, |
|
524 |
iup.vbox{ |
|
525 |
iup.label{title="IUP "..iup._VERSION}, |
|
526 |
iup.label{title=_VERSION}, |
|
527 |
iup.fill{} |
|
528 |
;alignment="ARIGHT" |
|
529 |
}
|
|
530 |
;margin="0x0" |
|
531 |
},
|
|
532 |
iup.hbox{ |
|
533 |
iup.button{title=strings.about.license, |
|
534 |
tip=strings.tips.browser, |
|
535 |
padding="4x2", |
|
536 |
action=function() |
|
537 |
iup.Help(urls.license) |
|
538 |
end
|
|
539 |
},
|
|
540 |
iup.fill{}, |
|
541 |
iup.button{title=strings.about.email, |
|
542 |
tip=strings.tips.email, |
|
543 |
padding="4x2", |
|
544 |
action=function() |
|
545 |
iup.Help(urls.email) |
|
546 |
end
|
|
547 |
},
|
|
548 |
iup.button{title=strings.about.close, |
|
549 |
padding="4x2", |
|
550 |
action=function() |
|
551 |
return iup.CLOSE |
|
552 |
end
|
|
553 |
}
|
|
554 |
;margin=0,gap=4 |
|
555 |
}
|
|
556 |
;gap="2x2",margin="8x6",alignment="ABOTTOM" |
|
557 |
};
|
|
558 |
show_cb=function(self,state) |
|
559 |
if state==iup.SHOW then |
|
|
10
by Stuart P. Bentley
moved branding/htdocs into own series |
560 |
iup.SetFocus(self[1][2][4]) --fix committed |
|
4
by Stuart P. Bentley
more pages and a rearranged about dialog |
561 |
end
|
562 |
end
|
|
563 |
;dialogframe="YES" |
|
564 |
},
|
|
565 |
}
|
|
566 |
||
567 |
for _,each in pairs(dialogs) do |
|
568 |
each.icon=icon |
|
569 |
end
|
|
570 |
||
|
1
by Stuart P. Bentley
initial scripts add+commit |
571 |
Sandpad=iup.dialog{title=strings.appname; |
572 |
iup.hbox{ |
|
573 |
iup.vbox{ |
|
|
10
by Stuart P. Bentley
moved branding/htdocs into own series |
574 |
--development of filename in leftboxcontrols branch
|
|
5
by Stuart P. Bentley
branched off leftboxcontrols and internalfenv |
575 |
boxes[1].text |
|
10
by Stuart P. Bentley
moved branding/htdocs into own series |
576 |
--development of string/Lua radio in leftboxcontrols branch
|
|
1
by Stuart P. Bentley
initial scripts add+commit |
577 |
;gap=4--,margin=0 |
578 |
},
|
|
579 |
iup.vbox{ |
|
580 |
boxes[2].text, |
|
581 |
iup.hbox{ |
|
582 |
iup.hbox{ |
|
583 |
boxes[2].cls.artog, |
|
584 |
boxes[2].cls.run |
|
585 |
;gap=-1,margin="0x0",alignment="ACENTER" |
|
586 |
},
|
|
587 |
boxes[2].cls.clear |
|
588 |
;gap=4,alignment="ACENTER" |
|
589 |
},
|
|
590 |
iup.frame{title=strings.frames.box3; |
|
591 |
iup.vbox{ |
|
592 |
iup.hbox{ |
|
593 |
iup.hbox{ |
|
594 |
iup.label{title="("}, |
|
595 |
boxes[3].text, |
|
596 |
iup.label{title=")"} |
|
597 |
;gap=2,alignment="ACENTER" |
|
598 |
},
|
|
599 |
boxes[3].cls.clear |
|
600 |
;gap=4,margin=4 |
|
601 |
},
|
|
602 |
returndata
|
|
603 |
}
|
|
604 |
;gap=8 |
|
605 |
}
|
|
606 |
--;gap=4,margin=0
|
|
607 |
}
|
|
608 |
;margin="2x2",gap=0 |
|
609 |
}
|
|
610 |
;menu=iup.menu{ |
|
611 |
iup.submenu{title=strings.menus.file.title; |
|
612 |
iup.menu{ |
|
|
10
by Stuart P. Bentley
moved branding/htdocs into own series |
613 |
--development of file options in leftboxcontrols branch
|
|
1
by Stuart P. Bentley
initial scripts add+commit |
614 |
iup.item{title=strings.menus.file.clear, |
615 |
action=clearallboxes}, |
|
616 |
iup.separator{}, |
|
617 |
iup.item{title=strings.menus.file.quit, action="return iup.CLOSE"} |
|
618 |
}
|
|
619 |
},
|
|
620 |
iup.submenu{title=strings.menus.settings.title; |
|
621 |
iup.menu{ |
|
622 |
iup.item{title=strings.menus.settings.exe; |
|
623 |
action=function() |
|
624 |
dialogs.settings:popup() |
|
625 |
end
|
|
626 |
},
|
|
627 |
}
|
|
628 |
},
|
|
629 |
iup.submenu{title=strings.menus.help.title; |
|
630 |
iup.menu{ |
|
|
3
by Stuart P. Bentley
new links, changed version presentation, committing htdocs |
631 |
iup.item{title=strings.menus.help.manual; |
|
1
by Stuart P. Bentley
initial scripts add+commit |
632 |
action=function() |
|
3
by Stuart P. Bentley
new links, changed version presentation, committing htdocs |
633 |
iup.Help(urls.manual) |
|
1
by Stuart P. Bentley
initial scripts add+commit |
634 |
end
|
635 |
},
|
|
636 |
iup.separator{}, |
|
|
4
by Stuart P. Bentley
more pages and a rearranged about dialog |
637 |
iup.item{title=strings.menus.help.askq, |
638 |
action=function() |
|
639 |
iup.Help(urls.askq) |
|
640 |
end
|
|
641 |
},
|
|
|
2
by Stuart P. Bentley
icons and the files to use 'em |
642 |
iup.item{title=strings.menus.help.bugreport, |
|
1
by Stuart P. Bentley
initial scripts add+commit |
643 |
action=function() |
|
3
by Stuart P. Bentley
new links, changed version presentation, committing htdocs |
644 |
iup.Help(urls.bugreport) |
|
1
by Stuart P. Bentley
initial scripts add+commit |
645 |
end
|
646 |
},
|
|
647 |
iup.separator{}, |
|
|
4
by Stuart P. Bentley
more pages and a rearranged about dialog |
648 |
iup.submenu{title=strings.menus.help.pages; |
649 |
iup.menu{ |
|
650 |
iup.item{title=strings.pages.home; |
|
651 |
action=function() |
|
652 |
iup.Help(urls.home) |
|
653 |
end
|
|
654 |
},
|
|
655 |
iup.item{title=strings.pages.launchpad; |
|
656 |
action=function() |
|
657 |
iup.Help(urls.launchpad) |
|
658 |
end
|
|
659 |
},
|
|
660 |
iup.item{title=strings.pages.luaforge; |
|
661 |
action=function() |
|
662 |
iup.Help(urls.luaforge) |
|
663 |
end
|
|
664 |
},
|
|
665 |
}
|
|
666 |
},
|
|
|
1
by Stuart P. Bentley
initial scripts add+commit |
667 |
iup.item{title=strings.menus.help.about; |
668 |
action=function() |
|
|
4
by Stuart P. Bentley
more pages and a rearranged about dialog |
669 |
dialogs.about:popup() |
|
1
by Stuart P. Bentley
initial scripts add+commit |
670 |
end
|
671 |
}
|
|
672 |
}
|
|
673 |
}
|
|
674 |
}
|
|
|
2
by Stuart P. Bentley
icons and the files to use 'em |
675 |
;size="HALFxHALF",gap=4,margin="4x4",icon=icon, |
|
1
by Stuart P. Bentley
initial scripts add+commit |
676 |
minsize="400x250", |
677 |
shrink="YES", --should never come into play under MINSIZE |
|
678 |
}
|
|
679 |
||
680 |
local sysname=iup.GetGlobal "SYSTEM" |
|
681 |
if sysname~="Win2k" and sysname~="WinXP" then |
|
682 |
--for some reason it uses a meg less RAM this way (on my Vista x64 system)
|
|
683 |
Sandpad.layered="YES" |
|
684 |
Sandpad.layeralpha=255 |
|
685 |
end
|
|
686 |
||
687 |
Sandpad:show() |
|
688 |
iup.SetFocus(boxes[3].text) --box of least resistance |
|
689 |
||
690 |
iup.MainLoop() |