page-flw.mkxl /size: 5389 b    last modification: 2023-12-21 09:44
1%D \module
2%D   [       file=page-flw,
3%D        version=2003.04.19, % from test-002 (1997) profile experiment
4%D          title=\CONTEXT\ Page Macros,
5%D       subtitle=Text Flows,
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 / Text Flows}
15
16%D This is high experimental and especially flushing may change (proper spacing is
17%D the driving force here). It's an old mechanism used for playing with stepping
18%D through document threads. As it's a simple and effective mechanism we keep it
19%D around. It's not to be confused with upcoming stream support.
20%D
21%D \starttyping
22%D \setuppapersize [S6]
23%D \setuptolerance [verytolerant,stretch]
24%D \setupfooter    [strut=no]
25%D \setupwhitespace[big]
26%D
27%D \setuplayout
28%D   [rightedge=5cm,width=fit,margin=0pt,edgedistance=1cm,
29%D    footer=4cm,footerdistance=1cm,header=0cm]
30%D
31%D \setuptexttexts  [edge][][\vbox{\flushtextflow{alpha}}]
32%D \setupfootertexts[edge][][\vbox{\flushtextflow{beta}}]
33%D \setupfootertexts        [\vbox{\flushtextflow{gamma}}][]
34%D
35%D \definetextflow [alfa]  [width=\rightedgewidth]
36%D \definetextflow [beta]  [width=\rightedgewidth]
37%D \definetextflow [gamma] [width=\footerheight]
38%D
39%D \starttext
40%D
41%D \dorecurse{50}
42%D   {\getrandomnumber{\funny}{0}{8}
43%D    \ifcase\funny \starttextflow[alfa]  \input tufte.tex   \stoptextflow
44%D    \or           \starttextflow[beta]  \input knuth.tex   \stoptextflow
45%D    \or           \starttextflow[gamma] \input materie.tex \stoptextflow
46%D    \or          {\bf   TUFTE}\quad \input tufte   \par
47%D    \or          {\bf   TUFTE}\quad \input tufte   \par
48%D    \or          {\bf   KNUTH}\quad \input knuth   \par
49%D    \or          {\bf   KNUTH}\quad \input knuth   \par
50%D    \or          {\bf MATERIE}\quad \input materie \par
51%D    \else        {\bf MATERIE}\quad \input materie \par
52%D    \fi}
53%D
54%D \stoptext
55%D \stoptyping
56
57\unprotect
58
59\installcorenamespace{textflow}
60\installcorenamespace{textflowbox}
61
62\installcommandhandler \??textflow {textflow} \??textflow
63
64\setuptextflow
65  [%c!style=,
66   %c!color=,
67   \c!width=\availablehsize]
68
69\appendtoks
70    \ifcsname\??textflowbox\currenttextflow\endcsname
71       \setbox\csname\??textflowbox\currenttextflow\endcsname\emptybox
72    \else
73       \expandafter\newbox\csname\??textflowbox\currenttextflow\endcsname
74    \fi
75\to \everydefinetextflow
76
77\newinteger\b_page_textflow_box
78
79\permanent\def\textflowcollector#1%
80  {\begincsname\??textflowbox#1\endcsname}
81
82\permanent\protected\def\doifelsetextflowcollector#1%
83  {\ifcsname\??textflowbox#1\endcsname
84     \expandafter\firstoftwoarguments
85   \else
86     \expandafter\secondoftwoarguments
87   \fi}
88
89\permanent\protected\def\doifelsetextflow#1%
90  {\unless\ifcsname\??textflowbox#1\endcsname
91     \expandafter\secondoftwoarguments
92   \orelse\ifvoid\csname\??textflowbox#1\endcsname
93     \expandafter\secondoftwoarguments
94   \else
95     \expandafter\firstoftwoarguments
96   \fi}
97
98\aliased\let\doiftextflowcollectorelse\doifelsetextflowcollector
99\aliased\let\doiftextflowelse         \doifelsetextflow
100
101\permanent\protected\def\starttextflow[#1]%
102  {\begingroup
103   \cdef\currenttextflow{#1}%
104   \ifcsname\??textflowbox\currenttextflow\endcsname
105     \b_page_textflow_box\csname\??textflowbox\currenttextflow\endcsname
106     \global\setbox\b_page_textflow_box\vbox
107       \bgroup
108       \dontcomplain
109       \ifvoid\b_page_textflow_box\else
110         \unvbox\b_page_textflow_box
111       \fi
112       \hsize\textflowparameter\c!width\relax
113       \usetextflowstyleandcolor\c!style\c!color
114       \enforced\permanent\protected\def\stoptextflow{\endgraf\egroup\endgroup}%
115   \else
116     \enforced\aliased\let\stoptextflow\endgroup
117   \fi}
118
119\aliased\let\stoptextflow\relax
120
121\permanent\protected\def\flushtextflow#1%
122  {\begingroup
123   \cdef\currenttextflow{#1}%
124   \ifcsname\??textflowbox\currenttextflow\endcsname
125     \b_page_textflow_box\csname\??textflowbox\currenttextflow\endcsname
126     \ifvoid\b_page_textflow_box
127       % sorry
128     \orelse\ifdim\ht\b_page_textflow_box>\vsize
129       \setbox\scratchbox\vsplit\b_page_textflow_box to \vsize
130       \ifvoid\scratchbox\else
131         \unvbox\scratchbox
132       \fi
133     \else
134       \unvbox\b_page_textflow_box
135     \fi
136   \fi
137   \endgroup}
138
139\protect \endinput
140
141% \setuppapersize [A6]
142% \setupbodyfont [pagella, 12pt]
143%
144% \definetextflow [even]  [width=\textwidth]
145% \definetextflow [odd]   [width=\textwidth]
146%
147% \starttextflow [even] \dorecurse{15}{\input bryson} \stoptextflow
148% \starttextflow [odd]  \dorecurse {5}{\input knuth } \stoptextflow
149%
150% \starttext
151%
152% \doloop {
153%     \ifodd\realpageno
154%         \doiftextflowelse{odd} {
155%             \bgroup
156%             \vsize\dimexpr\textheight-\strutdp\relax
157%             \flushtextflow{odd}
158%             \egroup
159%         } {
160%             \null
161%         }
162%         \page
163%     \else
164%         \doiftextflowelse{even} {
165%             \bgroup
166%             \vsize\dimexpr\textheight-\strutdp\relax
167%             \flushtextflow{even}
168%             \egroup
169%         } {
170%           \null
171%         }
172%         \page
173%     \fi
174%     \doiftextflowelse{even}\donothing{\doiftextflowelse{odd}\donothing\exitloop}
175% }
176%
177% \stoptext
178
179