From 3668eb2ecc0f7dcc6c44fd1e971cbe37fa010fd6 Mon Sep 17 00:00:00 2001 From: Hans Hagen Date: Fri, 2 Aug 2019 21:03:52 +0200 Subject: 2019-08-02 19:47:00 --- tex/context/base/mkiv/pack-ori.lua | 70 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 70 insertions(+) create mode 100644 tex/context/base/mkiv/pack-ori.lua (limited to 'tex/context/base/mkiv/pack-ori.lua') diff --git a/tex/context/base/mkiv/pack-ori.lua b/tex/context/base/mkiv/pack-ori.lua new file mode 100644 index 000000000..a786b19ef --- /dev/null +++ b/tex/context/base/mkiv/pack-ori.lua @@ -0,0 +1,70 @@ +if not modules then modules = { } end modules ['pack-ori'] = { + version = 1.001, + comment = "companion to supp-box.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 variables = interfaces.variables + +local settings_to_array = utilities.parsers.settings_to_array + +local orientation = { + [variables.up] = 0x000, + [variables.left] = 0x001, + [variables.down] = 0x002, + [variables.right] = 0x003, + [variables.top] = 0x004, + [variables.bottom] = 0x005, +} +local vertical = { + [variables.line] = 0x000, + [variables.top] = 0x010, + [variables.bottom] = 0x020, + [variables.middle] = 0x030, +} +local horizontal = { + [variables.middle] = 0x000, + [variables.flushleft] = 0x100, + [variables.flushright] = 0x200, + [variables.left] = 0x300, + [variables.right] = 0x400, +} + +implement { + name = "toorientation", + public = true, + arguments = { + { + { "horizontal", "string" }, + { "vertical", "string" }, + { "orientation", "string" }, + } + }, + actions = function(t) + local n = 0 + local m = t.horizontal if m then n = n | (horizontal [m] or 0) end + local m = t.vertical if m then n = n | (vertical [m] or 0) end + local m = t.orientation if m then n = n | (orientation[m] or 0) end + -- logs.report("orientation","0x%03X : %s",n,table.sequenced(t)) + context(n) + end, +} + +implement { + name = "stringtoorientation", + public = true, + arguments = "string", + actions = function(s) + local n = 0 + local t = settings_to_array(s) + local m = t[1] if m then n = n | (horizontal [m] or 0) end + local m = t[2] if m then n = n | (vertical [m] or 0) end + local m = t[3] if m then n = n | (orientation[m] or 0) end + -- logs.report("orientation","0x%03X : %s",n,s) + context(n) + end, +} -- cgit v1.2.3