1
2
3
4
5
6
7
8
9
10
11
12
13
14\writestatus{loading}{ConTeXt Page Macros Runtime Macros}
15
16\registerctxluafile{pagerun}{}
17
18\unprotect
19
20\permanent\protected\tolerant\gdef\showprint[#1]#*[#2]#*[#3]
21 {\setbuffer[crap]
22 \unprotect
23 \definepapersize[X][\c!width=4em, \c!height=6em]
24 \definepapersize[Y][\c!width=12em,\c!height=14em]
25 \setuppapersize[X,#1][Y,#2]
26 \setuplayout[#3]
27 \setuplayout[\v!page]
28 \framed
29 [\c!offset=\v!overlay,\c!strut=\v!no,
30 \c!width=\paperwidth,\c!height=\paperheight]
31 {\ss ABC\par DEF}
32 \protect
33 \endbuffer
34 \framed[\c!offset=\v!overlay,\c!strut=\v!no]{\typesetbuffer[crap]}}
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72\permanent\protected\tolerant\gdef\showframe[#1]#*[#2]
73 {\ifarguments
74 \showframe
75 [\v!top,\v!header,
76 \v!text,
77 \v!footer,\v!bottom]
78 [\v!leftedge,\v!leftmargin,
79 \v!text,
80 \v!rightmargin,\v!rightedge]
81 \or
82 \showframe
83 [\v!header,\v!text,\v!footer]
84 [#1]
85 \or
86 \setupbackgrounds
87 [\v!page]
88 [\c!frame=\v!on,
89 \c!corner=\v!rectangular,
90 \c!frameoffset=\zeropoint,
91 \c!framedepth=\zeropoint,
92 \c!framecolor=layout:page]
93 \setupbackgrounds
94 [#1][#2]
95 [\c!background=,
96 \c!frame=\v!on,
97 \c!corner=\v!rectangular,
98 \c!frameoffset=\zeropoint,
99 \c!framedepth=\zeropoint,
100 \c!framecolor=]
101 \fi
102 \setupbackgrounds
103 [\c!state=\v!repeat]}
104
105\permanent\protected\tolerant\gdef\showsetups[#1]
106 {\ctxcommand{showlayoutvariables("#1")}}
107
108\permanent\protected\tolerant\gdef\showlayout[#1]
109 {\ctxcommand{showlayout("#1")}}
110
111\permanent\protected\gdef\showmargins
112 {\starttabulate
113 \NC asynchrone \NC \doifelseoddpage {odd} {even} \NC \NR
114 \NC synchrone \NC \doifelserightpage {right} {left} \NC \NR
115 \NC right margin \NC \the\rightmarginwidth \NC \NR
116 \NC left margin \NC \the\leftmarginwidth \NC \NR
117 \NC outer margin \NC \the\outermarginwidth \NC \NR
118 \NC inner margin \NC \the\innermarginwidth \NC \NR
119 \stoptabulate}
120
121\permanent\protected\gdef\showcentering
122 {\setupbackgrounds
123 [\v!text]
124 [\c!background=centeringlines]}
125
126\defineoverlay
127 [centeringlines]
128 [\vpack to \d_overlay_height \bgroup
129 \vfill
130 \hpack to \d_overlay_width \bgroup
131 \hss
132 \hskip1cm
133 \dorecurse{15}{
134 \kern.25\onepoint
135 \ifodd\recurselevel
136 \darkred
137 \else
138 \darkblue
139 \fi
140 \vrule
141 height.5\d_overlay_height
142 depth .5\d_overlay_height
143 width .5\onepoint
144 \hskip1cm
145 }
146 \hss
147 \egroup
148 \vfill
149 \egroup]
150
151
152
153\newconstant\c_page_grids_location
154\newconstant\c_page_grids_line_mode
155\newconstant\c_page_grids_lineno_mode
156\newconstant\c_page_grids_columns_mode
157
158\permanent\protected\tolerant\gdef\showgrid[#1]
159 {\c_page_grids_location \plusone
160 \c_page_grids_line_mode \plusone
161 \c_page_grids_lineno_mode \plusone
162 \c_page_grids_columns_mode\plusone
163 \processallactionsinset
164 [#1]
165 [ \v!reset=>\c_page_grids_location \zerocount
166 \c_page_grids_columns_mode\zerocount,
167 \v!bottom=>\c_page_grids_location \plusone,
168 \v!top=>\c_page_grids_location \plustwo,
169 \v!none=>\c_page_grids_line_mode \zerocount,
170 \v!all=>\c_page_grids_line_mode \plusone,
171 \v!lines=>\c_page_grids_line_mode \plustwo,
172 \v!frame=>\c_page_grids_line_mode \plusthree,
173 \v!nonumber=>\c_page_grids_lineno_mode \zerocount,
174 \v!right=>\c_page_grids_lineno_mode \plusone,
175 \v!left=>\c_page_grids_lineno_mode \plustwo,
176 \v!outer=>\c_page_grids_lineno_mode \plusthree,
177 \v!inner=>\c_page_grids_lineno_mode \plusfour,
178 \v!columns=>\c_page_grids_columns_mode\plusone]
179 \ifcase\c_page_grids_location
180 \let\page_grids_add_to_box\gobbleoneargument
181 \else
182 \let\page_grids_add_to_box\page_grids_add_to_box_indeed
183 \fi
184 \ifcase\c_page_grids_columns_mode
185 \let\page_grids_add_to_one\gobbleoneargument
186 \let\page_grids_add_to_mix\gobbleoneargument
187 \else
188 \let\page_grids_add_to_one\page_grids_add_to_one_indeed
189 \let\page_grids_add_to_mix\page_grids_add_to_mix_indeed
190 \fi}
191
192
193
194\glet\page_grids_add_to_box\gobbleoneargument
195\glet\page_grids_add_to_one\gobbleoneargument
196\glet\page_grids_add_to_mix\gobbleoneargument
197
198\gdef\page_grids_add_to_box_indeed#1
199 {\startcolor[layout:grid]
200 \resetvisualizers
201 \gridboxlinemode \c_page_grids_line_mode
202 \gridboxlinenomode\c_page_grids_lineno_mode
203 \setgridbox\scratchbox\makeupwidth\textheight
204 \global\setbox#1\hpack\bgroup
205 \ifcase\c_page_grids_location\or\or\box#1\hskip\makeupwidth\fi
206 \begingroup
207 \ifcase\layoutcolumns\else
208 \setlayoutcomponentattribute{\v!grid:\v!columns}
209 \hpack \layoutcomponentboxattribute to \makeupwidth\bgroup
210 \gray
211 \dorecurse\layoutcolumns
212 {\hkern\layoutcolumnwidth
213 \ifnum\recurselevel<\layoutcolumns
214 \vrule
215 \s!height\ht\scratchbox
216 \s!depth \dp\scratchbox
217 \s!width \layoutcolumndistance
218 \fi}
219 \egroup
220 \hkern\makeupwidth
221 \fi
222 \ifnum\layoutrows>\plusone
223 \vpack to \textheight\bgroup
224 \gray
225 \forgetall
226 \resetvisualizers
227
228 \offinterlineskip
229 \hsize\makeupwidth
230 \topskipcorrection
231 \getrawnoflines\layoutrowdistance
232 \scratchheight\noflines\strutht
233 \scratchdepth\noflines\strutdp
234 \getrawnoflines\textheight
235 \scratchdimen\dimexpr\makeupwidth\lineheight\relax
236 \advanceby\layoutrows\plusone
237 \localcontrolledrepeat\noflines
238 {\hkern.5\lineheight\relax
239 \ifcase\numexpr\currentloopiterator;\layoutrows\relax
240 \vrule
241 \s!height\scratchheight
242 \s!depth \scratchdepth
243 \else
244 \novrule
245 \s!height\strutht
246 \s!depth \strutdp
247 \fi
248 \s!width\scratchdimen
249 \par}
250 \vfill
251 \egroup
252 \hkern\makeupwidth
253 \fi
254 \setlayoutcomponentattribute{\v!grid:\v!lines}
255 \hpack \layoutcomponentboxattribute{\box\scratchbox}
256 \endgroup
257 \ifcase\c_page_grids_location\or\hskip\makeupwidth\box#1\fi
258 \egroup
259 \stopcolor}
260
261\gdef\page_grids_add_to_one_indeed#1
262 {\begingroup
263 \resetvisualizers
264 \global\setbox#1\vpack{\noindent\backgroundline[layout:one]{\box#1}}
265 \endgroup}
266
267\gdef\page_grids_add_to_mix_indeed#1
268 {\begingroup
269 \resetvisualizers
270 \global\setbox#1\vpack{\noindent\backgroundline[layout:mix]{\box#1}}
271 \endgroup}
272
273\protect
274
275\continueifinputfile{slayoutshow.mkxl}
276
277\setupwhitespace[big]
278
279\setuphead[section][page=yes]
280
281\starttext
282
283\startsubject[title=\type{\showprint}]
284 \showprint
285\stopsubject
286
287\startsubject[title=\type{\showframe}]
288 \showframe
289\stopsubject
290
291\startsubject[title=\type{\showlayout}]
292 \showlayout
293\stopsubject
294
295\startsubject[title=\type{\showsetups}]
296 \showsetups
297\stopsubject
298
299\startsubject[title=\type{\showmargins}]
300 \showmargins
301\stopsubject
302
303\startsubject[title=\type{\showgrid}]
304 \showgrid
305\stopsubject
306
307\stoptext
308 |