diff options
Diffstat (limited to 'Master/texmf-dist/tex/context/base/mkiv/typo-lin.lua')
-rw-r--r-- | Master/texmf-dist/tex/context/base/mkiv/typo-lin.lua | 93 |
1 files changed, 49 insertions, 44 deletions
diff --git a/Master/texmf-dist/tex/context/base/mkiv/typo-lin.lua b/Master/texmf-dist/tex/context/base/mkiv/typo-lin.lua index 8393ea65b34..ebf748a8294 100644 --- a/Master/texmf-dist/tex/context/base/mkiv/typo-lin.lua +++ b/Master/texmf-dist/tex/context/base/mkiv/typo-lin.lua @@ -64,7 +64,7 @@ local listcodes = nodes.listcodes local hlist_code = nodecodes.hlist local glue_code = nodecodes.glue local kern_code = nodecodes.kern -local linelist_code = listcodes.line +local line_code = listcodes.line ----- localpar_code = nodecodes.localpar local leftskip_code = gluecodes.leftskip local rightskip_code = gluecodes.rightskip @@ -73,7 +73,7 @@ local parfillskip_code = gluecodes.parfillskip local tonut = nodes.tonut local tonode = nodes.tonode -local nexthlist = nuts.traversers.hlist +local traverse_id = nuts.traverse_id local insert_before = nuts.insert_before local insert_after = nuts.insert_after local find_tail = nuts.tail @@ -90,7 +90,7 @@ local getboth = nuts.getboth local setlink = nuts.setlink local setkern = nuts.setkern local getkern = nuts.getkern -local getdirection = nuts.getdirection +local getdir = nuts.getdir local getshift = nuts.getshift local setshift = nuts.setshift local getwidth = nuts.getwidth @@ -109,8 +109,6 @@ local new_hlist = nodepool.hlist local new_rule = nodepool.rule local new_glue = nodepool.glue -local righttoleft_code = nodes.dirvalues.righttoleft - local texgetcount = tex.getcount local texgetglue = tex.getglue local setmetatableindex = table.setmetatableindex @@ -129,12 +127,22 @@ local noflines = 0 -- This is the third version, a mix between immediate (prestice lines) and delayed -- as we don't want anchors that are not used. +-- if reverse then delta = - delta end +-- head = insert_before(head,head,nodepool.textdir("-TLT")) +-- .... +-- head = insert_before(head,head,nodepool.textdir("TLT")) + +-- todo: figure out metatable mess ... when we copy we also need to copy +-- anchors ... use rawgets + +-- problem: what if a box is copied ... we could check an attribute + local function finalize(prop,key) -- delayed calculations local line = prop.line local hsize = prop.hsize local width = prop.width local shift = getshift(line) -- dangerous as it can be vertical as well - local reverse = getdirection(line) == righttoleft_code or false + local reverse = getdir(line) == "TRT" or false local pack = new_hlist() local head = getlist(line) local delta = 0 @@ -240,47 +248,49 @@ function paragraphs.normalize(head,islocal) return head, false end -- this can become a separate handler but it makes sense to integrate it here - local mode = texgetcount("parfillleftmode") - if mode > 0 then - local l_width, l_stretch, l_shrink = texgetglue("parfillleftskip") - if l_width ~= 0 or l_stretch ~= 0 or l_shrink ~= 0 then - local last = nil -- a nut - local done = mode == 2 -- false - for line, subtype in nexthlist, head do - if subtype == linelist_code and not getprop(line,"line") then - if done then - last = line - else - done = true - end + local l_width, l_stretch, l_shrink = texgetglue("parfillleftskip") + if l_width ~= 0 or l_stretch ~= 0 or l_shrink ~= 0 then + local last = nil -- a nut + local done = false + for line in traverse_id(hlist_code,tonut(head)) do + if getsubtype(line) == line_code and not getprop(line,"line") then + if done then + last = line + else + done = true end end - if last then -- only if we have more than one line - local head = getlist(last) - local current = head + end + if last then -- only if we have more than one line + local head = getlist(last) + local current = head + if current then + if getid(current) == glue_code and getsubtype(current,leftskip_code) then + current = getnext(current) + end if current then - if getid(current) == glue_code and getsubtype(current,leftskip_code) then - current = getnext(current) - end - if current then - head, current = insert_before(head,current,new_glue(l_width,l_stretch,l_shrink)) - if head == current then - setlist(last,head) - end - -- can be a 'rehpack(h )' - rehpack(last) + head, current = insert_before(head,current,new_glue(l_width,l_stretch,l_shrink)) + if head == current then + setlist(last,head) end + -- can be a 'rehpack(h )' + rehpack(last) end end end end -- normalizer - for line, subtype in nexthlist, head do - if subtype == linelist_code and not getprop(line,"line") then + for line in traverse_id(hlist_code,tonut(head)) do + if getsubtype(line) == line_code and not getprop(line,"line") then normalize(line) + if done then + last = line + else + done = true + end end end - return head, true -- true is obsolete + return head, true end -- print(nodes.idstostring(head)) @@ -408,17 +418,12 @@ function paragraphs.moveinline(n,blob,dx,dy) end end -local latelua = nodepool.latelua -local setposition = jobpositions.setspec -local t_anchor = { x = true, c = true } -- needs checking +local lateluafunction = nodepool.lateluafunction +local setposition = job.positions.set +local t_anchor = { x = true, c = true } local function setanchor(h_anchor) - return latelua { - action = setposition, - name = "md:h", - index = h_anchor, - value = t_anchor, -- really shared ? - } + return lateluafunction(function() setposition("md:h",h_anchor,t_anchor) end) end function paragraphs.calculatedelta(n,width,delta,atleft,islocal,followshape,area) |