summaryrefslogtreecommitdiff
path: root/tex/context/base/attr-eff.lua
diff options
context:
space:
mode:
authorMarius <mariausol@gmail.com>2010-12-09 15:40:15 +0200
committerMarius <mariausol@gmail.com>2010-12-09 15:40:15 +0200
commitb782434a6f45ef1dd0f67bbfc8670acba6b6659a (patch)
treee8b24b10b08f984b96a6ccf7ace8819431f02fa7 /tex/context/base/attr-eff.lua
parenta0d3450a96f813449290b05e0ef5f2f6de0cbc04 (diff)
downloadcontext-b782434a6f45ef1dd0f67bbfc8670acba6b6659a.tar.gz
beta 2010.12.09 12:11
Diffstat (limited to 'tex/context/base/attr-eff.lua')
-rw-r--r--tex/context/base/attr-eff.lua47
1 files changed, 33 insertions, 14 deletions
diff --git a/tex/context/base/attr-eff.lua b/tex/context/base/attr-eff.lua
index 53610cbff..6ed64f201 100644
--- a/tex/context/base/attr-eff.lua
+++ b/tex/context/base/attr-eff.lua
@@ -12,16 +12,20 @@ local allocate = utilities.storage.allocate
local attributes, nodes = attributes, nodes
-local states = attributes.states
-local tasks = nodes.tasks
-local nodeinjections = backends.nodeinjections
+local states = attributes.states
+local tasks = nodes.tasks
+local nodeinjections = backends.nodeinjections
+local settexattribute = tex.setattribute
attributes.effects = attributes.effects or { }
local effects = attributes.effects
+
+local a_effect = attributes.private('effect')
+
effects.data = allocate()
effects.values = effects.values or { }
effects.registered = effects.registered or { }
-effects.attribute = attributes.private("effect")
+effects.attribute = a_effect
storage.register("attributes/effects/registered", effects.registered, "attributes.effects.registered")
storage.register("attributes/effects/values", effects.values, "attributes.effects.values")
@@ -52,7 +56,15 @@ end
setmetatable(effects, { __index = extender })
setmetatable(effects.data, { __index = reviver })
-function effects.register(effect,stretch,rulethickness)
+effects.handler = nodes.installattributehandler {
+ name = "effect",
+ namespace = effects,
+ initializer = states.initialize,
+ finalizer = states.finalize,
+ processor = states.process,
+}
+
+local function register(effect,stretch,rulethickness)
local stamp = format(template,effect,stretch,rulethickness)
local n = registered[stamp]
if not n then
@@ -63,14 +75,21 @@ function effects.register(effect,stretch,rulethickness)
return n
end
-attributes.effects.handler = nodes.installattributehandler {
- name = "effect",
- namespace = effects,
- initializer = states.initialize,
- finalizer = states.finalize,
- processor = states.process,
-}
-
-function effects.enable()
+local function enable()
tasks.enableaction("shipouts","attributes.effects.handler")
end
+
+effects.register = register
+effects.enable = enable
+
+-- interface
+
+local enabled = false
+
+function commands.triggereffect(effect,stretch,rulethickness)
+ if not enabled then
+ enable()
+ enabled = true
+ end
+ settexattribute(a_effect,register(effect,stretch,rulethickness))
+end