summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/context/base/s-inf-03.mkiv
blob: 85440f0db97f3ff15f995feef017c602685f85e5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
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
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
% \nopdfcompression

% \enablemode[ipad]

\doifmodeelse {ipad} {

    \setuppapersize
      [S6,landscape]
      [S6,landscape]

    \definefont
      [TitlePageFont]
      [MonoBold at 20pt]

} {

    \definefont
      [TitlePageFont]
      [MonoBold at 26pt]

}

\setuplayout
  [header=0cm,
   footer=1cm,
   backspace=.5cm,
   topspace=.5cm,
   width=middle,
   height=middle]

\setuphead
  [title]
  [style=\ttc,
   interaction=reference]

\definehead
  [xtitle]
  [title]

\setuphead
  [xtitle]
  [color=darkgreen]

\setupbodyfont
  [tt]

\setupfootertexts
  [\llap{\goto{\hbox to 5cm{\hss previous}}[previouspage]}%
   \quad\pagenumber\quad
   \rlap{\goto{\hbox to 5cm{next\hss}}[nextpage]}]

\setupinteraction
  [state=start,
   style=,
   color=,
   title={ConTeXt MkIV},
   subtitle={Lua modules and functions},
   author={Hans Hagen - automatically generated},
   contrastcolor=]

\setupinteractionscreen
  [option=bookmark]

\placebookmarks
  [title,xtitle]
  [force=yes]

\definecolor[darkyellow][r=.5,g=.5,b=0]
\definecolor[darkgray]  [s=.15]

\nonknuthmode

\starttext

\startbuffer
\startluacode
local basiclua = libraries.basiclua
local basictex = libraries.basictex
local extratex = libraries.extratex
local extralua = libraries.extralua
local obsolete = libraries.obsolete

local find = string.find
local color, goto = context.color, context.goto

for k, v in table.sortedpairs(_G) do
    if obsolete[k] or find(k,"_") or k == "arg" or k == "utf" then
        --
    elseif basiclua[k] then
        goto(function() color( { "darkred" }, k) end, { k } )
    elseif extralua[k] then
        goto(function() color( { "darkgreen" }, k) end, { k } )
    elseif basictex[k] then
        goto(function() color( { "darkblue" }, k) end, { k } )
    elseif extratex[k] then
        goto(function() color( { "darkyellow" }, k) end, { k } )
    elseif type(v) == "table" then
        goto(function() color( { "white" }, k) end, { k } )
    end
    context(" ")
end
\stopluacode
\stopbuffer

\setupbackgrounds
  [page]
  [background=color,
   backgroundcolor=darkgray,
   backgroundoffset=2mm]

\setuplayout
  [page]

\startstandardmakeup
    \vfill
    \pagereference[global]
    \startnarrower[5mm]
        \raggedcenter
        \TitlePageFont \setupinterlinespace
        \getbuffer % luabuffer
        \par
    \stopnarrower
    \vfill
    \vfill
    \hskip10mm\scale[width=\dimexpr\paperwidth-20mm\relax]{\ttbf\white\ConTeXt\ MkIV}
    \par
  % \hskip10mm\scale[width=\dimexpr\paperwidth-20mm\relax]{\white \strut Lua infrastructure \emdash\ \currentdate}
    \vfill
\stopstandardmakeup

\setuplayout

\setupbackgrounds
  [page]
  [background=]

\startluacode
local builtin  = libraries.builtin
local globals  = libraries.globals
local basiclua = libraries.basiclua
local basictex = libraries.basictex
local extratex = libraries.extratex
local extralua = libraries.extralua
local obsolete = libraries.obsolete

local sortedkeys = table.sortedkeys
local mark       = storage.mark
local marked     = storage.marked
local gsub       = string.gsub
local sub        = string.sub
local byte       = string.byte
local upper      = string.upper

local skipglobal = table.tohash {
    "_G", "context", "modules", "global", "arg", "utf", 1,
    "_ptbs_", "_pcol_", "_plib_", "_clib_", "_tlib_",
    "_M", "kpse",
}

local skipkeys = table.tohash {
    "_pcol_", "_plib_", "_clib_", "_tlib_", "_bpnf_", "_ptbs_",
    "_cldf_", "_cldn_",
    "_clmb_", "_clme_", "_clmm_", "_clmn_", "_clma_", "_clmh_",
    "_G", "_M", "_VERSION", "_COPYRIGHT", "_DESCRIPTION", "_NAME", "_PACKAGE", "__unload",
}

local sameglobal = {
    ["global"]   = "_G",
 -- ["commands"] = "cs", -- already gone
}

-- -- -- -- -- -- -- -- -- -- -- -- --
-- this should be done internally
-- -- -- -- -- -- -- -- -- -- -- -- --

for k,v in next, modules do
    mark(v)
end

mark(document.arguments)
mark(environment.arguments)
mark(environment.engineflags)
mark(characters.data)

-- -- -- -- -- -- -- -- -- -- -- -- --
-- -- -- -- -- -- -- -- -- -- -- -- --

local variant = 1 -- all parents
local variant = 2 -- parent name too
local variant = 3 -- no parents

local function childtables(key,tab,handler,depth)
    depth = depth or 1
    local keys = sortedkeys(tab) -- no sorted_pairs
    for i=1,#keys do
        local k = keys[i]
