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/typo-inj.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/typo-inj.lua')
-rw-r--r-- | Master/texmf-dist/tex/context/base/typo-inj.lua | 94 |
1 files changed, 94 insertions, 0 deletions
diff --git a/Master/texmf-dist/tex/context/base/typo-inj.lua b/Master/texmf-dist/tex/context/base/typo-inj.lua new file mode 100644 index 00000000000..b5d9e1c513a --- /dev/null +++ b/Master/texmf-dist/tex/context/base/typo-inj.lua @@ -0,0 +1,94 @@ +if not modules then modules = { } end modules ['typo-inj'] = { -- was node-par + version = 1.001, + comment = "companion to typo-inj.mkiv", + author = "Hans Hagen, PRAGMA-ADE, Hasselt NL", + copyright = "PRAGMA ADE / ConTeXt Development Team", + license = "see context related readme files" +} + +local tonumber = tonumber + +local context = context +local implement = interfaces.implement + +local injectors = { } +typesetters.injectors = injectors +local list = { } +injectors.list = list +local showall = false + +local settings_to_array = utilities.parsers.settings_to_array + +local ctx_domarkinjector = context.domarkinjector +local ctx_doactivateinjector = context.doactivateinjector + +table.setmetatableindex(list,function(t,k) + local v = { + counter = 0, + actions = { }, + show = false, + active = false, + } + t[k] = v + return v +end) + +function injectors.reset(name) + list[name] = nil +end + +function injectors.set(name,numbers,command) + local injector = list[name] + local actions = injector.actions + local places = settings_to_array(numbers) + for i=1,#places do + actions[tonumber(places[i])] = command + end + if not injector.active then + ctx_doactivateinjector(name) + injector.active = true + end +end + +function injectors.show(name) + if not name or name == "" then + showall = true + else + local list = settings_to_array(name) + for i=1,#list do + list[list[i]].show = true + end + end +end + +function injectors.mark(name,show) + local injector = list[name] + local n = injector.counter + 1 + injector.counter = n + if showall or injector.show then + ctx_domarkinjector(injector.actions[n] and 1 or 0,n) + end +end + +function injectors.check(name,n) -- we could also accent n = number : +/- 2 + local injector = list[name] + if n == false then + n = injector.counter + elseif n == nil then + n = injector.counter + 1 -- next (upcoming) + else + n = tonumber(n) or 0 + end + local action = injector.actions[n] + if action then + context(action) + end +end + +implement { name = "resetinjector", actions = injectors.reset, arguments = "string" } +implement { name = "showinjector", actions = injectors.show, arguments = "string" } +implement { name = "setinjector", actions = injectors.set, arguments = { "string", "string", "string" } } +implement { name = "markinjector", actions = injectors.mark, arguments = "string" } +implement { name = "checkinjector", actions = injectors.check, arguments = "string" } +implement { name = "checkpreviousinjector", actions = injectors.check, arguments = { "string", true } } +implement { name = "checknextinjector", actions = injectors.check } |