1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69\unprotect
70
71
72
73\setupxml
74 [ \c!entities = \v!yes ]
75
76
77
78\defineregister
79 [ texmacro ]
80
81\definesorting
82 [ texcommand ]
83 [ texcommands ]
84 [ \v!none ]
85
86\setupsorting
87 [ texcommand ]
88 [ \c!command = \showsetupinlist ,
89 \c!criterium = \setupparameter \c!criterium ]
90
91\pushmacro \setuptext
92
93\ifcase \contextlmtxmode \else \pushoverloadmode \let \setuptext \setuptext \popoverloadmode \fi
94
95\defineframedtext
96 [ setuptext ]
97 [ \c!width = \hsize ,
98 \c!height = \v!fit ,
99 \c!align = \v!right ,
100 \c!offset = 0 . 7 5 \emwidth ]
101
102\popmacro \setuptext
103
104\installcorenamespace { interfacesetup }
105
106\installsetuponlycommandhandler \??interfacesetup { setup }
107
108\setupsetup
109 [ \c!before = ,
110 \c!after = ,
111 \c!command = \setup ,
112 \c!criterium = \v!used ]
113
114
115
116\unexpanded \def \setupnumfont { }
117\unexpanded \def \setuptxtfont { }
118\unexpanded \def \setupintfont { \WORD }
119\unexpanded \def \setupvarfont { \sl }
120\unexpanded \def \setupoptfont { \sl }
121\unexpanded \def \setupalwcolor { }
122\unexpanded \def \setupoptcolor { darkgray }
123
124\unexpanded \def \setupvarword # 1 { \detokenize { # 1 } }
125\unexpanded \def \setupintword # 1 { \WORD { \detokenize { # 1 } } }
126\unexpanded \def \setuptxtword # 1 { \detokenize { # 1 } }
127
128\unexpanded \def \cmd_internal_value # 1
129 { \dontleavehmode
130 \begingroup
131 \setupintfont { # 1 }
132 \endgroup }
133
134\unexpanded \def \cmd_text_value # 1
135 { \dontleavehmode
136 \begingroup
137 \setupvarfont { # 1 }
138 \endgroup }
139
140\unexpanded \def \cmd_command_value # 1
141 { \begingroup
142 \setupvarfont { # 1 }
143 \endgroup }
144
145
146
147\let \currentSETUPfullname \s!unknown
148
149\startxmlsetups xml : setups : assemblename
150 \doifelse { \xmlatt { # 1 } { type } } { environment } {
151 \doifsomethingelse { \xmlatt { # 1 } { begin } } {
152 \edef \currentSETUPprefix { \xmllastatt }
153 } {
154 \let \currentSETUPprefix \e!start
155 }
156 } {
157 \let \currentSETUPprefix \empty
158 }
159 \edef \currentSETUPname { \xmlatt { # 1 } { name } }
160 \doifelsenothing { \xmlatt { # 1 } { variant } } {
161 \let \currentSETUPvariant \empty
162 } {
163 \def \currentSETUPvariant { : \xmllastatt }
164 }
165 \edef \currentSETUPfullname {
166 \currentSETUPprefix
167 \currentSETUPname
168 \currentSETUPvariant
169 }
170\stopxmlsetups
171
172\startxmlsetups xml : setups : assemblename : instance
173 \doifelse { \xmlatt { # 1 } { type } } { environment } {
174 \doifsomethingelse { \xmlatt { # 1 } { begin } } {
175 \edef \currentSETUPprefix { \xmllastatt }
176 } {
177 \let \currentSETUPprefix \e!start
178 }
179 } {
180 \let \currentSETUPprefix \empty
181 }
182 \edef \currentSETUPname { \xmlatt { # 1 } { name } }
183 \doifelsenothing { \xmlatt { # 1 } { variant } } {
184 \let \currentSETUPvariant \empty
185 } {
186 \def \currentSETUPvariant { : \xmllastatt }
187 }
188 \edef \currentSETUPfullname {
189 \currentSETUPprefix
190 \currentSETUPname
191 \currentSETUPvariant
192 }
193\stopxmlsetups
194
195\startxmlsetups xml : setups : register
196 \doifcommon { \xmlatt { # 1 } { variant } } { instance , instance : assignment , instance : ownnumber , instance : argument } {
197 \def \docommand # # 1 {
198 \xmlsetup { # 1 } { xml : setups : assemblename : instance }
199 \expanded { \texcommand [ \currentSETUPfullname : # # 1 ] { { # 1 } { # # 1 } } }
200 }
201 \processcommacommand [ \clf_getinstances { # 1 } ] \docommand
202 }
203 \xmlsetup { # 1 } { xml : setups : assemblename }
204 \expanded { \texcommand [ \currentSETUPfullname ] { { # 1 } { } } }
205\stopxmlsetups
206
207\startluacode
208
209 local find , gsub = string . find , string . gsub
210
211 local xmlcollected = xml . collected
212 local xmlcount = xml . count
213 local xmlfirst = xml . first
214
215 local lxmlgetid = lxml . getid
216 local lxmlflush = lxml . flush
217
218 local context = context
219
220 local setupvarword = context . formatted . setupvarword
221 local setupintword = context . formatted . setupintword
222 local setuptxtword = context . formatted . setuptxtword
223
224 local getsetupstring = interfaces . getsetupstring
225
226
227
228
229 local setups = moduledata . setups or { }
230 moduledata . setups = setups
231 local definitions = { }
232 setups . definitions = definitions
233
234 local report = logs . reporter ( " command setup " )
235 local report_known = logs . reporter ( " command setup " , " known " )
236
237 function xml . functions . setups_define ( id )
238 local x = lxmlgetid ( id )
239 for c in xmlcollected ( x , " cd:interface/cd:define " ) do
240 definitions [ c . at . name ] = c
241 end
242 for c in xmlcollected ( x , " cd:interface/cd:interface " ) do
243 c . at . file = c . __f__
244 c . at [ " xmlns:cd " ] = nil
245
246 end
247
248 local interface = interfaces . currentinterface or " en "
249
250 if interface ~ = " en " then
251
252 local constants = interfaces . complete . constants
253 local variables = interfaces . complete . variables
254 local commands = interfaces . complete . commands
255 local elements = interfaces . complete . elements
256
257 local function replace ( pattern , attribute , one , two , three )
258 for e in xmlcollected ( x , pattern ) do
259 local a = e . at
260 local t = a [ attribute ]
261 if t then
262 local c = one [ t ] or ( two and two [ t ] ) or ( three and three [ t ] )
263 if c then
264 local v = c [ interface ]
265 if v then
266 a [ attribute ] = v
267 end
268 end
269 end
270 end
271 end
272
273 replace ( ' cd:command ' , ' name ' , commands , elements , variables )
274 replace ( ' cd:string ' , ' value ' , commands , elements )
275 replace ( ' cd:variable ' , ' value ' , variables )
276
277 replace ( ' cd:parameter ' , ' name ' , constants )
278 replace ( ' cd:constant ' , ' type ' , variables )
279 replace ( ' cd:constant ' , ' default ' , variables )
280 replace ( ' cd:variable ' , ' type ' , variables )
281 replace ( ' cd:inherit ' , ' name ' , commands , elements )
282
283 replace ( ' cd:instances/cd:constant ' , ' value ' , variables )
284 end
285
286 if tex . modes [ " setups:save " ] and environment . currentrun = = 1 then
287
288
289
290 local filename = " context- " . . interface . . " .xml "
291 local xmlroot = x
292 local xmlblob = tostring ( xmlroot )
293 io . savedata ( filename , xmlblob )
294 xmlroot = xml . load ( filename )
295
296 local definitions = { }
297 for e in xml . collected ( xmlroot , " cd:interface/cd:define " ) do
298 definitions [ e . at . name ] = e . dt
299 end
300 local function resolve ( root )
301 for e in xmlcollected ( root , " * " ) do
302 if e . tg = = " resolve " then
303 local name = e . at . name or " "
304 local resolved = definitions [ name ]
305 if resolved then
306 e . __p__ . dt [ e . ni ] = resolved
307 resolve ( resolved )
308
309 else
310 report ( " unable to resolve: %a " , name )
311 end
312 end
313 end
314 end
315 resolve ( xmlroot )
316 for e in xml . collected ( xmlroot , " cd:interface/cd:define " ) do
317 e . __p__ . dt [ e . ni ] = " "
318 end
319
320 xml . delete ( xmlroot , " /cd:interface/cd:interface[@file='i-common-definitions.xml'] " )
321
322 xmlblob = xml . tostring ( xmlroot )
323 io . savedata ( filename , xmlblob )
324 xmlroot = xml . load ( filename )
325
326 local spacer = utilities . strings . newrepeater ( " " )
327 local function simplify ( dt , n )
328 local nt , nn = { } , 0
329 for i = 1 , # dt do
330 local d = dt [ i ]
331 if d . special then
332
333 elseif type ( d ) ~ = " string " then
334 d . dt = simplify ( d . dt , n + 1 )
335 nn = nn + 1 nt [ nn ] = " \n " . . spacer [ n ]
336 nn = nn + 1 nt [ nn ] = d
337 nn = nn + 1 nt [ nn ] = " \n " . . spacer [ n -1 ]
338 end
339 end
340 return nn = = 0 and " " or nt
341 end
342 xmlroot . dt = simplify ( xmlroot . dt , 0 )
343
344 xmlblob = " <?xml version='1.0'?>\n<!-- expanded and compacted i-context.xml -->\n " . . xml . tostring ( xmlroot )
345 xmlblob = gsub ( xmlblob , " \n *\n " , " \n " )
346 io . savedata ( filename , xmlblob )
347 end
348 end
349
350 function moduledata . setups . resolved ( name )
351 lxmlflush ( definitions [ name ] )
352 end
353
354 function xml . finalizers . s_count ( collected )
355 local n = 0
356 for i = 1 , # collected do
357 local c = collected [ i ]
358 local tg = c . tg
359 if tg = = " resolve " then
360 local d = definitions [ c . at . name ]
361 n = n + xmlcount ( d , " /* " )
362 elseif tg = = " delimiter " then
363
364 else
365 n = n + 1
366 end
367 end
368 context ( n )
369 end
370
371 local function getinstances ( id )
372 local t = { }
373 local x = lxmlgetid ( id )
374 local r = xmlfirst ( x , " /instances/resolve " )
375 if r then
376 local x = setups . definitions [ r . at . name ]
377 for c in xmlcollected ( x , " constant " ) do
378 t [ # t + 1 ] = c . at . value
379 end
380 else
381 for c in xmlcollected ( x , " /instances/constant " ) do
382 t [ # t + 1 ] = c . at . value
383 end
384 end
385 return t
386 end
387
388 interfaces . implement {
389 name = " getsetupstring " ,
390 actions = function ( s )
391 local g = getsetupstring ( s )
392 if not find ( s , " ^cd: " ) then
393 setuptxtword ( g )
394 elseif find ( s , " %-.$ " ) then
395 setupvarword ( g )
396 else
397 setupintword ( g )
398 end
399 end ,
400 overload = true ,
401 arguments = " string " ,
402 }
403
404 interfaces . implement {
405 name = " rawsetupstring " ,
406 actions = { getsetupstring , context } ,
407 overload = true ,
408 arguments = " string " ,
409 }
410
411 interfaces . implement {
412 name = " getinstances " ,
413 actions = { getinstances , function ( t ) context ( " %,t " , t ) end } ,
414 overload = true ,
415 arguments = { " string " } ,
416 }
417
418 if structures then
419 local synonyms = structures . synonyms
420 if synonyms then
421 local collected = synonyms . collected
422 if collected then
423 local texcommand = collected . texcommand
424 if texcommand then
425 local entries = texcommand . entries
426 if entries then
427 local t = { }
428 local n = # entries
429 for i = 1 , n do
430 t [ i ] = entries [ i ] . definition . tag
431 end
432 table . sort ( t )
433 for i = 1 , n do
434 report_known ( t [ i ] )
435 end
436 end
437 end
438 end
439 end
440 end
441\stopluacode
442
443
444
445
446
447
448
449
450
451
452\startxmlsetups xml : setups : interfacefile
453 \loadsetups [ \xmlatt { # 1 } { filename } ]
454\stopxmlsetups
455
456\startxmlsetups xml : setups : basics
457 \xmlincludeoptions { # 1 } { interfacefile include } { filename } { recurse , basename }
458 \xmlsetsetup { # 1 } { * } { xml : setups : * }
459 \xmlfunction { # 1 } { setups define }
460\stopxmlsetups
461
462\xmlregisterdocumentsetup { setups } { xml : setups : basics }
463
464\let \loadedsetups \empty
465
466\unexpanded \def \loadsetups
467 { \dosingleempty \cmd_load_setups }
468
469\def \cmd_load_setups [ # 1 ]
470 { \edef \m_cmd_asked_setups { # 1 }
471 \doifnotmode { no setup main } { \def \m_cmd_asked_setups { i context . xml } }
472 \ifx \m_cmd_asked_setups \empty \else
473 \doonlyonce { setups : # 1 }
474 { \doglobal \prependtocommalist { setups : # 1 } \loadedsetups
475 \edef \currentloadedsetup { # 1 }
476 \doiffileexistselse { # 1 }
477 { \xmlloadonly { setups : # 1 } { # 1 } { setups } }
478 { \xmlloadonly { setups : # 1 } { # 1 . xml } { setups } }
479
480 \xmlfilter { setups : # 1 } { interface command command ( xml : setups : register ) } }
481 \fi }
482
483\newconstant \c_cmd_kind
484\newconditional \c_cmd_doing_line
485\newconditional \c_cmd_measuring
486\newconditional \c_cmd_show_setup
487\newcount \c_cmd_current_argument
488\newcount \c_cmd_maximum_argument
489\newdimen \d_cmd_current_width
490\let \m_cmd_current_hash \empty
491\let \m_cmd_current_file \empty
492
493
494
495\unexpanded \def \basicsetup { \c_cmd_kind \zerocount \cmd_show_setup }
496\unexpanded \def \shortsetup { \c_cmd_kind \plusone \cmd_show_setup }
497
498\unexpanded \def \showsetup { \c_cmd_kind \plustwo \cmd_show_setup }
499
500\ifcase \contextlmtxmode \else
501 \pushoverloadmode
502 \unexpanded \def \setup { \c_cmd_kind \plustwo \cmd_show_setup }
503 \popoverloadmode
504\fi
505
506\unexpanded \def \showsetupinlist # 1 # 2 # 3
507 {
508 \edef \m_cmd_instance { \secondoftwoarguments # 3 }
509 \c_cmd_kind \plustwo
510 \xmlsetup { \firstoftwoarguments # 3 } { xml : setups : typeset }
511 \let \m_cmd_instance \empty
512 \par }
513
514\unexpanded \def \showsetupnameonly # 1 # 2 # 3
515 { \edef \m_cmd_instance { \secondoftwoarguments # 3 }
516 \c_cmd_kind \plustwo
517 \xmlsetup { \firstoftwoarguments # 3 } { xml : setups : assemblename }
518 \let \m_cmd_instance \empty
519 \texescape \currentSETUPfullname }
520
521\installtextracker
522 { cmd . showsetup }
523 { \settrue \c_cmd_show_setup }
524 { \setfalse \c_cmd_show_setup }
525
526\unexpanded \def \cmd_show_setup
527 { \doifelsenextoptionalcs \cmd_show_setup_yes \cmd_show_setup_nop }
528
529\def \cmd_show_setup_yes [ # 1 ]
530 { \cmd_show_setup_nop { # 1 } }
531
532\def \cmd_show_setup_nop # 1
533 { \begingroup
534 \registersort [ texcommand ] [ # 1 ]
535 \ifconditional \c_cmd_show_setup
536 \writestatus { setup } { # 1 \rawsynonymname { texcommand } { # 1 } }
537 \fi
538 \startelement [ setup ] [ name = # 1 ]
539 \startelement [ noexport ] [ comment = { setup definition # 1 } ]
540 \edef \cmd_id { \rawsynonymname { texcommand } { # 1 } }
541 \ifx \cmd_id \empty
542 missing : # 1
543 \else
544 \ifx \m_cmd_instance \empty
545 \edef \m_cmd_instance { \expandafter \secondoftwoarguments \cmd_id }
546 \fi
547 \xmlsetup { \expandafter \firstoftwoarguments \cmd_id } { xml : setups : typeset }
548 \let \m_cmd_instance \empty
549 \fi
550 \stopelement
551 \stopelement
552 \endgroup }
553
554\unexpanded \def \placesetup { \placelistofsorts [ texcommand ] [ \c!criterium = \v!used ] }
555\unexpanded \def \placeallsetups { \placelistofsorts [ texcommand ] [ \c!criterium = \v!all ] }
556
557
558
559\let \placeeverysetup \placeallsetups
560
561\unexpanded \def \cmd_show_setup_list_basic # 1 # 2 # 3
562 { \NC \tttf # 2 \NC \basicsetup [ # 2 ] \NC \NR }
563
564\unexpanded \def \placeeverysetupname
565 { \placelistofsorts
566 [ texcommand ]
567 [ \c!before = { \starttabulate [ ] } ,
568 \c!after = \stoptabulate ,
569 \c!criterium = \v!all ,
570 \c!command = \cmd_show_setup_list_basic ] }
571
572
573
574\startxmlsetups xml : setups : typeset
575 \doifelsenothing { # 1 } {
576 \xmlsetup { # 1 } { xml : setups : typeset : nop }
577 } {
578 \xmlsetup { # 1 } { xml : setups : typeset : yes }
579 }
580\stopxmlsetups
581
582\startxmlsetups xml : setups : typeset : nop
583 \blank
584 { \tttf MISSING SETUP }
585 \blank
586\stopxmlsetups
587
588\startxmlsetups xml : setups : make : string
589 \xmlatt { # 1 } { value }
590\stopxmlsetups
591
592\startxmlsetups xml : setups : make : instance
593 \ifx \m_cmd_instance \empty
594 \setupintfont { \xmlatt { # 1 } { value } }
595 \else
596 \m_cmd_instance
597 \fi
598\stopxmlsetups
599
600\startxmlsetups xml : setups : make : variable
601 \setupintfont { \xmlatt { # 1 } { value } }
602\stopxmlsetups
603
604\let \m_cmd_current_hash \empty
605\let \m_cmd_current_file \empty
606\let \m_cmd_font \empty
607\let \m_cmd_name \empty
608\let \m_cmd_start \empty
609\let \m_cmd_stop \empty
610\let \m_cmd_instance \empty
611
612\startxmlsetups xml : setups : make : prepare
613 \edef \m_cmd_current_hash { \xmlatt { # 1 } { hash } }
614 \xdef \m_cmd_current_file { \xmlatt { # 1 } { file } }
615 \xmldoifelseempty { # 1 } { sequence } {
616 \edef \m_cmd_name { \xmlatt { # 1 } { name } }
617 } {
618 \edef \m_cmd_name { \xmlfilter { # 1 } { sequence ( string variable instance ) command ( xml : setups : make : * ) } }
619 }
620 \doifelse { \xmlatt { # 1 } { type } } { environment } {
621 \doifsomethingelse { \xmlatt { # 1 } { begin } } {
622 \edef \m_cmd_start { \xmllastatt }
623 } {
624 \let \m_cmd_start \e!start
625 }
626 \doifsomethingelse { \xmlatt { # 1 } { end } } {
627 \edef \m_cmd_stop { \xmllastatt }
628 } {
629 \let \m_cmd_stop \e!stop
630 }
631 } {
632 \let \m_cmd_start \empty
633 \let \m_cmd_stop \empty
634 }
635 \doifelse { \xmlatt { # 1 } { generated } } { yes } {
636 \let \m_cmd_font \ttsl
637 } {
638 \let \m_cmd_font \relax
639 }
640\stopxmlsetups
641
642\startsetups xml : setups : make : start
643 \bgroup
644 \settrue \c_cmd_doing_line
645 \m_cmd_font
646 \letterbackslash
647 \m_cmd_start
648 \m_cmd_name
649 \ignorespaces
650 \egroup
651\stopsetups
652
653\startsetups xml : setups : make : stop
654 \ifx \m_cmd_stop \empty \else
655 \bgroup
656 \settrue \c_cmd_doing_line
657 \hskip . 5 em \unknown \hskip . 5 em
658 \m_cmd_font
659 \letterbackslash
660 \m_cmd_stop
661 \m_cmd_name
662 \ignorespaces
663 \egroup
664 \fi
665\stopsetups
666
667\startxmlsetups xml : setups : typeset : line
668 \ttbf
669 \nohyphens
670 \xmlsetup { # 1 } { xml : setups : make : prepare }
671 \directsetup { xml : setups : make : start }
672 \xmldoif { # 1 } { arguments } {
673 \bgroup
674 \settrue \c_cmd_doing_line
675 \global \c_cmd_current_argument \zerocount
676 \ignorespaces
677 \xmlfilter { # 1 } { arguments text ( ) }
678 \egroup
679 }
680 \directsetup { xml : setups : make : stop }
681\stopxmlsetups
682
683\startxmlsetups xml : setups : typeset : raw
684 \nohyphens
685 \veryraggedright
686 \global \c_cmd_current_argument \zerocount
687 \global \c_cmd_maximum_argument 0 \xmlfilter { # 1 } { arguments * s count ( ) } \relax
688 \xmlsetup { # 1 } { xml : setups : make : prepare }
689 \ttbf
690 \directsetup { xml : setups : make : start }
691 \xmldoif { # 1 } { arguments } {
692 \settrue \c_cmd_doing_line
693 \bgroup
694 \tttf
695 \global \c_cmd_current_argument \zerocount
696 \ignorespaces
697 \xmlfilter { # 1 } { arguments text ( ) }
698 \egroup
699 }
700 \directsetup { xml : setups : make : stop }
701\stopxmlsetups
702
703\startxmlsetups xml : setups : typeset : detail
704 \xmldoif { # 1 } { arguments } {
705 \bgroup
706 \setfalse \c_cmd_doing_line
707 \global \c_cmd_current_argument \zerocount
708
709
710 \blank [ \v!samepage , \v!medium ]
711 \switchtobodyfont [ \v!small ]
712 \ignorespaces \xmlfilter { # 1 } { arguments text ( ) } \endgraf
713 \egroup
714 }
715\stopxmlsetups
716
717\startxmlsetups xml : setups : instance
718 \doifelse { \xmltag { # 1 } } { resolve } {
719 \ctxlua{ lxml . command ( moduledata . setups . definitions [ ' \xmlatt{#1}{name} ' ] , " constant " , " xml:setups:instance " ) }
720 } {
721 \xmlatt { # 1 } { value } \enskip
722 }
723\stopxmlsetups
724
725\startxmlsetups xml : setups : typeset : instances
726 \ifx \m_cmd_instance \empty
727 \xmldoif { # 1 } { instances } {
728
729 \blank [ \v!samepage , \v!medium ]
730 { \ttbf instances : }
731 \enspace
732 \xmlfilter { # 1 } { instances ( constant resolve ) command ( xml : setups : instance ) }
733 \removeunwantedspaces
734 }
735 \fi
736\stopxmlsetups
737
738\startsetups xml : setups : start
739 \csname \e!start setuptext \endcsname
740\stopsetups
741
742\startsetups xml : setups : stop
743 \csname \e!stop setuptext \endcsname
744\stopsetups
745
746\startxmlsetups xml : setups : typeset : yes
747 \forgetparskip
748 \glet \m_cmd_current_file \empty
749 \ifcase \c_cmd_kind
750 \xmlsetup { # 1 } { xml : setups : typeset : line }
751 \or
752 \directsetup { xml : setups : start }
753 \xmlsetup { # 1 } { xml : setups : typeset : raw }
754 \directsetup { xml : setups : stop }
755 \or
756 \directsetup { xml : setups : start }
757 \xmlsetup { # 1 } { xml : setups : typeset : raw }
758 \endgraf
759 \xmlsetup { # 1 } { xml : setups : typeset : detail }
760 \endgraf
761 \xmlsetup { # 1 } { xml : setups : typeset : instances }
762 \directsetup { xml : setups : stop }
763 \fi
764 \glet \m_cmd_current_file \empty
765\stopxmlsetups
766
767\startsetups xml : setups : overlay : file
768 \vbox to \overlayheight \bgroup
769 \infofont
770 \vfill
771 \scratchdimen . 5 \exheight
772 \hbox to \overlaywidth \bgroup
773 \strut
774 \hss
775 \m_cmd_current_file
776 \hskip \dimexpr \scratchdimen \strutdp \relax
777 \egroup
778 \vskip \scratchdimen
779 \egroup
780\stopsetups
781
782\defineoverlay
783 [ setupfilename ]
784 [ \directsetup { xml : setups : overlay : file } ]
785
786\startxmlsetups xml : setups : resolve
787 \ignorespaces
788 \ctxlua{ moduledata . setups . resolved ( ' \xmlatt{#1}{name} ' ) }
789\stopxmlsetups
790
791
792
793\startxmlsetups xml : setups : define
794 \ignorespaces \xmlflush { # 1 }
795\stopxmlsetups
796
797\startxmlsetups xml : setups : sequence
798 \ignorespaces \xmlflush { # 1 }
799\stopxmlsetups
800
801\startxmlsetups xml : setups : string
802 \xmlatt { # 1 } { value } \ignorespaces
803\stopxmlsetups
804
805\startxmlsetups xml : setups : delimiter
806 \ifconditional \c_cmd_doing_line
807 \kern . 5 \emwidth
808 \letterbackslash \xmlatt { # 1 } { name }
809 \fi
810 \ignorespaces
811\stopxmlsetups
812
813\startxmlsetups xml : setups : csname \show_setup_component { # 1 } { csname } \stopxmlsetups
814\startxmlsetups xml : setups : content \show_setup_component { # 1 } { content } \stopxmlsetups
815\startxmlsetups xml : setups : position \show_setup_component { # 1 } { position } \stopxmlsetups
816\startxmlsetups xml : setups : index \show_setup_component { # 1 } { index } \stopxmlsetups
817\startxmlsetups xml : setups : text \show_setup_component { # 1 } { text } \stopxmlsetups
818\startxmlsetups xml : setups : apply \show_setup_component { # 1 } { apply } \stopxmlsetups
819\startxmlsetups xml : setups : template \show_setup_component { # 1 } { template } \stopxmlsetups
820\startxmlsetups xml : setups : triplet \show_setup_component { # 1 } { triplet } \stopxmlsetups
821\startxmlsetups xml : setups : angles \show_setup_component { # 1 } { angles } \stopxmlsetups
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836\unexpanded \def \show_setup_component # 1 # 2
837 { \ifconditional \c_cmd_doing_line
838 \getvalue { show setup # 2 } { # 1 }
839 \else
840 \simpleSETUPargument { # 2 }
841 \fi }
842
843
844
845\unexpanded \def \cmd_column_one_start
846 { \bgroup
847 \scratchdimen 2 \emwidth
848 \advance \leftskip \scratchdimen
849 \noindent \llap { \hbox to \scratchdimen { \show_setup_number \hss } }
850 \strut }
851
852\unexpanded \def \cmd_column_one_stop
853 { \endgraf
854 \egroup }
855
856\unexpanded \def \cmd_column_two_start # 1 # 2
857 { \bgroup
858 \scratchdimen 2 . 5 \emwidth
859 \advance \hangindent \dimexpr \d_cmd_current_width \scratchdimen \relax
860 \noindent \hbox to \hangindent { # 1 \hss \hbox to \scratchdimen { \hss # 2 \hss } }
861 \strut }
862
863\unexpanded \def \cmd_column_two_stop
864 { \endgraf
865 \egroup }
866
867\startxmlsetups xml : setups : assignments
868 \ifconditional \c_cmd_doing_line
869 \ifcase \c_cmd_kind
870 \expandafter \show_setup_line
871 \else
872 \expandafter \show_setup_any
873 \fi { # 1 } { assignment \xmlattdef { # 1 } { delimiters } { brackets } }
874 \else
875 \global \d_cmd_current_width \zeropoint
876 \setbox \scratchbox \vbox \bgroup
877 \settrue \c_cmd_measuring
878 \xmlall { # 1 } { ( parameter resolve ) }
879 \egroup
880 \global \d_cmd_current_width \themaxboxwidth \scratchbox \relax
881 \cmd_column_one_start
882 \ignorespaces
883 \xmldoifelse { # 1 } { ( parameter inherit resolve ) } {
884 \xmlflush { # 1 }
885 } {
886 \unknown
887 }
888 \cmd_column_one_stop
889
890 \blank [ \v!samepage , \v!medium ]
891 \ignorespaces
892 \fi
893\stopxmlsetups
894
895\startxmlsetups xml : setups : keywords
896 \ifconditional \c_cmd_doing_line
897 \ifcase \c_cmd_kind
898 \expandafter \show_setup_line
899 \else
900 \expandafter \show_setup_any
901 \fi { # 1 } { \xmlattdef { # 1 } { delimiters } { brackets } }
902 \else
903 \cmd_column_one_start
904 \ignorespaces
905 \xmlflush { # 1 }
906 \cmd_column_one_stop
907
908 \blank [ \v!samepage , \v!medium ]
909 \ignorespaces
910 \fi
911\stopxmlsetups
912
913\startxmlsetups xml : setups : parameter
914 \ifconditional \c_cmd_measuring
915 \getsetupstring { \xmlatt { # 1 } { name } } \par
916 \else
917 \cmd_column_two_start { \getsetupstring { \xmlatt { # 1 } { name } } } { = }
918 \ignorespaces
919 \xmlflush { # 1 }
920 \doifmode { interface : setup : defaults } {
921 \ifx \m_cmd_current_hash \empty \else
922 \begingroup
923
924 \let \emwidth \relax
925 \let \exheight \relax
926 \edef \temp { \csname named \m_cmd_current_hash parameter \endcsname \empty { \xmlatt { # 1 } { name } } }
927 \ifx \temp \empty \else
928 = \space
929 \detokenize \expandafter { \temp }
930 \fi
931 \endgroup
932 \fi
933 }
934 \cmd_column_two_stop
935 \fi
936 \ignorespaces
937\stopxmlsetups
938
939
940\xmlmapvalue { setups : method } { range } { : }
941\xmlmapvalue { setups : method } { apply } { > }
942\xmlmapvalue { setups : method } { factor } { * }
943\xmlmapvalue { setups : method } { none } { }
944
945\startxmlsetups xml : setups : constant : value
946 \getsetupstring { \xmlatt { # 1 } { type } }
947\stopxmlsetups
948
949\definebar
950 [ cmd underbar ]
951 [ \v!underbar ]
952 [ \c!foregroundcolor = ,
953 \c!foregroundstyle = ,
954 \c!color = ]
955
956\startxmlsetups xml : setups : constant
957 \doifelsemode { setups pass one } {
958 } {
959 \doifsomethingelse { \xmlatt { # 1 } { prefix } } {
960 \getsetupstring { \xmllastatt }
961 \xmlmappedvalue { setups : method } { \xmlatt { # 1 } { method } } { none }
962 } {
963 \doif { \xmlatt { # 1 } { default } } { yes } {
964 \cmd_underbar
965 }
966 }
967 { \getsetupstring { \xmlatt { # 1 } { type } } }
968 \space
969 \ignorespaces
970 }
971\stopxmlsetups
972
973\startxmlsetups xml : setups : variable
974 \doifelsemode { setups pass one } {
975 \expanded { \setupintfont { \xmlatt { # 1 } { value } } } \ignorespaces
976 } {
977 \getsetupstring { \xmlatt { # 1 } { value } }
978 \space
979 \ignorespaces
980 }
981\stopxmlsetups
982
983\startxmlsetups xml : setups : inherit
984
985 \rawsetupstring { cd : inherits } :
986 \enspace
987 \letterbackslash
988 \xmlatt { # 1 } { name }
989
990 \ignorespaces
991\stopxmlsetups
992
993\unexpanded \def \simpleSETUPargument # 1
994 { \cmd_column_one_start
995 \cmd_internal_value { # 1 }
996 \cmd_column_one_stop
997
998 \blank [ \v!samepage , \v!medium ]
999 \ignorespaces }
1000
1001
1002
1003\unexpanded \def \show_setup_any # 1 # 2
1004 { \bgroup
1005 \global \advance \c_cmd_current_argument \plusone
1006 \doifelse { \xmlatt { # 1 } { optional } } { yes } \donetrue \donefalse
1007 \setbox 0 = \hbox
1008 { \ifdone \sl \fi
1009 \doifelse { \xmlatt { # 1 } { list } } { yes }
1010 { \getsetupstring { cd : # 2 l } }
1011 { \getsetupstring { cd : # 2 s } } }
1012 \setbox 2 = \hbox to \wd 0
1013 { \hss
1014 \ifcase \c_cmd_kind \else
1015 \ifcase \c_cmd_maximum_argument \relax
1016 \or
1017 \raise 1 . 2 5 \exheight \hbox
1018 { \txx * }
1019 \else
1020 \raise 1 . 2 5 \exheight \hbox
1021 { \txx \the \c_cmd_current_argument }
1022 \fi
1023 \fi
1024 \hss }
1025 \setbox 4 = \hbox to \wd 0
1026 { \hss
1027 \ifdone
1028 \lower 2 \exheight \hbox
1029 \bgroup
1030 \txx
1031 \getsetupstring { cd : optional }
1032 \egroup
1033 \hss
1034 \fi }
1035 \ht 2 \ht \strutbox
1036 \dp 4 \dp \strutbox
1037 \hskip . 5 \emwidth
1038 \wd 0 \zeropoint
1039 \box 0
1040 \wd 2 \zeropoint
1041 \box 2
1042 \box 4
1043 \egroup
1044 \ignorespaces }
1045
1046\unexpanded \def \show_setup_line # 1 # 2
1047 { \kern . 5 \emwidth
1048 \getsetupstring { cd : # 2 s }
1049 \ignorespaces }
1050
1051\unexpanded \def \show_setup_number
1052 { \global \advance \c_cmd_current_argument \plusone
1053 \hbox to 2 \emwidth
1054 { \ifcase \c_cmd_maximum_argument \relax
1055 \or * \else \the \c_cmd_current_argument
1056 \fi
1057 \hss } }
1058
1059
1060
1061\unexpanded \def \setupEQsymbol
1062 { . \lower . 2 5 \exheight \hpack { = } . }
1063
1064\unexpanded \def \setupAPPLYsymbol
1065 { . . \lower . 2 5 \exheight \hpack { = > } . . }
1066
1067
1068
1069\unexpanded \def \show_setup_csname # 1 { \show_setup_any { # 1 } { noargument } }
1070\unexpanded \def \show_setup_content # 1 { \show_setup_any { # 1 } { content } }
1071\unexpanded \def \show_setup_position # 1 { \show_setup_any { # 1 } { position } }
1072\unexpanded \def \show_setup_index # 1 { \show_setup_any { # 1 } { index } }
1073\unexpanded \def \show_setup_text # 1 { \show_setup_any { # 1 } { textual } }
1074\unexpanded \def \show_setup_apply # 1 { \show_setup_any { # 1 } { apply } }
1075\unexpanded \def \show_setup_template # 1 { \show_setup_any { # 1 } { template } }
1076\unexpanded \def \show_setup_triplet # 1 { \show_setup_any { # 1 } { triplet } }
1077\unexpanded \def \show_setup_angles # 1 { \show_setup_any { # 1 } { angle } }
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097\definetype [ parametercommand ]
1098\definetype [ parameterkey ]
1099\definetype [ parametervalue ] [ \c!space = \v!on ]
1100
1101\setuptype [ parametercommand ] [ \c!color = darkmagenta ]
1102\setuptype [ parametervalue ] [ \c!color = darkyellow ]
1103
1104\startxmlsetups xml : setups : parameters : value
1105 \edef \currentsetupparameterkey { \xmlatt { # 1 } { name } }
1106 \edef \currentsetupparametervalue { \begincsname named \currentsetupparametercategory parameter \endcsname \currentsetupparameterinstance \currentsetupparameterkey }
1107 \ifx \currentsetupparameterinstance \empty
1108 \expanded {
1109 \NC \parameterkey { \currentsetupparameterkey }
1110 \NC \parametervalue { \detokenize \expandafter { \currentsetupparametervalue } }
1111 \NC \NR
1112 }
1113 \else \ifx \currentsetupparametervalue \empty
1114 \else
1115 \edef \currentsetupparameterdefault { \begincsname named \currentsetupparametercategory parameter \endcsname \empty \currentsetupparameterkey }
1116 \ifx \currentsetupparametervalue \currentsetupparameterdefault
1117
1118 \else
1119 \expanded {
1120 \NC \parameterkey { \currentsetupparameterkey }
1121 \NC \parametervalue { \detokenize \expandafter { \currentsetupparametervalue } }
1122 \NC \NR
1123 }
1124 \fi
1125 \fi \fi
1126\stopxmlsetups
1127
1128\startxmlsetups xml : setups : parameters : values
1129 \blank [ \v!big , \v!samepage ]
1130 \expanded {
1131 \parametercommand {
1132 \currentsetupparametercommand
1133 \space : \space
1134 \ifx \currentsetupparameterinstance \empty
1135 defaults
1136 \else
1137 \currentsetupparameterinstance
1138 \fi
1139 }
1140 }
1141 \blank [ \v!big , \v!samepage ]
1142 \starttabulate [ l pl ]
1143
1144 \xmlall
1145 { # 1 }
1146 { interface command [ @ name = = \currentsetupparametercommand or @ handler = = \currentsetupparametercommand ] arguments assignments parameter command ( xml : setups : parameters : value ) }
1147 \ifnum \noftabulaterows = \zerocount
1148 \NC \parameterkey { no specific settings } \NC \NC \NR
1149 \fi
1150 \stoptabulate
1151\stopxmlsetups
1152
1153\starttexdefinition showrootvalues [ # 1 ]
1154 \edef \currentsetupparametercategory { # 1 }
1155 \edef \currentsetupparametercommand { setup # 1 }
1156 \let \currentsetupparameterinstance \empty
1157 \xmlsetup { \loadedsetups } { xml : setups : parameters : values }
1158\stoptexdefinition
1159
1160\starttexdefinition showinstancevalues [ # 1 ] # 2 [ # 3 ]
1161 \edef \currentsetupparametercategory { # 1 }
1162 \edef \currentsetupparametercommand { setup # 1 }
1163 \edef \currentsetupparameterinstance { # 3 }
1164 \xmlsetup { \loadedsetups } { xml : setups : parameters : values }
1165\stoptexdefinition
1166
1167
1168
1169\unexpanded \def \cmdinternal # 1
1170 { { \tttf \getsetupstring { # 1 } } }
1171
1172\let \cmdbasicsetup \basicsetup
1173\let \cmdshortsetup \shortsetup
1174\let \cmdfullsetup \showsetup
1175
1176\unexpanded \def \cmd_with_instance # 1 # 2 # 3
1177 { \edef \m_cmd_instance { # 3 }
1178 # 1 { # 2 }
1179 \let \m_cmd_instance \empty }
1180
1181\unexpanded \def \cmdbasicsetupinstance { \cmd_with_instance \cmdbasicsetup }
1182\unexpanded \def \cmdshortsetupinstance { \cmd_with_instance \cmdshortsetup }
1183\unexpanded \def \cmdfullsetupinstance { \cmd_with_instance \cmdfullsetup }
1184
1185
1186
1187\definefloat
1188 [ definition ]
1189
1190\setupcaption
1191 [ definition ]
1192 [ align = flushright ]
1193
1194\unexpanded \def \showdefinition
1195 { \doifelsenextoptional \cmd_show_definition_yes \cmd_show_definition_nop }
1196
1197\unexpanded \def \cmd_show_definition_nop # 1
1198 { \cmd_show_definition_yes [ # 1 ] }
1199
1200\unexpanded \def \cmd_show_definition_yes [ # 1 ]
1201 { \placedefinition [ here ] [ definition : # 1 ] { \tex { # 1 } } { \showsetup { # 1 } } }
1202
1203\unexpanded \def \definition [ # 1 ]
1204 { \begingroup
1205 \getcommalistsize [ # 1 ]
1206 \scratchcounter \zerocount
1207 \def \dodefinition # # 1
1208 { \advance \scratchcounter \plusone
1209 \ifnum \scratchcounter = \commalistsize
1210 \in { and } [ definition : # # 1 ]
1211 \else \ifnum \scratchcounter = \plusone
1212 \in { definition } [ definition : # # 1 ] \space
1213 \else
1214 \in { , } [ definition : # # 1 ] \space
1215 \fi \fi }
1216 \processcommalist [ # 1 ] \dodefinition
1217 \endgroup }
1218
1219\protect \endinput
1220 |