1
2
3
4
5
6
7
8
9
10
11
12
13
14\writestatus{loading}{ConTeXt Core Macros Insertions}
15
16
17
18
19
20\registerctxluafile{pageins}{}
21
22\unprotect
23
24
25
26
27
28
29\installcorenamespace{insertion}
30\installcorenamespace{insertionnumber}
31
32\installcommandhandler \??insertion {insertion} \??insertion
33
34\setupinsertion
35 [
36
37
38
39 \c!location=\v!page]
40
41\newconstant\insertionmigrationmode
42
43\def\page_inserts_check_anchoring
44 {\edef\p_anchoring{\namedinsertionparameter\empty\c!anchoring}
45 \insertionmigrationmode\ifx\p_anchoring\v!auto\plusone\else\zerocount\fi
46 \clf_setinsertmigration{\p_anchoring}}
47
48\appendtoks
49 \ifx\currentinsertionparent\empty
50 \page_inserts_check_anchoring
51 \fi
52\to \everysetupinsertion
53
54\setupinsertion
55 [\c!anchoring=\v!none]
56
57\appendtoks
58 \page_inserts_check_anchoring
59\to \everystarttext
60
61\newcount\currentinsertionnumber
62
63\newtoks\t_page_inserts_list
64
65\let\doprocessinsert\relax
66
67
68
69\unexpanded\def\setcurrentinsertion#1
70 {\edef\currentinsertion{#1}
71 \currentinsertionnumber\csname\??insertionnumber\currentinsertion\endcsname}
72
73\def\namedinsertionnumber#1{\csname\??insertionnumber#1\endcsname}
74
75\unexpanded\def\page_inserts_synchronize_registers
76 {\currentinsertionnumber\csname\??insertionnumber\currentinsertion\endcsname}
77
78
79
80
81
82
83
84
85\appendtoks
86 \ifx\currentinsertionparent\empty \else
87 \page_inserts_synchronize_registers
88 \fi
89\to \everysetupinsertion
90
91\unexpanded\def\page_inserts_process#1
92 {\edef\currentinsertion{#1}
93 \currentinsertionnumber\csname\??insertionnumber\currentinsertion\endcsname
94 \doprocessinsert\currentinsertionnumber}
95
96\unexpanded\def\processinsertions
97 {\the\t_page_inserts_list}
98
99\unexpanded\def\synchronizeinsertions
100 {\let\doprocessinsert\page_inserts_synchronize
101 \processinsertions}
102
103\unexpanded\def\page_inserts_synchronize#1
104 {\ifvoid#1\else
105 \insert#1{\unvbox#1}
106 \fi}
107
108\unexpanded\def\doifelseinsertion#1
109 {\ifcsname\??insertionnumber#1\endcsname
110 \expandafter\firstoftwoarguments
111 \else
112 \expandafter\secondoftwoarguments
113 \fi}
114
115\let\doifinsertionelse\doifelseinsertion
116
117
118
119
120
121
122
123
124
125
126
127
128
129\appendtoks
130 \ifx\currentinsertionparent\empty
131 \ifcsname\??insertionnumber\currentinsertion\endcsname
132
133 \else
134 \expandafter\newinsert\csname\??insertionnumber\currentinsertion\endcsname
135 \page_inserts_synchronize_registers
136 \clf_defineinsertion
137 {\currentinsertion}
138 {
139 number \currentinsertionnumber
140 }
141 \relax
142 \t_page_inserts_list\expandafter\expandafter\expandafter
143 {\expandafter\the\expandafter\t_page_inserts_list
144 \expandafter\page_inserts_process\csname\??insertionnumber\currentinsertion\endcsname}
145 \count\currentinsertionnumber\plusthousand
146 \skip \currentinsertionnumber\zeropoint
147 \dimen\currentinsertionnumber\maxdimen
148 \fi
149 \else
150 \expandafter\let\csname\??insertionnumber\currentinsertion\expandafter\endcsname
151 \csname\??insertionnumber\currentinsertionparent\endcsname
152 \fi
153\to \everydefineinsertion
154
155\appendtoks
156 \ifx\currentinsertionparent\empty \else
157 \clf_setupinsertion
158 {\currentinsertion}
159 {
160 location {\insertionparameter\c!location}
161 }
162 \relax
163 \fi
164\to \everysetupinsertion
165
166\unexpanded\def\page_inserts_set_location#1#2
167 {\clf_setinsertionlocation{#1}{#2}}
168
169
170
171\def\page_insert_insertion_height#1
172 {\dimexpr\expandafter\page_insert_insertion_height_indeed\csname\??insertionnumber#1\endcsname\relax}
173
174\def\page_insert_insertion_height_indeed#1
175 {\ifvoid#1\zeropoint\else1\skip#1\ht#1\fi}
176
177
178
179
180
181
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\protect \endinput
212 |