s-layout-show.mkxl /size: 9548 b    last modification: 2023-12-21 09:45
1%D \module
2%D   [       file=page-run,
3%D        version=2000.10.20,
4%D          title=\CONTEXT\ Page Macros,
5%D       subtitle=Runtime Macros,
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 / Runtime Macros}
15
16\registerctxluafile{page-run}{} % maybe rename this one
17
18\unprotect
19
20\permanent\protected\tolerant\gdef\showprint[#1]#*[#2]#*[#3]% only english
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% \switchtobodyfont[8pt]
37%
38% \startcombination[4*4]
39%   {\showprint}                                      {\strut}
40%   {\showprint[][][location=middle]}                 {\type{location=middle}}
41%   {\showprint[][][location=middle,marking=on]}      {\type{markering=aan}\break\type{location=middle}}
42%   {\showprint[][][location=middle,marking=on,nx=2]} {\type{markering=aan}\break\type{location=middle}\break\type{nx=2}}
43%   {\showprint[][][location=left]}                   {\type{location=left}}
44%   {\showprint[][][location=right]}                  {\type{location=right}}
45%   {\showprint[][][location={left,bottom}]}          {\type{location={left,bottom}}}
46%   {\showprint[][][location={right,bottom}]}         {\type{location={right,bottom}}}
47%   {\showprint[][][nx=2,ny=1]}                       {\type{nx=2,ny=1}}
48%   {\showprint[][][nx=1,ny=2]}                       {\type{nx=1,ny=2}}
49%   {\showprint[][][nx=2,ny=2]}                       {\type{nx=2,ny=2}}
50%   {\showprint[][][nx=2,ny=2,location=middle]}       {\type{nx=2,ny=2}\break\type{location=middle}}
51%   {\showprint[][][backoffset=3pt]}                  {\type{rugoffset=.5cm}}
52%   {\showprint[][][topoffset=3pt]}                   {\type{kopoffset=.5cm}}
53%   {\showprint[][][scale=1.5]}                       {\type{schaal=1.5}}
54%   {\showprint[][][scale=0.8]}                       {\type{schaal=0.8}}
55% \stopcombination
56%
57% \startcombination[3*4]
58%   {\showprint[landscape][]         [location=middle]} {\type{landscape}}
59%   {\showprint[]         [landscape][location=middle]} {\strut\break\type{landscape}}
60%   {\showprint[landscape][landscape][location=middle]} {\type{landscape}\break\type{landscape}}
61%   {\showprint[90]       []         [location=middle]} {\type{90}}
62%   {\showprint[]         [90]       [location=middle]} {\strut\break\type{90}}
63%   {\showprint[90]       [90]       [location=middle]} {\type{90}\break\type{90}}
64%   {\showprint[180]      []         [location=middle]} {\type{180}}
65%   {\showprint[]         [180]      [location=middle]} {\strut\break\type{180}}
66%   {\showprint[180]      [180]      [location=middle]} {\type{180}\break\type{180}}
67%   {\showprint[mirrored] []         [location=middle]} {\type{mirrored}}
68%   {\showprint[]         [mirrored] [location=middle]} {\strut\break\type{mirrored}}
69%   {\showprint[mirrored] [mirrored] [location=middle]} {\type{mirrored}\break\type{mirrored}}
70% \stopcombination
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%D Page grids:
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 % downward compatible default
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]% new option
179   \ifcase\c_page_grids_location
180     \let\page_grids_add_to_box\gobbleoneargument
181   \else % 1=bottom 2=top
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% if really needed for speed we can cache the grid
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% to be checked for color and layer ..... use mp
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 % todo: check color
204   \global\setbox#1\hpack % global ?
205     {\ifcase\c_page_grids_location\or\or\box#1\hskip-\makeupwidth\fi
206      \begingroup % color
207      \ifcase\layoutcolumns\else
208        \gray
209        \setlayoutcomponentattribute{\v!grid:\v!columns}%
210        \hpack \layoutcomponentboxattribute to \makeupwidth
211          {\dorecurse\layoutcolumns
212             {\hskip\layoutcolumnwidth
213              \ifnum\recurselevel<\layoutcolumns
214                \vrule
215                  \s!height\ht\scratchbox
216                  \s!depth \dp\scratchbox
217                  \s!width \layoutcolumndistance
218              \fi}}%
219        \hskip-\makeupwidth
220      \fi
221      \setlayoutcomponentattribute{\v!grid:\v!lines}%
222      \hpack \layoutcomponentboxattribute{\box\scratchbox}%
223      \endgroup
224      \ifcase\c_page_grids_location\or\hskip-\makeupwidth\box#1\fi}%
225   \stopcolor}
226
227\gdef\page_grids_add_to_one_indeed#1%
228  {\begingroup
229   \resetvisualizers
230   \global\setbox#1\vpack{\noindent\backgroundline[layout:one]{\box#1}}%
231   \endgroup}
232
233\gdef\page_grids_add_to_mix_indeed#1%
234  {\begingroup
235   \resetvisualizers
236   \global\setbox#1\vpack{\noindent\backgroundline[layout:mix]{\box#1}}%
237   \endgroup}
238
239\protect
240
241\continueifinputfile{s-layout-show.mkxl}
242
243\setupwhitespace[big]
244
245\setuphead[section][page=yes]
246
247\starttext
248
249\startsubject[title=\type{\showprint}]
250    \showprint
251\stopsubject
252
253\startsubject[title=\type{\showframe}]
254    \showframe
255\stopsubject
256
257\startsubject[title=\type{\showlayout}]
258    \showlayout
259\stopsubject
260
261\startsubject[title=\type{\showsetups}]
262    \showsetups
263\stopsubject
264
265\startsubject[title=\type{\showmargins}]
266    \showmargins
267\stopsubject
268
269\startsubject[title=\type{\showgrid}]
270    \showgrid
271\stopsubject
272
273\stoptext
274