1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21\unprotect
22
23\registerctxluafile{pageinj}{}
24
25\installcorenamespace {pageinjection}
26\installcorenamespace {pageinjectionalternative}
27\installcorenamespace {pageinjectionrenderings}
28
29\installframedcommandhandler \??pageinjection {pageinjection} \??pageinjection
30\installcommandhandler \??pageinjectionalternative {pageinjectionalternative} \??pageinjectionalternative
31
32\let\page_boxes_flush_before\clf_flushpageinjectionsbefore
33\let\page_boxes_flush_after \clf_flushpageinjectionsafter
34
35\def\page_injections_flush_indeed
36 {\begingroup
37 \setbox\scratchbox\normalhpack
38 {\inheritedpageinjectionframed{\texsetup\p_page_injectionalternative_rederingsetup}}
39 \printpaperwidth \wd\scratchbox
40 \printpaperheight\ht\scratchbox
41 \scrn_canvas_synchronize_only
42 \invokepagehandler\v!normal{\box\scratchbox}
43 \endgroup
44 \scrn_canvas_synchronize_reset}
45
46\def\page_injections_flush_saved#name#parameters
47 {\begingroup
48 \edef\currentpageinjection{#name}
49 \getdummyparameters[#parameters]
50 \edef\currentpageinjectionalternative {\pageinjectionparameter \c!alternative }
51 \edef\p_page_injectionalternative_rederingsetup{\pageinjectionalternativeparameter\c!renderingsetup}
52 \page_injections_nextpage
53 \page_injections_flush_indeed
54 \endgroup}
55
56\unexpanded\def\pageinjection
57 {\begingroup
58 \dodoubleempty\page_injections_direct}
59
60\def\page_injections_direct[#1][#2]
61 {\doifelseassignment{#1}
62 {\doifelseassignment{#2}
63 {\page_injections_direct_settings_parameters{#1}{#2}}
64 {\page_injections_direct_parameters {#1}}}
65 {\doifelseassignment{#2}
66 {\page_injections_direct_name_parameters {#1}{#2}}
67 {\page_injections_direct_name {#1}}}}
68
69\def\page_injections_direct_settings_parameters#settings
70 {\let\currentpageinjection\empty
71 \checkpageinjectionparent
72 \setupcurrentpageinjection[#settings]
73 \page_injections_direct_indeed}
74
75\def\page_injections_direct_parameters
76 {\let\currentpageinjection\empty
77 \checkpageinjectionparent
78 \page_injections_direct_indeed}
79
80\def\page_injections_direct_name_parameters#name
81 {\edef\currentpageinjection{#name}
82 \checkpageinjectionparent
83 \page_injections_direct_indeed}
84
85\def\page_injections_direct_name#name
86 {\edef\currentpageinjection{#name}
87 \checkpageinjectionparent
88 \page_injections_direct_indeed{}}
89
90\def\page_injections_direct_indeed
91 {\edef\p_page_injections_state{\pageinjectionparameter\c!state}
92 \edef\p_page_injections_delay{\pageinjectionparameter\c!delay}
93 \edef\p_page_injections_page {\pageinjectionparameter\c!page }
94 \ifx\p_page_injections_delay\v!yes
95 \expandafter\page_injections_direct_indeed_yes
96 \else
97 \expandafter\page_injections_direct_indeed_nop
98 \fi}
99
100\def\page_injections_direct_indeed_yes#parameters
101 {\clf_savepageinjections
102 name {\currentpageinjection}
103 state {\p_page_injections_state}
104 userdata {\normalunexpanded{#parameters}}
105 \relax
106 \endgroup}
107
108\def\page_injections_direct_indeed_nop#parameters
109 {\ifx\p_page_injections_page\empty
110 \page
111 \else
112 \page[\p_page_injections_page]
113 \fi
114 \getdummyparameters[#parameters]
115 \page_injections_place
116 \endgroup}
117
118
119
120
121
122
123
124
125
126\def\page_injections_place
127 {\edef\currentpageinjectionalternative {\pageinjectionparameter \c!alternative }
128 \edef\p_page_injectionalternative_rederingsetup{\pageinjectionalternativeparameter\c!renderingsetup}
129 \page_injections_nextpage
130 \ifx\currentpageinjectionalternative\v!none \else
131 \forgetparindent
132 \dontcomplain
133 \setconstant\shipoutfinalizemethod\zerocount
134 \page_injections_flush_indeed
135 \fi}
136
137\def\page_injections_nextpage
138 {\edef\p_page_injections_pagestate{\pageinjectionparameter\c!pagestate}
139 \ifx\p_page_injections_pagestate\v!stop \else
140 \edef\p_page_injections_n{\pageinjectionparameter\c!n}
141 \ifx\p_page_injections_n\empty
142 \let\p_page_injections_n\plusone
143 \fi
144 \dorecurse\p_page_injections_n
145 {\incrementcounter[\s!realpage]
146 \incrementcounter[\s!userpage]}
147 \fi}
148
149\definepageinjectionalternative[\v!figure][\c!renderingsetup=\??pageinjectionrenderings:\v!figure]
150\definepageinjectionalternative[\v!buffer][\c!renderingsetup=\??pageinjectionrenderings:\v!buffer]
151\definepageinjectionalternative[\v!setups][\c!renderingsetup=\??pageinjectionrenderings:\s!setup ]
152
153\startsetups[\??pageinjectionrenderings:\v!figure]
154 \dontleavehmode\externalfigure[\dummyparameter\c!name][\c!factor=\v!max]
155\stopsetups
156
157\startsetups[\??pageinjectionrenderings:\s!setup]
158 \setups[\dummyparameter\c!setups]
159\stopsetups
160
161\startsetups[\??pageinjectionrenderings:\v!buffer]
162 \getbuffer[\dummyparameter\c!name]
163\stopsetups
164
165
166
167
168\setuppageinjection
169 [ \c!width=\paperwidth,
170 \c!height=\paperheight,
171 \c!frame=\v!off,
172 \c!offset=\v!overlay,
173 \c!delay=\v!no,
174 \c!state=\v!next,
175 \c!alternative=\v!figure]
176
177\definepageinjection[\v!previouspage][\c!delay=\v!yes,\c!state=\v!previous]
178\definepageinjection[\v!nextpage] [\c!delay=\v!yes,\c!state=\v!next]
179\definepageinjection[\v!here]
180\definepageinjection[\v!empty] [\c!alternative=\v!none]
181
182
183
184\protect \endinput
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240 |