summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHans Hagen <pragma@wxs.nl>2009-11-26 16:28:00 +0100
committerHans Hagen <pragma@wxs.nl>2009-11-26 16:28:00 +0100
commit527274eadad499558bb40b794882661970c5cc67 (patch)
treefd9ec2fc0bd070a11ce0756eb7b78e5952331dc6
parentd59c05050d5ff72bb4c9496b06e42648ed5f982e (diff)
downloadcontext-527274eadad499558bb40b794882661970c5cc67.tar.gz
stable 2009.11.26 16:28
-rw-r--r--scripts/context/lua/mtx-context.lua34
-rw-r--r--scripts/context/lua/mtx-update.lua16
-rw-r--r--scripts/context/lua/mtxrun.lua63
-rw-r--r--scripts/context/stubs/mswin/mtxrun.lua63
-rwxr-xr-xscripts/context/stubs/unix/mtxrun63
-rw-r--r--tex/context/base/cont-new.tex2
-rw-r--r--tex/context/base/context.tex2
-rw-r--r--tex/context/base/core-def.mkiv1
-rw-r--r--tex/context/base/core-job.lua12
-rw-r--r--tex/context/base/core-sys.lua18
-rw-r--r--tex/context/base/core-sys.mkiv129
-rw-r--r--tex/context/base/data-pre.lua8
-rw-r--r--tex/context/base/data-res.lua2
-rw-r--r--tex/context/base/font-ctx.lua6
-rw-r--r--tex/context/base/font-ini.mkiv12
-rw-r--r--tex/context/base/l-file.lua4
-rw-r--r--tex/context/base/l-pdfview.lua90
-rw-r--r--tex/context/base/luat-env.lua2
-rw-r--r--tex/context/base/lxml-ini.mkiv1
-rw-r--r--tex/context/base/lxml-lpt.lua3
-rw-r--r--tex/context/base/lxml-tex.lua9
-rw-r--r--tex/context/base/lxml-xml.lua17
-rw-r--r--tex/context/base/s-inf-02.tex27
-rw-r--r--tex/generic/context/luatex-fonts-merged.lua6
24 files changed, 439 insertions, 151 deletions
diff --git a/scripts/context/lua/mtx-context.lua b/scripts/context/lua/mtx-context.lua
index 22abf74b1..b146b3c09 100644
--- a/scripts/context/lua/mtx-context.lua
+++ b/scripts/context/lua/mtx-context.lua
@@ -465,10 +465,11 @@ function scripts.context.multipass.makeoptionfile(jobname,ctxdata,kindofrun,curr
--
setalways("%% process info")
--
- setalways( "\\setupsystem[\\c!n=%s,\\c!m=%s]", kindofrun or 0, currentrun or 0)
- setalways( "\\setupsystem[\\c!type=%s]",os.platform)
- setvalue ("inputfile" , "\\setupsystem[inputfile=%s]")
+ -- setvalue ("inputfile" , "\\setupsystem[inputfile=%s]")
+ setalways( "\\setupsystem[inputfile=%s]",environment.argument("input") or environment.files[1] or "\\jobname")
setvalue ("result" , "\\setupsystem[file=%s]")
+ setalways( "\\setupsystem[\\c!n=%s,\\c!m=%s]", kindofrun or 0, currentrun or 0)
+ -- setalways( "\\setupsystem[\\c!type=%s]",os.platform)
setvalues("path" , "\\usepath[%s]")
setvalue ("setuppath" , "\\setupsystem[\\c!directory={%s}]")
setvalue ("randomseed" , "\\setupsystem[\\c!random=%s]")
@@ -621,21 +622,26 @@ local function makestub(format,filename,prepname)
return filename
end
-function scripts.context.openpdf(name)
- os.spawn(string.format('pdfopen --file "%s" 2>&1', file.replacesuffix(name,"pdf")))
-end
-function scripts.context.closepdf(name)
- os.spawn(string.format('pdfclose --file "%s" 2>&1', file.replacesuffix(name,"pdf")))
-end
-
--~ function scripts.context.openpdf(name)
---~ -- somehow two instances start up, one with a funny filename
---~ os.spawn(string.format("\"c:/program files/kde/bin/okular.exe\" --unique %s",file.replacesuffix(name,"pdf")))
+--~ os.spawn(string.format('pdfopen --file "%s" 2>&1', file.replacesuffix(name,"pdf")))
--~ end
--~ function scripts.context.closepdf(name)
---~ --
+--~ os.spawn(string.format('pdfclose --file "%s" 2>&1', file.replacesuffix(name,"pdf")))
--~ end
+local pdfview -- delayed loading
+
+function scripts.context.openpdf(name)
+ pdfview = pdfview or dofile(resolvers.find_file("l-pdfview.lua","tex"))
+ logs.simple("pdfview methods: %s, current method: %s, MTX_PDFVIEW_METHOD=%s",pdfview.methods(),pdfview.method,os.getenv(pdfview.METHOD) or "<unset>")
+ pdfview.open(file.replacesuffix(name,"pdf"))
+end
+
+function scripts.context.closepdf(name)
+ pdfview = pdfview or dofile(resolvers.find_file("l-pdfview.lua","tex"))
+ pdfview.close(file.replacesuffix(name,"pdf"))
+end
+
function scripts.context.run(ctxdata,filename)
-- filename overloads environment.files
local files = (filename and { filename }) or environment.files
@@ -1411,7 +1417,7 @@ messages.help = [[
-- output is currently obsolete for mkiv
-- setuppath=list must check
-- modefile=name must check
--- inputfile=name load the given inputfile (must check)
+-- input=name load the given inputfile (must check)
messages.expert = [[
expert options:
diff --git a/scripts/context/lua/mtx-update.lua b/scripts/context/lua/mtx-update.lua
index ed2606576..3dd2f0e47 100644
--- a/scripts/context/lua/mtx-update.lua
+++ b/scripts/context/lua/mtx-update.lua
@@ -146,9 +146,9 @@ scripts.update.platforms = {
scripts.update.modules = {
}
-function scripts.update.run(str)
+function scripts.update.run(str,force)
logs.report("run", str)
- if environment.argument("force") then
+ if force or environment.argument("force") then
-- important, otherwise formats fly to a weird place
-- (texlua sets luatex as the engine, we need to reset that or to fix texexec :)
os.setenv("engine",nil)
@@ -337,13 +337,17 @@ function scripts.update.synchronize()
-- command = format("%s %s %s %s'%s' '%s'", bin, normalflags, deleteflags, url, archives, destination)
-- end
local normalflags, deleteflags = states.get("rsync.flags.normal"), ""
+ local dryrunflags = ""
+ if not environment.argument("force") then
+ dryrunflags = "--dry-run"
+ end
if (destination:find("texmf$") or destination:find("texmf%-context$")) and (not environment.argument("keep")) then
deleteflags = states.get("rsync.flags.delete")
end
- command = format("%s %s %s %s'%s' '%s'", bin, normalflags, deleteflags, url, archives, destination)
- logs.report("mtx update", format("running command: %s",command))
+ command = format("%s %s %s %s %s'%s' '%s'", bin, normalflags, deleteflags, dryrunflags, url, archives, destination)
+ --logs.report("mtx update", format("running command: %s",command))
if not fetched[command] then
- scripts.update.run(command)
+ scripts.update.run(command,true)
fetched[command] = command
end
end
@@ -479,7 +483,7 @@ if scripts.savestate then
states.set("rsync.program", environment.argument("rsync"), "rsync", true) -- ok
states.set("rsync.server", environment.argument("server"), "contextgarden.net::", true) -- ok
states.set("rsync.module", environment.argument("module"), "minimals", true) -- ok
- states.set("rsync.flags.normal", environment.argument("flags"), "-rpztlv --stats", true) -- ok
+ states.set("rsync.flags.normal", environment.argument("flags"), "-rpztlv", true) -- ok
states.set("rsync.flags.delete", nil, "--delete", true) -- ok
states.set("paths.root", environment.argument("texroot"), "tex", true) -- ok
diff --git a/scripts/context/lua/mtxrun.lua b/scripts/context/lua/mtxrun.lua
index 6425d7060..a187f0697 100644
--- a/scripts/context/lua/mtxrun.lua
+++ b/scripts/context/lua/mtxrun.lua
@@ -1890,8 +1890,8 @@ function file.nameonly(name)
return (gsub(match(name,"^.+[/\\](.-)$") or name,"%..*$",""))
end
-function file.extname(name)
- return match(name,"^.+%.([^/\\]-)$") or ""
+function file.extname(name,default)
+ return match(name,"^.+%.([^/\\]-)$") or default or ""
end
file.suffix = file.extname
@@ -6081,7 +6081,7 @@ local xmlfilter = xml.filter -- we could inline this one for speed
local xmltostring = xml.tostring
local xmlserialize = xml.serialize
-local function first(collected)
+local function first(collected) -- wrong ?
return collected and collected[1]
end
@@ -6122,8 +6122,10 @@ local function position(collected,n)
n = tonumber(n) or 0
if n < 0 then
return collected[#collected + n + 1]
- else
+ elseif n > 0 then
return collected[n]
+ else
+ return collected[1].mi -- match
end
end
end
@@ -6489,7 +6491,7 @@ end
if arg then
- -- new, reconstruct quoted snippets (maybe better just remnove the " then and add them later)
+ -- new, reconstruct quoted snippets (maybe better just remove the " then and add them later)
local newarg, instring = { }, false
for index, argument in ipairs(arg) do
@@ -6809,6 +6811,9 @@ if not modules then modules = { } end modules ['luat-log'] = {
-- this is old code that needs an overhaul
+--~ io.stdout:setvbuf("no")
+--~ io.stderr:setvbuf("no")
+
local write_nl, write, format = texio.write_nl or print, texio.write or io.write, string.format
local texcount = tex and tex.count
@@ -6890,27 +6895,49 @@ function logs.tex.line(fmt,...) -- new
end
end
+--~ function logs.tex.start_page_number()
+--~ local real, user, sub = texcount.realpageno, texcount.userpageno, texcount.subpageno
+--~ if real > 0 then
+--~ if user > 0 then
+--~ if sub > 0 then
+--~ write(format("[%s.%s.%s",real,user,sub))
+--~ else
+--~ write(format("[%s.%s",real,user))
+--~ end
+--~ else
+--~ write(format("[%s",real))
+--~ end
+--~ else
+--~ write("[-")
+--~ end
+--~ end
+
+--~ function logs.tex.stop_page_number()
+--~ write("]")
+--~ end
+
+local real, user, sub
+
function logs.tex.start_page_number()
- local real, user, sub = texcount.realpageno, texcount.userpageno, texcount.subpageno
+ real, user, sub = texcount.realpageno, texcount.userpageno, texcount.subpageno
+end
+
+function logs.tex.stop_page_number()
if real > 0 then
if user > 0 then
if sub > 0 then
- write(format("[%s.%s.%s",real,user,sub))
+ logs.report("pages", "flushing page, realpage %s, userpage %s, subpage %s",real,user,sub)
else
- write(format("[%s.%s",real,user))
+ logs.report("pages", "flushing page, realpage %s, userpage %s",real,user)
end
else
- write(format("[%s",real))
+ logs.report("pages", "flushing page, realpage %s",real)
end
else
- write("[-")
+ logs.report("pages", "flushing page")
end
end
-function logs.tex.stop_page_number()
- write("]")
-end
-
logs.tex.report_job_stat = statistics.show_job_stat
-- xml logging
@@ -9393,6 +9420,14 @@ prefixes.relative = function(str,n)
return resolvers.clean_path(str)
end
+prefixes.auto = function(str)
+ local fullname = prefixes.relative(str)
+ if not lfs.isfile(fullname) then
+ fullname = prefixes.locate(str)
+ end
+ return fullname
+end
+
prefixes.locate = function(str)
local fullname = resolvers.find_given_file(str) or ""
return resolvers.clean_path((fullname ~= "" and fullname) or str)
diff --git a/scripts/context/stubs/mswin/mtxrun.lua b/scripts/context/stubs/mswin/mtxrun.lua
index 6425d7060..a187f0697 100644
--- a/scripts/context/stubs/mswin/mtxrun.lua
+++ b/scripts/context/stubs/mswin/mtxrun.lua
@@ -1890,8 +1890,8 @@ function file.nameonly(name)
return (gsub(match(name,"^.+[/\\](.-)$") or name,"%..*$",""))
end
-function file.extname(name)
- return match(name,"^.+%.([^/\\]-)$") or ""
+function file.extname(name,default)
+ return match(name,"^.+%.([^/\\]-)$") or default or ""
end
file.suffix = file.extname
@@ -6081,7 +6081,7 @@ local xmlfilter = xml.filter -- we could inline this one for speed
local xmltostring = xml.tostring
local xmlserialize = xml.serialize
-local function first(collected)
+local function first(collected) -- wrong ?
return collected and collected[1]
end
@@ -6122,8 +6122,10 @@ local function position(collected,n)
n = tonumber(n) or 0
if n < 0 then
return collected[#collected + n + 1]
- else
+ elseif n > 0 then
return collected[n]
+ else
+ return collected[1].mi -- match
end
end
end
@@ -6489,7 +6491,7 @@ end
if arg then
- -- new, reconstruct quoted snippets (maybe better just remnove the " then and add them later)
+ -- new, reconstruct quoted snippets (maybe better just remove the " then and add them later)
local newarg, instring = { }, false
for index, argument in ipairs(arg) do
@@ -6809,6 +6811,9 @@ if not modules then modules = { } end modules ['luat-log'] = {
-- this is old code that needs an overhaul
+--~ io.stdout:setvbuf("no")
+--~ io.stderr:setvbuf("no")
+
local write_nl, write, format = texio.write_nl or print, texio.write or io.write, string.format
local texcount = tex and tex.count
@@ -6890,27 +6895,49 @@ function logs.tex.line(fmt,...) -- new
end
end
+--~ function logs.tex.start_page_number()
+--~ local real, user, sub = texcount.realpageno, texcount.userpageno, texcount.subpageno
+--~ if real > 0 then
+--~ if user > 0 then
+--~ if sub > 0 then
+--~ write(format("[%s.%s.%s",real,user,sub))
+--~ else
+--~ write(format("[%s.%s",real,user))
+--~ end
+--~ else
+--~ write(format("[%s",real))
+--~ end
+--~ else
+--~ write("[-")
+--~ end
+--~ end
+
+--~ function logs.tex.stop_page_number()
+--~ write("]")
+--~ end
+
+local real, user, sub
+
function logs.tex.start_page_number()
- local real, user, sub = texcount.realpageno, texcount.userpageno, texcount.subpageno
+ real, user, sub = texcount.realpageno, texcount.userpageno, texcount.subpageno
+end
+
+function logs.tex.stop_page_number()
if real > 0 then
if user > 0 then
if sub > 0 then
- write(format("[%s.%s.%s",real,user,sub))
+ logs.report("pages", "flushing page, realpage %s, userpage %s, subpage %s",real,user,sub)
else
- write(format("[%s.%s",real,user))
+ logs.report("pages", "flushing page, realpage %s, userpage %s",real,user)
end
else
- write(format("[%s",real))
+ logs.report("pages", "flushing page, realpage %s",real)
end
else
- write("[-")
+ logs.report("pages", "flushing page")
end
end
-function logs.tex.stop_page_number()
- write("]")
-end
-
logs.tex.report_job_stat = statistics.show_job_stat
-- xml logging
@@ -9393,6 +9420,14 @@ prefixes.relative = function(str,n)
return resolvers.clean_path(str)
end
+prefixes.auto = function(str)
+ local fullname = prefixes.relative(str)
+ if not lfs.isfile(fullname) then
+ fullname = prefixes.locate(str)
+ end
+ return fullname
+end
+
prefixes.locate = function(str)
local fullname = resolvers.find_given_file(str) or ""
return resolvers.clean_path((fullname ~= "" and fullname) or str)
diff --git a/scripts/context/stubs/unix/mtxrun b/scripts/context/stubs/unix/mtxrun
index 6425d7060..a187f0697 100755
--- a/scripts/context/stubs/unix/mtxrun
+++ b/scripts/context/stubs/unix/mtxrun
@@ -1890,8 +1890,8 @@ function file.nameonly(name)
return (gsub(match(name,"^.+[/\\](.-)$") or name,"%..*$",""))
end
-function file.extname(name)
- return match(name,"^.+%.([^/\\]-)$") or ""
+function file.extname(name,default)
+ return match(name,"^.+%.([^/\\]-)$") or default or ""
end
file.suffix = file.extname
@@ -6081,7 +6081,7 @@ local xmlfilter = xml.filter -- we could inline this one for speed
local xmltostring = xml.tostring
local xmlserialize = xml.serialize
-local function first(collected)
+local function first(collected) -- wrong ?
return collected and collected[1]
end
@@ -6122,8 +6122,10 @@ local function position(collected,n)
n = tonumber(n) or 0
if n < 0 then
return collected[#collected + n + 1]
- else
+ elseif n > 0 then
return collected[n]
+ else
+ return collected[1].mi -- match
end
end
end
@@ -6489,7 +6491,7 @@ end
if arg then
- -- new, reconstruct quoted snippets (maybe better just remnove the " then and add them later)
+ -- new, reconstruct quoted snippets (maybe better just remove the " then and add them later)
local newarg, instring = { }, false
for index, argument in ipairs(arg) do
@@ -6809,6 +6811,9 @@ if not modules then modules = { } end modules ['luat-log'] = {
-- this is old code that needs an overhaul
+--~ io.stdout:setvbuf("no")
+--~ io.stderr:setvbuf("no")
+
local write_nl, write, format = texio.write_nl or print, texio.write or io.write, string.format
local texcount = tex and tex.count
@@ -6890,27 +6895,49 @@ function logs.tex.line(fmt,...) -- new
end
end
+--~ function logs.tex.start_page_number()
+--~ local real, user, sub = texcount.realpageno, texcount.userpageno, texcount.subpageno
+--~ if real > 0 then
+--~ if user > 0 then
+--~ if sub > 0 then
+--~ write(format("[%s.%s.%s",real,user,sub))
+--~ else
+--~ write(format("[%s.%s",real,user))
+--~ end
+--~ else
+--~ write(format("[%s",real))
+--~ end
+--~ else
+--~ write("[-")
+--~ end
+--~ end
+
+--~ function logs.tex.stop_page_number()
+--~ write("]")
+--~ end
+
+local real, user, sub
+
function logs.tex.start_page_number()
- local real, user, sub = texcount.realpageno, texcount.userpageno, texcount.subpageno
+ real, user, sub = texcount.realpageno, texcount.userpageno, texcount.subpageno
+end
+
+function logs.tex.stop_page_number()
if real > 0 then
if user > 0 then
if sub > 0 then
- write(format("[%s.%s.%s",real,user,sub))
+ logs.report("pages", "flushing page, realpage %s, userpage %s, subpage %s",real,user,sub)
else
- write(format("[%s.%s",real,user))
+ logs.report("pages", "flushing page, realpage %s, userpage %s",real,user)
end
else
- write(format("[%s",real))
+ logs.report("pages", "flushing page, realpage %s",real)
end
else
- write("[-")
+ logs.report("pages", "flushing page")
end
end
-function logs.tex.stop_page_number()
- write("]")
-end
-
logs.tex.report_job_stat = statistics.show_job_stat
-- xml logging
@@ -9393,6 +9420,14 @@ prefixes.relative = function(str,n)
return resolvers.clean_path(str)
end
+prefixes.auto = function(str)
+ local fullname = prefixes.relative(str)
+ if not lfs.isfile(fullname) then
+ fullname = prefixes.locate(str)
+ end
+ return fullname
+end
+
prefixes.locate = function(str)
local fullname = resolvers.find_given_file(str) or ""
return resolvers.clean_path((fullname ~= "" and fullname) or str)
diff --git a/tex/context/base/cont-new.tex b/tex/context/base/cont-new.tex
index d81b5e522..aab4c7e01 100644
--- a/tex/context/base/cont-new.tex
+++ b/tex/context/base/cont-new.tex
@@ -11,7 +11,7 @@
%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
%C details.
-\newcontextversion{2009.11.24 10:13}
+\newcontextversion{2009.11.26 16: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.tex b/tex/context/base/context.tex
index 4347a8148..addd49fc0 100644
--- a/tex/context/base/context.tex
+++ b/tex/context/base/context.tex
@@ -20,7 +20,7 @@
%D your styles an modules.
\edef\contextformat {\jobname}
-\edef\contextversion{2009.11.24 10:13}
+\edef\contextversion{2009.11.26 16:28}
%D For those who want to use this:
diff --git a/tex/context/base/core-def.mkiv b/tex/context/base/core-def.mkiv
index bc1b6b2bf..aab7ff052 100644
--- a/tex/context/base/core-def.mkiv
+++ b/tex/context/base/core-def.mkiv
@@ -36,7 +36,6 @@
\appendtoks \settopskip \to \everyjob
\appendtoks \preloadlanguages \to \everyjob
\appendtoks \preloadspecials \to \everyjob
-\appendtoks \splitjobfilename \to \everyjob
\appendtoks \checknotes \to \everyjob % depends on bodyfont
\appendtoks \initializeMPgraphics \to \everyjob % after loading system files
\appendtoks \reportsystemcommandmode \to \everyjob
diff --git a/tex/context/base/core-job.lua b/tex/context/base/core-job.lua
index 2815aecf3..a2ce27ef7 100644
--- a/tex/context/base/core-job.lua
+++ b/tex/context/base/core-job.lua
@@ -6,10 +6,10 @@ if not modules then modules = { } end modules ['core-job'] = {
license = "see context related readme files"
}
-local texsprint, texprint, format, find, gmatch = tex.sprint, tex.print, string.format, string.find, string.gmatch
-
-local ctxcatcodes = tex.ctxcatcodes
-local texcatcodes = tex.texcatcodes
+local texsprint, texprint = tex.sprint, tex.print
+local ctxcatcodes, texcatcodes = tex.ctxcatcodes, tex.texcatcodes
+local lower, format, find, gmatch = string.lower, string.format, string.find, string.gmatch
+local concat = table.concat
-- main code
@@ -63,12 +63,12 @@ end
function commands.usepath(paths,maxreadlevel)
resolvers.register_extra_path(paths)
- texsprint(texcatcodes,table.concat(resolvers.instance.extra_paths or {}, ""))
+ texsprint(texcatcodes,concat(resolvers.instance.extra_paths or {}, ""))
end
function commands.usesubpath(subpaths,maxreadlevel)
resolvers.register_extra_path(nil,subpaths)
- texsprint(texcatcodes,table.concat(resolvers.instance.extra_paths or {}, ""))
+ texsprint(texcatcodes,concat(resolvers.instance.extra_paths or {}, ""))
end
function commands.usezipfile(name,tree)
diff --git a/tex/context/base/core-sys.lua b/tex/context/base/core-sys.lua
new file mode 100644
index 000000000..f530896fa
--- /dev/null
+++ b/tex/context/base/core-sys.lua
@@ -0,0 +1,18 @@
+if not modules then modules = { } end modules ['core-sys'] = {
+ version = 1.001,
+ comment = "companion to core-sys.mkiv",
+ author = "Hans Hagen, PRAGMA-ADE, Hasselt NL",
+ copyright = "PRAGMA ADE / ConTeXt Development Team",
+ license = "see context related readme files"
+}
+
+local lower, extname, basename, removesuffix = string.lower, file.extname, file.basename, file.removesuffix
+
+function commands.updatefilenames(inputfilename,outputfilename)
+ environment.inputfilename = inputfilename or ""
+ environment.outputfilename = outputfilename or ""
+ environment.jobfilename = inputfilename or tex.jobname or ""
+ environment.jobfilesuffix = lower(extname(environment.jobfilename))
+ environment.inputfilebarename = removesuffix(basename(inputfilename))
+ environment.inputfilesuffix = lower(extname(inputfilename))
+end
diff --git a/tex/context/base/core-sys.mkiv b/tex/context/base/core-sys.mkiv
index f30c8a958..16ab62283 100644
--- a/tex/context/base/core-sys.mkiv
+++ b/tex/context/base/core-sys.mkiv
@@ -15,6 +15,8 @@
\writestatus{loading}{ConTeXt Core Macros / System}
+\registerctxluafile{core-sys}{1.001}
+
\unprotect
%D Version checking:
@@ -36,29 +38,65 @@
%newlinechar=10 \def\outputnewlinechar{\rawcharacter{10}}
\newlinechar=10 \edef\outputnewlinechar{^^J}
-% in case formats are shared:
+\edef\operatingsystem {\ctxlua{tex.write(os.platform)}}
+
+\def\jobfilename {\ctxlua{tex.sprint(tex.texcatcodes,environment.jobfilename or "")}}
+\def\jobfilesuffix {\ctxlua{tex.sprint(tex.texcatcodes,environment.jobfilesuffix or "")}}
+\def\inputfilebarename{\ctxlua{tex.sprint(tex.texcatcodes,environment.inputfilebarename or "")}}
+\def\inputfilesuffix {\ctxlua{tex.sprint(tex.texcatcodes,environment.inputfilesuffix or "")}}
+\def\inputfilename {\ctxlua{tex.sprint(tex.texcatcodes,environment.inputfilename or "")}}
+\def\outputfilename {\ctxlua{tex.sprint(tex.texcatcodes,environment.outputfilename or "")}}
\def\initializenewlinechar
{\bgroup\newlinechar=10\xdef\outputnewlinechar{^^J}\egroup}
-%D Job names.
-
-\def\outputfilename {\@@svfile}
-\def\inputfilename {\@@svinputfile}
-\def\operatingsystem{\@@svtype}
+\newtoks \everysetupsystem
-\let\jobfilename \jobname
-\let\jobfilesuffix\c!tex
+\def\setupsystem
+ {\dosingleargument\dosetupsystem}
-\def\splitjobfilename % todo: mkiv
- {\resetsystemmode{suffix-\jobfilesuffix}%
- \edef\ascii{\inputfilename}\defconvertedcommand\ascii\ascii
- \splitstring\ascii\at.\to\jobfilename\and\jobfilesuffix
- \lowercasestring\jobfilesuffix\to\jobfilesuffix
- \doifnothing\jobfilename {\let\jobfilename \jobname}%
- % todo and totest: \defconvertedcommand\jobfilename\jobfilename
- \doifnothing\jobfilesuffix{\let\jobfilesuffix\c!tex}%
- \setsystemmode{suffix-\jobfilesuffix}}
+\def\dosetupsystem[#1]%
+ {\getparameters[\??sv][#1]%
+ \the\everysetupsystem}
+
+\appendtoks
+ \setuprandomize[\@@svrandom]%
+\to \everysetupsystem
+
+\appendtoks
+ \edef\outputresolution{\@@svresolution}%
+\to \everysetupsystem
+
+\appendtoks
+ \ifcase\@@svn
+ % % 0 : unknown
+ \or
+ \setsystemmode\v!first % 1 : first run
+ \or
+ % % 2 : successive run
+ \or
+ \setsystemmode\v!first % 3 : first and only run
+ \or
+ \setsystemmode\v!last % 4 : (extra) last run
+ \fi
+\to \everysetupsystem
+
+\appendtoks
+ \edef\outputfilename{\@@svfile}%
+ \edef\inputfilename {\@@svinputfile}%
+\to \everysetupsystem
+
+\let\@@jobsuffix\s!unknown
+
+\appendtoks
+ \resetsystemmode{suffix-\@@jobsuffix}%
+ \edef\@@jobsuffix{\jobsuffix}%
+ \setsystemmode{suffix-\@@jobsuffix}%
+\to \everysetupsystem
+
+\appendtoks
+ \ctxlua {commands.updatefilenames("\inputfilename","\outputfilename")}%
+\to \everysetupsystem
% Some mechanisms (see x-res-01) use either \jobfilename or
% \jobfilename.somesuffix, in which case we need to use the
@@ -72,41 +110,23 @@
{\let\jobfullname\empty}
{\doif\jobfilesuffix\c!tex{\edef\jobfullname{\jobfilename.#1}}}}
-% ...
-
-\def\dosetupsystem[#1]%
- {\getparameters[\??sv][#1]%
- \setuprandomize[\@@svrandom]%
- \beforesplitstring\@@svresolution\at dpi\to\@@svresolution
- \let\outputresolution\@@svresolution
- \ifcase\@@svn
- % % 0 : unknown
- \or
- \setsystemmode\v!first % 1 : first run
- \or
- % % 2 : successive run
- \or
- \setsystemmode\v!first % 3 : first and only run
- \or
- \setsystemmode\v!last % 4 : (extra) last run
- \fi
-% \processaction
-% [\@@svtype]
-% %[ mswin=>\edef\@@svline{\rawcharacter{13}\rawcharacter{10}}, % crlf
-% [ mswin=>\edef\@@svline{\rawcharacter{13}}, % cr % crlf
-% darwin=>\edef\@@svline{\rawcharacter{13}}, % cr
-% \s!unknown=>\edef\@@svline{\rawcharacter{10}}]% % lf
- \splitjobfilename}
-
-% \edef\@@svline{\rawcharacter{10}} % unix is the most critical/sensitive system
-
\let\systemendofline\outputnewlinechar % will become obsolete
-\def\setupsystem
- {\dosingleargument\dosetupsystem}
-
\def\systemparameter#1{\executeifdefined{\??sv#1}\empty}
+%D There are a couple of system states avaiable:
+%D
+%D \starttabulate [|T|T|]
+%D \NC \type{\jobname} \NC \jobname \NC \NR
+%D \NC \type{\jobfilename} \NC \jobfilename \NC \NR
+%D \NC \type{\jobfilesuffix} \NC \jobfilesuffix \NC \NR
+%D \NC \type{\inputfilename} \NC \inputfilename \NC \NR
+%D \NC \type{\inputfilebarename} \NC \inputfilebarename \NC \NR
+%D \NC \type{\inputfilesuffix} \NC \inputfilesuffix \NC \NR
+%D \NC \type{\outputfilename} \NC \outputfilename \NC \NR
+%D \NC \type{\operatingsystem} \NC \operatingsystem \NC \NR
+%D \stoptabulate
+
%D The system modes set by the setup command can be used in
%D situations like:
%D
@@ -134,13 +154,13 @@
\s!default=>\getnewrandomseed\scratchcounter,
\s!unknown=>\scratchcounter#1]%
\expanded{\setrandomseed{\the\scratchcounter}}%
-% \writestatus\m!systems{randomseed: \the\scratchcounter}%
+ % \writestatus\m!systems{randomseed: \the\scratchcounter}%
\egroup}}
\setupsystem
[\c!directory=,
\c!n=0, % 0:unknown 1: one run 2: first 3: successive 4: final run
- \c!resolution=600dpi,
+ \c!resolution=600,% in dpi, no unit in mkiv
\c!random=,
\c!file=\jobname,
\c!inputfile=\outputfilename,
@@ -413,13 +433,4 @@
\def\defreducedargument {\dodefreducedargument\edef}
\def\gdefreducedargument{\dodefreducedargument\xdef}
-\startruntimeluacode
- \ctxlua {
- environment.inputfilename = "\inputfilename"
- environment.outputfilename = "\outputfilename"
- environment.jobfilename = "\jobfilename"
- environment.jobfilesuffix = "\jobfilesuffix"
- }
-\stopruntimeluacode
-
\protect \endinput
diff --git a/tex/context/base/data-pre.lua b/tex/context/base/data-pre.lua
index 5cf5c93d5..26843d21c 100644
--- a/tex/context/base/data-pre.lua
+++ b/tex/context/base/data-pre.lua
@@ -35,6 +35,14 @@ prefixes.relative = function(str,n)
return resolvers.clean_path(str)
end
+prefixes.auto = function(str)
+ local fullname = prefixes.relative(str)
+ if not lfs.isfile(fullname) then
+ fullname = prefixes.locate(str)
+ end
+ return fullname
+end
+
prefixes.locate = function(str)
local fullname = resolvers.find_given_file(str) or ""
return resolvers.clean_path((fullname ~= "" and fullname) or str)
diff --git a/tex/context/base/data-res.lua b/tex/context/base/data-res.lua
index 3fc36dab2..4305d0bed 100644
--- a/tex/context/base/data-res.lua
+++ b/tex/context/base/data-res.lua
@@ -262,7 +262,7 @@ function resolvers.settrace(n) -- no longer number but: 'locating' or 'detail'
end
end
-resolvers.settrace(os.getenv("MTX.resolvers.TRACE") or os.getenv("MTX_INPUT_TRACE"))
+resolvers.settrace(os.getenv("MTX_INPUT_TRACE"))
function resolvers.osenv(key)
local ie = instance.environment
diff --git a/tex/context/base/font-ctx.lua b/tex/context/base/font-ctx.lua
index 3845ae5b9..2f63b3a8d 100644
--- a/tex/context/base/font-ctx.lua
+++ b/tex/context/base/font-ctx.lua
@@ -9,7 +9,7 @@ if not modules then modules = { } end modules ['font-ctx'] = {
-- needs a cleanup: merge of replace, lang/script etc
local texsprint, count = tex.sprint, tex.count
-local format, concat, gmatch, match, find, lower = string.format, table.concat, string.gmatch, string.match, string.find, string.lower
+local format, concat, gmatch, match, find, lower, gsub = string.format, table.concat, string.gmatch, string.match, string.find, string.lower, string.gsub
local tostring, next, type = tostring, next, type
local ctxcatcodes = tex.ctxcatcodes
@@ -412,3 +412,7 @@ function fonts.dimenfactor(unit,tfmdata)
return dimenfactors[unit] or unit
end
end
+
+function fonts.cleanname(name) -- mapped onto macro, see fonts.names.cleanname
+ texsprint(ctxcatcodes,(gsub(lower(name),"[^%a%d]","")))
+end
diff --git a/tex/context/base/font-ini.mkiv b/tex/context/base/font-ini.mkiv
index eca6e5679..0b58c9791 100644
--- a/tex/context/base/font-ini.mkiv
+++ b/tex/context/base/font-ini.mkiv
@@ -1755,15 +1755,6 @@
\newdimen\bodyfontsize \bodyfontsize=\globalbodyfontsize
%D \macros
-%D {outputresolution}
-%D
-%D Sometimes (to be honest: not in this module) we need to
-%D take the system resolution into account. Therefore we also
-%D define a macro:
-
-\def\outputresolution {600}
-
-%D \macros
%D {bodyfontfactor,bodyfontpoints}
%D
%D For multiplication purposes we keep an auxiliary counter
@@ -4027,10 +4018,13 @@
%D \TestLookup{familyname=helveticaneue,weight=bold,style=italic}
%D \stoptyping
+% we can also move the lookups to the fonts.namespace (of commands)
+
\def\dolookupfontbyspec #1{\ctxlua{fonts.names.lookup("#1")}}
\def\dolookupnoffound {\ctxlua{tex.write(fonts.names.noflookups())}}
\def\dolookupgetkeyofindex#1#2{\ctxlua{tex.write(fonts.names.getlookupkey("#1",#2))}}
\def\dolookupgetkey #1{\ctxlua{tex.write(fonts.names.getlookupkey("#1"))}}
+\def\cleanfontname #1{\ctxlua{fonts.cleanname("#1")}}
\protect \endinput
diff --git a/tex/context/base/l-file.lua b/tex/context/base/l-file.lua
index 37de64ba1..be42727c0 100644
--- a/tex/context/base/l-file.lua
+++ b/tex/context/base/l-file.lua
@@ -41,8 +41,8 @@ function file.nameonly(name)
return (gsub(match(name,"^.+[/\\](.-)$") or name,"%..*$",""))
end
-function file.extname(name)
- return match(name,"^.+%.([^/\\]-)$") or ""
+function file.extname(name,default)
+ return match(name,"^.+%.([^/\\]-)$") or default or ""
end
file.suffix = file.extname
diff --git a/tex/context/base/l-pdfview.lua b/tex/context/base/l-pdfview.lua
new file mode 100644
index 000000000..f74a7f04e
--- /dev/null
+++ b/tex/context/base/l-pdfview.lua
@@ -0,0 +1,90 @@
+if not modules then modules = { } end modules ['l-pdfview'] = {
+ version = 1.001,
+ comment = "companion to mtx-context.lua",
+ author = "Hans Hagen, PRAGMA-ADE, Hasselt NL",
+ copyright = "PRAGMA ADE / ConTeXt Development Team",
+ license = "see context related readme files"
+}
+
+local format, getenv = string.format, os.getenv
+
+pdfview = pdfview or { }
+
+local opencalls = {
+ ['default'] = "pdfopen --file", -- "pdfopen --back --file"
+ ['okular'] = 'start "test" "c:/program files/kde/bin/okular.exe" --unique', -- todo: get focus
+ ['xpdf'] = "xpdfopen",
+}
+
+local closecalls= {
+ ['default'] = "pdfclose --file",
+ ['okular'] = nil,
+ ['xpdf'] = nil,
+}
+
+local allcalls = {
+ ['default'] = "pdfclose --all",
+ ['okular'] = nil,
+ ['xpdf'] = nil,
+}
+
+pdfview.METHOD = "MTX_PDFVIEW_METHOD"
+pdfview.method = getenv(pdfview.METHOD) or 'default'
+pdfview.method = (opencalls[pdfview.method] and pdfview.method) or 'default'
+
+function pdfview.methods()
+ return table.concat(table.sortedkeys(opencalls), " ")
+end
+
+function pdfview.status()
+ return format("pdfview methods: %s, current method: %s, MTX_PDFVIEW_METHOD=%s",pdfview.methods(),pdfview.method,getenv(pdfview.METHOD) or "<unset>")
+end
+
+local openedfiles = { }
+
+local function fullname(name)
+ return file.addsuffix(name,"pdf")
+end
+
+function pdfview.open(...)
+ local opencall = opencalls[pdfview.method]
+ if opencall then
+ for _, name in ipairs({...}) do
+ name = fullname(name)
+ if io.exists(name) then
+ os.execute(format('%s "%s" 2>&1', opencall, name))
+ openedfiles[name] = true
+ end
+ end
+ end
+end
+
+function pdfview.close(...)
+ local closecall = closecalls[pdfview.method]
+ if closecall then
+ for _, name in ipairs({...}) do
+ name = fullname(name)
+ if openedfiles[name] then
+ os.execute(format('%s "%s" 2>&1', closecall, name))
+ openedfiles[name] = nil
+ else
+ pdfview.closeall()
+ break
+ end
+ end
+ end
+end
+
+function pdfview.closeall()
+ local allcall = allcalls[pdfview.method]
+ if allcall then
+ os.execute(format('%s 2>&1', allcall))
+ end
+ openedfiles = { }
+end
+
+--~ pdfview.open("t:/document/show-exa.pdf")
+--~ os.sleep(3)
+--~ pdfview.close("t:/document/show-exa.pdf")
+
+return pdfview
diff --git a/tex/context/base/luat-env.lua b/tex/context/base/luat-env.lua
index 43e3c272e..f06e61867 100644
--- a/tex/context/base/luat-env.lua
+++ b/tex/context/base/luat-env.lua
@@ -138,7 +138,7 @@ end
if arg then
- -- new, reconstruct quoted snippets (maybe better just remnove the " then and add them later)
+ -- new, reconstruct quoted snippets (maybe better just remove the " then and add them later)
local newarg, instring = { }, false
for index, argument in ipairs(arg) do
diff --git a/tex/context/base/lxml-ini.mkiv b/tex/context/base/lxml-ini.mkiv
index e0a217a2b..90e60d513 100644
--- a/tex/context/base/lxml-ini.mkiv
+++ b/tex/context/base/lxml-ini.mkiv
@@ -29,6 +29,7 @@
\def\c!entities{entities} % to be internationalized
\def\xmlmain #1{\ctxlua{lxml.main("#1")}}
+\def\xmlmatch #1{\ctxlua{lxml.match("#1")}}
\def\xmlall #1#2{\ctxlua{lxml.all("#1","#2")}}
\def\xmlatt #1#2{\ctxlua{lxml.att("#1","#2")}}
\def\xmlattdef #1#2#3{\ctxlua{lxml.att("#1","#2","#3")}}
diff --git a/tex/context/base/lxml-lpt.lua b/tex/context/base/lxml-lpt.lua
index 8f92abd80..406d00c05 100644
--- a/tex/context/base/lxml-lpt.lua
+++ b/tex/context/base/lxml-lpt.lua
@@ -386,8 +386,9 @@ local lp_and = P("&") / " and "
local lp_builtin = P (
P("first") / "1" +
P("last") / "#list" +
- P("position") / "l" +
+ P("position") / "l" + -- is element in finalizer
P("rootposition") / "order" +
+ P("order") / "order" +
P("index") / "(ll.ni or 1)" +
P("match") / "(ll.mi or 1)" +
P("text") / "(ll.dt[1] or '')" +
diff --git a/tex/context/base/lxml-tex.lua b/tex/context/base/lxml-tex.lua
index c1284b87b..0305b889e 100644
--- a/tex/context/base/lxml-tex.lua
+++ b/tex/context/base/lxml-tex.lua
@@ -904,6 +904,10 @@ local function position(collected,n)
end
end
+local function match(collected)
+ texwrite((collected and collected[1].mi) or 0)
+end
+
local function index(collected,n)
if collected then
n = tonumber(n) or 0
@@ -1018,6 +1022,7 @@ finalizers.command = command
finalizers.attribute = attribute
finalizers.text = text
finalizers.position = position
+finalizers.match = match
finalizers.index = index
finalizers.concat = concat
finalizers.concatrange = concatrange
@@ -1202,6 +1207,10 @@ function lxml.name(id) -- or remapped name? -> lxml.info, combine
end
end
+function lxml.match(id) -- or remapped name? -> lxml.info, combine
+ texsprint(get_id(id).mi or 0)
+end
+
function lxml.tag(id) -- tag vs name -> also in l-xml tag->name
texsprint(get_id(id).tg or "")
end
diff --git a/tex/context/base/lxml-xml.lua b/tex/context/base/lxml-xml.lua
index 5d6db9475..bde11cd53 100644
--- a/tex/context/base/lxml-xml.lua
+++ b/tex/context/base/lxml-xml.lua
@@ -11,7 +11,7 @@ local xmlfilter = xml.filter -- we could inline this one for speed
local xmltostring = xml.tostring
local xmlserialize = xml.serialize
-local function first(collected)
+local function first(collected) -- wrong ?
return collected and collected[1]
end
@@ -52,12 +52,18 @@ local function position(collected,n)
n = tonumber(n) or 0
if n < 0 then
return collected[#collected + n + 1]
- else
+ elseif n > 0 then
return collected[n]
+ else
+ return collected[1].mi or 0
end
end
end
+local function match(collected)
+ return (collected and collected[1].mi) or 0 -- match
+end
+
local function index(collected)
if collected then
return collected[1].ni
@@ -211,6 +217,7 @@ finalizers.attribute = attribute
finalizers.att = att
finalizers.count = count
finalizers.position = position
+finalizers.match = match
finalizers.index = index
finalizers.attributes = attributes
finalizers.chainattribute = chainattribute
@@ -262,10 +269,14 @@ end
xml.content = text
-function xml.position(id,pattern,n)
+function xml.position(id,pattern,n) -- element
return position(xmlfilter(id,pattern),n)
end
+function xml.match(id,pattern) -- number
+ return match(xmlfilter(id,pattern))
+end
+
function xml.empty(id,pattern)
return empty(xmlfilter(id,pattern))
end
diff --git a/tex/context/base/s-inf-02.tex b/tex/context/base/s-inf-02.tex
new file mode 100644
index 000000000..77a3f650c
--- /dev/null
+++ b/tex/context/base/s-inf-02.tex
@@ -0,0 +1,27 @@
+%D \module
+%D [ file=s-inf-02,
+%D version=2009.11.25,
+%D title=\CONTEXT\ Style File,
+%D subtitle=Information 2 (filenames),
+%D author=Hans Hagen,
+%D date=\currentdate,
+%D copyright={PRAGMA / Hans Hagen \& Ton Otten}]
+%C
+%C This module is part of the \CONTEXT\ macro||package and is
+%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
+%C details.
+
+\starttext
+
+\starttabulate [|T|T|]
+ \NC \type{\jobname} \NC \jobname \NC \NR
+ \NC \type{\jobfilename} \NC \jobfilename \NC \NR
+ \NC \type{\jobfilesuffix} \NC \jobfilesuffix \NC \NR
+ \NC \type{\inputfilename} \NC \inputfilename \NC \NR
+ \NC \type{\inputfilebarename} \NC \inputfilebarename \NC \NR
+ \NC \type{\inputfilesuffix} \NC \inputfilesuffix \NC \NR
+ \NC \type{\outputfilename} \NC \outputfilename \NC \NR
+ \NC \type{\operatingsystem} \NC \operatingsystem \NC \NR
+\stoptabulate
+
+\stoptext
diff --git a/tex/generic/context/luatex-fonts-merged.lua b/tex/generic/context/luatex-fonts-merged.lua
index 86fa6cd3b..99f007a92 100644
--- a/tex/generic/context/luatex-fonts-merged.lua
+++ b/tex/generic/context/luatex-fonts-merged.lua
@@ -1,6 +1,6 @@
-- merged file : c:/data/develop/context/texmf/tex/generic/context/luatex-fonts-merged.lua
-- parent file : c:/data/develop/context/texmf/tex/generic/context/luatex-fonts.lua
--- merge date : 11/24/09 10:17:26
+-- merge date : 11/26/09 16:35:22
do -- begin closure to overcome local limits and interference
@@ -1445,8 +1445,8 @@ function file.nameonly(name)
return (gsub(match(name,"^.+[/\\](.-)$") or name,"%..*$",""))
end
-function file.extname(name)
- return match(name,"^.+%.([^/\\]-)$") or ""
+function file.extname(name,default)
+ return match(name,"^.+%.([^/\\]-)$") or default or ""
end
file.suffix = file.extname