scrn-ini.lmt /size: 1647 b    last modification: 2024-01-16 09:03
1if not modules then modules = { } end modules ['scrn-ini'] = {
2    version   = 1.001,
3    comment   = "companion to scrn-int.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
9local next = next
10
11-- We delay preroll because it needs a font and don't want to force a font load (at
12-- startup) because we preset a field so some are tokenlists as we need to preserve
13-- catcodes.
14
15interactions         = { }
16interactions.general = interactions.general or { }
17local general        = interactions.general
18
19local expand_macro   = token.expand_macro
20
21local prerolled      = { }
22local identitydata   = { }
23
24table.setmetatableindex(identitydata, function(t,k)
25    if k == "keywords" then
26        k = "keyword"
27    end
28    -- fetch and process at the tex end (catcode etc)
29    expand_macro("scrn_identity_get",true,k)
30    -- return the registered return value
31    local v = prerolled[k] or ""
32    if k == "title" and v == "" then
33        v = tex.jobname
34    end
35    return v
36end)
37
38function general.getidentityvariable(name)
39    return identitydata[name]
40end
41
42function general.getidentity()
43    return identitydata
44end
45
46interfaces.implement {
47    name      = "setidentityvariable",
48    arguments = "2 strings",
49    public    = true,
50    protected = true,
51    actions   = function(key,value)
52                    prerolled[key] = value
53                end,
54}
55
56interfaces.implement {
57    name      = "setautoprefix",
58    actions   = function(prefix)
59        backends.codeinjections.setautoprefix(prefix)
60    end,
61    arguments = "string",
62}
63