diff options
author | Context Git Mirror Bot <phg42.2a@gmail.com> | 2014-05-03 13:55:34 +0200 |
---|---|---|
committer | Context Git Mirror Bot <phg42.2a@gmail.com> | 2014-05-03 13:55:34 +0200 |
commit | 624cbb5da392e9403984dd1cf368c0d408b1c2a8 (patch) | |
tree | 489c049ac849bb5bbce7d32e4df477872c58373d /tex/context/base/pack-rul.lua | |
parent | 088de88944c1f2254250bb448c7371a87ff7ee39 (diff) | |
download | context-624cbb5da392e9403984dd1cf368c0d408b1c2a8.tar.gz |
2014-01-03 00:42:00
Diffstat (limited to 'tex/context/base/pack-rul.lua')
-rw-r--r-- | tex/context/base/pack-rul.lua | 71 |
1 files changed, 31 insertions, 40 deletions
diff --git a/tex/context/base/pack-rul.lua b/tex/context/base/pack-rul.lua index c8ed0722b..329ea63b8 100644 --- a/tex/context/base/pack-rul.lua +++ b/tex/context/base/pack-rul.lua @@ -21,25 +21,15 @@ local line_code = nodes.listcodes.line local texsetdimen = tex.setdimen local texsetcount = tex.setcount - -local nuts = nodes.nuts - -local getfield = nuts.getfield -local setfield = nuts.setfield -local getnext = nuts.getnext -local getprev = nuts.getprev -local getlist = nuts.getlist -local getsubtype = nuts.getsubtype -local getbox = nuts.getbox - -local hpack = nuts.hpack -local free = nuts.free -local copy = nuts.copy_list -local traverse_id = nuts.traverse_id -local node_dimensions = nuts.dimensions +local texgetbox = tex.getbox +local hpack = nodes.hpack +local free = nodes.free +local copy = nodes.copy_list +local traverse_id = nodes.traverse_id +local node_dimensions = nodes.dimensions function commands.doreshapeframedbox(n) - local box = getbox(n) + local box = texgetbox(n) local noflines = 0 local firstheight = nil local lastdepth = nil @@ -48,27 +38,27 @@ function commands.doreshapeframedbox(n) local maxwidth = 0 local totalwidth = 0 local averagewidth = 0 - local boxwidth = getfield(box,"width") + local boxwidth = box.width if boxwidth ~= 0 then -- and h.subtype == vlist_code - local list = getlist(box) + local list = box.list if list then local function check(n,repack) if not firstheight then - firstheight = getfield(n,"height") + firstheight = n.height end - lastdepth = getfield(n,"depth") + lastdepth = n.depth noflines = noflines + 1 - local l = getlist(n) + local l = n.list if l then if repack then - local subtype = getsubtype(n) + local subtype = n.subtype if subtype == box_code or subtype == line_code then - lastlinelength = node_dimensions(l,getfield(n,"dir")) -- used to be: hpack(copy(l)).width + lastlinelength = node_dimensions(l,n.dir) -- used to be: hpack(copy(l)).width else - lastlinelength = getfield(n,"width") + lastlinelength = n.width end else - lastlinelength = getfield(n,"width") + lastlinelength = n.width end if lastlinelength > maxwidth then maxwidth = lastlinelength @@ -94,27 +84,28 @@ function commands.doreshapeframedbox(n) elseif maxwidth ~= 0 then if hdone then for h in traverse_id(hlist_code,list) do - local l = getlist(h) + local l = h.list if l then - local subtype = getsubtype(h) + local subtype = h.subtype if subtype == box_code or subtype == line_code then - l = hpack(l,maxwidth,'exactly',getfield(h,"dir")) -- multiple return values - setfield(h,"list",l) - setfield(h,"shift",0) -- needed for display math, so no width check possible + h.list = hpack(l,maxwidth,'exactly',h.dir) + h.shift = 0 -- needed for display math end - setfield(h,"width",maxwidth) + h.width = maxwidth end end + box.width = maxwidth -- moved + averagewidth = noflines > 0 and totalwidth/noflines or 0 end -- if vdone then -- for v in traverse_id(vlist_code,list) do - -- local width = getfield(n,"width") + -- local width = n.width -- if width > maxwidth then - -- setfield(v,"width",maxwidth) + -- v.width = maxwidth -- end -- end -- end - setfield(box,"width",maxwidth) + box.width = maxwidth averagewidth = noflines > 0 and totalwidth/noflines or 0 end end @@ -128,18 +119,18 @@ function commands.doreshapeframedbox(n) end function commands.doanalyzeframedbox(n) - local box = getbox(n) + local box = texgetbox(n) local noflines = 0 local firstheight = nil local lastdepth = nil - if getfield(box,"width") ~= 0 then - local list = getlist(box) + if box.width ~= 0 then + local list = box.list if list then local function check(n) if not firstheight then - firstheight = getfield(n,"height") + firstheight = n.height end - lastdepth = getfield(n,"depth") + lastdepth = n.depth noflines = noflines + 1 end for h in traverse_id(hlist_code,list) do |