1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17\writestatus { loading }{ ConTeXt Core Macros Bars }
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
74\registerctxluafile { node rul }{ optimize }
75
76\installcorenamespace { bar }
77\installcorenamespace { barindex }
78\installcorenamespace { barattribute }
79\installcorenamespace { barstack }
80
81\installcommandhandler \??bar { bar } \??bar
82
83\newtoks \t_node_rules_checklist
84
85\let \c_node_rules_index \relax
86\let \p_node_rules_color \empty
87
88\let \setupbars\setupbar
89
90\appendtoks
91 \ifsecondargument
92 \node_rules_define
93 \else
94 \the \t_node_rules_checklist
95 \fi
96\to \everysetupbar
97
98\appendtoks
99 \ifcsname \??barindex \currentbar \endcsname
100 \lastnamedcs \zerocount
101 \else
102 \expandafter \newcount \csname \??barindex \currentbar \endcsname
103 \fi
104
105 \normalexpanded { \t_node_rules_checklist { \the \t_node_rules_checklist \relax \node_rules_redefine { \currentbar }}}
106
107 \node_rules_define
108 \setuevalue \currentbar { \node_rules_direct { \currentbar }}
109\to \everydefinebar
110
111\newbox \b_node_rules
112
113\unexpanded \def \node_rules_define
114 { \edef \p_node_rules_color { \barparameter \c!color }
115 \edef \p_node_text { \barparameter \c!text }
116 \ifx \p_node_text \empty \else
117 \setbox \b_node_rules \hbox { \p_node_text }
118 \fi
119 \setevalue { \??barattribute \currentbar }{ \number
120 \clf_definerule
121 continue { \barparameter \c!continue }
122 unit { \barparameter \c!unit }
123 order { \barparameter \c!order }
124 rulethickness { \barparameter \c!rulethickness }
125 method \barparameter \c!method
126 max \barparameter \c!max \space
127 mp { \includeMPgraphic { \barparameter \c!mp }}
128 ma \thecolormodelattribute
129 ca \thecolorattribute \p_node_rules_color
130 ta \thetransparencyattribute \p_node_rules_color
131 offset \barparameter \c!offset \space
132 dy \barparameter \c!dy \space
133 empty { \barparameter \c!empty }
134 \ifx \p_node_text \empty \else
135
136 text \b_node_rules
137 repeat { \barparameter \c!repeat }
138 \fi
139 \relax }}
140
141\unexpanded \def \node_rules_redefine # 1
142 { \def \currentbar { # 1 } \node_rules_define }
143
144\unexpanded \def \node_rules_direct # 1
145 { \groupedcommand
146 { \node_rules_set { # 1 } \barparameter \c!left }
147 { \relax \barparameter \c!right }}
148
149\unexpanded \def \inlinebar [# 1 ]
150 { \node_rules_direct { # 1 }}
151
152
153
154
155
156
157\unexpanded \def \node_rules_set # 1
158 { \edef \currentbar { # 1 }
159 \usebarstyleandcolor \c!foregroundstyle\c!foregroundcolor
160
161
162 \expandafter\let\expandafter \c_node_rules_index \csname \??barindex # 1 \endcsname
163 \advance \c_node_rules_index \plusone
164 \clf_enablerules
165 \c_attr_ruled \numexpr
166 \plusthousand * \c_node_rules_index
167
168 \csname \??barattribute # 1 \ifcsname \??bar # 1 : \number \c_node_rules_index \s!parent \endcsname : \number \c_node_rules_index \fi\endcsname
169 \relax }
170
171\unexpanded \def \resetbar
172 { \c_attr_ruled \attributeunsetvalue }
173
174\unexpanded \def \nobar
175 { \groupedcommand
176 { \resetbar \barparameter \c!left }
177 { \relax \barparameter \c!right }}
178
179\unexpanded \def \startbar [# 1 ]
180 { \begingroup
181 \node_rules_set { # 1 }
182 \ignorespaces
183 \barparameter \c!left }
184
185\unexpanded \def \stopbar
186 { \removeunwantedspaces
187 \barparameter \c!right
188 \endgroup }
189
190\unexpanded \def \setbar [# 1 ]
191 { \node_rules_set { # 1 }}
192
193\let \directsetbar \node_rules_set
194
195
196
197\newcount \c_node_rules_nesting
198
199\unexpanded \def \pushbar [# 1 ]
200 { \global\advance \c_node_rules_nesting \plusone
201 \expandafter\edef\csname \??barstack \number \c_node_rules_nesting \endcsname { \c_attr_ruled \the \c_attr_ruled }
202 \node_rules_set { # 1 }}
203
204\unexpanded \def \popbar
205 { \csname \??barstack \number \c_node_rules_nesting \endcsname
206 \global\advance \c_node_rules_nesting \minusone }
207
208\setupbars
209 [ \c!method = 0 ,
210 \c!continue = \v!no ,
211 \c!empty = ,
212 \c!offset = 0 ,
213 \c!dy = 0 ,
214 \c!max = 3 ,
215 \c!style = ,
216 \c!rulethickness = . 1 ,
217 \c!order = \v!foreground ,
218 \c!unit = ex ,
219 \c!color =]
220
221
222
223
224\let \normalmathoverbar \overbar
225\let \normalmathunderbar \underbar
226\let \normalmathoverstrike \overstrike
227\let \normalmathunderstrike \understrike
228
229\definebar [ \v!overbar ] [ \c!method = 1 , \c!dy = 0 . 4 , \c!offset = 1 . 8 , \c!continue = \v!yes ]
230\definebar [ \v!underbar ] [ \c!method = 1 , \c!dy = 0 . 4 , \c!offset = 0 . 3 , \c!continue = \v!yes ]
231\definebar [ \v!overstrike ][ \c!method = 0 , \c!dy = 0 . 4 , \c!offset = 0 . 5 , \c!continue = \v!yes ]
232
233\definebar
234 [ \v!understrike ]
235 [ \c!method = 0 ,
236 \c!offset = 1 . 3 7 5 ,
237 \c!rulethickness = 2 . 5 ,
238 \c!continue = \v!yes ,
239 \c!order = \v!background ,
240 \c!color = lightgray ]
241
242\definebar [ \v!overbars ] [ \v!overbar ] [ \c!continue = \v!no ]
243\definebar [ \v!underbars ] [ \v!underbar ] [ \c!continue = \v!no ]
244\definebar [ \v!overstrikes ] [ \v!overstrike ] [ \c!continue = \v!no ]
245\definebar [ \v!understrikes ][ \v!understrike ][ \c!continue = \v!no ]
246
247\definebar
248 [ \v!hiddenbar ]
249 [ \v!underbar ]
250 [ \c!continue = \v!yes ,
251 \c!empty = \v!yes ,
252 \c!left = \zwj ,
253 \c!right = \zwj ]
254
255
256
257
258
259\ifdefined \normalmathunderbar
260 \expandafter\let\expandafter \normaltextunderbar \csname \v!underbar \endcsname
261 \unexpanded \def \underbar { \mathortext \normalmathunderbar \normaltextunderbar }
262\else
263 \expandafter\let\expandafter \underbar \csname \v!underbar \endcsname
264\fi
265
266\ifdefined \normalmathoverbar
267 \expandafter\let\expandafter \normaltextoverbar \csname \v!overbar \endcsname
268 \unexpanded \def \overbar { \mathortext \normalmathoverbar \normaltextoverbar }
269\else
270 \expandafter\let\expandafter \overbar \csname \v!overbar \endcsname
271\fi
272
273\ifdefined \normalmathunderstrike
274 \expandafter\let\expandafter \normaltextunderstrike \csname \v!understrike \endcsname
275 \unexpanded \def \understrike { \mathortext \normalmathunderstrike \normaltextunderstrike }
276\else
277 \expandafter\let\expandafter \understrike \csname \v!understrike \endcsname
278\fi
279
280\ifdefined \normalmathoverstrike
281 \expandafter\let\expandafter \normaltextoverstrike \csname \v!overstrike \endcsname
282 \unexpanded \def \overstrike { \mathortext \normalmathoverstrike \normaltextoverstrike }
283\else
284 \expandafter\let\expandafter \overstrike \csname \v!overstrike \endcsname
285\fi
286
287\expandafter\let\expandafter \overstrikes \csname \v!overstrikes \endcsname
288\expandafter\let\expandafter \underbars \csname \v!underbars \endcsname
289\expandafter\let\expandafter \overbars \csname \v!overbars \endcsname
290
291\unexpanded \def \setupunderbar [# 1 ]
292 {}
293
294
295
296
297
298
299
300
301
302
303
304\startuseMPgraphic { rules:under:random }
305 draw
306 ( ( 0 , RuleDepth ) ... ( RuleWidth , RuleDepth ) ) randomized ( 4 RuleThickness )
307 shifted ( 0 , RuleFactor RuleOffset )
308 withpen pencircle scaled RuleThickness
309 withcolor RuleColor ;
310 setbounds currentpicture to unitsquare xysized ( RuleWidth , RuleHeight ) ;
311\stopuseMPgraphic
312
313\startuseMPgraphic { rules:under:dash }
314 draw
315 ( ( 0 , RuleDepth ) -- ( RuleWidth , RuleDepth ) )
316 shifted ( 0 , RuleFactor RuleOffset )
317 dashed dashpattern ( on RuleFactor 2 off RuleFactor 2 )
318 withpen pencircle scaled RuleThickness
319 withcolor RuleColor ;
320 setbounds currentpicture to unitsquare xysized ( RuleWidth , RuleHeight ) ;
321\stopuseMPgraphic
322
323\startuseMPgraphic { rules:under:dots }
324 path p ; p : = ( 0 , RuleDepth ) -- ( RuleWidth , RuleDepth ) ;
325 numeric l ; l : = arclength ( p ) ;
326 l : = l mod RuleThickness 4 ;
327 draw
328 p
329 shifted ( l , RuleFactor RuleOffset )
330 dashed dashpattern ( off 2 RuleThickness l on 0 off 2 RuleThickness )
331 withpen pencircle scaled 2 RuleThickness
332 withcolor RuleColor ;
333 setbounds currentpicture to unitsquare xysized ( RuleWidth , RuleHeight ) ;
334\stopuseMPgraphic
335
336\definebar
337 [ undergraphic ]
338 [ \c!mp = rules : under : dash ,
339 \c!offset = . 2 ,
340 \c!order = \v!background ]
341
342\definebar [ underrandom ] [ undergraphic ][ \c!mp = rules : under : random ]
343\definebar [ underrandoms ][ underrandom ] [ \c!continue = \v!yes ]
344
345\definebar [ underdash ] [ undergraphic ][ \c!mp = rules : under : dash ]
346\definebar [ underdashes ] [ underdash ] [ \c!continue = \v!yes ]
347
348\definebar [ underdot ] [ undergraphic ][ \c!mp = rules : under : dots ]
349\definebar [ underdots ] [ underdot ] [ \c!continue = \v!yes ]
350
351
352
353\installcorenamespace { shift }
354\installcorenamespace { shiftindex }
355\installcorenamespace { shiftattribute }
356
357\installcommandhandler \??shift { shift } \??shift
358
359\newtoks \t_node_shifts_checklist
360
361\let \c_node_shifts_index \relax
362
363\let \setupshifts \setupshift
364
365\appendtoks
366 \ifsecondargument
367 \node_shifts_define
368 \else
369 \the \t_node_shifts_checklist
370 \fi
371\to \everysetupshift
372
373\appendtoks
374 \ifcsname \??shiftindex \currentshift \endcsname
375 \lastnamedcs \zerocount
376 \else
377 \expandafter \newcount \csname \??shiftindex \currentshift \endcsname
378 \fi
379 \normalexpanded { \t_node_shifts_checklist { \the \t_node_shifts_checklist \node_shifts_redefine { \currentshift }}}
380 \node_shifts_define
381 \setuevalue \currentshift { \node_shifts_direct { \currentshift }}
382\to \everydefineshift
383
384\unexpanded \def \node_shifts_define
385 { \setevalue { \??shiftattribute \currentshift }{ \number
386 \clf_defineshift
387 continue { \shiftparameter \c!continue }
388 unit { \shiftparameter \c!unit }
389 method \shiftparameter \c!method
390 dy \shiftparameter \c!dy
391 \relax }}
392
393\unexpanded \def \node_shifts_redefine # 1
394 { \def \currentshift { # 1 } \node_shifts_define }
395
396
397
398
399
400
401
402
403\unexpanded \def \node_shifts_set # 1
404 { \def \currentshift { # 1 }
405 \expandafter\let\expandafter \c_node_shifts_index \csname \??shiftindex # 1 \endcsname
406 \advance \c_node_shifts_index \plusone
407 \clf_enableshifts
408 \c_attr_shifted \numexpr
409 \plusthousand * \c_node_shifts_index
410 \csname \??shiftattribute # 1 \ifcsname \??shift # 1 : \number \c_node_shifts_index \s!parent \endcsname : \number \c_node_shifts_index \fi\endcsname
411 \relax
412 \useshiftstyleandcolor \c!style\c!color
413 \dosetupisolatedalign { \shiftparameter \c!align }}
414
415\unexpanded \def \startshift [# 1 ]
416 { \begingroup
417 \node_shifts_set { # 1 }
418 \ignorespaces }
419
420\unexpanded \def \stopshift
421 { \removeunwantedspaces
422 \endgroup }
423
424
425
426
427\unexpanded \def \node_shifts_direct # 1
428 { \groupedcommand
429 { \begingroup \dostartisolation \begingroup \node_shifts_set { # 1 } \ignorespaces }
430 { \removeunwantedspaces \endgroup \dostopisolation \endgroup }}
431
432\setupshifts
433 [ \c!method = 0 ,
434 \c!continue = \v!no ,
435 \c!dy = 0 ,
436 \c!unit = ex ,
437 \c!align = ,
438 \c!style = ,
439 \c!color =]
440
441\defineshift [ \v!shiftup ] [ \c!method = 0 , \c!dy = 1 , \c!unit = ex , \c!continue = \v!yes , \c!style = \txx , \c!color =]
442\defineshift [ \v!shiftdown ] [ \c!method = 1 , \c!dy = . 3 , \c!unit = ex , \c!continue = \v!yes , \c!style = \txx , \c!color =]
443
444
445
446\expandafter\let\expandafter \shiftup \csname \v!shiftup \endcsname
447\expandafter\let\expandafter \shiftdown \csname \v!shiftdown \endcsname
448
449
450
451\unexpanded \def \dostartisolation { \signalcharacter }
452\unexpanded \def \dostopisolation { \signalcharacter }
453\unexpanded \def \doisolator { \signalcharacter }
454
455\unexpanded \def \dosetupisolatedalign # 1
456 { \doisolator
457 \setupalign [# 1 ] \relax }
458
459\unexpanded \def \doisolatedgroupedalign # 1 # 2
460 { \groupedcommand
461 { \begingroup \dostartisolation \begingroup # 1 }
462 { # 2 \endgroup \dostopisolation \endgroup }}
463
464
465
466
467
468
469
470\installcorenamespace { linefiller }
471\installcorenamespace { linefillerindex }
472\installcorenamespace { linefillerattribute }
473
474\installcommandhandler \??linefiller { linefiller } \??linefiller
475
476\definesystemattribute [ linefiller ][ public ]
477
478\newtoks \t_node_linefiller_checklist
479
480\let \c_node_linefiller_index \relax
481
482\let \setuplinefillers\setuplinefiller
483
484\appendtoks
485 \ifsecondargument
486 \node_linefiller_define
487 \else
488 \the \t_node_linefiller_checklist
489 \fi
490\to \everysetuplinefiller
491
492\appendtoks
493 \ifcsname \??linefillerindex \currentlinefiller \endcsname
494 \lastnamedcs \zerocount
495 \else
496 \expandafter \newcount \csname \??linefillerindex \currentlinefiller \endcsname
497 \fi
498 \etoksapp \t_node_linefiller_checklist { \t_node_linefiller_checklist \node_linefiller_redefine { \currentlinefiller }}
499 \node_linefiller_define
500\to \everydefinelinefiller
501
502\unexpanded \def \node_linefiller_define
503 { \edef \p_node_rules_color { \linefillerparameter \c!color }
504 \setevalue { \??linefillerattribute \currentlinefiller }{ \number
505 \clf_definelinefiller
506
507 location { \linefillerparameter \c!location }
508 scope { \linefillerparameter \c!scope }
509 mp { \includeMPgraphic { \linefillerparameter \c!mp }}
510 ma \thecolormodelattribute
511 ca \thecolorattribute \p_node_rules_color
512 ta \thetransparencyattribute \p_node_rules_color
513 height \dimexpr \linefillerparameter \c!height \relax
514 depth \dimexpr \linefillerparameter \c!depth \relax
515 distance \dimexpr \linefillerparameter \c!distance \relax
516 threshold \dimexpr \linefillerparameter \c!threshold \relax
517 rulethickness \dimexpr \linefillerparameter \c!rulethickness \relax
518 \relax }}
519
520\unexpanded \def \node_linefiller_redefine # 1
521 { \def \currentlinefiller { # 1 } \node_linefiller_define }
522
523\unexpanded \def \node_linefiller_set # 1
524 { \def \currentlinefiller { # 1 }
525 \expandafter\let\expandafter \c_node_linefiller_index \csname \??linefillerindex # 1 \endcsname
526 \advance \c_node_linefiller_index \plusone
527 \clf_enablelinefillers
528 \c_attr_linefiller \numexpr
529 \plusthousand * \c_node_linefiller_index
530 \csname \??linefillerattribute # 1 \ifcsname \??linefiller # 1 : \number \c_node_linefiller_index \s!parent \endcsname : \number \c_node_linefiller_index \fi\endcsname
531 \relax }
532
533\unexpanded \def \startlinefiller
534 { \dodoubleempty \node_linefiller_start }
535
536\unexpanded \def \node_linefiller_start [# 1 ][# 2 ]
537 { \begingroup
538 \par
539 \def \currentlinefiller { # 1 }
540 \ifsecondargument
541
542 \setuplinefiller [# 1 ][# 2 ]
543 \fi
544 \node_linefiller_set { # 1 }
545 \linefillerparameter \c!before
546 \usealignparameter \linefillerparameter
547 \uselinefillerstyleandcolor \c!textstyle\c!textcolor }
548
549\unexpanded \def \stoplinefiller
550 { \par
551 \linefillerparameter \c!after
552 \endgroup }
553
554\unexpanded \def \setlinefiller [# 1 ]
555 { \node_linefiller_set { # 1 }}
556
557\setuplinefillers
558 [
559
560 \c!location = \v!both ,
561 \c!scope = \v!local ,
562 \c!distance = \zeropoint ,
563 \c!threshold = \zeropoint ,
564 \c!rulethickness = \linewidth ,
565 \c!height = \linewidth ,
566 \c!depth = \zeropoint ,
567
568
569
570
571
572 \c!color =]
573
574\definelinefiller
575 [ filler ]
576 [ \c!height = . 7 5 \exheight ,
577
578
579 \c!distance = . 2 5 \emwidth ,
580 \c!rulethickness = . 2 5 \exheight ]
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597\unexpanded \def \node_backgrounds_filler_box # 1 # 2 [# 3 ]
598 { \bgroup
599 \clf_enablebackgroundboxes
600 \dowithnextbox {
601 \node_linefiller_set { # 3 }
602 # 1
603 attr \backgroundattribute \plusone
604
605 { \box \nextbox }
606 \egroup }
607 # 2 }
608
609\unexpanded \def \linefillerhbox { \node_backgrounds_filler_box \hpack\hbox }
610\unexpanded \def \linefillervbox { \node_backgrounds_filler_box \vpack\vbox }
611\unexpanded \def \linefillervtop { \node_backgrounds_filler_box \tpack\vtop }
612
613
614
615\unexpanded \def \autorule { \clf_autorule }
616
617\protect \endinput
618 |