layo-ini.lua /size: 1549 b    last modification: 2020-07-01 14:35
1
if
not
modules
then
modules
=
{
}
end
modules
[
'
layo-ini
'
]
=
{
2
version
=
1
.
001
,
3
comment
=
"
companion to layo-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
-- We need to share information between the TeX and Lua end about the typographical
10
-- model. This happens here. This code might move.
11 12
local
texgetcount
=
tex
.
getcount
13
local
conditionals
=
tex
.
conditionals
14 15
layouts
=
{
16
status
=
{
}
,
17
}
18 19
local
status
=
layouts
.
status
20 21
function
status
.
leftorrightpageaction
(
left
,
right
)
22
if
left
=
=
nil
then
23
left
,
right
=
false
,
true
24
end
25
if
not
conditionals
.
layoutisdoublesided
then
26
return
left
,
right
27
elseif
conditionals
.
layoutissinglesided
then
28
return
left
,
right
29
elseif
texgetcount
(
"
pagenoshift
"
)
%
2
=
=
0
then
30
if
texgetcount
(
"
realpageno
"
)
%
2
=
=
0
then
31
return
right
,
left
32
else
33
return
left
,
right
34
end
35
else
36
if
texgetcount
(
"
realpageno
"
)
%
2
=
=
0
then
37
return
left
,
right
38
else
39
return
right
,
left
40
end
41
end
42
end
43 44
function
status
.
isleftpage
(
r
)
45
if
not
conditionals
.
layoutisdoublesided
then
46
return
false
47
elseif
conditionals
.
layoutissinglesided
then
48
return
false
49
elseif
texgetcount
(
"
pagenoshift
"
)
%
2
=
=
0
then
50
return
(
r
or
texgetcount
(
"
realpageno
"
)
)
%
2
=
=
0
51
else
52
return
not
(
r
or
texgetcount
(
"
realpageno
"
)
)
%
2
=
=
0
53
end
54
end
55