summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/context/base/node-fin.lua
diff options
context:
space:
mode:
Diffstat (limited to 'Master/texmf-dist/tex/context/base/node-fin.lua')
-rw-r--r--Master/texmf-dist/tex/context/base/node-fin.lua108
1 files changed, 64 insertions, 44 deletions
diff --git a/Master/texmf-dist/tex/context/base/node-fin.lua b/Master/texmf-dist/tex/context/base/node-fin.lua
index c6e3be44815..5c1cc9ad57a 100644
--- a/Master/texmf-dist/tex/context/base/node-fin.lua
+++ b/Master/texmf-dist/tex/context/base/node-fin.lua
@@ -9,29 +9,33 @@ if not modules then modules = { } end modules ['node-fin'] = {
-- this module is being reconstructed
local next, type, format = next, type, string.format
-local texsprint = tex.sprint
-local ctxcatcodes = tex.ctxcatcodes
+local attributes, nodes, node = attributes, nodes, node
-local glyph = node.id('glyph')
-local glue = node.id('glue')
-local rule = node.id('rule')
-local whatsit = node.id('whatsit')
-local hlist = node.id('hlist')
-local vlist = node.id('vlist')
+local has_attribute = node.has_attribute
+local copy_node = node.copy
-local has_attribute = node.has_attribute
-local copy_node = node.copy
+local nodecodes = nodes.nodecodes
+local whatcodes = nodes.whatcodes
-local starttiming, stoptiming = statistics.starttiming, statistics.stoptiming
+local glyph_code = nodecodes.glyph
+local disc_code = nodecodes.disc
+local glue_code = nodecodes.glue
+local rule_code = nodecodes.rule
+local whatsit_code = nodecodes.whatsit
+local hlist_code = nodecodes.hlist
+local vlist_code = nodecodes.vlist
-states = states or { }
-shipouts = shipouts or { }
+local pdfliteral_code = whatcodes.pdfliteral
+local states = attributes.states
local numbers = attributes.numbers
local trigger = attributes.private('trigger')
local triggering = false
+local starttiming = statistics.starttiming
+local stoptiming = statistics.stoptiming
+
-- these two will be like trackers
function states.enabletriggering()
@@ -57,7 +61,7 @@ end
-- function states.flush()
-- if #collected > 0 then
-- for i=1,#collected do
--- texsprint(ctxcatcodes,collected[i]) -- we're in context mode anyway
+-- context(collected[i]) -- we're in context mode anyway
-- end
-- collected = { }
-- states.collected = collected
@@ -109,9 +113,9 @@ local function process_attribute(head,plugin) -- head,attribute,enabled,initiali
end
end
-nodes.process_attribute = process_attribute
+-- nodes.process_attribute = process_attribute
-function nodes.install_attribute_handler(plugin) -- we need to avoid this nested function
+function nodes.installattributehandler(plugin) -- we need to avoid this nested function
return function(head)
return process_attribute(head,plugin)
end
@@ -159,7 +163,7 @@ end
--~ end
--~ ]]
--~
---~ function nodes.install_attribute_handler(plugin) -- we need to avoid this nested function
+--~ function nodes.installattributehandler(plugin) -- we need to avoid this nested function
--~ plugindata[plugin.name] = plugin
--~ local str = format(template,plugin.name)
--~ return loadstring(str)()
@@ -170,20 +174,25 @@ end
local insert_node_before = node.insert_before
local insert_node_after = node.insert_after
-local nsdata, nsdone, nsforced, nsselector, nstrigger
+local nsdata, nsnone, nslistwise, nsforced, nsselector, nstrigger
local current, current_selector, done = 0, 0, false -- nb, stack has a local current !
function states.initialize(namespace,attribute,head)
- nsdata, nsnone = namespace.data, namespace.none
- nsforced, nsselector, nslistwise = namespace.forced, namespace.selector, namespace.listwise
- nstrigger = triggering and namespace.triggering and trigger
- current, current_selector, done = 0, 0, false -- todo: done cleanup
+ nsdata = namespace.data
+ nsnone = namespace.none
+ nsforced = namespace.forced
+ nsselector = namespace.selector
+ nslistwise = namespace.listwise
+ nstrigger = triggering and namespace.triggering and trigger
+ current = 0
+ current_selector = 0
+ done = false -- todo: done cleanup
end
function states.finalize(namespace,attribute,head) -- is this one ok?
if current > 0 and nsnone then
local id = head.id
- if id == hlist or id == vlist then
+ if id == hlist_code or id == vlist_code then
local list = head.list
if list then
head.list = insert_node_before(list,list,copy_node(nsnone))
@@ -201,27 +210,30 @@ local function process(namespace,attribute,head,inheritance,default) -- one attr
while stack do
local id = stack.id
-- we need to deal with literals too (reset as well as oval)
- -- if id == glyph or (id == whatsit and stack.subtype == 8) or (id == rule and stack.width ~= 0) or (id == glue and stack.leader) then -- or disc
- if id == glyph or (id == rule and stack.width ~= 0) or (id == glue and stack.leader) then -- or disc
+ -- if id == glyph_code or (id == whatsit_code and stack.subtype == pdfliteral_code) or (id == rule_code and stack.width ~= 0) or (id == glue_code and stack.leader) then -- or disc_code
+ if id == glyph_code -- or id == disc_code
+ or (id == rule_code and stack.width ~= 0) or (id == glue_code and stack.leader) then -- or disc_code
local c = has_attribute(stack,attribute)
if c then
if default and c == inheritance then
if current ~= default then
head = insert_node_before(head,stack,copy_node(nsdata[default]))
- current, done = default, true
+ current = default
+ done = true
end
elseif current ~= c then
head = insert_node_before(head,stack,copy_node(nsdata[c]))
- current, done = c, true
+ current = c
+ done = true
end
-- here ? compare selective
- if id == glue then --leader
+ if id == glue_code then --leader
-- same as *list
local content = stack.leader
if content then
local savedcurrent = current
local ci = content.id
- if ci == hlist or ci == vlist then
+ if ci == hlist_code or ci == vlist_code then
-- else we reset inside a box unneeded, okay, the downside is
-- that we trigger color in each repeated box, so there is room
-- for improvement here
@@ -245,13 +257,15 @@ local function process(namespace,attribute,head,inheritance,default) -- one attr
elseif default and inheritance then
if current ~= default then
head = insert_node_before(head,stack,copy_node(nsdata[default]))
- current, done = default, true
+ current = default
+ done = true
end
elseif current > 0 then
head = insert_node_before(head,stack,copy_node(nsnone))
- current, done = 0, true
+ current = 0
+ done = true
end
- elseif id == hlist or id == vlist then
+ elseif id == hlist_code or id == vlist_code then
local content = stack.list
if content then
local ok = false
@@ -286,41 +300,46 @@ local function selective(namespace,attribute,head,inheritance,default) -- two at
while stack do
local id = stack.id
-- we need to deal with literals too (reset as well as oval)
- -- if id == glyph or (id == whatsit and stack.subtype == 8) or (id == rule and stack.width ~= 0) or (id == glue and stack.leader) then -- or disc
- if id == glyph or (id == rule and stack.width ~= 0) or (id == glue and stack.leader) then -- or disc
+ -- if id == glyph_code or (id == whatsit_code and stack.subtype == pdfliteral_code) or (id == rule_code and stack.width ~= 0) or (id == glue_code and stack.leader) then -- or disc_code
+ if id == glyph_code -- or id == disc_code
+ or (id == rule_code and stack.width ~= 0) or (id == glue_code and stack.leader) then -- or disc_code
local c = has_attribute(stack,attribute)
if c then
if default and c == inheritance then
if current ~= default then
local data = nsdata[default]
head = insert_node_before(head,stack,copy_node(data[nsforced or has_attribute(stack,nsselector) or nsselector]))
- current, done = default, true
+ current = default
+ done = true
end
else
local s = has_attribute(stack,nsselector)
if current ~= c or current_selector ~= s then
local data = nsdata[c]
head = insert_node_before(head,stack,copy_node(data[nsforced or has_attribute(stack,nsselector) or nsselector]))
- current, current_selector, done = c, s, true
+ current = c
+ current_selector = s
+ done = true
end
end
elseif default and inheritance then
if current ~= default then
local data = nsdata[default]
head = insert_node_before(head,stack,copy_node(data[nsforced or has_attribute(stack,nsselector) or nsselector]))
- current, done = default, true
+ current = default
+ done = true
end
elseif current > 0 then
head = insert_node_before(head,stack,copy_node(nsnone))
current, current_selector, done = 0, 0, true
end
- if id == glue then -- leader
+ if id == glue_code then -- leader
-- same as *list
local content = stack.leader
if content then
local savedcurrent = current
local ci = content.id
- if ci == hlist or ci == vlist then
+ if ci == hlist_code or ci == vlist_code then
-- else we reset inside a box unneeded, okay, the downside is
-- that we trigger color in each repeated box, so there is room
-- for improvement here
@@ -341,7 +360,7 @@ local function selective(namespace,attribute,head,inheritance,default) -- two at
done = done or ok
end
end
- elseif id == hlist or id == vlist then
+ elseif id == hlist_code or id == vlist_code then
local content = stack.list
if content then
local ok = false
@@ -376,7 +395,7 @@ local function stacked(namespace,attribute,head,default) -- no triggering, no in
local current, depth = default or 0, 0
while stack do
local id = stack.id
- if id == glyph or (id == rule and stack.width ~= 0) or (id == glue and stack.leader) then -- or disc
+ if id == glyph_code or (id == rule_code and stack.width ~= 0) or (id == glue_code and stack.leader) then -- or disc_code
local c = has_attribute(stack,attribute)
if c then
if current ~= c then
@@ -384,7 +403,7 @@ local function stacked(namespace,attribute,head,default) -- no triggering, no in
depth = depth + 1
current, done = c, true
end
- if id == glue then
+ if id == glue_code then
local content = stack.leader
if content then -- unchecked
local ok = false
@@ -392,14 +411,15 @@ local function stacked(namespace,attribute,head,default) -- no triggering, no in
done = done or ok
end
end
- elseif default then
+--~ elseif default then
+ elseif default > 0 then
--
elseif current > 0 then
head = insert_node_before(head,stack,copy_node(nsnone))
depth = depth - 1
current, done = 0, true
end
- elseif id == hlist or id == vlist then
+ elseif id == hlist_code or id == vlist_code then
local content = stack.list
if content then
-- the problem is that broken lines gets the attribute which can be a later one