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\lettonothing\p_page_injections_n
36\lettonothing\p_page_injections_page
37\lettonothing\p_page_injections_state
38
39\def\page_injections_flush_indeed
40 {\begingroup
41 \setbox\scratchbox\normalhpack
42 {\inheritedpageinjectionframed{\texsetup\p_page_injectionalternative_rederingsetup}}
43 \printpaperwidth \wd\scratchbox
44 \printpaperheight\ht\scratchbox
45 \scrn_canvas_synchronize_only
46 \invokepagehandler\v!normal{\box\scratchbox}
47 \endgroup
48 \scrn_canvas_synchronize_reset}
49
50\def\page_injections_flush_saved#name#parameters
51 {\begingroup
52 \cdef\currentpageinjection{#name}
53 \getdummyparameters[#parameters]
54 \edef\currentpageinjectionalternative {\pageinjectionparameter \c!alternative }
55 \edef\p_page_injectionalternative_rederingsetup{\pageinjectionalternativeparameter\c!renderingsetup}
56 \page_injections_nextpage
57 \page_injections_flush_indeed
58 \endgroup}
59
60\permanent\tolerant\protected\def\pageinjection[#1]#*[#2]
61 {\begingroup
62 \ifhastok={#1}
63 \ifhastok={#2}
64 \page_injections_direct_settings_parameters{#1}{#2}
65 \else
66 \page_injections_direct_parameters{#1}
67 \fi
68 \else
69 \ifhastok={#2}
70 \page_injections_direct_name_parameters{#1}{#2}
71 \else
72 \page_injections_direct_name{#1}
73 \fi
74 \fi}
75
76\def\page_injections_direct_settings_parameters#settings
77 {\lettonothing\currentpageinjection
78 \checkpageinjectionparent
79 \setupcurrentpageinjection[#settings]
80 \page_injections_direct_indeed}
81
82\def\page_injections_direct_parameters
83 {\lettonothing\currentpageinjection
84 \checkpageinjectionparent
85 \page_injections_direct_indeed}
86
87\def\page_injections_direct_name_parameters#name
88 {\cdef\currentpageinjection{#name}
89 \checkpageinjectionparent
90 \page_injections_direct_indeed}
91
92\def\page_injections_direct_name#name
93 {\cdef\currentpageinjection{#name}
94 \checkpageinjectionparent
95 \page_injections_direct_indeed{}}
96
97\def\page_injections_direct_indeed
98 {\edef\p_page_injections_state{\pageinjectionparameter\c!state}
99 \edef\p_page_injections_page {\pageinjectionparameter\c!page }
100 \ifcstok{\pageinjectionparameter\c!delay}\v!yes
101 \expandafter\page_injections_direct_indeed_yes
102 \else
103 \expandafter\page_injections_direct_indeed_nop
104 \fi}
105
106\def\page_injections_direct_indeed_yes#parameters
107 {\clf_savepageinjections
108 name {\currentpageinjection}
109 state {\p_page_injections_state}
110 userdata {\normalunexpanded{#parameters}}
111 \relax
112 \endgroup}
113
114\def\page_injections_direct_indeed_nop#parameters
115 {\ifempty\p_page_injections_page
116 \page
117 \else
118 \page[\p_page_injections_page]
119 \fi
120 \getdummyparameters[#parameters]
121 \page_injections_place
122 \endgroup}
123
124\def\page_injections_place
125 {\edef\currentpageinjectionalternative {\pageinjectionparameter \c!alternative }
126 \edef\p_page_injectionalternative_rederingsetup{\pageinjectionalternativeparameter\c!renderingsetup}
127 \page_injections_nextpage
128 \ifx\currentpageinjectionalternative\v!none \else
129 \forgetparindent
130 \dontcomplain
131 \setconstant\shipoutfinalizemethod\zerocount
132 \page_injections_flush_indeed
133 \fi}
134
135\def\page_injections_nextpage
136 {\ifcstok{\pageinjectionparameter\c!pagestate}\v!stop\else
137 \edef\p_page_injections_n{\pageinjectionparameter\c!n}
138 \ifempty\p_page_injections_n
139 \let\p_page_injections_n\plusone
140 \fi
141 \dorecurse\p_page_injections_n
142 {\incrementcounter[\s!realpage]
143 \incrementcounter[\s!userpage]}
144 \fi}
145
146\definepageinjectionalternative[\v!figure][\c!renderingsetup=\??pageinjectionrenderings:\v!figure]
147\definepageinjectionalternative[\v!buffer][\c!renderingsetup=\??pageinjectionrenderings:\v!buffer]
148\definepageinjectionalternative[\v!setups][\c!renderingsetup=\??pageinjectionrenderings:\s!setup ]
149
150\startsetups[\??pageinjectionrenderings:\v!figure]
151 \dontleavehmode\externalfigure[\dummyparameter\c!name][\c!factor=\v!max]
152\stopsetups
153
154\startsetups[\??pageinjectionrenderings:\s!setup]
155 \setups[\dummyparameter\c!setups]
156\stopsetups
157
158\startsetups[\??pageinjectionrenderings:\v!buffer]
159 \getbuffer[\dummyparameter\c!name]
160\stopsetups
161
162
163
164
165\setuppageinjection
166 [ \c!width=\paperwidth,
167 \c!height=\paperheight,
168 \c!frame=\v!off,
169 \c!offset=\v!overlay,
170 \c!delay=\v!no,
171 \c!state=\v!next,
172 \c!alternative=\v!figure]
173
174\definepageinjection[\v!previouspage][\c!delay=\v!yes,\c!state=\v!previous]
175\definepageinjection[\v!nextpage] [\c!delay=\v!yes,\c!state=\v!next]
176\definepageinjection[\v!here]
177\definepageinjection[\v!empty] [\c!alternative=\v!none]
178
179
180
181\protect \endinput
182
183
184
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 |