s-inf-03.mkiv /size: 10 Kb    last modification: 2020-07-01 14:35
1
% \nopdfcompression
2 3
% \starttext
4
% There is a loop somewhere ... todo.
5
% \stoptext
6 7
\enablemode
[
tablet
]
% whatever that means
8 9
\setupbodyfont
[
dejavu
]
10 11
\doifelsemode
{
tablet
}
{
12 13
\setuppapersize
14
[
S
6
,
landscape
]
15
[
S
6
,
landscape
]
16 17
\definefont
18
[
TitlePageFont
]
19
[
MonoBold
at
1
4
pt
]
20 21
\setupbodyfont
22
[
tt
,
8
pt
]
23 24
}
{
25 26
\definefont
27
[
TitlePageFont
]
28
[
MonoBold
at
1
7
pt
]
29 30
\setupbodyfont
31
[
tt
]
32 33
}
34 35
\setuplayout
36
[
header
=
0
cm
,
37
footer
=
1
cm
,
38
backspace
=
.
5
cm
,
39
topspace
=
.
5
cm
,
40
width
=
middle
,
41
height
=
middle
]
42 43
\setuphead
44
[
title
]
45
[
style
=
\ttc
,
46
interaction
=
reference
]
47 48
\definehead
49
[
xtitle
]
50
[
title
]
51 52
\setuphead
53
[
xtitle
]
54
[
color
=
darkgreen
]
55 56
\setupfootertexts
57
[
\llap
{
\goto
{
\hbox
to
5
cm
{
\hss
previous
}}
[
previouspage
]
}
%
58
\quad
\pagenumber\quad
59
\rlap
{
\goto
{
\hbox
to
5
cm
{
next
\hss
}}
[
nextpage
]
}
]
60 61
\ifcase
\contextlmtxmode
62
\setupinteraction
63
[
title
=
{
ConTeXt
MkIV
}
]
64
\else
65
\setupinteraction
66
[
title
=
{
ConTeXt
LMTX
}
]
67
\fi
68 69
\setupinteraction
70
[
state
=
start
,
71
style
=
,
72
color
=
,
73
subtitle
=
{
Lua
modules
and
functions
}
,
74
author
=
{
Hans
Hagen
-
automatically
generated
}
,
75
contrastcolor
=]
76 77
\setupinteractionscreen
78
[
option
=
bookmark
]
79 80
\placebookmarks
81
[
title
,
xtitle
]
82
[
force
=
yes
]
83 84
\definecolor
[
darkyellow
][
r
=
.
5
,
g
=
.
5
,
b
=
0
]
85
\definecolor
[
darkgray
]
[
s
=
.
1
5
]
86 87
\nonknuthmode
88 89
\starttext
90 91
\startbuffer
92
\startluacode
93
local
basiclua
=
libraries
.
basiclua
94
local
basictex
=
libraries
.
basictex
95
local
extratex
=
libraries
.
extratex
96
local
extralua
=
libraries
.
extralua
97
local
obsolete
=
libraries
.
obsolete
98 99
local
find
=
string
.
find
100
local
color
,
gotolocation
=
context
.
color
,
context
[
"
goto
"
]
101 102
for
k
,
v
in
table
.
sortedpairs
(
_G
)
do
103
if
obsolete
[
k
]
or
find
(
k
,
"
_
"
)
or
k
=
=
"
arg
"
or
k
=
=
"
utf
"
then
104
--
105
elseif
basiclua
[
k
]
then
106
gotolocation
(
function
(
)
color
(
{
"
darkred
"
}
,
k
)
end
,
{
k
}
)
107
elseif
extralua
[
k
]
then
108
gotolocation
(
function
(
)
color
(
{
"
darkgreen
"
}
,
k
)
end
,
{
k
}
)
109
elseif
basictex
[
k
]
then
110
gotolocation
(
function
(
)
color
(
{
"
darkblue
"
}
,
k
)
end
,
{
k
}
)
111
elseif
extratex
[
k
]
then
112
gotolocation
(
function
(
)
color
(
{
"
darkyellow
"
}
,
k
)
end
,
{
k
}
)
113
elseif
type
(
v
)
=
=
"
table
"
then
114
gotolocation
(
function
(
)
color
(
{
"
white
"
}
,
k
)
end
,
{
k
}
)
115
end
116
context
(
"
"
)
117
end
118
\stopluacode
119
\stopbuffer
120 121
\setupbackgrounds
122
[
page
]
123
[
background
=
color
,
124
backgroundcolor
=
darkgray
,
125
backgroundoffset
=
2
mm
]
126 127
\startpagemakeup
128
\vfill
129
\pagereference
[
global
]
130
\startnarrower
[
1
0
mm
]
131
\setupalign
[
nothyhenated
,
middle
,
broad
]
132
\TitlePageFont
\setupinterlinespace
133
\getbuffer
% luabuffer
134
\par
135
\stopnarrower
136
\vfill
137
\vfill
138
\hskip
1
0
mm
\scale
[
width
=
\dimexpr
\paperwidth
-
2
0
mm
\relax
]
{
\ttbf
\white
\ConTeXt
\ \ifcase
\contextlmtxmode
MkIV
\else
LMTX
\fi
}
139
\par
140
% \hskip10mm\scale[width=\dimexpr\paperwidth-20mm\relax]{\white \strut Lua infrastructure \emdash\ \currentdate}
141
\vfill
142
\stoppagemakeup
143 144
\setupbackgrounds
145
[
page
]
146
[
background
=]
147 148
\startluacode
149
local
builtin
=
libraries
.
builtin
150
local
globals
=
libraries
.
globals
151
local
basiclua
=
libraries
.
basiclua
152
local
basictex
=
libraries
.
basictex
153
local
extratex
=
libraries
.
extratex
154
local
extralua
=
libraries
.
extralua
155
local
obsolete
=
libraries
.
obsolete
156 157
local
sortedkeys
=
table
.
sortedkeys
158
local
mark
=
storage
.
mark
159
local
marked
=
storage
.
marked
160
local
gsub
=
string
.
gsub
161
local
sub
=
string
.
sub
162
local
byte
=
string
.
byte
163
local
upper
=
string
.
upper
164 165
local
skipglobal
=
table
.
tohash
{
166
"
_G
"
,
"
_M
"
,
"
_ENV
"
,
"
"
,
167
"
context
"
,
"
modules
"
,
"
global
"
,
"
arg
"
,
"
utf
"
,
1
,
168
"
kpse
"
,
"
commands
"
,
"
ffi
"
,
169
}
170 171
local
skipkeys
=
table
.
tohash
{
172
-- "_cldf_", "_cldn_", "_cldo_",
173
"
_clmb_
"
,
"
_clme_
"
,
"
_clmm_
"
,
"
_clmn_
"
,
"
_clma_
"
,
"
_clmh_
"
,
174
"
_G
"
,
"
_M
"
,
"
_ENV
"
,
"
"
,
175
-- "global", "shortcuts",
176
"
_VERSION
"
,
"
_COPYRIGHT
"
,
"
_DESCRIPTION
"
,
"
_NAME
"
,
"
_PACKAGE
"
,
"
__unload
"
,
177
}
178 179
local
sameglobal
=
{
180
[
"
global
"
]
=
"
_G
"
,
181
-- ["commands"] = "cs", -- already gone
182
}
183 184
-- -- -- -- -- -- -- -- -- -- -- -- --
185
-- this should be done internally
186
-- -- -- -- -- -- -- -- -- -- -- -- --
187 188
for
k
,
v
in
next
,
modules
do
189
mark
(
v
)
190
end
191 192
mark
(
document
.
arguments
)
193
mark
(
environment
.
arguments
)
194
mark
(
environment
.
engineflags
)
195
mark
(
characters
.
data
)
196 197
-- -- -- -- -- -- -- -- -- -- -- -- --
198
-- -- -- -- -- -- -- -- -- -- -- -- --
199 200
local
variant
=
1
-- all parents
201
local
variant
=
2
-- parent name too
202
local
variant
=
3
-- no parents
203 204
local
done
=
{
}
205 206
local
function
childtables
(
key
,
tab
,
handler
,
depth
)
207
depth
=
depth
or
1
208
local
keys
=
sortedkeys
(
tab
)
-- no sorted_pairs
209
for
i
=
1
,
#
keys
do
210
local
k
=
keys
[
i
]
211
-- if k ~= "_G" and k ~= "_M" and type(k) == "string" then
212
if
not
skipkeys
[
k
]
and
type
(
k
)
=
=
"
string
"
then
213
local
v
=
tab
[
k
]
214
local
t
=
type
(
v
)
215
local
s
=
k
216
if
variant
~
=
3
then
217
s
=
key
and
(
key
.
.
"
.
"
.
.
s
)
or
s
218
end
219
if
t
=
=
"
table
"
then
220
if
marked
(
v
)
then
221
t
=
"
data
"
222
handler
(
s
,
t
,
depth
)
223
elseif
done
[
v
]
then
224
-- logs.report("inf-03","key %a in %a already done",k,v)
225
else
226
done
[
v
]
=
true
227
handler
(
s
,
t
,
depth
)
228
if
variant
=
=
3
then
229
childtables
(
false
,
v
,
handler
,
depth
+
1
)
230
elseif
variant
=
=
2
then
231
childtables
(
k
,
v
,
handler
,
depth
+
1
)
232
else
233
childtables
(
s
,
v
,
handler
,
depth
+
1
)
234
end
235
end
236
else
237
handler
(
s
,
t
,
depth
)
238
end
239
end
240
end
241
end
242 243
local
NC
,
NR
=
context
.
NC
,
context
.
NR
244
local
overstrike
,
rlap
,
bf
=
context
.
overstrike
,
context
.
rlap
,
context
.
bf
245
local
color
,
gotolocation
=
context
.
color
,
context
[
"
goto
"
]
246 247
local
function
cleanup
(
s
)
248
return
"
\\char
"
.
.
byte
(
s
)
.
.
"
"
249
end
250 251
local
function
handler
(
k
,
t
,
depth
)
252
k
=
gsub
(
k
,
"
([~#$%%^&{}\\|])
"
,
cleanup
)
253
NC
(
)
rlap
(
"
\\quad\\tx\\kern
"
.
.
(
depth
or
0
)
.
.
"
em
"
.
.
upper
(
sub
(
t
,
1
,
1
)
)
.
.
"
"
.
.
k
)
NC
(
)
NC
(
)
NR
(
)
254
end
255 256
local
function
show
(
title
,
subtitle
,
alias
,
builtin
,
t
,
lib
,
libcolor
,
glo
,
glocolor
,
mark
,
obsolete
)
257
-- todo: table as argument
258
-- print(title,subtitle,alias,builtin,t,lib,libcolor,glo,glocolor,mark,obsolete)
259
local
keys
=
sortedkeys
(
t
)
-- no sorted_pairs
260
if
#
keys
>
0
then
261
local
fulltitle
=
title
262
if
subtitle
and
subtitle
~
=
"
"
then
263
fulltitle
=
fulltitle
.
.
"
(
"
.
.
subtitle
.
.
"
)
"
264
end
265
if
alias
and
alias
~
=
"
"
then
266
fulltitle
=
fulltitle
.
.
"
(alias:
"
.
.
alias
.
.
"
)
"
267
end
268
if
builtin
then
269
context
.
startxtitle
{
reference
=
title
,
title
=
fulltitle
,
backreference
=
"
global
"
}
270
else
271
context
.
starttitle
{
reference
=
title
,
title
=
fulltitle
,
backreference
=
"
global
"
}
272
end
273
context
.
startcolumns
{
n
=
2
}
274
context
.
starttabulate
{
"
|||
"
}
275
local
t_obsolete
=
rawget
(
t
,
"
obsolete
"
)
-- tricky a t.obsolete fails
276
if
type
(
t_obsolete
)
~
=
"
table
"
then
277
t_obsolete
=
nil
278
end
279
for
i
=
1
,
#
keys
do
280
local
k
=
keys
[
i
]
281
local
v
=
t
[
k
]
282
if
k
and
k
~
=
"
obsolete
"
and
not
skipkeys
[
k
]
and
(
not
obsolete
or
not
obsolete
[
k
]
)
then
283
local
inlib
=
lib
and
lib
[
k
]
284
local
inglo
=
glo
and
glo
[
k
]
285
local
t
=
type
(
v
)
286
local
kstr
,
tstr
=
k
,
t
287
local
obs
=
t_obsolete
and
t_obsolete
[
k
]
288
if
obs
then
289
tstr
=
function
(
)
overstrike
(
t
)
end
290
kstr
=
function
(
)
overstrike
(
k
)
end
291
end
292
local
marked
=
marked
(
v
)
293
if
marked
then
294
tstr
=
"
data table
"
295
end
296
if
t
=
=
"
table
"
then
297
local
m
=
getmetatable
(
v
)
298
if
m
and
m
.
__call
then
299
tstr
=
"
function
"
300
end
301
end
302
if
not
mark
then
303
--
304
elseif
inlib
and
tostring
(
inlib
)
~
=
tostring
(
v
)
then
305
tstr
=
"
overloaded
"
.
.
tstr
306
elseif
inglo
and
tostring
(
inglo
)
~
=
tostring
(
v
)
then
307
tstr
=
"
overloaded
"
.
.
tstr
308
end
309
NC
(
)
bf
(
)
310
if
inlib
then
311
if
not
mark
and
t
=
=
"
table
"
then
312
gotolocation
(
function
(
)
color
(
{
libcolor
}
,
kstr
)
end
,
{
k
}
)
313
else
314
color
(
{
libcolor
}
,
kstr
)
315
end
316
elseif
inglo
then
317
if
not
mark
and
t
=
=
"
table
"
then
318
gotolocation
(
function
(
)
color
(
{
glocolor
}
,
kstr
)
end
,
{
k
}
)
319
else
320
color
(
{
glocolor
}
,
kstr
)
321
end
322
else
323
if
not
mark
and
t
=
=
"
table
"
then
324
gotolocation
(
k
,
{
kstr
}
)
325
else
326
context
(
kstr
)
327
end
328
end
329
NC
(
)
330
if
inlib
then
331
color
(
{
libcolor
}
,
tstr
)
332
elseif
inglo
then
333
color
(
{
glocolor
}
,
tstr
)
334
else
335
context
(
tstr
)
336
end
337
NC
(
)
NR
(
)
338
if
mark
and
t
=
=
"
table
"
and
title
~
=
"
libraries
"
and
title
~
=
"
package
"
and
not
marked
then
339
childtables
(
false
,
v
,
handler
)
-- (k,v,handler)
340
end
341
end
342
end
343
context
.
stoptabulate
(
)
344
context
.
stopcolumns
(
)
345
if
builtin
then
346
context
.
stopxtitle
(
)
347
else
348
context
.
stoptitle
(
)
349
end
350
end
351
end
352 353
show
(
"
global
"
,
"
"
,
sameglobal
.
global
,
false
,
_G
,
builtin
,
"
darkgreen
"
,
globals
,
"
darkblue
"
,
false
,
obsolete
)
354 355
-- inspect(table.sortedkeys(context))
356 357
for
k
,
v
in
table
.
sortedpairs
(
_G
)
do
358
if
not
skipglobal
[
k
]
and
not
obsolete
[
k
]
and
type
(
v
)
=
=
"
table
"
and
not
marked
(
v
)
then
359 360
-- local mt = getmetatable(v)
361
-- print("!!!!!!!!!!",k,v,mt,mt and mt.__index)
362 363
if
basiclua
[
k
]
then
show
(
k
,
"
basic lua
"
,
sameglobal
[
k
]
,
basiclua
[
k
]
,
v
,
builtin
[
k
]
,
"
darkred
"
,
false
,
false
,
true
)
364
elseif
extralua
[
k
]
then
show
(
k
,
"
extra lua
"
,
sameglobal
[
k
]
,
extralua
[
k
]
,
v
,
builtin
[
k
]
,
"
darkred
"
,
false
,
false
,
true
)
365
elseif
basictex
[
k
]
then
show
(
k
,
"
basic tex
"
,
sameglobal
[
k
]
,
basictex
[
k
]
,
v
,
builtin
[
k
]
,
"
darkred
"
,
false
,
false
,
true
)
366
elseif
extratex
[
k
]
then
show
(
k
,
"
extra tex
"
,
sameglobal
[
k
]
,
extratex
[
k
]
,
v
,
builtin
[
k
]
,
"
darkred
"
,
false
,
false
,
true
)
367
else
368
show
(
k
,
"
context
"
,
sameglobal
[
k
]
,
false
,
v
,
builtin
[
k
]
,
"
darkyellow
"
,
false
,
false
,
true
)
369
end
370
end
371
end
372 373
\stopluacode
374 375
\stoptext
376