diff options
author | Karl Berry <karl@freefriends.org> | 2020-03-05 00:48:46 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2020-03-05 00:48:46 +0000 |
commit | f210bce174e1f2f05305ab03e88e120a1cbfc4da (patch) | |
tree | 5c4e2ad096b5c745e859516ac3196fa0864292d5 /Master/texmf-dist/tex/context/base/mkiv/back-ini.lua | |
parent | 35fd641a3546acc0c62e0aa7f134888e36da30d4 (diff) |
context (from cont-tmf.zip of Feb 17 16:00, size 116339406)
git-svn-id: svn://tug.org/texlive/trunk@54086 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/tex/context/base/mkiv/back-ini.lua')
-rw-r--r-- | Master/texmf-dist/tex/context/base/mkiv/back-ini.lua | 162 |
1 files changed, 29 insertions, 133 deletions
diff --git a/Master/texmf-dist/tex/context/base/mkiv/back-ini.lua b/Master/texmf-dist/tex/context/base/mkiv/back-ini.lua index b7af1529b71..b0af61edcd8 100644 --- a/Master/texmf-dist/tex/context/base/mkiv/back-ini.lua +++ b/Master/texmf-dist/tex/context/base/mkiv/back-ini.lua @@ -8,31 +8,21 @@ if not modules then modules = { } end modules ['back-ini'] = { local next, type = next, type local format = string.format -local sind, cosd, abs = math.sind, math.cosd, math.abs -local insert, remove = table.insert, table.remove -local unpack = unpack backends = backends or { } local backends = backends -local trace_backend = false trackers.register("backend.initializers", function(v) trace_finalizers = v end) +local context = context +local trace = false trackers.register("backend", function(v) trace = v end) local report = logs.reporter("backend") -local report_backend = logs.reporter("backend","initializing") local allocate = utilities.storage.allocate local setmetatableindex = table.setmetatableindex local setaction = nodes.tasks.setaction -local scanners = tokens.scanners -local scannumber = scanners.number -local scankeyword = scanners.keyword -local scancount = scanners.count -local scanstring = scanners.string - -local scanners = interfaces.scanners - local implement = interfaces.implement +local variables = interfaces.variables local texset = tex.set @@ -76,7 +66,7 @@ local lmtx_mode = nil local function lmtxmode() if lmtx_mode == nil then - lmtx_mode = ((tonumber(CONTEXTLMTXMODE) or 0) > 0) and drivers and drivers.lmtxversion + lmtx_mode = CONTEXTLMTXMODE > 0 and drivers and drivers.lmtxversion end return lmtx_mode end @@ -87,11 +77,11 @@ function backends.install(what) if type(what) == "string" then local backend = backends[what] if backend then - if trace_backend then + if trace then if backend.comment then - report_backend("initializing backend %a, %a",what,backend.comment) + report("initializing backend %a, %a",what,backend.comment) else - report_backend("initializing backend %a",what) + report("initializing backend %a",what) end end backends.current = what @@ -101,8 +91,8 @@ function backends.install(what) setmetatableindex(plugin, default) setmetatableindex(target, plugin) end - elseif trace_backend then - report_backend("no backend named %a",what) + elseif trace then + report("no backend named %a",what) end end end @@ -139,7 +129,7 @@ interfaces.implement { name = "setrealspaces", arguments = "string", actions = function(v) - setaction("shipouts","nodes.handlers.accessibility",v == interfaces.variables.yes) + setaction("shipouts","nodes.handlers.accessibility",v == variables.yes) end } @@ -192,125 +182,31 @@ implement { end } --- could also be codeinjections - -function backends.noflatelua() - return status.late_callbacks or 0 -end - --- - -local stack = { } -local restore = true -- false -local nodepool = nodes.pool -local savenode = nodepool.save -local restorenode = nodepool.restore -local setmatrixnode = nodepool.setmatrix +local page_x_origin = 0 +local page_y_origin = 0 -updaters.register("backend.update",function() - savenode = nodepool.save - restorenode = nodepool.restore - setmatrixnode = nodepool.setmatrix -end) - -local function stopsomething() - local top = remove(stack) - if top == false then - -- not wrapped - elseif top == true then - context(restorenode()) - elseif top then - context(setmatrixnode(unpack(top))) -- not really needed anymore - context(restorenode()) - else - -- nesting error - end -end - -local function startrotation() - local a = scannumber() - if a == 0 then - insert(stack,false) - else - local s, c = sind(a), cosd(a) - if abs(s) < 0.000001 then - s = 0 -- otherwise funny -0.00000 - end - if abs(c) < 0.000001 then - c = 0 -- otherwise funny -0.00000 - end - context(savenode()) - context(setmatrixnode(c,s,-s,c)) - insert(stack,restore and { c, -s, s, c } or true) - end +function codeinjections.setpageorigin(x,y) + page_x_origin = x + page_y_origin = y end -implement { name = "startrotation", actions = startrotation } -implement { name = "stoprotation", actions = stopsomething } - -local function startscaling() -- at the tex end we use sx and sy instead of rx and ry - local rx, ry = 1, 1 - while true do - if scankeyword("rx") then - rx = scannumber() - elseif scankeyword("ry") then - ry = scannumber() - -- elseif scankeyword("revert") then - -- local top = stack[#stack] - -- if top then - -- rx = top[1] - -- ry = top[4] - -- else - -- rx = 1 - -- ry = 1 - -- end - else - break - end - end - if rx == 1 and ry == 1 then - insert(stack,false) - else - if rx == 0 then - rx = 0.0001 - end - if ry == 0 then - ry = 0.0001 - end - context(savenode()) - context(setmatrixnode(rx,0,0,ry)) - insert(stack,restore and { 1/rx, 0, 0, 1/ry } or true) - end +function codeinjections.getpageorigin() + local x = page_x_origin + local y = page_y_origin + page_x_origin = 0 + page_y_origin = 0 + return x, y, (x ~= 0 or y ~= 0) end -implement { name = "startscaling", actions = startscaling } -implement { name = "stopscaling", actions = stopsomething } - -local function startmatrix() -- rx sx sy ry -- tx, ty - local rx, sx, sy, ry = 1, 0, 0, 1 - while true do - if scankeyword("rx") then rx = scannumber() - elseif scankeyword("ry") then ry = scannumber() - elseif scankeyword("sx") then sx = scannumber() - elseif scankeyword("sy") then sy = scannumber() - else break end - end - if rx == 1 and sx == 0 and sy == 0 and ry == 1 then - insert(stack,false) - else - context(savenode()) - context(setmatrixnode(rx,sx,sy,ry)) - insert(stack,store and { -rx, -sx, -sy, -ry } or true) - end -end +implement { + name = "setpageorigin", + arguments = { "dimension", "dimension" }, + actions = codeinjections.setpageorigin, +} -implement { name = "startmatrix", actions = startmatrix } -implement { name = "stopmatrix", actions = stopsomething } +-- could also be codeinjections -local function startmirroring() - context(setmatrixnode(-1,0,0,1)) +function backends.noflatelua() + return status.late_callbacks or 0 end - -implement { name = "startmirroring", actions = startmirroring } -implement { name = "stopmirroring", actions = startmirroring } -- not: stopsomething |