1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16\writestatus{loading}{ConTeXt File Macros Job Handling}
17
18\unprotect
19
20\registerctxluafile{filejob}{}
21
22
23
24\unexpanded\def\doifelseinputfile#name
25 {\clf_doifelseinputfile{#name}}
26
27\let\doifinputfileelse\doifelseinputfile
28
29\unexpanded\def\processfile#name
30 {\clf_processfile{#name}}
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45\unexpanded\def\usepath[#path]
46 {\clf_usepath{#path}}
47
48\unexpanded\def\usesubpath[#path]
49 {\clf_usesubpath{#path}}
50
51\unexpanded\def\pushpath[#path]
52 {\clf_pushpath{#path}}
53
54\unexpanded\def\poppath
55 {\clf_poppath}
56
57\unexpanded\def\resetpath
58 {\clf_resetpath}
59
60\def\allinputpaths
61 {\clf_allinputpaths}
62
63
64
65\let\locatedfilepath\empty
66
67\unexpanded\def\locatefilepath#name
68 {\edef\locatedfilepath{\clf_locatefilepath{#name}}}
69
70
71
72
73
74
75
76
77
78
79
80\unexpanded\def\usezipfile
81 {\dodoubleempty\syst_files_use_zip_file}
82
83\def\syst_files_use_zip_file[#zipname][#subtree]
84 {\clf_usezipfile{#zipname}{#subtree}}
85
86
87
88\unexpanded\def\loadexamodes
89 {\dosingleempty\syst_files_load_exa_modes}
90
91\def\syst_files_load_exa_modes[#name]
92 {\clf_loadexamodes{#name}}
93
94
95
96
97
98
99\unexpanded\def\syst_files_load
100 {\syst_files_load_indeed\f!newfilename
101 \syst_files_load_indeed\f!locfilename
102 \syst_files_load_indeed\f!expfilename
103 \syst_files_load_indeed\f!sysfilename
104
105 }
106
107\def\syst_files_load_indeed#name
108 {\readsysfile{#name}{\showmessage\m!system2{#name}}\donothing}
109
110
111
112\ifdefined\textlevel \else \newcount\textlevel \fi
113\ifdefined\strc_pagenumbers_flush_final_page \else \let\strc_pagenumbers_flush_final_page\relax \fi
114
115\unexpanded\def\dostarttext
116 {\glet\dostarttext\relax
117 \the\everystarttext
118 \global\everystarttext\emptytoks}
119
120\unexpanded\def\dostoptext
121 {\glet\dostoptext\relax
122 \strc_pagenumbers_flush_final_page
123 \page
124 \the\everystoptext
125 \global\everystoptext\emptytoks
126 \the\everybye
127 \global\everybye\emptytoks
128 \the\everygoodbye
129 \global\everygoodbye\emptytoks
130 \doifelsesometoks\everynotabene{\writeline\the\everynotabene\writeline}\donothing
131 \normalend}
132
133\unexpanded\def\starttext {\clf_starttext}
134\unexpanded\def\stoptext {\clf_stoptext}
135\unexpanded\def\forcequitjob {\clf_forcequitjob}
136\unexpanded\def\autostarttext{\clf_autostarttext}
137\unexpanded\def\autostoptext {\clf_autostoptext}
138
139\pushoverloadmode
140
141\unexpanded\def\end {\clf_forceendjob}
142
143\popoverloadmode
144
145\unexpanded\def\finishjob{\stoptext}
146
147\newtoks\everystartnotext
148\newtoks\everystopnotext
149
150\unexpanded\def\startnotext {\the\everystartnotext}
151\unexpanded\def\stopnotext {\the\everystopnotext \normalend}
152
153
154
155\unexpanded\def\processfilemany#name{\clf_processfilemany{#name}}
156\unexpanded\def\processfileonce#name{\clf_processfileonce{#name}}
157\unexpanded\def\processfilenone#name{\clf_processfilenone{#name}}
158
159\unexpanded\def\project {\doifelsenextoptionalcs\useproject \syst_structure_arg_project}
160\unexpanded\def\product {\doifelsenextoptionalcs\useproduct \syst_structure_arg_product}
161\unexpanded\def\component {\doifelsenextoptionalcs\usecomponent \syst_structure_arg_component}
162\unexpanded\def\environment{\doifelsenextoptionalcs\useenvironment\syst_structure_arg_environment}
163
164\def\syst_structure_arg_project #name {\clf_useproject {#name}}
165\def\syst_structure_arg_product #name {\clf_useproduct {#name}}
166\def\syst_structure_arg_component #name {\clf_usecomponent {#name}}
167\def\syst_structure_arg_environment#name {\clf_useenvironment{#name}}
168
169\unexpanded\def\startproject {\doifelsenextoptionalcs\syst_structure_start_opt_project \syst_structure_start_arg_project }
170\unexpanded\def\startproduct {\doifelsenextoptionalcs\syst_structure_start_opt_product \syst_structure_start_arg_product }
171\unexpanded\def\startcomponent {\doifelsenextoptionalcs\syst_structure_start_opt_component \syst_structure_start_arg_component }
172\unexpanded\def\startenvironment{\doifelsenextoptionalcs\syst_structure_start_opt_environment\syst_structure_start_arg_environment}
173
174\def\syst_structure_start_arg_project #name {\clf_startproject {#name}}
175\def\syst_structure_start_arg_product #name {\clf_startproduct {#name}}
176\def\syst_structure_start_arg_component #name {\clf_startcomponent {#name}}
177\def\syst_structure_start_arg_environment#name {\clf_startenvironment{#name}}
178
179\unexpanded\def\useproject [#name]{\clf_useproject {#name}}
180\unexpanded\def\useproduct [#name]{\clf_useproduct {#name}}
181\unexpanded\def\usecomponent [#name]{\clf_usecomponent {#name}}
182\unexpanded\def\useenvironment[#name]{\clf_useenvironment{#name}}
183
184\unexpanded\def\syst_structure_start_opt_project [#name]{\clf_startproject {#name}}
185\unexpanded\def\syst_structure_start_opt_product [#name]{\clf_startproduct {#name}}
186\unexpanded\def\syst_structure_start_opt_component [#name]{\clf_startcomponent {#name}}
187\unexpanded\def\syst_structure_start_opt_environment[#name]{\clf_startenvironment{#name}}
188
189\newconditional\endofinput
190
191\unexpanded\def\signalendofinput#1
192 {\global\settrue\endofinput}
193
194\unexpanded\def\honorendofinput
195 {\ifconditional\endofinput
196 \global\setfalse\endofinput
197 \endinput
198 \fi}
199
200\unexpanded\def\stopproject {\clf_stopproject \honorendofinput}
201\unexpanded\def\stopproduct {\clf_stopproduct \honorendofinput}
202\unexpanded\def\stopcomponent {\clf_stopcomponent \honorendofinput}
203\unexpanded\def\stopenvironment {\clf_stopenvironment\honorendofinput}
204
205 \let\currentproject \clf_currentproject
206 \let\currentproduct \clf_currentproduct
207 \let\currentcomponent \clf_currentcomponent
208 \let\currentenvironment \clf_currentenvironment
209 \let\processedfile \clf_processedfile
210 \let\processedfiles \clf_processedfiles
211
212\unexpanded\def\dostarttextfile #name{\clf_dostarttextfile{name}}
213\unexpanded\def\dostoptextfile {\clf_dostoptextfile}
214
215\unexpanded\def\loadtexfile [#name]{\clf_usetexfile{#name}}
216\unexpanded\def\loadluafile [#name]{\clf_useluafile{#name}}
217\unexpanded\def\loadcldfile [#name]{\clf_usecldfile{#name}}
218\unexpanded\def\loadanyfile [#name]{\clf_useanyfile{#name}}
219
220\unexpanded\def\loadtexfileonce [#name]{\clf_usetexfileonce{#name}}
221\unexpanded\def\loadluafileonce [#name]{\clf_useluafileonce{#name}}
222\unexpanded\def\loadcldfileonce [#name]{\clf_usecldfileonce{#name}}
223\unexpanded\def\loadanyfileonce [#name]{\clf_useanyfileonce{#name}}
224
225
226
227\unexpanded\def\continueifinputfile#name
228 {\clf_doifelsecontinuewithfile{#name}\relax\endinput}
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254\neverypar\emptytoks
255
256
257
258\newsystemmode\v!project
259\newsystemmode\v!product
260\newsystemmode\v!component
261\newsystemmode\v!environment
262
263\unexpanded\def\startprojectindeed
264 {
265 \pushsystemmode\v!project
266 \setsystemmode\v!project}
267
268\unexpanded\def\stopprojectindeed
269 {\popsystemmode\v!project
270
271 \signalendofinput\v!project}
272
273\unexpanded\def\startproductindeed
274 {\starttext
275 \pushsystemmode\v!product
276 \setsystemmode\v!product}
277
278\unexpanded\def\stopproductindeed
279 {\popsystemmode\v!product
280 \stoptext
281 \signalendofinput\v!product}
282
283\unexpanded\def\startcomponentindeed
284 {\starttext
285 \pushreferenceprefix\currentcomponent
286 \pushsystemmode\v!component
287 \setsystemmode\v!component}
288
289\unexpanded\def\stopcomponentindeed
290 {\popsystemmode\v!component
291 \popreferenceprefix
292 \stoptext
293 \signalendofinput\v!component}
294
295\unexpanded\def\startenvironmentindeed
296 {\pushsystemmode\v!environment
297 \setsystemmode\v!environment}
298
299\unexpanded\def\stopenvironmentindeed
300 {\popsystemmode\v!environment
301 \signalendofinput\v!environment}
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330\installcorenamespace {document}
331
332\installcommandhandler \??document \s!document \??document
333
334\setupdocument
335 [\c!before=\directsetup{\s!document:\v!start},
336 \c!after =\directsetup{\s!document:\v!stop}]
337
338\def\syst_document_setup#1
339 {\directsetup{\doifelsesetups{\currentdocument:\v!start}\currentdocument\s!document:\v!start}}
340
341\appendtoks
342 \normalexpanded {
343 \startsetups[\currentdocument:\v!start]\noexpand\directsetup{\ifx\empty\currentdocumentparent\s!document\else\currentdocumentparent\fi:\v!start}\stopsetups
344 \startsetups[\currentdocument:\v!stop ]\noexpand\directsetup{\ifx\empty\currentdocumentparent\s!document\else\currentdocumentparent\fi:\v!stop }\stopsetups
345 \setvalue{\e!start\currentdocument}{\dodoubleargument\syst_document_start[\currentdocument]}
346 \letvalue{\e!stop \currentdocument}\stopdocument
347 }
348\to \everydefinedocument
349
350\unexpanded\def\startdocument
351 {\dodoubleargument\syst_document_start}
352
353\unexpanded\def\syst_document_start[#namespace][#settings]
354 {\pushmacro\currentdocument
355 \ifsecondargument
356 \edef\currentdocument{#namespace}
357 \setupcurrentdocument[#settings]
358 \else\iffirstargument
359 \doifelseassignment{#namespace}
360 {\let\currentdocument\empty
361 \setupcurrentdocument[#namespace]}
362 {\edef\currentdocument{#namespace}}
363 \fi\fi
364 \ifx\empty\currentdocument\else\setmode\currentdocument\fi
365 \starttext
366 \the\everystartdocument
367 \documentvariable\c!before}
368
369\unexpanded\def\stopdocument
370 {\documentvariable\c!after
371 \the\everystopdocument
372 \stoptext
373 \ifx\empty\currentdocument\else\resetmode\currentdocument\fi
374 \popmacro\currentdocument}
375
376 \let\documentvariable \documentparameter
377\unexpanded\def\unexpandeddocumentvariable{\documentparameter}
378
379\unexpanded\def\doifelsedocumentvariable#name{\doifelsesomething{\documentvariable{#name}}}
380\unexpanded\def\doifdocumentvariable #name{\doifsomething {\documentvariable{#name}}}
381\unexpanded\def\doifnotdocumentvariable #name{\doifnot {\documentvariable{#name}}}
382
383\let\doifdocumentvariableelse\doifelsedocumentvariable
384
385\unexpanded\def\presetdocument
386 {\dodoubleargument\syst_document_preset}
387
388\unexpanded\def\syst_document_preset[#namespace][#settings]
389 {\pushmacro\currentdocument
390 \ifsecondargument
391 \edef\currentdocument{#namespace}
392 \setupcurrentdocument[#settings]
393 \else\iffirstargument
394 \doifelseassignment{#namespace}
395 {\let\currentdocument\empty
396 \setupcurrentdocument[#namespace]}
397 {}
398 \fi\fi
399 \popmacro\currentdocument}
400
401
402
403
404
405
406
407
408
409
410
411\unexpanded\def\samplefile#1
412 {\clf_samplefile{#1}}
413
414\protect \endinput
415 |