summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/context/base/mkiv/node-rul.lua
diff options
context:
space:
mode:
Diffstat (limited to 'Master/texmf-dist/tex/context/base/mkiv/node-rul.lua')
-rw-r--r--Master/texmf-dist/tex/context/base/mkiv/node-rul.lua111
1 files changed, 64 insertions, 47 deletions
diff --git a/Master/texmf-dist/tex/context/base/mkiv/node-rul.lua b/Master/texmf-dist/tex/context/base/mkiv/node-rul.lua
index 1df5bf32ae7..b904e54d616 100644
--- a/Master/texmf-dist/tex/context/base/mkiv/node-rul.lua
+++ b/Master/texmf-dist/tex/context/base/mkiv/node-rul.lua
@@ -22,7 +22,7 @@ local tonumber = tonumber
local context = context
local attributes = attributes
local nodes = nodes
-local properties = nodes.properties
+local properties = nodes.properties.data
local enableaction = nodes.tasks.enableaction
@@ -30,7 +30,6 @@ local nuts = nodes.nuts
local tonode = nuts.tonode
local tonut = nuts.tonut
-local getfield = nuts.getfield
local setnext = nuts.setnext
local setprev = nuts.setprev
local setlink = nuts.setlink
@@ -50,7 +49,10 @@ local getwidth = nuts.getwidth
local setwidth = nuts.setwidth
local setoffsets = nuts.setoffsets
local setfield = nuts.setfield
-local getdata = nuts.getdata
+
+----- getfield = nuts.getfield
+----- getdata = nuts.getdata
+local getruledata = nuts.getruledata
local isglyph = nuts.isglyph
@@ -122,6 +124,9 @@ local dimenfactor = fonts.helpers.dimenfactor
local splitdimen = number.splitdimen
local setmetatableindex = table.setmetatableindex
+local magicconstants = tex.magicconstants
+local running = magicconstants.running
+
--
local striprange = nuts.striprange
@@ -166,7 +171,7 @@ rules .ruleactions = ruleactions
nutrules.ruleactions = ruleactions -- convenient
local function mathaction(n,h,v,what)
- local font = CONTEXTLMTXMODE > 1 and getdata(n) or getfield(n,"transform")
+ local font = getruledata(n)
local actions = fontresources[font].mathruleactions
if actions then
local action = actions[what]
@@ -184,6 +189,8 @@ local function mathrule(n,h,v)
mathaction(n,h,v,"hruleaction")
end
+local x
+
local function useraction(n,h,v)
local p = properties[n]
if p then
@@ -222,7 +229,7 @@ local trace_ruled = false trackers.register("nodes.rules", function(v) trace_
local report_ruled = logs.reporter("nodes","rules")
function rules.define(settings)
- local nofdata = #data+1
+ local nofdata = #data + 1
data[nofdata] = settings
local text = settings.text
if text then
@@ -234,7 +241,7 @@ function rules.define(settings)
settings.text = nil
end
end
- context(nofdata)
+ return nofdata
end
local function flush_ruled(head,f,l,d,level,parent,strip) -- not that fast but acceptable for this purpose
@@ -263,7 +270,7 @@ local function flush_ruled(head,f,l,d,level,parent,strip) -- not that fast but a
if not f then
return head
end
- local w, ht, dp = getrangedimensions(parent,f,getnext(l))
+ local wd, ht, dp = getrangedimensions(parent,f,getnext(l))
local method = d.method
local empty = d.empty == v_yes
local offset = d.offset
@@ -304,7 +311,7 @@ local function flush_ruled(head,f,l,d,level,parent,strip) -- not that fast but a
m = 0
end
- local function inject(r,w,ht,dp)
+ local function inject(r,wd,ht,dp)
if layer then
setattr(r,a_viewerlayer,layer)
end
@@ -315,7 +322,7 @@ local function flush_ruled(head,f,l,d,level,parent,strip) -- not that fast but a
setnext(l)
flushlist(f)
else
- local k = new_kern(-w)
+ local k = new_kern(-wd)
if foreground then
insert_node_after(head,l,k)
insert_node_after(head,k,r)
@@ -327,12 +334,12 @@ local function flush_ruled(head,f,l,d,level,parent,strip) -- not that fast but a
end
if trace_ruled then
report_ruled("level %a, width %p, height %p, depth %p, nodes %a, text %a",
- level,w,ht,dp,n_tostring(f,l),n_tosequence(f,l,true))
+ level,wd,ht,dp,n_tostring(f,l),n_tosequence(f,l,true))
end
end
if mp and mp ~= "" then
local r = usernutrule {
- width = w,
+ width = wd,
height = ht,
depth = dp,
type = "mp",
@@ -344,22 +351,26 @@ local function flush_ruled(head,f,l,d,level,parent,strip) -- not that fast but a
ca = color,
ta = transparency,
}
- inject(r,w,ht,dp)
+ inject(r,wd,ht,dp)
else
local tx = d.text
if tx then
local l = copy_list(tx)
if d["repeat"] == v_yes then
- l = new_leader(w,l)
+ l = new_leader(wd,l)
setattrlist(l,tx)
end
- l = hpack_nodes(l,w,"exactly")
- inject(l,w,ht,dp)
+ l = hpack_nodes(l,wd,"exactly")
+ inject(l,wd,ht,dp)
else
for i=1,level do
- local ht = (offset+(i-1)*dy)*e + rulethickness - m
- local dp = -(offset+(i-1)*dy)*e + rulethickness + m
- local r = new_rule(w,ht,dp)
+ local hd = (offset+(i-1)*dy)*e - m
+-- local ht = hd + rulethickness - m
+-- local dp = -hd + rulethickness + m
+ local ht = hd + rulethickness
+ local dp = -hd + rulethickness
+ local r = new_rule(wd,ht,dp)
+ -- can be done more efficient
if color then
setattr(r,a_colormodel,colorspace)
setattr(r,a_color,color)
@@ -367,7 +378,7 @@ local function flush_ruled(head,f,l,d,level,parent,strip) -- not that fast but a
if transparency then
setattr(r,a_transparency,transparency)
end
- inject(r,w,ht,dp)
+ inject(r,wd,ht,dp)
end
end
end
@@ -388,16 +399,18 @@ local report_shifted = logs.reporter("nodes","shifting")
local a_shifted = attributes.private('shifted')
-nodes.shifts = nodes.shifts or { }
-nodes.shifts.data = nodes.shifts.data or { }
+local shifts = nodes.shifts or { }
+nodes.shifts = shifts
+shifts.data = shifts.data or { }
-storage.register("nodes/shifts/data", nodes.shifts.data, "nodes.shifts.data")
+storage.register("nodes/shifts/data", shifts.data, "nodes.shifts.data")
-local data = nodes.shifts.data
+local data = shifts.data
-function nodes.shifts.define(settings)
- data[#data+1] = settings
- context(#data)
+function shifts.define(settings)
+ local nofdata = #data + 1
+ data[nofdata] = settings
+ return nofdata
end
local function flush_shifted(head,first,last,data,level,parent,strip) -- not that fast but acceptable for this purpose
@@ -428,26 +441,28 @@ local function flush_shifted(head,first,last,data,level,parent,strip) -- not tha
return head
end
-nodes.shifts.handler = function(head)
+shifts.handler = function(head)
return processwords(a_shifted,data,flush_shifted,head)
end
-function nodes.shifts.enable()
+function shifts.enable()
enableaction("shipouts","nodes.shifts.handler")
end
-- linefillers
-nodes.linefillers = nodes.linefillers or { }
-nodes.linefillers.data = nodes.linefillers.data or { }
+local linefillers = nodes.linefillers or { }
+nodes.linefillers = linefillers
+linefillers.data = linefillers.data or { }
-storage.register("nodes/linefillers/data", nodes.linefillers.data, "nodes.linefillers.data")
+storage.register("nodes/linefillers/data", linefillers.data, "nodes.linefillers.data")
-local data = nodes.linefillers.data
+local data = linefillers.data
-function nodes.linefillers.define(settings)
- data[#data+1] = settings
- context(#data)
+function linefillers.define(settings)
+ local nofdata = #data + 1
+ data[nofdata] = settings
+ return nofdata
end
local function linefiller(current,data,width,location)
@@ -484,7 +499,7 @@ local function linefiller(current,data,width,location)
end
end
-function nodes.linefillers.filler(current,data,width,height,depth)
+function linefillers.filler(current,data,width,height,depth)
if width and width > 0 then
local height = height or data.height or 0
local depth = depth or data.depth or 0
@@ -532,9 +547,9 @@ local function find_attr(head,attr)
end
end
-function nodes.linefillers.handler(head)
- for current, subtype, list in nexthlist, head do
- if list and subtype == linelist_code then
+function linefillers.handler(head)
+ for current, subtype in nexthlist, head do
+ if current and subtype == linelist_code then
-- why doesn't leftskip take the attributes
-- or list[linefiller] or maybe first match (maybe we need a fast helper for that)
local a = getattr(current,a_linefiller)
@@ -558,6 +573,8 @@ function nodes.linefillers.handler(head)
rightlocal = true
end
--
+ local list = getlist(current)
+ --
if location == v_left or location == v_both then
local lskip = nil -- leftskip
local iskip = nil -- indentation
@@ -656,7 +673,7 @@ end
local enable = false
-function nodes.linefillers.enable()
+function linefillers.enable()
if not enable then
-- we could now nil it
enableaction("finalizers","nodes.linefillers.handler")
@@ -698,7 +715,7 @@ implement {
implement {
name = "defineshift",
- actions = { nodes.shifts.define, context },
+ actions = { shifts.define, context },
arguments = {
{
{ "continue" },
@@ -712,12 +729,12 @@ implement {
implement {
name = "enableshifts",
onlyonce = true,
- actions = nodes.shifts.enable
+ actions = shifts.enable
}
implement {
name = "definelinefiller",
- actions = { nodes.linefillers.define, context },
+ actions = { linefillers.define, context },
arguments = {
{
{ "method", "integer" },
@@ -739,7 +756,7 @@ implement {
implement {
name = "enablelinefillers",
onlyonce = true,
- actions = nodes.linefillers.enable
+ actions = linefillers.enable
}
-- We add a bonus feature here (experiment):
@@ -759,9 +776,9 @@ interfaces.implement {
},
actions = function(t)
local n = new_rule(
- t.width,
- t.height,
- t.depth
+ t.width or running,
+ t.height or running,
+ t.depth or running
)
setattrlist(n,true)
setoffsets(n,t.xoffset,t.yoffset) -- ,t.left, t.right