summaryrefslogtreecommitdiff
path: root/tex/context/base/mkiv/buff-ini.lua
diff options
context:
space:
mode:
Diffstat (limited to 'tex/context/base/mkiv/buff-ini.lua')
-rw-r--r--tex/context/base/mkiv/buff-ini.lua85
1 files changed, 50 insertions, 35 deletions
diff --git a/tex/context/base/mkiv/buff-ini.lua b/tex/context/base/mkiv/buff-ini.lua
index fd5b047af..2bbec2e4a 100644
--- a/tex/context/base/mkiv/buff-ini.lua
+++ b/tex/context/base/mkiv/buff-ini.lua
@@ -68,6 +68,13 @@ local txtcatcodes = catcodenumbers.txtcatcodes
local setdata = job.datasets.setdata
local getdata = job.datasets.getdata
+local ctx_viafile = context.viafile
+local ctx_getbuffer = context.getbuffer
+local ctx_pushcatcodetable = context.pushcatcodetable
+local ctx_popcatcodetable = context.popcatcodetable
+local ctx_setcatcodetable = context.setcatcodetable
+local ctx_printlines = context.printlines
+
buffers = buffers or { }
local buffers = buffers
@@ -209,21 +216,21 @@ implement {
arguments = "string"
}
-local anything = patterns.anything
-local alwaysmatched = patterns.alwaysmatched
-local utf8character = patterns.utf8character
-
-local function countnesting(b,e)
- local n
- local g = P(b) / function() n = n + 1 end
- + P(e) / function() n = n - 1 end
- -- + anything
- + utf8character
- local p = alwaysmatched / function() n = 0 end
- * g^0
- * alwaysmatched / function() return n end
- return p
-end
+-- local anything = patterns.anything
+-- local alwaysmatched = patterns.alwaysmatched
+-- local utf8character = patterns.utf8character
+--
+-- local function countnesting(b,e)
+-- local n
+-- local g = P(b) / function() n = n + 1 end
+-- + P(e) / function() n = n - 1 end
+-- -- + anything
+-- + utf8character
+-- local p = alwaysmatched / function() n = 0 end
+-- * g^0
+-- * alwaysmatched / function() return n end
+-- return p
+-- end
local counters = { }
local nesting = 0
@@ -286,7 +293,7 @@ local getmargin = (emptyline + normalline)^1
local function undent(str) -- new version, needs testing: todo: not always needed, like in xtables
nofspaces = #str
local margin = lpegmatch(getmargin,str)
- if nofspaces == #str or nofspaces ==0 then
+ if nofspaces == #str or nofspaces == 0 then
return str
end
local stripper = strippers[nofspaces]
@@ -609,30 +616,32 @@ local function runbuffer(name,encapsulate,runnername,suffixes)
return resultname -- first result
end
+local f_getbuffer = formatters["buffer.%s"]
+
local function getbuffer(name)
local str = getcontent(name)
if str ~= "" then
-- characters.showstring(str)
- context.viafile(str,formatters["buffer.%s"](validstring(name,"noname")))
+ ctx_viafile(str,f_getbuffer(validstring(name,"noname")))
end
end
local function getbuffermkvi(name) -- rather direct !
- context.viafile(resolvers.macros.preprocessed(getcontent(name)),formatters["buffer.%s.mkiv"](validstring(name,"noname")))
+ ctx_viafile(resolvers.macros.preprocessed(getcontent(name)),formatters["buffer.%s.mkiv"](validstring(name,"noname")))
end
local function gettexbuffer(name)
local buffer = name and cache[name]
if buffer and buffer.data ~= "" then
- context.pushcatcodetable()
+ ctx_pushcatcodetable()
if buffer.catcodes == txtcatcodes then
- context.setcatcodetable(txtcatcodes)
+ ctx_setcatcodetable(txtcatcodes)
else
- context.setcatcodetable(ctxcatcodes)
+ ctx_setcatcodetable(ctxcatcodes)
end
- -- context(function() context.viafile(buffer.data) end)
- context.getbuffer { name } -- viafile flushes too soon
- context.popcatcodetable()
+ -- context(function() ctx_viafile(buffer.data) end)
+ ctx_getbuffer { name } -- viafile flushes too soon
+ ctx_popcatcodetable()
end
end
@@ -643,6 +652,12 @@ implement { name = "getbuffer", actions = getbuffer, arguments = "stri
implement { name = "getbuffermkvi", actions = getbuffermkvi, arguments = "string" }
implement { name = "gettexbuffer", actions = gettexbuffer, arguments = "string" }
+interfaces.implement {
+ name = "getbuffercontent",
+ arguments = "string",
+ actions = { getcontent, context },
+}
+
implement {
name = "typesetbuffer",
actions = { runbuffer, context },
@@ -667,29 +682,29 @@ implement {
implement {
name = "feedback", -- bad name, maybe rename to injectbuffercontent
- actions = { collectcontent, context.printlines },
+ actions = { collectcontent, ctx_printlines },
arguments = "string"
}
do
- local context = context
- local ctxcore = context.core
+ local context = context
+ local ctxcore = context.core
- local startbuffer = ctxcore.startbuffer
- local stopbuffer = ctxcore.stopbuffer
+ local ctx_startbuffer = ctxcore.startbuffer
+ local ctx_stopbuffer = ctxcore.stopbuffer
- local startcollecting = context.startcollecting
- local stopcollecting = context.stopcollecting
+ local ctx_startcollecting = context.startcollecting
+ local ctx_stopcollecting = context.stopcollecting
function ctxcore.startbuffer(...)
- startcollecting()
- startbuffer(...)
+ ctx_startcollecting()
+ ctx_startbuffer(...)
end
function ctxcore.stopbuffer()
- stopbuffer()
- stopcollecting()
+ ctx_stopbuffer()
+ ctx_stopcollecting()
end
end