From 57a61e4673116076f5bbff7600e6dad376af9173 Mon Sep 17 00:00:00 2001 From: Context Git Mirror Bot Date: Mon, 11 Apr 2016 10:29:07 +0200 Subject: 2016-04-10 23:57:00 --- scripts/context/lua/mtx-context.lua | 1 + scripts/context/lua/mtx-fonts.lua | 34 +-- scripts/context/lua/mtx-interface.lua | 398 ++++++++++++++++++--------------- scripts/context/lua/mtxrun.lua | 8 +- scripts/context/stubs/mswin/mtxrun.lua | 8 +- scripts/context/stubs/unix/mtxrun | 8 +- scripts/context/stubs/win64/mtxrun.lua | 8 +- 7 files changed, 253 insertions(+), 212 deletions(-) (limited to 'scripts') diff --git a/scripts/context/lua/mtx-context.lua b/scripts/context/lua/mtx-context.lua index 7c64687b9..dce9170cc 100644 --- a/scripts/context/lua/mtx-context.lua +++ b/scripts/context/lua/mtx-context.lua @@ -731,6 +731,7 @@ function scripts.context.run(ctxdata,filename) end end -- + -- todo: --output-file=... in luatex -- local l_flags = { ["interaction"] = a_batchmode, diff --git a/scripts/context/lua/mtx-fonts.lua b/scripts/context/lua/mtx-fonts.lua index 79c8cf65e..a83d8fc48 100644 --- a/scripts/context/lua/mtx-fonts.lua +++ b/scripts/context/lua/mtx-fonts.lua @@ -242,17 +242,18 @@ end local function showfeatures(tag,specification) report() - report("mapping : %s",tag) - report("fontname: %s",specification.fontname) - report("fullname: %s",specification.fullname) - report("filename: %s",specification.filename) - report("family : %s",specification.familyname or "") - report("weight : %s",specification.weight or "") - report("style : %s",specification.style or "") - report("width : %s",specification.width or "") - report("variant : %s",specification.variant or "") - report("subfont : %s",subfont(specification.subfont)) - report("fweight : %s",fontweight(specification.fontweight)) + report("mapping : %s",tag) + report("fontname : %s",specification.fontname) + report("fullname : %s",specification.fullname) + report("filename : %s",specification.filename) + report("family : %s",specification.familyname or "") + -- report("subfamily : %s",specification.subfamilyname or "") + report("weight : %s",specification.weight or "") + report("style : %s",specification.style or "") + report("width : %s",specification.width or "") + report("variant : %s",specification.variant or "") + report("subfont : %s",subfont(specification.subfont)) + report("fweight : %s",fontweight(specification.fontweight)) -- maybe more local features = fonts.helpers.getfeatures(specification.filename,specification.format) if features then @@ -306,11 +307,12 @@ local function list_specifications(t,info) local v = s[k] local entry = t[v] s[k] = { - entry.familyname or "", - entry.weight or "", - entry.style or "", - entry.width or "", - entry.variant or "", + entry.familyname or "", + -- entry.subfamilyname or "", + entry.weight or "", + entry.style or "", + entry.width or "", + entry.variant or "", entry.fontname, entry.filename, subfont(entry.subfont), diff --git a/scripts/context/lua/mtx-interface.lua b/scripts/context/lua/mtx-interface.lua index d0c889c9f..c5fb7c595 100644 --- a/scripts/context/lua/mtx-interface.lua +++ b/scripts/context/lua/mtx-interface.lua @@ -21,9 +21,7 @@ local helpinfo = [[ - generate context interface files - generate context message files - generate context label files + generate context mkii interface files equals @@ -228,87 +226,229 @@ function flushers.textpad(collected) end end +-- function scripts.interface.editor(editor,split,forcedinterfaces) +-- local interfaces= forcedinterfaces or environment.files +-- if #interfaces == 0 then +-- interfaces= userinterfaces +-- end +-- local xmlfile = resolvers.findfile("cont-en.xml") or "" +-- if xmlfile == "" then +-- report("unable to locate cont-en.xml") +-- end +-- local collected = { } +-- for i=1,#interfaces do +-- local interface = interfaces[i] +-- local keyfile = resolvers.findfile(format("keys-%s.xml",interface)) or "" +-- if keyfile == "" then +-- report("unable to locate keys-*.xml") +-- else +-- local commands = { } +-- local mappings = { } +-- local environments = { } +-- local x = xml.load(keyfile) +-- for e, d, k in xml.elements(x,"/cd:interface/cd:commands/cd:command") do -- somehow this was variable +-- local at = d[k].at +-- local name, value = at.name, at.value +-- if name and value then +-- mappings[name] = value +-- end +-- end +-- local x = xml.load(xmlfile) +-- for e, d, k in xml.elements(x,"/cd:interface/cd:command") do +-- local at = d[k].at +-- local name, type = at.name, at["type"] +-- if name and name ~= "" then +-- local remapped = mappings[name] or name +-- if type == "environment" then +-- if split then +-- environments[#environments+1] = remapped +-- else +-- commands[#commands+1] = "start" .. remapped +-- commands[#commands+1] = "stop" .. remapped +-- end +-- else +-- commands[#commands+1] = remapped +-- end +-- end +-- end +-- if #commands > 0 then +-- sort(commands) +-- sort(environments) +-- collected[interface] = { +-- commands = commands, +-- environments = environments, +-- } +-- end +-- end +-- end +-- -- awaiting completion of the xml file +-- local definitions = dofile(resolvers.findfile("mult-def.lua")) +-- if definitions then +-- local commands = { en = { } } +-- for command, languages in next, definitions.commands do +-- commands.en[languages.en or command] = true +-- for language, command in next, languages do +-- local c = commands[language] +-- if c then +-- c[command] = true +-- else +-- commands[language] = { [command] = true } +-- end +-- end +-- end +-- for language, data in next, commands do +-- local fromlua = data +-- local fromxml = collected[language].commands +-- for i=1,#fromxml do +-- local c = fromxml[i] +-- if not fromlua[c] then +-- -- print(language,c) +-- fromlua[c] = true +-- end +-- end +-- collected[language].commands = table.sortedkeys(fromlua) +-- end +-- end +-- -- +-- flushers[editor](collected) +-- end + +-- function scripts.interface.editor(editor,split,forcedinterfaces) +-- local interfaces= forcedinterfaces or environment.files +-- if #interfaces == 0 then +-- interfaces= userinterfaces +-- end +-- -- +-- local filename = "context-en.xml" +-- local xmlfile = resolvers.findfile(filename) or "" +-- if xmlfile == "" then +-- report("unable to locate %a",filename) +-- return +-- end +-- local x = xml.load(xmlfile) +-- -- +-- local filename = "mult-def.lua" +-- local deffile = resolvers.findfile(filename) or "" +-- if deffile == "" then +-- report("unable to locate %a",filename) +-- return +-- end +-- local interface = dofile(filename) +-- if not interface or not next(interface) then +-- report("invalid file %a",filename) +-- return +-- end +-- local variables = interface.variables +-- local constants = interface.constants +-- local commands = interface.commands +-- local elements = interface.elements +-- local collected = { } +-- for i=1,#interfaces do +-- local interface = interfaces[i] +-- local i_commands = { } +-- local i_environments = { } +-- local start = elements.start[interface] or elements.start.en +-- local stop = elements.stop [interface] or elements.stop .en +-- for e, d, k in xml.elements(x,"cd:interface/cd:command") do +-- local at = d[k].at +-- local name = at["name"] or "" +-- local type = at["type"] +-- if name ~= "" then +-- local c = commands[name] +-- local n = c and (c[interface] or c.en) or name +-- if type ~= "environment" then +-- i_commands[#i_commands+1] = n +-- elseif split then +-- i_environments[#i_environments+1] = n +-- else +-- -- variables ? +-- i_commands[#i_commands+1] = start .. n +-- i_commands[#i_commands+1] = stop .. n +-- end +-- end +-- end +-- if #i_commands > 0 then +-- sort(i_commands) +-- sort(i_environments) +-- collected[interface] = { +-- commands = i_commands, +-- environments = i_environments, +-- } +-- end +-- end +-- -- +-- flushers[editor](collected) +-- end + function scripts.interface.editor(editor,split,forcedinterfaces) local interfaces= forcedinterfaces or environment.files if #interfaces == 0 then interfaces= userinterfaces end - local xmlfile = resolvers.findfile("cont-en.xml") or "" + -- + local filename = "i-context.xml" + local xmlfile = resolvers.findfile(filename) or "" if xmlfile == "" then - report("unable to locate cont-en.xml") + report("unable to locate %a",filename) + return + end + -- + local filename = "mult-def.lua" + local deffile = resolvers.findfile(filename) or "" + if deffile == "" then + report("unable to locate %a",filename) + return + end + local interface = dofile(deffile) + if not interface or not next(interface) then + report("invalid file %a",filename) + return end + local variables = interface.variables + local constants = interface.constants + local commands = interface.commands + local elements = interface.elements + -- local collected = { } + -- + local xmlroot = xml.load(xmlfile) + xml.include(xmlroot,"cd:interfacefile","filename",true,function(s) + return io.loaddata(resolvers.findfile(s)) + end) + -- for i=1,#interfaces do - local interface = interfaces[i] - local keyfile = resolvers.findfile(format("keys-%s.xml",interface)) or "" - if keyfile == "" then - report("unable to locate keys-*.xml") - else - local commands = { } - local mappings = { } - local environments = { } - local x = xml.load(keyfile) - for e, d, k in xml.elements(x,"/cd:interface/cd:commands/cd:command") do -- somehow this was variable - local at = d[k].at - local name, value = at.name, at.value - if name and value then - mappings[name] = value - end - end - local x = xml.load(xmlfile) - for e, d, k in xml.elements(x,"/cd:interface/cd:command") do - local at = d[k].at - local name, type = at.name, at["type"] - if name and name ~= "" then - local remapped = mappings[name] or name - if type == "environment" then - if split then - environments[#environments+1] = remapped - else - commands[#commands+1] = "start" .. remapped - commands[#commands+1] = "stop" .. remapped - end - else - commands[#commands+1] = remapped - end - end - end - if #commands > 0 then - sort(commands) - sort(environments) - collected[interface] = { - commands = commands, - environments = environments, - } - end - end - end - -- awaiting completion of the xml file - local definitions = dofile(resolvers.findfile("mult-def.lua")) - if definitions then - local commands = { en = { } } - for command, languages in next, definitions.commands do - commands.en[languages.en or command] = true - for language, command in next, languages do - local c = commands[language] - if c then - c[command] = true + local interface = interfaces[i] + local i_commands = { } + local i_environments = { } + local start = elements.start[interface] or elements.start.en + local stop = elements.stop [interface] or elements.stop .en + for e in xml.collected(xmlroot,"cd:interface/cd:command") do + local at = e.at + local name = at["name"] or "" + local type = at["type"] + if name ~= "" then + local c = commands[name] + local n = c and (c[interface] or c.en) or name + if at.generated == "yes" then + -- skip (for now) + elseif type ~= "environment" then + i_commands[#i_commands+1] = n + elseif split then + i_environments[#i_environments+1] = n else - commands[language] = { [command] = true } + -- variables ? + i_commands[#i_commands+1] = start .. n + i_commands[#i_commands+1] = stop .. n end end end - for language, data in next, commands do - local fromlua = data - local fromxml = collected[language].commands - for i=1,#fromxml do - local c = fromxml[i] - if not fromlua[c] then - -- print(language,c) - fromlua[c] = true - end - end - collected[language].commands = table.sortedkeys(fromlua) + if #i_commands > 0 then + sort(i_commands) + sort(i_environments) + collected[interface] = { + commands = i_commands, + environments = i_environments, + } end end -- @@ -341,7 +481,7 @@ function scripts.interface.check() end end -function scripts.interface.interfaces() +function scripts.interface.mkii() local filename = resolvers.findfile(environment.files[1] or "mult-def.lua") or "" if filename ~= "" then local interface = dofile(filename) @@ -386,6 +526,7 @@ function scripts.interface.interfaces() end -- we could just replace attributes for language, _ in next, commands.setuplayout do + -- keyword files local texresult, xmlresult = { }, { } texresult[#texresult+1] = format("%% this file is auto-generated, don't edit this file\n%%") xmlresult[#xmlresult+1] = format("\n",tag) @@ -402,9 +543,10 @@ function scripts.interface.interfaces() report("saving interface definitions '%s'",texfilename) io.savedata(xmlfilename,concat(xmlresult,"\n")) report("saving interface translations '%s'",xmlfilename) + -- mkii files if language ~= "en" and xmldata ~= "" then local newdata = xmldata:gsub("( %s\n",what,kind)) --- for tag, data in table.sortedpairs(whatdata) do --- if not data.hidden then --- f:write("\n") --- for language, text in table.sortedpairs(data.labels) do --- if text ~= "" then --- if expand then --- text = utfgsub(text,".",contextnames) --- text = gsub(text," ", "\ ") --- end --- if namespace and namespace[tag] then --- tag = prefix .. tag --- end --- if find(text,",") then --- text = "{" .. text .. "}" --- end --- if text == "" then --- -- skip --- else --- if type(text) == "table" then --- f:write(format("\\setup%stext[\\s!%s][%s={{%s},}]\n",kind,language,tag,text)) --- else --- f:write(format("\\setup%stext[\\s!%s][%s={{%s},{%s}}]\n",kind,language,tag,text[1],text[2])) --- end --- end --- end --- end --- end --- end --- end --- function flushall(txtname,expand) --- local f = io.open(txtname,"w") --- if f then --- report("saving '%s'",txtname) --- f:write("% this file is auto-generated, don't edit this file\n") --- flush(f,"head","titles",expand,variables,"\\v!") --- flush(f,"label","texts",expand,variables,"\\v!") --- flush(f,"mathlabel","functions",expand) --- flush(f,"taglabel","tags",expand) --- f:write("\n") --- f:write("\\endinput\n") --- f:close() --- end --- end --- flushall("lang-txt.mkii",true) --- flushall("lang-txt.mkiv",false) --- end - local ea = environment.argument -if ea("context") then - scripts.interface.interfaces() - -- scripts.interface.messages() - -- scripts.interface.labels() -elseif ea("interfaces") or ea("messages") or ea("labels") then - if ea("interfaces") then - scripts.interface.interfaces() - end - -- if ea("messages") then - -- scripts.interface.messages() - -- end - -- if ea("labels") then - -- scripts.interface.labels() - -- end +if ea("mkii") then + scripts.interface.mkii() elseif ea("preprocess") then scripts.interface.preprocess() elseif ea("toutf") then diff --git a/scripts/context/lua/mtxrun.lua b/scripts/context/lua/mtxrun.lua index 176598941..d0251f8b9 100644 --- a/scripts/context/lua/mtxrun.lua +++ b/scripts/context/lua/mtxrun.lua @@ -7972,7 +7972,7 @@ do -- create closure to overcome 200 locals limit package.loaded["trac-log"] = package.loaded["trac-log"] or true --- original size: 30753, stripped down to: 21355 +-- original size: 30767, stripped down to: 21355 if not modules then modules={} end modules ['trac-log']={ version=1.001, @@ -8016,7 +8016,7 @@ local report,subreport,status,settarget,setformats,settranslations local direct,subdirect,writer,pushtarget,poptarget,setlogfile,settimedlog,setprocessor,setformatters,newline if tex and (tex.jobname or tex.formatname) then if texio.setescape then - texio.setescape(0) + texio.setescape(0) end local function useluawrites() local texio_write_nl=texio.write_nl @@ -18735,8 +18735,8 @@ end -- of closure -- used libraries : l-lua.lua l-package.lua l-lpeg.lua l-function.lua l-string.lua l-table.lua l-io.lua l-number.lua l-set.lua l-os.lua l-file.lua l-gzip.lua l-md5.lua l-url.lua l-dir.lua l-boolean.lua l-unicode.lua l-math.lua util-str.lua util-tab.lua util-fil.lua util-sac.lua util-sto.lua util-prs.lua util-fmt.lua trac-set.lua trac-log.lua trac-inf.lua trac-pro.lua util-lua.lua util-deb.lua util-mrg.lua util-tpl.lua util-env.lua luat-env.lua lxml-tab.lua lxml-lpt.lua lxml-mis.lua lxml-aux.lua lxml-xml.lua trac-xml.lua data-ini.lua data-exp.lua data-env.lua data-tmp.lua data-met.lua data-res.lua data-pre.lua data-inp.lua data-out.lua data-fil.lua data-con.lua data-use.lua data-zip.lua data-tre.lua data-sch.lua data-lua.lua data-aux.lua data-tmf.lua data-lst.lua util-lib.lua luat-sta.lua luat-fmt.lua -- skipped libraries : - --- original bytes : 796558 --- stripped bytes : 288905 +-- original bytes : 796572 +-- stripped bytes : 288919 -- end library merge diff --git a/scripts/context/stubs/mswin/mtxrun.lua b/scripts/context/stubs/mswin/mtxrun.lua index 176598941..d0251f8b9 100644 --- a/scripts/context/stubs/mswin/mtxrun.lua +++ b/scripts/context/stubs/mswin/mtxrun.lua @@ -7972,7 +7972,7 @@ do -- create closure to overcome 200 locals limit package.loaded["trac-log"] = package.loaded["trac-log"] or true --- original size: 30753, stripped down to: 21355 +-- original size: 30767, stripped down to: 21355 if not modules then modules={} end modules ['trac-log']={ version=1.001, @@ -8016,7 +8016,7 @@ local report,subreport,status,settarget,setformats,settranslations local direct,subdirect,writer,pushtarget,poptarget,setlogfile,settimedlog,setprocessor,setformatters,newline if tex and (tex.jobname or tex.formatname) then if texio.setescape then - texio.setescape(0) + texio.setescape(0) end local function useluawrites() local texio_write_nl=texio.write_nl @@ -18735,8 +18735,8 @@ end -- of closure -- used libraries : l-lua.lua l-package.lua l-lpeg.lua l-function.lua l-string.lua l-table.lua l-io.lua l-number.lua l-set.lua l-os.lua l-file.lua l-gzip.lua l-md5.lua l-url.lua l-dir.lua l-boolean.lua l-unicode.lua l-math.lua util-str.lua util-tab.lua util-fil.lua util-sac.lua util-sto.lua util-prs.lua util-fmt.lua trac-set.lua trac-log.lua trac-inf.lua trac-pro.lua util-lua.lua util-deb.lua util-mrg.lua util-tpl.lua util-env.lua luat-env.lua lxml-tab.lua lxml-lpt.lua lxml-mis.lua lxml-aux.lua lxml-xml.lua trac-xml.lua data-ini.lua data-exp.lua data-env.lua data-tmp.lua data-met.lua data-res.lua data-pre.lua data-inp.lua data-out.lua data-fil.lua data-con.lua data-use.lua data-zip.lua data-tre.lua data-sch.lua data-lua.lua data-aux.lua data-tmf.lua data-lst.lua util-lib.lua luat-sta.lua luat-fmt.lua -- skipped libraries : - --- original bytes : 796558 --- stripped bytes : 288905 +-- original bytes : 796572 +-- stripped bytes : 288919 -- end library merge diff --git a/scripts/context/stubs/unix/mtxrun b/scripts/context/stubs/unix/mtxrun index 176598941..d0251f8b9 100644 --- a/scripts/context/stubs/unix/mtxrun +++ b/scripts/context/stubs/unix/mtxrun @@ -7972,7 +7972,7 @@ do -- create closure to overcome 200 locals limit package.loaded["trac-log"] = package.loaded["trac-log"] or true --- original size: 30753, stripped down to: 21355 +-- original size: 30767, stripped down to: 21355 if not modules then modules={} end modules ['trac-log']={ version=1.001, @@ -8016,7 +8016,7 @@ local report,subreport,status,settarget,setformats,settranslations local direct,subdirect,writer,pushtarget,poptarget,setlogfile,settimedlog,setprocessor,setformatters,newline if tex and (tex.jobname or tex.formatname) then if texio.setescape then - texio.setescape(0) + texio.setescape(0) end local function useluawrites() local texio_write_nl=texio.write_nl @@ -18735,8 +18735,8 @@ end -- of closure -- used libraries : l-lua.lua l-package.lua l-lpeg.lua l-function.lua l-string.lua l-table.lua l-io.lua l-number.lua l-set.lua l-os.lua l-file.lua l-gzip.lua l-md5.lua l-url.lua l-dir.lua l-boolean.lua l-unicode.lua l-math.lua util-str.lua util-tab.lua util-fil.lua util-sac.lua util-sto.lua util-prs.lua util-fmt.lua trac-set.lua trac-log.lua trac-inf.lua trac-pro.lua util-lua.lua util-deb.lua util-mrg.lua util-tpl.lua util-env.lua luat-env.lua lxml-tab.lua lxml-lpt.lua lxml-mis.lua lxml-aux.lua lxml-xml.lua trac-xml.lua data-ini.lua data-exp.lua data-env.lua data-tmp.lua data-met.lua data-res.lua data-pre.lua data-inp.lua data-out.lua data-fil.lua data-con.lua data-use.lua data-zip.lua data-tre.lua data-sch.lua data-lua.lua data-aux.lua data-tmf.lua data-lst.lua util-lib.lua luat-sta.lua luat-fmt.lua -- skipped libraries : - --- original bytes : 796558 --- stripped bytes : 288905 +-- original bytes : 796572 +-- stripped bytes : 288919 -- end library merge diff --git a/scripts/context/stubs/win64/mtxrun.lua b/scripts/context/stubs/win64/mtxrun.lua index 176598941..d0251f8b9 100644 --- a/scripts/context/stubs/win64/mtxrun.lua +++ b/scripts/context/stubs/win64/mtxrun.lua @@ -7972,7 +7972,7 @@ do -- create closure to overcome 200 locals limit package.loaded["trac-log"] = package.loaded["trac-log"] or true --- original size: 30753, stripped down to: 21355 +-- original size: 30767, stripped down to: 21355 if not modules then modules={} end modules ['trac-log']={ version=1.001, @@ -8016,7 +8016,7 @@ local report,subreport,status,settarget,setformats,settranslations local direct,subdirect,writer,pushtarget,poptarget,setlogfile,settimedlog,setprocessor,setformatters,newline if tex and (tex.jobname or tex.formatname) then if texio.setescape then - texio.setescape(0) + texio.setescape(0) end local function useluawrites() local texio_write_nl=texio.write_nl @@ -18735,8 +18735,8 @@ end -- of closure -- used libraries : l-lua.lua l-package.lua l-lpeg.lua l-function.lua l-string.lua l-table.lua l-io.lua l-number.lua l-set.lua l-os.lua l-file.lua l-gzip.lua l-md5.lua l-url.lua l-dir.lua l-boolean.lua l-unicode.lua l-math.lua util-str.lua util-tab.lua util-fil.lua util-sac.lua util-sto.lua util-prs.lua util-fmt.lua trac-set.lua trac-log.lua trac-inf.lua trac-pro.lua util-lua.lua util-deb.lua util-mrg.lua util-tpl.lua util-env.lua luat-env.lua lxml-tab.lua lxml-lpt.lua lxml-mis.lua lxml-aux.lua lxml-xml.lua trac-xml.lua data-ini.lua data-exp.lua data-env.lua data-tmp.lua data-met.lua data-res.lua data-pre.lua data-inp.lua data-out.lua data-fil.lua data-con.lua data-use.lua data-zip.lua data-tre.lua data-sch.lua data-lua.lua data-aux.lua data-tmf.lua data-lst.lua util-lib.lua luat-sta.lua luat-fmt.lua -- skipped libraries : - --- original bytes : 796558 --- stripped bytes : 288905 +-- original bytes : 796572 +-- stripped bytes : 288919 -- end library merge -- cgit v1.2.3