diff options
author | Taco Hoekwater <taco@elvenkind.com> | 2010-05-24 14:05:02 +0000 |
---|---|---|
committer | Taco Hoekwater <taco@elvenkind.com> | 2010-05-24 14:05:02 +0000 |
commit | 57ea7dad48fbf2541c04e434c31bde655ada3ac4 (patch) | |
tree | 1f8b43bc7cb92939271e1f5bec610710be69097f /Master/texmf-dist/scripts/context/lua/mtx-timing.lua | |
parent | 6ee41e1f1822657f7f23231ec56c0272de3855e3 (diff) |
here is context 2010.05.24 13:05
git-svn-id: svn://tug.org/texlive/trunk@18445 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/scripts/context/lua/mtx-timing.lua')
-rw-r--r-- | Master/texmf-dist/scripts/context/lua/mtx-timing.lua | 80 |
1 files changed, 36 insertions, 44 deletions
diff --git a/Master/texmf-dist/scripts/context/lua/mtx-timing.lua b/Master/texmf-dist/scripts/context/lua/mtx-timing.lua index 1dcb9aa0e0d..40e33cdaef0 100644 --- a/Master/texmf-dist/scripts/context/lua/mtx-timing.lua +++ b/Master/texmf-dist/scripts/context/lua/mtx-timing.lua @@ -55,15 +55,17 @@ local html_menu = [[ local directrun = true -function goodies.progress.make_svg(filename,other) +local what = { "parameters", "nodes" } + +function plugins.progress.make_svg(filename,other) local metadata, menudata, c = { }, { }, 0 metadata[#metadata+1] = 'outputformat := "svg" ;' - for _, kind in pairs { "parameters", "nodes" } do - local mdk = { } + for i=1,#what do + local kind, mdk = what[i], { } menudata[kind] = mdk - for n, name in pairs(goodies.progress[kind](filename)) do - local first = goodies.progress.path(filename,name) - local second = goodies.progress.path(filename,other) + for n, name in next, plugins.progress[kind](filename) do + local first = plugins.progress.path(filename,name) + local second = plugins.progress.path(filename,other) c = c + 1 metadata[#metadata+1] = format(meta,c,first,second) mdk[#mdk+1] = { name, c } @@ -88,18 +90,19 @@ function goodies.progress.make_svg(filename,other) end end -function goodies.progress.makehtml(filename,other,menudata,metadata) +function plugins.progress.makehtml(filename,other,menudata,metadata) local graphics = { } local result = { graphics = graphics } - for _, kind in pairs { "parameters", "nodes" } do + for i=1,#what do + local kind, menu = what[i], { } local md = menudata[kind] - local menu = { } result[kind] = menu - for k, v in ipairs(md) do + for k=1,#md do + local v = md[k] local name, number = v[1], v[2] - local min = goodies.progress.bot(filename,name) - local max = goodies.progress.top(filename,name) - local pages = goodies.progress.pages(filename) + local min = plugins.progress.bot(filename,name) + local max = plugins.progress.top(filename,name) + local pages = plugins.progress.pages(filename) local average = math.round(max/pages) if directrun then local data = metadata[number] @@ -119,55 +122,44 @@ function goodies.progress.makehtml(filename,other,menudata,metadata) return result end -function goodies.progress.valid_file(name) +function plugins.progress.valid_file(name) return name and name ~= "" and lfs.isfile(name .. "-luatex-progress.lut") end -function goodies.progress.make_lmx_page(name,launch,remove) +function plugins.progress.make_lmx_page(name,launch,remove) + local filename = name .. "-luatex-progress" local other = "elapsed_time" local template = 'context-timing.lmx' - lmx.variables['color-background-green'] = '#4F6F6F' - lmx.variables['color-background-blue'] = '#6F6F8F' - lmx.variables['color-background-yellow'] = '#8F8F6F' - lmx.variables['color-background-purple'] = '#8F6F8F' - - lmx.variables['color-background-body'] = '#808080' - lmx.variables['color-background-main'] = '#3F3F3F' - lmx.variables['color-background-one'] = lmx.variables['color-background-green'] - lmx.variables['color-background-two'] = lmx.variables['color-background-blue'] + plugins.progress.convert(filename) - lmx.variables['title-default'] = 'ConTeXt Timing Information' - lmx.variables['title'] = lmx.variables['title-default'] + local menudata, metadata = plugins.progress.make_svg(filename,other) + local htmldata = plugins.progress.makehtml(filename,other,menudata,metadata) lmx.htmfile = function(name) return name .. "-timing.xhtml" end lmx.lmxfile = function(name) return resolvers.find_file(name,'tex') end - lmx.set('title', format('ConTeXt Timing Information: %s',file.basename(name))) - lmx.set('color-background-one', lmx.get('color-background-green')) - lmx.set('color-background-two', lmx.get('color-background-blue')) - - goodies.progress.convert(filename) - - local menudata, metadata = goodies.progress.make_svg(filename,other) - local htmldata = goodies.progress.makehtml(filename,other,menudata,metadata) - - lmx.set('parametersmenu', concat(htmldata.parameters, " ")) - lmx.set('nodesmenu', concat(htmldata.nodes, " ")) - lmx.set('graphics', concat(htmldata.graphics, "\n\n")) + local variables = { + ['title-default'] = 'ConTeXt Timing Information', + ['title'] = format('ConTeXt Timing Information: %s',file.basename(name)), + ['parametersmenu'] = concat(htmldata.parameters, " "), + ['nodesmenu'] = concat(htmldata.nodes, " "), + ['graphics'] = concat(htmldata.graphics, "\n\n"), + ['color-background-one'] = lmx.get('color-background-green'), + ['color-background-two'] = lmx.get('color-background-blue'), + } if launch then - local htmfile = lmx.show(template) + local htmfile = lmx.show(template,variables) if remove then os.sleep(1) -- give time to launch os.remove(htmfile) end else - lmx.make(template) + lmx.make(template,variables) end - lmx.restore() end scripts = scripts or { } @@ -176,17 +168,17 @@ scripts.timings = scripts.timings or { } function scripts.timings.xhtml(filename) if filename == "" then logs.simple("provide filename") - elseif not goodies.progress.valid_file(filename) then + elseif not plugins.progress.valid_file(filename) then logs.simple("first run context again with the --timing option") else local basename = file.removesuffix(filename) local launch = environment.argument("launch") local remove = environment.argument("remove") - goodies.progress.make_lmx_page(basename,launch,remove) + plugins.progress.make_lmx_page(basename,launch,remove) end end -logs.extendbanner("ConTeXt Timing Tools 0.1",true) +logs.extendbanner("ConTeXt Timing Tools 0.10",true) messages.help = [[ --xhtml make xhtml file |