s-inf-01.mkvi /size: 9584 b    last modification: 2020-07-01 14:35
1
%D \module
2
%D [ file=s-inf-01,
3
%D version=2009.07.09,
4
%D title=\CONTEXT\ Style File,
5
%D subtitle=Information 1 (\MKII/\MKIV\ usage),
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
%D Some day I will generalize this table mechanism. This list is only
15
%D right when run in the minimals as my machine might have more files.
16
%D
17
%D Als, the remaining tex code can proably be lua also which is more
18
%D consistent.
19
%D
20
%D \starttyping
21
%D context auto:s-inf-01
22
%D context auto:s-inf-01 --basepath=t:/texmf/tex/context/base
23
%D \stoptyping
24 25
% \enabletrackers[context.*]
26 27
\startluacode
28
local
format
,
gsub
,
find
,
match
=
string
.
format
,
string
.
gsub
,
string
.
find
,
string
.
match
29
local
setmetatableindex
=
table
.
setmetatableindex
30 31
local
list
=
{
}
32
local
size
=
{
}
33
local
comp
=
{
}
34
local
used
=
setmetatableindex
(
"
table
"
)
35
local
nope
=
setmetatableindex
(
"
number
"
)
36 37
local
omit
=
{
38
"
char%-def%.lua
"
,
39
"
mult%-def%.lua
"
,
"
mult%-..%.mkii
"
,
"
mult%-m..%.mkii
"
,
40
}
41
local
skip
=
{
42
"
prag%-.*%.tex
"
,
"
docs%-.*.tex
"
,
"
list%-.*%.tex
"
,
"
test%-.*%.tex
"
,
"
demo%-.*%.tex
"
,
43
"
opti%-.*%.tex
"
,
"
chrt%-.*%.tex
"
,
"
.*%-old
"
,
"
.*%-obs
"
,
"
.*%-tst
"
,
"
supp%-.*%.tex
"
,
44
"
colo%-pan.tex
"
,
"
.*test.*
"
45
}
46
local
types
=
{
47
"
tex
"
,
"
mkii
"
,
"
mkiv
"
,
"
mkvi
"
,
"
mkxl
"
,
"
mklx
"
,
"
lua
"
,
-- "mpiv"
48
}
49
local
patterns
=
{
50
"
^([a-z][a-z][a-z][a-z])%-[a-z0-9%-]+%.[a-z]+
"
,
51
"
^([xms])%-[a-z0-9%-]+%.[a-z]+
"
,
52
}
53 54
local
function
collect
(
list
,
suffix
,
n
)
55
local
path
=
document
.
arguments
.
basepath
or
file
.
dirname
(
resolvers
.
find_file
(
"
context.mkiv
"
)
,
"
.
"
)
56
local
pattern
=
path
.
.
"
/*.
"
.
.
suffix
.
.
"
$
"
-- avoid bla.tex~
57
local
texfiles
=
dir
.
glob
(
pattern
)
58
for
i
=
1
,
#
texfiles
do
59
local
name
=
texfiles
[
i
]
60
local
base
=
file
.
basename
(
name
)
61
for
p
=
1
,
#
patterns
do
62
local
category
=
match
(
base
,
patterns
[
p
]
)
63
if
category
and
lfs
.
isfile
(
name
)
then
64
local
okay
=
true
65
for
s
=
1
,
#
skip
do
66
if
find
(
base
,
skip
[
s
]
)
then
67
okay
=
false
68
break
69
end
70
end
71
if
okay
then
72
local
lm
=
list
[
category
]
73
local
sm
=
size
[
category
]
74
local
cm
=
comp
[
category
]
75
if
not
lm
then
76
lm
=
setmetatableindex
(
"
number
"
)
77
sm
=
setmetatableindex
(
"
number
"
)
78
cm
=
setmetatableindex
(
"
number
"
)
79
list
[
category
]
=
lm
80
size
[
category
]
=
sm
81
comp
[
category
]
=
cm
82
end
83
lm
[
n
]
=
lm
[
n
]
+
1
84
local
done
=
true
85
for
o
=
1
,
#
omit
do
86
if
find
(
base
,
omit
[
o
]
)
then
87
done
=
false
88
break
89
end
90
end
91
local
data
=
io
.
loaddata
(
name
)
92
if
data
then
93
if
suffix
=
=
"
lua
"
then
94
data
=
gsub
(
data
,
"
%-%-%[%[.-%]%]%-%-
"
,
"
"
)
95
data
=
gsub
(
data
,
"
%-%-.-[\n\r]
"
,
"
"
)
96
else
97
data
=
gsub
(
data
,
"
%%.-[\n\r]
"
,
"
"
)
98
end
99
data
=
gsub
(
data
,
"
%s
"
,
"
"
)
100
else
101
logs
.
report
(
"
error
"
,
"
unknown file %a
"
,
name
)
102
data
=
"
"
103
end
104
sm
[
n
+
#
types
]
=
sm
[
n
+
#
types
]
+
#
data
105
if
done
then
106
sm
[
n
]
=
sm
[
n
]
+
#
data
107
else
108
cm
[
n
]
=
cm
[
n
]
+
1
109
end
110
end
111
end
112
end
113
end
114
end
115 116
local
function
prepare
(
what
)
117
if
next
(
list
)
then
118
-- already loaded
119
else
120
for
i
=
1
,
#
types
do
121
collect
(
list
,
types
[
i
]
,
i
)
122
end
123
for
category
in
next
,
list
do
124
pattern
=
"
{
"
.
.
category
.
.
"
%-
"
125
for
suffix
,
t
in
next
,
used
do
126
local
data
=
io
.
loaddata
(
resolvers
.
find_file
(
"
context.
"
.
.
suffix
)
)
127
if
data
and
find
(
data
,
pattern
)
then
128
t
[
category
]
=
true
129
end
130
end
131
end
132
end
133
local
max
,
what
=
0
,
(
what
=
=
"
size
"
and
size
)
or
list
134
for
k
,
v
in
table
.
sortedpairs
(
what
)
do
135
for
i
=
1
,
7
do
if
v
[
i
]
>
max
then
max
=
v
[
i
]
end
end
136
end
137
return
max
,
what
,
function
(
n
)
return
(
max
=
=
0
and
0
)
or
(
n
=
=
0
and
0
)
or
n
/
max
end
138
end
139 140
local
f_norm
=
string
.
formatters
[
"
%0.3f
"
]
141 142
function
document
.
context_state_1
(
what
)
143
local
max
,
what
,
norm
=
prepare
(
what
)
144
context
.
starttabulate
{
"
|Tl|T|T|T|T|T|T|T|
"
}
145
context
.
NC
(
)
146
context
(
category
)
147
context
.
NC
(
)
148
for
i
=
1
,
#
types
do
149
local
n
,
m
=
0
,
0
150
for
k
,
v
in
next
,
list
do
151
local
nn
=
what
[
k
]
[
i
]
152
local
mm
=
what
[
k
]
[
i
+
#
types
]
153
n
=
n
+
nn
154
m
=
m
+
(
mm
or
nn
)
155
end
156
context
.
Top
(
types
[
i
]
,
norm
(
max
)
,
n
,
m
)
157
context
.
NC
(
)
158
end
159
context
.
NC
(
)
160
context
.
NR
(
)
161
context
.
HL
(
)
162
for
k
,
v
in
table
.
sortedpairs
(
what
)
do
163
local
c
=
what
=
=
size
and
comp
[
k
]
or
nope
164
context
.
NC
(
)
165
context
(
"
\\bf %s~%s~~%s~~%s~~%s~~%s
"
,
166
(
used
.
mkii
[
k
]
and
"
ii
"
)
or
"
~~
"
,
167
(
used
.
mkiv
[
k
]
and
"
iv
"
)
or
"
~~
"
,
168
(
used
.
mkvi
[
k
]
and
"
vi
"
)
or
"
~~
"
,
169
(
used
.
mkiv
[
k
]
and
"
xl
"
)
or
"
~~
"
,
170
(
used
.
mkvi
[
k
]
and
"
lx
"
)
or
"
~~
"
,
171
k
172
)
173
context
.
NC
(
)
174
for
i
=
1
,
#
types
do
175
context
.
Bar
(
types
[
i
]
,
v
[
i
]
,
c
[
i
]
,
f_norm
(
norm
(
v
[
i
]
)
)
)
176
context
.
NC
(
)
177
end
178
context
.
NR
(
)
179
end
180
context
.
stoptabulate
(
)
181
end
182 183
function
document
.
context_state_2
(
what
)
184
local
max
,
what
,
norm
=
prepare
(
what
)
185
for
k
,
v
in
table
.
sortedpairs
(
what
)
do
186
local
c
=
(
what
=
=
size
and
comp
[
k
]
)
or
nope
187
context
.
StartUp
(
k
)
188
for
i
=
1
,
#
types
do
189
context
.
Up
(
types
[
i
]
,
f_norm
(
norm
(
v
[
i
]
)
)
)
190
end
191
context
.
StopUp
(
)
192
end
193
end
194 195
\stopluacode
196 197
\definecolor
[
bar
:
tex
]
[
middlegreen
]
198
\definecolor
[
bar
:
mkii
][
middleblue
]
199
\definecolor
[
bar
:
mkiv
][
middlered
]
200
\definecolor
[
bar
:
mkvi
][
middleyellow
]
201
\definecolor
[
bar
:
mkxl
][
middlemagenta
]
202
\definecolor
[
bar
:
mklx
][
middlecyan
]
203
\definecolor
[
bar
:
lua
]
[
middlegray
]
204 205
\newcount
\UpCounter
206 207
\starttexdefinition
Top
#
what
#
fraction
#
total
#
bigones
208
\hbox
to
7
em
{
\hss
#
total
}
%
209
\enspace
210
\hbox
{{
\bf
#
what
}
\ifnum
#
total
=#
bigones
\else
~
#
bigones
\rlap
{
~+
}
\fi\hss
}
%
211
\stoptexdefinition
212 213
\starttexdefinition
Bar
#
color
#
size
#
nobigones
#
fraction
214
\ifcase
#
size
\else
215
\hbox
to
7
em
{
\hss\ifcase
#
nobigones
\else
\llap
{
-~
}
\fi
#
size
}
%
216
\enspace
217
\blackrule
[
color
=
bar
:
#
color
,
width
=#
fraction
\dimexpr
2
0
em
\relax
,
height
=
.
8
\strutht
]
%
218
\fi
219
\stoptexdefinition
220 221
\starttexdefinition
StartUp
#
name
222
\def
\UpName
{
#
name
}
%
223
\dontleavehmode
\framed
[
frame
=
off
,
align
=
{
middle
,
low
}
,
height
=
1
8
em
]
\bgroup
224
\stoptexdefinition
225 226
\starttexdefinition
StopUp
227
\par
\nointerlineskip
\blackrule
[
height
=
1
pt
,
width
=
7
em
,
depth
=
0
pt
,
color
=
darkgray
]
228
\par
\tttf
\strut
\UpName
\par
229
\egroup
230
\ifnum
\UpCounter
=
1
7
231
\par
\UpCounter
\zerocount
232
\else
233
\kern
1
em
\advance
\UpCounter
\plusone
234
\fi
235
\stoptexdefinition
236 237
\starttexdefinition
Up
#
color
#
width
238
% \scratchdimen#width\dimexpr 16em\relax
239
\scratchdimen
#
width
\dimexpr
4
0
em
\relax
240
\ifdim
\scratchdimen
=
\zeropoint
241
\kern
1
em
242
\else\ifdim
\scratchdimen
>
1
3
em
243
\blackrule
[
color
=
bar
:
#
color
,
height
=
1
5
em
,
width
=
1
em
]
%
244
\hskip
-
1
.
1
em
245
\blackrule
[
color
=
white
,
height
=
1
4
em
,
width
=
1
.
2
em
]
%
246
\hskip
-
1
.
1
em
247
\blackrule
[
color
=
bar
:
#
color
,
height
=
1
3
em
,
width
=
1
em
]
%
248
\else
249
\ifdim
\scratchdimen
<
\onepoint
\scratchdimen
\onepoint
\fi
250
\blackrule
[
color
=
bar
:
#
color
,
height
=
\scratchdimen
,
width
=
1
em
]
%
251
\fi\fi
252
\stoptexdefinition
253 254
\starttexdefinition
Show
#
title
#
how
#
what
255
\startTEXpage
[
offset
=
1
em
,
width
=
fit
]
256
\hbox
{
\tttf
\strut
\currentdate
~-~
#
title
}
257
\blank
[
line
]
258
\ctxlua{
document
.
context_state_
\number
#
how
(
"
#what
"
)
}
259
\stopTEXpage
260
\stoptexdefinition
261 262
% \continueifinputfile{s-inf-01.mkvi}
263 264
\starttext
265
\Show
266
{
The
number
of
files
used
in
ConTeXt
(
base
modules
and
styles
)
.
}
267
{
1
}{
number
}
268
\Show
269
{
The
size
of
(
core
)
files
used
in
ConTeXt
(
-
:
large
data
files
excluded
;
+
:
large
data
files
included
;
comment
and
spaces
removed
)
}
270
{
1
}{
size
}
271
\Show
272
{
The
relative
number
of
files
used
in
ConTeXt
(
tex
,
mkii
,
mkiv
,
mkvi
,
mkxl
,
mklx
,
lua
)
.
}
273
{
2
}{
number
}
274
\Show
275
{
The
relative
size
of
files
used
in
ConTeXt
(
tex
,
mkii
,
mkiv
,
mkvi
,
mkxl
,
mklx
,
lua
)
.
}
276
{
2
}{
size
}
277
\stoptext
278