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\newdimension\d_rule_width
75\newdimension\d_rule_height
76\newdimension\d_rule_depth
77\newdimension\d_rule_h
78\newdimension\d_rule_v
79\newdimension\d_rule_line
80\newdimension\d_rule_offset
81\newdimension\d_rule_factor
82
83\mutable\lettonothing\m_rule_direction
84
85\mutable\lettonothing\m_rule_option
86\mutable\lettonothing\m_rule_color
87
88\registerctxluafile{noderul}{autosuffix}
89
90\installcorenamespace{bar}
91\installcorenamespace{barstack}
92
93\installcommandhandler \??bar {bar} \??bar
94
95\mutable\lettonothing\p_node_color
96\mutable\lettonothing\p_node_text
97\mutable\lettonothing\p_node_offset
98
99\aliased\let\setupbars\setupbar
100
101\appendtoks
102 \frozen\protected\instance\edefcsname\currentbar\endcsname{\node_rules_direct{\currentbar}}
103\to \everydefinebar
104
105
106
107
108
109
110\protected\def\node_rules_direct#1
111 {\groupedcommand
112 {\dontleavehmode
113 \node_rules_set{#1}
114 \barparameter\c!left
115 }
116 {
117 \barparameter\c!right}}
118
119\permanent\protected\def\inlinebar[#1]
120 {\node_rules_direct{#1}}
121
122
123
124
125
126
127
128
129
130
131
132\newinteger\c_node_rules_nesting
133\newinteger\c_node_rules_level
134\newinteger\c_node_rules_up
135\newinteger\c_node_rules_down
136
137\permanent\protected\def\node_rules_set#1
138 {\cdef\currentbar{#1}
139 \advanceby\c_node_rules_level\plusone
140 \usebarstyleandcolor\c!foregroundstyle\c!foregroundcolor
141 \edef\p_node_color {\barparameter\c!color}
142 \edef\p_node_offset {\barparameter\c!offset}
143 \edef\p_node_continue{\barparameter\c!continue}
144
145 \scratchcounter\barparameter\c!method\relax
146 \ifnum\scratchcounter=\plustwo
147
148 \orelse\ifnum\scratchcounter=\plusthree
149
150 \else
151
152 \advanceby\ifdim\p_node_offset\onepoint<\zeropoint\c_node_rules_down\else\c_node_rules_up\fi\plusone
153 \fi
154 \ifx\p_node_continue\v!always
155 \attribute\runningtextattribute \minusone
156 \let\p_node_continue\v!yes
157 \fi
158 \clf_setrule
159 method \scratchcounter
160 continue {\p_node_continue}
161 rulethickness {\barparameter\c!rulethickness}
162 mp {\includeMPgraphic{\barparameter\c!mp}}
163 ma \c_attr_colormodel
164 ca \rawcolorattribute\p_node_color
165 ta \rawtransparencyattribute\p_node_color
166 order {\barparameter\c!order}
167 \ifnum\scratchcounter=\plustwo
168 height {\barparameter\c!height}
169 depth {\barparameter\c!depth}
170 \ifchkdimexpr\p_node_offset\or
171 offset \number\lastchkdimension
172 \fi
173 \orelse\ifnum\scratchcounter=\plusthree
174 height {\barparameter\c!height}
175 depth {\barparameter\c!depth}
176 \ifchkdimexpr\p_node_offset\or
177 offset \number\lastchkdimension
178 \fi
179 \else
180 unit {\barparameter\c!unit}
181 level \c_node_rules_level
182 stack \ifdim\p_node_offset\onepoint<\zeropoint\c_node_rules_down\else\c_node_rules_up\fi
183 max \barparameter\c!max\relaxedspace
184 offset \p_node_offset\relaxedspace
185 dy \barparameter\c!dy\relaxedspace
186 empty {\barparameter\c!empty}
187 \ifempty{\barparameter\c!text}\else
188 text \hbox{\lastnamedcs}
189 repeat {\barparameter\c!repeat}
190 \fi
191 \fi
192 \relax}
193
194\permanent\protected\def\resetbar
195 {\c_attr_ruled\attributeunsetvalue}
196
197\permanent\protected\def\nobar
198 {\groupedcommand
199 {\resetbar\barparameter\c!left}
200 {\relax\barparameter\c!right}}
201
202\permanent\protected\def\startbar[#1]
203 {\begingroup
204 \node_rules_set{#1}
205 \ignorespaces
206 \barparameter\c!left}
207
208\permanent\protected\def\stopbar
209 {\removeunwantedspaces
210 \barparameter\c!right
211 \endgroup}
212
213\permanent\protected\def\setbar[#1]
214 {\node_rules_set{#1}}
215
216\aliased\let\directsetbar\node_rules_set
217
218
219
220\permanent\protected\def\pushbar[#1]
221 {\global\advanceby\c_node_rules_nesting\plusone
222 \edefcsname\??barstack\the\c_node_rules_nesting\endcsname
223 {\c_node_rules_level\the\c_node_rules_level
224 \c_attr_ruled \the\c_attr_ruled}
225 \node_rules_set{#1}}
226
227\permanent\protected\def\popbar
228 {\csname\??barstack\the\c_node_rules_nesting\endcsname\relax
229 \global\advanceby\c_node_rules_nesting\minusone}
230
231
232
233\setupbars
234 [\c!method=0,
235 \c!continue=\v!no,
236 \c!level=\v!yes,
237 \c!empty=,
238 \c!offset=0,
239 \c!dy=0,
240 \c!max=3,
241 \c!style=,
242 \c!rulethickness=.1,
243 \c!order=\v!foreground,
244 \c!height=\zeropoint,
245 \c!depth=\zeropoint,
246 \c!unit=ex,
247 \c!color=]
248
249
250
251
252\pushoverloadmode
253
254\aliased\let\normalmathoverbar \overbar
255\aliased\let\normalmathunderbar \underbar
256
257
258
259\definebar[\v!overbar] [\c!method=1,\c!dy=0.4,\c!offset=1.8,\c!continue=\v!yes]
260\definebar[\v!underbar] [\c!method=1,\c!dy=0.4,\c!offset=0.3,\c!continue=\v!yes]
261\definebar[\v!overstrike][\c!method=0,\c!dy=0.4,\c!offset=0.5,\c!continue=\v!yes]
262
263\definebar
264 [\v!understrike]
265 [\c!method=0,
266 \c!offset=1.375,
267 \c!rulethickness=2.5,
268 \c!continue=\v!yes,
269 \c!order=\v!background,
270 \c!color=lightgray]
271
272\definebar[\v!overbars] [\v!overbar] [\c!continue=\v!no]
273\definebar[\v!underbars] [\v!underbar] [\c!continue=\v!no]
274\definebar[\v!overstrikes] [\v!overstrike] [\c!continue=\v!no]
275\definebar[\v!understrikes][\v!understrike][\c!continue=\v!no]
276
277\definebar
278 [\v!hiddenbar]
279 [\v!underbar]
280 [\c!continue=\v!yes,
281 \c!empty=\v!yes,
282 \c!left=\zwj,
283 \c!right=\zwj]
284
285\definebar
286 [\v!outline]
287 [\c!method=2,
288 \c!offset=\zeropoint,
289 \c!rulethickness=0.25,
290 \c!continue=\v!yes,
291 \c!order=\v!background,
292 \c!color=lightgray]
293
294\definebar
295 [\v!outlined]
296 [\v!outline]
297 [\c!height=\strutht,
298 \c!depth=\strutdp]
299
300
301
302
303
304
305
306
307
308
309
310\definebar
311 [\v!backgroundbar]
312 [\c!method=3,
313 \c!offset=0,
314 \c!rulethickness=0.25,
315 \c!continue=\v!yes,
316 \c!order=\v!background,
317 \c!color=lightgray]
318
319\definebar
320 [mathbackground]
321 [backgroundbar]
322 [\c!continue=\v!always,
323 \c!max=1,
324 \c!height=\strutht,
325 \c!depth=\strutdp]
326
327
328
329
330
331\ifdefined\normalmathunderbar
332 \enforced\permanent\expandafter\let\expandafter\normaltextunderbar\csname\v!underbar\endcsname
333 \enforced\permanent\protected\def\underbar{\mathortext\normalmathunderbar\normaltextunderbar}
334\else
335 \enforced\permanent\expandafter\let\expandafter\underbar\csname\v!underbar\endcsname
336\fi
337
338\ifdefined\normalmathoverbar
339 \enforced\permanent\expandafter\let\expandafter\normaltextoverbar\csname\v!overbar\endcsname
340 \enforced\permanent\protected\def\overbar{\mathortext\normalmathoverbar\normaltextoverbar}
341\else
342 \enforced\permanent\expandafter\let\expandafter\overbar\csname\v!overbar\endcsname
343\fi
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359\enforced\permanent\expandafter\let\expandafter\overstrikes\csname\v!overstrikes\endcsname
360\enforced\permanent\expandafter\let\expandafter\underbars \csname\v!underbars \endcsname
361\enforced\permanent\expandafter\let\expandafter\overbars \csname\v!overbars \endcsname
362
363\enforced\permanent\protected\def\setupunderbar[#1]
364 {}
365
366\popoverloadmode
367
368
369
370
371
372
373
374
375
376
377
378\startuseMPgraphic{rules:under:random}
379 draw
380 ((0,RuleDepth) ... (RuleWidth,RuleDepth)) randomized (4RuleThickness)
381 shifted (0,RuleFactorRuleOffset)
382 withpen pencircle scaled RuleThickness
383 withcolor RuleColor ;
384 setbounds currentpicture to unitsquare xysized(RuleWidth,RuleHeight) ;
385\stopuseMPgraphic
386
387\startuseMPgraphic{rules:under:dash}
388 draw
389 ((0,RuleDepth) -- (RuleWidth,RuleDepth))
390 shifted (0,RuleFactorRuleOffset)
391 dashed dashpattern(on RuleFactor2 off RuleFactor2)
392 withpen pencircle scaled RuleThickness
393 withcolor RuleColor ;
394 setbounds currentpicture to unitsquare xysized(RuleWidth,RuleHeight) ;
395\stopuseMPgraphic
396
397\startuseMPgraphic{rules:under:dots}
398 path p ; p := (0,RuleDepth) -- (RuleWidth,RuleDepth) ;
399 numeric l ; l := arclength(p);
400 l := l mod RuleThickness4;
401 draw
402 p
403 shifted (l,RuleFactorRuleOffset)
404 dashed dashpattern(off 2RuleThicknessl on 0 off 2RuleThickness)
405 withpen pencircle scaled 2RuleThickness
406 withcolor RuleColor ;
407 setbounds currentpicture to unitsquare xysized(RuleWidth,RuleHeight) ;
408\stopuseMPgraphic
409
410\definebar
411 [undergraphic]
412 [\c!mp=rules:under:dash,
413 \c!level=\v!auto,
414 \c!offset=.2,
415 \c!dy=.4,
416 \c!continue=\v!yes,
417 \c!order=\v!background]
418
419\definebar[underrandom] [undergraphic][\c!mp=rules:under:random,]
420\definebar[underrandoms][underrandom] [\c!continue=\v!no]
421
422\definebar[underdash] [undergraphic][\c!mp=rules:under:dash]
423\definebar[underdashes] [underdash] [\c!continue=\v!no]
424
425\definebar[underdot] [undergraphic][\c!mp=rules:under:dots]
426\definebar[underdots] [underdot] [\c!continue=\v!no]
427
428
429
430\installcorenamespace{shift}
431
432\installcommandhandler \??shift {shift} \??shift
433
434\let\setupshifts\setupshift
435
436\appendtoks
437 \frozen\protected\instance\edefcsname\currentshift\endcsname{\node_shifts_direct{\currentshift}}
438\to \everydefineshift
439
440\protected\def\node_shifts_set#1
441 {\ifhastok={#1}
442 \setupcurrentshift[#1]
443 \else
444 \cdef\currentshift{#1}
445 \fi
446 \useshiftstyleandcolor\c!style\c!color
447 \dosetupisolatedalign{\shiftparameter\c!align}
448 \clf_setshift
449 continue {\shiftparameter\c!continue}
450 unit {\shiftparameter\c!unit}
451 method \shiftparameter\c!method
452 dy \shiftparameter\c!dy
453 \relax}
454
455\permanent\protected\def\startshift[#1]
456 {\begingroup
457 \node_shifts_set{#1}
458 \ignorespaces}
459
460\permanent\protected\def\stopshift
461 {\removeunwantedspaces
462 \endgroup}
463
464\protected\def\node_shifts_direct#1
465 {\groupedcommand
466 {\begingroup\dostartisolation\begingroup\node_shifts_set{#1}\ignorespaces}
467 {\removeunwantedspaces\endgroup\dostopisolation\endgroup}}
468
469\setupshifts
470 [\c!method=0,
471 \c!continue=\v!no,
472 \c!dy=0,
473 \c!unit=ex,
474 \c!align=,
475 \c!style=,
476 \c!color=]
477
478\defineshift [\v!shiftup] [\c!method=0,\c!dy=1,\c!unit=ex,\c!continue=\v!yes,\c!style=\txx,\c!color=]
479\defineshift [\v!shiftdown] [\c!method=1,\c!dy=.3,\c!unit=ex,\c!continue=\v!yes,\c!style=\txx,\c!color=]
480
481
482
483\expandafter\let\expandafter\shiftup \csname\v!shiftup \endcsname
484\expandafter\let\expandafter\shiftdown\csname\v!shiftdown\endcsname
485
486
487
488\permanent\protected\def\dostartisolation{\signalcharacter}
489\permanent\protected\def\dostopisolation {\signalcharacter}
490\permanent\protected\def\doisolator {\signalcharacter}
491
492\permanent\protected\def\dosetupisolatedalign#1
493 {\doisolator
494 \setupalign[#1]\relax}
495
496\permanent\protected\def\doisolatedgroupedalign#1#2
497 {\groupedcommand
498 {\begingroup\dostartisolation\begingroup#1}
499 {#2\endgroup\dostopisolation\endgroup}}
500
501
502
503
504
505
506
507\installcorenamespace{linefiller}
508
509\installcommandhandler \??linefiller {linefiller} \??linefiller
510
511\definesystemattribute[linefiller][public]
512
513\aliased\let\setuplinefillers\setuplinefiller
514
515\protected\def\node_linefiller_set#1
516 {\cdef\currentlinefiller{#1}
517 \edef\p_node_color{\linefillerparameter\c!color}
518 \clf_setlinefiller
519
520 location {\linefillerparameter\c!location}
521 scope {\linefillerparameter\c!scope}
522 mp {\includeMPgraphic{\linefillerparameter\c!mp}}
523 ma \c_attr_colormodel
524 ca \rawcolorattribute\p_node_color
525 ta \rawtransparencyattribute\p_node_color
526 height {\linefillerparameter\c!height}
527 depth {\linefillerparameter\c!depth}
528 distance {\linefillerparameter\c!distance}
529 threshold {\linefillerparameter\c!threshold}
530 rulethickness {\linefillerparameter\c!rulethickness}
531 \relax}
532
533\permanent\tolerant\protected\def\startlinefiller[#1]#*[#S#2]
534 {\begingroup
535 \par
536 \cdef\currentlinefiller{#1}
537 \ifparameter#2\or
538
539 \setuplinefiller[#1][#2]
540 \fi
541 \node_linefiller_set{#1}
542 \linefillerparameter\c!before
543 \usealignparameter\linefillerparameter
544 \uselinefillerstyleandcolor\c!textstyle\c!textcolor}
545
546\permanent\protected\def\stoplinefiller
547 {\par
548 \linefillerparameter\c!after
549 \endgroup}
550
551\permanent\protected\def\setlinefiller[#1]
552 {\node_linefiller_set{#1}}
553
554\setuplinefillers
555 [
556
557 \c!location=\v!both,
558 \c!scope=\v!local,
559 \c!distance=\zeropoint,
560 \c!threshold=\zeropoint,
561 \c!rulethickness=\linewidth,
562 \c!height=\linewidth,
563 \c!depth=\zeropoint,
564
565
566
567
568
569 \c!color=]
570
571\definelinefiller
572 [filler]
573 [\c!height=.75\exheight,
574
575
576 \c!distance=.25\emwidth,
577 \c!rulethickness=.25\exheight]
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594\protected\def\node_backgrounds_filler_box#1#2[#3]
595 {\bgroup
596 \clf_enablebackgroundboxes
597 \dowithnextbox{
598 \node_linefiller_set{#3}
599 #1
600 attr \backgroundattribute \plusone
601 {\box\nextbox}
602 \egroup}
603 #2}
604
605\permanent\protected\def\linefillerhbox{\node_backgrounds_filler_box\hpack\hbox}
606\permanent\protected\def\linefillervbox{\node_backgrounds_filler_box\vpack\vbox}
607\permanent\protected\def\linefillervtop{\node_backgrounds_filler_box\tpack\vtop}
608
609
610
611
612
613
614
615
616
617\installcorenamespace{shadow}
618
619\installcommandhandler \??shadow {shadow} \??shadow
620
621\let\setupshadows\setupshadow
622
623\appendtoks
624 \frozen\protected\instance\edefcsname\currentshadow\endcsname{\node_shadows_direct{\currentshadow}}
625\to \everydefineshadow
626
627\protected\def\node_shadows_set#1
628 {\ifhastok={#1}
629 \setupcurrentshadow[#1]
630 \else
631 \cdef\currentshadow{#1}
632 \fi
633 \useshadowstyleandcolor\c!style\c!color
634 \edef\p_node_color{\shadowparameter\c!contrastcolor}
635 \clf_setshadow
636 continue {\shadowparameter\c!continue}
637 unit {\shadowparameter\c!unit}
638 weight {\shadowparameter\c!weight}
639 method \shadowparameter\c!method
640 dx \shadowparameter\c!dx\relaxedspace
641 dy \shadowparameter\c!dy\relaxedspace
642
643 ma \c_attr_colormodel
644 ca \rawcolorattribute\p_node_color
645 ta \rawtransparencyattribute\p_node_color
646 \relax}
647
648\permanent\protected\def\startshadow[#1]
649 {\begingroup
650 \node_shadows_set{#1}
651 \ignorespaces}
652
653\permanent\protected\def\stopshadow
654 {\removeunwantedspaces
655 \endgroup}
656
657\protected\def\node_shadows_direct#1
658 {\groupedcommand
659 {\begingroup\dostartisolation\begingroup\node_shadows_set{#1}\ignorespaces}
660 {\removeunwantedspaces\endgroup\dostopisolation\endgroup}}
661
662\setupshadows
663 [\c!method=0,
664 \c!continue=\v!yes,
665 \c!dx=.04,
666 \c!dy=.04,
667 \c!unit=ex,
668 \c!style=,
669 \c!color=,
670 \c!weight=100,
671 \c!contrastcolor=middlegray]
672
673\defineshadow [shadowed]
674
675
676
677
678
679
680
681
682
683\installcorenamespace{graphiclines}
684\installcorenamespace{graphiccolor}
685
686\newdimen\d_grph_line_width
687\newdimen\d_grph_line_offset
688\newcount\c_grph_line_action
689
690\defcsname\??graphiclines s\endcsname{\strut}
691\defcsname\??graphiclines m\endcsname{\setstrut\strutht.85\strutht\strutdp.85\strutdp}
692\defcsname\??graphiclines a\endcsname{\d_grph_line_offset 1ma}
693\defcsname\??graphiclines x\endcsname{\d_grph_line_offset 1ex}
694\defcsname\??graphiclines h\endcsname{\d_grph_line_offset \strutht}
695\defcsname\??graphiclines d\endcsname{\d_grph_line_offset\strutdp}
696\defcsname\??graphiclines o\endcsname{\d_grph_line_offset \zeropoint}
697\defcsname\??graphiclines e\endcsname{\c_grph_line_action \plusone}
698\defcsname\??graphiclines c\endcsname{\c_grph_line_action \plustwo}
699\defcsname\??graphiclines r\endcsname{\c_grph_line_action \plustree}
700\defcsname\??graphiclines t\endcsname{\d_grph_line_offset \strutht}
701\defcsname\??graphiclines b\endcsname{\d_grph_line_offset\strutdp\c_grph_line_action\plusone}
702\defcsname\??graphiclines T\endcsname{\d_grph_line_offset .75\strutht}
703\defcsname\??graphiclines B\endcsname{\d_grph_line_offset.25\strutdp\c_grph_line_action\plusone}
704
705\def\grph_line_inject_step#1
706 {\ifcsname\??graphiclines#1\endcsname
707 \lastnamedcs
708 \orelse\ifchkdim#1\or
709 \d_grph_line_width#1\relax
710
711 \orelse\ifchkdim#1pt\or
712 \d_grph_line_width#1\d_grph_line_width
713 \else
714 \edef\m_rulecolor{#1}
715 \fi}
716
717
718
719\tolerant\permanent\protected\def\grph_line_inject
720 {\dontleavehmode
721 \iftrialtypesetting
722 \expandafter\gobbletwooptionals
723 \else
724 \expandafter\grph_line_inject_yes
725 \fi}
726
727\def\grph_line_inject_yes[#1]#*[#2]
728 {\begingroup
729 \edef\m_rulecolor{\mathmatrixparameter\c!rulecolor}
730 \d_grph_line_width{\mathmatrixparameter\c!rulethickness}
731 \d_grph_line_offset\zeropoint
732 \c_grph_line_action\zerocount
733 \processcommacommand[#2]\grph_line_inject_step
734 \ifcase\c_grph_line_action
735 \ifcstok{\begincsname\??graphiccolor#1\endcsname}\empty
736 \gletcsname\??graphiccolor#1\endcsname\m_rulecolor
737 \fi
738 \orelse\ifempty{#1}
739
740 \else
741
742 \colo_helpers_direct_activate{\begincsname\??graphiccolor#1\endcsname}
743 \gletcsname\??graphiccolor#1\endcsname\empty
744 \fi
745 \hpack \ifzeropt\d_grph_line_offset\else\s!yoffset\d_grph_line_offset\fi
746 {
747 \clf_linesegment
748 {#1}
749 \c_math_eqalign_row
750 \c_math_eqalign_column
751 \c_grph_line_action
752 \d_grph_line_width}
753 \endgroup}
754
755\let\graphicline\grph_line_inject
756
757\protect \endinput
758 |