diff options
author | Hans Hagen <pragma@wxs.nl> | 2018-07-27 19:41:15 +0200 |
---|---|---|
committer | Context Git Mirror Bot <phg@phi-gamma.net> | 2018-07-27 19:41:15 +0200 |
commit | b61d5dd3555e906b21601ff75b3268c0f359283e (patch) | |
tree | d46b07daf1c26c0fc7d7254d3f0e1515e9ed36a8 /tex/context/base/mkiv/spac-ver.lua | |
parent | 1add40ac787d36d3bd40e196aea752dff2cfb769 (diff) | |
download | context-b61d5dd3555e906b21601ff75b3268c0f359283e.tar.gz |
2018-07-27 19:21:00
Diffstat (limited to 'tex/context/base/mkiv/spac-ver.lua')
-rw-r--r-- | tex/context/base/mkiv/spac-ver.lua | 185 |
1 files changed, 111 insertions, 74 deletions
diff --git a/tex/context/base/mkiv/spac-ver.lua b/tex/context/base/mkiv/spac-ver.lua index aae9913f7..d056d6ed3 100644 --- a/tex/context/base/mkiv/spac-ver.lua +++ b/tex/context/base/mkiv/spac-ver.lua @@ -117,6 +117,7 @@ local a_snapvbox = attributes.private('snapvbox') local nuts = nodes.nuts local tonut = nuts.tonut +local tonode = nuts.tonode local getnext = nuts.getnext local setlink = nuts.setlink @@ -212,76 +213,80 @@ vspacingdata.snapmethods = snapmethods storage.register("builders/vspacing/data/snapmethods", snapmethods, "builders.vspacing.data.snapmethods") -local default = { - [v_maxheight] = true, - [v_maxdepth] = true, - [v_strut] = true, - [v_hfraction] = 1, - [v_dfraction] = 1, - [v_bfraction] = 0.25, -} +do -local fractions = { - [v_minheight] = v_hfraction, [v_maxheight] = v_hfraction, - [v_mindepth] = v_dfraction, [v_maxdepth] = v_dfraction, - [v_box] = v_bfraction, - [v_top] = v_tlines, [v_bottom] = v_blines, -} + local default = { + [v_maxheight] = true, + [v_maxdepth] = true, + [v_strut] = true, + [v_hfraction] = 1, + [v_dfraction] = 1, + [v_bfraction] = 0.25, + } -local values = { - offset = "offset" -} + local fractions = { + [v_minheight] = v_hfraction, [v_maxheight] = v_hfraction, + [v_mindepth] = v_dfraction, [v_maxdepth] = v_dfraction, + [v_box] = v_bfraction, + [v_top] = v_tlines, [v_bottom] = v_blines, + } -local colonsplitter = lpeg.splitat(":") + local values = { + offset = "offset" + } -local function listtohash(str) - local t = { } - for s in gmatch(str,"[^, ]+") do - local key, detail = lpegmatch(colonsplitter,s) - local v = variables[key] - if v then - t[v] = true - if detail then - local k = fractions[key] - if k then - detail = tonumber("0" .. detail) - if detail then - t[k] = detail - end - else - k = values[key] + local colonsplitter = lpeg.splitat(":") + + local function listtohash(str) + local t = { } + for s in gmatch(str,"[^, ]+") do + local key, detail = lpegmatch(colonsplitter,s) + local v = variables[key] + if v then + t[v] = true + if detail then + local k = fractions[key] if k then - detail = todimen(detail) + detail = tonumber("0" .. detail) if detail then t[k] = detail end + else + k = values[key] + if k then + detail = todimen(detail) + if detail then + t[k] = detail + end + end end end + else + detail = tonumber("0" .. key) + if detail then + t[v_hfraction] = detail + t[v_dfraction] = detail + end end + end + if next(t) then + t[v_hfraction] = t[v_hfraction] or 1 + t[v_dfraction] = t[v_dfraction] or 1 + return t else - detail = tonumber("0" .. key) - if detail then - t[v_hfraction] = detail - t[v_dfraction] = detail - end + return default end end - if next(t) then - t[v_hfraction] = t[v_hfraction] or 1 - t[v_dfraction] = t[v_dfraction] or 1 - return t - else - return default + + function vspacing.definesnapmethod(name,method) + local n = #snapmethods + 1 + local t = listtohash(method) + snapmethods[n] = t + t.name = name -- not interfaced + t.specification = method -- not interfaced + context(n) end -end -function vspacing.definesnapmethod(name,method) - local n = #snapmethods + 1 - local t = listtohash(method) - snapmethods[n] = t - t.name = name -- not interfaced - t.specification = method -- not interfaced - context(n) end local function validvbox(parentid,list) @@ -1911,6 +1916,8 @@ do -- ugly code: we get partial lists (check if this stack is still okay) ... and we run -- into temp nodes (sigh) + local forceflush = false + function vspacing.pagehandler(newhead,where) -- local newhead = texlists.contrib_head if newhead then @@ -1937,6 +1944,12 @@ do end end texsetcount("c_spac_vspacing_ignore_parskip",0) + + if forceflush then + forceflush = false + flush = true + end + if flush then if stackhead then if trace_collect_vspacing then report("%s > appending %s nodes to stack (final): %s",where,newhead) end @@ -1962,30 +1975,44 @@ do if trace_collect_vspacing then report("%s > storing %s nodes in stack (initial): %s",where,newhead) end stackhead = newhead end -if not flush then - local h = 0 - for n, id in nextnode, stackhead do - if id == glue_code then - h = h + getwidth(n) - elseif id == kern_code then - h = h + getkern(n) - end - end - if h + tex.pagetotal >= tex.pagegoal then - newhead = stackhead - stackhead, stacktail = nil, nil - return newhead - end -end stacktail = newtail - -- texlists.contrib_head = nil - -- newhead = nil end end --- tex.triggerbuildpage() 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 + for n, id in nextnode, stackhead do + if id == glue_code then + h = h + getwidth(n) + elseif id == kern_code then + h = h + getkern(n) + end + end + end + return h + end + + function vspacing.forcepageflush() + forceflush = true + end + local ignore = table.tohash { "split_keep", "split_off", @@ -2225,7 +2252,7 @@ do -- end -- } - interfaces.implement { + implement { name = "removelastline", actions = function() local head = texlists.page_head @@ -2241,7 +2268,7 @@ do end } - interfaces.implement { + implement { name = "showpagelist", -- will improve actions = function() local head = texlists.page_head @@ -2255,4 +2282,14 @@ do end } + implement { + name = "pageoverflow", + actions = { vspacing.pageoverflow, context } + } + + implement { + name = "forcepageflush", + actions = vspacing.forcepageflush + } + end |