summaryrefslogtreecommitdiff
path: root/tex/context/base/mkiv/trac-ctx.lua
diff options
context:
space:
mode:
authorContext Git Mirror Bot <phg42.2a@gmail.com>2016-01-12 17:15:07 +0100
committerContext Git Mirror Bot <phg42.2a@gmail.com>2016-01-12 17:15:07 +0100
commit8d8d528d2ad52599f11250cfc567fea4f37f2a8b (patch)
tree94286bc131ef7d994f9432febaf03fe23d10eef8 /tex/context/base/mkiv/trac-ctx.lua
parentf5aed2e51223c36c84c5f25a6cad238b2af59087 (diff)
downloadcontext-8d8d528d2ad52599f11250cfc567fea4f37f2a8b.tar.gz
2016-01-12 16:26:00
Diffstat (limited to 'tex/context/base/mkiv/trac-ctx.lua')
-rw-r--r--tex/context/base/mkiv/trac-ctx.lua70
1 files changed, 70 insertions, 0 deletions
diff --git a/tex/context/base/mkiv/trac-ctx.lua b/tex/context/base/mkiv/trac-ctx.lua
new file mode 100644
index 000000000..493ce7936
--- /dev/null
+++ b/tex/context/base/mkiv/trac-ctx.lua
@@ -0,0 +1,70 @@
+if not modules then modules = { } end modules ['trac-ctx'] = {
+ version = 1.001,
+ comment = "companion to trac-ctx.mkiv",
+ author = "Hans Hagen, PRAGMA-ADE, Hasselt NL",
+ copyright = "PRAGMA ADE / ConTeXt Development Team",
+ license = "see context related readme files"
+}
+
+local context = context
+local implement = interfaces.implement
+local register = trackers.register
+
+local textrackers = tex.trackers or { }
+local texdirectives = tex.directives or { }
+
+tex.trackers = textrackers
+tex.directives = texdirectives
+
+storage.register("tex/trackers", textrackers, "tex.trackers")
+storage.register("tex/directives",texdirectives,"tex.directives")
+
+local function doit(category,tag,v)
+ local tt = category[tag]
+ if tt then
+ context.unprotect()
+ context(v and tt[1] or tt[2]) -- could be one call
+ context.protect()
+ end
+end
+
+local function initialize(category,register)
+ for tag, commands in next, category do
+ register(tag, function(v) doit(category,tag,v) end) -- todo: v,tag in caller
+ end
+end
+
+local function install(category,register,tag,enable,disable)
+ category[tag] = { enable, disable }
+ register(tag, function(v) doit(category,tag,v) end) -- todo: v,tag in caller
+end
+
+implement {
+ name = "initializetextrackers",
+ actions = function()
+ initialize(textrackers,trackers.register)
+ end
+}
+
+implement {
+ name = "initializetexdirectives",
+ actions = function()
+ initialize(texdirectives,directives.register)
+ end
+}
+
+implement {
+ name = "installtextracker",
+ actions = function(tag,enable,disable)
+ install(textrackers,trackers.register,tag,enable,disable)
+ end,
+ arguments = { "string", "string", "string" }
+}
+
+implement {
+ name = "installtexdirective",
+ actions = function(tag,enable,disable)
+ install(texdirectives,directives.register,tag,enable,disable)
+ end,
+ arguments = { "string", "string", "string" }
+}