diff options
author | Karl Berry <karl@freefriends.org> | 2013-04-08 00:43:40 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2013-04-08 00:43:40 +0000 |
commit | 824f7b0903de8ad7f6ee3d7656005e4c59155e06 (patch) | |
tree | abfc8673ef9916f3ab7074e811207384c301492b /Master/texmf-dist/tex/context/base/node-aux.lua | |
parent | 689aefb0727676ed3cddf331337b4be226495e72 (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-aux.lua')
-rw-r--r-- | Master/texmf-dist/tex/context/base/node-aux.lua | 110 |
1 files changed, 69 insertions, 41 deletions
diff --git a/Master/texmf-dist/tex/context/base/node-aux.lua b/Master/texmf-dist/tex/context/base/node-aux.lua index 43624adfd3a..e3fc7ad6fe8 100644 --- a/Master/texmf-dist/tex/context/base/node-aux.lua +++ b/Master/texmf-dist/tex/context/base/node-aux.lua @@ -12,13 +12,15 @@ local type, tostring = type, tostring local nodes, node = nodes, node -local utfvalues = string.utfvalues +local utfvalues = utf.values local nodecodes = nodes.nodecodes local glyph_code = nodecodes.glyph local hlist_code = nodecodes.hlist local vlist_code = nodecodes.vlist +local attributelist_code = nodecodes.attributelist -- temporary +local math_code = nodecodes.math local nodepool = nodes.pool @@ -29,20 +31,22 @@ local traverse_nodes = node.traverse local traverse_id = node.traverse_id local free_node = node.free local hpack_nodes = node.hpack -local has_attribute = node.has_attribute -local set_attribute = node.set_attribute -local get_attribute = node.get_attribute local unset_attribute = node.unset_attribute local first_glyph = node.first_glyph or node.first_character local copy_node = node.copy +local copy_node_list = node.copy_list local slide_nodes = node.slide local insert_node_after = node.insert_after local isnode = node.is_node -local current_font = font.current() +local unsetvalue = attributes.unsetvalue + +local current_font = font.current local texbox = tex.box +local report_error = logs.reporter("node-aux:error") + function nodes.repackhlist(list,...) --~ nodes.showsimplelist(list) local temp, b = hpack_nodes(list,...) @@ -54,7 +58,7 @@ end local function set_attributes(head,attr,value) for n in traverse_nodes(head) do - set_attribute(n,attr,value) + n[attr] = value local id = n.id if id == hlist_node or id == vlist_node then set_attributes(n.list,attr,value) @@ -64,8 +68,8 @@ end local function set_unset_attributes(head,attr,value) for n in traverse_nodes(head) do - if not has_attribute(n,attr) then - set_attribute(n,attr,value) + if not n[attr] then + n[attr] = value end local id = n.id if id == hlist_code or id == vlist_code then @@ -76,7 +80,7 @@ end local function unset_attributes(head,attr) for n in traverse_nodes(head) do - unset_attribute(n,attr) + n[attr] = unsetvalue local id = n.id if id == hlist_code or id == vlist_code then unset_attributes(n.list,attr) @@ -84,16 +88,16 @@ local function unset_attributes(head,attr) end end +nodes.setattribute = node.set_attribute +nodes.getattribute = node.has_attribute +nodes.unsetattribute = node.unset_attribute +nodes.has_attribute = node.has_attribute + nodes.firstglyph = first_glyph -nodes.setattribute = set_attribute -nodes.getattribute = has_attribute -nodes.unsetattribute = unset_attribute nodes.setattributes = set_attributes nodes.setunsetattributes = set_unset_attributes nodes.unsetattributes = unset_attributes -nodes.has_attribute = has_attribute - -- function nodes.is_skipable(a,id) -- skipable nodes at the margins during character protrusion -- return ( -- id ~= glyph_node @@ -200,23 +204,33 @@ function nodes.firstcharinbox(n) return 0 end ---~ local function firstline(n) ---~ while n do ---~ local id = n.id ---~ if id == hlist_code then ---~ if n.subtype == line_code then ---~ return n ---~ else ---~ return firstline(n.list) ---~ end ---~ elseif id == vlist_code then ---~ return firstline(n.list) ---~ end ---~ n = n.next ---~ end ---~ end - ---~ nodes.firstline = firstline +if not node.end_of_math then + function node.end_of_math(n) + for n in traverse_id(math_code,n.next) do + return n + end + end +end + +nodes.endofmath = node.end_of_math + +-- local function firstline(n) +-- while n do +-- local id = n.id +-- if id == hlist_code then +-- if n.subtype == line_code then +-- return n +-- else +-- return firstline(n.list) +-- end +-- elseif id == vlist_code then +-- return firstline(n.list) +-- end +-- n = n.next +-- end +-- end + +-- nodes.firstline = firstline -- this depends on fonts, so we have a funny dependency ... will be -- sorted out .. we could make tonodes a plugin into this @@ -264,7 +278,7 @@ end nodes.tonodes = tonodes -local function link(head,tail,list,currentfont,currentattr) +local function link(list,currentfont,currentattr,head,tail) for i=1,#list do local n = list[i] if n then @@ -272,6 +286,9 @@ local function link(head,tail,list,currentfont,currentattr) if not tn then local tn = type(n) if tn == "number" then + if not currentfont then + currentfont = current_font() + end local h, t = tonodes(tostring(n),currentfont,currentattr) if not h then -- skip @@ -282,7 +299,10 @@ local function link(head,tail,list,currentfont,currentattr) end elseif tn == "string" then if #tn > 0 then - local h, t = tonodes(n,font.current(),currentattr) + if not currentfont then + currentfont = current_font() + end + local h, t = tonodes(n,currentfont,currentattr) if not h then -- skip elseif not head then @@ -293,7 +313,10 @@ local function link(head,tail,list,currentfont,currentattr) end elseif tn == "table" then if #tn > 0 then - head, tail = link(head,tail,n,currentfont,currentattr) + if not currentfont then + currentfont = current_font() + end + head, tail = link(n,currentfont,currentattr,head,tail) end end elseif not head then @@ -303,6 +326,14 @@ local function link(head,tail,list,currentfont,currentattr) else tail = n end + elseif n.id == attributelist_code then + -- weird case + report_error("weird node type in list at index %s:",i) + for i=1,#list do + local l = list[i] + report_error("%3i: %s %S",i,l.id == attributelist_code and "!" or ">",l) + end + os.exit() else tail.next = n n.prev = tail @@ -319,10 +350,7 @@ local function link(head,tail,list,currentfont,currentattr) return head, tail end -function nodes.link(...) - local currentfont = font.current - return link(nil,nil,{...},currentfont,currentattr) -end +nodes.link = link local function locate(start,wantedid,wantedsubtype) for n in traverse_nodes(start) do @@ -342,7 +370,7 @@ end nodes.locate = locate -function nodes.concat(list) -- no slide ! +function nodes.concat(list) local head, tail for i=1,#list do local li = list[i] @@ -351,10 +379,10 @@ function nodes.concat(list) -- no slide ! elseif head then tail.next = li li.prev = tail - tail = li + tail = li.next and slide_nodes(li) or li else head = li - tail = li + tail = li.next and slide_nodes(li) or li end end return head, tail |