luametalatex/luametalatex-dir-registers.lua

40 lines
1.1 KiB
Lua
Raw Normal View History

2020-05-28 14:37:19 +02:00
-- local names = {}
local setters = {
}
local getters = {
}
local value_values = token.values'value'
for i=0,#value_values do
value_values[value_values[i]] = i
end
function tex.gettextdir() return tex.textdirection end
function tex.getlinedir() return tex.linedirection end
function tex.getmathdir() return tex.mathdirection end
function tex.getpardir() return tex.pardirection end
local integer_code = value_values.integer
local function set_xdir(id, scanning)
2020-06-28 04:52:06 +02:00
if scanning == 'value' then
print(scanning)
2020-05-28 14:37:19 +02:00
return integer_code, getters[id]()
end
2020-06-28 04:52:06 +02:00
-- local global = scanning == 'global'
2020-05-28 14:37:19 +02:00
local value
if token.scan_keyword'tlt' then
value = 0
elseif token.scan_keyword'trt' then
value = 1
else
value = token.scan_int()
end
setters[id](value)
end
return function(name)
local getter = tex["get" .. name]
local setter = tex["set" .. name]
assert(getter and setter, "direction parameter undefined")
local idx = token.luacmd(name, set_xdir, "protected", "global", "value")
getters[idx] = getter
setters[idx] = setter
return idx
end