summaryrefslogtreecommitdiff
path: root/tex/generic/context/luatex/luatex-basics-nod.lua
diff options
context:
space:
mode:
authorContext Git Mirror Bot <phg42.2a@gmail.com>2016-05-17 19:31:15 +0200
committerContext Git Mirror Bot <phg42.2a@gmail.com>2016-05-17 19:31:15 +0200
commit2017d30b4ca772c8eeac4fc0eb9b54e547a9a1d8 (patch)
treed96df31f305a095c078ea5fb9f639ca34ac36c12 /tex/generic/context/luatex/luatex-basics-nod.lua
parent53ff76b73cd1f373ecdfb0f7f17df6f352621d6e (diff)
downloadcontext-2017d30b4ca772c8eeac4fc0eb9b54e547a9a1d8.tar.gz
2016-05-17 19:25:00
Diffstat (limited to 'tex/generic/context/luatex/luatex-basics-nod.lua')
-rw-r--r--tex/generic/context/luatex/luatex-basics-nod.lua80
1 files changed, 71 insertions, 9 deletions
diff --git a/tex/generic/context/luatex/luatex-basics-nod.lua b/tex/generic/context/luatex/luatex-basics-nod.lua
index 1ec2895ba..e7b5ab24f 100644
--- a/tex/generic/context/luatex/luatex-basics-nod.lua
+++ b/tex/generic/context/luatex/luatex-basics-nod.lua
@@ -51,14 +51,23 @@ nodes = { }
nodes.pool = { }
nodes.handlers = { }
-local nodecodes = { } for k,v in next, node.types () do nodecodes[string.gsub(v,"_","")] = k end
-local whatcodes = { } for k,v in next, node.whatsits() do whatcodes[string.gsub(v,"_","")] = k end
-local glyphcodes = { [0] = "character", "glyph", "ligature", "ghost", "left", "right" }
-local disccodes = { [0] = "discretionary", "explicit", "automatic", "regular", "first", "second" }
+local nodecodes = { }
+local glyphcodes = node.subtypes("glyph")
+local disccodes = node.subtypes("disc")
+
+for k, v in next, node.types() do
+ v = string.gsub(v,"_","")
+ nodecodes[k] = v
+ nodecodes[v] = k
+end
+for i=0,#glyphcodes do
+ glyphcodes[glyphcodes[i]] = i
+end
+for i=0,#disccodes do
+ disccodes[disccodes[i]] = i
+end
nodes.nodecodes = nodecodes
-nodes.whatcodes = whatcodes
-nodes.whatsitcodes = whatcodes
nodes.glyphcodes = glyphcodes
nodes.disccodes = disccodes
@@ -137,7 +146,6 @@ nodes.slide = node.slide
nodes.vpack = node.vpack
nodes.first_glyph = node.first_glyph
-nodes.first_character = node.first_character
nodes.has_glyph = node.has_glyph or node.first_glyph
nodes.current_attr = node.current_attr
@@ -175,20 +183,71 @@ nodes.tonut = tonut
nuts.tonode = tonode
nuts.tonut = tonut
-
local getfield = direct.getfield
local setfield = direct.setfield
nuts.getfield = getfield
nuts.setfield = setfield
nuts.getnext = direct.getnext
+nuts.setnext = direct.setnext
nuts.getprev = direct.getprev
+nuts.setprev = direct.setprev
+nuts.getboth = direct.getboth
+nuts.setboth = direct.setboth
nuts.getid = direct.getid
-nuts.getattr = getfield
+nuts.getattr = direct.get_attribute or direct.has_attribute or getfield
nuts.setattr = setfield
nuts.getfont = direct.getfont
+nuts.setfont = direct.setfont
nuts.getsubtype = direct.getsubtype
+nuts.setsubtype = direct.setsubtype or function(n,s) setfield(n,"subtype",s) end
nuts.getchar = direct.getchar
+nuts.setchar = direct.setchar
+nuts.getdisc = direct.getdisc
+nuts.setdisc = direct.setdisc
+nuts.setlink = direct.setlink
+nuts.getlist = direct.getlist
+nuts.setlist = direct.setlist or function(n,l) setfield(n,"list",l) end
+nuts.getleader = direct.getleader
+nuts.setleader = direct.setleader or function(n,l) setfield(n,"leader",l) end
+
+if not direct.is_glyph then
+ local getchar = direct.getchar
+ local getid = direct.getid
+ local getfont = direct.getfont
+ local glyph_code = nodes.nodecodes.glyph
+ function direct.is_glyph(n,f)
+ local id = getid(n)
+ if id == glyph_code then
+ if f and getfont(n) == f then
+ return getchar(n)
+ else
+ return false
+ end
+ else
+ return nil, id
+ end
+ end
+ function direct.is_char(n,f)
+ local id = getid(n)
+ if id == glyph_code then
+ if getsubtype(n) >= 256 then
+ return false
+ elseif f and getfont(n) == f then
+ return getchar(n)
+ else
+ return false
+ end
+ else
+ return nil, id
+ end
+ end
+end
+
+nuts.ischar = direct.is_char
+nuts.is_char = direct.is_char
+nuts.isglyph = direct.is_glyph
+nuts.is_glyph = direct.is_glyph
nuts.insert_before = direct.insert_before
nuts.insert_after = direct.insert_after
@@ -203,6 +262,9 @@ nuts.is_node = direct.is_node
nuts.end_of_math = direct.end_of_math
nuts.traverse = direct.traverse
nuts.traverse_id = direct.traverse_id
+nuts.traverse_char = direct.traverse_char
+nuts.ligaturing = direct.ligaturing
+nuts.kerning = direct.kerning
nuts.getprop = nuts.getattr
nuts.setprop = nuts.setattr