summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/context/base/mkiv/spac-ver.lua
diff options
context:
space:
mode:
Diffstat (limited to 'Master/texmf-dist/tex/context/base/mkiv/spac-ver.lua')
-rw-r--r--Master/texmf-dist/tex/context/base/mkiv/spac-ver.lua143
1 files changed, 66 insertions, 77 deletions
diff --git a/Master/texmf-dist/tex/context/base/mkiv/spac-ver.lua b/Master/texmf-dist/tex/context/base/mkiv/spac-ver.lua
index 33b81e5c7e8..2fc9263213c 100644
--- a/Master/texmf-dist/tex/context/base/mkiv/spac-ver.lua
+++ b/Master/texmf-dist/tex/context/base/mkiv/spac-ver.lua
@@ -1,5 +1,6 @@
if not modules then modules = { } end modules ['spac-ver'] = {
version = 1.001,
+ optimize = true,
comment = "companion to spac-ver.mkiv",
author = "Hans Hagen, PRAGMA-ADE, Hasselt NL",
copyright = "PRAGMA ADE / ConTeXt Development Team",
@@ -38,6 +39,7 @@ local unpack = unpack or table.unpack
local allocate = utilities.storage.allocate
local todimen = string.todimen
local formatters = string.formatters
+local abs = math.abs
local nodes = nodes
local trackers = trackers
@@ -180,11 +182,10 @@ local gluecodes = nodes.gluecodes
local penalty_code = nodecodes.penalty
local kern_code = nodecodes.kern
local glue_code = nodecodes.glue
-local insert_code = nodecodes.ins
local hlist_code = nodecodes.hlist
local vlist_code = nodecodes.vlist
local rule_code = nodecodes.rule
-local localpar_code = nodecodes.localpar
+local par_code = nodecodes.par
local userskip_code = gluecodes.userskip
local lineskip_code = gluecodes.lineskip
@@ -292,7 +293,7 @@ end
local function validvbox(parentid,list)
if parentid == hlist_code then
local id = getid(list)
- if id == localpar_code and start_of_par(list) then
+ if id == par_code and start_of_par(list) then
list = getnext(list)
if not next then
return nil
@@ -328,7 +329,7 @@ local function already_done(parentid,list,a_snapmethod) -- todo: done when only
-- problem: any snapped vbox ends up in a line
if list and parentid == hlist_code then
local id = getid(list)
- if id == localpar_code and start_of_par(list) then
+ if id == par_code and start_of_par(list) then
list = getnext(list)
if not list then
return false
@@ -1262,7 +1263,7 @@ do
end
end
-- in fact, we could try again later ... so then no remove (a few tries)
- return remove_node(head, current, true)
+ return remove_node(head,current,true)
end
local function collapser(head,where,what,trace,snap,a_snapmethod) -- maybe also pass tail
@@ -1500,7 +1501,7 @@ do
-- if trace then
-- trace_done("removed penalty",current)
-- end
- -- head, current = remove_node(head, current, true)
+ -- head, current = remove_node(head,current,true)
current = getnext(current)
elseif id == kern_code then
if snap and trace_vsnapping and getkern(current) ~= 0 then
@@ -1538,7 +1539,7 @@ do
if trace then
trace_skip("penalty in skip",sc,so,sp,current)
end
- head, current = remove_node(head, current, true)
+ head, current = remove_node(head,current,true)
elseif not sc then -- if not sc then
if glue_data then
if trace then
@@ -1561,7 +1562,7 @@ do
if trace then
trace_natural("removed",current)
end
- head, current = remove_node(head, current, true)
+ head, current = remove_node(head,current,true)
if trace then
trace_natural("collapsed",previous)
end
@@ -1586,7 +1587,7 @@ do
if trace then
trace_skip(sc == disable and "disable" or "enable",sc,so,sp,current)
end
- head, current = remove_node(head, current, true)
+ head, current = remove_node(head,current,true)
else
current = next
end
@@ -1595,12 +1596,12 @@ do
trace_skip("packed",sc,so,sp,current)
end
-- can't happen !
- head, current = remove_node(head, current, true)
+ head, current = remove_node(head,current,true)
elseif sc == nowhite then
local next = getnext(current)
if next then
ignore_whitespace = true
- head, current = remove_node(head, current, true)
+ head, current = remove_node(head,current,true)
else
current = next
end
@@ -1608,7 +1609,7 @@ do
if trace then
trace_skip("discard",sc,so,sp,current)
end
- head, current = remove_node(head, current, true)
+ head, current = remove_node(head,current,true)
elseif sc == overlay then
-- todo (overlay following line over previous
if trace then
@@ -1621,20 +1622,20 @@ do
if trace then
trace_skip("disabled",sc,so,sp,current)
end
- head, current = remove_node(head, current, true)
+ head, current = remove_node(head,current,true)
elseif not glue_data then
if trace then
trace_skip("assign",sc,so,sp,current)
end
glue_order = so
- head, current, glue_data = remove_node(head, current)
+ head, current, glue_data = remove_node(head,current)
elseif glue_order < so then
if trace then
trace_skip("force",sc,so,sp,current)
end
glue_order = so
flush_node(glue_data)
- head, current, glue_data = remove_node(head, current)
+ head, current, glue_data = remove_node(head,current)
elseif glue_order == so then
-- is now exclusive, maybe support goback as combi, else why a set
if sc == largest then
@@ -1650,7 +1651,7 @@ do
if trace then
trace_skip("remove smallest",sc,so,sp,current)
end
- head, current = remove_node(head, current, true)
+ head, current = remove_node(head,current,true)
end
elseif sc == goback then
if trace then
@@ -1665,34 +1666,34 @@ do
trace_skip("force",sc,so,sp,current)
end
flush_node(glue_data)
- head, current, glue_data = remove_node(head, current)
+ head, current, glue_data = remove_node(head,current)
elseif sc == penalty then
if trace then
trace_skip("penalty",sc,so,sp,current)
end
flush_node(glue_data)
glue_data = nil
- head, current = remove_node(head, current, true)
+ head, current = remove_node(head,current,true)
elseif sc == add then
if trace then
trace_skip("add",sc,so,sp,current)
end
local cwidth, cstretch, cshrink = getglue(current)
local gwidth, gstretch, gshrink = getglue(glue_data)
- setglue(old,gwidth + cwidth, gstretch + cstretch, gshrink + cshrink)
+ setglue(glue_data,gwidth + cwidth, gstretch + cstretch,gshrink + cshrink)
-- toto: order
- head, current = remove_node(head, current, true)
+ head, current = remove_node(head,current,true)
else
if trace then
trace_skip("unknown",sc,so,sp,current)
end
- head, current = remove_node(head, current, true)
+ head, current = remove_node(head,current,true)
end
else
if trace then
trace_skip("unknown",sc,so,sp,current)
end
- head, current = remove_node(head, current, true)
+ head, current = remove_node(head,current,true)
end
if sc == force then
force_glue = true
@@ -1747,7 +1748,7 @@ do
if trace then
trace_natural("ignored parskip",current)
end
- head, current = remove_node(head, current, true)
+ head, current = remove_node(head,current,true)
elseif glue_data then
local w = getwidth(current)
if (w ~= 0) and (w > getwidth(glue_data)) then
@@ -1755,18 +1756,18 @@ do
if trace then
trace_natural("taking parskip",current)
end
- head, current = remove_node(head, current)
+ head, current = remove_node(head,current)
else
if trace then
trace_natural("removed parskip",current)
end
- head, current = remove_node(head, current, true)
+ head, current = remove_node(head,current,true)
end
else
if trace then
trace_natural("honored parskip",current)
end
- head, current, glue_data = remove_node(head, current)
+ head, current, glue_data = remove_node(head,current)
end
elseif subtype == topskip_code or subtype == splittopskip_code then
local next = getnext(current)
@@ -1901,18 +1902,6 @@ do
return head
end
- -- alignment after_output end box new_graf vmode_par hmode_par insert penalty before_display after_display
- -- \par -> vmode_par
- --
- -- status.best_page_break
- -- tex.lists.best_page_break
- -- tex.lists.best_size (natural size to best_page_break)
- -- tex.lists.least_page_cost (badness of best_page_break)
- -- tex.lists.page_head
- -- tex.lists.contrib_head
-
- -- do
-
local stackhead, stacktail, stackhack = nil, nil, false
local function report(message,where,lst)
@@ -1929,7 +1918,6 @@ do
local forceflush = false
function vspacing.pagehandler(newhead,where)
- -- local newhead = texlists.contrib_head
if newhead then
local newtail = find_node_tail(newhead) -- best pass that tail, known anyway
local flush = false
@@ -1971,11 +1959,9 @@ do
if stackhack then
stackhack = false
if trace_collect_vspacing then report("%s > processing %s nodes: %s",where,newhead) end
- -- texlists.contrib_head = collapser(newhead,"page",where,trace_page_vspacing,true,a_snapmethod)
newhead = collapser(newhead,"page",where,trace_page_vspacing,true,a_snapmethod)
else
if trace_collect_vspacing then report("%s > flushing %s nodes: %s",where,newhead) end
- -- texlists.contrib_head = newhead
end
return newhead
else
@@ -1992,20 +1978,6 @@ do
return nil
end
- -- function vspacing.flushpagestack()
- -- if stackhead then
- -- local head = texlists.contrib_head
- -- if head then
- -- local tail = find_node_tail(head)
- -- setlink(tail,stackhead)
- -- else
- -- texlists.contrib_head = tonode(stackhead)
- -- end
- -- stackhead, stacktail = nil, nil
- -- end
- --
- -- end
-
function vspacing.pageoverflow()
local h = 0
if stackhead then
@@ -2156,32 +2128,49 @@ do
end
end
- local trace = false
+ local trace = false
+ local last = nil
+ local vmode_code = tex.modelevels.vertical
+ local temp_code = nodecodes.temp
+ local getnest = tex.getnest
+ local getlist = tex.getlist
trackers.register("vspacing.forcestrutdepth",function(v) trace = v end)
- local last = nil
+ -- abs : negative is inner
- -- function vspacing.forcestrutdepth(n,depth,trace_mode,plus)
- -- local box = texgetbox(n)
- -- if box then
- -- box = tonut(box)
- -- local head = getlist(box)
- -- if head then
- -- local tail = find_node_tail(head)
- -- if tail and getid(tail) == hlist_code then
- -- local dp = getdepth(tail)
- -- if dp < depth then
- -- setdepth(tail,depth)
- -- outer.prevdepth = depth
- -- if trace or trace_mode > 0 then
- -- nuts.setvisual(tail,"depth")
- -- end
- -- end
- -- end
- -- end
- -- end
- -- end
+ function vspacing.checkstrutdepth(depth)
+ local nest = getnest()
+ if abs(nest.mode) == vmode_code and nest.head then
+ local tail = nest.tail
+ local id = tail.id
+ if id == hlist_code then
+ if tail.depth < depth then
+ tail.depth = depth
+ end
+ nest.prevdepth = depth
+ elseif id == temp_code and getnest("ptr") == 0 then
+ local head = getlist("page_head")
+ if head then
+ tail = nodes.tail(head)
+ if tail and tail.id == hlist_code then
+ if tail.depth < depth then
+ tail.depth = depth
+ end
+ nest.prevdepth = depth
+ -- only works in lmtx
+ texset("pagedepth",depth)
+ end
+ end
+ end
+ end
+ end
+
+ interfaces.implement {
+ name = "checkstrutdepth",
+ arguments = "dimension",
+ actions = vspacing.checkstrutdepth,
+ }
function vspacing.forcestrutdepth(n,depth,trace_mode,plus)
local box = texgetbox(n)