diff options
Diffstat (limited to 'Master/texmf-dist/tex/context/base/attr-ini.lua')
-rw-r--r-- | Master/texmf-dist/tex/context/base/attr-ini.lua | 67 |
1 files changed, 61 insertions, 6 deletions
diff --git a/Master/texmf-dist/tex/context/base/attr-ini.lua b/Master/texmf-dist/tex/context/base/attr-ini.lua index 96d7c7228c7..f3714fcb4d9 100644 --- a/Master/texmf-dist/tex/context/base/attr-ini.lua +++ b/Master/texmf-dist/tex/context/base/attr-ini.lua @@ -32,9 +32,14 @@ storage.register("attributes/names", names, "attributes.names") storage.register("attributes/numbers", numbers, "attributes.numbers") storage.register("attributes/list", list, "attributes.list") +names [0] = "fontdynamic" +numbers["fontdynamic"] = 0 + function attributes.define(name,number) -- at the tex end if not numbers[name] then - numbers[name], names[number], list[number] = number, name, { } + numbers[name] = number + names[number] = name + list[number] = { } end end @@ -85,22 +90,72 @@ end -- new (actually a tracer) -function attributes.ofnode(n) - local a = n.attr - if a then - a = a.next +local report_attribute = logs.reporter("attributes") + +local function showlist(what,list) + if list then + local a = list.next + local i = 0 while a do local number, value = a.number, a.value - texio.write_nl(format("%s : attribute %3i, value %4i, name %s",tostring(n),number,value,names[number] or '?')) + i = i + 1 + report_attribute("%s %2i: attribute %3i, value %4i, name %s",tostring(what),i,number,value,names[number] or '?') a = a.next end end end +function attributes.showcurrent() + showlist("current",node.current_attr()) +end + +function attributes.ofnode(n) + showlist(n,n.attr) +end + -- interface commands.defineattribute = attributes.define +commands.showattributes = attributes.showcurrent function commands.getprivateattribute(name) context(attributes.private(name)) end + +-- rather special + +local store = { } + +function commands.savecurrentattributes(name) + name = name or "" + local n = node.current_attr() + n = n and n.next + local t = { } + while n do + t[n.number] = n.value + n = n.next + end + store[name] = { + attr = t, + font = font.current(), + } +end + +function commands.restorecurrentattributes(name) + name = name or "" + local t = store[name] + if t then + local attr = t.attr + local font = t.font + if attr then + for k, v in next, attr do + tex.attribute[k] = v + end + end + if font then + -- tex.font = font + context.getvalue(fonts.hashes.csnames[font]) -- we don't have a direct way yet (will discuss it with taco) + end + end + -- store[name] = nil +end |