s-characters-properties.lua /size: 2593 b    last modification: 2020-07-01 14:35
1if not modules then modules = { } end modules ['s-characters-properties'] = {
2    version   = 1.001,
3    comment   = "companion to s-characters-properties.mkiv",
4    author    = "Hans Hagen, PRAGMA-ADE, Hasselt NL",
5    copyright = "PRAGMA ADE / ConTeXt Development Team",
6    license   = "see context related readme files"
7}
8
9moduledata.characters            = moduledata.characters            or { }
10moduledata.characters.properties = moduledata.characters.properties or { }
11
12local catcodenames = { [0] =
13    "escape",    "begingroup", "endgroup",  "mathshift",
14    "alignment", "endofline",  "parameter", "superscript",
15    "subscript", "ignore",     "space",     "letter",
16    "other",     "active",     "comment",   "invalid",
17}
18
19table.swapped(catcodes,catcodes)
20
21local catcodes   = context.catcodes
22local getcatcode = tex.getcatcode
23local c_context  = catcodes.context
24local c_tex      = catcodes.tex
25local c_protect  = catcodes.protect
26local c_text     = catcodes.text
27local c_verbatim = catcodes.verbatim
28
29local context      = context
30local ctx_NC       = context.NC
31local ctx_NR       = context.NR
32local ctx_MR       = context.MR
33local ctx_ML       = context.ML
34local ctx_bold     = context.bold
35local ctx_verbatim = context.verbatim
36
37function moduledata.characters.properties.showcatcodes(specification)
38
39    local function range(f,l,quit)
40        if quit then
41            ctx_MR()
42        end
43        for i=f,l do
44            ctx_NC()
45            if quit then
46                ctx_verbatim("%c .. %c",f,l)
47            else
48                ctx_verbatim("%c",i)
49            end
50            ctx_NC() context(catcodenames[getcatcode(c_tex,i)])
51            ctx_NC() context(catcodenames[getcatcode(c_context,i)])
52            ctx_NC() context(catcodenames[getcatcode(c_protect,i)])
53            ctx_NC() context(catcodenames[getcatcode(c_text,i)])
54            ctx_NC() context(catcodenames[getcatcode(c_verbatim,i)])
55            ctx_NC() ctx_NR()
56            if quit then
57                ctx_MR()
58                break
59            end
60        end
61    end
62
63    context.starttabulate { "|c|c|c|c|c|c|" }
64        ctx_ML()
65        ctx_NC() ctx_bold("ascii")
66        ctx_NC() ctx_bold("context")
67        ctx_NC() ctx_bold("tex")
68        ctx_NC() ctx_bold("protect")
69        ctx_NC() ctx_bold("text")
70        ctx_NC() ctx_bold("verbatim")
71        ctx_NC() ctx_NR()
72        ctx_ML()
73        range(32,47)
74        range(48,57,true)
75        range(58,64)
76        range(65,90,true)
77        range(91,96)
78        range(97,122,true)
79        range(123,126)
80        ctx_ML()
81    context.stoptabulate()
82
83end
84