summaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
authorHans Hagen <pragma@wxs.nl>2009-11-13 12:45:00 +0100
committerHans Hagen <pragma@wxs.nl>2009-11-13 12:45:00 +0100
commit9cf4a9e0a6642da57b94730bf7104335735a7ace (patch)
tree54c569dc3afe03413ce4ff8e22e2f80a70188e64 /scripts
parente1359274233291895621d41406cf38756e2e04b1 (diff)
downloadcontext-9cf4a9e0a6642da57b94730bf7104335735a7ace.tar.gz
beta 2009.11.13 12:45
Diffstat (limited to 'scripts')
-rw-r--r--scripts/context/lua/mtx-context.lua13
-rw-r--r--scripts/context/lua/mtx-fonts.lua80
-rw-r--r--scripts/context/lua/mtxrun.lua35
-rw-r--r--scripts/context/stubs/mswin/mtxrun.lua35
-rwxr-xr-xscripts/context/stubs/unix/mtxrun35
5 files changed, 119 insertions, 79 deletions
diff --git a/scripts/context/lua/mtx-context.lua b/scripts/context/lua/mtx-context.lua
index b79f2748b..344ff42c5 100644
--- a/scripts/context/lua/mtx-context.lua
+++ b/scripts/context/lua/mtx-context.lua
@@ -1178,6 +1178,7 @@ function scripts.context.extras(pattern)
for s in string.gmatch(data,"%% *(.-)[\n\r]") do
h[#h+1] = s
end
+ h[#h+1] = ""
logs.help(table.concat(h,"\n"),"nomoreinfo")
end
end
@@ -1417,9 +1418,11 @@ expert options:
--trackers show/set tracker variables
--directives show/set directive variables
--timing generate timing and statistics overview
---extra=name process extra (mtx-context-<name> in distribution)
--tracefiles show some extra info when locating files (at the tex end)
--randomseed
+
+--extra=name process extra (mtx-context-<name> in distribution)
+--extras show extras
]]
messages.private = [[
@@ -1470,10 +1473,16 @@ elseif environment.argument("update") then
scripts.context.update()
elseif environment.argument("expert") then
logs.help(table.join({ messages.expert, messages.private, messages.special },"\n"))
+elseif environment.argument("extras") then
+ scripts.context.extras()
elseif environment.argument("extra") then
scripts.context.extra()
elseif environment.argument("help") then
- logs.help(messages.help)
+ if environment.files[1] == "extras" then
+ scripts.context.extras()
+ else
+ logs.help(messages.help)
+ end
elseif environment.argument("trackers") and type(environment.argument("trackers")) == "boolean" then
scripts.context.trackers()
elseif environment.argument("directives") and type(environment.argument("directives")) == "boolean" then
diff --git a/scripts/context/lua/mtx-fonts.lua b/scripts/context/lua/mtx-fonts.lua
index 42e5e3f2c..0cd9a3270 100644
--- a/scripts/context/lua/mtx-fonts.lua
+++ b/scripts/context/lua/mtx-fonts.lua
@@ -65,11 +65,7 @@ local function showfeatures(v,n,f,s,t)
logs.reportline()
end
-function scripts.fonts.list(pattern,reload,all,info)
- if reload then
- logs.simple("fontnames, reloading font database")
- end
- -- make a function for this
+local function make_pattern(pattern) -- will become helper in string
pattern = pattern:lower()
pattern = pattern:gsub("%-","%%-")
pattern = pattern:gsub("%.","%%.")
@@ -80,33 +76,60 @@ function scripts.fonts.list(pattern,reload,all,info)
else
pattern = "^" .. pattern .. "$"
end
- --
- local t = fonts.names.list(pattern,reload)
+ return pattern
+end
+
+local function reloadbase(reload)
if reload then
+ logs.simple("fontnames, reloading font database")
+ names.load(true)
logs.simple("fontnames, done\n\n")
end
+end
+
+function scripts.fonts.list_by_pattern(pattern,reload,all,info)
+ reloadbase(reload)
+ local t = fonts.names.list(make_pattern(pattern))
if t then
local s, w = table.sortedkeys(t), { 0, 0, 0 }
- local function action(f)
- for k,v in ipairs(s) do
- local type, name, file, sub = unpack(t[v])
- f(v,name,file,sub,type)
- end
+ for k,v in ipairs(s) do
+ local entry = t[v]
+ local n = #v if n > w[1] then w[1] = n end
+ local n = #entry[2] if n > w[2] then w[2] = n end
+ local n = #entry[3] if n > w[3] then w[3] = n end
end
- action(function(v,n,f,s,t)
- if #v > w[1] then w[1] = #v end
- if #n > w[2] then w[2] = #n end
- if #f > w[3] then w[3] = #f end
- end)
- action(function(v,n,f,s,t)
- if s then s = "(sub)" else s = "" end
+ local template = "%-" .. w[1] .. "s %-" .. w[2] .. "s %-" .. w[3] .. "s %s"
+ for k,v in ipairs(s) do
+ local entry = t[v]
+ local tag, fontname, filename, sub = v, entry[2], entry[3], entry[4]
+ if sub then sub = "(sub)" else sub = "" end
if info then
- showfeatures(v,n,f,s,t)
+ showfeatures(tag,fontname,filename,sub,t)
else
- local str = string.format("%s %s %s %s",v:padd(w[1]," "),n:padd(w[2]," "),f:padd(w[3]," "), s)
- print(str:strip())
+ print(string.format(template,tag,fontname,filename,sub))
end
- end)
+ end
+ end
+end
+
+function scripts.fonts.list_by_specification(specification,reload,all,info)
+ reloadbase(reload)
+ local t = fonts.names.collectspec(specification)
+ if t then
+ local w, tags = { 0, 0, 0 }, { }
+ for k,entry in ipairs(t) do
+ local s = entry[5] .. "-" .. (entry[6] or "noweight") .. "-" .. (entry[7] or "nostyle") .. "-" .. (entry[8] or "nowidth")
+ local n = #s if n > w[1] then w[1] = n end
+ local n = #entry[2] if n > w[2] then w[2] = n end
+ local n = #entry[3] if n > w[3] then w[3] = n end
+ tags[k] = s
+ end
+ local template = "%-" .. w[1] .."s %-" .. w[2] .. "s %-" .. w[3] .. "s %s"
+ for k,entry in ipairs(t) do
+ local tag, fontname, filename, sub, name, weight, style = tags[k], entry[2], entry[3], entry[4], entry[5], entry[6], entry[7]
+ if sub then sub = "(sub)" else sub = "" end
+ print(string.format(template,tag,fontname,filename,sub))
+ end
end
end
@@ -156,7 +179,7 @@ messages.help = [[
--save save open type font in raw table
--names generate 'luatex-fonts-names.lua' (not for context!)
---pattern=str filter files
+--pattern=str filter files using pattern
--all provide alternatives
]]
@@ -165,11 +188,16 @@ if environment.argument("reload") then
elseif environment.argument("names") then
scripts.fonts.names()
elseif environment.argument("list") then
- local pattern = environment.argument("pattern") or environment.files[1] or ""
local all = environment.argument("all")
local info = environment.argument("info")
local reload = environment.argument("reload")
- scripts.fonts.list(pattern,reload,all,info)
+ if environment.argument("pattern") then
+ scripts.fonts.list_by_pattern(environment.argument("pattern"),reload,all,info)
+ elseif environment.files[1] then
+ scripts.fonts.list_by_specification(environment.files[1],reload,all,info)
+ else
+ scripts.fonts.list_by_pattern("",reload,all,info) -- wildcard
+ end
elseif environment.argument("save") then
local name = environment.files[1] or ""
local sub = environment.files[2] or ""
diff --git a/scripts/context/lua/mtxrun.lua b/scripts/context/lua/mtxrun.lua
index 6440db64b..130ad493c 100644
--- a/scripts/context/lua/mtxrun.lua
+++ b/scripts/context/lua/mtxrun.lua
@@ -475,9 +475,9 @@ if not modules then modules = { } end modules ['l-table'] = {
table.join = table.concat
local concat, sort, insert, remove = table.concat, table.sort, table.insert, table.remove
-local format, find, gsub, lower, dump = string.format, string.find, string.gsub, string.lower, string.dump
+local format, find, gsub, lower, dump, match = string.format, string.find, string.gsub, string.lower, string.dump, string.match
local getmetatable, setmetatable = getmetatable, setmetatable
-local type, next, tostring, ipairs = type, next, tostring, ipairs
+local type, next, tostring, tonumber, ipairs, pairs = type, next, tostring, tonumber, ipairs, pairs
function table.strip(tab)
local lst = { }
@@ -765,6 +765,8 @@ end
--
-- local propername = lpeg.P(lpeg.R("AZ","az","__") * lpeg.R("09","AZ","az", "__")^0 * lpeg.P(-1) )
+-- problem: there no good number_to_string converter with the best resolution
+
local function do_serialize(root,name,depth,level,indexed)
if level > 0 then
depth = depth .. " "
@@ -809,10 +811,9 @@ local function do_serialize(root,name,depth,level,indexed)
if hexify then
handle(format("%s 0x%04X,",depth,v))
else
- handle(format("%s %s,",depth,v))
+ handle(format("%s %.99g,",depth,v))
end
elseif t == "string" then
---~ if reduce and (find(v,"^[%-%+]?[%d]-%.?[%d+]$") == 1) then
if reduce and tonumber(v) then
handle(format("%s %s,",depth,v))
else
@@ -850,29 +851,28 @@ local function do_serialize(root,name,depth,level,indexed)
--~ if hexify then
--~ handle(format("%s %s=0x%04X,",depth,key(k),v))
--~ else
- --~ handle(format("%s %s=%s,",depth,key(k),v))
+ --~ handle(format("%s %s=%.99g,",depth,key(k),v))
--~ end
if type(k) == "number" then -- or find(k,"^%d+$") then
if hexify then
handle(format("%s [0x%04X]=0x%04X,",depth,k,v))
else
- handle(format("%s [%s]=%s,",depth,k,v))
+ handle(format("%s [%s]=%.99g,",depth,k,v))
end
elseif noquotes and not reserved[k] and find(k,"^%a[%w%_]*$") then
if hexify then
handle(format("%s %s=0x%04X,",depth,k,v))
else
- handle(format("%s %s=%s,",depth,k,v))
+ handle(format("%s %s=%.99g,",depth,k,v))
end
else
if hexify then
handle(format("%s [%q]=0x%04X,",depth,k,v))
else
- handle(format("%s [%q]=%s,",depth,k,v))
+ handle(format("%s [%q]=%.99g,",depth,k,v))
end
end
elseif t == "string" then
---~ if reduce and (find(v,"^[%-%+]?[%d]-%.?[%d+]$") == 1) then
if reduce and tonumber(v) then
--~ handle(format("%s %s=%s,",depth,key(k),v))
if type(k) == "number" then -- or find(k,"^%d+$") then
@@ -1264,7 +1264,7 @@ function table.clone(t,p) -- t is optional or nil or table
elseif not t then
t = { }
end
- setmetatable(t, { __index = function(_,key) return p[key] end })
+ setmetatable(t, { __index = function(_,key) return p[key] end }) -- why not __index = p ?
return t
end
@@ -2830,9 +2830,9 @@ function aux.make_settings_to_hash_pattern(set,how)
end
end
-function aux.settings_to_hash(str)
+function aux.settings_to_hash(str,existing)
if str and str ~= "" then
- hash = { }
+ hash = existing or { }
if moretolerant then
pattern_b_s:match(str)
else
@@ -2844,9 +2844,9 @@ function aux.settings_to_hash(str)
end
end
-function aux.settings_to_hash_tolerant(str)
+function aux.settings_to_hash_tolerant(str,existing)
if str and str ~= "" then
- hash = { }
+ hash = existing or { }
pattern_b_s:match(str)
return hash
else
@@ -2854,9 +2854,9 @@ function aux.settings_to_hash_tolerant(str)
end
end
-function aux.settings_to_hash_strict(str)
+function aux.settings_to_hash_strict(str,existing)
if str and str ~= "" then
- hash = { }
+ hash = existing or { }
pattern_c_s:match(str)
return next(hash) and hash
else
@@ -2944,7 +2944,7 @@ function aux.getparameters(self,class,parentclass,settings)
sc = table.clone(self[parent])
self[class] = sc
end
- aux.add_settings_to_array(sc, settings)
+ aux.settings_to_hash(settings,sc)
end
-- temporary here
@@ -7046,6 +7046,7 @@ end
local name, banner = 'report', 'context'
local function report(category,fmt,...)
+--~ print(fmt,...)
if fmt then
write_nl(format("%s | %s: %s",name,category,format(fmt,...)))
elseif category then
diff --git a/scripts/context/stubs/mswin/mtxrun.lua b/scripts/context/stubs/mswin/mtxrun.lua
index 6440db64b..130ad493c 100644
--- a/scripts/context/stubs/mswin/mtxrun.lua
+++ b/scripts/context/stubs/mswin/mtxrun.lua
@@ -475,9 +475,9 @@ if not modules then modules = { } end modules ['l-table'] = {
table.join = table.concat
local concat, sort, insert, remove = table.concat, table.sort, table.insert, table.remove
-local format, find, gsub, lower, dump = string.format, string.find, string.gsub, string.lower, string.dump
+local format, find, gsub, lower, dump, match = string.format, string.find, string.gsub, string.lower, string.dump, string.match
local getmetatable, setmetatable = getmetatable, setmetatable
-local type, next, tostring, ipairs = type, next, tostring, ipairs
+local type, next, tostring, tonumber, ipairs, pairs = type, next, tostring, tonumber, ipairs, pairs
function table.strip(tab)
local lst = { }
@@ -765,6 +765,8 @@ end
--
-- local propername = lpeg.P(lpeg.R("AZ","az","__") * lpeg.R("09","AZ","az", "__")^0 * lpeg.P(-1) )
+-- problem: there no good number_to_string converter with the best resolution
+
local function do_serialize(root,name,depth,level,indexed)
if level > 0 then
depth = depth .. " "
@@ -809,10 +811,9 @@ local function do_serialize(root,name,depth,level,indexed)
if hexify then
handle(format("%s 0x%04X,",depth,v))
else
- handle(format("%s %s,",depth,v))
+ handle(format("%s %.99g,",depth,v))
end
elseif t == "string" then
---~ if reduce and (find(v,"^[%-%+]?[%d]-%.?[%d+]$") == 1) then
if reduce and tonumber(v) then
handle(format("%s %s,",depth,v))
else
@@ -850,29 +851,28 @@ local function do_serialize(root,name,depth,level,indexed)
--~ if hexify then
--~ handle(format("%s %s=0x%04X,",depth,key(k),v))
--~ else
- --~ handle(format("%s %s=%s,",depth,key(k),v))
+ --~ handle(format("%s %s=%.99g,",depth,key(k),v))
--~ end
if type(k) == "number" then -- or find(k,"^%d+$") then
if hexify then
handle(format("%s [0x%04X]=0x%04X,",depth,k,v))
else
- handle(format("%s [%s]=%s,",depth,k,v))
+ handle(format("%s [%s]=%.99g,",depth,k,v))
end
elseif noquotes and not reserved[k] and find(k,"^%a[%w%_]*$") then
if hexify then
handle(format("%s %s=0x%04X,",depth,k,v))
else
- handle(format("%s %s=%s,",depth,k,v))
+ handle(format("%s %s=%.99g,",depth,k,v))
end
else
if hexify then
handle(format("%s [%q]=0x%04X,",depth,k,v))
else
- handle(format("%s [%q]=%s,",depth,k,v))
+ handle(format("%s [%q]=%.99g,",depth,k,v))
end
end
elseif t == "string" then
---~ if reduce and (find(v,"^[%-%+]?[%d]-%.?[%d+]$") == 1) then
if reduce and tonumber(v) then
--~ handle(format("%s %s=%s,",depth,key(k),v))
if type(k) == "number" then -- or find(k,"^%d+$") then
@@ -1264,7 +1264,7 @@ function table.clone(t,p) -- t is optional or nil or table
elseif not t then
t = { }
end
- setmetatable(t, { __index = function(_,key) return p[key] end })
+ setmetatable(t, { __index = function(_,key) return p[key] end }) -- why not __index = p ?
return t
end
@@ -2830,9 +2830,9 @@ function aux.make_settings_to_hash_pattern(set,how)
end
end
-function aux.settings_to_hash(str)
+function aux.settings_to_hash(str,existing)
if str and str ~= "" then
- hash = { }
+ hash = existing or { }
if moretolerant then
pattern_b_s:match(str)
else
@@ -2844,9 +2844,9 @@ function aux.settings_to_hash(str)
end
end
-function aux.settings_to_hash_tolerant(str)
+function aux.settings_to_hash_tolerant(str,existing)
if str and str ~= "" then
- hash = { }
+ hash = existing or { }
pattern_b_s:match(str)
return hash
else
@@ -2854,9 +2854,9 @@ function aux.settings_to_hash_tolerant(str)
end
end
-function aux.settings_to_hash_strict(str)
+function aux.settings_to_hash_strict(str,existing)
if str and str ~= "" then
- hash = { }
+ hash = existing or { }
pattern_c_s:match(str)
return next(hash) and hash
else
@@ -2944,7 +2944,7 @@ function aux.getparameters(self,class,parentclass,settings)
sc = table.clone(self[parent])
self[class] = sc
end
- aux.add_settings_to_array(sc, settings)
+ aux.settings_to_hash(settings,sc)
end
-- temporary here
@@ -7046,6 +7046,7 @@ end
local name, banner = 'report', 'context'
local function report(category,fmt,...)
+--~ print(fmt,...)
if fmt then
write_nl(format("%s | %s: %s",name,category,format(fmt,...)))
elseif category then
diff --git a/scripts/context/stubs/unix/mtxrun b/scripts/context/stubs/unix/mtxrun
index 6440db64b..130ad493c 100755
--- a/scripts/context/stubs/unix/mtxrun
+++ b/scripts/context/stubs/unix/mtxrun
@@ -475,9 +475,9 @@ if not modules then modules = { } end modules ['l-table'] = {
table.join = table.concat
local concat, sort, insert, remove = table.concat, table.sort, table.insert, table.remove
-local format, find, gsub, lower, dump = string.format, string.find, string.gsub, string.lower, string.dump
+local format, find, gsub, lower, dump, match = string.format, string.find, string.gsub, string.lower, string.dump, string.match
local getmetatable, setmetatable = getmetatable, setmetatable
-local type, next, tostring, ipairs = type, next, tostring, ipairs
+local type, next, tostring, tonumber, ipairs, pairs = type, next, tostring, tonumber, ipairs, pairs
function table.strip(tab)
local lst = { }
@@ -765,6 +765,8 @@ end
--
-- local propername = lpeg.P(lpeg.R("AZ","az","__") * lpeg.R("09","AZ","az", "__")^0 * lpeg.P(-1) )
+-- problem: there no good number_to_string converter with the best resolution
+
local function do_serialize(root,name,depth,level,indexed)
if level > 0 then
depth = depth .. " "
@@ -809,10 +811,9 @@ local function do_serialize(root,name,depth,level,indexed)
if hexify then
handle(format("%s 0x%04X,",depth,v))
else
- handle(format("%s %s,",depth,v))
+ handle(format("%s %.99g,",depth,v))
end
elseif t == "string" then
---~ if reduce and (find(v,"^[%-%+]?[%d]-%.?[%d+]$") == 1) then
if reduce and tonumber(v) then
handle(format("%s %s,",depth,v))
else
@@ -850,29 +851,28 @@ local function do_serialize(root,name,depth,level,indexed)
--~ if hexify then
--~ handle(format("%s %s=0x%04X,",depth,key(k),v))
--~ else
- --~ handle(format("%s %s=%s,",depth,key(k),v))
+ --~ handle(format("%s %s=%.99g,",depth,key(k),v))
--~ end
if type(k) == "number" then -- or find(k,"^%d+$") then
if hexify then
handle(format("%s [0x%04X]=0x%04X,",depth,k,v))
else
- handle(format("%s [%s]=%s,",depth,k,v))
+ handle(format("%s [%s]=%.99g,",depth,k,v))
end
elseif noquotes and not reserved[k] and find(k,"^%a[%w%_]*$") then
if hexify then
handle(format("%s %s=0x%04X,",depth,k,v))
else
- handle(format("%s %s=%s,",depth,k,v))
+ handle(format("%s %s=%.99g,",depth,k,v))
end
else
if hexify then
handle(format("%s [%q]=0x%04X,",depth,k,v))
else
- handle(format("%s [%q]=%s,",depth,k,v))
+ handle(format("%s [%q]=%.99g,",depth,k,v))
end
end
elseif t == "string" then
---~ if reduce and (find(v,"^[%-%+]?[%d]-%.?[%d+]$") == 1) then
if reduce and tonumber(v) then
--~ handle(format("%s %s=%s,",depth,key(k),v))
if type(k) == "number" then -- or find(k,"^%d+$") then
@@ -1264,7 +1264,7 @@ function table.clone(t,p) -- t is optional or nil or table
elseif not t then
t = { }
end
- setmetatable(t, { __index = function(_,key) return p[key] end })
+ setmetatable(t, { __index = function(_,key) return p[key] end }) -- why not __index = p ?
return t
end
@@ -2830,9 +2830,9 @@ function aux.make_settings_to_hash_pattern(set,how)
end
end
-function aux.settings_to_hash(str)
+function aux.settings_to_hash(str,existing)
if str and str ~= "" then
- hash = { }
+ hash = existing or { }
if moretolerant then
pattern_b_s:match(str)
else
@@ -2844,9 +2844,9 @@ function aux.settings_to_hash(str)
end
end
-function aux.settings_to_hash_tolerant(str)
+function aux.settings_to_hash_tolerant(str,existing)
if str and str ~= "" then
- hash = { }
+ hash = existing or { }
pattern_b_s:match(str)
return hash
else
@@ -2854,9 +2854,9 @@ function aux.settings_to_hash_tolerant(str)
end
end
-function aux.settings_to_hash_strict(str)
+function aux.settings_to_hash_strict(str,existing)
if str and str ~= "" then
- hash = { }
+ hash = existing or { }
pattern_c_s:match(str)
return next(hash) and hash
else
@@ -2944,7 +2944,7 @@ function aux.getparameters(self,class,parentclass,settings)
sc = table.clone(self[parent])
self[class] = sc
end
- aux.add_settings_to_array(sc, settings)
+ aux.settings_to_hash(settings,sc)
end
-- temporary here
@@ -7046,6 +7046,7 @@ end
local name, banner = 'report', 'context'
local function report(category,fmt,...)
+--~ print(fmt,...)
if fmt then
write_nl(format("%s | %s: %s",name,category,format(fmt,...)))
elseif category then