summaryrefslogtreecommitdiff
path: root/tex/context/base/mkiv/mlib-lua.lua
diff options
context:
space:
mode:
authorHans Hagen <pragma@wxs.nl>2017-01-17 18:05:46 +0100
committerContext Git Mirror Bot <phg42.2a@gmail.com>2017-01-17 18:05:46 +0100
commit0cfeab235554eeee0dddd6c3f44d3939ab490ff1 (patch)
treefed70e9a3332741e5294a01197c716dff8556506 /tex/context/base/mkiv/mlib-lua.lua
parent72d161c0a522fd92f32edd3588fa126c453f4a3d (diff)
downloadcontext-0cfeab235554eeee0dddd6c3f44d3939ab490ff1.tar.gz
2017-01-17 17:43:00
Diffstat (limited to 'tex/context/base/mkiv/mlib-lua.lua')
-rw-r--r--tex/context/base/mkiv/mlib-lua.lua32
1 files changed, 31 insertions, 1 deletions
diff --git a/tex/context/base/mkiv/mlib-lua.lua b/tex/context/base/mkiv/mlib-lua.lua
index 2b5648e16..8f24124b9 100644
--- a/tex/context/base/mkiv/mlib-lua.lua
+++ b/tex/context/base/mkiv/mlib-lua.lua
@@ -406,7 +406,7 @@ end
-- end
function mp.tt_dimensions(n)
- local box = textexts[n]
+ local box = textexts and textexts[n]
if box then
-- could be made faster with nuts but not critical
mptriplet(box.width/factor,box.height/factor,box.depth/factor)
@@ -509,3 +509,33 @@ end
-- function mp.prefix(str)
-- mpprint(hash[str])
-- end
+
+local getdimen = tex.getdimen
+local getcount = tex.getcount
+local gettoks = tex.gettoks
+local setdimen = tex.setdimen
+local setcount = tex.setcount
+local settoks = tex.settoks
+
+local mpprint = mp.print
+local mpquoted = mp.quoted
+
+local factor = number.dimenfactors.bp
+
+-- more helpers
+
+function mp.getdimen(k) mpprint (getdimen(k)*factor) end
+function mp.getcount(k) mpprint (getcount(k)) end
+function mp.gettoks (k) mpquoted(gettoks (k)) end
+function mp.setdimen(k,v) setdimen(k,v/factor) end
+function mp.setcount(k,v) setcount(k,v) end
+function mp.settoks (k,v) settoks (k,v) end
+
+-- def foo = lua.mp.foo ... enddef ; % loops due to foo in suffix
+
+mp._get_dimen_ = mp.getdimen
+mp._get_count_ = mp.getcount
+mp._get_toks_ = mp.gettoks
+mp._set_dimen_ = mp.setdimen
+mp._set_count_ = mp.setcount
+mp._set_toks_ = mp.settoks