summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/context/base/toks-ini.lua
diff options
context:
space:
mode:
authorTaco Hoekwater <taco@elvenkind.com>2009-08-23 11:11:32 +0000
committerTaco Hoekwater <taco@elvenkind.com>2009-08-23 11:11:32 +0000
commit8fc3039c82d48605b5ca8b2eda3f4fdd755681e1 (patch)
tree3cd9bbdd599bc4d1ac0409e167fee2136e4c0ec9 /Master/texmf-dist/tex/context/base/toks-ini.lua
parent850fc99b7cd3ae7a20065531fe866ff7bae642ec (diff)
this is context 2009.08.19 17:10
git-svn-id: svn://tug.org/texlive/trunk@14827 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/tex/context/base/toks-ini.lua')
-rw-r--r--Master/texmf-dist/tex/context/base/toks-ini.lua53
1 files changed, 27 insertions, 26 deletions
diff --git a/Master/texmf-dist/tex/context/base/toks-ini.lua b/Master/texmf-dist/tex/context/base/toks-ini.lua
index d39188215ff..1313b04a238 100644
--- a/Master/texmf-dist/tex/context/base/toks-ini.lua
+++ b/Master/texmf-dist/tex/context/base/toks-ini.lua
@@ -5,13 +5,16 @@ if not modules then modules = { } end modules ['toks-ini'] = {
license = "see context related readme files"
}
-utf = utf or unicode.utf8
+local utf = unicode.utf8
+local format, gsub, texsprint = string.format, string.gsub, tex.sprint
+
+local ctxcatcodes = tex.ctxcatcodes
--[[ldx--
-<p>This code is experimental.</p>
+<p>This code is experimental and needs a cleanup. The visualizers will move to
+a module.</p>
--ldx]]--
-
-- 1 = command, 2 = modifier (char), 3 = controlsequence id
--
-- callback.register('token_filter', token.get_next)
@@ -169,18 +172,18 @@ function collectors.show_token(t)
if t then
local cmd, chr, id, cs, name = t[1], t[2], t[3], nil, token.command_name(t) or ""
if cmd == commands.letter or cmd == commands.other then
- return string.format("%s-> %s -> %s", name, chr, utf.char(chr))
+ return format("%s-> %s -> %s", name, chr, utf.char(chr))
elseif id > 0 then
cs = token.csname_name(t) or nil
if cs then
- return string.format("%s-> %s", name, cs)
+ return format("%s-> %s", name, cs)
elseif tonumber(chr) < 0 then
- return string.format("%s-> %s", name, id)
+ return format("%s-> %s", name, id)
else
- return string.format("%s-> (%s,%s)", name, chr, id)
+ return format("%s-> (%s,%s)", name, chr, id)
end
else
- return string.format("%s", name)
+ return format("%s", name)
end
else
return "no node"
@@ -194,14 +197,13 @@ function collectors.trace()
end
collectors.show_methods.a = function(data) -- no need to store the table, just pass directly
- local flush, ct = tex.sprint, tex.ctxcatcodes
local template = "\\NC %s\\NC %s\\NC %s\\NC %s\\NC %s\\NC\\NR "
- flush(ct, "\\starttabulate[|T|Tr|cT|Tr|T|]")
- flush(ct, template:format("cmd","chr","","id","name"))
- flush(ct, "\\HL")
+ texsprint(ctxcatcodes, "\\starttabulate[|T|Tr|cT|Tr|T|]")
+ texsprint(ctxcatcodes, format(template,"cmd","chr","","id","name"))
+ texsprint(ctxcatcodes, "\\HL")
for _,v in pairs(data) do
local cmd, chr, id, cs, sym = v[1], v[2], v[3], "", ""
- local name = (token.command_name(v) or ""):gsub("_","\\_")
+ local name = gsub(token.command_name(v) or "","_","\\_")
if id > 0 then
cs = token.csname_name(v) or ""
if cs ~= "" then cs = "\\string " .. cs end
@@ -212,27 +214,26 @@ collectors.show_methods.a = function(data) -- no need to store the table, just p
sym = "\\char " .. chr
end
if tonumber(chr) < 0 then
- flush(ct, template:format(name, "", sym, id, cs))
+ texsprint(ctxcatcodes, format(template, name, "", sym, id, cs))
else
- flush(ct, template:format(name, chr, sym, id, cs))
+ texsprint(ctxcatcodes, format(template, name, chr, sym, id, cs))
end
end
- flush(ct, "\\stoptabulate")
+ texsprint(ctxcatcodes, "\\stoptabulate")
end
collectors.show_methods.b_c = function(data,swap) -- no need to store the table, just pass directly
- local flush, ct = tex.sprint, tex.ctxcatcodes
local template = "\\NC %s\\NC %s\\NC %s\\NC\\NR"
if swap then
- flush(ct, "\\starttabulate[|Tl|Tl|Tr|]")
+ texsprint(ctxcatcodes, "\\starttabulate[|Tl|Tl|Tr|]")
else
- flush(ct, "\\starttabulate[|Tl|Tr|Tl|]")
+ texsprint(ctxcatcodes, "\\starttabulate[|Tl|Tr|Tl|]")
end
- flush(ct, template:format("cmd","chr","name"))
- flush(ct, "\\HL")
+ texsprint(ctxcatcodes, format(template,"cmd","chr","name"))
+ texsprint(ctxcatcodes, "\\HL")
for _,v in pairs(data) do
local cmd, chr, id, cs, sym = v[1], v[2], v[3], "", ""
- local name = (token.command_name(v) or ""):gsub("_","\\_")
+ local name = gsub(token.command_name(v) or "","_","\\_")
if id > 0 then
cs = token.csname_name(v) or ""
end
@@ -246,14 +247,14 @@ collectors.show_methods.b_c = function(data,swap) -- no need to store the table,
end
end
if swap then
- flush(ct, template:format(name, sym, chr))
+ texsprint(ctxcatcodes, format(template, name, sym, chr))
elseif tonumber(chr) < 0 then
- flush(ct, template:format(name, "", sym))
+ texsprint(ctxcatcodes, format(template, name, "", sym))
else
- flush(ct, template:format(name, chr, sym))
+ texsprint(ctxcatcodes, format(template, name, chr, sym))
end
end
- flush(ct, "\\stoptabulate")
+ texsprint(ctxcatcodes, "\\stoptabulate")
end
-- Even more experimental ...