summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/context/base/math-ini.lua
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2015-04-18 22:52:45 +0000
committerKarl Berry <karl@freefriends.org>2015-04-18 22:52:45 +0000
commit16aa5a7c87f18a2483d0d61795899f886781b51c (patch)
tree1d72f00b2a4185425393598402fe055c61d1de58 /Master/texmf-dist/tex/context/base/math-ini.lua
parente68dc4d5506d46bf72823234f902bc76d1f70352 (diff)
context, from www.pragma-ade.com/context/beta/cont-tmf.zip (18apr15)
git-svn-id: svn://tug.org/texlive/trunk@36923 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/tex/context/base/math-ini.lua')
-rw-r--r--Master/texmf-dist/tex/context/base/math-ini.lua160
1 files changed, 116 insertions, 44 deletions
diff --git a/Master/texmf-dist/tex/context/base/math-ini.lua b/Master/texmf-dist/tex/context/base/math-ini.lua
index 9772ce5389d..88159e10746 100644
--- a/Master/texmf-dist/tex/context/base/math-ini.lua
+++ b/Master/texmf-dist/tex/context/base/math-ini.lua
@@ -18,30 +18,33 @@ if not modules then modules = { } end modules ['math-ini'] = {
local formatters, find = string.formatters, string.find
local utfchar, utfbyte, utflength = utf.char, utf.byte, utf.length
local floor = math.floor
+local toboolean = toboolean
-local context = context
-local commands = commands
+local context = context
+local commands = commands
+local implement = interfaces.implement
-local context_sprint = context.sprint
------ context_fprint = context.fprint -- a bit inefficient
+local context_sprint = context.sprint
+----- context_fprint = context.fprint -- a bit inefficient
+local ctx_doifelsesomething = commands.doifelsesomething
-local trace_defining = false trackers.register("math.defining", function(v) trace_defining = v end)
+local trace_defining = false trackers.register("math.defining", function(v) trace_defining = v end)
-local report_math = logs.reporter("mathematics","initializing")
+local report_math = logs.reporter("mathematics","initializing")
-mathematics = mathematics or { }
-local mathematics = mathematics
+mathematics = mathematics or { }
+local mathematics = mathematics
-mathematics.extrabase = 0xFE000 -- here we push some virtuals
-mathematics.privatebase = 0xFF000 -- here we push the ex
+mathematics.extrabase = 0xFE000 -- here we push some virtuals
+mathematics.privatebase = 0xFF000 -- here we push the ex
-local unsetvalue = attributes.unsetvalue
-local allocate = utilities.storage.allocate
-local chardata = characters.data
+local unsetvalue = attributes.unsetvalue
+local allocate = utilities.storage.allocate
+local chardata = characters.data
-local texsetattribute = tex.setattribute
-local setmathcode = tex.setmathcode
-local setdelcode = tex.setdelcode
+local texsetattribute = tex.setattribute
+local setmathcode = tex.setmathcode
+local setdelcode = tex.setdelcode
local families = allocate {
mr = 0,
@@ -464,7 +467,7 @@ end
local function utfmathfiller(chr, default)
local cd = somechar[chr]
- local cmd = cd and (cd.mathfiller or cd.mathname)
+ local cmd = cd and cd.mathfiller -- or cd.mathname
return cmd or default or ""
end
@@ -476,20 +479,72 @@ mathematics.utfmathaccent = utfmathaccent
-- interfaced
-function commands.utfmathclass (...) context(utfmathclass (...)) end
-function commands.utfmathstretch(...) context(utfmathstretch(...)) end
-function commands.utfmathcommand(...) context(utfmathcommand(...)) end
-function commands.utfmathfiller (...) context(utfmathfiller (...)) end
+implement {
+ name = "utfmathclass",
+ actions = { utfmathclass, context },
+ arguments = "string"
+}
-function commands.doifelseutfmathaccent(chr,asked)
- commands.doifelse(utfmathaccent(chr,nil,asked))
-end
+implement {
+ name = "utfmathstretch",
+ actions = { utfmathstretch, context },
+ arguments = "string"
+}
+
+implement {
+ name = "utfmathcommand",
+ actions = { utfmathcommand, context },
+ arguments = "string"
+}
+
+implement {
+ name = "utfmathfiller",
+ actions = { utfmathfiller, context },
+ arguments = "string"
+}
-function commands.utfmathcommandabove(asked) context(utfmathcommand(asked,nil,"topaccent","over" )) end
-function commands.utfmathcommandbelow(asked) context(utfmathcommand(asked,nil,"botaccent","under")) end
+implement {
+ name = "utfmathcommandabove",
+ actions = { utfmathcommand, context },
+ arguments = { "string", false, "'topaccent'","'over'" }
+}
-function commands.doifelseutfmathabove(chr) commands.doifelse(utfmathaccent(chr,nil,"topaccent","over" )) end
-function commands.doifelseutfmathbelow(chr) commands.doifelse(utfmathaccent(chr,nil,"botaccent","under")) end
+implement {
+ name = "utfmathcommandbelow",
+ actions = { utfmathcommand, context },
+ arguments = { "string", false, "'botaccent'","'under'" }
+}
+implement {
+ name = "utfmathcommandfiller",
+ actions = { utfmathfiller, context },
+ arguments = "string"
+}
+
+-- todo: make this a helper:
+
+implement {
+ name = "doifelseutfmathabove",
+ actions = { utfmathaccent, ctx_doifelsesomething },
+ arguments = { "string", false, "'topaccent'", "'over'" }
+}
+
+implement {
+ name = "doifelseutfmathbelow",
+ actions = { utfmathaccent, ctx_doifelsesomething },
+ arguments = { "string", false, "'botaccent'", "'under'" }
+}
+
+implement {
+ name = "doifelseutfmathaccent",
+ actions = { utfmathaccent, ctx_doifelsesomething },
+ arguments = "string",
+}
+
+implement {
+ name = "doifelseutfmathfiller",
+ actions = { utfmathfiller, ctx_doifelsesomething },
+ arguments = "string",
+}
-- helpers
--
@@ -599,30 +654,34 @@ local noffunctions = 1000 -- offset
categories.functions = functions
-function commands.taggedmathfunction(tag,label,apply)
- local delta = apply and 1000 or 0
- if label then
- local n = functions[tag]
- if not n then
- noffunctions = noffunctions + 1
- functions[noffunctions] = tag
- functions[tag] = noffunctions
- texsetattribute(a_mathcategory,noffunctions + delta)
+implement {
+ name = "taggedmathfunction",
+ arguments = { "string", "string", "string" },
+ actions = function(tag,label,apply)
+ local delta = toboolean(apply) and 1000 or 0
+ if toboolean(label) then
+ local n = functions[tag]
+ if not n then
+ noffunctions = noffunctions + 1
+ functions[noffunctions] = tag
+ functions[tag] = noffunctions
+ texsetattribute(a_mathcategory,noffunctions + delta)
+ else
+ texsetattribute(a_mathcategory,n + delta)
+ end
+ context.mathlabeltext(tag)
else
- texsetattribute(a_mathcategory,n + delta)
+ texsetattribute(a_mathcategory,1000 + delta)
+ context(tag)
end
- context.mathlabeltext(tag)
- else
- texsetattribute(a_mathcategory,1000 + delta)
- context(tag)
end
-end
+}
--
local list
-function commands.resetmathattributes()
+function mathematics.resetattributes()
if not list then
list = { }
for k, v in next, attributes.numbers do
@@ -635,3 +694,16 @@ function commands.resetmathattributes()
texsetattribute(list[i],unsetvalue)
end
end
+
+implement {
+ name = "resetmathattributes",
+ actions = mathematics.resetattributes
+}
+
+-- weird to do this here but it's a side affect of math anyway
+
+interfaces.implement {
+ name = "enableasciimode",
+ onlyonce = true,
+ actions = resolvers.macros.enablecomment,
+}