page-str.mkxl /size: 3945 b    last modification: 2023-12-21 09:44
1%D \module
2%D   [       file=page-str,
3%D        version=2010.03.13, % 2006.03.21,
4%D          title=\CONTEXT\ Page Macros,
5%D       subtitle=Page Streams,
6%D         author=Hans Hagen,
7%D           date=\currentdate,
8%D      copyright={PRAGMA ADE \& \CONTEXT\ Development Team}]
9%C
10%C This module is part of the \CONTEXT\ macro||package and is
11%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
12%C details.
13
14\writestatus{loading}{ConTeXt Page Macros / Page Streams}
15
16%D The first version of this component of \CONTEXT\ was written for Thomas Schmitz
17%D who asked for parallel page streams. While playing with the code, I decided to
18%D make it into a component that can be used to construct all kind of stream related
19%D mechanisms. Because I could apply this feature in a project, there is some
20%D additional code here (related to graphics).
21%D
22%D These macros were written while listening to and watching the DVD \quotation
23%D {Rush In Rio}.
24%D
25%D The reimplementation (or rather experimenting with the complete rewrite) was done
26%D while looping over \quotation {Wende Snijders No.9}.
27%D
28%D Remark: marknotes are gone, at least for a while.
29
30\registerctxluafile{page-str}{autosuffix}
31
32\unprotect
33
34\mutable\lettonothing\currentoutputstream
35
36\newif   \ifinoutputstream        % will become a conditional or mode
37\newtoks \everyenableoutputstream
38
39\appendtoks
40    \page_otr_command_flush_side_floats
41\to \everyenableoutputstream
42
43\permanent\protected\def\initializeoutputstreams
44  {\clf_initializestream
45   \enforced\glet\initializeoutputstreams\relax}
46
47\permanent\protected\def\enableoutputstream[#1]% could be \startoutputsubstream
48  {\initializeoutputstreams
49   \expand\everyenableoutputstream
50   \inoutputstreamtrue
51   \xdef\currentoutputstream{#1}%
52   \clf_enablestream{#1}
53   \prevdepth\zeropoint} % maybe more is needed i.e. we need to get rid of leading glue
54
55\permanent\protected\def\disableoutputstream
56  {\inoutputstreamfalse
57   \glet\currentoutputstream\s!default
58   \clf_disablestream}
59
60\permanent\protected\def\startoutputstream[#1]%
61  {\begingroup
62   \initializeoutputstreams
63   \expand\everyenableoutputstream
64   \inoutputstreamtrue
65   \xdef\currentoutputstream{#1}%
66   \clf_startstream{#1}}
67
68\permanent\protected\def\stopoutputstream
69  {\clf_stopstream
70   \endgroup}
71
72\permanent\protected\def\startoutputsubstream[#1]% just push/pop instead
73  {\globalpushmacro\currentoutputstream
74   \enableoutputstream[#1]}
75
76\permanent\protected\def\stopoutputsubstream
77  {\globalpopmacro\currentoutputstream
78   \enableoutputstream[\currentoutputstream]}
79
80\permanent         \protected\def\flushoutputstream  [#1]{\clf_flushstream{#1}}
81\permanent         \protected\def\outputstreambox    [#1]{\vbox{\clf_flushstream{#1}}}
82\permanent         \protected\def\outputstreamcopy   [#1]{\vbox{\clf_flushstreamcopy{#1}}}
83\permanent         \protected\def\outputstreamunvbox [#1]{\clf_flushstream{#1}}
84\permanent         \protected\def\outputstreamunvcopy[#1]{\clf_flushstreamcopy{#1}}
85\permanent         \protected\def\synchronizestreams [#1]{\clf_synchronizestream{#1}}
86\permanent\tolerant\protected\def\pushoutputstream   [#1]{\clf_pushstream{#1}}
87
88\protect \endinput
89
90% \enabletrackers[streams.flushing]
91%
92% \setuplayout[grid=yes] \showgrid
93%
94% \starttext
95%
96% \input tufte
97%
98% \startoutputstream[nl]
99%
100% Wat doen we hier?
101%
102% \enableoutputstream[en]
103%
104% Are you sleeping, brother John?\footnote{xxx}
105%
106% \dorecurse{4}{x \footnote{note \recurselevel}\input tufte \par \pushoutputstream}
107%
108% \enableoutputstream[de]
109%
110% Bruder Jakob, schläfst du noch?\footnote{yyy}
111%
112% \dorecurse{4}{x \footnote{note \recurselevel}\input ward \par \pushoutputstream}
113%
114% \disableoutputstream
115%
116% \stopoutputstream
117%
118% Vader Jacob, slaap je nog?\footnote{zzz}
119%
120% \input tufte
121%
122% \synchronizestreams[en,de,nl]
123%
124% \page \flushoutputstream[en] \input knuth
125% \page \flushoutputstream[de] \input knuth
126% \page \flushoutputstream[nl] \input knuth
127%
128% \stoptext
129