Some updates

This commit is contained in:
Marcel Krüger 2021-04-16 10:15:58 +02:00
parent a6d3b3cc0f
commit 7f370bc361
6 changed files with 53 additions and 50 deletions

View File

@ -63,18 +63,16 @@ local function get_outline()
return outline
end
local properties = node.direct.properties
local immediateassignment = token.new(5, token.command_id'convert')
local global = token.new(0, token.command_id'prefix')
local deadcycles = token.new(8, token.command_id'set_page_property')
local zero_tok = token.create(0x30)
local relax = token.new(0, 0)
local reset_deadcycles = {
immediateassignment,
global,
deadcycles,
zero_tok,
relax,
local reset_deadcycles do
local tokens = {
token.primitive_tokens.global,
token.primitive_tokens.deadcycles,token.create(0x30),
token.primitive_tokens.relax,
}
function reset_deadcycles()
token.put_next(tokens)
end
end
token.luacmd("shipout", function()
local pfile = get_pfile()
local total_voffset, total_hoffset = tex.voffset + pdfvariable.vorigin, tex.hoffset + pdfvariable.horigin
@ -95,8 +93,7 @@ token.luacmd("shipout", function()
local content = pfile:stream(nil, '', out)
pfile:indirect(page, string.format([[<</Type/Page/Parent %i 0 R/Contents %i 0 R/MediaBox[0 %i %i %i]/Resources%s%s%s%s>>]], parent, content, -math.ceil(to_bp(list.depth)), math.ceil(to_bp(list.width)), math.ceil(to_bp(list.height)), resources(pdfvariable.pageresources .. pdf.pageresources), annots, pdfvariable.pageattr, pdf.pageattributes))
node.flush_list(list)
token.put_next(reset_deadcycles)
scan_token()
tex.runlocal(reset_deadcycles)
end, 'force', 'protected')
local infodir = ""
@ -226,7 +223,8 @@ function callbacks.stop_run()
local size = pfile:close()
texio.write_nl("term", "(see the transcript file for additional information)")
-- TODO: Additional logging, epecially targeting the log file
texio.write_nl("term and log", string.format(" %d words of node memory still in use:", status.nodestate.use))
texio.write_nl("term and log", " node memory still in use:")
-- texio.write_nl("term and log", string.format(" %d words of node memory still in use:", status.nodestate.use))
local by_type, by_sub = {}, {}
for n, id, sub in node.traverse(node.usedlist()) do
if id == whatsit_id then

View File

@ -103,9 +103,8 @@ local errorvalues = tex.geterrorvalues()
function callbacks.intercept_tex_error(mode, errortype)
errortype = errorvalues[errortype]
if errortype == "eof" then
tex.runlocal(function()token.put_next(token.create'tracingall')end)
do_terminal_input()
tex.runlocal(token.skip_next)
-- print('EOF', token.peek_next())
token.put_next(token.create'ABD')
return 3
end
texio.write'.'

View File

@ -121,6 +121,9 @@ tex_variable(count_code, scan_int, 'outputmode', 1) -- The "traditional" default
tex_variable(dimen_code, scan_dimen, 'pageheight', 0)
tex_variable(dimen_code, scan_dimen, 'pagewidth', 0)
tex_variable(dimen_code, scan_dimen, 'hoffset', 0)
tex_variable(dimen_code, scan_dimen, 'voffset', 0)
tex_variable(count_code, scan_int, 'bodydirection', 0)
tex_variable(count_code, scan_int, 'pagedirection', 0)

View File

@ -190,6 +190,9 @@ token.luacmd("read", function(_, prefix)
end
local macro = scan_csname(true)
local file = ifiles[id]
local tokens = {}
local balance = 0
repeat
local line
if file then
line = file:reader()
@ -198,7 +201,7 @@ token.luacmd("read", function(_, prefix)
ifiles[id] = nil
end
else
error[[FIXME: Ask the user for input]]
line = io.stdin:read()
end
local endlocal
tex.runlocal(function()
@ -207,8 +210,6 @@ token.luacmd("read", function(_, prefix)
tex.print(line and line ~= "" and line or " ")
tex.print(endlocal)
end)
local tokens = {}
local balance = 0
while true do
local tok = token.scan_next()
if tok == endlocal then break end
@ -219,7 +220,7 @@ token.luacmd("read", function(_, prefix)
end
tokens[#tokens+1] = tok
end
if balance ~= 0 then error[[FIXME: Read additional input lines]] end
until balance == 0
tex.runlocal(function()
tokens[#tokens+1] = rbrace
token.put_next(tokens)

View File

@ -68,7 +68,7 @@ end
local undefined_cmd = token.command_id'undefined_cs'
local lua_call_cmd = token.command_id'lua_call'
local lua_value_cmd = token.command_id'lua_value'
local lua_expandable_call_cmd = token.command_id'lua_expandable_call'
local lua_protected_call_cmd = token.command_id'lua_protected_call'
local if_test_cmd = token.command_id'if_test'
function token.luacmd(name, func, ...)
local idx
@ -78,10 +78,10 @@ function token.luacmd(name, func, ...)
idx = tok.index
elseif cmd == lua_call_cmd then
idx = tok.index
elseif cmd == lua_expandable_call_cmd then
elseif cmd == lua_protected_call_cmd then
idx = tok.index
elseif cmd == if_test_cmd and tok.index > 48 then
idx = tok.index - 48
elseif cmd == if_test_cmd and tok.index > 49 then
idx = tok.index - 49
elseif ... == 'force' then
idx = new_luafunction(name)
set_lua(name, idx, select(2, ...))
@ -106,6 +106,7 @@ if initex then
local prepared = lua.prepared_code
prepared[1] = string.format("fixupluafunctions(%i)", predefined_luafunctions)
--[[
for i=0,0 do -- maybeFIXME: In practise only one language is preloaded in LuaTeX anyway
-- for i=0,tex.count[19] do -- Sometimes catches reserved language ids which are not used yet
-- for i=0,lang.new():id()-1 do -- lang.new():id() is always 0 in luametatex?!?
@ -136,6 +137,7 @@ if initex then
end
prepared[#prepared+1] = str
end
]]
for i=2,#prepared do
if type(prepared[i]) ~= 'string' then
prepared[i] = assert(prepared[i]())

View File

@ -273,7 +273,7 @@ nodehandler.math = ignore_node
nodehandler.kern = ignore_node
-- The following are only for frontend use:
nodehandler.boundary = ignore_node
nodehandler.local_par = ignore_node
nodehandler.par = ignore_node
nodehandler.penalty = ignore_node
nodehandler.mark = ignore_node