1if not modules then modules = { } end modules ['math-ext'] = { 2 version = 1.001, 3 comment = "companion to math-ini.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 9-- local basename = file.basename 10-- local sortedhash = table.sortedhash 11-- 12-- local mathematics = mathematics 13-- local extras = mathematics.extras or { } 14-- mathematics.extras = extras 15-- 16-- local characters = characters 17-- local chardata = characters.data 18-- local mathpairs = characters.mathpairs 19-- 20-- local trace_virtual = false 21-- local report_math = logs.reporter("mathematics") 22-- 23-- trackers.register("math.virtual", function(v) trace_virtual = v end) 24-- 25-- local mathplus = { } 26-- 27-- function extras.add(unicode) 28-- local min = mathematics.extrabase 29-- local max = min + 0xFFF 30-- if unicode >= min and unicode <= max then 31-- if chardata[unicode] then 32-- mathplus[unicode] = true 33-- else 34-- report_math("extra %U is not a registered code point",unicode) 35-- end 36-- else 37-- report_math("extra %U should be in range %U - %U",unicode,min,max) 38-- end 39-- end 40-- 41-- function extras.copy(target,original) 42-- local characters = target.characters 43-- local properties = target.properties 44-- local parameters = target.parameters 45-- for unicode in sortedhash(mathplus) do 46-- local extradesc = chardata[unicode] 47-- local nextinsize = extradesc.nextinsize 48-- if nextinsize then 49-- local extrachar = characters[unicode] 50-- local first = 1 51-- local charused = unicode 52-- if not extrachar then 53-- for i=1,#nextinsize do 54-- local slot = nextinsize[i] 55-- extrachar = characters[slot] 56-- if extrachar then 57-- characters[unicode] = extrachar 58-- first = i + 1 59-- charused = slot 60-- break 61-- end 62-- end 63-- end 64-- if not extrachar then 65-- if trace_virtual then 66-- report_math("extra %U in %a at %p with class %a and name %a is not mapped", 67-- unicode,basename(properties.fullname),parameters.size, 68-- extradesc.mathclass,extradesc.mathname) 69-- end 70-- elseif not extrachar.next then 71-- local nextused = false 72-- for i=first,#nextinsize do 73-- local nextslot = nextinsize[i] 74-- local nextbase = characters[nextslot] 75-- if nextbase then 76-- local nextnext = nextbase and nextbase.next 77-- if nextnext then 78-- local nextchar = characters[nextnext] 79-- if nextchar then 80-- extrachar.next = nextchar 81-- nextused = nextslot 82-- break 83-- end 84-- end 85-- end 86-- end 87-- if trace_virtual then 88-- if nextused then 89-- report_math("extra %U in %a at %p with class %a and name %a maps onto %U with next %U", 90-- unicode,basename(properties.fullname),parameters.size,charused, 91-- extradesc.mathclass,extradesc.mathname,nextused) 92-- else 93-- report_math("extra %U in %a at %p with class %a and name %a maps onto %U with no next", 94-- unicode,basename(properties.fullname),parameters.size,charused, 95-- extradesc.mathclass,extradesc.mathname) 96-- end 97-- end 98-- else 99-- if trace_virtual then 100-- report_math("extra %U in %a at %p with class %a and name %a maps onto %U with no next", -- own next 101-- unicode,basename(properties.fullname),parameters.size,charused, 102-- extradesc.mathclass,extradesc.mathname) 103-- end 104-- end 105-- end 106-- end 107-- end 108-- 109-- utilities.sequencers.appendaction(mathactions,"system","mathematics.extras.copy") 110 |