diff options
-rw-r--r-- | scripts/context/lua/mtx-server-ctx-help.lua | 215 | ||||
-rw-r--r-- | scripts/context/lua/mtxrun.lua | 25 | ||||
-rw-r--r-- | scripts/context/stubs/mswin/mtxrun.lua | 25 | ||||
-rwxr-xr-x | scripts/context/stubs/unix/mtxrun | 25 | ||||
-rw-r--r-- | tex/context/base/cont-new.mkii | 2 | ||||
-rw-r--r-- | tex/context/base/cont-new.mkiv | 2 | ||||
-rw-r--r-- | tex/context/base/context-help.lmx | 1 | ||||
-rw-r--r-- | tex/context/base/context-version.pdf | bin | 4083 -> 4080 bytes | |||
-rw-r--r-- | tex/context/base/context-version.png | bin | 106124 -> 106343 bytes | |||
-rw-r--r-- | tex/context/base/context.mkii | 2 | ||||
-rw-r--r-- | tex/context/base/context.mkiv | 2 | ||||
-rw-r--r-- | tex/context/base/l-url.lua | 2 | ||||
-rw-r--r-- | tex/context/base/status-files.pdf | bin | 24459 -> 24439 bytes | |||
-rw-r--r-- | tex/context/base/status-lua.pdf | bin | 190370 -> 190368 bytes | |||
-rw-r--r-- | tex/context/base/x-dir-05.mkiv | 4 | ||||
-rw-r--r-- | tex/generic/context/luatex/luatex-fonts-merged.lua | 2 |
16 files changed, 208 insertions, 99 deletions
diff --git a/scripts/context/lua/mtx-server-ctx-help.lua b/scripts/context/lua/mtx-server-ctx-help.lua index a212e1369..39a73dc4e 100644 --- a/scripts/context/lua/mtx-server-ctx-help.lua +++ b/scripts/context/lua/mtx-server-ctx-help.lua @@ -15,7 +15,7 @@ dofile(resolvers.findfile("trac-lmx.lua","tex")) -- problem ... serialize parent stack -local format = string.format +local format, match, gsub, find = string.format, string.match, string.gsub, string.find local concat = table.concat local report = logs.reporter("ctx-help") @@ -282,18 +282,48 @@ document.setups.translations = document.setups.translations or { } document.setups.formats = { - open_command = { [[\%s]], [[context.%s (]] }, - close_command = { [[]], [[ )]] }, - connector = { [[]], [[, ]] }, - href_in_list = { [[<a href='mtx-server-ctx-help.lua?command=%s&mode=%s'>%s</a>]], [[<a href='mtx-server-ctx-help.lua?command=%s&mode=%s'>%s</a>]] }, - href_as_command = { [[<a href='mtx-server-ctx-help.lua?command=%s&mode=%s'>\%s</a>]], [[<a href='mtx-server-ctx-help.lua?command=%s&mode=%s'>context.%s</a>]] }, + open_command = { + tex = [[\%s]], + lua = [[context.%s (]], + }, + close_command = { + tex = [[]], + lua = [[ )]], + }, + connector = { + tex = [[]], + lua = [[, ]], + }, + href_in_list = { + tex = [[<a href='mtx-server-ctx-help.lua?command=%s&mode=%s'>%s</a>]], + lua = [[<a href='mtx-server-ctx-help.lua?command=%s&mode=%s'>%s</a>]], + }, + href_as_command = { + tex = [[<a href='mtx-server-ctx-help.lua?command=%s&mode=%s'>\%s</a>]], + lua = [[<a href='mtx-server-ctx-help.lua?command=%s&mode=%s'>context.%s</a>]], + }, + modes = { + tex = [[<a href='mtx-server-ctx-help.lua?mode=lua'>lua mode</a>]], + lua = [[<a href='mtx-server-ctx-help.lua?mode=tex'>tex mode</a>]], + }, + optional_single = { + tex = "[optional string %s]", + lua = "{optional string %s}", + }, + optional_list = { + tex = "[optional list %s]", + lua = "{optional table %s}" , + } , + mandate_single = { + tex = "[mandate string %s]", + lua = "{mandate string %s}", + }, + mandate_list = { + tex = "[mandate list %s]", + lua = "{mandate list %s}", + }, interface = [[<a href='mtx-server-ctx-help.lua?interface=%s&mode=%s'>%s</a>]], source = [[<a href='mtx-server-ctx-help.lua?source=%s&mode=%s'>%s</a>]], - modes = { [[<a href='mtx-server-ctx-help.lua?mode=2'>lua mode</a>]], [[<a href='mtx-server-ctx-help.lua?mode=1'>tex mode</a>]] }, - optional_single = { "[optional string %s]", "{optional string %s}" }, - optional_list = { "[optional list %s]", "{optional table %s}" } , - mandate_single = { "[mandate string %s]", "{mandate string %s}" }, - mandate_list = { "[mandate list %s]", "{mandate list %s}" }, parameter = [[<tr><td width='15%%'>%s</td><td width='15%%'>%s</td><td width='70%%'>%s</td></tr>]], parameters = [[<table width='100%%'>%s</table>]], listing = [[<pre><t>%s</t></listing>]], @@ -315,7 +345,7 @@ end local function translated(e,int) local attributes = e.at local s = attributes.type or "?" - local tag = s:match("^cd:(.*)$") + local tag = match(s,"^cd:(.*)$") if attributes.default == "yes" then return format(document.setups.formats.default,tag or "?") elseif tag then @@ -329,7 +359,7 @@ document.setups.loaded = document.setups.loaded or { } document.setups.current = { } document.setups.showsources = true -document.setups.mode = 1 +document.setups.mode = "tex" function document.setups.load(filename) filename = resolvers.findfile(filename) or "" @@ -402,7 +432,7 @@ end function document.setups.show(name) local current = document.setups.current if current.root then - local name = name:gsub("[<>]","") + local name = gsub(name,"[<>]","") local setup = xml.first(current.root,"cd:command[@name='" .. name .. "']") current.used[#current.used+1] = setup xml.sprint(setup) @@ -452,12 +482,12 @@ function document.setups.collect(name,int,lastmode) category = attributes.category or "", } if document.setups.showsources then - data.source = (attributes.file and formats.source:format(attributes.file,lastmode,attributes.file)) or "" + data.source = (attributes.file and format(formats.source,attributes.file,lastmode,attributes.file)) or "" else data.source = attributes.file or "" end local n, sequence, tags = 0, { }, { } - sequence[#sequence+1] = formats.open_command[lastmode]:format(document.setups.csname(command,int)) + sequence[#sequence+1] = format(formats.open_command[lastmode],document.setups.csname(command,int)) local arguments, tag = { }, "" for r, d, k in xml.elements(command,"(cd:keywords|cd:assignments)") do n = n + 1 @@ -470,15 +500,15 @@ function document.setups.collect(name,int,lastmode) end if attributes.optional == 'yes' then if attributes.list == 'yes' then - tag = formats.optional_list[lastmode]:format(n) + tag = format(formats.optional_list[lastmode],n) else - tag = formats.optional_single[lastmode]:format(n) + tag = format(formats.optional_single[lastmode],n) end else if attributes.list == 'yes' then - tag = formats.mandate_list[lastmode]:format(n) + tag = format(formats.mandate_list[lastmode],n) else - tag = formats.mandate_single[lastmode]:format(n) + tag = format(formats.mandate_single[lastmode],n) end end sequence[#sequence+1] = tag @@ -506,7 +536,7 @@ function document.setups.collect(name,int,lastmode) right[#right+1] = translated(d[k],int) end end - parameters[#parameters+1] = formats.parameter:format(left,"",concat(right, ", ")) + parameters[#parameters+1] = format(formats.parameter,left,"",concat(right, ", ")) else local what = tags[n] for r, d, k in xml.elements(d[k],"(cd:parameter|cd:inherit)") do @@ -514,11 +544,11 @@ function document.setups.collect(name,int,lastmode) local left, right = d[k].at.name or "?", { } if tag == "inherit" then local name = d[k].at.name or "?" - local goto = document.setups.formats.href_as_command[lastmode]:format(name,lastmode,name) - if #parameters > 0 and not parameters[#parameters]:find("<br/>") then - parameters[#parameters+1] = formats.parameter:format("<br/>","","") + local goto = format(document.setups.formats.href_as_command[lastmode],name,lastmode,name) + if #parameters > 0 and not find(parameters[#parameters],"<br/>") then + parameters[#parameters+1] = format(formats.parameter,"<br/>","","") end - parameters[#parameters+1] = formats.parameter:format(what,formats.special:format(translate("inherits",int)),goto) + parameters[#parameters+1] = format(formats.parameter,what,format(formats.special,translate("inherits",int)),goto) else for r, d, k in xml.elements(d[k],"(cd:constant|cd:resolve)") do local tag = d[k].tg @@ -534,15 +564,15 @@ function document.setups.collect(name,int,lastmode) right[#right+1] = translated(d[k],int) end end - parameters[#parameters+1] = formats.parameter:format(what,left,concat(right, ", ")) + parameters[#parameters+1] = format(formats.parameter,what,left,concat(right, ", ")) end what = "" end end - parameters[#parameters+1] = formats.parameter:format("<br/>","","") + parameters[#parameters+1] = format(formats.parameter,"<br/>","","") end data.parameters = parameters or { } - data.mode = formats.modes[lastmode or 1] + data.mode = formats.modes[lastmode or "tex"] return data else return nil @@ -566,7 +596,7 @@ local interfaces = { romanian = 'ro', } -local lastinterface, lastcommand, lastsource, lastmode = "en", "", "", 1 +local lastinterface, lastcommand, lastsource, lastmode = "en", "", "", "tex" local variables = { ['color-background-main-left'] = '#3F3F3F', @@ -584,78 +614,87 @@ local function doit(configuration,filename,hashed) local formats = document.setups.formats - local start = os.clock() + local start = os.clock() + local detail = hashed.queries - local detail = url.query(hashed.query or "") + if detail then - lastinterface = detail.interface or lastinterface - lastcommand = detail.command or lastcommand - lastsource = detail.source or lastsource - lastmode = tonumber(detail.mode or lastmode) or 1 + lastinterface = detail.interface or lastinterface + lastcommand = detail.command or lastcommand + lastsource = detail.source or lastsource + lastmode = detail.mode or lastmode or "tex" - if lastinterface then - report("checking interface: %s",lastinterface) - document.setups.load(format("cont-%s.xml",lastinterface)) - end + lastcommand = gsub(lastcommand,"%s*^\\*(.+)%s*","%1") - local div = document.setups.div[lastinterface] - local span = document.setups.span[lastinterface] + if lastinterface then + report("checking interface: %s",lastinterface) + document.setups.load(format("cont-%s.xml",lastinterface)) + end - local result = { content = "error" } + local div = document.setups.div [lastinterface] + local span = document.setups.span[lastinterface] - local names, refs, ints = document.setups.names(lastinterface), { }, { } - for k=1,#names do - local v = names[k] - refs[k] = formats.href_in_list[lastmode]:format(v[1],lastmode,v[2]) - end - if lastmode ~= 2 then - local sorted = table.sortedkeys(interfaces) - for k=1,#sorted do - local v = sorted[k] - ints[k] = formats.interface:format(interfaces[v],lastmode,v) + local names, refs, ints = document.setups.names(lastinterface), { }, { } + for k=1,#names do + local v = names[k] + refs[k] = format(formats.href_in_list[lastmode],v[1],lastmode,v[2]) + end + if lastmode ~= "lua" then + local sorted = table.sortedkeys(interfaces) + for k=1,#sorted do + local v = sorted[k] + ints[k] = format(formats.interface,interfaces[v],lastmode,v) + end end - end - local n = concat(refs,"<br/>") - local i = concat(ints,"<br/><br/>") + local n = concat(refs,"<br/>") + local i = concat(ints,"<br/><br/>") - if div then - variables.names = div:format(n) - variables.interfaces = div:format(i) - else - variables.names = n - variables.interfaces = i - end + if div then + variables.names = format(div,n) + variables.interfaces = format(div,i) + else + variables.names = n + variables.interfaces = i + end - -- first we need to add information about mkii/mkiv - - variables.maintitle = "no definition" - variables.maintext = "" - variables.extra = "" - - if document.setups.showsources and lastsource and lastsource ~= "" then - -- todo: mkii, mkiv, tex (can be different) - local data = io.loaddata(resolvers.findfile(lastsource)) - variables.maintitle = lastsource - variables.maintext = formats.listing:format(data) - lastsource = "" - elseif lastcommand and lastcommand ~= "" then - local data = document.setups.collect(lastcommand,lastinterface,lastmode) - if data then - local what, extra = { "environment", "category", "source", "mode" }, { } - for k=1,#what do - local v = what[k] - if data[v] and data[v] ~= "" then - lmx.set(v, data[v]) - extra[#extra+1] = v .. ": " .. data[v] + -- first we need to add information about mkii/mkiv + + variables.maintitle = "no definition" + variables.maintext = "" + variables.extra = "" + + if document.setups.showsources and lastsource and lastsource ~= "" then + -- todo: mkii, mkiv, tex (can be different) + local data = io.loaddata(resolvers.findfile(lastsource)) + variables.maintitle = lastsource + variables.maintext = format(formats.listing,data) + lastsource = "" + elseif lastcommand and lastcommand ~= "" then + local data = document.setups.collect(lastcommand,lastinterface,lastmode) + if data then + local what, extra = { "environment", "category", "source", "mode" }, { } + for k=1,#what do + local v = what[k] + if data[v] and data[v] ~= "" then + lmx.set(v, data[v]) + extra[#extra+1] = v .. ": " .. data[v] + end end + variables.maintitle = data.sequence + variables.maintext = format(formats.parameters,concat(data.parameters)) + variables.extra = concat(extra," ") + else + variables.maintext = "select command" end - variables.maintitle = data.sequence - variables.maintext = formats.parameters:format(concat(data.parameters)) - variables.extra = concat(extra," ") - else - variables.maintext = "select command" end + + else + + variables.maintitle = "no definition" + variables.maintext = "some error" + variables.extra = "" + end local content = lmx.convert('context-help.lmx',false,variables) diff --git a/scripts/context/lua/mtxrun.lua b/scripts/context/lua/mtxrun.lua index 5f2ecc2ac..3ebe0c0ba 100644 --- a/scripts/context/lua/mtxrun.lua +++ b/scripts/context/lua/mtxrun.lua @@ -3466,7 +3466,7 @@ url.escape = escapestring function url.query(str) if type(str) == "string" then - return lpegmatch(splitquery,str) + return lpegmatch(splitquery,str) or "" else return str end @@ -16925,6 +16925,21 @@ function runners.timed(action) statistics.timed(action) end +function runners.associate(filename) + os.launch(filename) +end + +function runners.gethelp(filename) + local url = environment.argument("url") + if url and url ~= "" then + local command = string.gsub(environment.argument("command") or "unknown","^%s*\\*(.-)%s*$","%1") + url = utilities.templates.replace(url,{ command = command }) + os.launch(url) + else + report("no --url given") + end +end + -- this is a bit dirty ... first we store the first filename and next we -- split the arguments so that we only see the ones meant for this script -- ... later we will use the second half @@ -17094,6 +17109,14 @@ elseif e_argument("launch") then runners.loadbase() runners.launch_file(filename) +elseif e_argument("associate") then + + runners.associate(filename) + +elseif e_argument("gethelp") then + + runners.gethelp() + elseif e_argument("makestubs") then -- make stubs (depricated) diff --git a/scripts/context/stubs/mswin/mtxrun.lua b/scripts/context/stubs/mswin/mtxrun.lua index 5f2ecc2ac..3ebe0c0ba 100644 --- a/scripts/context/stubs/mswin/mtxrun.lua +++ b/scripts/context/stubs/mswin/mtxrun.lua @@ -3466,7 +3466,7 @@ url.escape = escapestring function url.query(str) if type(str) == "string" then - return lpegmatch(splitquery,str) + return lpegmatch(splitquery,str) or "" else return str end @@ -16925,6 +16925,21 @@ function runners.timed(action) statistics.timed(action) end +function runners.associate(filename) + os.launch(filename) +end + +function runners.gethelp(filename) + local url = environment.argument("url") + if url and url ~= "" then + local command = string.gsub(environment.argument("command") or "unknown","^%s*\\*(.-)%s*$","%1") + url = utilities.templates.replace(url,{ command = command }) + os.launch(url) + else + report("no --url given") + end +end + -- this is a bit dirty ... first we store the first filename and next we -- split the arguments so that we only see the ones meant for this script -- ... later we will use the second half @@ -17094,6 +17109,14 @@ elseif e_argument("launch") then runners.loadbase() runners.launch_file(filename) +elseif e_argument("associate") then + + runners.associate(filename) + +elseif e_argument("gethelp") then + + runners.gethelp() + elseif e_argument("makestubs") then -- make stubs (depricated) diff --git a/scripts/context/stubs/unix/mtxrun b/scripts/context/stubs/unix/mtxrun index 5f2ecc2ac..3ebe0c0ba 100755 --- a/scripts/context/stubs/unix/mtxrun +++ b/scripts/context/stubs/unix/mtxrun @@ -3466,7 +3466,7 @@ url.escape = escapestring function url.query(str) if type(str) == "string" then - return lpegmatch(splitquery,str) + return lpegmatch(splitquery,str) or "" else return str end @@ -16925,6 +16925,21 @@ function runners.timed(action) statistics.timed(action) end +function runners.associate(filename) + os.launch(filename) +end + +function runners.gethelp(filename) + local url = environment.argument("url") + if url and url ~= "" then + local command = string.gsub(environment.argument("command") or "unknown","^%s*\\*(.-)%s*$","%1") + url = utilities.templates.replace(url,{ command = command }) + os.launch(url) + else + report("no --url given") + end +end + -- this is a bit dirty ... first we store the first filename and next we -- split the arguments so that we only see the ones meant for this script -- ... later we will use the second half @@ -17094,6 +17109,14 @@ elseif e_argument("launch") then runners.loadbase() runners.launch_file(filename) +elseif e_argument("associate") then + + runners.associate(filename) + +elseif e_argument("gethelp") then + + runners.gethelp() + elseif e_argument("makestubs") then -- make stubs (depricated) diff --git a/tex/context/base/cont-new.mkii b/tex/context/base/cont-new.mkii index 2219a1944..0c72e4e56 100644 --- a/tex/context/base/cont-new.mkii +++ b/tex/context/base/cont-new.mkii @@ -11,7 +11,7 @@ %C therefore copyrighted by \PRAGMA. See mreadme.pdf for %C details. -\newcontextversion{2012.08.09 17:17} +\newcontextversion{2012.08.09 20:28} %D This file is loaded at runtime, thereby providing an %D excellent place for hacks, patches, extensions and new diff --git a/tex/context/base/cont-new.mkiv b/tex/context/base/cont-new.mkiv index 1b23be6db..7a27bd400 100644 --- a/tex/context/base/cont-new.mkiv +++ b/tex/context/base/cont-new.mkiv @@ -11,7 +11,7 @@ %C therefore copyrighted by \PRAGMA. See mreadme.pdf for %C details. -\newcontextversion{2012.08.09 17:17} +\newcontextversion{2012.08.09 20:28} %D This file is loaded at runtime, thereby providing an %D excellent place for hacks, patches, extensions and new diff --git a/tex/context/base/context-help.lmx b/tex/context/base/context-help.lmx index 5401fb65d..939b70cb6 100644 --- a/tex/context/base/context-help.lmx +++ b/tex/context/base/context-help.lmx @@ -19,6 +19,7 @@ </script> <title><?lua pv('title') ?></title> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/> + <!-- <base target="context-help" /> --> <style type="text/css"> <!-- <?lmx-include context.css ?> diff --git a/tex/context/base/context-version.pdf b/tex/context/base/context-version.pdf Binary files differindex 4ed7baa36..43761cd4d 100644 --- a/tex/context/base/context-version.pdf +++ b/tex/context/base/context-version.pdf diff --git a/tex/context/base/context-version.png b/tex/context/base/context-version.png Binary files differindex 33390a965..5836cbe59 100644 --- a/tex/context/base/context-version.png +++ b/tex/context/base/context-version.png diff --git a/tex/context/base/context.mkii b/tex/context/base/context.mkii index 5b9915753..aa77123ed 100644 --- a/tex/context/base/context.mkii +++ b/tex/context/base/context.mkii @@ -20,7 +20,7 @@ %D your styles an modules. \edef\contextformat {\jobname} -\edef\contextversion{2012.08.09 17:17} +\edef\contextversion{2012.08.09 20:28} %D For those who want to use this: diff --git a/tex/context/base/context.mkiv b/tex/context/base/context.mkiv index 0061b73f0..00e71bd40 100644 --- a/tex/context/base/context.mkiv +++ b/tex/context/base/context.mkiv @@ -25,7 +25,7 @@ %D up and the dependencies are more consistent. \edef\contextformat {\jobname} -\edef\contextversion{2012.08.09 17:17} +\edef\contextversion{2012.08.09 20:28} %D For those who want to use this: diff --git a/tex/context/base/l-url.lua b/tex/context/base/l-url.lua index dfd7905ad..647b3b6f3 100644 --- a/tex/context/base/l-url.lua +++ b/tex/context/base/l-url.lua @@ -257,7 +257,7 @@ url.escape = escapestring function url.query(str) if type(str) == "string" then - return lpegmatch(splitquery,str) + return lpegmatch(splitquery,str) or "" else return str end diff --git a/tex/context/base/status-files.pdf b/tex/context/base/status-files.pdf Binary files differindex ecc283532..176821a2f 100644 --- a/tex/context/base/status-files.pdf +++ b/tex/context/base/status-files.pdf diff --git a/tex/context/base/status-lua.pdf b/tex/context/base/status-lua.pdf Binary files differindex 129ade8a0..2764e6bc5 100644 --- a/tex/context/base/status-lua.pdf +++ b/tex/context/base/status-lua.pdf diff --git a/tex/context/base/x-dir-05.mkiv b/tex/context/base/x-dir-05.mkiv index de1d3fa5f..379b3220a 100644 --- a/tex/context/base/x-dir-05.mkiv +++ b/tex/context/base/x-dir-05.mkiv @@ -52,13 +52,13 @@ \stopluacode \def\getfilestatevariable#1#2% - {\ctxlua{commands.getfilestatevariable("#1","#2")}} + {\ctxcommand{getfilestatevariable("#1","#2")}} \def\savefilestate {\dodoubleargument\dosavefilestate} \def\dosavefilestate[#1][#2]% - {\ctxlua{commands.savefilestate("#1","#2")}% + {\ctxcommand{savefilestate("#1","#2")}% \setxvariables [#1] [name={#2}, diff --git a/tex/generic/context/luatex/luatex-fonts-merged.lua b/tex/generic/context/luatex/luatex-fonts-merged.lua index 0ca0f4732..f3c201b25 100644 --- a/tex/generic/context/luatex/luatex-fonts-merged.lua +++ b/tex/generic/context/luatex/luatex-fonts-merged.lua @@ -1,6 +1,6 @@ -- merged file : luatex-fonts-merged.lua -- parent file : luatex-fonts.lua --- merge date : 08/09/12 17:17:04 +-- merge date : 08/09/12 20:28:34 do -- begin closure to overcome local limits and interference |