diff options
Diffstat (limited to 'Master/texmf-dist/tex/context/base/mlib-ctx.lua')
-rw-r--r-- | Master/texmf-dist/tex/context/base/mlib-ctx.lua | 36 |
1 files changed, 29 insertions, 7 deletions
diff --git a/Master/texmf-dist/tex/context/base/mlib-ctx.lua b/Master/texmf-dist/tex/context/base/mlib-ctx.lua index cc5682e6fdc..1a5ce2a2419 100644 --- a/Master/texmf-dist/tex/context/base/mlib-ctx.lua +++ b/Master/texmf-dist/tex/context/base/mlib-ctx.lua @@ -8,12 +8,18 @@ if not modules then modules = { } end modules ['mlib-ctx'] = { -- todo -local format, join = string.format, table.concat +local format, concat = string.format, table.concat local sprint = tex.sprint +local report_metapost = logs.reporter("metapost") + local starttiming, stoptiming = statistics.starttiming, statistics.stoptiming -metapost = metapost or {} +local mplib = mplib + +metapost = metapost or {} +local metapost = metapost + metapost.defaultformat = "metafun" function metapost.graphic(instance,mpsformat,str,initializations,preamble,askedfig) @@ -29,7 +35,7 @@ function metapost.getclippath(instance,mpsformat,data,initializations,preamble) local result = mpx:execute(format("%s;beginfig(1);%s;%s;endfig;",preamble or "",initializations or "",data)) stoptiming(metapost.exectime) if result.status > 0 then - logs.report("metafun", "%s: %s", result.status, result.error or result.term or result.log) + report_metapost("%s: %s", result.status, result.error or result.term or result.log) result = nil else result = metapost.filterclippath(result) @@ -62,19 +68,19 @@ end function metapost.theclippath(...) local result = metapost.getclippath(...) if result then -- we could just print the table - result = join(metapost.flushnormalpath(result),"\n") + result = concat(metapost.flushnormalpath(result),"\n") sprint(result) end end statistics.register("metapost processing time", function() local n = metapost.n - if n > 0 then - local e, t = metapost.externals.n, statistics.elapsedtime + if n and n > 0 then + local e, t = metapost.makempy.nofconverted, statistics.elapsedtime local str = format("%s seconds, loading: %s seconds, execution: %s seconds, n: %s", t(metapost), t(mplib), t(metapost.exectime), n) if e > 0 then - return format("%s, external: %s seconds (%s calls)", str, t(metapost.externals), e) + return format("%s, external: %s seconds (%s calls)", str, t(metapost.makempy), e) else return str end @@ -82,3 +88,19 @@ statistics.register("metapost processing time", function() return nil end end) + +-- only used in graphictexts + +metapost.tex = metapost.tex or { } + +local environments = { } + +function metapost.tex.set(str) + environments[#environments+1] = str +end +function metapost.tex.reset() + environments = { } +end +function metapost.tex.get() + return concat(environments,"\n") +end |