0 7ˆl–Ü4ý(Ð;�½p-©‹Fÿ�þYn,Üd+mQ¹üÿÍ „™u¯ÌÀÊ0Vif not modules then modules = { } end modules ['driv-ini'] = { version = 1.001, comment = "companion to driv-ini.mkiv", author = "Hans Hagen, PRAGMA-ADE, Hasselt NL", copyright = "PRAGMA ADE / ConTeXt Development Team", license = "see context related readme files" } local type = type local addsuffix = file.addsuffix local setmetatableindex = table.setmetatableindex local formatters = string.formatters local starttiming = statistics.starttiming local stoptiming = statistics.stoptiming local report = logs.reporter("drivers") local instances = { } local helpers = { } local converters = { } local prepared = { } local wrappedup = { } local cleanedup = { } local currentdriver = "default" local currentinstance = nil local shipout = tex.shipout local texgetbox = tex.getbox local texgetcount = tex.getcount function converters.engine(driver,boxnumber,mode,number,specification) return shipout(boxnumber) end local prepare = nil local convert = nil local wrapup = nil local cleanup = nil local outputfilename = nil drivers = drivers or { instances = instances, helpers = helpers, converters = converters, lmtxversion = 0.10, report = report, } local dummy = function() end local defaulthandlers = { prepare = dummy, initialize = dummy, finalize = dummy, updatefontstate = dummy, wrapup = dummy, cleanup = dummy, convert = dummy, outputfilename = dummy, } local installwhatsits do local leaderlevel = 0 local backends = backends local function pushleaderlevel() leaderlevel = leaderlevel + 1 end local function popleaderlevel() leaderlevel = leaderlevel - 1 end local function flushlatelua(current,h,v) -- Here we assume maganement by the lua function so currently we don't -- check for leaderlevel. return backends.latelua(current,h,v) end local function flushwriteout(current) if leaderlevel == 0 then backends.writeout(current) end end local function flushopenout(current) if leaderlevel == 0 then backends.openout(current) end end local function flushcloseout(current) if leaderlevel == 0 then backends.closeout(current) end end local function flushsavepos(current,pos_h,pos_v) local jp = job.positions jp.lastx = pos_h jp.lasty = pos_v end local function flushuserdefined() -- nothing here end local whatsitcodes = nodes.whatsitcodes local trace = true trackers.register("backends.whatsits",function(v) trace = v end) installwhatsits = function(name,flushers) -- latelua : specific -- userdefined : special purpose, handled in callbacks -- savepos : only used by generic packages -- open : generic -- close : generic -- write : generic -- An alternative is to have a first time setter. local function checkagain(t, k) local v = rawget(flushers,k) -- in case it's registered later if not v then if trace then report("unsupported whatsit %a in driver %a",whatsitcodes[k] or k,name) end v = function() end end t[k] = v return v end -- flushers.whatsit = setmetatableindex ( { -- [whatsitcodes.literal] = flushers.literal, -- [whatsitcodes.latelua] = flushlatelua, -- [whatsitcodes.userdefined] = flushuserdefined, -- [whatsitcodes.savepos] = flushsavepos, -- [whatsitcodes.save] = flushers.save, -- [whatsitcodes.restore] = flushers.res