s-regimes-list.mkiv /size: 2060 b    last modification: 2020-07-01 14:35
1%D \module
2%D   [       file=s-regimes-list, % was: s-reg-01
3%D        version=2005.04.25,
4%D          title=\CONTEXT\ Style File,
5%D       subtitle=Extra Regime Support,
6%D         author=Hans Hagen,
7%D           date=\currentdate,
8%D      copyright={PRAGMA ADE \& \CONTEXT\ Development Team}]
9%C
10%C This module is part of the \CONTEXT\ macro||package and is
11%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
12%C details.
13
14%D \macros
15%D   {showregime}
16%D
17%D This code is moved from the kernel to here.
18
19\startmodule[regimes-list]
20
21\startluacode
22
23moduledata.regimes        = moduledata.regimes        or { }
24moduledata.regimes.charts = moduledata.regimes.charts or { }
25
26local byte = string.byte
27
28function moduledata.regimes.charts.show(regime)
29    if regime and regime ~= "" then
30        local r = regimes.mapping[regime]
31        if r then
32            local chardata = characters.data
33            context.starttabulate { "|rT|rT|rT|cT|lT|lT|pT|" }
34            for k, v in table.sortedhash(r) do
35                local chr = chardata[v]
36                local num = byte(k)
37                local uni = utf.byte(v)
38                if chr then
39                    context.NC() context(num)
40                    context.NC() context("0x%02X",num)
41                    context.NC() context("%U",uni)
42                    context.NC() context.char(uni)
43                    context.NC() context(chr.contextname)
44                    context.NC() context(chr.category)
45                    context.NC() context(chr.description)
46                    context.NC() context.NR()
47                else
48                    -- can't happen
49                end
50            end
51            context.stoptabulate()
52        else
53            context("unknown regime %s",regime)
54        end
55    else
56        context("available regimes: %, t",regimes.list())
57    end
58end
59
60\stopluacode
61
62\installmodulecommandluasingle \showregime {moduledata.regimes.charts.show}
63
64\stopmodule
65
66\continueifinputfile{s-regimes-list.mkiv}
67
68\usemodule[art-01]
69
70\starttext
71
72    \showregime[8859-1]
73
74\stoptext
75