From d7ccb42582f85acf30568913610ccf4d602023fb Mon Sep 17 00:00:00 2001 From: Taco Hoekwater Date: Wed, 1 Jun 2011 08:54:21 +0000 Subject: commit context 2011.05.18 git-svn-id: svn://tug.org/texlive/trunk@22719 c570f23f-e606-0410-a88d-b1316a301751 --- Master/texmf-dist/tex/context/base/s-inf-01.mkvi | 244 +++++++++++++++++++++++ 1 file changed, 244 insertions(+) create mode 100644 Master/texmf-dist/tex/context/base/s-inf-01.mkvi (limited to 'Master/texmf-dist/tex/context/base/s-inf-01.mkvi') diff --git a/Master/texmf-dist/tex/context/base/s-inf-01.mkvi b/Master/texmf-dist/tex/context/base/s-inf-01.mkvi new file mode 100644 index 00000000000..4792e739a66 --- /dev/null +++ b/Master/texmf-dist/tex/context/base/s-inf-01.mkvi @@ -0,0 +1,244 @@ +%D \module +%D [ file=s-inf-01, +%D version=2009.07.09, +%D title=\CONTEXT\ Style File, +%D subtitle=Information 1 (\MKII/\MKIV\ usage), +%D author=Hans Hagen, +%D date=\currentdate, +%D copyright={PRAGMA / Hans Hagen \& Ton Otten}] +%C +%C This module is part of the \CONTEXT\ macro||package and is +%C therefore copyrighted by \PRAGMA. See mreadme.pdf for +%C details. + +%D Some day I will generalize this table mechanism. This list is only +%D right when run in the minimals as my machine might have more files. +%D +%D Als, the remaining tex code can proably be lua also which is more +%D consistent. +%D +%D \starttyping +%D context auto:s-inf-01 +%D context auto:s-inf-01 --basepath=t:/texmf/tex/context/base +%D \stoptyping + +\startluacode + local format, gsub, find, match = string.format, string.gsub, string.find, string.match + + local list, size, comp, used, nope = { }, { }, { }, { mkii = { }, mkiv = { }, mkvi = { } }, { 0, 0, 0, 0, 0 } + + local omit = { + "char%-def%.lua", + "mult%-def%.lua", "mult%-..%.mkii", "mult%-m..%.mkii", + } + local skip = { + "prag%-.*%.tex", "docs%-.*.tex", "list%-.*%.tex", "test%-.*%.tex", "demo%-.*%.tex", + "opti%-.*%.tex", "chrt%-.*%.tex", ".*%-old", ".*%-obs", ".*%-tst", "supp%-.*%.tex", + "colo%-pan.tex", ".*test.*" + } + local types = { + "tex", "mkii", "mkiv", "mkvi", "lua" + } + local patterns = { + "^([a-z][a-z][a-z][a-z])%-[a-z0-9%-]+%.[a-z]+", + "^([xms])%-[a-z0-9%-]+%.[a-z]+", + } + + local function collect(list,suffix,n) + local path = document.arguments.basepath or file.dirname(resolvers.find_file("context.mkiv"),".") + local pattern = path .. "/*." .. suffix + local texfiles = dir.glob(pattern) + for _, name in ipairs(texfiles) do + local base = file.basename(name) + for p=1,#patterns do + local category = match(base,patterns[p]) + if category and lfs.isfile(name) then + local okay = true + for s=1,#skip do + if find(base,skip[s]) then + okay = false + break + end + end + if okay then + local lm, sm, cm = list[category], size[category], comp[category] + if not lm then + lm, sm, cm = { 0, 0, 0, 0, 0 }, { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, { 0, 0, 0, 0, 0 } + list[category], size[category], comp[category] = lm, sm, cm + end + lm[n] = lm[n] + 1 + local done = true + for o=1,#omit do + if find(base,omit[o]) then + done = false + break + end + end + local data = io.loaddata(name) + if suffix == "lua" then + data = gsub(data,"%-%-%[%[.-%]%]%-%-","") + data = gsub(data,"%-%-.-[\n\r]","") + else + data = gsub(data,"%%.-[\n\r]","") + end + data = gsub(data,"%s","") + sm[n+5] = sm[n+5] + #data + if done then + sm[n] = sm[n] + #data + else + cm[n] = cm[n] + 1 + end + end + end + end + end + end + + local function prepare(what) + if next(list) then + -- already loaded + else + for k, v in ipairs(types) do + collect(list,v,k) + end + for category, _ in pairs(list) do + pattern ="{"..category.."%-" + for suffix, t in pairs(used) do + local data = io.loaddata(resolvers.find_file("context."..suffix)) + if data and find(data,pattern) then + t[category] = true + end + end + end + end + local max, what = 0, (what == "size" and size) or list + for k, v in table.sortedpairs(what) do + for i=1,5 do if v[i] > max then max = v[i] end end + end + return max, what, function(n) return (max == 0 and 0) or (n == 0 and 0) or n/max end + end + + function document.context_state_1(what) + local max, what, norm = prepare(what) + context.starttabulate { "|Tl|T|T|T|T|T|" } + context.NC() + context(category) + context.NC() + for i, t in ipairs(types) do + local n, m = 0, 0 + for k, v in pairs(list) do + local nn, mm = what[k][i], what[k][i+5] + n = n + nn + m = m + (mm or nn) + end + context.Top(t,norm(max),n,m) + context.NC() + end + context.NC() + context.NR() + context.HL() + for k, v in table.sortedpairs(what) do + local c = (what == size and comp[k]) or nope + context.NC() + context("%s~%s~~%s~~%s", + (used.mkii[k] and "ii") or "~~", + (used.mkiv[k] and "iv") or "~~", + (used.mkvi[k] and "vi") or "~~", + k + ) + context.NC() + for i, t in ipairs(types) do + context.Bar(t,v[i],c[i],norm(v[i])) + context.NC() + end + context.NR() + end + context.stoptabulate() + end + + function document.context_state_2(what) + local max, what, norm = prepare(what) + for k, v in table.sortedpairs(what) do + local c = (what == size and comp[k]) or nope + context.StartUp(k) + for i, t in ipairs(types) do + context.Up(t,norm(v[i])) + end + context.StopUp() + end + end + +\stopluacode + +\definecolor[bar:tex] [middlegreen] +\definecolor[bar:mkii][middleblue] +\definecolor[bar:mkiv][middlered] +\definecolor[bar:mkvi][middleyellow] +\definecolor[bar:lua] [middlegray] + +\newcount\UpCounter + +\starttexdefinition Top #what#fraction#total#bigones + \hbox to 5em{\hss#total}% + \enspace + \hbox {#what\ifnum#total=#bigones\else~#bigones\rlap{~+}\fi\hss}% +\stoptexdefinition + +\starttexdefinition Bar #color#size#nobigones#fraction + \ifcase#size\else + \hbox to 5em{\hss\ifcase#nobigones\else\llap{-~}\fi#size}% + \enspace + \blackrule[color=bar:#color,width=#fraction\dimexpr 20em\relax,height=.8\strutht]% + \fi +\stoptexdefinition + +\starttexdefinition StartUp #name + \def\UpName{#name}% + \dontleavehmode\framed[frame=off,align={middle,low},height=18em]\bgroup +\stoptexdefinition + +\starttexdefinition StopUp + \par\nointerlineskip\blackrule[height=1pt,width=5em,depth=0pt,color=darkgray] + \par\tttf\strut\UpName\par + \egroup + \ifnum\UpCounter=17 + \par \UpCounter\zerocount + \else + \kern1em \advance\UpCounter\plusone + \fi +\stoptexdefinition + +\starttexdefinition Up #color#width + \scratchdimen#width\dimexpr 16em\relax + \ifdim\scratchdimen=\zeropoint + \kern1em + \else + \ifdim\scratchdimen<\onepoint \scratchdimen\onepoint \fi + \blackrule[color=bar:#color,height=\scratchdimen,width=1em]% + \fi +\stoptexdefinition + +\starttexdefinition Show #title#how#what + \startTEXpage[offset=1em,width=fit] + \hbox{\tttf\strut\currentdate~-~#title} + \par + \ctxlua{document.context_state_\number#how("#what")} + \stopTEXpage +\stoptexdefinition + +% \doifnotmode{demo}{\endinput} + +\starttext + \Show + {The number of files used in ConTeXt (base modules and styles).} + {1}{number} + \Show + {The size of (core) files used in ConTeXt (- indicates exclusion of large data files; + indicates inclusion of large data files; comment and spaces removed.)} + {1}{size} + \Show + {The relative number of files used in ConTeXt (tex, mkii, mkiv, mkvi, lua).} + {2}{number} + \Show + {The relative size of files used in ConTeXt (tex, mkii, mkiv, mkvi, lua).} + {2}{size} +\stoptext -- cgit v1.2.3