1
2
3
4
5
6
7
8
9
10
11
12
13
14\writestatus{loading}{ConTeXt Page Macros MakeUp}
15
16\unprotect
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39\installcorenamespace{makeup}
40\installcorenamespace{makeupdoublesided}
41
42\installcommandhandler \??makeup {makeup} \??makeup
43
44\appendtoks
45 \frozen\protected\instance\edefcsname\e!start\currentmakeup\e!makeup\endcsname{\startmakeup[\currentmakeup]}
46 \frozen\protected\instance\edefcsname\e!stop \currentmakeup\e!makeup\endcsname{\stopmakeup}
47 \doifelselayoutdefined\currentmakeup\donothing{\definelayout[\currentmakeup]}
48\to \everydefinemakeup
49
50
51
52
53\permanent\tolerant\protected\def\startmakeup[#1]#*[#S#2]
54 {\ifparameters
55 \expandafter\page_makeup_start_nop
56 \else
57 \expandafter\page_makeup_start_yes
58 \fi[#1][#2]}
59
60\aliased\let\stopmakeup\relax
61
62
63
64\protected\def\page_makeup_start_nop[#name][#S#settings]
65 {\page
66 \setupheader[\c!state=\v!empty]
67 \setupfooter[\c!state=\v!empty]
68 \bgroup
69 \forgetall
70 \dontcomplain
71 \vbox to \textheight \bgroup
72 \setsystemmode\v!makeup
73 \hsize\textwidth
74 \enforced\let\stopmakeup\page_makeup_stop_nop}
75
76\permanent\protected\def\page_makeup_stop_nop
77 {\egroup
78 \egroup
79 \page}
80
81
82
83\newbox \b_page_makeup
84\newtoks\t_page_makeup_every_setup
85
86\def\page_makeup_start_yes[#name]
87 {\doifelsecommandhandler\??makeup{#name}\page_makeup_start_indeed\page_makeup_start_nop[#name]}
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107\def\page_makeup_start_indeed[#name][#S#settings]
108 {
109 \begingroup
110
111 \global\cdef\m_page_makeup_name{#name}
112 \let\currentmakeup\m_page_makeup_name
113 \let\currentlayout\m_page_makeup_name
114 \xdef\m_page_makeup_layout_parent{\layoutparameter\s!parent}
115 \setupcurrentmakeup[#settings]
116 \edef\p_page{\makeupparameter\c!page}
117 \ifempty\p_page
118 \endgroup
119 \page
120 \relax
121 \orelse\ifx\p_page\v!no
122
123 \endgroup
124 \else
125 \normalexpanded{\endgroup\page[\p_page]}
126 \fi
127
128
129
130
131 \ifx\m_page_makeup_name\currentlayout
132
133 \orelse\ifx\m_page_makeup_layout_parent\??layout
134
135 \normalexpanded{\setuplayout[#name][\s!parent=\??layout\currentlayout]}
136
137
138 \fi
139 \startlayout[#name]
140 \bgroup
141
142 \let\currentmakeup\m_page_makeup_name
143 \setupcurrentmakeup[#settings]
144 \setsystemmode\v!makeup
145 \expand\t_page_makeup_every_setup
146 \makeupparameter\c!commands
147 \forgetall
148 \dontcomplain
149 \global\setbox\b_page_makeup\vbox to \makeupparameter\c!height \bgroup
150 \usemakeupstyleandcolor\c!style\c!color
151 \hsize\makeupparameter\c!width
152 \usealignparameter\makeupparameter
153 \usesetupsparameter\makeupparameter
154 \makeupparameter\c!top
155 \enforced\let\stopmakeup\page_makeup_stop_yes}
156
157\permanent\protected\def\page_makeup_stop_yes
158 {\endgraf
159 \makeupparameter\c!bottom
160 \egroup
161 \strc_pagenumbers_page_state_push
162 \makeupparameter\c!before\relax
163 \begingroup
164 \ifdim\ht\b_page_makeup>\vsize
165 \ht\b_page_makeup\vsize
166 \fi
167 \setuppagenumber[\c!state=\makeupparameter\c!pagestate]
168 \ifcstok{\makeupparameter\c!location}\v!top
169 \topskip\zeroskip
170 \fi
171 \edef\p_reference{\makeupparameter\c!reference}
172 \dontleavehmode
173 \usereferenceparameter\makeupparameter
174 \box\b_page_makeup
175 \expand\t_page_makeup_every_setup
176 \page
177 \endgroup
178 \makeupparameter\c!after\relax
179 \ifdoublesided \ifodd\realpageno \else
180 \csname\??makeupdoublesided\makeupparameter\c!doublesided\endcsname
181 \fi \fi
182 \strc_pagenumbers_page_state_pop
183 \egroup
184 \stoplayout
185 \ifx\m_page_makeup_name\currentlayout
186 \orelse\ifx\m_page_makeup_layout_parent\??layout
187
188 \normalexpanded{\setuplayout[\m_page_makeup_name][\s!parent=\??layout\currentlayout]}
189 \fi}
190
191\defcsname\??makeupdoublesided\v!yes\endcsname
192 {\emptyhbox
193 \page}
194
195\defcsname\??makeupdoublesided\v!empty\endcsname
196 {\expand\t_page_makeup_every_setup
197
198 \page[\v!blank]
199 \emptyhbox
200 \page}
201
202
203
204\permanent\protected\def\startcolumnmakeup
205 {\bgroup
206 \getrawnoflines\textheight
207 \setbox\scratchbox\vbox to \dimexpr\noflines\lineheight\lineheight\topskip\relax
208 \bgroup
209 \forgetall}
210
211\permanent\protected\def\stopcolumnmakeup
212 {\egroup
213 \dp\scratchbox\zeropoint
214 \wd\scratchbox\textwidth
215 \box\scratchbox
216 \egroup
217 \page_otr_command_synchronize_hsize}
218
219
220
221
222
223\appendtoks
224 \setupfooter[\c!state=\makeupparameter\c!footerstate]
225 \setupheader[\c!state=\makeupparameter\c!headerstate]
226 \setuptext [\c!state=\makeupparameter\c!textstate]
227 \setupbottom[\c!state=\makeupparameter\c!bottomstate]
228 \setuptop [\c!state=\makeupparameter\c!topstate]
229\to \t_page_makeup_every_setup
230
231
232
233\setupmakeup
234 [\c!width=\innermakeupwidth,
235 \c!height=\textheight,
236
237
238
239
240
241
242
243 \c!page=\v!right,
244 \c!doublesided=\v!empty,
245 \c!top=\vss,
246 \c!bottom=\vss,
247 \c!bottomstate=\v!normal,
248 \c!topstate=\v!normal,
249 \c!textstate=\v!normal,
250 \c!headerstate=\v!stop,
251 \c!footerstate=\v!stop,
252 \c!pagestate=\v!stop]
253
254
255\definemakeup
256 [\v!standard]
257 [\c!width=\innermakeupwidth,
258 \c!height=\textheight,
259 \c!page=\v!right,
260 \c!doublesided=\v!empty]
261
262\definemakeup
263 [\v!text]
264 [\c!topstate=\v!start,
265 \c!headerstate=\v!start,
266 \c!textstate=\v!start,
267 \c!footerstate=\v!start,
268 \c!bottomstate=\v!start,
269 \c!doublesided=\v!no,
270 \c!page=\v!yes,
271 \c!top=\pseudostrut\ignorespaces,
272 \c!bottom=\obeydepth\vss]
273
274\definemakeup
275 [\v!page]
276
277\definemakeup
278 [\v!middle]
279 [\v!standard]
280
281
282
283
284\protect
285 |