node-rul.mkiv /size: 19 Kb    last modification: 2020-07-01 14:35
1
%D \module
2
%D [ file=node-rul,
3
%D version=2009.11.03, % 1995.10.10,
4
%D title=\CONTEXT\ Core Macros,
5
%D subtitle=Bars,
6
%D author=Hans Hagen,
7
%D date=\currentdate,
8
%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}]
9
%C
10
%C This module is part of the \CONTEXT\ macro||package and is
11
%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
12
%C details.
13 14
% todo: ex and and em traveling with attribute
15
% todo: this will move to typo-rul + ctxcommands
16 17
\writestatus
{
loading
}{
ConTeXt
Core
Macros
/
Bars
}
18 19
%D \macros
20
%D {underbar,underbars,
21
%D overbar,overbars,
22
%D overstrike,overstrikes,
23
%D setupbar}
24
%D
25
%D In the rare case that we need undelined words, for instance because all font
26
%D alternatives are already in use, one can use \type {\underbar} and \type
27
%D {\overstrike} and their plural forms.
28
%D
29
%D \startbuffer
30
%D \underbars {drawing \underbar{bars} under words is a typewriter leftover}
31
%D \overstrikes {striking words makes them \overstrike {unreadable} but
32
%D sometimes even \overbar {top lines} come into view.}
33
%D \stopbuffer
34
%D
35
%D \typebuffer
36
%D
37
%D \startlines
38
%D \getbuffer
39
%D \stoplines
40
%D
41
%D The formal definitions are:
42
%D
43
%D \showsetup{underbar}
44
%D \showsetup{underbars}
45
%D \showsetup{overbar}
46
%D \showsetup{overbars}
47
%D \showsetup{overstrike}
48
%D \showsetup{overstrikes}
49
%D
50
%D \showsetup{setupbars}
51
%D
52
%D Units can be any normal \TEX\ unit:
53
%D
54
%D \startbuffer
55
%D \setupbars[unit=mm,rulethickness=1] bar\startbar[underbar]foo\stopbar bar\blank
56
%D \setupbars[unit=ex,rulethickness=1] bar\startbar[underbar]foo\stopbar bar\blank
57
%D \setupbars[unit=pt,rulethickness=1] bar\startbar[underbar]foo\stopbar bar\blank
58
%D \setupbars[unit=pt,rulethickness=10pt] bar\startbar[underbar]foo\stopbar bar
59
%D \stopbuffer
60
%D
61
%D \typebuffer \blank \getbuffer \blank
62
%D
63
%D As with many early usage of \LUA\ in \MKIV\ this mechanism explores a way
64
%D to deal with local settings at the \TEX\ end and remembering parameters
65
%D at the \LUA\ end. We might do things differently now, but as settings normally
66
%D don't change that often, we're not in a hurry to do that now. The problem at
67
%D the \LUA\ end is that we don't know when to clean up.
68 69
\unprotect
70 71
%definesystemattribute[ruled]
72
%definesystemattribute[shifted]
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
% temporary synonym
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
% \normalexpanded{\t_node_rules_checklist{\node_rules_redefine{\currentbar}\the\t_node_rules_checklist}}%
105
\normalexpanded
{
\t_node_rules_checklist
{
\the
\t_node_rules_checklist
\relax
\node_rules_redefine
{
\currentbar
}}}
%
106
% \etoksapp\t_node_rules_checklist{\node_rules_redefine{\currentbar}}%
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
% number
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
% number
132
dy
\barparameter
\c!dy
\space
% number
133
empty
{
\barparameter
\c!empty
}
%
134
\ifx
\p_node_text
\empty
\else
135
% not that useful and efficient, more for testing something
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
% \unexpanded\def\inlinecurrentbar
153
% {\node_rules_direct{\currentbar}}
154 155
% store in properties
156 157
\unexpanded
\def
\node_rules_set
#
1
% maybe reverse the 1000 (also maybe use more attributes instead of settings)
158
{
\edef
\currentbar
{
#
1
}
%
159
\usebarstyleandcolor
\c!foregroundstyle\c!foregroundcolor
160
% maybe: \usebarstyleandcolor\c!textgroundstyle\c!textcolor
161
% todo: move this to lua .. we callout anyway
162
\expandafter\let\expandafter
\c_node_rules_index
\csname
\??barindex
#
1
\endcsname
163
\advance
\c_node_rules_index
\plusone
164
\clf_enablerules
% will be relaxed
165
\c_attr_ruled
\numexpr
166
\plusthousand
*
\c_node_rules_index
167
% optimizing this one needs testing
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
% ungrouped
196 197
\newcount
\c_node_rules_nesting
% todo: same as colors
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
,
% new: 0=center nested, 1=stack nested
210
\c!continue
=
\v!no
,
211
\c!empty
=
,
% new: yes = hide text
212
\c!offset
=
0
,
% upwards, replaces: topoffset bottomoffset
213
\c!dy
=
0
,
214
\c!max
=
3
,
215
\c!style
=
,
216
\c!rulethickness
=
.
1
,
217
\c!order
=
\v!foreground
,
218
\c!unit
=
ex
,
% so now we are relative
219
\c!color
=]
% replaces: rulecolor
220 221
% \definebar[touchbar] [\c!method=0,\c!dy=-0.4,\c!offset=-0.0]
222
% \definebar[touchbars] [touchbar] [\c!continue=\v!yes]
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
% \setupbar[\v!overstrike][continue=all]
256 257
% we want these always so ...
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
]
% too incompatible for the moment
292
{}
293 294
%D An experimental new feature:
295
%D
296
%D \startbuffer
297
%D test {\red\underrandoms{test me}} and \underrandom{test} or \underrandom{grep} \blank
298
%D test {\red\underdashes {test me}} and \underdash {test} or \underdash {grep} \blank
299
%D test {\red\underdots {test me}} and \underdot {test} or \underdot {grep} \blank
300
%D \stopbuffer
301
%D
302
%D \typebuffer \getbuffer
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
%D This will move: (a bit duplicated)
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
% temporary synonym
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
}}}
% order ?
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
% number
391
\relax
}}
392 393
\unexpanded
\def
\node_shifts_redefine
#
1
%
394
{
\def
\currentshift
{
#
1
}
\node_shifts_define
}
395 396
% \unexpanded\def\node_shifts_set
397
% {\clf_enableshifts
398
% \glet\node_shifts_set\node_shifts_set_indeed
399
% \node_shifts_set}
400
%
401
% \def\node_shifts_set_indeed#1% todo: check parent !
402 403
\unexpanded
\def
\node_shifts_set
#
1
% todo: check parent ! todo: move attr etc to lua
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
% will be relaxed
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
}}
% weird feature that i probably needed once
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
% \unexpanded\def\node_shifts_direct#1%
425
% {\doisolatedgroupedalign{\node_shifts_set{#1}}\donothing}
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
% we want these always so ...
445 446
\expandafter\let\expandafter
\shiftup
\csname
\v!shiftup
\endcsname
447
\expandafter\let\expandafter
\shiftdown
\csname
\v!shiftdown
\endcsname
448 449
% This is a weird helper:
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
%D More rules.
465 466
% The following code rocks and was written with the Toto Live in Poland bluray
467
% in loop mode on my 5.1 surround development setup (the Toto lineup with Simon
468
% Phillips on drums). The Amsterdam concert is equally energizing.
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
% temporary synonym
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
%method \linefillerparameter\c!method
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
% todo: check parent ! todo: move attr etc to lua
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
% we need to update settings
542
\setuplinefiller
[#
1
][#
2
]
% no \setupcurrentlinefiller as we need to update settings
543
\fi
544
\node_linefiller_set
{
#
1
}
%
545
\linefillerparameter
\c!before
546
\usealignparameter
\linefillerparameter
547
\uselinefillerstyleandcolor
\c!textstyle\c!textcolor
}
% bars have foregroundcolor
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
[
%c!method=0,
559
%c!mp=,
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
%\c!textcolor=,
568
%\c!textstyle=,
569
%\c!align=,
570
%\c!before=,
571
%\c!after=,
572
\c!color
=]
573 574
\definelinefiller
575
[
filler
]
576
[
\c!height
=
.
7
5
\exheight
,
577
%\c!mp=rules:filler:demo,
578
%\c!threshold=.25\emwidth,
579
\c!distance
=
.
2
5
\emwidth
,
580
\c!rulethickness
=
.
2
5
\exheight
]
581 582
%D Bonus:
583
%D
584
%D \starttyping
585
%D \startuseMPgraphic{foo}
586
%D fill unitsquare
587
%D xyscaled (RuleWidth,RuleHeight+RuleDepth) enlarged (ExHeight/4,ExHeight/8)
588
%D shifted (-ExHeight/8,ExHeight/16)
589
%D withcolor RuleColor ;
590
%D \stopuseMPgraphic
591
%D
592
%D \definelinefiller[foo][mp=foo,color=darkred]
593
%D
594
%D \linefillerhbox[foo]{OEPS}
595
%D \stoptyping
596 597
\unexpanded
\def
\node_backgrounds_filler_box
#
1
#
2
[#
3
]
%
598
{
\bgroup
599
\clf_enablebackgroundboxes
600
\dowithnextbox
{
%
601
\node_linefiller_set
{
#
3
}
% already sets the attribute
602
#
1
%
603
attr
\backgroundattribute
\plusone
604
% attr \linefillerattribute \the\c_attr_linefiller
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
%D Bonus:
614 615
\unexpanded
\def
\autorule
{
\clf_autorule
}
616 617
\protect
\endinput
618