summaryrefslogtreecommitdiff
path: root/tex/context/base/mkxl/page-str.mkxl
blob: 067283ee0e151b9da058011d6d0edd7db72eaff1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
%D \module
%D   [       file=page-str,
%D        version=2010.03.13, % 2006.03.21,
%D          title=\CONTEXT\ Page Macros,
%D       subtitle=Page Streams,
%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 / Page Streams}

%D The first version of this component of \CONTEXT\ was written for Thomas Schmitz
%D who asked for parallel page streams. While playing with the code, I decided to
%D make it into a component that can be used to construct all kind of stream related
%D mechanisms. Because I could apply this feature in a project, there is some
%D additional code here (related to graphics).
%D
%D These macros were written while listening to and watching the DVD \quotation
%D {Rush In Rio}.
%D
%D The reimplementation (or rather experimenting with the complete rewrite) was done
%D while looping over \quotation {Wende Snijders No.9}.
%D
%D Remark: marknotes are gone, at least for a while.

\registerctxluafile{page-str}{autosuffix}

\unprotect

\mutable\let\currentoutputstream\empty

\newif   \ifinoutputstream        % will become a conditional or mode
\newtoks \everyenableoutputstream

\appendtoks
    \page_otr_command_flush_side_floats
\to \everyenableoutputstream

\permanent\protected\def\initializeoutputstreams
  {\clf_initializestream
   \enforced\glet\initializeoutputstreams\relax}

\permanent\protected\def\enableoutputstream[#1]% could be \startoutputsubstream
  {\initializeoutputstreams
   \the\everyenableoutputstream
   \inoutputstreamtrue
   \xdef\currentoutputstream{#1}%
   \clf_enablestream{#1}
   \prevdepth\zeropoint} % maybe more is needed i.e. we need to get rid of leading glue

\permanent\protected\def\disableoutputstream
  {\inoutputstreamfalse
   \glet\currentoutputstream\s!default
   \clf_disablestream}

\permanent\protected\def\startoutputstream[#1]%
  {\begingroup
   \initializeoutputstreams
   \the\everyenableoutputstream
   \inoutputstreamtrue
   \xdef\currentoutputstream{#1}%
   \clf_startstream{#1}}

\permanent\protected\def\stopoutputstream
  {\clf_stopstream
   \endgroup}

\permanent\protected\def\startoutputsubstream[#1]% just push/pop instead
  {\globalpushmacro\currentoutputstream
   \enableoutputstream[#1]}

\permanent\protected\def\stopoutputsubstream
  {\globalpopmacro\currentoutputstream
   \enableoutputstream[\currentoutputstream]}

\permanent         \protected\def\flushoutputstream  [#1]{\clf_flushstream{#1}}
\permanent         \protected\def\outputstreambox    [#1]{\vbox{\clf_flushstream{#1}}}
\permanent         \protected\def\outputstreamcopy   [#1]{\vbox{\clf_flushstreamcopy{#1}}}
\permanent         \protected\def\outputstreamunvbox [#1]{\clf_flushstream{#1}}
\permanent         \protected\def\outputstreamunvcopy[#1]{\clf_flushstreamcopy{#1}}
\permanent         \protected\def\synchronizestreams [#1]{\clf_synchronizestream{#1}}
\permanent\tolerant\protected\def\pushoutputstream   [#1]{\clf_pushstream{#1}}

\protect \endinput

% \enabletrackers[streams.flushing]
%
% \setuplayout[grid=yes] \showgrid
%
% \starttext
%
% \input tufte
%
% \startoutputstream[nl]
%
% Wat doen we hier?
%
% \enableoutputstream[en]
%
% Are you sleeping, brother John?\footnote{xxx}
%
% \dorecurse{4}{x \footnote{note \recurselevel}\input tufte \par \pushoutputstream}
%
% \enableoutputstream[de]
%
% Bruder Jakob, schläfst du noch?\footnote{yyy}
%
% \dorecurse{4}{x \footnote{note \recurselevel}\input ward \par \pushoutputstream}
%
% \disableoutputstream
%
% \stopoutputstream
%
% Vader Jacob, slaap je nog?\footnote{zzz}
%
% \input tufte
%
% \synchronizestreams[en,de,nl]
%
% \page \flushoutputstream[en] \input knuth
% \page \flushoutputstream[de] \input knuth
% \page \flushoutputstream[nl] \input knuth
%
% \stoptext