diff options
author | Hans Hagen <pragma@wxs.nl> | 2018-05-19 22:19:19 +0200 |
---|---|---|
committer | Context Git Mirror Bot <phg42.2a@gmail.com> | 2018-05-19 22:19:19 +0200 |
commit | 6a68bb9d4e7e8454b031143b9cd14edf3702a68d (patch) | |
tree | 14cb116ce0f1adc4459d6cea9aee07cacd3541fd /tex/context/modules | |
parent | 2e8819dad63db17febca68fd6b7ba9a06f9c50b5 (diff) | |
download | context-6a68bb9d4e7e8454b031143b9cd14edf3702a68d.tar.gz |
2018-05-19 21:51:00
Diffstat (limited to 'tex/context/modules')
-rw-r--r-- | tex/context/modules/mkiv/s-present-steps.mkiv | 113 |
1 files changed, 88 insertions, 25 deletions
diff --git a/tex/context/modules/mkiv/s-present-steps.mkiv b/tex/context/modules/mkiv/s-present-steps.mkiv index dbfabf9cd..432650a5e 100644 --- a/tex/context/modules/mkiv/s-present-steps.mkiv +++ b/tex/context/modules/mkiv/s-present-steps.mkiv @@ -32,20 +32,18 @@ function steps.startsteps(buffername) name = buffername end -function steps.startstep(str) - settings = utilities.parsers.settings_to_hash(str) -end - -function steps.stopstep() - settings.content = buffers.getcontent(name) - data[#data+1] = settings -end - function steps.stopsteps() + local n = 0 for i=1,#data do - for j=1,i do - local step = data[j] - if step then + 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 @@ -58,37 +56,94 @@ function steps.stopsteps() end end if flush then - context(function() - buffers.assign("step",step.content) - context.processstep("step",set,j,i) - end) + 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\currentstep {0} +\def\currentsubstep{0} + +\unexpanded\def\startprocessingsteps + {\global\wantedsubstep\zerocount} + +\unexpanded\def\stopprocessingsteps + {} \unexpanded\def\processstep#1#2#3#4% {\par - \edef\currentstep{#4}% - \ifnum#3=#4\relax + \edef\currentstep {#2}% + \edef\currentsubstep{#3}% + \ifcase#4\relax \setupreferencing[prefix=#2:#3] \getbuffer[#1]% - \page + \par \else + \setupreferencing[prefix=] \getbuffer[#1]% - \par + \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} @@ -99,11 +154,19 @@ end \unexpanded\def\stopstep {\ctxlua{moduledata.steps.stopstep()}} -\unexpanded\def\startsteps - {\ctxlua{moduledata.steps.startsteps("\thedefinedbuffer{step}")}} +\let\stopsubstep\relax -\unexpanded\def\stopsteps - {\ctxlua{moduledata.steps.stopsteps()}} +\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 |