diff options
author | Context Git Mirror Bot <phg42.2a@gmail.com> | 2016-03-12 17:15:10 +0100 |
---|---|---|
committer | Context Git Mirror Bot <phg42.2a@gmail.com> | 2016-03-12 17:15:10 +0100 |
commit | 4b6314243d4bc44fa3c94f569264fdffd5405e90 (patch) | |
tree | a50e4f3309d40b2709618a00311934c55258cfbc /tex/context/base/mkiv/cldf-stp.lua | |
parent | 4a28e5cee346738f2f9be479090c3657a87b7206 (diff) | |
download | context-4b6314243d4bc44fa3c94f569264fdffd5405e90.tar.gz |
2016-03-12 16:45:00
Diffstat (limited to 'tex/context/base/mkiv/cldf-stp.lua')
-rw-r--r-- | tex/context/base/mkiv/cldf-stp.lua | 69 |
1 files changed, 69 insertions, 0 deletions
diff --git a/tex/context/base/mkiv/cldf-stp.lua b/tex/context/base/mkiv/cldf-stp.lua new file mode 100644 index 000000000..7b5225dd3 --- /dev/null +++ b/tex/context/base/mkiv/cldf-stp.lua @@ -0,0 +1,69 @@ +if not modules then modules = { } end modules ['cldf-stp'] = { + version = 1.001, + comment = "companion to cldf-ini.mkiv", + author = "Hans Hagen, PRAGMA-ADE, Hasselt NL", + copyright = "PRAGMA ADE / ConTeXt Development Team", + license = "see context related readme files" +} + +-- limitation: input levels + +-- context.stepwise (function() +-- ... +-- context.step(nil|...) +-- ... +-- context.step(nil|...) +-- ... +-- context.stepwise (function() +-- ... +-- context.step(nil|...) +-- ... +-- context.step(nil|...) +-- ... +-- end) +-- ... +-- context.step(nil|...) +-- ... +-- context.step(nil|...) +-- ... +-- end) + +local create = coroutine.create +local yield = coroutine.yield +local resume = coroutine.resume +local status = coroutine.status + +local stepper = nil +local stack = { } -- will never be deep so no gc needed +local depth = 0 + +local nextstep = function() + if status(stepper) == "dead" then + stepper = stack[depth] + depth = depth - 1 + stack[depth] = false + end + resume(stepper) +end + +interfaces.implement { + name = "step", + actions = nextstep, +} + +local cldresume = context.constructcsonly("clf_step") + +function context.step(first,...) + if first ~= nil then + context(first,...) + end + cldresume() + yield() +end + +function context.stepwise(f) + depth = depth + 1 + stack[depth] = stepper + stepper = create(f) + resume(stepper) +end |