summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/context/base/node-ref.lua
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2013-04-08 00:43:40 +0000
committerKarl Berry <karl@freefriends.org>2013-04-08 00:43:40 +0000
commit824f7b0903de8ad7f6ee3d7656005e4c59155e06 (patch)
treeabfc8673ef9916f3ab7074e811207384c301492b /Master/texmf-dist/tex/context/base/node-ref.lua
parent689aefb0727676ed3cddf331337b4be226495e72 (diff)
context import for TL13, from www.pragma-ade.com/context/beta/cont-tmf.zip
git-svn-id: svn://tug.org/texlive/trunk@29731 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/tex/context/base/node-ref.lua')
-rw-r--r--Master/texmf-dist/tex/context/base/node-ref.lua153
1 files changed, 82 insertions, 71 deletions
diff --git a/Master/texmf-dist/tex/context/base/node-ref.lua b/Master/texmf-dist/tex/context/base/node-ref.lua
index dc14102827f..09e066434a6 100644
--- a/Master/texmf-dist/tex/context/base/node-ref.lua
+++ b/Master/texmf-dist/tex/context/base/node-ref.lua
@@ -1,6 +1,6 @@
-if not modules then modules = { } end modules ['node-bck'] = {
+if not modules then modules = { } end modules ['node-ref'] = {
version = 1.001,
- comment = "companion to node-bck.mkiv",
+ comment = "companion to node-ref.mkiv",
author = "Hans Hagen, PRAGMA-ADE, Hasselt NL",
copyright = "PRAGMA ADE / ConTeXt Development Team",
license = "see context related readme files"
@@ -68,29 +68,28 @@ local nodepool = nodes.pool
local new_kern = nodepool.kern
-local has_attribute = node.has_attribute
local traverse = node.traverse
local find_node_tail = node.tail or node.slide
local tosequence = nodes.tosequence
-local function dimensions(parent,start,stop)
- stop = stop and stop.next
- if parent then
- if stop then
- return list_dimensions(parent.glue_set,parent.glue_sign,parent.glue_order,start,stop)
- else
- return list_dimensions(parent.glue_set,parent.glue_sign,parent.glue_order,start)
- end
- else
- if stop then
- return list_dimensions(start,stop)
- else
- return list_dimensions(start)
- end
- end
-end
-
---~ more compact
+-- local function dimensions(parent,start,stop)
+-- stop = stop and stop.next
+-- if parent then
+-- if stop then
+-- return list_dimensions(parent.glue_set,parent.glue_sign,parent.glue_order,start,stop)
+-- else
+-- return list_dimensions(parent.glue_set,parent.glue_sign,parent.glue_order,start)
+-- end
+-- else
+-- if stop then
+-- return list_dimensions(start,stop)
+-- else
+-- return list_dimensions(start)
+-- end
+-- end
+-- end
+--
+-- -- more compact
local function dimensions(parent,start,stop)
if parent then
@@ -111,14 +110,14 @@ local function inject_range(head,first,last,reference,make,stack,parent,pardir,t
if result and resolved then
if head == first then
if trace_backend then
- report_area("head: %04i %s %s %s => w=%s, h=%s, d=%s, c=%s",reference,pardir or "---",txtdir or "----",tosequence(first,last,true),width,height,depth,resolved)
+ report_area("head: %04i %s %s %s => w=%p, h=%p, d=%p, c=%s",reference,pardir or "---",txtdir or "----",tosequence(first,last,true),width,height,depth,resolved)
end
result.next = first
first.prev = result
return result, last
else
if trace_backend then
- report_area("middle: %04i %s %s => w=%s, h=%s, d=%s, c=%s",reference,pardir or "---",txtdir or "----",tosequence(first,last,true),width,height,depth,resolved)
+ report_area("middle: %04i %s %s => w=%p, h=%p, d=%p, c=%s",reference,pardir or "---",txtdir or "----",tosequence(first,last,true),width,height,depth,resolved)
end
local prev = first.prev
if prev then
@@ -183,7 +182,7 @@ local function inject_list(id,current,reference,make,stack,pardir,txtdir)
-- todo: only when width is ok
if result and resolved then
if trace_backend then
- report_area("box: %04i %s %s: w=%s, h=%s, d=%s, c=%s",reference,pardir or "---",txtdir or "----",width,height,depth,resolved)
+ report_area("box: %04i %s %s: w=%p, h=%p, d=%p, c=%s",reference,pardir or "---",txtdir or "----",width,height,depth,resolved)
end
if not first then
current.list = result
@@ -212,21 +211,12 @@ local function inject_areas(head,attribute,make,stack,done,skip,parent,pardir,tx
txtdir = txtdir or "==="
while current do
local id = current.id
- local r = has_attribute(current,attribute)
- if id == whatsit_code then
- local subtype = current.subtype
- if subtype == localpar_code then
- pardir = current.dir
- elseif subtype == dir_code then
- txtdir = current.dir
- end
- elseif id == glue_code and current.subtype == leftskip_code then -- any glue at the left?
- --
- elseif id == hlist_code or id == vlist_code then
--- somehow reference is true so the following fails (second one not done) in
--- test \goto{test}[page(2)] test \gotobox{test}[page(2)]
--- so let's wait till this fails again
--- if not reference and r and (not skip or r > skip) then -- > or ~=
+ if id == hlist_code or id == vlist_code then
+ local r = current[attribute]
+ -- somehow reference is true so the following fails (second one not done) in
+ -- test \goto{test}[page(2)] test \gotobox{test}[page(2)]
+ -- so let's wait till this fails again
+ -- if not reference and r and (not skip or r > skip) then -- > or ~=
if r and (not skip or r > skip) then -- > or ~=
inject_list(id,current,r,make,stack,pardir,txtdir)
end
@@ -241,19 +231,31 @@ local function inject_areas(head,attribute,make,stack,done,skip,parent,pardir,tx
if r then
done[r] = done[r] - 1
end
- elseif not r then
- -- just go on, can be kerns
- elseif not reference then
- reference, first, last, firstdir = r, current, current, txtdir
- elseif r == reference then
- last = current
- elseif (done[reference] or 0) == 0 then -- or id == glue_code and current.subtype == right_skip_code
- if not skip or r > skip then -- maybe no > test
- head, current = inject_range(head,first,last,reference,make,stack,parent,pardir,firstdir)
- reference, first, last, firstdir = nil, nil, nil, nil
+ elseif id == whatsit_code then
+ local subtype = current.subtype
+ if subtype == localpar_code then
+ pardir = current.dir
+ elseif subtype == dir_code then
+ txtdir = current.dir
end
+ elseif id == glue_code and current.subtype == leftskip_code then -- any glue at the left?
+ --
else
- reference, first, last, firstdir = r, current, current, txtdir
+ local r = current[attribute]
+ if not r then
+ -- just go on, can be kerns
+ elseif not reference then
+ reference, first, last, firstdir = r, current, current, txtdir
+ elseif r == reference then
+ last = current
+ elseif (done[reference] or 0) == 0 then -- or id == glue_code and current.subtype == right_skip_code
+ if not skip or r > skip then -- maybe no > test
+ head, current = inject_range(head,first,last,reference,make,stack,parent,pardir,firstdir)
+ reference, first, last, firstdir = nil, nil, nil, nil
+ end
+ else
+ reference, first, last, firstdir = r, current, current, txtdir
+ end
end
current = current.next
end
@@ -271,23 +273,29 @@ local function inject_area(head,attribute,make,stack,done,parent,pardir,txtdir)
local current = head
while current do
local id = current.id
- local r = has_attribute(current,attribute)
- if id == whatsit_code then
+ if id == hlist_code or id == vlist_code then
+ local r = current[attribute]
+ if r and not done[r] then
+ done[r] = true
+ inject_list(id,current,r,make,stack,pardir,txtdir)
+ end
+ local list = current.list
+ if list then
+ current.list = inject_area(list,attribute,make,stack,done,current,pardir,txtdir)
+ end
+ elseif id == whatsit_code then
local subtype = current.subtype
if subtype == localpar_code then
pardir = current.dir
elseif subtype == dir_code then
txtdir = current.dir
end
- elseif id == hlist_code or id == vlist_code then
+ else
+ local r = current[attribute]
if r and not done[r] then
done[r] = true
- inject_list(id,current,r,make,stack,pardir,txtdir)
+ head, current = inject_range(head,current,current,r,make,stack,parent,pardir,txtdir)
end
- current.list = inject_area(current.list,attribute,make,stack,done,current,pardir,txtdir)
- elseif r and not done[r] then
- done[r] = true
- head, current = inject_range(head,current,current,r,make,stack,parent,pardir,txtdir)
end
current = current.next
end
@@ -305,8 +313,8 @@ local new_kern = nodepool.kern
local set_attribute = node.set_attribute
local register_color = colors.register
-local a_colormodel = attributes.private('colormodel')
local a_color = attributes.private('color')
+local a_colormodel = attributes.private('colormodel')
local a_transparency = attributes.private('transparency')
local u_transparency = nil
local u_colors = { }
@@ -331,18 +339,18 @@ local function colorize(width,height,depth,n,reference,what)
end
if width == 0 then
-- probably a strut as placeholder
- report_area("%s %s has no horizontal dimensions: width=%s, height=%s, depth=%s",what,reference,width,height,depth)
+ report_area("%s %s has no %s dimensions, width %p, height %p, depth %p",what,reference,"horizontal",width,height,depth)
width = 65536
end
if height + depth <= 0 then
- report_area("%s %s has no vertical dimensions: width=%s, height=%s, depth=%s",what,reference,n,width,height,depth)
+ report_area("%s %s has no %s dimensions, width %p, height %p, depth %p",what,reference,"vertical",width,height,depth)
height = 65536/2
depth = height
end
local rule = new_rule(width,height,depth)
- set_attribute(rule,a_colormodel,1) -- gray color model
- set_attribute(rule,a_color,u_color)
- set_attribute(rule,a_transparency,u_transparency)
+ rule[a_colormodel] = 1 -- gray color model
+ rule[a_color] = u_color
+ rule[a_transparency] = u_transparency
if width < 0 then
local kern = new_kern(width)
rule.width = -width
@@ -395,7 +403,7 @@ local function makereference(width,height,depth,reference)
local sr = stack[reference]
if sr then
if trace_references then
- report_reference("resolving attribute %s",reference)
+ report_reference("resolving attribute %a",reference)
end
local resolved, ht, dp, set, n = sr[1], sr[2], sr[3], sr[4], sr[5]
if ht then
@@ -423,10 +431,10 @@ local function makereference(width,height,depth,reference)
if cleanupreferences then stack[reference] = nil end
return result, resolved
elseif trace_references then
- report_reference("unable to resolve annotation %s",reference)
+ report_reference("unable to resolve annotation %a",reference)
end
elseif trace_references then
- report_reference("unable to resolve attribute %s",reference)
+ report_reference("unable to resolve attribute %a",reference)
end
end
@@ -462,7 +470,7 @@ local function makedestination(width,height,depth,reference)
local sr = stack[reference]
if sr then
if trace_destinations then
- report_destination("resolving attribute %s",reference)
+ report_destination("resolving attribute %a",reference)
end
local resolved, ht, dp, name, view = sr[1], sr[2], sr[3], sr[4], sr[5]
if ht then
@@ -493,12 +501,12 @@ local function makedestination(width,height,depth,reference)
for n=1,#name do
local annot = nodeinjections.destination(width,height,depth,name[n],view)
if not result then
- result, current = annot, annot
+ result = annot
else
current.next = annot
annot.prev = current
- current = annot
end
+ current = find_node_tail(annot)
end
if result then
-- some internal error
@@ -508,7 +516,7 @@ local function makedestination(width,height,depth,reference)
if cleanupdestinations then stack[reference] = nil end
return result, resolved
elseif trace_destinations then
- report_destination("unable to resolve attribute %s",reference)
+ report_destination("unable to resolve attribute %a",reference)
end
end
@@ -544,6 +552,9 @@ function references.injectcurrentset(h,d) -- used inside doifelse
end
end
+commands.injectreference = references.inject
+commands.injectcurrentreference = references.injectcurrentset
+
--
local function checkboth(open,close)