1if 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
10
11
12local texgetcount = tex.getcount
13local conditionals = tex.conditionals
14
15layouts = {
16 status = { },
17}
18
19local status = layouts.status
20
21function 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
42end
43
44function 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
54end
55 |