summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/context/base/node-tra.lua
diff options
context:
space:
mode:
Diffstat (limited to 'Master/texmf-dist/tex/context/base/node-tra.lua')
-rw-r--r--Master/texmf-dist/tex/context/base/node-tra.lua94
1 files changed, 76 insertions, 18 deletions
diff --git a/Master/texmf-dist/tex/context/base/node-tra.lua b/Master/texmf-dist/tex/context/base/node-tra.lua
index aeaa6769e5e..5acd70baf2e 100644
--- a/Master/texmf-dist/tex/context/base/node-tra.lua
+++ b/Master/texmf-dist/tex/context/base/node-tra.lua
@@ -1,6 +1,6 @@
if not modules then modules = { } end modules ['node-tra'] = {
version = 1.001,
- comment = "companion to node-ini.tex",
+ comment = "companion to node-ini.mkiv",
author = "Hans Hagen, PRAGMA-ADE, Hasselt NL",
copyright = "PRAGMA ADE / ConTeXt Development Team",
license = "see context related readme files"
@@ -8,11 +8,11 @@ if not modules then modules = { } end modules ['node-tra'] = {
--[[ldx--
<p>This is rather experimental. We need more control and some of this
-might become a runtime module instead.</p>
+might become a runtime module instead. This module will be cleaned up!</p>
--ldx]]--
local utf = unicode.utf8
-local format, match, concat, utfchar = string.format, string.match, table.concat, utf.char
+local format, match, concat, rep, utfchar = string.format, string.match, table.concat, string.rep, utf.char
local ctxcatcodes = tex.ctxcatcodes
@@ -26,9 +26,12 @@ nodes.tracers.characters = nodes.tracers.characters or { }
nodes.tracers.steppers = nodes.tracers.steppers or { }
local glyph = node.id('glyph')
+local hlist = node.id('hlist')
+local vlist = node.id('vlist')
local disc = node.id('disc')
local glue = node.id('glue')
local kern = node.id('kern')
+local rule = node.id('rule')
local whatsit = node.id('whatsit')
local copy_node_list = node.copy_list
@@ -137,11 +140,12 @@ function nodes.tracers.characters.start()
end
function nodes.tracers.characters.stop()
tracers.list['characters'] = list
- lmx.set('title', 'ConTeXt Character Processing Information')
- lmx.set('color-background-one', lmx.get('color-background-yellow'))
- lmx.set('color-background-two', lmx.get('color-background-purple'))
- lmx.show('context-characters.lmx')
- lmx.restore()
+ local variables = {
+ ['title'] = 'ConTeXt Character Processing Information',
+ ['color-background-one'] = lmx.get('color-background-yellow'),
+ ['color-background-two'] = lmx.get('color-background-purple'),
+ }
+ lmx.show('context-characters.lmx',variables)
nodes.process_characters = npc
tasks.restart("processors", "characters")
end
@@ -205,7 +209,7 @@ function nodes.tracers.steppers.features()
while f do
if f.id == glyph then
local tfmdata, t = fontdata[f.font], { }
- for feature, value in table.sortedpairs(tfmdata.shared.features) do
+ for feature, value in table.sortedhash(tfmdata.shared.features) do
if feature == "number" or feature == "features" then
-- private
elseif type(value) == "boolean" then
@@ -310,7 +314,7 @@ function nodes.show_list(head, message)
if message then
texio.write_nl(message)
end
- for n in traverse(head) do
+ for n in traverse_nodes(head) do
texio.write_nl(tostring(n))
end
end
@@ -330,7 +334,8 @@ function nodes.tosequence(start,stop,compact)
if start then
local t = { }
while start do
- if start.id == glyph then
+ local id = start.id
+ if id == glyph then
local c = start.char
if compact then
if start.components then
@@ -341,11 +346,19 @@ function nodes.tosequence(start,stop,compact)
else
t[#t+1] = format("U+%04X:%s",c,utfchar(c))
end
+ elseif id == whatsit and start.subtype == 6 or start.subtype == 7 then
+ t[#t+1] = "[" .. start.dir .. "]"
+ elseif id == rule then
+ if compact then
+ t[#t+1] = "|"
+ else
+ t[#t+1] = node_type(id)
+ end
else
if compact then
t[#t+1] = "[]"
else
- t[#t+1] = match(tostring(start),": (%S+)")
+ t[#t+1] = node_type(id)
end
end
if start == stop then
@@ -360,22 +373,22 @@ function nodes.tosequence(start,stop,compact)
return concat(t," ")
end
else
- return "<empty>"
+ return "[empty]"
end
end
function nodes.report(t,done)
if done then
if status.output_active then
- texio.write(format("<++ %s>",count(t)))
+ logs.report("nodes","output, changed, %s nodes",nodes.count(t))
else
- texio.write(format("<+ %s>",count(t)))
+ texio.write("nodes","normal, changed, %s nodes",nodes.count(t))
end
else
if status.output_active then
- texio.write(format("<-- %s>",count(t)))
+ logs.report("nodes","output, unchanged, %s nodes",nodes.count(t))
else
- texio.write(format("<- %s>",count(t)))
+ texio.write("nodes","normal, unchanged, %s nodes",nodes.count(t))
end
end
end
@@ -390,7 +403,7 @@ end
function nodes.ids_to_string(head,tail)
local t, last_id, last_n = { }, nil, 0
- for n in traverse_nodes(head,tail) do
+ for n in traverse_nodes(head,tail) do -- hm, does not stop at tail
local id = n.id
if not last_id then
last_id, last_n = id, 1
@@ -404,6 +417,9 @@ function nodes.ids_to_string(head,tail)
end
last_id, last_n = id, 1
end
+ if n == tail then
+ break
+ end
end
if not last_id then
t[#t+1] = "no nodes"
@@ -414,3 +430,45 @@ function nodes.ids_to_string(head,tail)
end
return concat(t," ")
end
+
+nodes.ids_tostring = nodes.ids_to_string
+
+local function show_simple_list(h,depth,n)
+ while h do
+ texio.write_nl(rep(" ",n) .. tostring(h))
+ if not depth or n < depth then
+ local id = h.id
+ if id == hlist or id == vlist then
+ show_simple_list(h.list,depth,n+1)
+ end
+ end
+ h = h.next
+ end
+end
+
+--~ \startluacode
+--~ callback.register('buildpage_filter',function() nodes.show_simple_list(tex.lists.contrib_head) end)
+--~ \stopluacode
+--~ \vbox{b\footnote{n}a}
+--~ \startluacode
+--~ callback.register('buildpage_filter',nil)
+--~ \stopluacode
+
+nodes.show_simple_list = function(h,depth) show_simple_list(h,depth,0) end
+
+function nodes.list_to_utf(h,joiner)
+ local joiner = (joiner ==true and utfchar(0x200C)) or joiner -- zwnj
+ local w = { }
+ while h do
+ if h.id == glyph then -- always true
+ w[#w+1] = utfchar(h.char)
+ if joiner then
+ w[#w+1] = joiner
+ end
+ else
+ w[#w+1] = "[-]"
+ end
+ h = h.next
+ end
+ return concat(w)
+end