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
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168\permanent\protected\def\node_rules_set#1
169 {\cdef\currentbar{#1}
170 \advanceby\c_node_rules_level\plusone
171 \usebarstyleandcolor\c!foregroundstyle\c!foregroundcolor
172 \edef\p_node_color {\barparameter\c!color}
173 \edef\p_node_offset{\barparameter\c!offset}
174
175 \advanceby\ifdim\p_node_offset\onepoint<\zeropoint\c_node_rules_down\else\c_node_rules_up\fi\plusone
176 \scratchcounter\barparameter\c!method\relax
177 \clf_setrule
178 method \scratchcounter
179 continue {\barparameter\c!continue}
180 rulethickness {\barparameter\c!rulethickness}
181 mp {\includeMPgraphic{\barparameter\c!mp}}
182 ma \c_attr_colormodel
183 ca \rawcolorattribute\p_node_color
184 ta \rawtransparencyattribute\p_node_color
185 order {\barparameter\c!order}
186 \ifnum\scratchcounter=\plustwo
187 height \dimexpr\barparameter\c!height\relax
188 depth \dimexpr\barparameter\c!depth\relax
189 \else
190 unit {\barparameter\c!unit}
191 level \c_node_rules_level
192 stack \ifdim\p_node_offset\onepoint<\zeropoint\c_node_rules_down\else\c_node_rules_up\fi
193 max \barparameter\c!max\space
194 offset \p_node_offset\space
195 dy \barparameter\c!dy\space
196 empty {\barparameter\c!empty}
197 \ifempty{\barparameter\c!text}\else
198 text \hbox{\lastnamedcs}
199 repeat {\barparameter\c!repeat}
200 \fi
201 \fi
202 \relax}
203
204\permanent\protected\def\resetbar
205 {\c_attr_ruled\attributeunsetvalue}
206
207\permanent\protected\def\nobar
208 {\groupedcommand
209 {\resetbar\barparameter\c!left}
210 {\relax\barparameter\c!right}}
211
212\permanent\protected\def\startbar[#1]
213 {\begingroup
214 \node_rules_set{#1}
215 \ignorespaces
216 \barparameter\c!left}
217
218\permanent\protected\def\stopbar
219 {\removeunwantedspaces
220 \barparameter\c!right
221 \endgroup}
222
223\permanent\protected\def\setbar[#1]
224 {\node_rules_set{#1}}
225
226\aliased\let\directsetbar\node_rules_set
227
228
229
230\permanent\protected\def\pushbar[#1]
231 {\global\advanceby\c_node_rules_nesting\plusone
232 \edefcsname\??barstack\the\c_node_rules_nesting\endcsname
233 {\c_node_rules_level\the\c_node_rules_level
234 \c_attr_ruled \the\c_attr_ruled}
235 \node_rules_set{#1}}
236
237\permanent\protected\def\popbar
238 {\csname\??barstack\the\c_node_rules_nesting\endcsname\relax
239 \global\advanceby\c_node_rules_nesting\minusone}
240
241
242
243\setupbars
244 [\c!method=0,
245 \c!continue=\v!no,
246 \c!level=\v!yes,
247 \c!empty=,
248 \c!offset=0,
249 \c!dy=0,
250 \c!max=3,
251 \c!style=,
252 \c!rulethickness=.1,
253 \c!order=\v!foreground,
254 \c!height=\zeropoint,
255 \c!depth=\zeropoint,
256 \c!unit=ex,
257 \c!color=]
258
259
260
261
262\pushoverloadmode
263
264\aliased\let\normalmathoverbar \overbar
265\aliased\let\normalmathunderbar \underbar
266
267
268
269\definebar[\v!overbar] [\c!method=1,\c!dy=0.4,\c!offset=1.8,\c!continue=\v!yes]
270\definebar[\v!underbar] [\c!method=1,\c!dy=0.4,\c!offset=0.3,\c!continue=\v!yes]
271\definebar[\v!overstrike][\c!method=0,\c!dy=0.4,\c!offset=0.5,\c!continue=\v!yes]
272
273\definebar
274 [\v!understrike]
275 [\c!method=0,
276 \c!offset=1.375,
277 \c!rulethickness=2.5,
278 \c!continue=\v!yes,
279 \c!order=\v!background,
280 \c!color=lightgray]
281
282\definebar[\v!overbars] [\v!overbar] [\c!continue=\v!no]
283\definebar[\v!underbars] [\v!underbar] [\c!continue=\v!no]
284\definebar[\v!overstrikes] [\v!overstrike] [\c!continue=\v!no]
285\definebar[\v!understrikes][\v!understrike][\c!continue=\v!no]
286
287\definebar
288 [\v!hiddenbar]
289 [\v!underbar]
290 [\c!continue=\v!yes,
291 \c!empty=\v!yes,
292 \c!left=\zwj,
293 \c!right=\zwj]
294
295\definebar
296 [\v!outline]
297 [\c!method=2,
298 \c!offset=0,
299 \c!rulethickness=0.25,
300 \c!continue=\v!yes,
301 \c!order=\v!background,
302 \c!color=lightgray]
303
304\definebar
305 [\v!outlined]
306 [\v!outline]
307 [\c!height=\strutht,
308 \c!depth=\strutdp]
309
310
311
312
313
314\ifdefined\normalmathunderbar
315 \enforced\permanent\expandafter\let\expandafter\normaltextunderbar\csname\v!underbar\endcsname
316 \enforced\permanent\protected\def\underbar{\mathortext\normalmathunderbar\normaltextunderbar}
317\else
318 \enforced\permanent\expandafter\let\expandafter\underbar\csname\v!underbar\endcsname
319\fi
320
321\ifdefined\normalmathoverbar
322 \enforced\permanent\expandafter\let\expandafter\normaltextoverbar\csname\v!overbar\endcsname
323 \enforced\permanent\protected\def\overbar{\mathortext\normalmathoverbar\normaltextoverbar}
324\else
325 \enforced\permanent\expandafter\let\expandafter\overbar\csname\v!overbar\endcsname
326\fi
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342\enforced\permanent\expandafter\let\expandafter\overstrikes\csname\v!overstrikes\endcsname
343\enforced\permanent\expandafter\let\expandafter\underbars \csname\v!underbars \endcsname
344\enforced\permanent\expandafter\let\expandafter\overbars \csname\v!overbars \endcsname
345
346\enforced\permanent\protected\def\setupunderbar[#1]
347 {}
348
349\popoverloadmode
350
351
352
353
354
355
356
357
358
359
360
361\startuseMPgraphic{rules:under:random}
362 draw
363 ((0,RuleDepth) ... (RuleWidth,RuleDepth)) randomized (4RuleThickness)
364 shifted (0,RuleFactorRuleOffset)
365 withpen pencircle scaled RuleThickness
366 withcolor RuleColor ;
367 setbounds currentpicture to unitsquare xysized(RuleWidth,RuleHeight) ;
368\stopuseMPgraphic
369
370\startuseMPgraphic{rules:under:dash}
371 draw
372 ((0,RuleDepth) -- (RuleWidth,RuleDepth))
373 shifted (0,RuleFactorRuleOffset)
374 dashed dashpattern(on RuleFactor2 off RuleFactor2)
375 withpen pencircle scaled RuleThickness
376 withcolor RuleColor ;
377 setbounds currentpicture to unitsquare xysized(RuleWidth,RuleHeight) ;
378\stopuseMPgraphic
379
380\startuseMPgraphic{rules:under:dots}
381 path p ; p := (0,RuleDepth) -- (RuleWidth,RuleDepth) ;
382 numeric l ; l := arclength(p);
383 l := l mod RuleThickness4;
384 draw
385 p
386 shifted (l,RuleFactorRuleOffset)
387 dashed dashpattern(off 2RuleThicknessl on 0 off 2RuleThickness)
388 withpen pencircle scaled 2RuleThickness
389 withcolor RuleColor ;
390 setbounds currentpicture to unitsquare xysized(RuleWidth,RuleHeight) ;
391\stopuseMPgraphic
392
393\definebar
394 [undergraphic]
395 [\c!mp=rules:under:dash,
396 \c!level=\v!auto,
397 \c!offset=.2,
398 \c!dy=.4,
399 \c!continue=\v!yes,
400 \c!order=\v!background]
401
402\definebar[underrandom] [undergraphic][\c!mp=rules:under:random,]
403\definebar[underrandoms][underrandom] [\c!continue=\v!no]
404
405\definebar[underdash] [undergraphic][\c!mp=rules:under:dash]
406\definebar[underdashes] [underdash] [\c!continue=\v!no]
407
408\definebar[underdot] [undergraphic][\c!mp=rules:under:dots]
409\definebar[underdots] [underdot] [\c!continue=\v!no]
410
411
412
413\installcorenamespace{shift}
414
415\installcommandhandler \??shift {shift} \??shift
416
417\let\setupshifts\setupshift
418
419\appendtoks
420 \frozen\protected\instance\edefcsname\currentshift\endcsname{\node_shifts_direct{\currentshift}}
421\to \everydefineshift
422
423\protected\def\node_shifts_set#1
424 {\cdef\currentshift{#1}
425 \useshiftstyleandcolor\c!style\c!color
426 \dosetupisolatedalign{\shiftparameter\c!align}
427 \clf_setshift
428 continue {\shiftparameter\c!continue}
429 unit {\shiftparameter\c!unit}
430 method \shiftparameter\c!method
431 dy \shiftparameter\c!dy
432 \relax}
433
434\permanent\protected\def\startshift[#1]
435 {\begingroup
436 \node_shifts_set{#1}
437 \ignorespaces}
438
439\permanent\protected\def\stopshift
440 {\removeunwantedspaces
441 \endgroup}
442
443\protected\def\node_shifts_direct#1
444 {\groupedcommand
445 {\begingroup\dostartisolation\begingroup\node_shifts_set{#1}\ignorespaces}
446 {\removeunwantedspaces\endgroup\dostopisolation\endgroup}}
447
448\setupshifts
449 [\c!method=0,
450 \c!continue=\v!no,
451 \c!dy=0,
452 \c!unit=ex,
453 \c!align=,
454 \c!style=,
455 \c!color=]
456
457\defineshift [\v!shiftup] [\c!method=0,\c!dy=1,\c!unit=ex,\c!continue=\v!yes,\c!style=\txx,\c!color=]
458\defineshift [\v!shiftdown] [\c!method=1,\c!dy=.3,\c!unit=ex,\c!continue=\v!yes,\c!style=\txx,\c!color=]
459
460
461
462\expandafter\let\expandafter\shiftup \csname\v!shiftup \endcsname
463\expandafter\let\expandafter\shiftdown\csname\v!shiftdown\endcsname
464
465
466
467\permanent\protected\def\dostartisolation{\signalcharacter}
468\permanent\protected\def\dostopisolation {\signalcharacter}
469\permanent\protected\def\doisolator {\signalcharacter}
470
471\permanent\protected\def\dosetupisolatedalign#1
472 {\doisolator
473 \setupalign[#1]\relax}
474
475\permanent\protected\def\doisolatedgroupedalign#1#2
476 {\groupedcommand
477 {\begingroup\dostartisolation\begingroup#1}
478 {#2\endgroup\dostopisolation\endgroup}}
479
480
481
482
483
484
485
486\installcorenamespace{linefiller}
487
488\installcommandhandler \??linefiller {linefiller} \??linefiller
489
490\definesystemattribute[linefiller][public]
491
492\aliased\let\setuplinefillers\setuplinefiller
493
494\protected\def\node_linefiller_set#1
495 {\cdef\currentlinefiller{#1}
496 \edef\p_node_color{\linefillerparameter\c!color}
497 \clf_setlinefiller
498
499 location {\linefillerparameter\c!location}
500 scope {\linefillerparameter\c!scope}
501 mp {\includeMPgraphic{\linefillerparameter\c!mp}}
502 ma \c_attr_colormodel
503 ca \rawcolorattribute\p_node_color
504 ta \rawtransparencyattribute\p_node_color
505 height \dimexpr\linefillerparameter\c!height\relax
506 depth \dimexpr\linefillerparameter\c!depth\relax
507 distance \dimexpr\linefillerparameter\c!distance\relax
508 threshold \dimexpr\linefillerparameter\c!threshold\relax
509 rulethickness \dimexpr\linefillerparameter\c!rulethickness\relax
510 \relax}
511
512\permanent\tolerant\protected\def\startlinefiller[#1]#*[#S#2]
513 {\begingroup
514 \par
515 \cdef\currentlinefiller{#1}
516 \ifparameter#2\or
517
518 \setuplinefiller[#1][#2]
519 \fi
520 \node_linefiller_set{#1}
521 \linefillerparameter\c!before
522 \usealignparameter\linefillerparameter
523 \uselinefillerstyleandcolor\c!textstyle\c!textcolor}
524
525\permanent\protected\def\stoplinefiller
526 {\par
527 \linefillerparameter\c!after
528 \endgroup}
529
530\permanent\protected\def\setlinefiller[#1]
531 {\node_linefiller_set{#1}}
532
533\setuplinefillers
534 [
535
536 \c!location=\v!both,
537 \c!scope=\v!local,
538 \c!distance=\zeropoint,
539 \c!threshold=\zeropoint,
540 \c!rulethickness=\linewidth,
541 \c!height=\linewidth,
542 \c!depth=\zeropoint,
543
544
545
546
547
548 \c!color=]
549
550\definelinefiller
551 [filler]
552 [\c!height=.75\exheight,
553
554
555 \c!distance=.25\emwidth,
556 \c!rulethickness=.25\exheight]
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573\protected\def\node_backgrounds_filler_box#1#2[#3]
574 {\bgroup
575 \clf_enablebackgroundboxes
576 \dowithnextbox{
577 \node_linefiller_set{#3}
578 #1
579 attr \backgroundattribute \plusone
580 {\box\nextbox}
581 \egroup}
582 #2}
583
584\permanent\protected\def\linefillerhbox{\node_backgrounds_filler_box\hpack\hbox}
585\permanent\protected\def\linefillervbox{\node_backgrounds_filler_box\vpack\vbox}
586\permanent\protected\def\linefillervtop{\node_backgrounds_filler_box\tpack\vtop}
587
588
589
590
591
592\protect \endinput
593 |