2021-11-06 11:38:39 +01:00
|
|
|
local scan_int = token.scan_int
|
2020-08-13 22:24:13 +02:00
|
|
|
local scan_keyword = token.scan_keyword
|
|
|
|
|
2020-05-28 14:37:19 +02:00
|
|
|
-- local names = {}
|
|
|
|
local setters = {
|
|
|
|
}
|
|
|
|
local getters = {
|
|
|
|
}
|
|
|
|
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
|
2021-11-06 13:23:29 +01:00
|
|
|
local integer_code = luametalatex.value.integer
|
2020-05-28 14:37:19 +02:00
|
|
|
local function set_xdir(id, scanning)
|
2020-06-28 04:52:06 +02:00
|
|
|
if scanning == 'value' then
|
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
|
2020-08-13 22:24:13 +02:00
|
|
|
if scan_keyword'tlt' then
|
2020-05-28 14:37:19 +02:00
|
|
|
value = 0
|
2020-08-13 22:24:13 +02:00
|
|
|
elseif scan_keyword'trt' then
|
2020-05-28 14:37:19 +02:00
|
|
|
value = 1
|
|
|
|
else
|
2020-08-13 22:24:13 +02:00
|
|
|
value = scan_int()
|
2020-05-28 14:37:19 +02:00
|
|
|
end
|
2020-08-13 22:24:13 +02:00
|
|
|
setters[id](value, scanning)
|
2020-05-28 14:37:19 +02:00
|
|
|
end
|
|
|
|
return function(name)
|
|
|
|
local getter = tex["get" .. name]
|
|
|
|
local setter = tex["set" .. name]
|
|
|
|
assert(getter and setter, "direction parameter undefined")
|
2021-11-06 13:23:29 +01:00
|
|
|
local idx = luametalatex.luacmd(name, set_xdir, "protected", "global", "value")
|
2020-05-28 14:37:19 +02:00
|
|
|
getters[idx] = getter
|
|
|
|
setters[idx] = setter
|
|
|
|
return idx
|
|
|
|
end
|