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{noderul}{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\pushoverloadmode
225
226\let\normalmathoverbar \overbar
227\let\normalmathunderbar \underbar
228\let\normalmathoverstrike \overstrike
229\let\normalmathunderstrike\understrike
230
231\definebar[\v!overbar] [\c!method=1,\c!dy=0.4,\c!offset=1.8,\c!continue=\v!yes]
232\definebar[\v!underbar] [\c!method=1,\c!dy=0.4,\c!offset=0.3,\c!continue=\v!yes]
233\definebar[\v!overstrike][\c!method=0,\c!dy=0.4,\c!offset=0.5,\c!continue=\v!yes]
234
235\popoverloadmode
236
237\definebar
238 [\v!understrike]
239 [\c!method=0,
240 \c!offset=1.375,
241 \c!rulethickness=2.5,
242 \c!continue=\v!yes,
243 \c!order=\v!background,
244 \c!color=lightgray]
245
246\definebar[\v!overbars] [\v!overbar] [\c!continue=\v!no]
247\definebar[\v!underbars] [\v!underbar] [\c!continue=\v!no]
248\definebar[\v!overstrikes] [\v!overstrike] [\c!continue=\v!no]
249\definebar[\v!understrikes][\v!understrike][\c!continue=\v!no]
250
251\definebar
252 [\v!hiddenbar]
253 [\v!underbar]
254 [\c!continue=\v!yes,
255 \c!empty=\v!yes,
256 \c!left=\zwj,
257 \c!right=\zwj]
258
259
260
261
262
263\ifdefined\normalmathunderbar
264 \expandafter\let\expandafter\normaltextunderbar\csname\v!underbar\endcsname
265 \unexpanded\def\underbar{\mathortext\normalmathunderbar\normaltextunderbar}
266\else
267 \expandafter\let\expandafter\underbar\csname\v!underbar\endcsname
268\fi
269
270\ifdefined\normalmathoverbar
271 \expandafter\let\expandafter\normaltextoverbar\csname\v!overbar\endcsname
272 \unexpanded\def\overbar{\mathortext\normalmathoverbar\normaltextoverbar}
273\else
274 \expandafter\let\expandafter\overbar\csname\v!overbar\endcsname
275\fi
276
277\ifdefined\normalmathunderstrike
278 \expandafter\let\expandafter\normaltextunderstrike\csname\v!understrike\endcsname
279 \unexpanded\def\understrike{\mathortext\normalmathunderstrike\normaltextunderstrike}
280\else
281 \expandafter\let\expandafter\understrike\csname\v!understrike\endcsname
282\fi
283
284\ifdefined\normalmathoverstrike
285 \expandafter\let\expandafter\normaltextoverstrike\csname\v!overstrike\endcsname
286 \unexpanded\def\overstrike{\mathortext\normalmathoverstrike \normaltextoverstrike}
287\else
288 \expandafter\let\expandafter\overstrike\csname\v!overstrike\endcsname
289\fi
290
291\expandafter\let\expandafter\overstrikes\csname\v!overstrikes\endcsname
292\expandafter\let\expandafter\underbars \csname\v!underbars \endcsname
293\expandafter\let\expandafter\overbars \csname\v!overbars \endcsname
294
295\unexpanded\def\setupunderbar[#1]
296 {}
297
298
299
300
301
302
303
304
305
306
307
308\startuseMPgraphic{rules:under:random}
309 draw
310 ((0,RuleDepth) ... (RuleWidth,RuleDepth)) randomized (4RuleThickness)
311 shifted (0,RuleFactorRuleOffset)
312 withpen pencircle scaled RuleThickness
313 withcolor RuleColor ;
314 setbounds currentpicture to unitsquare xysized(RuleWidth,RuleHeight) ;
315\stopuseMPgraphic
316
317\startuseMPgraphic{rules:under:dash}
318 draw
319 ((0,RuleDepth) -- (RuleWidth,RuleDepth))
320 shifted (0,RuleFactorRuleOffset)
321 dashed dashpattern(on RuleFactor2 off RuleFactor2)
322 withpen pencircle scaled RuleThickness
323 withcolor RuleColor ;
324 setbounds currentpicture to unitsquare xysized(RuleWidth,RuleHeight) ;
325\stopuseMPgraphic
326
327\startuseMPgraphic{rules:under:dots}
328 path p ; p := (0,RuleDepth) -- (RuleWidth,RuleDepth) ;
329 numeric l ; l := arclength(p);
330 l := l mod RuleThickness4;
331 draw
332 p
333 shifted (l,RuleFactorRuleOffset)
334 dashed dashpattern(off 2RuleThicknessl on 0 off 2RuleThickness)
335 withpen pencircle scaled 2RuleThickness
336 withcolor RuleColor ;
337 setbounds currentpicture to unitsquare xysized(RuleWidth,RuleHeight) ;
338\stopuseMPgraphic
339
340\definebar
341 [undergraphic]
342 [\c!mp=rules:under:dash,
343 \c!offset=.2,
344 \c!continue=\v!yes,
345 \c!order=\v!background]
346
347\definebar[underrandom] [undergraphic][\c!mp=rules:under:random]
348\definebar[underrandoms][underrandom] [\c!continue=\v!no]
349
350\definebar[underdash] [undergraphic][\c!mp=rules:under:dash]
351\definebar[underdashes] [underdash] [\c!continue=\v!no]
352
353\definebar[underdot] [undergraphic][\c!mp=rules:under:dots]
354\definebar[underdots] [underdot] [\c!continue=\v!no]
355
356
357
358\installcorenamespace{shift}
359\installcorenamespace{shiftindex}
360\installcorenamespace{shiftattribute}
361
362\installcommandhandler \??shift {shift} \??shift
363
364\newtoks\t_node_shifts_checklist
365
366\let\c_node_shifts_index\relax
367
368\let\setupshifts\setupshift
369
370\appendtoks
371 \ifsecondargument
372 \node_shifts_define
373 \else
374 \the\t_node_shifts_checklist
375 \fi
376\to \everysetupshift
377
378\appendtoks
379 \ifcsname\??shiftindex\currentshift\endcsname
380 \lastnamedcs\zerocount
381 \else
382 \expandafter\newcount\csname\??shiftindex\currentshift\endcsname
383 \fi
384 \normalexpanded{\t_node_shifts_checklist{\the\t_node_shifts_checklist\node_shifts_redefine{\currentshift}}}
385 \node_shifts_define
386 \setuevalue\currentshift{\node_shifts_direct{\currentshift}}
387\to \everydefineshift
388
389\unexpanded\def\node_shifts_define
390 {\setevalue{\??shiftattribute\currentshift}{\number
391 \clf_defineshift
392 continue {\shiftparameter\c!continue}
393 unit {\shiftparameter\c!unit}
394 method \shiftparameter\c!method
395 dy \shiftparameter\c!dy
396 \relax}}
397
398\unexpanded\def\node_shifts_redefine#1
399 {\def\currentshift{#1}\node_shifts_define}
400
401
402
403
404
405
406
407
408\unexpanded\def\node_shifts_set#1
409 {\def\currentshift{#1}
410 \expandafter\let\expandafter\c_node_shifts_index\csname\??shiftindex#1\endcsname
411 \advance\c_node_shifts_index\plusone
412 \clf_enableshifts
413 \c_attr_shifted\numexpr
414 \plusthousand*\c_node_shifts_index
415 \csname\??shiftattribute#1\ifcsname\??shift#1:\number\c_node_shifts_index\s!parent\endcsname:\number\c_node_shifts_index\fi\endcsname
416 \relax
417 \useshiftstyleandcolor\c!style\c!color
418 \dosetupisolatedalign{\shiftparameter\c!align}}
419
420\unexpanded\def\startshift[#1]
421 {\begingroup
422 \node_shifts_set{#1}
423 \ignorespaces}
424
425\unexpanded\def\stopshift
426 {\removeunwantedspaces
427 \endgroup}
428
429
430
431
432\unexpanded\def\node_shifts_direct#1
433 {\groupedcommand
434 {\begingroup\dostartisolation\begingroup\node_shifts_set{#1}\ignorespaces}
435 {\removeunwantedspaces\endgroup\dostopisolation\endgroup}}
436
437\setupshifts
438 [\c!method=0,
439 \c!continue=\v!no,
440 \c!dy=0,
441 \c!unit=ex,
442 \c!align=,
443 \c!style=,
444 \c!color=]
445
446\defineshift [\v!shiftup] [\c!method=0,\c!dy=1,\c!unit=ex,\c!continue=\v!yes,\c!style=\txx,\c!color=]
447\defineshift [\v!shiftdown] [\c!method=1,\c!dy=.3,\c!unit=ex,\c!continue=\v!yes,\c!style=\txx,\c!color=]
448
449
450
451\expandafter\let\expandafter\shiftup \csname\v!shiftup \endcsname
452\expandafter\let\expandafter\shiftdown \csname\v!shiftdown \endcsname
453
454
455
456\unexpanded\def\dostartisolation{\signalcharacter}
457\unexpanded\def\dostopisolation {\signalcharacter}
458\unexpanded\def\doisolator {\signalcharacter}
459
460\unexpanded\def\dosetupisolatedalign#1
461 {\doisolator
462 \setupalign[#1]\relax}
463
464\unexpanded\def\doisolatedgroupedalign#1#2
465 {\groupedcommand
466 {\begingroup\dostartisolation\begingroup#1}
467 {#2\endgroup\dostopisolation\endgroup}}
468
469
470
471
472
473
474
475\installcorenamespace{linefiller}
476\installcorenamespace{linefillerindex}
477\installcorenamespace{linefillerattribute}
478
479\installcommandhandler \??linefiller {linefiller} \??linefiller
480
481\definesystemattribute[linefiller][public]
482
483\newtoks\t_node_linefiller_checklist
484
485\let\c_node_linefiller_index\relax
486
487\let\setuplinefillers\setuplinefiller
488
489\appendtoks
490 \ifsecondargument
491 \node_linefiller_define
492 \else
493 \the\t_node_linefiller_checklist
494 \fi
495\to \everysetuplinefiller
496
497\appendtoks
498 \ifcsname\??linefillerindex\currentlinefiller\endcsname
499 \lastnamedcs\zerocount
500 \else
501 \expandafter\newcount\csname\??linefillerindex\currentlinefiller\endcsname
502 \fi
503 \etoksapp\t_node_linefiller_checklist{\t_node_linefiller_checklist\node_linefiller_redefine{\currentlinefiller}}
504 \node_linefiller_define
505\to \everydefinelinefiller
506
507\unexpanded\def\node_linefiller_define
508 {\edef\p_node_rules_color{\linefillerparameter\c!color}
509 \setevalue{\??linefillerattribute\currentlinefiller}{\number
510 \clf_definelinefiller
511
512 location {\linefillerparameter\c!location}
513 scope {\linefillerparameter\c!scope}
514 mp {\includeMPgraphic{\linefillerparameter\c!mp}}
515 ma \thecolormodelattribute
516 ca \thecolorattribute\p_node_rules_color
517 ta \thetransparencyattribute\p_node_rules_color
518 height \dimexpr\linefillerparameter\c!height\relax
519 depth \dimexpr\linefillerparameter\c!depth\relax
520 distance \dimexpr\linefillerparameter\c!distance\relax
521 threshold \dimexpr\linefillerparameter\c!threshold\relax
522 rulethickness \dimexpr\linefillerparameter\c!rulethickness\relax
523 \relax}}
524
525\unexpanded\def\node_linefiller_redefine#1
526 {\def\currentlinefiller{#1}\node_linefiller_define}
527
528\unexpanded\def\node_linefiller_set#1
529 {\def\currentlinefiller{#1}
530 \expandafter\let\expandafter\c_node_linefiller_index\csname\??linefillerindex#1\endcsname
531 \advance\c_node_linefiller_index\plusone
532 \clf_enablelinefillers
533 \c_attr_linefiller\numexpr
534 \plusthousand*\c_node_linefiller_index
535 \csname\??linefillerattribute#1\ifcsname\??linefiller#1:\number\c_node_linefiller_index\s!parent\endcsname:\number\c_node_linefiller_index\fi\endcsname
536 \relax}
537
538\unexpanded\def\startlinefiller
539 {\dodoubleempty\node_linefiller_start}
540
541\unexpanded\def\node_linefiller_start[#1][#2]
542 {\begingroup
543 \par
544 \def\currentlinefiller{#1}
545 \ifsecondargument
546
547 \setuplinefiller[#1][#2]
548 \fi
549 \node_linefiller_set{#1}
550 \linefillerparameter\c!before
551 \usealignparameter\linefillerparameter
552 \uselinefillerstyleandcolor\c!textstyle\c!textcolor}
553
554\unexpanded\def\stoplinefiller
555 {\par
556 \linefillerparameter\c!after
557 \endgroup}
558
559\unexpanded\def\setlinefiller[#1]
560 {\node_linefiller_set{#1}}
561
562\setuplinefillers
563 [
564
565 \c!location=\v!both,
566 \c!scope=\v!local,
567 \c!distance=\zeropoint,
568 \c!threshold=\zeropoint,
569 \c!rulethickness=\linewidth,
570 \c!height=\linewidth,
571 \c!depth=\zeropoint,
572
573
574
575
576
577 \c!color=]
578
579\definelinefiller
580 [filler]
581 [\c!height=.75\exheight,
582
583
584 \c!distance=.25\emwidth,
585 \c!rulethickness=.25\exheight]
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602\unexpanded\def\node_backgrounds_filler_box#1#2[#3]
603 {\bgroup
604 \clf_enablebackgroundboxes
605 \dowithnextbox{
606 \node_linefiller_set{#3}
607 #1
608 attr \backgroundattribute \plusone
609
610 {\box\nextbox}
611 \egroup}
612 #2}
613
614\unexpanded\def\linefillerhbox{\node_backgrounds_filler_box\hpack\hbox}
615\unexpanded\def\linefillervbox{\node_backgrounds_filler_box\vpack\vbox}
616\unexpanded\def\linefillervtop{\node_backgrounds_filler_box\tpack\vtop}
617
618
619
620\unexpanded\def\autorule{\clf_autorule}
621
622\protect \endinput
623 |