diff options
author | Marius <mariausol@gmail.com> | 2013-05-20 03:20:28 +0300 |
---|---|---|
committer | Marius <mariausol@gmail.com> | 2013-05-20 03:20:28 +0300 |
commit | 5fc5cfb5014ddcc2942e13a559f4082fb66aa6e7 (patch) | |
tree | 53f81e99fac8c80ddd2fb70e233a7e5d5735722f /tex/context/base/s-languages-sorting.lua | |
parent | 13ec4b540e0d46c97fd7b089e0b7413da81e0a9f (diff) | |
download | context-5fc5cfb5014ddcc2942e13a559f4082fb66aa6e7.tar.gz |
beta 2013.05.20 02:00
Diffstat (limited to 'tex/context/base/s-languages-sorting.lua')
-rw-r--r-- | tex/context/base/s-languages-sorting.lua | 236 |
1 files changed, 118 insertions, 118 deletions
diff --git a/tex/context/base/s-languages-sorting.lua b/tex/context/base/s-languages-sorting.lua index b7d75f8b8..82a0827bb 100644 --- a/tex/context/base/s-languages-sorting.lua +++ b/tex/context/base/s-languages-sorting.lua @@ -1,118 +1,118 @@ -if not modules then modules = { } end modules ['s-languages-system'] = {
- version = 1.001,
- comment = "companion to s-languages-system.mkiv",
- author = "Hans Hagen, PRAGMA-ADE, Hasselt NL",
- copyright = "PRAGMA ADE / ConTeXt Development Team",
- license = "see context related readme files"
-}
-
-moduledata.languages = moduledata.languages or { }
-moduledata.languages.sorting = moduledata.languages.sorting or { }
-
-local formatters = string.formatters
-local utfbyte, utfcharacters = utf.byte, utf.characters
-local sortedpairs = table.sortedpairs
-
-local definitions = sorters.definitions
-local constants = sorters.constants
-local replacementoffset = constants.replacementoffset
-
-local currentfont = font.current
-local fontchars = fonts.hashes.characters
-
-local c_darkblue = { "darkblue" }
-local c_darkred = { "darkred" }
-local f_chr = formatters["\\tttf%H"]
-
-local function chr(str,done)
- if done then
- context.space()
- end
- local c = fontchars[currentfont()]
- for s in utfcharacters(str) do
- local u = utfbyte(s)
- if c[u] then
- context(s)
- elseif u > replacementoffset then
- context.color(c_darkblue, f_chr(u))
- else
- context.color(c_darkred, f_chr(u))
- end
- end
- return true
-end
-
-local function map(a,b,done)
- if done then
- context.space()
- end
- -- context.tttf()
- chr(a)
- context("=")
- chr(b)
- return true
-end
-
-local function nop()
- -- context.tttf()
- context("none")
-end
-
-local function key(data,field)
- context.NC()
- context(field)
- context.NC()
- context(data[field])
- context.NC()
- context.NR()
-end
-
-function moduledata.languages.sorting.showinstalled(tag)
- if not tag or tag == "" or tag == interfaces.variables.all then
- for tag, data in sortedpairs(definitions) do
- moduledata.languages.sorting.showinstalled (tag)
- end
- else
- sorters.update() -- syncs data
- local data = definitions[tag]
- if data then
- context.starttabulate { "|lB|pl|" }
- key(data,"language")
- key(data,"parent")
- key(data,"method")
- context.NC()
- context("replacements")
- context.NC()
- local replacements = data.replacements
- if #replacements == 0 then
- nop()
- else
- for i=1,#replacements do
- local r = replacements[i]
- map(r[1],r[2],i > 1)
- end
- end
- context.NC()
- context.NR()
- context.NC()
- context("order")
- context.NC()
- local orders = data.orders
- for i=1,#orders do
- chr(orders[i],i > 1)
- end
- context.NC()
- context.NR()
- context.NC()
- context("entries")
- context.NC()
- local done = false
- for k, e in sortedpairs(data.entries) do
- done = map(k,e,done)
- end
- context.NC()
- context.NR()
- context.stoptabulate()
- end
- end
-end
+if not modules then modules = { } end modules ['s-languages-system'] = { + version = 1.001, + comment = "companion to s-languages-system.mkiv", + author = "Hans Hagen, PRAGMA-ADE, Hasselt NL", + copyright = "PRAGMA ADE / ConTeXt Development Team", + license = "see context related readme files" +} + +moduledata.languages = moduledata.languages or { } +moduledata.languages.sorting = moduledata.languages.sorting or { } + +local formatters = string.formatters +local utfbyte, utfcharacters = utf.byte, utf.characters +local sortedpairs = table.sortedpairs + +local definitions = sorters.definitions +local constants = sorters.constants +local replacementoffset = constants.replacementoffset + +local currentfont = font.current +local fontchars = fonts.hashes.characters + +local c_darkblue = { "darkblue" } +local c_darkred = { "darkred" } +local f_chr = formatters["\\tttf%H"] + +local function chr(str,done) + if done then + context.space() + end + local c = fontchars[currentfont()] + for s in utfcharacters(str) do + local u = utfbyte(s) + if c[u] then + context(s) + elseif u > replacementoffset then + context.color(c_darkblue, f_chr(u)) + else + context.color(c_darkred, f_chr(u)) + end + end + return true +end + +local function map(a,b,done) + if done then + context.space() + end + -- context.tttf() + chr(a) + context("=") + chr(b) + return true +end + +local function nop() + -- context.tttf() + context("none") +end + +local function key(data,field) + context.NC() + context(field) + context.NC() + context(data[field]) + context.NC() + context.NR() +end + +function moduledata.languages.sorting.showinstalled(tag) + if not tag or tag == "" or tag == interfaces.variables.all then + for tag, data in sortedpairs(definitions) do + moduledata.languages.sorting.showinstalled (tag) + end + else + sorters.update() -- syncs data + local data = definitions[tag] + if data then + context.starttabulate { "|lB|pl|" } + key(data,"language") + key(data,"parent") + key(data,"method") + context.NC() + context("replacements") + context.NC() + local replacements = data.replacements + if #replacements == 0 then + nop() + else + for i=1,#replacements do + local r = replacements[i] + map(r[1],r[2],i > 1) + end + end + context.NC() + context.NR() + context.NC() + context("order") + context.NC() + local orders = data.orders + for i=1,#orders do + chr(orders[i],i > 1) + end + context.NC() + context.NR() + context.NC() + context("entries") + context.NC() + local done = false + for k, e in sortedpairs(data.entries) do + done = map(k,e,done) + end + context.NC() + context.NR() + context.stoptabulate() + end + end +end |