diff options
author | Hans Hagen <pragma@wxs.nl> | 2011-10-02 14:35:00 +0200 |
---|---|---|
committer | Hans Hagen <pragma@wxs.nl> | 2011-10-02 14:35:00 +0200 |
commit | 24aff58a5359beca49ea5f7f0485c535cb8b37bc (patch) | |
tree | 9b3ec4380d6c155e24838d15a8442cb65c13a8ea /tex/context/base/attr-ini.lua | |
parent | e8749bfa2bcf0582f7fa93699b4eb9d5924785e8 (diff) | |
download | context-24aff58a5359beca49ea5f7f0485c535cb8b37bc.tar.gz |
beta 2011.10.02 14:35
Diffstat (limited to 'tex/context/base/attr-ini.lua')
-rw-r--r-- | tex/context/base/attr-ini.lua | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/tex/context/base/attr-ini.lua b/tex/context/base/attr-ini.lua index d29809706..c382302f0 100644 --- a/tex/context/base/attr-ini.lua +++ b/tex/context/base/attr-ini.lua @@ -106,3 +106,41 @@ commands.defineattribute = attributes.define 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 |