1
2
3
4
5
6
7
8
9
10
11
12
13
14\writestatus{loading}{ConTeXt Page Macros Initializations}
15
16\registerctxluafile{pageini}{}
17
18
19
20
21
22
23
24
25
26
27\unprotect
28
29
30
31\newcount\nofshipouts
32
33\appendtoks
34 \global\advance\nofshipouts\plusone
35\to \everyaftershipout
36
37\newconditional\c_otr_shipout_enabled \settrue\c_otr_shipout_enabled
38
39\unexpanded\def\page_otr_shipout
40 {\ifconditional\c_otr_shipout_enabled
41 \expandafter\page_otr_shipout_yes
42 \else
43 \expandafter\page_otr_shipout_nop
44 \fi}
45
46\let\page_otr_shipout_yes\normalshipout
47
48\unexpanded\def\page_otr_shipout_nop
49 {\writestatus\m!system{ignoring shipout of real page \the\realpageno}
50 \global\advance\realpageno\minusone
51 \dowithnextbox{\deadcycles\zerocount}}
52
53
54
55
56
57
58
59\newbox\pagebox
60
61
62
63
64
65\newtoks\t_page_postprocessors_box
66\newtoks\t_page_postprocessors_page
67\newtoks\t_page_postprocessors_column
68
69\newconstant\b_page_postprocessor
70
71\def\page_apply_postprocessors_box#1
72 {\b_page_postprocessor#1\relax
73 \the\t_page_postprocessors_box}
74
75\def\page_apply_postprocessors_page#1
76 {\b_page_postprocessor#1\relax
77 \the\t_page_postprocessors_page}
78
79\def\page_apply_postprocessors_column#1
80 {\b_page_postprocessor#1\relax
81 \the\t_page_postprocessors_column}
82
83
84
85\def\page_otr_flush_all_floats
86 {
87 \ifconditional\c_page_floats_some_waiting
88 \page_otr_command_flush_all_floats
89 \fi}
90
91\def\page_otr_insert_dummy_page
92 {\par
93 \ifvmode
94 \page_otr_flush_all_floats
95 \fixedspace
96 \vfill
97 \page_otr_command_next_page
98 \fi}
99
100\def\page_otr_flush_pending_content
101 {\vkern\zeropoint\relax
102 \ifvoid\normalpagebox \else
103 \unvbox\normalpagebox
104 \penalty\outputpenalty
105 \fi}
106
107\newconstant\c_page_postponed_mode
108\newbox \b_page_otr_saved
109
110\installoutputroutine\savepagecontent
111 {\global\setbox\b_page_otr_saved\box\normalpagebox}
112
113\unexpanded\def\flushpagecontent
114 {\ifvoid\b_page_otr_saved\else\unvbox\b_page_otr_saved\fi}
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151\def\page_otr_construct_and_shipout#1#2#3
152 {\forgetall
153 \page_boxes_shipout{\page_boxes_constructed_page#1#2}
154 \page_otr_flush_pending_content
155
156 \page_otr_check_for_pending_inserts
157
158 \inpagebodytrue
159 \pagebodymode\plusone
160 \page_otr_command_flush_saved_floats
161 \page_otr_command_set_vsize
162 \strc_pagenumbers_increment_counters
163 \page_adapts_synchronize
164 \page_otr_check_for_pending_inserts
165 \page_otr_command_flush_facing_floats
166 \page_floats_flush_page_floats
167 \page_spread_flush
168 \ifnum#3=\plusone
169
170 \ifnum\c_page_postponed_mode=\plusone
171 \aftergroup\page_postponed_blocks_flush
172 \else
173 \page_postponed_blocks_flush
174 \fi
175 \else
176 \page_postponed_blocks_flush
177 \fi}
178
179
180
181
182\newbox\b_page_otr_special
183
184\def\page_otr_flush_special_content
185 {\ifvoid\b_page_otr_special \else
186 \box\b_page_otr_special
187 \fi}
188
189\def\page_otr_add_special_content
190 {\dowithnextboxcs\page_otr_add_special_content_indeed\hbox}
191
192\def\page_otr_add_special_content_indeed
193 {\wd\nextbox\zeropoint
194 \ht\nextbox\zeropoint
195 \dp\nextbox\zeropoint
196 \global\setbox\b_page_otr_special\hbox
197 {
198 \box\b_page_otr_special\box\nextbox}}
199
200\let\flushatshipout\page_otr_add_special_content
201
202\maxdeadcycles=1000
203
204\newtoks\afterpage \newtoks\aftereverypage
205\newtoks\beforepage \newtoks\beforeeverypage
206
207\newif\ifarrangingpages \arrangingpagesfalse
208
209\newconstant\pageornamentstate
210
211
212
213
214
215
216
217\appendtoks
218 \ifcase\pageornamentstate \or
219 \global\pageornamentstate\zerocount
220 \fi
221\to \everyaftershipout
222
223
224
225\newconditional\c_page_marks_building_successive_pages \settrue\c_page_marks_building_successive_pages
226
227\def\page_marks_synchronize_page#1
228 {\strc_markings_synchronize[\v!page][#1][\ifconditional\c_page_marks_building_successive_pages\v!keep\fi]}
229
230\def\page_marks_synchronize_column#1#2#3#4
231 {\ifnum#3=#1\relax
232 \strc_markings_synchronize[\number#3,\v!column:\number#3,\v!first,\v!column:\v!first][#4][]
233 \else\ifnum#3=#2\relax
234 \strc_markings_synchronize[\number#3,\v!column:\number#3,\v!last, \v!column:\v!last ][#4][]
235 \else
236 \strc_markings_synchronize[\number#3,\v!column:\number#3 ][#4][]
237 \fi\fi}
238
239
240
241\newconditional\c_page_boxes_save_page_body
242\newbox \b_page_boxes_saved_page_body
243
244\def\page_boxes_constructed_page_body#1#2
245 {\ifconditional\c_page_boxes_save_page_body \global\setbox\b_page_boxes_saved_page_body \fi \vpack \bgroup
246 \boxmaxdepth\maxdimen
247 \dontcomplain
248 \page_marks_synchronize_page {#2}
249 \page_boxes_construct_content \pagebox{#1}{#2}
250 \page_backgrounds_add_to_main \pagebox
251 \page_boxes_apply_offsets \pagebox
252 \page_info_add_to_box \pagebox
253 \ifcase\pageornamentstate
254 \page_backgrounds_add_to_paper \pagebox
255 \fi
256 \anch_positions_register_page \pagebox
257 \ifarrangingpages
258 \page_boxes_apply_shift_paper \pagebox
259 \else
260 \page_boxes_apply_clip_paper \pagebox
261 \page_marks_add_page \pagebox
262 \page_boxes_apply_replicate \pagebox
263 \page_boxes_apply_scale \pagebox
264 \page_boxes_apply_mirror_paper \pagebox
265 \page_boxes_apply_orientate_paper \pagebox
266 \page_marks_add_more \pagebox
267 \page_boxes_apply_center \pagebox
268 \page_backgrounds_add_to_print \pagebox
269 \page_boxes_apply_mirror_print \pagebox
270 \page_boxes_apply_orientate_print \pagebox
271 \page_boxes_apply_shift_print \pagebox
272 \page_boxes_apply_offset \pagebox
273 \page_boxes_apply_negate_print \pagebox
274 \fi
275 \box\pagebox
276 \egroup \ifconditional\c_page_boxes_save_page_body \copy\b_page_boxes_saved_page_body \fi}
277
278\appendtoks
279 \restoreglobalbodyfont
280 \pickupattributes
281\to \everybeforepagebody
282
283\ifdefined\nestednewbox \else \newbox\nestednextbox \fi
284
285\prependtoks
286 \let\nextbox\nestednextbox
287\to \everybeforepagebody
288
289\def\page_boxes_constructed_page#1#2
290 {\vpack\bgroup
291 \the\everybeforepagebody
292 \starttextproperties
293 \checkmarginblocks
294 \the\beforeeverypage
295 \normalexpanded{\global\beforepage\emptytoks\the\beforepage}
296 \inpagebodytrue
297 \pagebodymode\plusone
298 \page_boxes_constructed_page_body#1#2
299 \normalexpanded{\global\afterpage \emptytoks\the\afterpage }
300 \the\aftereverypage
301 \resetpagebreak
302 \resetlayouttextlines
303 \stoptextproperties
304 \the\everyafterpagebody
305 \egroup}
306
307\def\doifelsetopofpage
308 {\ifdim\pagegoal=\maxdimen
309 \expandafter\firstoftwoarguments
310 \else\ifdim\pagegoal=\vsize
311 \doubleexpandafter\firstoftwoarguments
312 \else
313 \doubleexpandafter\secondoftwoarguments
314 \fi\fi}
315
316\let\doiftopofpageelse\doifelsetopofpage
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333\installcorenamespace{markedpage}
334
335\unexpanded\def\markpage
336 {\dotripleempty\page_mark}
337
338\def\page_mark[#1][#2][#3]
339 {\clf_markpage{#1}{#2}{#3}}
340
341\def\markedpages[#1]
342 {\clf_markedpages{#1}}
343
344\unexpanded\def\doifelsemarkedpage#1
345 {\clf_doifelsemarkedpage{#1}}
346
347\unexpanded\def\doifmarkedpage#1
348 {\clf_doifmarkedpage{#1}}
349
350\unexpanded\def\startmarkpages
351 {\dodoubleempty\page_start_marked}
352
353\def\page_start_marked[#1][#2]
354 {\clf_startmarkpages{#1}{#2}}
355
356\unexpanded\def\stopmarkpages
357 {\clf_stopmarkpages}
358
359\unexpanded\def\checkmarkedpages
360 {\clf_checkmarkedpages}
361
362\def\markedpageparameter#1#2
363 {\clf_markedpageparameter{#1}{#2}}
364
365\appendtoks
366 \checkmarkedpages
367\to \everyaftershipout
368
369
370
371\newconstant\c_page_force_strut_depth_trace_mode
372
373\installtextracker
374 {otr.forcestrutdepth}
375 {\c_page_force_strut_depth_trace_mode\plusone}
376 {\c_page_force_strut_depth_trace_mode\zerocount}
377
378\installoutputroutine\forcestrutdepth
379 {\clf_forcestrutdepth\normalpagebox\strutdp\c_page_force_strut_depth_trace_mode
380 \unvbox\normalpagebox}
381
382\installoutputroutine\forcestrutdepthplus
383 {\clf_forcestrutdepthplus\normalpagebox\strutdp\c_page_force_strut_depth_trace_mode
384 \unvbox\normalpagebox}
385
386
387
388
389
390
391
392
393
394
395
396
397\unexpanded\def\doifelsependingpagecontent{\clf_doifelsependingpagecontent}
398
399\protect \endinput
400 |