diff options
author | Hans Hagen <pragma@wxs.nl> | 2010-10-01 23:14:00 +0200 |
---|---|---|
committer | Hans Hagen <pragma@wxs.nl> | 2010-10-01 23:14:00 +0200 |
commit | a74fc8b35a066ab9f8a523287dc59d2a9edb28e4 (patch) | |
tree | 4c317bd6e7df9305095b4050d57277b4f6bf866f /tex/context/base/spac-ver.lua | |
parent | 61c1d2003dcba72d8c5a48076424372614bff9a4 (diff) | |
download | context-a74fc8b35a066ab9f8a523287dc59d2a9edb28e4.tar.gz |
beta 2010.10.01 23:14
Diffstat (limited to 'tex/context/base/spac-ver.lua')
-rw-r--r-- | tex/context/base/spac-ver.lua | 119 |
1 files changed, 109 insertions, 10 deletions
diff --git a/tex/context/base/spac-ver.lua b/tex/context/base/spac-ver.lua index 59f66803e..a0ced869f 100644 --- a/tex/context/base/spac-ver.lua +++ b/tex/context/base/spac-ver.lua @@ -733,8 +733,11 @@ local discard, largest, force, penalty, add, disable, nowhite, goback, together --~ local function free_glue_node(n) --~ -- free_node(n.spec) ---~ print(n) +--~ print("before",n) +--~ io.flush() --~ free_node(n) +--~ print("after") +--~ io.flush() --~ end function vspacing.snapbox(n,how) @@ -832,7 +835,7 @@ local function collapser(head,where,what,trace,snap,a_snapmethod) -- maybe also while current do local id, subtype = current.id, current.subtype if id == hlist_code or id == vlist_code then --- needs checking, why so many calls + -- needs checking, why so many calls if snap then local list = current.list local s = has_attribute(current,a_snapmethod) @@ -847,7 +850,7 @@ local function collapser(head,where,what,trace,snap,a_snapmethod) -- maybe also else local sv = snapmethods[s] if sv then --- check if already snapped + -- check if already snapped if list and already_done(id,list,a_snapmethod) then local ht, dp = current.height, current.depth -- assume that the box is already snapped @@ -995,7 +998,7 @@ local function collapser(head,where,what,trace,snap,a_snapmethod) -- maybe also head, current = remove_node(head, current, true) elseif sc == add then if trace then trace_skip('add',sc,so,sp,current) end ---~ local old, new = glue_data.spec, current.spec + -- local old, new = glue_data.spec, current.spec local old, new = writable_spec(glue_data), current.spec old.width = old.width + new.width old.stretch = old.stretch + new.stretch @@ -1162,6 +1165,102 @@ local function collapser(head,where,what,trace,snap,a_snapmethod) -- maybe also return head, true end +--~ function remove_node(head, current, free_too) +--~ local t = current +--~ -- node.slide(head) +--~ print("") +--~ print("BEFORE R",nodes.idstostring(head)) +--~ print(" ",nodes.xidstostring(head)) +--~ head, current = node.remove(head,current) +--~ print("MIDDLE R",nodes.idstostring(head)) +--~ print(" ",nodes.xidstostring(head)) +--~ if t then +--~ if free_too then +--~ node.free(t) +--~ t = nil +--~ else +--~ t.next, t.prev = nil, nil +--~ end +--~ end +--~ print("AFTER R",nodes.idstostring(head)) +--~ print(" ",nodes.xidstostring(head)) +--~ return head, current, t +--~ end +--~ function nodes.xidstostring(head,tail) +--~ local n = head +--~ while n.next do +--~ n = n.next +--~ end +--~ local t, last_id, last_n = { }, nil, 0 +--~ while n do +--~ local id = n.id +--~ if not last_id then +--~ last_id, last_n = id, 1 +--~ elseif last_id == id then +--~ last_n = last_n + 1 +--~ else +--~ if last_n > 1 then +--~ t[#t+1] = string.format("[%s*%s]",last_n,node.type(last_id) or "?") +--~ else +--~ t[#t+1] = string.format("[%s]",node.type(last_id) or "?") +--~ end +--~ last_id, last_n = id, 1 +--~ end +--~ if n == head then +--~ break +--~ end +--~ n = n.prev +--~ end +--~ if not last_id then +--~ t[#t+1] = "no nodes" +--~ elseif last_n > 1 then +--~ t[#t+1] = string.format("[%s*%s]",last_n,node.type(last_id) or "?") +--~ else +--~ t[#t+1] = string.format("[%s]",node.type(last_id) or "?") +--~ end +--~ return table.concat(table.reverse(t)," ") +--~ end +--~ local function collapser(head) +--~ local current, glue_data = head, nil +--~ while current do +--~ local id, subtype = current.id, current.subtype +--~ if id == glue_code and subtype == userskip_code then +--~ local sc = has_attribute(current,a_skipcategory) +--~ if not sc then +--~ if glue_data then +--~ head, current = nodes.before(head,current,glue_data) +--~ current = current.next +--~ else +--~ local previous = current.prev +--~ if previous and previous.id == glue_code and previous.subtype == userskip_code then +--~ if previous.spec.writable then +--~ if current.spec.writable then +--~ head, current = remove_node(head, current, true) +--~ else +--~ current = current.next +--~ end +--~ else +--~ current = current.next +--~ end +--~ else +--~ current = current.next +--~ end +--~ end +--~ glue_data = nil +--~ elseif not glue_data then +--~ head, current, glue_data = remove_node(head, current) +--~ else +--~ head, current = remove_node(head, current, true) +--~ end +--~ else +--~ current = current.next +--~ end +--~ end +--~ return head, true +--~ end + + + -- alignment after_output end box new_graf vmode_par hmode_par insert penalty before_display after_display -- \par -> vmode_par -- @@ -1179,9 +1278,9 @@ local function report(message,lst) end function vspacing.pagehandler(newhead,where) ---~ local newhead = texlists.contrib_head + -- local newhead = texlists.contrib_head if newhead then ---~ starttiming(vspacing) + -- starttiming(vspacing) local newtail = find_node_tail(newhead) local flush = false stackhack = true -- todo: only when grid snapping once enabled @@ -1228,12 +1327,12 @@ function vspacing.pagehandler(newhead,where) stackhead = newhead end stacktail = newtail ---~ texlists.contrib_head = nil -newhead = nil + -- texlists.contrib_head = nil + newhead = nil end ---~ stoptiming(vspacing) + -- stoptiming(vspacing) end -return newhead + return newhead end local ignore = table.tohash { |