1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
|
%D \module
%D [ file=s-present-steps,
%D version=2018.05.17,
%D title=\CONTEXT\ Style File,
%D subtitle=Presentation Environment Repeated Steps,
%D author=Hans Hagen,
%D date=\currentdate,
%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}]
%C
%C This module is part of the \CONTEXT\ macro||package and is
%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
%C details.
%D This a preliminary module, a quick hack and not entirely proper \CONTEXT, but
%D let's see what more is needed.
\startmodule[present-steps]
\startluacode
moduledata.steps = moduledata.steps or { }
local steps = moduledata.steps
local data = { }
local name = "unknown"
local set = 0
local settings = nil
function steps.startsteps(buffername)
set = set + 1
data = { }
name = buffername
end
function steps.stopsteps()
local n = 0
for i=1,#data do
local state = "once"
local done = 0
while true do
context.startprocessingsteps()
for j=1,i do
local step = data[j]
local nested = step.nested
local content = step.content
local last = (i == #data) and (j == i) and 1 or 0
local option = step.option
local flush = true
if option == interfaces.variables["title"] then
if i > 1 then
flush = false
end
elseif option == interfaces.variables["repeat"] then
if i == 1 then
flush = false
end
end
if flush then
if j < i or nested == 0 then
context(function()
buffers.assign("step",content)
context.processstep("step",i,0,last)
-- context.writestatus("step a",string.formatters["%i %i %i"](i,0,last))
end)
state = "done"
else
done = done + 1
local d = done
context(function()
buffers.assign("step",content)
context.processstep("step",i,d,last)
-- context.writestatus("step b",string.formatters["%i %i %i"](i,d,last))
end)
if done == nested then
state = "done"
n = n + nested
else
state = "busy"
end
end
end
end
context.stopprocessingsteps()
if state == "done" then
break
end
end
end
end
function steps.startstep(str)
settings = utilities.parsers.settings_to_hash(str)
end
function steps.stopstep()
settings.content = buffers.getcontent(name)
settings.nested = tonumber(settings.n) or 0
data[#data+1] = settings
end
function steps.startsubstep(str)
local d = data[#data]
d.nested = d.nested + 1
end
function steps.stopsubstep()
end
\stopluacode
\definebuffer
[step]
\def\currentstep {0}
\def\currentsubstep{0}
\unexpanded\def\startprocessingsteps
{\global\wantedsubstep\zerocount}
\unexpanded\def\stopprocessingsteps
{}
\unexpanded\def\processstep#1#2#3#4%
{\par
\edef\currentstep {#2}%
\edef\currentsubstep{#3}%
\ifcase#4\relax
\setupreferencing[prefix=#2:#3]
\getbuffer[#1]%
\par
\else
\setupreferencing[prefix=]
\getbuffer[#1]%
\page
\fi}
\let\normalstartstep\startstep
\newcount\wantedsubstep
\unexpanded\def\startsteps
{\ctxlua{moduledata.steps.startsteps("\thedefinedbuffer{step}")}}
\unexpanded\def\stopsteps
{\ctxlua{moduledata.steps.stopsteps()}}
\unexpanded\def\startstep
{\dosingleempty\startstepindeed}
\def\startstepindeed[#1]%
{\ctxlua{moduledata.steps.startstep("#1")}%
\normalstartstep}
\unexpanded\def\stopstep
{\ctxlua{moduledata.steps.stopstep()}}
\let\stopsubstep\relax
\unexpanded\def\startsubstep#1\stopsubstep
{\ctxlua{moduledata.steps.startsubstep()}%
\ifcase\currentsubstep\relax
#1%
\else
\global\advance\wantedsubstep\plusone
\ifnum\currentsubstep>\wantedsubstep\else
#1%
\fi
\fi
\ctxlua{moduledata.steps.stopsubstep()}}
\stopmodule
\continueifinputfile{s-present-steps.mkiv}
\usemodule[present-common]
\inputpresentationfile{examples/present-steps-001.tex}
|