scrn-ref.lmt /size: 2000 b    last modification: 2024-01-16 10:22
1if not modules then modules = { } end modules ['scrn-ref'] = {
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
9interactions            = interactions or { }
10interactions.references = interactions.references or { }
11local references        = interactions.references
12
13local codeinjections    = backends.codeinjections
14
15local identify          = structures.references.identify
16
17local implement         = interfaces.implement
18
19local function check(what)
20    if what and what ~= "" then
21        local set, bug = identify("",what)
22        return not bug and #set > 0 and set
23    end
24end
25
26function references.setopendocumentaction(open)
27    local opendocument = check(open)
28    if opendocument then
29        codeinjections.registerdocumentopenaction(opendocument)
30    end
31end
32
33function references.setclosedocumentaction(close)
34    local closedocument = check(close)
35    if closedocument then
36        codeinjections.registerdocumentcloseaction(closedocument)
37    end
38end
39
40function references.setopenpageaction(open)
41    local openpage = check(open)
42    if openpage then
43        codeinjections.registerpageopenaction(openpage)
44    end
45end
46
47function references.setclosepageaction(close)
48    local closepage = check(close)
49    if closepage then
50        codeinjections.registerpagecloseaction(closepage)
51    end
52end
53
54implement {
55    name      = "setopendocumentaction",
56    arguments = "string",
57    actions   = references.setopendocumentaction
58}
59
60implement {
61    name      = "setclosedocumentaction",
62    arguments = "string",
63    actions   = references.setclosedocumentaction
64}
65
66implement {
67    name      = "setopenpageaction",
68    arguments = "string",
69    actions   = references.setopenpageaction
70}
71
72implement {
73    name      = "setclosepageaction",
74    arguments = "string",
75    actions   = references.setclosepageaction
76}
77