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/typo-fln.lua | |
parent | 088de88944c1f2254250bb448c7371a87ff7ee39 (diff) | |
download | context-624cbb5da392e9403984dd1cf368c0d408b1c2a8.tar.gz |
2014-01-03 00:42:00
Diffstat (limited to 'tex/context/base/typo-fln.lua')
-rw-r--r-- | tex/context/base/typo-fln.lua | 91 |
1 files changed, 38 insertions, 53 deletions
diff --git a/tex/context/base/typo-fln.lua b/tex/context/base/typo-fln.lua index 7ce41cd81..4c97af450 100644 --- a/tex/context/base/typo-fln.lua +++ b/tex/context/base/typo-fln.lua @@ -23,38 +23,25 @@ local firstlines = typesetters.firstlines local nodes = nodes local tasks = nodes.tasks -local nuts = nodes.nuts -local tonut = nuts.tonut -local tonode = nuts.tonode - -local getnext = nuts.getnext -local getid = nuts.getid -local getfield = nuts.getfield -local getlist = nuts.getlist -local getattr = nuts.getattr -local getbox = nuts.getbox - -local setfield = nuts.setfield -local setattr = nuts.setattr - +local getbox = nodes.getbox local nodecodes = nodes.nodecodes local glyph_code = nodecodes.glyph local disc_code = nodecodes.disc local kern_code = nodecodes.kern -local traverse_id = nuts.traverse_id -local free_node_list = nuts.flush_list -local free_node = nuts.flush_node -local copy_node_list = nuts.copy_list -local insert_node_after = nuts.insert_after -local insert_node_before = nuts.insert_before -local hpack_node_list = nuts.hpack -local remove_node = nuts.remove +local traverse_id = nodes.traverse_id +local free_node_list = nodes.flush_list +local free_node = nodes.flush_node +local copy_node_list = nodes.copy_list +local insert_node_after = nodes.insert_after +local insert_node_before = nodes.insert_before +local hpack_node_list = nodes.hpack +local remove_node = nodes.remove -local nodepool = nuts.pool +local nodepool = nodes.pool local newpenalty = nodepool.penalty local newkern = nodepool.kern -local tracerrule = nodes.tracers.pool.nuts.rule +local tracerrule = nodes.tracers.pool.nodes.rule local actions = { } firstlines.actions = actions @@ -105,9 +92,9 @@ actions[v_line] = function(head,setting) local linebreaks = { } for g in traverse_id(glyph_code,temp) do if dynamic > 0 then - setattr(g,0,dynamic) + g[0] = dynamic end - setfield(g,"font",font) + g.font = font end local start = temp local list = temp @@ -121,7 +108,7 @@ actions[v_line] = function(head,setting) hsize = hsize - hangindent end while start do - local id = getid(start) + local id = start.id if id == glyph_code then n = n + 1 elseif id == disc_code then @@ -130,7 +117,7 @@ actions[v_line] = function(head,setting) -- this could be an option elseif n > 0 then local pack = hpack_node_list(copy_node_list(list,start)) - if getfield(pack,"width") > hsize then + if pack.width > hsize then free_node_list(pack) list = prev break @@ -141,7 +128,7 @@ actions[v_line] = function(head,setting) nofchars = n end end - start = getnext(start) + start = start.next end if not linebreaks[i] then linebreaks[i] = n @@ -152,18 +139,18 @@ actions[v_line] = function(head,setting) for i=1,noflines do local linebreak = linebreaks[i] while start and n < nofchars do - local id = getid(start) + local id = start.id if id == glyph_code then -- or id == disc_code then if dynamic > 0 then - setattr(start,0,dynamic) + start[0] = dynamic end - setfield(start,"font",font) + start.font = font if ca and ca > 0 then - setattr(start,a_colorspace,ma == 0 and 1 or ma) - setattr(start,a_color,ca) + start[a_colorspace] = ma == 0 and 1 or ma + start[a_color] = ca end if ta and ta > 0 then - setattr(start,a_transparency,ta) + start[a_transparency] = ta end n = n + 1 end @@ -176,7 +163,7 @@ actions[v_line] = function(head,setting) head, start = insert_node_after(head,start,newpenalty(-10000)) -- break break end - start = getnext(start) + start = start.next end end free_node_list(temp) @@ -195,7 +182,7 @@ actions[v_word] = function(head,setting) local ca = setting.ca local ta = setting.ta while start do - local id = getid(start) + local id = start.id -- todo: delete disc nodes if id == glyph_code then if not ok then @@ -203,16 +190,16 @@ actions[v_word] = function(head,setting) ok = true end if ca and ca > 0 then - setattr(start,a_colorspace,ma == 0 and 1 or ma) - setattr(start,a_color,ca) + start[a_colorspace] = ma == 0 and 1 or ma + start[a_color] = ca end if ta and ta > 0 then - setattr(start,a_transparency,ta) + start[a_transparency] = ta end if dynamic > 0 then - setattr(start,0,dynamic) + start[0] = dynamic end - setfield(start,"font",font) + start.font = font elseif id == disc_code then -- continue elseif id == kern_code then -- todo: fontkern @@ -223,7 +210,7 @@ actions[v_word] = function(head,setting) break end end - start = getnext(start) + start = start.next end return head, true end @@ -231,17 +218,16 @@ end actions[v_default] = actions[v_line] function firstlines.handler(head) - head = tonut(head) local start = head local attr = nil while start do - attr = getattr(start,a_firstline) + attr = start[a_firstline] if attr then break - elseif getid(start) == glyph_code then + elseif start.id == glyph then break else - start = getnext(start) + start = start.next end end if attr then @@ -254,18 +240,17 @@ function firstlines.handler(head) if trace_firstlines then report_firstlines("processing firstlines, alternative %a",alternative) end - local head, done = action(head,settings) - return tonode(head), done + return action(head,settings) end end - return tonode(head), false + return head, false end -- goodie function commands.applytofirstcharacter(box,what) local tbox = getbox(box) -- assumes hlist - local list = getlist(tbox) + local list = tbox.list local done = nil for n in traverse_id(glyph_code,list) do list = remove_node(list,n) @@ -273,10 +258,10 @@ function commands.applytofirstcharacter(box,what) break end if done then - setfield(tbox,"list",list) + tbox.list = list local kind = type(what) if kind == "string" then - context[what](tonode(done)) + context[what](done) elseif kind == "function" then what(done) else |