1
2
3
4
5
6
7
8
9
10
11
12
13
14\writestatus{loading}{ConTeXt Structure Macros Registers}
15
16\registerctxluafile{strcreg}{}
17
18\unprotect
19
20\startcontextdefinitioncode
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45\installcorenamespace{register}
46
47\installcommandhandler\??register {register} \??register
48
49\let\strc_registers_setup_saved\setupregister
50
51\unexpanded\overloaded\def\setupregister
52 {\dotripleempty\strc_registers_setup}
53
54\def\strc_registers_setup[#1][#2][#3]
55 {\ifthirdargument
56 \def\strc_registers_setup_step##1{\strc_registers_setup_saved[#1:##1][#3]}
57 \processcommalist[#2]\strc_registers_setup_step
58 \else\ifsecondargument
59 \strc_registers_setup_saved[#1][#2]
60 \else
61 \strc_registers_setup_saved[#1]
62 \fi\fi}
63
64\unexpanded\def\setupregisters
65 {\dosingleempty\strc_registers_setup_root}
66
67\def\strc_registers_setup_root[#1]
68 {\strc_registers_setup_saved[#1]\relax}
69
70\setupregister
71 [\c!n=2,
72 \c!balance=\v!yes,
73 \c!align=\v!flushleft,
74 \c!tolerance=\v!stretch,
75 \c!before=\blank,
76
77
78 \c!compress=\v!no,
79 \c!interaction=\v!pagenumber,
80 \c!alternative=\v!a,
81 \c!distance=\emwidth,
82 \c!style=\v!bold,
83 \c!pagestyle=\v!slanted,
84 \c!indicator=\v!yes,
85 \c!criterium=\v!all,
86 \c!check=\v!yes,
87
88 \c!referencing=\v!on,
89 \c!location=\v!middle,
90
91 \c!number=\v!no,
92 \c!unknownreference=\v!empty,
93 \c!prefix=\v!both,
94
95
96 \c!pagenumber=\v!yes,
97 \c!pageprefixconnector=\endash,
98 \c!pagesegments=2:2,
99 \c!file=\jobname,
100
101 \c!method=,
102 \c!numberorder=\v!numbers,
103 \s!language=\currentmainlanguage]
104
105
106
107\setupregister
108 [\c!label=,
109 \c!entries=,
110 \c!alternative=]
111
112\definemixedcolumns
113 [\v!register]
114 [\c!n=\registerparameter\c!n,
115 \c!balance=\registerparameter\c!balance,
116 \c!align=\registerparameter\c!align,
117 \c!tolerance=\registerparameter\c!tolerance]
118
119
120
121
122
123
124
125
126
127
128\newconditional\c_strc_registers_defining
129\setnewconstant\c_strc_registers_maxlevel \plusfive
130
131\ifdefined\Word \else \unexpanded\def\Word#1{#1} \fi
132
133\appendtoks
134 \ifconditional\c_strc_registers_defining \else
135 \settrue\c_strc_registers_defining
136 \definemixedcolumns[\currentregister][\v!register]
137 \clf_defineregister{\currentregister}{\registerparameter\c!referencemethod}
138 \normalexpanded{\presetheadtext[\currentregister=\Word{\currentregister}]}
139 \setuevalue{\currentregister}{\dodoubleempty\strc_registers_insert_entry[\currentregister]}
140 \setuevalue{\e!see\currentregister}{\dodoubleempty\strc_registers_insert_see[\currentregister]}
141
142
143 \setuevalue{\e!place\currentregister}{\placeregister[\currentregister]}
144 \setuevalue{\e!complete\currentregister}{\completeregister[\currentregister]}
145 \setuevalue{\e!setup\currentregister\e!endsetup}{\setupregister[\currentregister]}
146 \dorecurse\c_strc_registers_maxlevel{
147 \normalexpanded{\defineregister[\currentregister:\recurselevel][\currentregister]}
148
149 \letregisterparameter{\c!entries:\recurselevel}\empty
150 \letregisterparameter{\c!keys :\recurselevel}\empty
151 }
152
153 \setfalse\c_strc_registers_defining
154 \fi
155\to \everydefineregister
156
157\appendtoks
158 \clf_setregistermethod{\currentregister}{\registerparameter\c!referencemethod}
159\to \everysetupregister
160
161
162
163\glet\currentregistername \empty
164\glet\currentregisternumber\!!zerocount
165
166\def\strc_registers_register_page_entry
167 {\iftrialtypesetting
168 \expandafter\gobblethreearguments
169 \else
170 \expandafter\strc_registers_register_page_entry_indeed
171 \fi}
172
173\def\strc_registers_register_page_expand_xml_entries
174 {\xmlstartraw
175 \xdef\currentregisterentriesa{\registerparameter{\c!entries:1}}
176 \xdef\currentregisterentriesb{\registerparameter{\c!entries:2}}
177 \xdef\currentregisterentriesc{\registerparameter{\c!entries:3}}
178 \xmlstopraw
179 \glet\currentregistercoding\s!xml}
180
181\def\strc_registers_register_page_expand_yes_entries
182 {\xdef\currentregisterentriesa{\registerparameter{\c!entries:1}}
183 \xdef\currentregisterentriesb{\registerparameter{\c!entries:2}}
184 \xdef\currentregisterentriesc{\registerparameter{\c!entries:3}}
185 \glet\currentregistercoding\s!tex}
186
187\def\strc_registers_register_page_expand_nop_entries
188 {\xdef\currentregisterentriesa{\detokenizedregisterparameter{\c!entries:1}}
189 \xdef\currentregisterentriesb{\detokenizedregisterparameter{\c!entries:2}}
190 \xdef\currentregisterentriesc{\detokenizedregisterparameter{\c!entries:3}}
191 \glet\currentregistercoding\s!tex}
192
193\def\strc_registers_register_page_expand_xml
194 {\xmlstartraw
195 \xdef\currentregisterentries{\registerparameter\c!entries}
196 \xmlstopraw
197 \glet\currentregistercoding\s!xml}
198
199\def\strc_registers_register_page_expand_yes
200 {\xdef\currentregisterentries{\registerparameter\c!entries}
201 \glet\currentregistercoding\s!tex}
202
203\def\strc_registers_register_page_expand_nop
204 {\xdef\currentregisterentries{\detokenizedregisterparameter\c!entries}
205 \glet\currentregistercoding\s!tex}
206
207\def\strc_registers_register_page_expand_xml_keys
208 {\xmlstartraw
209 \xdef\currentregisterkeysa{\registerparameter{\c!keys:1}}
210 \xdef\currentregisterkeysb{\registerparameter{\c!keys:2}}
211 \xdef\currentregisterkeysc{\registerparameter{\c!keys:3}}
212 \xmlstopraw}
213
214\def\strc_registers_register_page_expand_yes_keys
215 {\xdef\currentregisterkeysa{\registerparameter{\c!keys:1}}
216 \xdef\currentregisterkeysb{\registerparameter{\c!keys:2}}
217 \xdef\currentregisterkeysc{\registerparameter{\c!keys:3}}}
218
219\def\strc_registers_register_page_entry_indeed#1#2#3
220 {\begingroup
221 \edef\currentregister{#1}
222
223 \setupcurrentregister[#2]
224 \edef\currentregisterlabel {\registerparameter\c!label}
225 \edef\currentregisterexpansion{\registerparameter\c!expansion}
226 \edef\currentregisterownnumber{\registerparameter\c!ownnumber}
227 \xdef\currentregisterkeys {\registerparameter\c!keys}
228 \xdef\currentregisterentries {\registerparameter\c!entries}
229 \xdef\currentregisterxmlsetup {\registerparameter\c!xmlsetup}
230 \ifx\currentregisterentries\empty
231 \ifx\currentregisterexpansion\s!xml
232 \strc_registers_register_page_expand_xml_entries
233 \else\ifx\currentregisterexpansion\v!yes
234 \strc_registers_register_page_expand_yes_entries
235 \else
236 \strc_registers_register_page_expand_nop_entries
237 \fi\fi
238 \else
239 \ifx\currentregisterexpansion\s!xml
240 \strc_registers_register_page_expand_xml
241 \else\ifx\currentregisterexpansion\v!yes
242 \strc_registers_register_page_expand_yes
243 \else
244 \strc_registers_register_page_expand_nop
245 \fi\fi
246 \fi
247 \ifx\currentregisterkeys\empty
248 \ifx\currentregistercoding\s!xml
249 \strc_registers_register_page_expand_xml_keys
250 \else
251 \strc_registers_register_page_expand_yes_keys
252 \fi
253 \fi
254 \setnextinternalreference
255
256
257 \glet\currentregistername\currentregister
258 \xdef\currentregisternumber{\clf_storeregister
259 metadata {
260 name {\currentregister}
261 coding {\currentregistercoding}
262 \ifx\currentregisterownnumber\v!yes
263 own {\registerparameter\c!alternative}
264 \fi
265 \ifx\currentreferencecoding\s!xml
266 xmlroot {\xmldocument}
267 \fi
268 \ifx\currentregisterxmlsetup\empty \else
269 xmlsetup {\currentregisterxmlsetup}
270 \fi
271 }
272 references {
273 \ifx\currentregisterlabel\empty \else
274 label {\currentregisterlabel}
275 \fi
276
277 }
278 entries {
279
280 \ifx\currentregisterentries\empty
281 entries {
282 {\currentregisterentriesa}
283 {\currentregisterentriesb}
284 {\currentregisterentriesc}
285 }
286 \else
287 entry {\currentregisterentries}
288 \fi
289 \ifx\currentregisterkeys\empty
290 keys {
291 {\currentregisterkeysa}
292 {\currentregisterkeysb}
293 {\currentregisterkeysc}
294 }
295 \else
296 key {\currentregisterkeys}
297 \fi
298 }
299 userdata {\detokenize\expandafter{\normalexpanded{#3}}}
300 }
301 \clf_setinternalreference
302 internal \locationcount
303 view {\interactionparameter\c!focus}
304 \relax
305 \ifx\currentregisterownnumber\v!yes
306 \glet\currentregistersynchronize\relax
307 \else
308 \xdef\currentregistersynchronize{\clf_deferredenhanceregister{\currentregister}\number\currentregisternumber}
309 \fi
310 \currentregistersynchronize
311
312
313 \dostarttagged\t!registerlocation\currentregister
314 \c_attr_destination\lastdestinationattribute \signalcharacter
315 \dotagregisterlocation
316 \dostoptagged
317 \endgroup}
318
319\unexpanded\def\dosetfastregisterentry#1#2#3#4#5
320 {\begingroup
321 \edef\currentregister{#1}
322 \setnextinternalreference
323 \glet\currentregistername\currentregister
324 \xdef\currentregisternumber{\clf_storeregister
325 {
326 metadata {
327 name {\currentregister}
328 }
329 entries {
330 entry {#2}
331 key {#3}
332 }
333 processors {
334 entry {#4}
335 page {#5}
336 }
337 }
338 }
339
340
341
342
343 \relax
344 \xdef\currentregistersynchronize{\clf_deferredenhanceregister{\currentregister}\number\currentregisternumber}
345 \currentregistersynchronize
346 \dostarttagged\t!registerlocation\currentregister
347 \c_attr_destination\lastdestinationattribute \signalcharacter
348 \dotagregisterlocation
349 \dostoptagged
350 \endgroup}
351
352\let\dotagregisterlocation\relax
353
354\unexpanded\def\strc_registers_insert_entry[#1][#2]
355 {\def\currentregister{#1}
356 \edef\p_ownnumber{\registerparameter\c!ownnumber}
357 \ifx\p_ownnumber\v!yes
358 \expandafter\strc_registers_insert_entry_yes
359 \else
360 \expandafter\strc_registers_insert_entry_nop
361 \fi{#2}}
362
363
364
365
366
367
368
369
370
371\def\strc_registers_insert_entry_nop
372 {\ifvmode
373 \expandafter\strc_registers_insert_entry_nop_par
374 \else
375 \expandafter\strc_registers_insert_entry_nop_txt
376 \fi}
377
378\def\strc_registers_insert_entry_yes
379 {\ifvmode
380 \expandafter\strc_registers_insert_entry_yes_par
381 \else
382 \expandafter\strc_registers_insert_entry_yes_txt
383 \fi}
384
385\def\strc_registers_insert_entry_nop_par#1#2
386 {\flushatnextpar{\strc_registers_register_page_entry\currentregister{\c!keys={#1},\c!entries={#2}}{}}}
387
388\def\strc_registers_insert_entry_yes_par#1#2#3
389 {\flushatnextpar{\strc_registers_register_page_entry\currentregister{\c!keys={#1},\c!alternative=#2,\c!entries={#3}}{}}}
390
391\def\strc_registers_insert_entry_nop_txt#1#2
392 {\strc_registers_register_page_entry\currentregister{\c!keys={#1},\c!entries={#2}}{}}
393
394\def\strc_registers_insert_entry_yes_txt#1#2#3
395 {\strc_registers_register_page_entry\currentregister{\c!keys={#1},\c!alternative=#2,\c!entries={#3}}{}}
396
397\unexpanded\def\startregister{\doquadrupleempty\strc_registers_start_entry}
398\unexpanded\def\stopregister {\dodoubleargument\strc_registers_stop_entry}
399
400
401
402\let\openregisterrange \startregister
403\let\closeregisterrange\stopregister
404
405\def\strc_registers_start_entry[#1][#2][#3][#4]#5
406 {\iffourthargument
407
408 \doflushatpar{\strc_registers_register_page_entry{#1}{\c!label=#2,\c!alternative=#3,\c!keys={#4},\c!entries={#5}}{}}
409 \else
410
411 \doflushatpar{\strc_registers_register_page_entry{#1}{\c!label=#2,\c!keys={#3},\c!entries={#5}}{}}
412 \fi}
413
414\def\strc_registers_stop_entry[#1][#2]
415 {\normalexpanded{\ctxlatecommand{extendregister("#1","#2")}}}
416
417\def\setregisterentry {\dotripleempty\strc_registers_set_entry}
418\def\finishregisterentry{\dotripleempty\strc_registers_finish_entry}
419
420
421
422\def\strc_registers_set_entry [#1][#2][#3]{\doflushatpar{\strc_registers_register_page_entry{#1}{#2}{#3}}}
423\def\strc_registers_finish_entry[#1][#2][#3]{\strc_registers_finish_entry_indeed{#1}{#2}{#3}}
424
425\def\strc_registers_finish_entry_indeed#1#2#3
426 {\begingroup
427 \edef\currentregister{#1}
428
429 \resetregisterparameter\c!entries
430 \resetregisterparameter\c!label
431 \resetregisterparameter\c!keys
432 \resetregisterparameter\c!alternative
433 \setupcurrentregister[#2]
434 \edef\currentregisterlabel {\registerparameter\c!label}
435 \edef\currentregisterexpansion{\registerparameter\c!expansion}
436 \edef\currentregisterownnumber{\registerparameter\c!ownnumber}
437 \xdef\currentregisterkeys {\registerparameter\c!keys}
438 \ifx\currentregisterexpansion\s!xml
439 \xmlstartraw
440 \xdef\currentregisterentries{\registerparameter\c!entries}
441 \xmlstopraw
442 \glet\currentregistercoding\s!xml
443 \else
444 \ifx\currentregisterexpansion\v!yes
445 \xdef\currentregisterentries{\registerparameter\c!entries}
446 \else
447 \xdef\currentregisterentries{\detokenizedregisterparameter\c!entries}
448 \fi
449 \glet\currentregistercoding\s!tex
450 \fi
451
452 \ifx\currentregisterentries\empty
453 \normalexpanded{\ctxcommand{extendregister("\currentregister","\currentregisterlabel", {
454 metadata = {
455 \ifx\currentregisterownnumber\v!yes
456 own = "\registerparameter\c!alternative",
457 \fi
458 },
459 userdata = \!!bs\detokenize{#3}\!!es
460 })
461 }}
462 \else
463 \normalexpanded{\ctxcommand{extendregister("\currentregister","\currentregisterlabel", {
464 metadata = {
465
466 coding = "\currentregistercoding",
467 \ifx\currentregisterownnumber\v!yes
468 own = "\registerparameter\c!alternative",
469 \fi
470 },
471 entries = {
472
473 \!!bs\currentregisterentries\!!es,
474 \!!bs\currentregisterkeys\!!es
475 },
476 userdata = \!!bs\detokenize{#3}\!!es
477 })
478 }}
479 \fi
480 \endgroup}
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500\unexpanded\def\setstructurepageregister
501 {\dotripleempty\strc_registers_set}
502
503\def\strc_registers_set[#1][#2][#3]
504 {\doflushatpar{\strc_registers_register_page_entry{#1}{#2}{#3}}}
505
506\unexpanded\def\startstructurepageregister{\doquadrupleempty\strc_registers_start}
507\unexpanded\def\stopstructurepageregister {\dodoubleargument\strc_registers_stop}
508
509\let\openstructurepageregisterrange \startstructurepageregister
510\let\closestructurepageregisterrange\stopstructurepageregister
511
512\def\strc_registers_start[#1][#2][#3][#4]
513 {\doflushatpar{\strc_registers_register_page_entry{#1}{\c!label=#2,#3}{#4}}}
514
515\def\strc_registers_stop[#1][#2]
516 {\normalexpanded{\ctxlatecommand{structures.registers.extend("#1","#2")}}}
517
518
519
520\unexpanded\def\strc_registers_insert_see[#1][#2]#3#4
521 {\doflushatpar{\strc_registers_insert_see_indeed{#1}{#2}{#3}{#4}}}
522
523\def\strc_registers_insert_see_indeed#1#2#3#4
524 {\begingroup
525 \edef\currentregister{#1}
526 \edef\currentregisterexpansion{\registerparameter\c!expansion}
527 \ifx\currentregisterexpansion\s!xml
528 \xmlstartraw
529 \xdef\currentregisterentries{\detokenize{#3}}
530 \xdef\currentregisterseeword{\detokenize{#4}}
531 \xmlstopraw
532 \glet\currentregistercoding\s!xml
533 \else
534 \ifx\currentregisterexpansion\v!yes
535 \xdef\currentregisterentries{#3}
536 \xdef\currentregisterseeword{#4}
537 \else
538 \xdef\currentregisterentries{\detokenize{#3}}
539 \xdef\currentregisterseeword{\detokenize{#4}}
540 \fi
541 \glet\currentregistercoding\s!tex
542 \fi
543 \setnextinternalreference
544
545 \edef\temp{\clf_storeregister{
546 metadata {
547 kind {see}
548 name {\currentregister}
549 }
550 references {
551
552 }
553 entries {
554
555 entry {\currentregisterentries}
556 key {#2}
557 }
558 seeword {
559 text {\currentregisterseeword}
560 }
561 }}
562 \clf_setinternalreference
563 internal \locationcount
564 view {\interactionparameter\c!focus}
565 \relax
566 \dostarttagged\t!registerlocation\currentregister
567 \c_attr_destination\lastdestinationattribute \signalcharacter
568 \dotagregisterlocation
569 \dostoptagged
570 \endgroup}
571
572
573
574
575
576\let\utilityregisterlength\!!zerocount
577
578\def\determineregistercharacteristics
579 {\dodoubleempty\strc_registers_determine_characteristics}
580
581\def\strc_registers_determine_characteristics[#1][#2]
582 {\begingroup
583 \setupregister[#1][#2]
584 \edef\currentregister{\firstinset{#1}}
585 \normalexpanded{\endgroup\noexpand\xdef\noexpand\utilityregisterlength{\clf_analyzeregister
586 {\currentregister}
587 {
588 language {\registerparameter\s!language}
589 method {\registerparameter\c!method}
590 numberorder {\registerparameter\c!numberorder}
591 compress {\registerparameter\c!compress}
592 criterium {\registerparameter\c!criterium}
593 pagenumber \ifx\registerpageseparatorsymbol\empty false\else true\fi
594 }
595 }}
596 \ifcase\utilityregisterlength\relax
597 \resetsystemmode\v!register
598 \else
599 \setsystemmode \v!register
600 \fi}
601
602\newtoks\everyplaceregister
603
604\appendtoks
605 \dontcomplain
606\to \everyplaceregister
607
608\newconditional\c_strc_registers_text_interaction
609
610\unexpanded\def\placeregister
611 {\dodoubleempty\strc_registers_place}
612
613\def\strc_registers_place[#1][#2]
614 {\iffirstargument
615 \begingroup
616
617 \setupregister[#1][#2]
618 \edef\currentregister{\firstinset{#1}}
619 \the\everyplaceregister
620 \ifnum\namedmixedcolumnsparameter\currentregister\c!n>\plusone
621 \startmixedcolumns[\currentregister]
622 \strc_registers_place_indeed{#1}
623 \stopmixedcolumns
624 \else
625 \strc_registers_place_indeed{#1}
626 \fi
627 \endgroup
628 \fi}
629
630\def\strc_registers_place_indeed#1
631 {\doifelse{\registerparameter\c!interaction}\v!text
632 \settrue\setfalse\c_strc_registers_text_interaction
633 \clf_processregister
634 {#1}
635 {
636 language {\registerparameter\s!language}
637 method {\registerparameter\c!method}
638 numberorder {\registerparameter\c!numberorder}
639 check {\registerparameter\c!check}
640 compress {\registerparameter\c!compress}
641 criterium {\registerparameter\c!criterium}
642 pagemethod {\registerparameter\c!pagemethod}
643 pagenumber \ifx\registerpageseparatorsymbol\empty false\else true\fi
644 }{
645 separatorset {\registerparameter\c!pageprefixseparatorset}
646 conversionset {\registerparameter\c!pageprefixconversionset}
647 starter {\registerparameter\c!pageprefixstarter}
648 stopper {\registerparameter\c!pageprefixstopper}
649 set {\registerparameter\c!pageprefixset}
650 segments {\registerparameter\c!pageprefixsegments}
651 connector {\registerparameter\c!pageprefixconnector}
652 }{
653 prefix {\registerparameter\c!pageprefix}
654 separatorset {\registerparameter\c!pageseparatorset}
655 conversionset {\registerparameter\c!pageconversionset}
656 starter {\registerparameter\c!pagestarter}
657 stopper {\registerparameter\c!pagestopper}
658 segments {\registerparameter\c!pagesegments}
659 }
660 \relax}
661
662\def\strc_registers_limited_entry#1
663 {\limitatetext{#1}\currentregistermaxwidth\unknown}
664
665\appendtoks
666 \edef\currentregistermaxwidth{\registerparameter\c!maxwidth}
667 \ifx\currentregistermaxwidth\empty
668 \let\limitedregisterentry\firstofoneargument
669 \else
670 \let\limitedregisterentry\strc_registers_limited_entry
671 \fi
672\to \everyplaceregister
673
674\unexpanded\def\completeregister
675 {\dodoubleempty\strc_registers_complete}
676
677\def\strc_registers_complete[#1][#2]
678 {\iffirstargument
679 \begingroup
680 \edef\currentregister{\firstinset{#1}}
681 \normalexpanded{\startnamedsection[\v!chapter][\c!title={\headtext{\currentregister}},reference=\currentregister]}
682 \placeregister[#1][#2]
683 \page[\v!yes]
684 \stopnamedsection
685 \endgroup
686 \fi}
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709\installcorenamespace{registerindicator}
710
711\def\defaultregistercharacter#1
712 {\edef\currentregistercharacter{#1}
713 \ifx\currentregistercharacter\empty
714
715 \else\ifx\currentregistercharacter\s!unknown
716
717 \else
718 \edef\p_indicator{\registerparameter\c!indicator}
719 \ifx\p_indicator\v!yes
720 \strc_registers_place_character_yes
721 \else
722 \strc_registers_place_character_nop
723 \fi
724 \fi\fi}
725
726\def\strc_registers_place_character_yes
727 {\expandnamespaceparameter\??registerindicator\registerparameter\c!alternative\v!a{\currentregistercharacter}}
728
729\def\strc_registers_place_character_nop
730 {\registerparameter\c!before
731 \goodbreak}
732
733
734
735\def\strc_registers_indicator_a#1#2
736 {\registerparameter\c!before
737
738 \typo_injectors_check_register
739 \begingroup
740 \useregisterstyleandcolor\c!style\c!color
741 \dontleavehmode
742 \typo_injectors_mark_register
743 \strut
744 \iflocation
745 \dosetdirectpagereference{\currentregister:\v!section:#1}
746 \fi
747 \registerparameter\c!command{#2}
748 \endgroup
749 \blank[\v!samepage]
750 \registerparameter\c!after
751 \par
752 \nobreak}
753
754
755
756\def\strc_registers_indicator_b#1#2
757 {\registerparameter\c!before
758 \typo_injectors_check_register
759 \begingroup
760 \useregisterstyleandcolor\c!style\c!color
761 \dontleavehmode
762 \typo_injectors_mark_register
763 \strut
764 \iflocation
765 \dosetdirectpagereference{\currentregister:\v!section:#1}
766 \fi
767 \registerparameter\c!command{#2}
768 \endgroup
769 \registerparameter\c!after
770 \nobreak}
771
772\setvalue{\??registerindicator a}#1{\strc_registers_indicator_a{#1}{#1}}
773\setvalue{\??registerindicator A}#1{\strc_registers_indicator_a{#1}{\WORD{#1}}}
774\setvalue{\??registerindicator b}#1{\strc_registers_indicator_b{#1}{#1}}
775\setvalue{\??registerindicator B}#1{\strc_registers_indicator_b{#1}{\WORD{#1}}}
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791\doinstallinjector\s!register
792
793
794
795
796
797\newconstant \c_strc_registers_page_state
798\newdimen \d_strc_registers_distance
799
800\unexpanded\def\startregisteroutput
801 {\endgraf
802 \begingroup
803 \d_strc_registers_distance\registerparameter\c!distance\relax
804 \dostarttaggedchained\t!register\currentregister\??register
805 \forgeteverypar
806 \forgetparindent
807 \forgetparskip}
808
809\unexpanded\def\stopregisteroutput
810 {\endgraf
811 \dostoptagged
812 \endgroup}
813
814\newdimen\d_strc_registers_hangindent
815\newcount\c_strc_registers_hangafter
816
817\unexpanded\def\usenestedregisterstyleandcolor#1#2
818 {\useregisterstyleandcolor#1#2
819
820 \ifconditional\c_strc_registers_text_interaction
821 \ifx\currentcolorparameter\empty \else
822 \resetinteractionparameter\c!color
823 \resetinteractionparameter\c!contrastcolor
824 \fi
825 \fi}
826
827\unexpanded\def\startregisterentries#1
828 {\endgraf
829 \begingroup
830 \scratchcounter\ifnum#1>\c_strc_registers_maxlevel\c_strc_registers_maxlevel\else#1\fi\relax
831 \dostarttagged\t!registerentries\empty
832 \let\savedcurrentregister\currentregister
833 \edef\currentregister{\currentregister:\number\scratchcounter}
834 \usenestedregisterstyleandcolor\c!textstyle\c!textcolor
835 \ifnum\scratchcounter>\plusone
836 \advance\leftskip\d_strc_registers_distance\relax
837 \fi
838 \d_strc_registers_hangindent\registerparameter\c!distance\relax
839 \c_strc_registers_hangafter \plusone
840 \blank[\v!samepage]
841 \let\currentregister\savedcurrentregister}
842
843\unexpanded\def\stopregisterentries
844 {\endgraf
845 \dostoptagged
846 \endgroup}
847
848\unexpanded\def\startregisterentry#1
849 {\typo_injectors_check_register
850 \begingroup
851 \dostarttagged\t!registerentry\empty
852 \global\setconstant\c_strc_registers_page_state\zerocount
853 \hangindent\d_strc_registers_hangindent
854 \hangafter \c_strc_registers_hangafter
855 \typo_injectors_mark_register}
856
857\unexpanded\def\stopregisterentry
858 {\endgraf
859 \global\setconstant\c_strc_registers_page_state\zerocount
860 \dostoptagged
861 \endgroup}
862
863\unexpanded\def\startregistersection#1
864 {\dostarttagged\t!registersection\empty
865 \dostarttagged\t!registertag\empty
866 \registercharacter{#1}\endgraf
867 \dostoptagged}
868
869\unexpanded\def\stopregistersection
870 {\dostoptagged
871 \endgraf}
872
873\unexpanded\def\startregisterpages
874 {\begingroup
875 \dostarttagged\t!registerpages\empty
876 \useregisterstyleandcolor\c!pagestyle\c!pagecolor
877 \registerparameter\c!pageleft}
878
879\unexpanded\def\stopregisterpages
880 {\registerparameter\c!pageright
881 \dostoptagged
882 \endgroup}
883
884\unexpanded\def\startregisterseewords
885 {\begingroup
886 \dostarttagged\t!registerpage\empty
887 \useregisterstyleandcolor\c!pagestyle\c!pagecolor}
888
889\unexpanded\def\stopregisterseewords
890 {\dostoptagged
891 \endgroup}
892
893\unexpanded\def\registerpageseparator
894 {\ifcase\c_strc_registers_page_state
895 \hskip\d_strc_registers_distance\relax
896 \or
897 \dostarttagged\t!registerseparator\empty
898 \registerpageseparatorsymbol
899 \dostoptagged
900 \or
901 \dostarttagged\t!registerseparator\empty
902 \registerpageseparatorsymbol
903 \dostoptagged
904 \fi}
905
906\unexpanded\def\registeronepagerangeseparator
907 {\endash}
908
909
910
911
912
913
914
915
916
917\unexpanded\def\withregisterpagecommand#1#2#3#4
918 {\ifcase#3\relax
919 {\tt [entry\space not\space flushed]}
920 \else
921 \def\currentregisterpageindex{#2}
922 \iflocation
923 \strc_references_goto_internal{\applyprocessor{#1}{\registerparameter\c!pagecommand{#4}}}[internal(#2)]
924 \else
925 \applyprocessor{#1}{\registerparameter\c!pagecommand{#4}}
926 \fi
927 \fi}
928
929\unexpanded\def\pushcurrentregister#1
930 {\let\m_current_register\currentregister
931 \edef\currentregister{#1}}
932
933\unexpanded\def\popcurrentregister
934 {\let\currentregister\m_current_register}
935
936\unexpanded\def\registeronepage#1#2#3#4#5
937 {\pushcurrentregister{#1}
938 \edef\p_pagenumber{\registerparameter\c!pagenumber}
939 \ifx\p_pagenumber\v!no\else
940 \registerpageseparator
941 \global\setconstant\c_strc_registers_page_state\plusone
942 \dostarttagged\t!registerpage\empty
943 \withregisterpagecommand{#2}{#3}{#4}{#5}
944 \dostoptagged
945 \fi
946 \popcurrentregister}
947
948\newconditional\c_strc_registers_following
949
950\appendtoks
951 \edef\p_compress{\registerparameter\c!compress}
952 \ifx\p_compress\v!text
953 \settrue\c_strc_registers_following
954 \letregisterparameter\c!compress\v!yes
955 \else
956 \setfalse\c_strc_registers_following
957 \fi
958\to \everyplaceregister
959
960\unexpanded\def\registerpagerange#1#2#3#4#5#6#7#8
961 {\pushcurrentregister{#1}
962 \edef\p_pagenumber{\registerparameter\c!pagenumber}
963 \ifx\p_pagenumber\v!no\else
964 \registerpageseparator
965 \global\setconstant\c_strc_registers_page_state\plusone
966 \dostarttagged\t!registerpagerange\empty
967 \dostarttagged\t!registerfrompage\empty
968 \withregisterpagecommand{#2}{#3}{#4}{#5}
969 \dostoptagged
970 \ifconditional\c_strc_registers_following
971 \ifnum#3=\numexpr#61\relax
972 \labeltext{following:\s!singular}
973 \else
974 \labeltext{following:\s!plural}
975 \fi
976 \else
977 \registeronepagerangeseparator
978 \dostarttagged\t!registertopage\empty
979 \withregisterpagecommand{#2}{#6}{#7}{#8}
980 \fi
981 \dostoptagged
982 \dostoptagged
983 \fi
984 \popcurrentregister}
985
986\unexpanded\def\defaultregisterentry#1#2#3#4#5
987 {\pushcurrentregister{#1}
988 \def\currentregisterpageindex{#3}
989 \iflocation
990 \def\currentregisterseeindex{#4}
991 \ifconditional\c_strc_registers_text_interaction
992 \strc_references_goto_internal{\setlocationcolor\doapplyregisterentrycommand{#2}{#5}}[internal(#3)]
993 \else
994 \doapplyregisterentrycommand{#2}{#5}
995 \fi
996 \else
997 \let\currentregisterseeindex\empty
998 \doapplyregisterentrycommand{#2}{#5}
999 \fi
1000 \popcurrentregister}
1001
1002\unexpanded\def\doapplyregisterentrycommand#1#2
1003 {\dostarttagged\t!registercontent\empty
1004 \ifx\currentregisterseeindex\empty \else
1005 \dontleavehmode
1006 \dosetdirectpagereference{seeindex:\currentregisterseeindex}
1007 \fi
1008 \applyprocessor{#1}{\registerparameter\c!textcommand{\limitedregisterentry{\registerparameter\c!deeptextcommand{#2}}}}
1009 \dostoptagged}
1010
1011\unexpanded\def\doapplyregisterseecommand#1#2
1012 {\ifx\currentregisterseeindex\empty
1013 \applyprocessor{#1}{#2}
1014 \else\iflocation
1015 \strc_references_goto_internal{\applyprocessor{#1}{#2}}[seeindex:\currentregisterseeindex]
1016 \else
1017 \applyprocessor{#1}{#2}
1018 \fi\fi}
1019
1020\unexpanded\def\defaultregisterseeword#1#2#3#4#5#6#7
1021 {\pushcurrentregister{#1}
1022 \ifnum#2=\plusone
1023 \registerpageseparator
1024 \fi
1025 \global\setconstant\c_strc_registers_page_state\plustwo
1026 \def\currentregisterpageindex{#5}
1027 \dostarttagged\t!registersee\empty
1028 \settrue\c_strc_registers_page_done
1029 \iflocation
1030 \def\currentregisterseeindex{#6}
1031 \else
1032 \let\currentregisterseeindex\empty
1033 \fi
1034 \ifnum#2=\plusone
1035 \labeltexts\v!see{\doapplyregisterseecommand{#4}{#7}}
1036 \else\ifnum#2=#3\relax
1037 \labeltexts\v!and{\doapplyregisterseecommand{#4}{#7}}
1038 \else
1039 ,\space\doapplyregisterseecommand{#4}{#7}
1040 \fi\fi
1041 \dostoptagged
1042 \popcurrentregister}
1043
1044\unexpanded\def\doapplyregistersectioncommand#1#2
1045 {\ifx\currentregistersectionindex\empty
1046 \applyprocessor{#1}{#2}
1047 \else\iflocation
1048 \strc_references_goto_internal{\applyprocessor{#1}{#2}}[sectionindex:\currentregistersectionindex]
1049 \else
1050 \applyprocessor{#1}{#2}
1051 \fi\fi}
1052
1053\unexpanded\def\defaultregistersection#1#2#3#4#5#6#7
1054 {\pushcurrentregister{#1}
1055 \ifnum#2=\plusone
1056 \registerpageseparator
1057 \fi
1058 \global\setconstant\c_strc_registers_page_state\plustwo
1059 \def\currentregisterpageindex{#5}
1060 \dostarttagged\t!registersection\empty
1061 \settrue\c_strc_registers_page_done
1062 \iflocation
1063 \def\currentregistersectionindex{#6}
1064 \else
1065 \let\currentregistersectionindex\empty
1066 \fi
1067 \ifnum#2=\plusone\else
1068 ,\space
1069 \fi
1070 \doapplyregistersectioncommand{#4}{#7}
1071 \dostoptagged
1072 \popcurrentregister}
1073
1074\let\registersection \defaultregistersection
1075\let\registerseeword \defaultregisterseeword
1076\let\registerentry \defaultregisterentry
1077\let\registercharacter\defaultregistercharacter
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120\def\registerpageuserdata #1#2{\clf_registeruserdata#1{#2}}
1121\def\currentregisterpageuserdata {\registerpageuserdata\currentregisterpageindex}
1122
1123
1124
1125\unexpanded\def\registerpagebuttonsymbol
1126 {\vrule\s!width\emwidth\s!height\exheight\s!depth\zeropoint\relax}
1127
1128\installcorenamespace{registersymbol}
1129
1130\setvalue{\??registersymbol n}
1131 {\def\registerpageseparatorsymbol{,\space}}
1132
1133\setvalue{\??registersymbol a}
1134 {\def\registerpageseparatorsymbol{,\space}}
1135
1136\setvalue{\??registersymbol\v!none}
1137 {\let\registerpageseparatorsymbol\empty
1138 \let\registeronepage \gobblefivearguments
1139 \let\registerpagerange\gobbleeightarguments}
1140
1141\setvalue{\??registersymbol 1}
1142 {\let\registerpageseparatorsymbol\space
1143 \def\registeronepage {\symbol[1]\gobblefivearguments}
1144 \def\registerpagerange{\symbol[1]\gobbleeightarguments}}
1145
1146\setvalue{\??registersymbol 2}
1147 {\let\registerpageseparatorsymbol\space
1148 \def\registeronepage {\registerpagebuttonsymbol\gobblefivearguments}
1149 \def\registerpagerange{\registerpagebuttonsymbol\gobbleeightarguments}}
1150
1151\unexpanded\def\setregisterpagerendering
1152 {\doifelse{\registerparameter\c!pagenumber}\v!no
1153 {\let \currentregisterpagesymbol\v!none}
1154 {\edef\currentregisterpagesymbol{\registerparameter\c!symbol}}
1155 \ifx\currentregisterpagesymbol\empty
1156 \csname\??registersymbol n\endcsname
1157 \else\ifcsname\??registersymbol\currentregisterpagesymbol\endcsname
1158 \csname\??registersymbol\currentregisterpagesymbol\endcsname
1159 \else
1160 \let\registerpageseparatorsymbol\space
1161 \def\registeronepage {\registerparameter\c!symbol\gobblefivearguments}
1162 \def\registerpagerange{\registerparameter\c!symbol\gobbleeightarguments}
1163 \fi\fi}
1164
1165\appendtoks
1166 \setregisterpagerendering
1167\to \everyplaceregister
1168
1169
1170
1171
1172 \def\findregisterinternal#1#2#3{\clf_findregisterinternal{#1}{#2}#3\relax}
1173\unexpanded\def\pageofinternal #1{\clf_pageofinternal#1\relax}
1174
1175\unexpanded\def\linkedregisterentrylink#1#2#3#4
1176 {\iflocation
1177 \scratchcounter\findregisterinternal{#1}{#2}\currentregisternumber\relax\relax
1178 \ifcase\scratchcounter\else
1179 #3\relax
1180 \goto{\symbol[#2]}[internal(\the\scratchcounter)]
1181 #4\relax
1182 \fi
1183 \else
1184
1185
1186
1187
1188
1189
1190 \fi}
1191
1192\unexpanded\def\linkedregisterentry#1
1193 {\dontleavehmode
1194 \begingroup
1195 \setbox\scratchbox\hbox{#1}
1196 \linkedregisterentrylink\currentregistername\v!previous\relax\nobreakspace
1197 \unhbox\scratchbox
1198 \linkedregisterentrylink\currentregistername\v!next\nobreakspace\relax
1199 \endgroup}
1200
1201\unexpanded\def\registerpacked#1#2
1202 {\iflocation
1203 \hskip\d_strc_registers_distance\relax
1204 \nobreak
1205 \ifnum#1=#2\relax
1206 \goto{\symbol[\v!somewhere]}[internal(#1)]
1207 \else
1208 \goto{\symbol[\v!first]}[internal(#1)]
1209 \nobreakspace
1210 \goto{\symbol[\v!last]}[internal(#2)]
1211 \fi
1212 \fi}
1213
1214
1215
1216\defineregister
1217 [\v!index]
1218
1219
1220\stopcontextdefinitioncode
1221
1222\protect \endinput
1223 |