summaryrefslogtreecommitdiff
path: root/tex/context/base/page-mis.mkiv
diff options
context:
space:
mode:
Diffstat (limited to 'tex/context/base/page-mis.mkiv')
-rw-r--r--tex/context/base/page-mis.mkiv95
1 files changed, 95 insertions, 0 deletions
diff --git a/tex/context/base/page-mis.mkiv b/tex/context/base/page-mis.mkiv
new file mode 100644
index 000000000..6137bb462
--- /dev/null
+++ b/tex/context/base/page-mis.mkiv
@@ -0,0 +1,95 @@
+%D \module
+%D [ file=page-mis,
+%D version=2008.11.17, % was part of page-flt.tex / 2000.10.20
+%D title=\CONTEXT\ Page Macros,
+%D subtitle=Misc Float Things,
+%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.
+
+\writestatus{loading}{ConTeXt Page Macros / Misc Float Things}
+
+\registerctxluafile{page-mis}{1.001}
+
+\unprotect
+
+% postponing
+
+\newevery\everytopofpage\relax
+
+\appendtoks \the\everytopofpage \to\everystarttext
+\appendtoks\global\everytopofpage\emptytoks\to\everystoptext
+
+% \startpostponing [pagenumber] [+pageoffset]
+%
+% \startpostponing[2]
+% PAGE 2 \blank
+% \stoppostponing
+%
+% \startpostponing[+1]
+% PAGE +1 \blank
+% \stoppostponing
+%
+% \startpostponing[+2]
+% PAGE +2 \blank
+% \stoppostponing
+%
+% \starttext \dorecurse{4}{\input tufte \page} \stoptext
+
+%D There is no real need to use \LUA\ here but the bookkeeping
+%D is somewhat easier and we also can erase buffers easier when
+%D we keep a local cache, especially as we can flush per page.
+
+\newif \ifinpostponing % prevents nesting
+\newcount\c_page_postponed_blocks_next_page % set at the lua end
+
+\unexpanded\setvalue{\e!start\v!postponing}%
+ {\bgroup
+ \obeylines
+ \doifnextoptionalelse{\egroup\page_postponed_blocks_start}{\egroup\page_postponed_blocks_start[0]}}
+
+\unexpanded\setvalue{\e!stop\v!postponing}%
+ {\ctxcommand{registerpostponedblock("\currentpostponedpage")}\relax}
+
+\def\page_postponed_blocks_start[#1]%
+ {\edef\currentpostponedpage{#1}%
+ \grabbufferdatadirect{postponedblock}{\e!start\v!postponing}{\e!stop\v!postponing}}
+
+% officially we should flush again after a flush as there can be new future pages
+% but that will be looked into when we run into it
+
+\unexpanded\def\page_postponed_blocks_flush_indeed
+ {\begingroup
+ \setsystemmode\v!postponing
+ \inpostponingtrue % for old times sake
+ \global\pagetotal\zeropoint % here? still needed? (was after flush pagefloats)
+ \the\everytopofpage\relax
+ %\flushrestfloats
+ \doflushpagefloats
+ \setnormalcatcodes % postponing in verbatim
+ \restoreglobalbodyfont % otherwise problems inside split verbatim
+ \ctxcommand{flushpostponedblocks()}%
+ \relax
+ \page_otr_command_flush_floats % new but potential dangerous, maybe we need a classification
+ \endgroup} % of blocks: with and without flush
+
+\def\page_postponed_blocks_flush
+ {\ifinpostponing
+ % probably a nested flush
+ \else\ifnum\c_page_postponed_blocks_next_page=\zerocount
+ % nothing in cache
+ \else\ifnum\c_page_postponed_blocks_next_page<\zerocount
+ % generic cache
+ \page_postponed_blocks_flush_indeed
+ \else\ifnum\c_page_postponed_blocks_next_page>\realpageno
+ % future content
+ \else
+ % pending content
+ \page_postponed_blocks_flush_indeed
+ \fi\fi\fi\fi}
+
+\protect \endinput