diff options
author | Hans Hagen <pragma@wxs.nl> | 2019-02-22 20:29:46 +0100 |
---|---|---|
committer | Context Git Mirror Bot <phg@phi-gamma.net> | 2019-02-22 20:29:46 +0100 |
commit | 7b271baae19db1528fbe6621bdf50af89a5a336b (patch) | |
tree | 4fc24a8f2be20aa90e90f6e1bcb62d69f4946235 /tex/context/base/mkiv/typo-mar.lua | |
parent | 67b9965fe473d18f13ed4c40f1e4e008eb870322 (diff) | |
download | context-7b271baae19db1528fbe6621bdf50af89a5a336b.tar.gz |
2019-02-22 19:43:00
Diffstat (limited to 'tex/context/base/mkiv/typo-mar.lua')
-rw-r--r-- | tex/context/base/mkiv/typo-mar.lua | 83 |
1 files changed, 39 insertions, 44 deletions
diff --git a/tex/context/base/mkiv/typo-mar.lua b/tex/context/base/mkiv/typo-mar.lua index bc9c408c1..f8665e0b0 100644 --- a/tex/context/base/mkiv/typo-mar.lua +++ b/tex/context/base/mkiv/typo-mar.lua @@ -62,13 +62,11 @@ local nuts = nodes.nuts local nodepool = nuts.pool local tonode = nuts.tonode -local tonut = nuts.tonut local hpack_nodes = nuts.hpack local traverse_id = nuts.traverse_id local flush_node_list = nuts.flush_list -local getfield = nuts.getfield local getnext = nuts.getnext local getprev = nuts.getprev local getid = nuts.getid @@ -84,6 +82,9 @@ local setshift = nuts.setshift local getwidth = nuts.getwidth local setwidth = nuts.setwidth local getheight = nuts.getheight +local getprop = nuts.getprop + +local setattrlist = nuts.setattrlist local getbox = nuts.getbox local takebox = nuts.takebox @@ -93,7 +94,6 @@ local getprop = nuts.getprop local nodecodes = nodes.nodecodes local listcodes = nodes.listcodes -local gluecodes = nodes.gluecodes local whatsitcodes = nodes.whatsitcodes local hlist_code = nodecodes.hlist @@ -103,17 +103,17 @@ local userdefined_code = whatsitcodes.userdefined local nodepool = nuts.pool -local new_usernumber = nodepool.usernumber +local new_usernode = nodepool.usernode local new_hlist = nodepool.hlist -local lateluafunction = nodepool.lateluafunction +local latelua = nodepool.latelua local texgetdimen = tex.getdimen local texgetcount = tex.getcount local texget = tex.get local isleftpage = layouts.status.isleftpage -local registertogether = builders.paragraphs.registertogether -- tonode +local registertogether = builders.paragraphs.registertogether local paragraphs = typesetters.paragraphs local addtoline = paragraphs.addtoline @@ -299,7 +299,9 @@ function margins.save(t) -- -- t.realpageno = texgetcount("realpageno") if inline then - context(tonode(new_usernumber(inline_mark,nofsaved))) -- or use a normal node + local n = new_usernode(inline_mark,nofsaved) + setattrlist(n,true) + context(tonode(n)) -- or use a normal node store[nofsaved] = t -- no insert nofinlined = nofinlined + 1 else @@ -448,8 +450,9 @@ end -- anchors are only set for lines that have a note -local function sa(tag) -- maybe l/r keys ipv left/right keys - local p = cache[tag] +local function sa(specification) -- maybe l/r keys ipv left/right keys + local tag = specification.tag + local p = cache[tag] if p then if trace_marginstack then report_margindata("updating anchor %a",tag) @@ -462,11 +465,13 @@ local function sa(tag) -- maybe l/r keys ipv left/right keys end local function setanchor(v_anchor) -- freezes the global here - return lateluafunction(function() sa(v_anchor) end) + return latelua { action = sa, tag = v_anchor } end -local function aa(tag,n) -- maybe l/r keys ipv left/right keys - local p = jobpositions.gettobesaved('md:v',tag) +local function aa(specification) -- maybe l/r keys ipv left/right keys + local tag = specification.tag + local n = specification.n + local p = jobpositions.gettobesaved('md:v',tag) if p then if trace_marginstack then report_margindata("updating injected %a",tag) @@ -483,7 +488,7 @@ local function aa(tag,n) -- maybe l/r keys ipv left/right keys end local function addtoanchor(v_anchor,n) -- freezes the global here - return lateluafunction(function() aa(v_anchor,n) end) + return latelua { action = aa, tag = v_anchor, n = n } end local function markovershoot(current) -- todo: alleen als offset > line @@ -717,8 +722,8 @@ local function flushinline(parent,head) while current and nofinlined > 0 do local id = getid(current) if id == whatsit_code then - if getsubtype(current) == userdefined_code and getfield(current,"user_id") == inline_mark then - local n = getfield(current,"value") + if getsubtype(current) == userdefined_code and getprop(current,"id") == inline_mark then + local n = getprop(current,"data") local candidate = inlinestore[n] if candidate then -- no vpack, as we want to realign inlinestore[n] = nil @@ -812,9 +817,8 @@ local function handler(scope,head,group) if trace_margindata then report_margindata("flushing stage one, stored %s, scope %s, delayed %s, group %a",nofstored,scope,nofdelayed,group) end - head = tonut(head) local current = head - local done = false + local done = false -- for tracing only while current do local id = getid(current) if (id == vlist_code or id == hlist_code) and getprop(current,"margindata") == nil then @@ -839,11 +843,9 @@ local function handler(scope,head,group) report_margindata("flushing stage one, nothing done, %s left",nofstored) end end -resetstacked() - return tonode(head), done - else - return head, false + resetstacked() end + return head end local trialtypesetting = context.trialtypesetting @@ -854,7 +856,7 @@ local trialtypesetting = context.trialtypesetting function margins.localhandler(head,group) -- sometimes group is "" which is weird if trialtypesetting() then - return head, false + return head end local inhibit = conditionals.inhibitmargindata @@ -862,15 +864,15 @@ function margins.localhandler(head,group) -- sometimes group is "" which is weir if trace_margingroup then report_margindata("ignored 3, group %a, stored %s, inhibit %a",group,nofstored,inhibit) end - return head, false - elseif nofstored > 0 then + return head + end + if nofstored > 0 then return handler(v_local,head,group) - else - if trace_margingroup then - report_margindata("ignored 4, group %a, stored %s, inhibit %a",group,nofstored,inhibit) - end - return head, false end + if trace_margingroup then + report_margindata("ignored 4, group %a, stored %s, inhibit %a",group,nofstored,inhibit) + end + return head end function margins.globalhandler(head,group) -- check group @@ -884,7 +886,7 @@ function margins.globalhandler(head,group) -- check group if trace_margingroup then report_margindata("ignored 1, group %a, stored %s, inhibit %a",group,nofstored,inhibit) end - return head, false + return head elseif group == "hmode_par" then return handler(v_global,head,group) elseif group == "vmode_par" then -- experiment (for alignments) @@ -899,22 +901,20 @@ function margins.globalhandler(head,group) -- check group if trace_margingroup then report_margindata("ignored 2, group %a, stored %s, inhibit %a",group,nofstored,inhibit) end - return head, false + return head end end local function finalhandler(head) if nofdelayed > 0 then local current = head - local done = false - while current and nofdelayed > 0 do + while current and nofdelayed > 0 do -- traverse_list local id = getid(current) if id == hlist_code then -- only lines? local a = getprop(current,"margindata") if not a then finalhandler(getlist(current)) elseif realigned(current,a) then - done = true if nofdelayed == 0 then return head, true end @@ -924,10 +924,8 @@ local function finalhandler(head) end current = getnext(current) end - return head, done - else - return head, false end + return head end function margins.finalhandler(head) @@ -935,16 +933,12 @@ function margins.finalhandler(head) if trace_margindata then report_margindata("flushing stage two, instore: %s, delayed: %s",nofstored,nofdelayed) end - head = tonut(head) - local head, done = finalhandler(head) --- resetstacked(true) -resetstacked(nofdelayed==0) - head = tonode(head) - return head, done + head = finalhandler(head) + resetstacked(nofdelayed==0) else resetstacked() - return head, false end + return head end -- Somehow the vbox builder (in combinations) gets pretty confused and decides to @@ -996,6 +990,7 @@ interfaces.implement { { "align" }, { "option" }, { "line", "integer" }, + { "index", "integer" }, { "stackname" }, { "stack" }, } |