diff options
author | Context Git Mirror Bot <phg42.2a@gmail.com> | 2014-05-03 13:55:34 +0200 |
---|---|---|
committer | Context Git Mirror Bot <phg42.2a@gmail.com> | 2014-05-03 13:55:34 +0200 |
commit | 624cbb5da392e9403984dd1cf368c0d408b1c2a8 (patch) | |
tree | 489c049ac849bb5bbce7d32e4df477872c58373d /tex/context/base/node-bck.lua | |
parent | 088de88944c1f2254250bb448c7371a87ff7ee39 (diff) | |
download | context-624cbb5da392e9403984dd1cf368c0d408b1c2a8.tar.gz |
2014-01-03 00:42:00
Diffstat (limited to 'tex/context/base/node-bck.lua')
-rw-r--r-- | tex/context/base/node-bck.lua | 111 |
1 files changed, 45 insertions, 66 deletions
diff --git a/tex/context/base/node-bck.lua b/tex/context/base/node-bck.lua index 4b7b4a064..feaa2c684 100644 --- a/tex/context/base/node-bck.lua +++ b/tex/context/base/node-bck.lua @@ -11,8 +11,6 @@ if not modules then modules = { } end modules ['node-bck'] = { local attributes, nodes, node = attributes, nodes, node -local tasks = nodes.tasks - local nodecodes = nodes.nodecodes local listcodes = nodes.listcodes @@ -21,25 +19,11 @@ local vlist_code = nodecodes.vlist local glyph_code = nodecodes.glyph local cell_code = listcodes.cell -local nuts = nodes.nuts -local nodepool = nuts.pool - -local tonode = nuts.tonode -local tonut = nuts.tonut - -local getfield = nuts.getfield -local setfield = nuts.setfield -local getnext = nuts.getnext -local getprev = nuts.getprev -local getid = nuts.getid -local getlist = nuts.getlist -local getattr = nuts.getattr -local setattr = nuts.setattr -local getsubtype = nuts.getsubtype - -local traverse = nuts.traverse -local traverse_id = nuts.traverse_id +local traverse = node.traverse +local traverse_id = node.traverse_id +local nodepool = nodes.pool +local tasks = nodes.tasks local new_rule = nodepool.rule local new_glue = nodepool.glue @@ -53,50 +37,50 @@ local a_alignbackground = attributes.private('alignbackground') local function add_backgrounds(head) -- rather old code .. to be redone local current = head while current do - local id = getid(current) + local id = current.id if id == hlist_code or id == vlist_code then - local list = getlist(current) + local list = current.list if list then local head = add_backgrounds(list) if head then - setfield(current,"list",head) + current.list = head list = head end end - local width = getfield(current,"width") + local width = current.width if width > 0 then - local background = getattr(current,a_background) + local background = current[a_background] if background then -- direct to hbox -- colorspace is already set so we can omit that and stick to color - local mode = getattr(current,a_colorspace) + local mode = current[a_colorspace] if mode then - local height = getfield(current,"height") - local depth = getfield(current,"depth") + local height = current.height + local depth = current.depth local skip = id == hlist_code and width or (height + depth) local glue = new_glue(-skip) local rule = new_rule(width,height,depth) - local color = getattr(current,a_color) - local transparency = getattr(current,a_transparency) - setattr(rule,a_colorspace,mode) + local color = current[a_color] + local transparency = current[a_transparency] + rule[a_colorspace] = mode if color then - setattr(rule,a_color,color) + rule[a_color] = color end if transparency then - setattr(rule,a_transparency,transparency) + rule[a_transparency] = transparency end - setfield(rule,"next",glue) - setfield(glue,"prev",rule) + rule.next = glue + glue.prev = rule if list then - setfield(glue,"next",list) - setfield(list,"prev",glue) + glue.next = list + list.prev = glue end - setfield(current,"list",rule) + current.list = rule end end end end - current = getnext(current) + current = current.next end return head, true end @@ -104,16 +88,16 @@ end local function add_alignbackgrounds(head) local current = head while current do - local id = getid(current) + local id = current.id if id == hlist_code then - local list = getlist(current) + local list = current.list if not list then -- no need to look - elseif getsubtype(current) == cell_code then + elseif current.subtype == cell_code then local background = nil local found = nil -- for l in traverse(list) do - -- background = getattr(l,a_alignbackground) + -- background = l[a_alignbackground] -- if background then -- found = l -- break @@ -122,7 +106,7 @@ local function add_alignbackgrounds(head) -- we know that it's a fake hlist (could be user node) -- but we cannot store tables in user nodes yet for l in traverse_id(hpack_code,list) do - background = getattr(l,a_alignbackground) + background = l[a_alignbackground] if background then found = l end @@ -131,28 +115,28 @@ local function add_alignbackgrounds(head) -- if background then -- current has subtype 5 (cell) - local width = getfield(current,"width") + local width = current.width if width > 0 then - local mode = getattr(found,a_colorspace) + local mode = found[a_colorspace] if mode then local glue = new_glue(-width) - local rule = new_rule(width,getfield(current,"height"),getfield(current,"depth")) - local color = getattr(found,a_color) - local transparency = getattr(found,a_transparency) - setattr(rule,a_colorspace,mode) + local rule = new_rule(width,current.height,current.depth) + local color = found[a_color] + local transparency = found[a_transparency] + rule[a_colorspace] = mode if color then - setattr(rule,a_color,color) + rule[a_color] = color end if transparency then - setattr(rule,a_transparency,transparency) + rule[a_transparency] = transparency end - setfield(rule,"next",glue) - setfield(glue,"prev",rule) + rule.next = glue + glue.prev = rule if list then - setfield(glue,"next",list) - setfield(list,"prev",glue) + glue.next = list + list.prev = glue end - setfield(current,"list",rule) + current.list = rule end end end @@ -160,23 +144,18 @@ local function add_alignbackgrounds(head) add_alignbackgrounds(list) end elseif id == vlist_code then - local list = getlist(current) + local list = current.list if list then add_alignbackgrounds(list) end end - current = getnext(current) + current = current.next end return head, true end --- nodes.handlers.backgrounds = add_backgrounds --- nodes.handlers.alignbackgrounds = add_alignbackgrounds - -nodes.handlers.backgrounds = function(head) local head, done = add_backgrounds (tonut(head)) return tonode(head), done end -nodes.handlers.alignbackgrounds = function(head) local head, done = add_alignbackgrounds(tonut(head)) return tonode(head), done end - --- elsewhere: needs checking +nodes.handlers.backgrounds = add_backgrounds +nodes.handlers.alignbackgrounds = add_alignbackgrounds tasks.appendaction("shipouts","normalizers","nodes.handlers.backgrounds") tasks.appendaction("shipouts","normalizers","nodes.handlers.alignbackgrounds") |