page-com.mkxl /size: 6788 b    last modification: 2023-12-21 09:44
1%D \module
2%D   [       file=page-com, % moved from page-imp
3%D        version=1998.01.15,
4%D          title=\CONTEXT\ Page Macros,
5%D       subtitle=Page Comments,
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%D This will become runtime loaded code.
15
16\writestatus{loading}{ConTeXt Page Macros / Page Comments}
17
18\unprotect
19
20%D \macros
21%D   {setuppagecomment,startpagecomment}
22%D
23%D This command is not yet documented. Usage:
24%D
25%D \starttyping
26%D \setuppagecomment[state=start,location=right]
27%D
28%D \startpagecomment
29%D \input knuth
30%D \stoppagecomment
31%D \stoptyping
32
33\installcorenamespace{pagecomment}
34\installcorenamespace{pagecommentlocations}
35\installcorenamespace{pagecommentstates}
36
37\newdimension\d_page_comments_offset
38\newdimension\d_page_comments_page_width
39\newdimension\d_page_comments_page_height
40\newdimension\d_page_comments_width
41\newdimension\d_page_comments_height
42\newdimension\d_page_comments_distance
43
44\newconditional\c_page_comment_enabled
45
46\let\p_page_commands_location\v!none
47\let\p_page_commands_state   \v!stop
48
49\installsetuponlycommandhandler \??pagecomment {pagecomment}
50
51\appendtoks
52    \edef\p_page_commands_location{\directpagecommentparameter\c!location}%
53    \edef\p_page_commands_state   {\directpagecommentparameter\c!state}%
54    \expandnamespacemacro\??pagecommentstates\p_page_commands_state\v!none
55\to \everysetuppagecomment
56
57% \ifdefined\scrn_canvas_synchronize_simple
58
59    \appendtoks
60        \ifx\p_page_commands_state\v!start
61            \scrn_canvas_synchronize_simple
62        \else
63            \scrn_canvas_synchronize_complex
64        \fi
65    \to \everyshipout
66
67% \fi
68
69\defcsname\??pagecommentstates\v!start\endcsname
70  {\d_page_comments_offset  \directpagecommentparameter\c!offset  \relax
71   \d_page_comments_distance\directpagecommentparameter\c!distance\relax
72   \d_page_comments_width   \directpagecommentparameter\c!width   \relax
73   \d_page_comments_height  \directpagecommentparameter\c!height  \relax
74   \expandnamespacemacro\??pagecommentlocations\p_page_commands_location\v!none
75   \definepapersize[\v!pagecomment][\c!height=\d_page_comments_page_height,\c!width=\d_page_comments_page_width]%
76   \setuppapersize[\papersize][\v!pagecomment]%
77   \setupbackgrounds[\v!paper][\c!background=\v!pagecomment]} % maybe append if already set
78
79\defcsname\??pagecommentstates\v!stop\endcsname
80  {\setupbackgrounds[\v!paper][\c!background=]}
81
82\defcsname\??pagecommentstates\v!none\endcsname
83  {}
84
85\defcsname\??pagecommentlocations\v!bottom\endcsname
86  {\setuplayout[\c!location=]%
87   \setuppapersize[\c!top=\vskip\d_page_comments_offset,\c!bottom=\vss,\c!left=\hkern\d_page_comments_offset,\c!right=]%
88   \d_page_comments_page_height\dimexpr\paperheight+2\d_page_comments_offset+\d_page_comments_distance+\d_page_comments_height\relax
89   \d_page_comments_page_width \dimexpr\paperwidth +2\d_page_comments_offset\relax
90   \defineoverlay[\v!pagecomment][\page_comments_top_bottom]}
91
92\defcsname\??pagecommentlocations\v!top\endcsname
93  {\setuplayout[\c!location=]%
94   \setuppapersize[\c!top=\vss,\c!bottom=\vskip\d_page_comments_offset,\c!left=\hkern\d_page_comments_offset,\c!right=]%
95   \d_page_comments_page_height\dimexpr\paperheight+2\d_page_comments_offset+\d_page_comments_distance+\d_page_comments_height\relax
96   \d_page_comments_page_width \dimexpr\paperwidth +2\d_page_comments_offset\relax
97   \defineoverlay[\v!pagecomment][\page_comments_top_bottom]}
98
99\defcsname\??pagecommentlocations\v!left\endcsname
100  {\setuplayout[\c!location=]%
101   \setuppapersize[\c!top=\vskip\d_page_comments_offset,\c!bottom=,\c!left=\hss,\c!right=\hkern\d_page_comments_offset]%
102   \d_page_comments_page_height\dimexpr\paperheight+2\d_page_comments_offset\relax
103   \d_page_comments_page_width \dimexpr\paperwidth +2\d_page_comments_offset+\d_page_comments_distance+\d_page_comments_width\relax
104   \defineoverlay[\v!pagecomment][\page_comments_left_right]}
105
106\defcsname\??pagecommentlocations\v!right\endcsname
107  {\setuplayout[\c!location=]%
108   \setuppapersize[\c!top=\vskip\d_page_comments_offset,\c!bottom=,\c!left=\hkern\d_page_comments_offset,\c!right =\hss]%
109   \d_page_comments_page_height\dimexpr\paperheight+2\d_page_comments_offset\relax
110   \d_page_comments_page_width \dimexpr\paperwidth +2\d_page_comments_offset+\d_page_comments_distance+\d_page_comments_width\relax
111   \defineoverlay[\v!pagecomment][\page_comments_left_right]}
112
113\defcsname\??pagecommentlocations\v!none\endcsname
114  {}% \setuppapersize[\c!bottom=,\c!top=,\c!left=,\c!right=]}
115
116\protected\def\page_comments_top_bottom
117  {\vpack to \printpaperheight
118     {%\forgetall
119      \hsize\printpaperwidth\relax
120      \ifx\p_page_commands_location\v!bottom
121        \vskip\dimexpr\paperheight+\d_page_comments_distance+\d_page_comments_offset\relax
122      \else
123        \vskip\d_page_comments_offset
124        \vss
125      \fi
126      \hkern\d_page_comments_offset
127      \vbox to \d_page_comments_height
128        {%\forgetall
129         \hsize\paperwidth
130         \ifconditional\c_page_comment_enabled
131           \getbuffer[\v!pagecomment]%
132           \global\c_page_comment_enabled\conditionalfalse
133         \fi}%
134      \hfill
135      \ifx\p_page_commands_location\v!bottom
136        \vss
137        \vskip\d_page_comments_offset
138      \else
139        \vskip\dimexpr\paperheight+\d_page_comments_distance+\d_page_comments_offset\relax
140      \fi}}
141
142\protected\def\page_comments_left_right
143  {\hpack to \printpaperwidth
144     {\ifx\p_page_commands_location\v!right
145        \hkern\dimexpr\paperwidth+\d_page_comments_distance+\d_page_comments_offset\relax
146      \else
147        \hkern\d_page_comments_offset
148        \hss
149      \fi
150      \vbox to \printpaperheight
151        {%\forgetall
152         \vskip\d_page_comments_offset
153         \hsize\d_page_comments_width
154         \ifconditional\c_page_comment_enabled
155           \getbuffer[\v!pagecomment]%
156           \global\c_page_comment_enabled\conditionalfalse
157         \fi
158         \vss}%
159      \ifx\p_page_commands_location\v!right
160        \hss
161        \hkern\d_page_comments_offset
162      \else
163        \hkern\dimexpr\paperwidth+\d_page_comments_distance+\d_page_comments_offset\relax
164      \fi}}
165
166\permanent\protected\defcsname\e!start\v!pagecomment\endcsname
167  {\global\c_page_comment_enabled\conditionaltrue
168   \grabbufferdatadirect\v!pagecomment{\e!start\v!pagecomment}{\e!stop\v!pagecomment}}
169
170\aliased\letcsname\e!stop\v!pagecomment\endcsname\relax
171
172\setuppagecomment
173  [\c!state=, % \v!stop would invoke background calculation
174   \c!location=\v!bottom,
175   \c!offset=.5cm,
176   \c!distance=.5cm,
177   \c!height=5cm,
178   \c!width=10cm]
179
180\protect \endinput
181