summaryrefslogtreecommitdiff
path: root/tex/context/base/mkiv/mlib-ctx.lua
diff options
context:
space:
mode:
Diffstat (limited to 'tex/context/base/mkiv/mlib-ctx.lua')
-rw-r--r--tex/context/base/mkiv/mlib-ctx.lua46
1 files changed, 36 insertions, 10 deletions
diff --git a/tex/context/base/mkiv/mlib-ctx.lua b/tex/context/base/mkiv/mlib-ctx.lua
index 96eb27cbd..0ff28c1c4 100644
--- a/tex/context/base/mkiv/mlib-ctx.lua
+++ b/tex/context/base/mkiv/mlib-ctx.lua
@@ -6,12 +6,10 @@ if not modules then modules = { } end modules ['mlib-ctx'] = {
license = "see context related readme files",
}
--- for the moment we have the scanners here but they migh tbe moved to
--- the other modules
-
local type, tostring = type, tostring
local format, concat = string.format, table.concat
local settings_to_hash = utilities.parsers.settings_to_hash
+local formatters = string.formatters
local report_metapost = logs.reporter("metapost")
@@ -20,9 +18,8 @@ local stoptiming = statistics.stoptiming
local mplib = mplib
-metapost = metapost or {}
+metapost = metapost or { }
local metapost = metapost
-
local context = context
local setters = tokens.setters
@@ -87,10 +84,6 @@ function metapost.getextensions(instance,state)
end
end
--- function commands.getmpextensions(instance,state)
--- context(metapost.getextensions(instance,state))
--- end
-
implement {
name = "setmpextensions",
actions = metapost.setextensions,
@@ -139,7 +132,7 @@ implement {
end
}
--- metapost.variables = { } -- to be stacked
+-- metapost.variables = { } -- to be stacked
implement {
name = "mprunvar",
@@ -202,6 +195,39 @@ function metapost.graphic(specification)
metapost.graphic_base_pass(setmpsformat(specification))
end
+function metapost.startgraphic(t)
+ if not t then
+ t = { }
+ end
+ if not t.instance then
+ t.instance = metapost.defaultinstance
+ end
+ if not t.format then
+ t.format = metapost.defaultformat
+ end
+ if not t.method then
+ t.method = metapost.defaultmethod
+ end
+ if not t.definitions then
+ t.definitions = ""
+ end
+ t.data = { }
+ return t
+end
+
+function metapost.stopgraphic(t)
+ if t then
+ t.data = concat(t.data or { },"\n")
+ metapost.graphic(t)
+ t.data = ""
+ end
+end
+
+function metapost.tographic(t,f,s,...)
+ local d = t.data
+ d[#d+1] = s and formatters[f](s,...) or f
+end
+
implement {
name = "mpgraphic",
actions = metapost.graphic,