summaryrefslogtreecommitdiff
path: root/tex/context/base/node-rul.lua
diff options
context:
space:
mode:
Diffstat (limited to 'tex/context/base/node-rul.lua')
-rw-r--r--tex/context/base/node-rul.lua125
1 files changed, 78 insertions, 47 deletions
diff --git a/tex/context/base/node-rul.lua b/tex/context/base/node-rul.lua
index 96d6bdf41..6f3bc9df9 100644
--- a/tex/context/base/node-rul.lua
+++ b/tex/context/base/node-rul.lua
@@ -13,12 +13,28 @@ if not modules then modules = { } end modules ['node-rul'] = {
local attributes, nodes, node = attributes, nodes, node
-local nodecodes = nodes.nodecodes
-local tasks = nodes.tasks
-
-local glyph_code = nodecodes.glyph
-local disc_code = nodecodes.disc
-local rule_code = nodecodes.rule
+local nuts = nodes.nuts
+local tonode = nuts.tonode
+local tonut = nuts.tonut
+
+local getfield = nuts.getfield
+local setfield = nuts.setfield
+local getnext = nuts.getnext
+local getprev = nuts.getprev
+local getid = nuts.getid
+local getattr = nuts.getattr
+local setattr = nuts.setattr
+local getfont = nuts.getfont
+local getsubtype = nuts.getsubtype
+local getchar = nuts.getchar
+local getlist = nuts.getlist
+
+local nodecodes = nodes.nodecodes
+local tasks = nodes.tasks
+
+local glyph_code = nodecodes.glyph
+local disc_code = nodecodes.disc
+local rule_code = nodecodes.rule
function nodes.striprange(first,last) -- todo: dir
if first and last then -- just to be sure
@@ -26,11 +42,11 @@ function nodes.striprange(first,last) -- todo: dir
return first, last
end
while first and first ~= last do
- local id = first.id
+ local id = getid(first)
if id == glyph_code or id == disc_code then -- or id == rule_code
break
else
- first = first.next
+ first = getnext(first)
end
end
if not first then
@@ -39,13 +55,13 @@ function nodes.striprange(first,last) -- todo: dir
return first, last
end
while last and last ~= first do
- local id = last.id
+ local id = getid(last)
if id == glyph_code or id == disc_code then -- or id == rule_code
break
else
- local prev = last.prev -- luatex < 0.70 has italic correction kern not prev'd
+ local prev = getprev(last) -- luatex < 0.70 has italic correction kern not prev'd
if prev then
- last = last.prev
+ last = prev
else
break
end
@@ -73,12 +89,12 @@ local a_color = attributes.private('color')
local a_transparency = attributes.private('transparency')
local a_colorspace = attributes.private('colormodel')
-local insert_node_before = node.insert_before
-local insert_node_after = node.insert_after
-local striprange = nodes.striprange
-local list_dimensions = node.dimensions
+local insert_node_before = nuts.insert_before
+local insert_node_after = nuts.insert_after
+local list_dimensions = nuts.dimensions
+local hpack_nodes = nuts.hpack
-local hpack_nodes = node.hpack
+local striprange = nodes.striprange
local fontdata = fonts.hashes.identifiers
local variables = interfaces.variables
@@ -111,7 +127,7 @@ local dir_code = whatcodes.dir
local kerning_code = kerncodes.kern
-local nodepool = nodes.pool
+local nodepool = nuts.pool
local new_rule = nodepool.rule
local new_kern = nodepool.kern
@@ -141,9 +157,9 @@ local function processwords(attribute,data,flush,head,parent) -- we have hlistdi
local f, l, a, d, i, class
local continue, done, strip, level = false, false, true, -1
while n do
- local id = n.id
+ local id = getid(n)
if id == glyph_code or id == rule_code then
- local aa = n[attribute]
+ local aa = getattr(n,attribute)
if aa then
if aa == a then
if not f then -- ?
@@ -172,13 +188,13 @@ local function processwords(attribute,data,flush,head,parent) -- we have hlistdi
end
f, l, a = nil, nil, nil
end
--- elseif f and (id == disc_code or (id == kern_code and n.subtype == kerning_code)) then
+-- elseif f and (id == disc_code or (id == kern_code and getsubtype(n) == kerning_code)) then
-- l = n
elseif id == disc_code then
if f then
l = n
end
- elseif id == kern_code and n.subtype == kerning_code then
+ elseif id == kern_code and getsubtype(n) == kerning_code then
if f then
l = n
end
@@ -187,11 +203,11 @@ local function processwords(attribute,data,flush,head,parent) -- we have hlistdi
head, done = flush(head,f,l,d,level,parent,strip), true
f, l, a = nil, nil, nil
end
- local list = n.list
+ local list = getlist(n)
if list then
- n.list = processwords(attribute,data,flush,list,n)
+ setfield(n,"list",(processwords(attribute,data,flush,list,n))) -- watch ()
end
- elseif checkdir and id == whatsit_code and n.subtype == dir_code then -- only changes in dir, we assume proper boundaries
+ elseif checkdir and id == whatsit_code and getsubtype(n) == dir_code then -- only changes in dir, we assume proper boundaries
if f and a then
l = n
end
@@ -203,8 +219,8 @@ local function processwords(attribute,data,flush,head,parent) -- we have hlistdi
-- l = n
elseif id == glue_code then
-- catch \underbar{a} \underbar{a} (subtype test is needed)
- local subtype = n.subtype
- if n[attribute] and (subtype == userskip_code or subtype == spaceskip_code or subtype == xspaceskip_code) then
+ local subtype = getsubtype(n)
+ if getattr(n,attribute) and (subtype == userskip_code or subtype == spaceskip_code or subtype == xspaceskip_code) then
l = n
else
head, done = flush(head,f,l,d,level,parent,strip), true
@@ -216,7 +232,7 @@ local function processwords(attribute,data,flush,head,parent) -- we have hlistdi
f, l, a = nil, nil, nil
end
end
- n = n.next
+ n = getnext(n)
end
if f then
head, done = flush(head,f,l,d,level,parent,strip), true
@@ -227,7 +243,16 @@ local function processwords(attribute,data,flush,head,parent) -- we have hlistdi
end
end
-nodes.processwords = processwords
+-- nodes.processwords = processwords
+
+nodes.processwords = function(attribute,data,flush,head,parent) -- we have hlistdir and local dir
+ head = tonut(head)
+ if parent then
+ parent = tonut(parent)
+ end
+ local head, done = processwords(attribute,data,flush,head,parent)
+ return tonode(head), done
+end
--
@@ -246,7 +271,7 @@ end
local a_viewerlayer = attributes.private("viewerlayer")
local function flush_ruled(head,f,l,d,level,parent,strip) -- not that fast but acceptable for this purpose
- if f.id ~= glyph_code then
+ if getid(f) ~= glyph_code then
-- saveguard ... we need to deal with rules and so (math)
return head
end
@@ -264,16 +289,16 @@ 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 = list_dimensions(parent.glue_set,parent.glue_sign,parent.glue_order,f,l.next)
+ local w = list_dimensions(getfield(parent,"glue_set"),getfield(parent,"glue_sign"),getfield(parent,"glue_order"),f,getnext(l))
local method, offset, continue, dy, order, max = d.method, d.offset, d.continue, d.dy, d.order, d.max
local rulethickness, unit = d.rulethickness, d.unit
local ma, ca, ta = d.ma, d.ca, d.ta
- local colorspace = ma > 0 and ma or f[a_colorspace] or 1
- local color = ca > 0 and ca or f[a_color]
- local transparency = ta > 0 and ta or f[a_transparency]
+ local colorspace = ma > 0 and ma or getattr(f,a_colorspace) or 1
+ local color = ca > 0 and ca or getattr(f,a_color)
+ local transparency = ta > 0 and ta or getattr(f,a_transparency)
local foreground = order == v_foreground
- local e = dimenfactor(unit,f.font) -- what if no glyph node
+ local e = dimenfactor(unit,getfont(f)) -- what if no glyph node
local rt = tonumber(rulethickness)
if rt then
@@ -281,7 +306,7 @@ local function flush_ruled(head,f,l,d,level,parent,strip) -- not that fast but a
else
local n, u = splitdimen(rulethickness)
if n and u then -- we need to intercept ex and em and % and ...
- rulethickness = n * dimenfactor(u,fontdata[f.font]) / 2
+ rulethickness = n * dimenfactor(u,fontdata[getfont(f)]) / 2
else
rulethickness = 1/5
end
@@ -300,18 +325,18 @@ local function flush_ruled(head,f,l,d,level,parent,strip) -- not that fast but a
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 v = f[a_viewerlayer]
+ local v = getattr(f,a_viewerlayer)
-- quick hack
if v then
- r[a_viewerlayer] = v
+ setattr(r,a_viewerlayer,v)
end
--
if color then
- r[a_colorspace] = colorspace
- r[a_color] = color
+ setattr(r,a_colorspace,colorspace)
+ setattr(r,a_color,color)
end
if transparency then
- r[a_transparency] = transparency
+ setattr(r,a_transparency,transparency)
end
local k = new_kern(-w)
if foreground then
@@ -365,21 +390,27 @@ local function flush_shifted(head,first,last,data,level,parent,strip) -- not tha
if true then
first, last = striprange(first,last)
end
- local prev, next = first.prev, last.next
- first.prev, last.next = nil, nil
- local width, height, depth = list_dimensions(parent.glue_set,parent.glue_sign,parent.glue_order,first,next)
+ local prev = getprev(first)
+ local next = getnext(last)
+ setfield(first,"prev",nil)
+ setfield(last,"next",nil)
+ local width, height, depth = list_dimensions(getfield(parent,"glue_set"),getfield(parent,"glue_sign"),getfield(parent,"glue_order"),first,next)
local list = hpack_nodes(first,width,"exactly")
if first == head then
head = list
end
if prev then
- prev.next, list.prev = list, prev
+ setfield(prev,"next",list)
+ setfield(list,"prev",prev)
end
if next then
- next.prev, list.next = list, next
+ setfield(next,"prev",list)
+ setfield(list,"next",next)
end
- local raise = data.dy * dimenfactor(data.unit,fontdata[first.font])
- list.shift, list.height, list.depth = raise, height, depth
+ local raise = data.dy * dimenfactor(data.unit,fontdata[getfont(first)])
+ setfield(list,"shift",raise)
+ setfield(list,"height",height)
+ setfield(list,"depth",depth)
if trace_shifted then
report_shifted("width %p, nodes %a, text %a",width,n_tostring(first,last),n_tosequence(first,last,true))
end