summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/context/base/mkiv/typo-mar.lua
diff options
context:
space:
mode:
Diffstat (limited to 'Master/texmf-dist/tex/context/base/mkiv/typo-mar.lua')
-rw-r--r--Master/texmf-dist/tex/context/base/mkiv/typo-mar.lua83
1 files changed, 44 insertions, 39 deletions
diff --git a/Master/texmf-dist/tex/context/base/mkiv/typo-mar.lua b/Master/texmf-dist/tex/context/base/mkiv/typo-mar.lua
index f8665e0b061..bc9c408c19f 100644
--- a/Master/texmf-dist/tex/context/base/mkiv/typo-mar.lua
+++ b/Master/texmf-dist/tex/context/base/mkiv/typo-mar.lua
@@ -62,11 +62,13 @@ 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
@@ -82,9 +84,6 @@ 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
@@ -94,6 +93,7 @@ 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_usernode = nodepool.usernode
+local new_usernumber = nodepool.usernumber
local new_hlist = nodepool.hlist
-local latelua = nodepool.latelua
+local lateluafunction = nodepool.lateluafunction
local texgetdimen = tex.getdimen
local texgetcount = tex.getcount
local texget = tex.get
local isleftpage = layouts.status.isleftpage
-local registertogether = builders.paragraphs.registertogether
+local registertogether = builders.paragraphs.registertogether -- tonode
local paragraphs = typesetters.paragraphs
local addtoline = paragraphs.addtoline
@@ -299,9 +299,7 @@ function margins.save(t)
--
-- t.realpageno = texgetcount("realpageno")
if inline then
- local n = new_usernode(inline_mark,nofsaved)
- setattrlist(n,true)
- context(tonode(n)) -- or use a normal node
+ context(tonode(new_usernumber(inline_mark,nofsaved))) -- or use a normal node
store[nofsaved] = t -- no insert
nofinlined = nofinlined + 1
else
@@ -450,9 +448,8 @@ end
-- anchors are only set for lines that have a note
-local function sa(specification) -- maybe l/r keys ipv left/right keys
- local tag = specification.tag
- local p = cache[tag]
+local function sa(tag) -- maybe l/r keys ipv left/right keys
+ local p = cache[tag]
if p then
if trace_marginstack then
report_margindata("updating anchor %a",tag)
@@ -465,13 +462,11 @@ local function sa(specification) -- maybe l/r keys ipv left/right keys
end
local function setanchor(v_anchor) -- freezes the global here
- return latelua { action = sa, tag = v_anchor }
+ return lateluafunction(function() sa(v_anchor) end)
end
-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)
+local function aa(tag,n) -- maybe l/r keys ipv left/right keys
+ local p = jobpositions.gettobesaved('md:v',tag)
if p then
if trace_marginstack then
report_margindata("updating injected %a",tag)
@@ -488,7 +483,7 @@ local function aa(specification) -- maybe l/r keys ipv left/right keys
end
local function addtoanchor(v_anchor,n) -- freezes the global here
- return latelua { action = aa, tag = v_anchor, n = n }
+ return lateluafunction(function() aa(v_anchor,n) end)
end
local function markovershoot(current) -- todo: alleen als offset > line
@@ -722,8 +717,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 getprop(current,"id") == inline_mark then
- local n = getprop(current,"data")
+ if getsubtype(current) == userdefined_code and getfield(current,"user_id") == inline_mark then
+ local n = getfield(current,"value")
local candidate = inlinestore[n]
if candidate then -- no vpack, as we want to realign
inlinestore[n] = nil
@@ -817,8 +812,9 @@ 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 -- for tracing only
+ local done = false
while current do
local id = getid(current)
if (id == vlist_code or id == hlist_code) and getprop(current,"margindata") == nil then
@@ -843,9 +839,11 @@ local function handler(scope,head,group)
report_margindata("flushing stage one, nothing done, %s left",nofstored)
end
end
- resetstacked()
+resetstacked()
+ return tonode(head), done
+ else
+ return head, false
end
- return head
end
local trialtypesetting = context.trialtypesetting
@@ -856,7 +854,7 @@ local trialtypesetting = context.trialtypesetting
function margins.localhandler(head,group) -- sometimes group is "" which is weird
if trialtypesetting() then
- return head
+ return head, false
end
local inhibit = conditionals.inhibitmargindata
@@ -864,15 +862,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
- end
- if nofstored > 0 then
+ return head, false
+ elseif 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
@@ -886,7 +884,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
+ return head, false
elseif group == "hmode_par" then
return handler(v_global,head,group)
elseif group == "vmode_par" then -- experiment (for alignments)
@@ -901,20 +899,22 @@ 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
+ return head, false
end
end
local function finalhandler(head)
if nofdelayed > 0 then
local current = head
- while current and nofdelayed > 0 do -- traverse_list
+ local done = false
+ while current and nofdelayed > 0 do
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,8 +924,10 @@ local function finalhandler(head)
end
current = getnext(current)
end
+ return head, done
+ else
+ return head, false
end
- return head
end
function margins.finalhandler(head)
@@ -933,12 +935,16 @@ function margins.finalhandler(head)
if trace_margindata then
report_margindata("flushing stage two, instore: %s, delayed: %s",nofstored,nofdelayed)
end
- head = finalhandler(head)
- resetstacked(nofdelayed==0)
+ head = tonut(head)
+ local head, done = finalhandler(head)
+-- resetstacked(true)
+resetstacked(nofdelayed==0)
+ head = tonode(head)
+ return head, done
else
resetstacked()
+ return head, false
end
- return head
end
-- Somehow the vbox builder (in combinations) gets pretty confused and decides to
@@ -990,7 +996,6 @@ interfaces.implement {
{ "align" },
{ "option" },
{ "line", "integer" },
- { "index", "integer" },
{ "stackname" },
{ "stack" },
}