From a104570ad82618ffffc82ffea3f12c5bb0a35232 Mon Sep 17 00:00:00 2001 From: Context Git Mirror Bot Date: Sat, 16 Apr 2016 16:06:47 +0200 Subject: 2016-04-16 15:32:00 --- tex/context/base/mkiv/mult-ini.lua | 110 ++++++++++++++++++++++++++----------- 1 file changed, 77 insertions(+), 33 deletions(-) (limited to 'tex/context/base/mkiv/mult-ini.lua') diff --git a/tex/context/base/mkiv/mult-ini.lua b/tex/context/base/mkiv/mult-ini.lua index 3fb5416ba..409c735b7 100644 --- a/tex/context/base/mkiv/mult-ini.lua +++ b/tex/context/base/mkiv/mult-ini.lua @@ -215,6 +215,8 @@ function interfaces.setuserinterface(interface,response) sharedstorage.currentinterface, currentinterface = interface, interface sharedstorage.currentresponse, currentresponse = response, response if environment.initex then + local setmacro = false + -- local setmacro = interfaces.setmacro -- cleaner (but we need to test first) local nofconstants = 0 local nofvariables = 0 local nofelements = 0 @@ -222,49 +224,91 @@ function interfaces.setuserinterface(interface,response) local nofformats = 0 local noftranslations = 0 local nofsetupstrings = 0 - local t, n, f, s -- - t, n, f, s = { }, 0, formatters["\\ui_c{%s}{%s}"], formatters["\\ui_s{%s}"] - for given, constant in next, complete.constants do - constant = constant[interface] or constant.en or given - constants[constant] = given -- breedte -> width - nofconstants = nofconstants + 1 - if given == constant then - t[nofconstants] = s(given) - else - t[nofconstants] = f(given,constant) + if setmacro then + for given, constant in next, complete.constants do + constant = constant[interface] or constant.en or given + constants[constant] = given -- breedte -> width + nofconstants = nofconstants + 1 + setmacro("c!"..given,given) + if currentinterface ~= "en" then + setmacro("k!"..constant,given) + end + end + else + local t, f, s = { }, formatters["\\ui_c{%s}{%s}"], formatters["\\ui_s{%s}"] + for given, constant in next, complete.constants do + constant = constant[interface] or constant.en or given + constants[constant] = given -- breedte -> width + nofconstants = nofconstants + 1 + if given == constant then + t[nofconstants] = s(given) + else + t[nofconstants] = f(given,constant) + end end + contextsprint(prtcatcodes,concat(t)) end - contextsprint(prtcatcodes,concat(t)) -- - t, n, f = { }, 0, formatters["\\ui_v{%s}{%s}"] - for given, variable in next, complete.variables do - variable = variable[interface] or variable.en or given - variables[given] = variable -- ja -> yes - nofvariables = nofvariables + 1 - t[nofvariables] = f(given,variable) + if setmacro then + for given, variable in next, complete.variables do + variable = variable[interface] or variable.en or given + variables[given] = variable -- ja -> yes + nofvariables = nofvariables + 1 + setmacro("v!"..given,variable) + end + else + local t, f = { }, formatters["\\ui_v{%s}{%s}"] + for given, variable in next, complete.variables do + variable = variable[interface] or variable.en or given + variables[given] = variable -- ja -> yes + nofvariables = nofvariables + 1 + t[nofvariables] = f(given,variable) + end + contextsprint(prtcatcodes,concat(t)) end - contextsprint(prtcatcodes,concat(t)) -- - t, n, f = { }, 0, formatters["\\ui_e{%s}{%s}"] - for given, element in next, complete.elements do - element = element[interface] or element.en or given - elements[element] = given - nofelements = nofelements + 1 - t[nofelements] = f(given,element) + if setmacro then + for given, element in next, complete.elements do + element = element[interface] or element.en or given + elements[element] = given + nofelements = nofelements + 1 + setmacro("e!"..given,element) + end + else + local t, f = { }, formatters["\\ui_e{%s}{%s}"] + for given, element in next, complete.elements do + element = element[interface] or element.en or given + elements[element] = given + nofelements = nofelements + 1 + t[nofelements] = f(given,element) + end + contextsprint(prtcatcodes,concat(t)) end - contextsprint(prtcatcodes,concat(t)) -- - t, n, f = { }, 0, formatters["\\ui_m{%s}{%s}"] - for given, command in next, complete.commands do - command = command[interface] or command.en or given - if command ~= given then - n = n + 1 - t[n] = f(given,command) + if setmacro then + -- this can only work ok when we already have defined the command + luatex.registerdumpactions(function() + for given, command in next, complete.commands do + command = command[interface] or command.en or given + if command ~= given then + setmacro(prtcatcodes,given,"\\"..command) + end + nofcommands = nofcommands + 1 + end + end) + else + local t, n, f = { }, 0, formatters["\\ui_m{%s}{%s}"] + for given, command in next, complete.commands do + command = command[interface] or command.en or given + if command ~= given then + n = n + 1 + t[n] = f(given,command) + end + nofcommands = nofcommands + 1 end - nofcommands = nofcommands + 1 + contextsprint(prtcatcodes,concat(t)) end - contextsprint(prtcatcodes,concat(t)) -- for given, format in next, complete.messages.formats do formats[given] = format[interface] or format.en or given -- cgit v1.2.3