summaryrefslogtreecommitdiff
path: root/tex/context/base/mkxl/scrn-ref.lmt
blob: 43c3a0276a699db5efded5e03bdaad0e33ee1495 (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
if not modules then modules = { } end modules ['scrn-ref'] = {
    version   = 1.001,
    comment   = "companion to scrn-int.mkiv",
    author    = "Hans Hagen, PRAGMA-ADE, Hasselt NL",
    copyright = "PRAGMA ADE / ConTeXt Development Team",
    license   = "see context related readme files"
}

interactions            = interactions or { }
interactions.references = interactions.references or { }
local references        = interactions.references

local codeinjections    = backends.codeinjections

local identify          = structures.references.identify

local implement         = interfaces.implement

local function check(what)
    if what and what ~= "" then
        local set, bug = identify("",what)
        return not bug and #set > 0 and set
    end
end

function references.setopendocumentaction(open)
    local opendocument = check(open)
    if opendocument then
        codeinjections.registerdocumentopenaction(opendocument)
    end
end

function references.setclosedocumentaction(close)
    local closedocument = check(close)
    if closedocument then
        codeinjections.registerdocumentcloseaction(closedocument)
    end
end

function references.setopenpageaction(open)
    local openpage = check(open)
    if openpage then
        codeinjections.registerpageopenaction(openpage)
    end
end

function references.setclosepageaction(close)
    local closepage = check(close)
    if closepage then
        codeinjections.registerpagecloseaction(closepage)
    end
end

implement {
    name      = "setopendocumentaction",
    arguments = "string",
    actions   = references.setopendocumentaction
}

implement {
    name      = "setclosedocumentaction",
    arguments = "string",
    actions   = references.setclosedocumentaction
}

implement {
    name      = "setopenpageaction",
    arguments = "string",
    actions   = references.setopenpageaction
}

implement {
    name      = "setclosepageaction",
    arguments = "string",
    actions   = references.setclosepageaction
}