diff options
Diffstat (limited to 'Master/texmf-dist/tex/context/base/mkiv/node-ref.lua')
-rw-r--r-- | Master/texmf-dist/tex/context/base/mkiv/node-ref.lua | 248 |
1 files changed, 36 insertions, 212 deletions
diff --git a/Master/texmf-dist/tex/context/base/mkiv/node-ref.lua b/Master/texmf-dist/tex/context/base/mkiv/node-ref.lua index e12bd95bdd6..ac43a84a368 100644 --- a/Master/texmf-dist/tex/context/base/mkiv/node-ref.lua +++ b/Master/texmf-dist/tex/context/base/mkiv/node-ref.lua @@ -77,6 +77,7 @@ local getdimensions = nuts.dimensions local getrangedimensions = nuts.rangedimensions local traverse = nuts.traverse local find_node_tail = nuts.tail +local start_of_par = nuts.start_of_par local nodecodes = nodes.nodecodes local gluecodes = nodes.gluecodes @@ -166,33 +167,33 @@ local function dimensions(parent,start,stop) -- in principle we could move some -- todo: if no prev and no next and parent -- todo: we need a a list_dimensions for a vlist if getid(parent) == vlist_code then - if false then - local l = getlist(parent) - local c = l - local ok = false - while c do - if c == start then - ok = true - end - if ok and getid(c) == hlist_code then - break - else - c = getnext(c) - end - end - if ok and c then - if trace_areas then - report_area("dimensions taken of first line in vlist") - end - local w, h, d = getwhd(c) - return w, h, d, c - else - if trace_areas then - report_area("dimensions taken of vlist (probably wrong)") - end - return hlist_dimensions(start,stop,parent) - end - else + -- if false then + -- local l = getlist(parent) + -- local c = l + -- local ok = false + -- while c do + -- if c == start then + -- ok = true + -- end + -- if ok and getid(c) == hlist_code then + -- break + -- else + -- c = getnext(c) + -- end + -- end + -- if ok and c then + -- if trace_areas then + -- report_area("dimensions taken of first line in vlist") + -- end + -- local w, h, d = getwhd(c) + -- return w, h, d, c + -- else + -- if trace_areas then + -- report_area("dimensions taken of vlist (probably wrong)") + -- end + -- return hlist_dimensions(start,stop,parent) + -- end + -- else -- -- we can as well calculate here because we only have kerns and glue -- @@ -200,7 +201,7 @@ local function dimensions(parent,start,stop) -- in principle we could move some local last = nil local current = start local noflines = 0 - while current do + while current do -- can be loop local id = getid(current) if id == hlist_code or id == vlist_code or id == rule_code then if noflines == 0 then @@ -239,7 +240,7 @@ local function dimensions(parent,start,stop) -- in principle we could move some return hlist_dimensions(start,stop,parent) end end - end + -- end else if trace_areas then report_area("dimensions taken of range starting with %a using parent",nodecodes[id]) @@ -258,7 +259,7 @@ local function inject_range(head,first,last,reference,make,stack,parent,pardir,t local width, height, depth, line = dimensions(parent,first,last) if txtdir == righttoleft_code then width = - width - elseif textdir == lefttoright_code then + elseif txtdir == lefttoright_code then -- go on elseif pardir == righttoleft_code then width = - width @@ -374,6 +375,9 @@ end -- where we can end up with a first and last spanning lines so maybe -- we need to do vlists differently +-- todo: no need for dir here if we inject in the right spot as then we can +-- pick up the dir elsewhere (in lmtx) + local function inject_areas(head,attribute,make,stack,done,skip,parent,pardir,txtdir) -- main local first, last, firstdir, reference local current = head @@ -383,9 +387,6 @@ local function inject_areas(head,attribute,make,stack,done,skip,parent,pardir,tx local r = getattr(current,attribute) -- test \goto{test}[page(2)] test \gotobox{test}[page(2)] -- test \goto{\TeX}[page(2)] test \gotobox{\hbox {x} \hbox {x}}[page(2)] - -- if r and (not skip or r >) skip then -- maybe no > test - -- inject_list(id,current,r,make,stack,pardir,txtdir) - -- end if r then if not reference then reference, first, last, firstdir = r, current, current, txtdir @@ -419,7 +420,7 @@ local function inject_areas(head,attribute,make,stack,done,skip,parent,pardir,tx local direction, pop = getdirection(current) txtdir = not pop and direction -- we might need a stack elseif id == localpar_code then - if getsubtype(current) == 0 then + if start_of_par(current) then pardir = getdirection(current) end else @@ -447,182 +448,6 @@ local function inject_areas(head,attribute,make,stack,done,skip,parent,pardir,tx return head, pardir, txtdir end --- -- not faster either: --- --- local findattr = node.direct.find_attribute --- --- local function inject_areas(head,attribute,make,stack,done,skip,parent,pardir,txtdir) -- main --- local first, last, firstdir, reference --- local someatt = findattr(head,attribute) --- if someatt then --- local current = head --- while current do --- local id = getid(current) --- if id == hlist_code or id == vlist_code then --- local r = getattr(current,attribute) --- -- test \goto{test}[page(2)] test \gotobox{test}[page(2)] --- -- test \goto{\TeX}[page(2)] test \gotobox{\hbox {x} \hbox {x}}[page(2)] --- -- if r and (not skip or r >) skip then -- maybe no > test --- -- inject_list(id,current,r,make,stack,pardir,txtdir) --- -- end --- if r then --- if not reference then --- reference, first, last, firstdir = r, current, current, txtdir --- elseif r == reference then --- -- same link --- last = current --- elseif (done[reference] or 0) == 0 then --- if not skip or r > skip then -- maybe no > test --- head, current = inject_range(head,first,last,reference,make,stack,parent,pardir,firstdir) --- reference, first, last, firstdir = nil, nil, nil, nil --- end --- else --- reference, first, last, firstdir = r, current, current, txtdir --- end --- done[r] = (done[r] or 0) + 1 --- end --- local list = getlist(current) --- if list then --- local h --- h, pardir, txtdir = inject_areas(list,attribute,make,stack,done,r or skip or 0,current,pardir,txtdir) --- if h ~= current then --- setlist(current,h) --- end --- end --- if r then --- done[r] = done[r] - 1 --- end --- elseif id == dir_code then --- local direction, pop = getdirection(current) --- txtdir = not pop and direction -- we might need a stack --- elseif id == localpar_code then -- only test at begin --- pardir = getdirection(current) --- elseif id == glue_code and getsubtype(current) == leftskip_code then -- any glue at the left? --- -- --- else --- local r = getattr(current,attribute) --- if not r then --- -- just go on, can be kerns --- elseif not reference then --- reference, first, last, firstdir = r, current, current, txtdir --- elseif r == reference then --- last = current --- elseif (done[reference] or 0) == 0 then -- or id == glue_code and getsubtype(current) == right_skip_code --- if not skip or r > skip then -- maybe no > test --- head, current = inject_range(head,first,last,reference,make,stack,parent,pardir,firstdir) --- reference, first, last, firstdir = nil, nil, nil, nil --- end --- else --- reference, first, last, firstdir = r, current, current, txtdir --- end --- end --- current = getnext(current) --- end --- if reference and (done[reference] or 0) == 0 then --- head = inject_range(head,first,last,reference,make,stack,parent,pardir,firstdir) --- end --- else --- local current = head --- while current do --- local id = getid(current) --- if id == hlist_code or id == vlist_code then --- local list = getlist(current) --- if list then --- local h = inject_areas(list,attribute,make,stack,done,skip or 0,current,pardir,txtdir) --- if h ~= current then --- setlist(current,h) --- end --- end --- elseif id == dir_code then --- local direction, pop = getdirection(current) --- txtdir = not pop and direction -- we might need a stack --- elseif id == localpar_code then -- only test at begin --- pardir = getdirection(current) --- end --- current = getnext(current) --- end --- end --- return head, pardir, txtdir --- end - --- -- maybe first check for glyphs and use a goto: --- --- local function inject_areas(head,attribute,make,stack,done,skip,parent,pardir,txtdir) -- main --- local first, last, firstdir, reference --- local current = head --- while current do --- local id = getid(current) --- local r -- else scope message due to goto --- if id == glyph_code then --- goto rest --- elseif id == hlist_code or id == vlist_code then --- r = getattr(current,attribute) --- -- test \goto{test}[page(2)] test \gotobox{test}[page(2)] --- -- test \goto{\TeX}[page(2)] test \gotobox{\hbox {x} \hbox {x}}[page(2)] --- -- if r and (not skip or r >) skip then -- maybe no > test --- -- inject_list(id,current,r,make,stack,pardir,txtdir) --- -- end --- if r then --- if not reference then --- reference, first, last, firstdir = r, current, current, txtdir --- elseif r == reference then --- -- same link --- last = current --- elseif (done[reference] or 0) == 0 then --- if not skip or r > skip then -- maybe no > test --- head, current = inject_range(head,first,last,reference,make,stack,parent,pardir,firstdir) --- reference, first, last, firstdir = nil, nil, nil, nil --- end --- else --- reference, first, last, firstdir = r, current, current, txtdir --- end --- done[r] = (done[r] or 0) + 1 --- end --- local list = getlist(current) --- if list then --- local h --- h, pardir, txtdir = inject_areas(list,attribute,make,stack,done,r or skip or 0,current,pardir,txtdir) --- if h ~= current then --- setlist(current,h) --- end --- end --- if r then --- done[r] = done[r] - 1 --- end --- elseif id == glue_code and getsubtype(current) == leftskip_code then -- any glue at the left? --- -- --- elseif id == dir_code then --- local direction, pop = getdirection(current) --- txtdir = not pop and direction -- we might need a stack --- elseif id == localpar_code then -- only test at begin --- pardir = getdirection(current) --- end --- goto next --- ::rest:: --- r = getattr(current,attribute) --- if not r then --- -- just go on, can be kerns --- elseif not reference then --- reference, first, last, firstdir = r, current, current, txtdir --- elseif r == reference then --- last = current --- elseif (done[reference] or 0) == 0 then -- or id == glue_code and getsubtype(current) == right_skip_code --- if not skip or r > skip then -- maybe no > test --- head, current = inject_range(head,first,last,reference,make,stack,parent,pardir,firstdir) --- reference, first, last, firstdir = nil, nil, nil, nil --- end --- else --- reference, first, last, firstdir = r, current, current, txtdir --- end --- ::next:: --- current = getnext(current) --- end --- if reference and (done[reference] or 0) == 0 then --- head = inject_range(head,first,last,reference,make,stack,parent,pardir,firstdir) --- end --- return head, pardir, txtdir --- end - -- tracing: todo: use predefined colors local register_color = colors.register @@ -766,7 +591,7 @@ local function makereference(width,height,depth,reference) -- height and depth a if depth < dp then depth = dp end end -- logs.report("temp","used: ht=%p dp=%p",height,depth) - local annot = nodeinjections.reference(width,height,depth,set) + local annot = nodeinjections.reference(width,height,depth,set,resolved.mesh) if annot then annot = tonut(annot) -- todo nofreferences = nofreferences + 1 @@ -929,7 +754,6 @@ local function makedestination(width,height,depth,reference) end end - function nodes.destinations.handler(head) if head and topofstack > 0 then return (inject_areas(head,attribute,makedestination,stack,done)) |