diff options
Diffstat (limited to 'Master/texmf-dist/tex/context/base/mkiv/node-rul.lua')
-rw-r--r-- | Master/texmf-dist/tex/context/base/mkiv/node-rul.lua | 68 |
1 files changed, 52 insertions, 16 deletions
diff --git a/Master/texmf-dist/tex/context/base/mkiv/node-rul.lua b/Master/texmf-dist/tex/context/base/mkiv/node-rul.lua index 4ec651d3b80..2b0368c2bc5 100644 --- a/Master/texmf-dist/tex/context/base/mkiv/node-rul.lua +++ b/Master/texmf-dist/tex/context/base/mkiv/node-rul.lua @@ -17,6 +17,9 @@ if not modules then modules = { } end modules ['node-rul'] = { -- fill s withcolor .5white ; -- draw boundingbox s withcolor yellow; +local tonumber = tonumber + +local context = context local attributes = attributes local nodes = nodes local properties = nodes.properties @@ -28,13 +31,13 @@ local tonode = nuts.tonode local tonut = nuts.tonut local getfield = nuts.getfield -local setfield = nuts.setfield local setnext = nuts.setnext local setprev = nuts.setprev local setlink = nuts.setlink local getnext = nuts.getnext local getprev = nuts.getprev local getid = nuts.getid +local getdir = nuts.getdir local getattr = nuts.getattr local setattr = nuts.setattr local getfont = nuts.getfont @@ -57,6 +60,7 @@ local traverse_id = nuts.traverse_id local list_dimensions = nuts.rangedimensions local hpack_nodes = nuts.hpack local current_attr = nuts.current_attr +local copy_list = nuts.copy_list local nodecodes = nodes.nodecodes local rulecodes = nodes.rulecodes @@ -82,6 +86,7 @@ local nodepool = nuts.pool local new_rule = nodepool.rule local new_userrule = nodepool.userrule local new_kern = nodepool.kern +local new_leader = nodepool.leader local n_tostring = nodes.idstostring local n_tosequence = nodes.tosequence @@ -125,13 +130,16 @@ local rules = nodes.rules or { } nodes.rules = rules rules.data = rules.data or { } +local nutrules = nuts.rules or { } +nuts.rules = nutrules -- not that many + storage.register("nodes/rules/data", rules.data, "nodes.rules.data") local data = rules.data -- we implement user rules here as it takes less code this way -local function userrule(t,noattributes) +local function usernutrule(t,noattributes) local r = new_userrule(t.width or 0,t.height or 0,t.depth or 0) if noattributes == false or noattributes == nil then -- avoid fuzzy ones @@ -139,7 +147,13 @@ local function userrule(t,noattributes) setattrlist(r,current_attr()) end properties[r] = t - return tonode(r) + return r +end + +nutrules.userrule = usernutrule + +local function userrule(t,noattributes) + return tonode(usernutrule(t,noattributes)) end rules.userrule = userrule @@ -208,8 +222,19 @@ local trace_ruled = false trackers.register("nodes.rules", function(v) trace_ local report_ruled = logs.reporter("nodes","rules") function rules.define(settings) - data[#data+1] = settings - context(#data) + local nofdata = #data+1 + data[nofdata] = settings + local text = settings.text + if text then + local b = nuts.takebox(text) + if b then + nodepool.register(b) + settings.text = getlist(b) + else + settings.text = nil + end + end + context(nofdata) end local function flush_ruled(head,f,l,d,level,parent,strip) -- not that fast but acceptable for this purpose @@ -242,7 +267,6 @@ local function flush_ruled(head,f,l,d,level,parent,strip) -- not that fast but a local method = d.method local empty = d.empty == v_yes local offset = d.offset - local continue = d.continue local dy = d.dy local order = d.order local max = d.max @@ -322,18 +346,28 @@ local function flush_ruled(head,f,l,d,level,parent,strip) -- not that fast but a } inject(tonut(r),w,ht,dp) else - for i=1,level do - local ht = (offset+(i-1)*dy)*e + rulethickness - m - local dp = -(offset+(i-1)*dy)*e + rulethickness + m - local r = new_rule(w,ht,dp) - if color then - setattr(r,a_colormodel,colorspace) - setattr(r,a_color,color) - end - if transparency then - setattr(r,a_transparency,transparency) + local tx = d.text + if tx then + tx = copy_list(tx) + if d["repeat"] == v_yes then + tx = new_leader(w,tx) end + local r = hpack_nodes(tx,w,"exactly") inject(r,w,ht,dp) + else + for i=1,level do + local ht = (offset+(i-1)*dy)*e + rulethickness - m + local dp = -(offset+(i-1)*dy)*e + rulethickness + m + local r = new_rule(w,ht,dp) + if color then + setattr(r,a_colormodel,colorspace) + setattr(r,a_color,color) + end + if transparency then + setattr(r,a_transparency,transparency) + end + inject(r,w,ht,dp) + end end end return head @@ -617,6 +651,8 @@ implement { { "ta", "integer" }, { "mp" }, { "empty" }, + { "text", "integer" }, + { "repeat" }, } } } |