summaryrefslogtreecommitdiff
path: root/tex/context/base/mkiv/mlib-int.lua
diff options
context:
space:
mode:
authorHans Hagen <pragma@wxs.nl>2018-08-30 19:50:57 +0200
committerContext Git Mirror Bot <phg@phi-gamma.net>2018-08-30 19:50:57 +0200
commit2106beefbc854f77a92264c815d3cf2b3460f0b6 (patch)
tree87e03bf8309b94bfad813eb755d7b0ab0d2717f5 /tex/context/base/mkiv/mlib-int.lua
parent5794d8b0c845aad2ab4cf36dc14201b21ef5a784 (diff)
downloadcontext-2106beefbc854f77a92264c815d3cf2b3460f0b6.tar.gz
2018-08-30 18:50:00
Diffstat (limited to 'tex/context/base/mkiv/mlib-int.lua')
-rw-r--r--tex/context/base/mkiv/mlib-int.lua178
1 files changed, 91 insertions, 87 deletions
diff --git a/tex/context/base/mkiv/mlib-int.lua b/tex/context/base/mkiv/mlib-int.lua
index 5abc49a52..63e7278da 100644
--- a/tex/context/base/mkiv/mlib-int.lua
+++ b/tex/context/base/mkiv/mlib-int.lua
@@ -7,11 +7,14 @@ if not modules then modules = { } end modules ['mlib-int'] = {
}
local factor = number.dimenfactors.bp
-local mpprint = mp.print
------ mpboolean = mp.boolean
------ mpquoted = mp.quoted
+----- mpprint = mp.print
+local mpnumeric = mp.numeric
+local mpboolean = mp.boolean
+local mpstring = mp.string
+local mpquoted = mp.quoted
local getdimen = tex.getdimen
local getcount = tex.getcount
+local getmacro = tokens.getters.macro
local get = tex.get
local mpcolor = attributes.colors.mpcolor
local emwidths = fonts.hashes.emwidths
@@ -19,79 +22,79 @@ local exheights = fonts.hashes.exheights
local mpgetdimen = mp.getdimen
-function mp.PaperHeight () mpprint(getdimen("paperheight") *factor) end
-function mp.PaperWidth () mpprint(getdimen("paperwidth") *factor) end
-function mp.PrintPaperHeight () mpprint(getdimen("printpaperheight") *factor) end
-function mp.PrintPaperWidth () mpprint(getdimen("printpaperwidth") *factor) end
-function mp.TopSpace () mpprint(getdimen("topspace") *factor) end
-function mp.BottomSpace () mpprint(getdimen("bottomspace") *factor) end
-function mp.BackSpace () mpprint(getdimen("backspace") *factor) end
-function mp.CutSpace () mpprint(getdimen("cutspace") *factor) end
-function mp.MakeupHeight () mpprint(getdimen("makeupheight") *factor) end
-function mp.MakeupWidth () mpprint(getdimen("makeupwidth") *factor) end
-function mp.TopHeight () mpprint(getdimen("topheight") *factor) end
-function mp.TopDistance () mpprint(getdimen("topdistance") *factor) end
-function mp.HeaderHeight () mpprint(getdimen("headerheight") *factor) end
-function mp.HeaderDistance () mpprint(getdimen("headerdistance") *factor) end
-function mp.TextHeight () mpprint(getdimen("textheight") *factor) end
-function mp.FooterDistance () mpprint(getdimen("footerdistance") *factor) end
-function mp.FooterHeight () mpprint(getdimen("footerheight") *factor) end
-function mp.BottomDistance () mpprint(getdimen("bottomdistance") *factor) end
-function mp.BottomHeight () mpprint(getdimen("bottomheight") *factor) end
-function mp.LeftEdgeWidth () mpprint(getdimen("leftedgewidth") *factor) end
-function mp.LeftEdgeDistance () mpprint(getdimen("leftedgedistance") *factor) end
-function mp.LeftMarginWidth () mpprint(getdimen("leftmarginwidth") *factor) end
-function mp.LeftMarginDistance () mpprint(getdimen("leftmargindistance") *factor) end
-function mp.TextWidth () mpprint(getdimen("textwidth") *factor) end
-function mp.RightMarginDistance () mpprint(getdimen("rightmargindistance") *factor) end
-function mp.RightMarginWidth () mpprint(getdimen("rightmarginwidth") *factor) end
-function mp.RightEdgeDistance () mpprint(getdimen("rightedgedistance") *factor) end
-function mp.RightEdgeWidth () mpprint(getdimen("rightedgewidth") *factor) end
-function mp.InnerMarginDistance () mpprint(getdimen("innermargindistance") *factor) end
-function mp.InnerMarginWidth () mpprint(getdimen("innermarginwidth") *factor) end
-function mp.OuterMarginDistance () mpprint(getdimen("outermargindistance") *factor) end
-function mp.OuterMarginWidth () mpprint(getdimen("outermarginwidth") *factor) end
-function mp.InnerEdgeDistance () mpprint(getdimen("inneredgedistance") *factor) end
-function mp.InnerEdgeWidth () mpprint(getdimen("inneredgewidth") *factor) end
-function mp.OuterEdgeDistance () mpprint(getdimen("outeredgedistance") *factor) end
-function mp.OuterEdgeWidth () mpprint(getdimen("outeredgewidth") *factor) end
-function mp.PageOffset () mpprint(getdimen("pagebackgroundoffset")*factor) end
-function mp.PageDepth () mpprint(getdimen("pagebackgrounddepth") *factor) end
-function mp.LayoutColumns () mpprint(getcount("layoutcolumns")) end
-function mp.LayoutColumnDistance() mpprint(getdimen("layoutcolumndistance")*factor) end
-function mp.LayoutColumnWidth () mpprint(getdimen("layoutcolumnwidth") *factor) end
-function mp.SpineWidth () mpprint(getdimen("spinewidth") *factor) end
-function mp.PaperBleed () mpprint(getdimen("paperbleed") *factor) end
-
-function mp.RealPageNumber () mpprint(getcount("realpageno")) end
-function mp.LastPageNumber () mpprint(getcount("lastpageno")) end
-
-function mp.PageNumber () mpprint(getcount("pageno")) end
-function mp.NOfPages () mpprint(getcount("lastpageno")) end
-
-function mp.SubPageNumber () mpprint(getcount("subpageno")) end
-function mp.NOfSubPages () mpprint(getcount("lastsubpageno")) end
-
-function mp.CurrentColumn () mpprint(getcount("mofcolumns")) end
-function mp.NOfColumns () mpprint(getcount("nofcolumns")) end
-
-function mp.BaseLineSkip () mpprint(get ("baselineskip",true) *factor) end
-function mp.LineHeight () mpprint(getdimen("lineheight") *factor) end
-function mp.BodyFontSize () mpprint(getdimen("bodyfontsize") *factor) end
-
-function mp.TopSkip () mpprint(get ("topskip",true) *factor) end
-function mp.StrutHeight () mpprint(getdimen("strutht") *factor) end
-function mp.StrutDepth () mpprint(getdimen("strutdp") *factor) end
-
-function mp.PageNumber () mpprint(getcount("pageno")) end
-function mp.RealPageNumber () mpprint(getcount("realpageno")) end
-function mp.NOfPages () mpprint(getcount("lastpageno")) end
-
-function mp.CurrentWidth () mpprint(get ("hsize") *factor) end
-function mp.CurrentHeight () mpprint(get ("vsize") *factor) end
-
-function mp.EmWidth () mpprint(emwidths [false]*factor) end
-function mp.ExHeight () mpprint(exheights[false]*factor) end
+function mp.PaperHeight () mpnumeric(getdimen("paperheight") *factor) end
+function mp.PaperWidth () mpnumeric(getdimen("paperwidth") *factor) end
+function mp.PrintPaperHeight () mpnumeric(getdimen("printpaperheight") *factor) end
+function mp.PrintPaperWidth () mpnumeric(getdimen("printpaperwidth") *factor) end
+function mp.TopSpace () mpnumeric(getdimen("topspace") *factor) end
+function mp.BottomSpace () mpnumeric(getdimen("bottomspace") *factor) end
+function mp.BackSpace () mpnumeric(getdimen("backspace") *factor) end
+function mp.CutSpace () mpnumeric(getdimen("cutspace") *factor) end
+function mp.MakeupHeight () mpnumeric(getdimen("makeupheight") *factor) end
+function mp.MakeupWidth () mpnumeric(getdimen("makeupwidth") *factor) end
+function mp.TopHeight () mpnumeric(getdimen("topheight") *factor) end
+function mp.TopDistance () mpnumeric(getdimen("topdistance") *factor) end
+function mp.HeaderHeight () mpnumeric(getdimen("headerheight") *factor) end
+function mp.HeaderDistance () mpnumeric(getdimen("headerdistance") *factor) end
+function mp.TextHeight () mpnumeric(getdimen("textheight") *factor) end
+function mp.FooterDistance () mpnumeric(getdimen("footerdistance") *factor) end
+function mp.FooterHeight () mpnumeric(getdimen("footerheight") *factor) end
+function mp.BottomDistance () mpnumeric(getdimen("bottomdistance") *factor) end
+function mp.BottomHeight () mpnumeric(getdimen("bottomheight") *factor) end
+function mp.LeftEdgeWidth () mpnumeric(getdimen("leftedgewidth") *factor) end
+function mp.LeftEdgeDistance () mpnumeric(getdimen("leftedgedistance") *factor) end
+function mp.LeftMarginWidth () mpnumeric(getdimen("leftmarginwidth") *factor) end
+function mp.LeftMarginDistance () mpnumeric(getdimen("leftmargindistance") *factor) end
+function mp.TextWidth () mpnumeric(getdimen("textwidth") *factor) end
+function mp.RightMarginDistance () mpnumeric(getdimen("rightmargindistance") *factor) end
+function mp.RightMarginWidth () mpnumeric(getdimen("rightmarginwidth") *factor) end
+function mp.RightEdgeDistance () mpnumeric(getdimen("rightedgedistance") *factor) end
+function mp.RightEdgeWidth () mpnumeric(getdimen("rightedgewidth") *factor) end
+function mp.InnerMarginDistance () mpnumeric(getdimen("innermargindistance") *factor) end
+function mp.InnerMarginWidth () mpnumeric(getdimen("innermarginwidth") *factor) end
+function mp.OuterMarginDistance () mpnumeric(getdimen("outermargindistance") *factor) end
+function mp.OuterMarginWidth () mpnumeric(getdimen("outermarginwidth") *factor) end
+function mp.InnerEdgeDistance () mpnumeric(getdimen("inneredgedistance") *factor) end
+function mp.InnerEdgeWidth () mpnumeric(getdimen("inneredgewidth") *factor) end
+function mp.OuterEdgeDistance () mpnumeric(getdimen("outeredgedistance") *factor) end
+function mp.OuterEdgeWidth () mpnumeric(getdimen("outeredgewidth") *factor) end
+function mp.PageOffset () mpnumeric(getdimen("pagebackgroundoffset")*factor) end
+function mp.PageDepth () mpnumeric(getdimen("pagebackgrounddepth") *factor) end
+function mp.LayoutColumns () mpnumeric(getcount("layoutcolumns")) end
+function mp.LayoutColumnDistance() mpnumeric(getdimen("layoutcolumndistance")*factor) end
+function mp.LayoutColumnWidth () mpnumeric(getdimen("layoutcolumnwidth") *factor) end
+function mp.SpineWidth () mpnumeric(getdimen("spinewidth") *factor) end
+function mp.PaperBleed () mpnumeric(getdimen("paperbleed") *factor) end
+
+function mp.RealPageNumber () mpnumeric(getcount("realpageno")) end
+function mp.LastPageNumber () mpnumeric(getcount("lastpageno")) end
+
+function mp.PageNumber () mpnumeric(getcount("pageno")) end
+function mp.NOfPages () mpnumeric(getcount("lastpageno")) end
+
+function mp.SubPageNumber () mpnumeric(getcount("subpageno")) end
+function mp.NOfSubPages () mpnumeric(getcount("lastsubpageno")) end
+
+function mp.CurrentColumn () mpnumeric(getcount("mofcolumns")) end
+function mp.NOfColumns () mpnumeric(getcount("nofcolumns")) end
+
+function mp.BaseLineSkip () mpnumeric(get ("baselineskip",true) *factor) end
+function mp.LineHeight () mpnumeric(getdimen("lineheight") *factor) end
+function mp.BodyFontSize () mpnumeric(getdimen("bodyfontsize") *factor) end
+
+function mp.TopSkip () mpnumeric(get ("topskip",true) *factor) end
+function mp.StrutHeight () mpnumeric(getdimen("strutht") *factor) end
+function mp.StrutDepth () mpnumeric(getdimen("strutdp") *factor) end
+
+function mp.PageNumber () mpnumeric(getcount("pageno")) end
+function mp.RealPageNumber () mpnumeric(getcount("realpageno")) end
+function mp.NOfPages () mpnumeric(getcount("lastpageno")) end
+
+function mp.CurrentWidth () mpnumeric(get ("hsize") *factor) end
+function mp.CurrentHeight () mpnumeric(get ("vsize") *factor) end
+
+function mp.EmWidth () mpnumeric(emwidths [false]*factor) end
+function mp.ExHeight () mpnumeric(exheights[false]*factor) end
mp.HSize = mp.CurrentWidth
mp.VSize = mp.CurrentHeight
@@ -100,9 +103,9 @@ mp.LastPageNumber = mp.NOfPages
function mp.PageFraction()
local lastpage = getcount("lastpageno")
if lastpage > 1 then
- mpprint((getcount("realpageno")-1)/(lastpage-1))
+ mpnumeric((getcount("realpageno")-1)/(lastpage-1))
else
- mpprint(1)
+ mpnumeric(1)
end
end
@@ -112,21 +115,22 @@ local on_right = structures.pages.on_right
local is_odd = structures.pages.is_odd
local in_body = structures.pages.in_body
-mp.OnRightPage = function() mpprint(on_right()) end -- needs checking
-mp.OnOddPage = function() mpprint(is_odd ()) end -- needs checking
-mp.InPageBody = function() mpprint(in_body ()) end -- needs checking
+mp.OnRightPage = function() mpboolean(on_right()) end -- needs checking
+mp.OnOddPage = function() mpboolean(is_odd ()) end -- needs checking
+mp.InPageBody = function() mpboolean(in_body ()) end -- needs checking
-- mp.CurrentLayout : \currentlayout
-function mp.OverlayWidth () mpprint(getdimen("d_overlay_width") *factor) end
-function mp.OverlayHeight () mpprint(getdimen("d_overlay_height") *factor) end
-function mp.OverlayDepth () mpprint(getdimen("d_overlay_depth") *factor) end
-function mp.OverlayLineWidth () mpprint(getdimen("d_overlay_linewidth")*factor) end
-function mp.OverlayOffset () mpprint(getdimen("d_overlay_offset") *factor) end
+function mp.OverlayWidth () mpnumeric(getdimen("d_overlay_width") * factor) end
+function mp.OverlayHeight () mpnumeric(getdimen("d_overlay_height") * factor) end
+function mp.OverlayDepth () mpnumeric(getdimen("d_overlay_depth") * factor) end
+function mp.OverlayLineWidth() mpnumeric(getdimen("d_overlay_linewidth") * factor) end
+function mp.OverlayOffset () mpnumeric(getdimen("d_overlay_offset") * factor) end
+function mp.OverlayRegion () mpstring(getmacro("m_overlay_region")) end
function mp.mf_default_color_model()
local colormethod = getcount("MPcolormethod")
- return mpprint((colormethod == 0 or colormethod == 1) and 1 or 3)
+ return mpnumeric((colormethod == 0 or colormethod == 1) and 1 or 3)
end
-- not much difference (10000 calls in a graphic neither as expansion seems to win