diff options
Diffstat (limited to 'tex/context/base/s-inf-03.mkiv')
-rw-r--r-- | tex/context/base/s-inf-03.mkiv | 352 |
1 files changed, 352 insertions, 0 deletions
diff --git a/tex/context/base/s-inf-03.mkiv b/tex/context/base/s-inf-03.mkiv new file mode 100644 index 000000000..bfcf5650b --- /dev/null +++ b/tex/context/base/s-inf-03.mkiv @@ -0,0 +1,352 @@ +% \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 + \startnarrower[5mm] + \raggedcenter + \TitlePageFont \setupinterlinespace + \getbuffer + \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 |