symb-run.mkiv /size: 3212 b    last modification: 2020-07-01 14:35
1%D \module
2%D   [       file=symb-run,
3%D        version=2010.12.08, % 1998.07.20,
4%D          title=\CONTEXT\ Symbol Libraries,
5%D       subtitle=Runtime Macros,
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\startluacode
15    function commands.showsymbolset(collection,symbols,fontid)
16        if type(symbols) == "string" then
17            symbols = utilities.parsers.settings_to_array(symbols)
18        end
19        local options  = { framecolor = "orange", rulethickness = ".8pt", offset = interfaces.variables.overlay }
20        local list     = table.tohash(symbols)
21        local alsofont = fontid > 0
22        local defined  = #symbols > 0
23        local byname   = false
24        if alsofont then
25            local is_symbol  = characters.is_symbol
26            local chardata   = characters.data
27            local resources  = fonts.hashes.resources [fontid]
28            local characters = fonts.hashes.characters[fontid]
29            if resources and characters then
30                local unicodes = resources.unicodes
31                if unicodes then
32                    for name, unicode in next, unicodes do
33                        if not list[name] and name ~= ".notdef" then
34                            local c = rawget(chardata,unicode)
35                            if not c or is_symbol[c.category] then
36                                list[name] = false
37                                byname     = true
38                            end
39                        end
40                    end
41                end
42            end
43        end
44        local detail = defined and byname
45        context.start()
46        context.forcesymbolset { collection }
47        context.starttabulate { detail and "|lT|l|l|lT|" or "|lT|l|l|"}
48        for symbol, how in table.sortedhash(list) do
49            context.NC()
50            if detail and how then
51                context.bold(symbol)
52            else
53                context(symbol)
54            end
55            context.NC()
56            context.symbol(symbol)
57            context.NC()
58            context.framed(options,context.nested.symbol(symbol))
59            context.NC()
60            if detail and how then
61                context.bold("defined")
62                context.NC()
63            end
64            context.NR()
65        end
66        context.stoptabulate()
67        context.stop()
68    end
69\stopluacode
70
71\unprotect
72
73\unexpanded\gdef\showsymbolset
74  {\dosingleargument\symb_show_set}
75
76\gdef\symb_show_set[#1]%
77  {\begingroup
78   \edef\p_font{\begincsname\??symboldefault#1\endcsname}%
79   \begingroup
80   \ifx\p_font\empty
81     \global\globalscratchcounter\zerocount
82   \else
83     \definedfont[\p_font]%
84     \global\globalscratchcounter\fontid\font\relax
85   \fi
86   \endgroup
87   \ctxcommand {
88      showsymbolset (
89        "#1",
90        "\symbolset{#1}",
91        \the\globalscratchcounter
92      ) }%
93   \endgroup}
94
95\protect
96
97\continueifinputfile{symb-run.mkiv}
98
99\usesymbols[cc]
100
101\starttext
102
103    \showsymbolset[cc]
104
105    \symbol[cc][cc-by-sa-nc]
106
107\stoptext
108