page-spr.mkiv /size: 4355 b    last modification: 2020-07-01 14:35
1
%D \module
2
%D [ file=page-spr,
3
%D version=2002.11.11,
4
%D title=\CONTEXT\ Page Macros,
5
%D subtitle=Spreading,
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
/
Spreading
}
15 16
% This module is experimental and not yet official!
17 18
\unprotect
19 20
\newbox
\b_page_spread_content
21
\newconditional
\c_page_spread_busy
22
\newconditional
\c_page_spread_once
% when true only one flush (writes etc)
23 24
% beware, ugly overload, to be redone
25 26
% \def\normalsettextpagecontent#1#2#3% #2 and #3 will disappear
27
% {\setbox#1\hbox
28
% {\setlayoutcomponentattribute{\v!page:\v!text}%
29
% \vbox \layoutcomponentboxattribute to \textheight
30
% {\offinterlineskip
31
% \freezetextwidth
32
% \hsize\textwidth % local variant of \sethsize
33
% \boxmaxdepth\maxdepth
34
% \noindent % content can be < \hsize
35
% \page_otr_command_package_contents#2#3}}%
36
% \dp#1\zeropoint
37
% \ifconditional\c_page_spread_busy
38
% \normalsettextpagecontent_spread{#1}%
39
% \else
40
% \normalsettextpagecontent_normal{#1}%
41
% \fi}
42 43
\def
\normalsettextpagecontent
#
1
#
2
#
3
% #2 and #3 will disappear
44
{
\setbox
#
1
\hpack
45
{
\setlayoutcomponentattribute
{
\v!page
:
\v!text
}
%
46
\vpack
\layoutcomponentboxattribute
to
\textheight
47
{
\offinterlineskip
48
\freezetextwidth
49
\hsize
\textwidth
% local variant of \sethsize
50
\boxmaxdepth\maxdepth
51
\noindent
% content can be < \hsize
52
\page_otr_command_package_contents
#
2
#
3
}}
%
53
\dp
#
1
\zeropoint
54
\ifconditional
\c_page_spread_busy
55
\normalsettextpagecontent_spread
{
#
1
}
%
56
\else
57
\normalsettextpagecontent_normal
{
#
1
}
%
58
\fi
}
59 60
% \def\normalsettextpagecontent_normal#1%
61
% {\setbox#1\hbox to \makeupwidth
62
% {\hss\box#1\hss}} % never change the \hss's
63 64
\def
\normalsettextpagecontent_normal
#
1
%
65
{
\ifdim
\wd
#
1
=
\makeupwidth
\else
66
\setbox
#
1
\hpack
to
\makeupwidth
67
{
\hss\box
#
1
\hss
}
% never change the \hss's
68
\fi
}
69 70
\def
\normalsettextpagecontent_spread
#
1
%
71
{
\setbox
#
1
\hpack
to
\makeupwidth
72
{
\ifvoid
\b_page_spread_content
73
\ifconditional
\c_page_spread_once
74
\box
#
1
%
75
\else
76
\global\setbox
\b_page_spread_content
\box
#
1
%
77
\copy
\b_page_spread_content
78
\fi
79
\hss
% left page
80
\else
81
\hss
% right page
82
\ifarrangingpages
83
% writes don't matter anyway
84
\else
\ifconditional
\c_page_spread_once
85
\global\setbox
\b_page_spread_content
\emptyhbox
86
\wd
\b_page_spread_content
\makeupwidth
87
\ht
\b_page_spread_content
\textheight
88
\else
89
% writes can interfere (todo: write stripper, but how about hyperlinks)
90
\fi
\fi
91
\box
\b_page_spread_content
92
\fi
}}
93 94
\unexpanded
\def
\page_spread_flush
95
{
\ifconditional
\c_page_spread_busy
\ifvoid
\b_page_spread_content
\else
96
% this page will be discarded later
97
\emptyhbox
\page
98
\fi
\fi
}
99 100
\unexpanded
\def
\startspread
101
{
\ifdoublesided
102
\ifconditional
\c_page_spread_busy
103
\doubleexpandafter
\page_spread_start_nop
104
\else
105
\doubleexpandafter
\page_spread_start_yes
106
\fi
107
\else
108
\expandafter
\page_spread_start_nop
109
\fi
}
110 111
\let
\stopspread
\relax
112 113
\unexpanded
\def
\page_spread_start_yes
114
{
\bgroup
115
\page
[
\v!left
]
%
116
%\setsystemmode{spread}%
117
\settrue
\c_page_spread_busy
118
\expanded
{
\setuplayout
[
\c!textwidth
=
\the\dimexpr
2
\textwidth
+
2
\backspace
\relax
]
}
%
119
\let
\stopspread
\page_spread_stop_yes
}
120 121
\unexpanded
\def
\page_spread_stop_yes
122
{
\kern
\zeropoint
123
\page
124
\setuplayout
[
\c!textwidth
=
\textwidth
]
125
\page
[
\v!left
]
126
\egroup
}
127 128
\unexpanded
\def
\page_spread_start_nop
129
{
\bgroup
130
\let
\stopspread
\page_spread_stop_nop
}
131 132
\unexpanded
\def
\page_spread_stop_nop
133
{
\egroup
}
134 135
\protect
\endinput
136 137
% texexec --arr --pdf test
138
%
139
% \setuplayout[width=middle]
140
% \setuppapersize[A4][A3,landscape]
141
% \setuppagenumbering[alternative=doublesided]
142
% \setuparranging[2UP]
143
%
144
% \starttext
145
%
146
% \dorecurse{3}{\input tufte }
147
%
148
% \startspread
149
% \dorecurse{10}{\input tufte }
150
% \stopspread
151
%
152
% \dorecurse{3}{\input tufte }
153
%
154
% \stoptext
155