summaryrefslogtreecommitdiff
path: root/tex/context/modules/mkiv/s-system-macros.mkxl
blob: 57417b2e1d550385d4250c1856c2624ab8a7e690 (plain)
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
%D \module
%D   [      file=s-system-tokens.mkxl,
%D        version=2020.06.02,
%D          title=\CONTEXT\ Style File,
%D       subtitle=System Tokens Checking,
%D         author=Hans Hagen,
%D           date=\currentdate,
%D      copyright={PRAGMA ADE \& \CONTEXT\ Development Team}]
%C
%C This module is part of the \CONTEXT\ macro||package and is
%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
%C details.

%D This file is for Wolfgang and Hans and it's used in the transition from \MKIV\
%D to the more robust \LMTX.

% todo:  \permanent\protected\let\select\directselect : same value (add ref)

\startmodule[system-macros]

\continueifinputfile{s-system-macros.mkxl}

\usemodule[article-basic] \setuplayout[tight] \setupbodyfont[7pt,tt]

\starttext

\startluacode
    local context  = context
    local ctx_NC   = context.NC
    local ctx_NR   = context.NR
    local ctx_bold = context.bold

    local find     = string.find
    local gsub     = string.gsub
    local create   = token.create

    local crap     = "[$>%|%&%#" .. string.char(0xEF) .. "]"

    require("mtx-interface")
    local data =  scripts.interface.editor("data")
    local files = data and data.common and data.common.filenames or { }
    local t = tex.hashtokens()
    table.sort(t)
    local function show(check)
        context.starttabulate { "|l|l|l|l|l|l|l|l|l|" }
        for i=1,#t do
            local k = t[i]
            if check(k) then
                local v = create(k)
                local frozen     = v.frozen     and "frozen"
                local permanent  = v.permanent  and "permanent"
                local immutable  = v.immutable  and "immutable"
                local primitive  = v.primitive  and "primitive"
                local mutable    = v.immutable  and "mutable"
                local tolerant   = v.tolerant   and "tolerant"
                local noaligned  = v.noaligned  and "noaligned"
                local instance   = v.instance   and "instance"
                local parameters = v.parameters or 0
                local dealtwith = frozen or permanent or immutable or primitive or mutable -- beware: we can have combinations
                local cscommand = gsub(v.cmdname or "","_"," ")
                local whatever  = find(k,"^[a-z][a-z][a-z]+_")
                local filename  = files[k]
                local csname    = context.escape(k)
                ctx_NC() if dealtwith then context("+") elseif whatever then context("-") elseif instance then context("!")end
                ctx_NC() if primitive then ctx_bold(csname) else context(csname) end
                ctx_NC() if parameters > 0 then context(parameters) end
                ctx_NC() context(cscommand)
                ctx_NC() if dealtwith      then context(dealtwith)  end
                ctx_NC() if tolerant       then context(tolerant)   end
                ctx_NC() if instance       then context(instance)   end
                ctx_NC() if noaligned      then context(noaligned)  end
                ctx_NC() if filename       then context(filename)   end
                ctx_NC() ctx_NR()
            end
        end
        context.stoptabulate()
    end

    show(function(k) return find(k,"^[a-zA-Z]+$") end)

    context.page()

    show(function(k) return not find(k,"^[a-zA-Z]+$") and not find(k,crap) end)
\stopluacode

\stoptext

\stopmodule