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 expandcurrent = structures.references.expandcurrent 16local identify = structures.references.identify 17 18local implement = interfaces.implement 19 20local function check(what) 21 if what and what ~= "" then 22 local set, bug = identify("",what) 23 return not bug and #set > 0 and set 24 end 25end 26 27local function setopendocumentaction(open) 28 local opendocument = check(open) 29 if opendocument then 30 codeinjections.registerdocumentopenaction(opendocument) 31 expandcurrent() 32 end 33end 34 35local function setclosedocumentaction(close) 36 local closedocument = check(close) 37 if closedocument then 38 codeinjections.registerdocumentcloseaction(closedocument) 39 expandcurrent() 40 end 41end 42 43local function setopenpageaction(open) 44 local openpage = check(open) 45 if openpage then 46 codeinjections.registerpageopenaction(openpage) 47 expandcurrent() 48 end 49end 50 51local function setclosepageaction(close) 52 local closepage = check(close) 53 if closepage then 54 codeinjections.registerpagecloseaction(closepage) 55 expandcurrent() 56 end 57end 58 59references.setopendocument = setopendocumentaction 60references.setclosedocument = setclosedocumentaction 61references.setopenpage = setopenpageaction 62references.setclosepage = setclosepageaction 63 64implement { name = "setopendocumentaction", arguments = "string", actions = setopendocumentaction } 65implement { name = "setclosedocumentaction", arguments = "string", actions = setclosedocumentaction } 66implement { name = "setopenpageaction", arguments = "string", actions = setopenpageaction } 67implement { name = "setclosepageaction", arguments = "string", actions = setclosepageaction } 68 |