page-fac.mkiv /size: 2368 b    last modification: 2020-07-01 14:35
1
%D \module
2
%D [ file=page-fac, % moved from page-ini
3
%D version=2011.12.07, % 2000.10.20,
4
%D title=\CONTEXT\ Page Macros,
5
%D subtitle=Facing Pages,
6
%D author=Hans Hagen,
7
%D date=\currentdate,
8
%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}]
9
%C
10
%C This module is part of the \CONTEXT\ macro||package and is
11
%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
12
%C details.
13 14
\writestatus
{
loading
}{
ConTeXt
Page
Macros
/
Facing
Pages
}
15 16
\unprotect
17 18
%D \macros
19
%D {setupoppositeplacing,startopposite}
20
%D
21
%D \starttyping
22
%D \starttext
23
%D test \startopposite \blackrule[width=3cm,height=4cm] \stopopposite test
24
%D test \startopposite \blackrule[width=3cm,height=4cm] \stopopposite test
25
%D \stoptext
26
%D \stoptyping
27 28
\newbox
\b_page_facings_content
29
\newconditional
\c_page_facings_busy
30 31
\installcorenamespace
{
oppositeplacing
}
32 33
\installsetuponlycommandhandler
\??oppositeplacing
{
oppositeplacing
}
34 35
\unexpanded
\def
\startopposite
36
{
\dowithnextboxcontent
37
{
\hsize
\makeupwidth
}
%
38
{
\global\setbox
\b_page_facings_content
\vbox
39
{
\ifvoid
\b_page_facings_content
40
\directoppositeplacingparameter
\c!before
41
\else
42
\directoppositeplacingparameter
\c!inbetween
43
\unvbox
\b_page_facings_content
44
\fi
45
\box
\nextbox
}}
%
46
\vbox
\bgroup
}
47 48
\unexpanded
\def
\stopopposite
49
{
\egroup
}
50 51
\def
\page_facings_finish
52
{
\ifvoid
\b_page_facings_content
\else
53
\global\setbox
\b_page_facings_content
\vbox
to
\makeupheight
54
{
\unvbox
\b_page_facings_content
55
\directoppositeplacingparameter
\c!after
56
\vss
}
%
57
\fi
}
58 59
\def
\page_facings_flush
60
{
\ifconditional
\c_page_facings_busy
61
\ifvoid
\b_page_facings_content
\else
62
\page_facings_flush_indeed
63
\fi
64
\fi
}
65 66
\def
\page_facings_flush_indeed
67
{
\ifnum
\realpageno
>
\plusone
68
\begingroup
69
\pageornamentstate
\plusone
% tricky
70
\page_facings_finish
71
\page_boxes_shipout
{
\page_boxes_constructed_page
\box
\b_page_facings_content
}
%
72
\endgroup
73
\else
74
\global\setbox
\b_page_facings_content
\emptybox
75
\fi
}
76 77
\appendtoks
78
\doifelse
{
\directoppositeplacingparameter
\c!state
}
\v!start
\settrue\setfalse
\c_page_facings_busy
79
\to
\everysetupoppositeplacing
80 81
\setupoppositeplacing
82
[
\c!state
=
\v!start
,
83
\c!before
=
,
84
\c!inbetween
=
\blank
,
85
\c!after
=]
86 87
\protect
\endinput
88