--      if k ~= "_G" and k ~= "_M" and type(k) == "string" then
        if not skipkeys[k] and type(k) == "string" then
            local v = tab[k]
            local t = type(v)
            local s = k
            if variant ~= 3 then
                s = key and (key .. "." .. s) or s
            end
            if t == "table" then
                if marked(v) then
                    t = "data"
                    handler(s,t,depth)
                else
                    handler(s,t,depth)
                    if variant == 3 then
                        childtables(false,v,handler,depth+1)
                    elseif variant == 2 then
                        childtables(k,v,handler,depth+1)
                    else
                        childtables(s,v,handler,depth+1)
                    end
                end
            else
                handler(s,t,depth)
            end
        end
    end
end

local NC, NR = context.NC, context.NR
local overstrike, rlap, bf = context.overstrike, context.rlap, context.bf
local color, goto = context.color, context.goto

local function cleanup(s)
    return "\\char" ..byte(s) .. " "
end

local function handler(k,t,depth)
    k = gsub(k,"([~#$%%^&{}\\\|])",cleanup)
--    NC() rlap("\\quad\\tx " .. upper(sub(t,1,1)) .. " ".. k) NC() NC() NR()
    NC() rlap("\\quad\\tx\\kern" .. (depth or 0).. "em" .. upper(sub(t,1,1)) .. " ".. k) NC() NC() NR()
end

local function show(title,subtitle,alias,builtin,t,lib,libcolor,glo,glocolor,mark,obsolete)
    -- todo: table as argument
    local keys = sortedkeys(t) -- no sorted_pairs
    if #keys > 0 then
        local fulltitle = title
        if subtitle and subtitle ~= "" then
            fulltitle = fulltitle .. " (" .. subtitle .. ")"
        end
        if alias and alias ~= "" then
            fulltitle = fulltitle .. " (alias: " .. alias .. ")"
        end
        if builtin then
            context.startxtitle { reference = title, title = fulltitle, backreference = "global" }
        else
            context.starttitle  { reference = title, title = fulltitle, backreference = "global" }
        end
        context.startcolumns { n = 2 }
        context.starttabulate { "|||" }
        local t_obsolete = t.obsolete
        if type(t_obsolete) ~= "table" then
            t_obsolete = nil
        end
        for i=1,#keys do
            local k = keys[i]
            local v = t[k]
            if k ~= "obsolete" and not skipkeys[k] and (not obsolete or not obsolete[k]) then
                local inlib = lib and lib[k]
                local inglo = glo and glo[k]
                if k then
                    local t = type(v)
                    local kstr, tstr = k, t
                    local obs = t_obsolete and t_obsolete[k]
                    if obs then
                        tstr = function() overstrike(t) end
                        kstr = function() overstrike(k) end
                    end
                    local marked = marked(v)
                    if marked then
                        tstr = "data table"
                    end
                    if t == "table" then
                        local m = getmetatable(v)
                        if m and m.__call then
                            tstr = "function"
                        end
                    end
                    if not mark then
                        --
                    elseif inlib and tostring(inlib) ~= tostring(v) then
                        tstr = "overloaded ".. tstr
                    elseif inglo and tostring(inglo) ~= tostring(v) then
                        tstr = "overloaded ".. tstr
                    end
                    NC() bf()
                    if inlib then
                        if not mark and t == "table" then
                            goto(function() color( { libcolor }, kstr) end, { k } )
                        else
                            color( { libcolor }, kstr)
                        end
                    elseif inglo then
                        if not mark and t == "table" then
                            goto(function() color( { glocolor }, kstr) end, { k } )
                        else
                            color( { glocolor }, kstr)
                        end
                    else
                        if not mark and t == "table" then
                            goto(k, { kstr } )
                        else
                            context(kstr)
                        end
                    end
                    NC()
                    if inlib then
                        color( { libcolor }, tstr)
                    elseif inglo then
                        color( { glocolor }, tstr)
                    else
                        context(tstr)
                    end
                    NC() NR()
                    if mark and t == "table" and title ~= "libraries" and title ~= "package" and not marked then
                        childtables(false,v,handler) -- (k,v,handler)
                    end
                end
            end
        end
        context.stoptabulate()
        context.stopcolumns()
        if builtin then
            context.stopxtitle()
        else
            context.stoptitle()
        end
    end
end

show("global","",sameglobal.global,false,_G,builtin,"darkgreen",globals,"darkblue",false,obsolete)

for k, v in table.sortedpairs(_G) do
    if not skipglobal[k] and not obsolete[k] and type(v) == "table" and not marked(v) then
        if     basiclua[k] then show(k,"basic lua",sameglobal[k],basiclua[k],v,builtin[k],"darkred",   false,false,true)
        elseif extralua[k] then show(k,"extra lua",sameglobal[k],extralua[k],v,builtin[k],"darkred",   false,false,true)
        elseif basictex[k] then show(k,"basic tex",sameglobal[k],basictex[k],v,builtin[k],"darkred",   false,false,true)
        elseif extratex[k] then show(k,"extra tex",sameglobal[k],extratex[k],v,builtin[k],"darkred",   false,false,true)
        else                    show(k,"context",  sameglobal[k],false,      v,builtin[k],"darkyellow",false,false,true)
        end
    end
end

\stopluacode

\stoptext