Skip to content

Commit 0aef45f

Browse files
committed
Show run buttons green when running
1 parent 8198da7 commit 0aef45f

File tree

7 files changed

+149
-100
lines changed

7 files changed

+149
-100
lines changed

dist/plugins/iwsy.js

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -194,11 +194,28 @@ const EasyCoder_IWSY = {
194194

195195
value: {
196196

197-
compile: () => {
197+
compile: (compiler) => {
198+
if (compiler.tokenIs(`the`)) {
199+
if (compiler.nextTokenIs(`step`)) {
200+
compiler.next();
201+
return {
202+
domain: `iwsy`,
203+
type: `step`
204+
};
205+
}
206+
}
198207
return null;
199208
},
200209

201-
get: () => {
210+
get: (program, value) => {
211+
switch (value.type) {
212+
case `step`:
213+
return {
214+
type: `constant`,
215+
numeric: true,
216+
content: program.iwsyStep
217+
};
218+
}
202219
return null;
203220
}
204221
},

iwsy/iwsy.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -532,7 +532,7 @@ const IWSY = (container, text) => {
532532

533533
// Set a step callback
534534
const onStep = onStepCB => {
535-
script.onstepCB = onStepCB;
535+
script.onStepCB = onStepCB;
536536
};
537537

538538
// Chain to another presentation
@@ -678,6 +678,7 @@ const IWSY = (container, text) => {
678678
setScript,
679679
gotoStep,
680680
run,
681-
stop
681+
stop,
682+
onStep
682683
};
683684
};

iwsy/resources/ecs/blocks.txt

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -95,8 +95,10 @@ Restart:
9595
create TR in Table
9696
create TD in TR
9797
set the style of TD to `width:8em;border:1px solid black;padding-left:0.5em`
98+
index BlockNameSpan to B
9899
create BlockNameSpan in TD
99100
set the content of BlockNameSpan to BlockName
101+
index BlockNameInput to B
100102
create BlockNameInput in TD
101103
set the style of BlockNameInput to `width:100%;display:none`
102104
set the content of BlockNameInput to BlockName
@@ -124,13 +126,12 @@ Restart:
124126
begin
125127
gosub to SaveSelectedBlock
126128
put the index of EditButton into SelectedBlock
127-
put the text of EditButton into Action
128129
put 0 into N
129130
while N is less than the json count of BlockNames
130131
begin
131132
index EditButton to N
132133
set style `background` of EditButton to ``
133-
set the text of EditButton to `Edit`
134+
if N is not SelectedBlock set the text of EditButton to `Edit`
134135
index BlockNameSpan to N
135136
index BlockNameInput to N
136137
set the content of BlockNameSpan to the text of BlockNameInput
@@ -141,6 +142,7 @@ Restart:
141142
add 1 to N
142143
end
143144
index EditButton to SelectedBlock
145+
put the text of EditButton into Action
144146
if Action is `Edit`
145147
begin
146148
set style `background` of EditButton to `lightgray`
@@ -172,7 +174,13 @@ Restart:
172174
add 1 to N
173175
end
174176
end
175-
else gosub to SaveSelectedBlock
177+
else
178+
begin
179+
gosub to SaveSelectedBlock
180+
set the text of EditButton to `Edit`
181+
clear Editor
182+
set style `display` of Editor to `none`
183+
end
176184
end
177185
on click DeleteBlock
178186
begin

iwsy/resources/ecs/content.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,8 +81,10 @@ Restart:
8181
create TR in Table
8282
create TD in TR
8383
set the style of TD to `width:8em;border:1px solid black`
84+
index ItemNameSpan to B
8485
create ItemNameSpan in TD
8586
set the content of ItemNameSpan to ItemName
87+
index ItemNameInput to B
8688
create ItemNameInput in TD
8789
set the style of ItemNameInput to `width:100%;display:none`
8890
set the content of ItemNameInput to ItemName

iwsy/resources/ecs/iwsy.txt

Lines changed: 50 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@
4848
variable CurrentScriptName
4949
variable Action
5050
variable Source
51+
variable Running
5152
variable N
5253

5354
! The browser
@@ -306,13 +307,16 @@ L2:
306307
end
307308
end
308309

310+
on click RunStop go to DoRunStop
311+
309312
gosub to CreateNewPresentation
310313
put Presentation into LastSavedState
311314
gosub to SetupSteps
312315
gosub to SetupBlocks
313316
gosub to SetupContent
314317
put 0 into N
315318
gosub to SelectSection
319+
clear Running
316320

317321
on message
318322
begin
@@ -322,7 +326,12 @@ L2:
322326
else if Action is `refresh`
323327
begin
324328
iwsy script Presentation
325-
gosub to UpdateCurrentSection
329+
set style `display` of StepsPanel to `none`
330+
set style `display` of BlocksPanel to `none`
331+
set style `display` of ContentPanel to `none`
332+
if Section is 0 set style `display` of StepsPanel to `block`
333+
else if Section is 1 set style `display` of BlocksPanel to `block`
334+
else if Section is 2 set style `display` of ContentPanel to `block`
326335
end
327336
end
328337
stop
@@ -506,6 +515,7 @@ SelectFile:
506515
set the content of Status to `Presentation '` cat File cat `' loaded`
507516
fork to ResetStatus
508517
set ShowRun
518+
print Presentation
509519
iwsy load Player Presentation
510520

511521
CloseBrowser:
@@ -527,6 +537,45 @@ ResetStatus:
527537
set the content of Status to ``
528538
stop
529539

540+
DoRunStop:
541+
if Running
542+
begin
543+
clear Running
544+
gosub to ClearStepsButtons
545+
set attribute `src` of RunStop to `resources/icon/run.png`
546+
iwsy stop
547+
end
548+
else
549+
begin
550+
set Running
551+
put property `steps` of Presentation into Item
552+
if the json count of Item is 0 stop
553+
set attribute `src` of RunStop to `resources/icon/runstop.png`
554+
555+
iwsy onstep
556+
begin
557+
set Message to object
558+
set property `action` of Message to `step`
559+
set property `step` of Message to the step
560+
send Message to StepsModule
561+
end
562+
563+
iwsy run then
564+
begin
565+
gosub to ClearStepsButtons
566+
set attribute `src` of RunStop to `resources/icon/run.png`
567+
clear Running
568+
stop
569+
end
570+
end
571+
stop
572+
573+
ClearStepsButtons:
574+
set Message to object
575+
set property `action` of Message to `clear`
576+
send Message to StepsModule
577+
return
578+
530579
GetPassword:
531580
if ReadOnly
532581
begin

0 commit comments

Comments
 (0)