summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/context/base/mkiv/data-tex.lua
diff options
context:
space:
mode:
Diffstat (limited to 'Master/texmf-dist/tex/context/base/mkiv/data-tex.lua')
-rw-r--r--Master/texmf-dist/tex/context/base/mkiv/data-tex.lua24
1 files changed, 18 insertions, 6 deletions
diff --git a/Master/texmf-dist/tex/context/base/mkiv/data-tex.lua b/Master/texmf-dist/tex/context/base/mkiv/data-tex.lua
index e4795d09d18..2c1a7dbd5d1 100644
--- a/Master/texmf-dist/tex/context/base/mkiv/data-tex.lua
+++ b/Master/texmf-dist/tex/context/base/mkiv/data-tex.lua
@@ -143,20 +143,31 @@ local function textopener(tag,filename,filehandle,coding)
lines[noflines] = nil
end
pushinputname(filename)
- local currentline, noflines = 0, noflines
- local t = {
+ local currentline = 0
+ local noflines = noflines
+ local handler = {
filename = filename,
noflines = noflines,
-- currentline = 0,
+ gotoline = function(self,n)
+ currentline = n - 1
+ if currentline <= 0 then
+ currentline = 0
+ end
+ end,
+ endoffile = function()
+ return not lines or currentline >= noflines
+ end,
close = function()
local usedname = popinputname() -- should match filename
if trace_locating then
report_tex("%a closer: %a closed",tag,filename)
end
- t = nil
+ handler = nil
+ lines = nil
end,
reader = function(self)
- self = self or t
+ self = self or handler
-- local currentline, noflines = self.currentline, self.noflines
if currentline >= noflines then
return nil
@@ -164,6 +175,7 @@ local function textopener(tag,filename,filehandle,coding)
currentline = currentline + 1
-- self.currentline = currentline
local content = lines[currentline]
+-- lines[currentline] = nil
if content == "" then
return ""
-- elseif content == ctrl_d or ctrl_z then
@@ -181,14 +193,14 @@ local function textopener(tag,filename,filehandle,coding)
end
end
}
- setmetatableindex(t,function(t,k)
+ setmetatableindex(handler,function(t,k)
if k == "currentline" then
return currentline
else
-- no such key
end
end)
- return t
+ return handler
end
helpers.settextopener(textopener) -- can only be done once