page-str.mkiv /size: 4409 b    last modification: 2020-07-01 14:35
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
17%D for Thomas Schmitz who asked for parallel page streams. While
18%D playing with the code, I decided to make it into a component
19%D that can be used to construct all kind of stream related
20%D mechanisms. Because I could apply this feature in a project,
21%D there is some additional code here (related to graphics).
22%D
23%D These macros were written while listening to and watching the DVD
24%D \quotation {Rush In Rio}.
25%D
26%D The reimplementation (or rather experimenting with the complete
27%D rewrite) was done while looping over \quotation {Wende Snijders
28%D No.9}.
29%D
30%D Remark: marknotes are gone, at least for a while.
31
32\registerctxluafile{page-str}{}
33
34\unprotect
35
36\let     \currentoutputstream     \empty
37\newif   \ifinoutputstream        % will become a conditional or mode
38\newtoks \everyenableoutputstream
39
40\appendtoks
41    \page_otr_command_flush_side_floats
42\to \everyenableoutputstream
43
44\unexpanded\def\initializeoutputstreams
45  {\clf_initializestream
46   \glet\initializeoutputstreams\relax}
47
48\unexpanded\def\enableoutputstream[#1]% could be \startoutputsubstream
49  {\initializeoutputstreams
50   \the\everyenableoutputstream
51   \inoutputstreamtrue
52   \xdef\currentoutputstream{#1}%
53   \clf_enablestream{#1}
54   \prevdepth\zeropoint % maybe more is needed i.e. we need to get rid of leading glue
55   }
56
57\unexpanded\def\disableoutputstream
58  {\inoutputstreamfalse
59   \glet\currentoutputstream\s!default
60   \clf_disablestream}
61
62\unexpanded\def\startoutputstream[#1]%
63  {\begingroup
64   \initializeoutputstreams
65   \the\everyenableoutputstream
66   \inoutputstreamtrue
67   \xdef\currentoutputstream{#1}%
68   \clf_startstream{#1}}
69
70\unexpanded\def\stopoutputstream
71  {\clf_stopstream
72   \endgroup}
73
74\unexpanded\def\startoutputsubstream[#1]% just push/pop instead
75  {\globalpushmacro\currentoutputstream
76   \enableoutputstream[#1]}
77
78\unexpanded\def\stopoutputsubstream
79  {\globalpopmacro\currentoutputstream
80   \enableoutputstream[\currentoutputstream]}
81
82\def\flushoutputstream  [#1]{\clf_flushstream{#1}}
83\def\outputstreambox    [#1]{\vbox{\clf_flushstream{#1}}}
84\def\outputstreamcopy   [#1]{\vbox{\clf_flushstreamcopy{#1}}}
85\def\outputstreamunvbox [#1]{\clf_flushstream{#1}}
86\def\outputstreamunvcopy[#1]{\clf_flushstreamcopy{#1}}
87\def\synchronizestreams [#1]{\clf_synchronizestream{#1}}
88\def\dopushoutputstream [#1]{\clf_pushstream{#1}}
89
90\unexpanded\def\pushoutputstream
91  {\dosingleempty\dopushoutputstream}
92
93% \unexpanded\def\defineoutputstream[#1]%
94%   {\doifundefined{otrs:#1}{\expandafter\newbox\csname otrs:#1\endcsname}}
95%
96% \def\useoutputstream[#1]%
97%   {\writestatus{otr}{using output stream #1}%
98%    \xdef\currentoutputstream{#1}}
99%
100% \directsetup{stream:\firstoutputstream:set}
101% \directsetup{stream:\firstoutputstream:top}
102% \directsetup{stream:\firstoutputstream:bottom}
103% \directsetup{stream:\firstoutputstream:reset}
104
105% Obsolete in \MKIV:
106%
107% \unexpanded\def\definemarknote
108%   {\dodoubleempty\dodefinemarknote}
109%
110% \def\dodefinemarknote[#1][#2]{}
111% \def\setmarknote         [#1]{\gobbleoneargument}
112% \def\flushmarknotes      [#1]{}
113% \def\erasemarknotes      [#1]{}
114
115\protect \endinput
116
117% \enabletrackers[streams.flushing]
118%
119% \setuplayout[grid=yes] \showgrid
120%
121% \starttext
122%
123% \input tufte
124%
125% \startoutputstream[nl]
126%
127% Wat doen we hier?
128%
129% \enableoutputstream[en]
130%
131% Are you sleeping, brother John?\footnote{xxx}
132%
133% \dorecurse{4}{x \footnote{note \recurselevel}\input tufte \par \pushoutputstream}
134%
135% \enableoutputstream[de]
136%
137% Bruder Jakob, schläfst du noch?\footnote{yyy}
138%
139% \dorecurse{4}{x \footnote{note \recurselevel}\input ward \par \pushoutputstream}
140%
141% \disableoutputstream
142%
143% \stopoutputstream
144%
145% Vader Jacob, slaap je nog?\footnote{zzz}
146%
147% \input tufte
148%
149% \synchronizestreams[en,de,nl]
150%
151% \page \flushoutputstream[en] \input knuth
152% \page \flushoutputstream[de] \input knuth
153% \page \flushoutputstream[nl] \input knuth
154%
155% \stoptext
156