mlib-int.lua /size: 9480 b    last modification: 2021-10-28 13:50
1
if
not
modules
then
modules
=
{
}
end
modules
[
'
mlib-int
'
]
=
{
2
version
=
1
.
001
,
3
comment
=
"
companion to mlib-ctx.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
factor
=
number
.
dimenfactors
.
bp
10
----- mpprint = mp.print
11
local
mpnumeric
=
mp
.
numeric
12
local
mpboolean
=
mp
.
boolean
13
local
mpstring
=
mp
.
string
14
local
mpquoted
=
mp
.
quoted
15
local
getdimen
=
tex
.
getdimen
16
local
getcount
=
tex
.
getcount
17
local
getmacro
=
tokens
.
getters
.
macro
18
local
get
=
tex
.
get
19
local
mpcolor
=
attributes
.
colors
.
mpcolor
20
local
emwidths
=
fonts
.
hashes
.
emwidths
21
local
exheights
=
fonts
.
hashes
.
exheights
22 23
local
registerscript
=
metapost
.
registerscript
24 25
local
on_right_page
=
structures
.
pages
.
on_right
26
local
is_odd_page
=
structures
.
pages
.
is_odd
27
local
in_body_page
=
structures
.
pages
.
in_body
28
local
page_fraction
=
structures
.
pages
.
fraction
29 30
local
function
defaultcolormodel
(
)
-- can be helper
31
local
colormethod
=
getcount
(
"
MPcolormethod
"
)
32
return
(
colormethod
=
=
0
or
colormethod
=
=
1
)
and
1
or
3
33
end
34 35
function
mp
.
PaperHeight
(
)
mpnumeric
(
getdimen
(
"
paperheight
"
)
*
factor
)
end
36
function
mp
.
PaperWidth
(
)
mpnumeric
(
getdimen
(
"
paperwidth
"
)
*
factor
)
end
37
function
mp
.
PrintPaperHeight
(
)
mpnumeric
(
getdimen
(
"
printpaperheight
"
)
*
factor
)
end
38
function
mp
.
PrintPaperWidth
(
)
mpnumeric
(
getdimen
(
"
printpaperwidth
"
)
*
factor
)
end
39
function
mp
.
TopSpace
(
)
mpnumeric
(
getdimen
(
"
topspace
"
)
*
factor
)
end
40
function
mp
.
BottomSpace
(
)
mpnumeric
(
getdimen
(
"
bottomspace
"
)
*
factor
)
end
41
function
mp
.
BackSpace
(
)
mpnumeric
(
getdimen
(
"
backspace
"
)
*
factor
)
end
42
function
mp
.
CutSpace
(
)
mpnumeric
(
getdimen
(
"
cutspace
"
)
*
factor
)
end
43
function
mp
.
MakeupHeight
(
)
mpnumeric
(
getdimen
(
"
makeupheight
"
)
*
factor
)
end
44
function
mp
.
MakeupWidth
(
)
mpnumeric
(
getdimen
(
"
makeupwidth
"
)
*
factor
)
end
45
function
mp
.
TopHeight
(
)
mpnumeric
(
getdimen
(
"
topheight
"
)
*
factor
)
end
46
function
mp
.
TopDistance
(
)
mpnumeric
(
getdimen
(
"
topdistance
"
)
*
factor
)
end
47
function
mp
.
HeaderHeight
(
)
mpnumeric
(
getdimen
(
"
headerheight
"
)
*
factor
)
end
48
function
mp
.
HeaderDistance
(
)
mpnumeric
(
getdimen
(
"
headerdistance
"
)
*
factor
)
end
49
function
mp
.
TextHeight
(
)
mpnumeric
(
getdimen
(
"
textheight
"
)
*
factor
)
end
50
function
mp
.
FooterDistance
(
)
mpnumeric
(
getdimen
(
"
footerdistance
"
)
*
factor
)
end
51
function
mp
.
FooterHeight
(
)
mpnumeric
(
getdimen
(
"
footerheight
"
)
*
factor
)
end
52
function
mp
.
BottomDistance
(
)
mpnumeric
(
getdimen
(
"
bottomdistance
"
)
*
factor
)
end
53
function
mp
.
BottomHeight
(
)
mpnumeric
(
getdimen
(
"
bottomheight
"
)
*
factor
)
end
54
function
mp
.
LeftEdgeWidth
(
)
mpnumeric
(
getdimen
(
"
leftedgewidth
"
)
*
factor
)
end
55
function
mp
.
LeftEdgeDistance
(
)
mpnumeric
(
getdimen
(
"
leftedgedistance
"
)
*
factor
)
end
56
function
mp
.
LeftMarginWidth
(
)
mpnumeric
(
getdimen
(
"
leftmarginwidth
"
)
*
factor
)
end
57
function
mp
.
LeftMarginDistance
(
)
mpnumeric
(
getdimen
(
"
leftmargindistance
"
)
*
factor
)
end
58
function
mp
.
TextWidth
(
)
mpnumeric
(
getdimen
(
"
textwidth
"
)
*
factor
)
end
59
function
mp
.
RightMarginDistance
(
)
mpnumeric
(
getdimen
(
"
rightmargindistance
"
)
*
factor
)
end
60
function
mp
.
RightMarginWidth
(
)
mpnumeric
(
getdimen
(
"
rightmarginwidth
"
)
*
factor
)
end
61
function
mp
.
RightEdgeDistance
(
)
mpnumeric
(
getdimen
(
"
rightedgedistance
"
)
*
factor
)
end
62
function
mp
.
RightEdgeWidth
(
)
mpnumeric
(
getdimen
(
"
rightedgewidth
"
)
*
factor
)
end
63
function
mp
.
InnerMarginDistance
(
)
mpnumeric
(
getdimen
(
"
innermargindistance
"
)
*
factor
)
end
64
function
mp
.
InnerMarginWidth
(
)
mpnumeric
(
getdimen
(
"
innermarginwidth
"
)
*
factor
)
end
65
function
mp
.
OuterMarginDistance
(
)
mpnumeric
(
getdimen
(
"
outermargindistance
"
)
*
factor
)
end
66
function
mp
.
OuterMarginWidth
(
)
mpnumeric
(
getdimen
(
"
outermarginwidth
"
)
*
factor
)
end
67
function
mp
.
InnerEdgeDistance
(
)
mpnumeric
(
getdimen
(
"
inneredgedistance
"
)
*
factor
)
end
68
function
mp
.
InnerEdgeWidth
(
)
mpnumeric
(
getdimen
(
"
inneredgewidth
"
)
*
factor
)
end
69
function
mp
.
OuterEdgeDistance
(
)
mpnumeric
(
getdimen
(
"
outeredgedistance
"
)
*
factor
)
end
70
function
mp
.
OuterEdgeWidth
(
)
mpnumeric
(
getdimen
(
"
outeredgewidth
"
)
*
factor
)
end
71
function
mp
.
PageOffset
(
)
mpnumeric
(
getdimen
(
"
pagebackgroundoffset
"
)
*
factor
)
end
72
function
mp
.
PageDepth
(
)
mpnumeric
(
getdimen
(
"
pagebackgrounddepth
"
)
*
factor
)
end
73
function
mp
.
LayoutColumns
(
)
mpnumeric
(
getcount
(
"
layoutcolumns
"
)
)
end
74
function
mp
.
LayoutColumnDistance
(
)
mpnumeric
(
getdimen
(
"
layoutcolumndistance
"
)
*
factor
)
end
75
function
mp
.
LayoutColumnWidth
(
)
mpnumeric
(
getdimen
(
"
layoutcolumnwidth
"
)
*
factor
)
end
76
function
mp
.
SpineWidth
(
)
mpnumeric
(
getdimen
(
"
spinewidth
"
)
*
factor
)
end
77
function
mp
.
PaperBleed
(
)
mpnumeric
(
getdimen
(
"
paperbleed
"
)
*
factor
)
end
78 79
function
mp
.
RealPageNumber
(
)
mpnumeric
(
getcount
(
"
realpageno
"
)
)
end
80
function
mp
.
LastPageNumber
(
)
mpnumeric
(
getcount
(
"
lastpageno
"
)
)
end
81 82
function
mp
.
PageNumber
(
)
mpnumeric
(
getcount
(
"
pageno
"
)
)
end
83
function
mp
.
NOfPages
(
)
mpnumeric
(
getcount
(
"
lastpageno
"
)
)
end
84 85
function
mp
.
SubPageNumber
(
)
mpnumeric
(
getcount
(
"
subpageno
"
)
)
end
86
function
mp
.
NOfSubPages
(
)
mpnumeric
(
getcount
(
"
lastsubpageno
"
)
)
end
87 88
function
mp
.
CurrentColumn
(
)
mpnumeric
(
getcount
(
"
mofcolumns
"
)
)
end
89
function
mp
.
NOfColumns
(
)
mpnumeric
(
getcount
(
"
nofcolumns
"
)
)
end
90 91
function
mp
.
BaseLineSkip
(
)
mpnumeric
(
get
(
"
baselineskip
"
,
true
)
*
factor
)
end
92
function
mp
.
LineHeight
(
)
mpnumeric
(
getdimen
(
"
lineheight
"
)
*
factor
)
end
93
function
mp
.
BodyFontSize
(
)
mpnumeric
(
getdimen
(
"
bodyfontsize
"
)
*
factor
)
end
94 95
function
mp
.
TopSkip
(
)
mpnumeric
(
get
(
"
topskip
"
,
true
)
*
factor
)
end
96
function
mp
.
StrutHeight
(
)
mpnumeric
(
getdimen
(
"
strutht
"
)
*
factor
)
end
97
function
mp
.
StrutDepth
(
)
mpnumeric
(
getdimen
(
"
strutdp
"
)
*
factor
)
end
98 99
function
mp
.
PageNumber
(
)
mpnumeric
(
getcount
(
"
pageno
"
)
)
end
100
function
mp
.
RealPageNumber
(
)
mpnumeric
(
getcount
(
"
realpageno
"
)
)
end
101
function
mp
.
NOfPages
(
)
mpnumeric
(
getcount
(
"
lastpageno
"
)
)
end
102 103
function
mp
.
CurrentWidth
(
)
mpnumeric
(
get
(
"
hsize
"
)
*
factor
)
end
104
function
mp
.
CurrentHeight
(
)
mpnumeric
(
get
(
"
vsize
"
)
*
factor
)
end
105 106
function
mp
.
EmWidth
(
)
mpnumeric
(
emwidths
[
false
]
*
factor
)
end
107
function
mp
.
ExHeight
(
)
mpnumeric
(
exheights
[
false
]
*
factor
)
end
108 109
function
mp
.
OverlayWidth
(
)
mpnumeric
(
getdimen
(
"
d_overlay_width
"
)
*
factor
)
end
110
function
mp
.
OverlayHeight
(
)
mpnumeric
(
getdimen
(
"
d_overlay_height
"
)
*
factor
)
end
111
function
mp
.
OverlayDepth
(
)
mpnumeric
(
getdimen
(
"
d_overlay_depth
"
)
*
factor
)
end
112
function
mp
.
OverlayLineWidth
(
)
mpnumeric
(
getdimen
(
"
d_overlay_linewidth
"
)
*
factor
)
end
113
function
mp
.
OverlayOffset
(
)
mpnumeric
(
getdimen
(
"
d_overlay_offset
"
)
*
factor
)
end
114
function
mp
.
OverlayRegion
(
)
mpstring
(
getmacro
(
"
m_overlay_region
"
)
)
end
115 116
function
mp
.
PageFraction
(
)
mpnumeric
(
page_fraction
(
)
)
end
117
function
mp
.
OnRightPage
(
)
mpboolean
(
on_right_page
(
)
)
end
118
function
mp
.
OnOddPage
(
)
mpboolean
(
is_odd_page
(
)
)
end
119
function
mp
.
InPageBody
(
)
mpboolean
(
in_body_page
(
)
)
end
120 121
function
mp
.
OverlayWidth
(
)
mpnumeric
(
getdimen
(
"
d_overlay_width
"
)
*
factor
)
end
122
function
mp
.
OverlayHeight
(
)
mpnumeric
(
getdimen
(
"
d_overlay_height
"
)
*
factor
)
end
123
function
mp
.
OverlayDepth
(
)
mpnumeric
(
getdimen
(
"
d_overlay_depth
"
)
*
factor
)
end
124
function
mp
.
OverlayLineWidth
(
)
mpnumeric
(
getdimen
(
"
d_overlay_linewidth
"
)
*
factor
)
end
125
function
mp
.
OverlayOffset
(
)
mpnumeric
(
getdimen
(
"
d_overlay_offset
"
)
*
factor
)
end
126
function
mp
.
OverlayRegion
(
)
mpstring
(
getmacro
(
"
m_overlay_region
"
)
)
end
127
-- mp.CurrentLayout () mpstring (getmacro("currentlayout")) end
128 129
function
mp
.
defaultcolormodel
(
)
mpnumeric
(
defaultcolormodel
(
)
)
end
130 131
mp
.
HSize
=
mp
.
CurrentWidth
132
mp
.
VSize
=
mp
.
CurrentHeight
133
mp
.
LastPageNumber
=
mp
.
NOfPages
134 135
-- not much difference (10000 calls in a graphic neither as expansion seems to win
136
-- over defining the macro etc) so let's not waste counters then
137 138
-- function mp.OverlayColor()
139
-- local c = mpcolor(
140
-- getcount("c_overlay_colormodel"),
141
-- getcount("c_overlay_color"),
142
-- getcount("c_overlay_transparency")
143
-- )
144
-- mpquoted(c)
145
-- end
146
--
147
-- function mp.OverlayLineColor()
148
-- local c = mpcolor(
149
-- getcount("c_overlay_colormodel"),
150
-- getcount("c_overlay_linecolor"),
151
-- getcount("c_overlay_linetransparency")
152
-- )
153
-- mpquoted(c)
154
-- end
155