diff options
author | Hans Hagen <pragma@wxs.nl> | 2022-07-06 22:05:18 +0200 |
---|---|---|
committer | Context Git Mirror Bot <phg@phi-gamma.net> | 2022-07-06 22:05:18 +0200 |
commit | 82c674fdcf5bcff4ad0dc0936d638fc729145616 (patch) | |
tree | 6ab4ee4417aa22180cd5b3c50ede6a031f8ce3f9 /tex/context/base/mkxl/page-blk.lmt | |
parent | 3a55e11c7295abf8f2dfe5e9d1c8b153f4518824 (diff) | |
download | context-82c674fdcf5bcff4ad0dc0936d638fc729145616.tar.gz |
2022-07-06 21:35:00
Diffstat (limited to 'tex/context/base/mkxl/page-blk.lmt')
-rw-r--r-- | tex/context/base/mkxl/page-blk.lmt | 98 |
1 files changed, 98 insertions, 0 deletions
diff --git a/tex/context/base/mkxl/page-blk.lmt b/tex/context/base/mkxl/page-blk.lmt new file mode 100644 index 000000000..2078245e4 --- /dev/null +++ b/tex/context/base/mkxl/page-blk.lmt @@ -0,0 +1,98 @@ +if not modules then modules = { } end modules ['page-blk'] = { + version = 1.001, + comment = "companion to page-blk.mkiv", + author = "Hans Hagen, PRAGMA-ADE, Hasselt NL", + copyright = "PRAGMA ADE / ConTeXt Development Team", + license = "see context related readme files" +} + +local context = context +local implement = interfaces.implement +local texgetcount = tex.getcount + +local blocks = { } +local block = false + +implement { + name = "startpageblock", + arguments = "string", + actions = function(s) + local p = texgetcount("realpageno") + block = { p, p } + blocks[s] = block + end, +} + +implement { + name = "stoppageblock", + actions = function() + local p = texgetcount("realpageno") - 1 + block[2] = p + end, +} + +implement { + name = "pageblockrealpage", + arguments = "string", + actions = function(name) + local b = blocks[name] + context(b and b[1] or 0) + end, +} + +implement { + name = "flushpageblocks", + arguments = "string", + actions = function(list) + local count = 0 + local order = utilities.parsers.settings_to_array(list) + local pages = { } + for i=1,#order do + local name = order[i] + local block = blocks[name] + if block then + for i=block[1],block[2] do + count = count + 1 + pages[count] = i + end + end + end + -- if count ~= nofpages then + -- end + -- inspect(blocks) + -- inspect(pages) + if lpdf.setpageorder then + lpdf.setpageorder(pages) -- ,count) + end + end +} + +-- maybe intercept nesting with error + +local currentpreroll = false +local prerolled = { } + +implement { + name = "startprerollpageblock", + arguments = "string", + actions = function(name) + currentrealpage = texgetcount("realpageno") + currentpreroll = name + end +} + +implement { + name = "stopprerollpageblock", + actions = function() + prerolled[currentpreroll] = texgetcount("realpageno") - currentrealpage + currentpreroll = false + end +} + +implement { + name = "prerolledpages", + arguments = "string", + actions = function(name) + context(prerolled[name] or 0) + end +} |