diff options
author | Karl Berry <karl@freefriends.org> | 2015-04-18 22:52:45 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2015-04-18 22:52:45 +0000 |
commit | 16aa5a7c87f18a2483d0d61795899f886781b51c (patch) | |
tree | 1d72f00b2a4185425393598402fe055c61d1de58 /Master/texmf-dist/tex/context/base/attr-ini.lua | |
parent | e68dc4d5506d46bf72823234f902bc76d1f70352 (diff) |
context, from www.pragma-ade.com/context/beta/cont-tmf.zip (18apr15)
git-svn-id: svn://tug.org/texlive/trunk@36923 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/tex/context/base/attr-ini.lua')
-rw-r--r-- | Master/texmf-dist/tex/context/base/attr-ini.lua | 60 |
1 files changed, 41 insertions, 19 deletions
diff --git a/Master/texmf-dist/tex/context/base/attr-ini.lua b/Master/texmf-dist/tex/context/base/attr-ini.lua index 1e518467cff..df7404d11b0 100644 --- a/Master/texmf-dist/tex/context/base/attr-ini.lua +++ b/Master/texmf-dist/tex/context/base/attr-ini.lua @@ -6,8 +6,6 @@ if not modules then modules = { } end modules ['attr-ini'] = { license = "see context related readme files" } -local commands, context, nodes, storage = commands, context, nodes, storage - local next, type = next, type --[[ldx-- @@ -15,6 +13,13 @@ local next, type = next, type symbolic names later on.</p> --ldx]]-- +local nodes = nodes +local context = context +local storage = storage +local commands = commands + +local implement = interfaces.implement + attributes = attributes or { } local attributes = attributes @@ -53,13 +58,13 @@ storage.register("attributes/list", list, "attributes.list") names[0], numbers["fontdynamic"] = "fontdynamic", 0 --[[ldx-- -<p>We can use the attributes in the range 127-255 (outside user space). These -are only used when no attribute is set at the \TEX\ end which normally -happens in <l n='context'/>.</p> +<p>private attributes are used by the system and public ones are for users. We use dedicated +ranges of numbers for them. Of course a the <l n='context'/> end a private attribute can be +accessible too, so a private attribute can have a public appearance.</p> --ldx]]-- -sharedstorage.attributes_last_private = sharedstorage.attributes_last_private or 127 -sharedstorage.attributes_last_public = sharedstorage.attributes_last_public or 1024 +sharedstorage.attributes_last_private = sharedstorage.attributes_last_private or 127 -- very private (can become 15) +sharedstorage.attributes_last_public = sharedstorage.attributes_last_public or 1024 -- less private function attributes.private(name) -- at the lua end (hidden from user) local number = numbers[name] @@ -97,8 +102,8 @@ end attributes.system = attributes.private -function attributes.define(name,number,category) - return (attributes[category or "public"] or attributes["public"])(name,number) +function attributes.define(name,category) + return (attributes[category or "public"] or attributes["public"])(name) end -- tracers @@ -126,19 +131,11 @@ function attributes.ofnode(n) showlist(n,n.attr) end --- interface - -commands.showattributes = attributes.showcurrent - -function commands.defineattribute(name,category) - context(attributes.define(name,category)) -end - -- rather special local store = { } -function commands.savecurrentattributes(name) +function attributes.save(name) name = name or "" local n = node.current_attr() n = n and n.next @@ -153,7 +150,7 @@ function commands.savecurrentattributes(name) } end -function commands.restorecurrentattributes(name) +function attributes.restore(name) name = name or "" local t = store[name] if t then @@ -171,3 +168,28 @@ function commands.restorecurrentattributes(name) end -- store[name] = nil end + +implement { + name = "defineattribute", + arguments = { "string", "string" }, + actions = { attributes.define, context } +} + +-- interface + +implement { + name = "showattributes", + actions = attributes.showcurrent +} + +implement { + name = "savecurrentattributes", + arguments = "string", + actions = attributes.save +} + +implement { + name = "restorecurrentattributes", + arguments = "string", + actions = attributes.restore +} |