s-present-stepwise.mkiv /size: 5112 b    last modification: 2020-07-01 14:35
1
%D \module
2
%D [ file=s-present-stepwise, % was s-pre-60
3
%D version=2004.03.15,
4
%D title=\CONTEXT\ Style File,
5
%D subtitle=Presentation Environment Stepwise,
6
%D author=Hans Hagen,
7
%D date=\currentdate,
8
%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}]
9
%C
10
%C This module is part of the \CONTEXT\ macro||package and is
11
%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
12
%C details.
13 14
% use lua instead of global mess
15 16
\startmodule
[
present
-
stepwise
]
17 18
\unprotect
19 20
\startmode
[
paper
,
print
]
21
\let
\StartSteps
\relax
22
\let
\StopSteps
\relax
23
\let
\FlushStep
\relax
24
\let
\ResetStep
\relax
25
\let
\StartBusy
\relax
26
\let
\StopBusy
\relax
27
\endinput
28
\stopmode
29 30
\newcount
\c_module_pre_steps_current
31
\newcount
\c_module_pre_steps_maximum
32
\newcount
\c_module_pre_steps_nesting_step
33
\newcount
\c_module_pre_steps_nesting_steps
34
\newcount
\c_module_pre_steps_nesting_busy
35 36
\def
\StepCounter
{
\the
\c_module_pre_steps_current
}
37
\def
\StepMaximum
{
\the
\c_module_pre_steps_maximum
}
38
\def
\StepLayer
{
step
:
\the
\c_module_pre_steps_current
}
39
\def
\NextStepLayer
{
step
:
\the\numexpr
\c_module_pre_steps_current
+
\plusone
\relax
}
40
\def
\FirstStepLayer
{
step
:
1
}
41 42
\useJSscripts
[
stp
]
43 44
\startsetups
[
set
-
stepper
]
45 46
\ifnum
\getvariable
{
stepper
}{
nofsteps
}
>
\c_module_pre_steps_maximum
47 48
\dostepwiserecurse
{
\numexpr
\c_module_pre_steps_maximum
+
\plusone
\relax
}
{
\getvariable
{
stepper
}{
nofsteps
}}
{
1
}
{
49
\doifnotmode
{
nosteps
,
nostep
}
{
50
\expanded
{
\defineviewerlayer
[
step
:
\recurselevel
][
state
=
stop
,
scope
=
global
]
}
51
}
52
}
53 54
\global
\c_module_pre_steps_maximum
\getvariable
{
stepper
}{
nofsteps
}
\relax
55 56
\fi
57 58
\stopsetups
59 60
\setvariables
61
[
stepper
]
62
[
set
=
\setups
{
set
-
stepper
}
,
63
nofsteps
=
5
0
]
64 65
\defineviewerlayer
[
step
:
busy
][
state
=
start
]
66 67
\definereference
[
SetupStepper
]
[
JS
(
SetupStepper
{
step
,
\StepMaximum
}
)]
68
\definereference
[
ResetStepper
]
[
JS
(
ResetStepper
)]
69
\definereference
[
CheckStepper
]
[
JS
(
CheckStepper
{
\StepCounter
}
)]
70
\definereference
[
InvokeStepper
]
[
JS
(
InvokeStepper
)]
71 72
% todo: roll back blank
73 74
\unexpanded
\def
\ResetStep
75
{
\iftrialtypesetting
\else
76
\global
\c_module_pre_steps_current
\zerocount
77
\fi
}
78 79
\unexpanded
\def
\NextStep
80
{
\iftrialtypesetting
\else
81
\global\advance
\c_module_pre_steps_current
\plusone
82
\fi
}
83 84
\unexpanded
\def
\PrevStep
85
{
\iftrialtypesetting
\else
86
\global\advance
\c_module_pre_steps_current
\minusone
87
\fi
}
88 89
\unexpanded
\def
\FlushStep
90
{
\iftrialtypesetting
\else
91
\StopStep
92
\NextStep
93
\StartStep
94
\fi
}
95 96
\unexpanded
\def
\StartStep
97
{
\iftrialtypesetting
\else
98
\global\advance
\c_module_pre_steps_nesting_step
\plusone
99
\ifcase
\c_module_pre_steps_nesting_step
\or
100
\startviewerlayer
[
\StepLayer
]
%
101
\fi
102
\fi
103
\ignorespaces
}
104 105
\unexpanded
\def
\StopStep
106
{
\removeunwantedspaces
107
\iftrialtypesetting
\else
108
\ifcase
\c_module_pre_steps_nesting_step
\or
109
\stopviewerlayer
110
\fi
111
\global\advance
\c_module_pre_steps_nesting_step
\minusone
112
\fi
}
113 114
\unexpanded
\def
\StartSteps
115
{
\iftrialtypesetting
\else
116
\global\advance
\c_module_pre_steps_nesting_steps
\plusone
117
\ifcase
\c_module_pre_steps_nesting_steps
\or
118
\ResetStep
119
\NextStep
120
\StartStep
121
\fi
122
\fi
}
123 124
\unexpanded
\def
\StopSteps
125
{
\iftrialtypesetting
\else
126
\ifcase
\c_module_pre_steps_nesting_steps
\or
127
\StopStep
128
\PrevStep
129
\fi
130
\global\advance
\c_module_pre_steps_nesting_steps
\minusone
131
\fi
}
132 133
\unexpanded
\def
\StartBusy
134
{
\iftrialtypesetting
\else
135
\global\advance
\c_module_pre_steps_nesting_busy
\plusone
136
\ifcase
\c_module_pre_steps_nesting_busy
\or
137
\startviewerlayer
[
step
:
busy
]
138
\fi
139
\fi
140
\ignorespaces
}
141 142
\unexpanded
\def
\StopBusy
143
{
\removeunwantedspaces
144
\iftrialtypesetting
\else
145
\ifcase
\c_module_pre_steps_nesting_busy
\or
146
\stopviewerlayer
147
\fi
148
\global\advance
\c_module_pre_steps_nesting_busy
\minusone
149
\fi
}
150 151
%D Handy:
152 153
\unexpanded
\def
\StartLocalSteps
154
{
\ResetStep
}
155 156
\unexpanded
\def
\StopLocalSteps
157
{}
158 159
\unexpanded
\def
\StartLocalStep
160
{
\NextStep
161
\StartStep
}
162 163
\unexpanded
\def
\StopLocalStep
164
{
\StopStep
}
165 166
\appendtoks
167
\ResetStep
168
\to
\everyaftershipout
169 170
\setupinteraction
171
[
%openaction=SetupStepper,
172
closeaction
=
ResetStepper
,
173
openpageaction
=
CheckStepper
,
174
closepageaction
=
ResetStepper
]
175 176
\defineoverlay
[
invoke
][
\overlaybutton
{
InvokeStepper
}
]
177 178
\setupbackgrounds
179
[
text
]
180
[
background
=
invoke
]
181 182
% bonus
183 184
\useMPlibrary
[
nav
]
185 186
\definepalet
187
[
navplus
]
188
[
attach
=
interactioncolor
,
189
comment
=
interactioncolor
]
190 191
\setupcomment
192
[
symbol
=
{
comment
-
normal
,
comment
-
down
}
,
193
textlayer
=
\StepLayer
,
194
option
=
buffer
,
195
height
=
\textheight
,
196
width
=
\textwidth
,
197
margin
=
0
pt
]
198 199
\setupattachments
200
[
symbol
=
{
attach
-
normal
,
attach
-
down
}
,
201
textlayer
=
\StepLayer
]
202 203
%D used as (given some definitions):
204
%D
205
%D \starttyping
206
%D \StartLocalSteps
207
%D \startcombination[both]
208
%D {\StartLocalStep\placestreamlayer[left]\StopLocalStep} {}
209
%D {\StartLocalStep\placestreamlayer[right]\StopLocalStep} {}
210
%D \stopcombination
211
%D \StopLocalSteps
212
%D \stoptyping
213 214
\protect
215 216
\stopmodule
217