1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
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
|