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\unexpanded\gdef\showprint{\dotripleempty\page_layouts_show_print}
21
22\gdef\page_layouts_show_print[#1][#2][#3]
23 {\setbuffer[crap]
24 \unprotect
25 \definepapersize[X][\c!width=4em, \c!height=6em]
26 \definepapersize[Y][\c!width=12em,\c!height=14em]
27 \setuppapersize[X,#1][Y,#2]
28 \setuplayout[#3]
29 \setuplayout[\v!page]
30 \framed
31 [\c!offset=\v!overlay,\c!strut=\v!no,
32 \c!width=\paperwidth,\c!height=\paperheight]
33 {\ss ABC\par DEF}
34 \protect
35 \endbuffer
36 \framed[\c!offset=\v!overlay,\c!strut=\v!no]{\typesetbuffer[crap]}}
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
73
74\unexpanded\gdef\showframe {\dodoubleempty\page_layouts_show_frame}
75\unexpanded\gdef\showsetups{\dosingleempty\page_layouts_show_setups}
76\unexpanded\gdef\showlayout{\dosingleempty\page_layouts_show_layout}
77
78\gdef\page_layouts_show_frame[#1][#2]
79 {\ifsecondargument
80 \setupbackgrounds
81 [\v!page]
82 [\c!frame=\v!on,
83 \c!corner=\v!rectangular,
84 \c!frameoffset=\zeropoint,
85 \c!framedepth=\zeropoint,
86 \c!framecolor=layout:page]
87 \setupbackgrounds
88 [#1][#2]
89 [\c!background=,
90 \c!frame=\v!on,
91 \c!corner=\v!rectangular,
92 \c!frameoffset=\zeropoint,
93 \c!framedepth=\zeropoint,
94 \c!framecolor=]
95 \else\iffirstargument
96 \showframe
97 [\v!header,\v!text,\v!footer]
98 [#1]
99 \else
100 \showframe
101 [\v!top,\v!header,
102 \v!text,
103 \v!footer,\v!bottom]
104 [\v!leftedge,\v!leftmargin,
105 \v!text,
106 \v!rightmargin,\v!rightedge]
107 \fi\fi
108 \setupbackgrounds
109 [\c!state=\v!repeat]}
110
111\gdef\page_layouts_show_setups[#1]
112 {\ctxcommand{showlayoutvariables("#1")}}
113
114\gdef\page_layouts_show_layout[#1]
115 {\ctxcommand{showlayout("#1")}}
116
117\unexpanded\gdef\showmargins
118 {\starttabulate
119 \NC asynchrone \NC \doifelseoddpage {odd} {even} \NC \NR
120 \NC synchrone \NC \doifelserightpage {right} {left} \NC \NR
121 \NC right margin \NC \the\rightmarginwidth \NC \NR
122 \NC left margin \NC \the\leftmarginwidth \NC \NR
123 \NC outer margin \NC \the\outermarginwidth \NC \NR
124 \NC inner margin \NC \the\innermarginwidth \NC \NR
125 \stoptabulate}
126
127
128
129\newconstant\c_page_grids_location
130\newconstant\c_page_grids_line_mode
131\newconstant\c_page_grids_lineno_mode
132\newconstant\c_page_grids_columns_mode
133
134\unexpanded\gdef\showgrid
135 {\dosingleempty\page_grids_show}
136
137\gdef\page_grids_show[#1]
138 {\c_page_grids_location \plusone
139 \c_page_grids_line_mode \plusone
140 \c_page_grids_lineno_mode \plusone
141 \c_page_grids_columns_mode\plusone
142 \processallactionsinset
143 [#1]
144 [ \v!reset=>\c_page_grids_location \zerocount
145 \c_page_grids_columns_mode\zerocount,
146 \v!bottom=>\c_page_grids_location \plusone,
147 \v!top=>\c_page_grids_location \plustwo,
148 \v!none=>\c_page_grids_line_mode \zerocount,
149 \v!all=>\c_page_grids_line_mode \plusone,
150 \v!lines=>\c_page_grids_line_mode \plustwo,
151 \v!frame=>\c_page_grids_line_mode \plusthree,
152 \v!nonumber=>\c_page_grids_lineno_mode \zerocount,
153 \v!right=>\c_page_grids_lineno_mode \plusone,
154 \v!left=>\c_page_grids_lineno_mode \plustwo,
155 \v!outer=>\c_page_grids_lineno_mode \plusthree,
156 \v!inner=>\c_page_grids_lineno_mode \plusfour,
157 \v!columns=>\c_page_grids_columns_mode\plusone]
158 \ifcase\c_page_grids_location
159 \let\page_grids_add_to_box\gobbleoneargument
160 \else
161 \let\page_grids_add_to_box\page_grids_add_to_box_indeed
162 \fi
163 \ifcase\c_page_grids_columns_mode
164 \let\page_grids_add_to_one\gobbleoneargument
165 \let\page_grids_add_to_mix\gobbleoneargument
166 \else
167 \let\page_grids_add_to_one\page_grids_add_to_one_indeed
168 \let\page_grids_add_to_mix\page_grids_add_to_mix_indeed
169 \fi}
170
171
172
173\glet\page_grids_add_to_box\gobbleoneargument
174\glet\page_grids_add_to_one\gobbleoneargument
175\glet\page_grids_add_to_mix\gobbleoneargument
176
177\gdef\page_grids_add_to_box_indeed#1
178 {\startcolor[layout:grid]
179 \resetvisualizers
180 \gridboxlinemode \c_page_grids_line_mode
181 \gridboxlinenomode\c_page_grids_lineno_mode
182 \setgridbox\scratchbox\makeupwidth\textheight
183 \global\setbox#1\hpack
184 {\ifcase\c_page_grids_location\or\or\box#1\hskip\makeupwidth\fi
185 \begingroup
186 \ifcase\layoutcolumns\else
187 \gray
188 \setlayoutcomponentattribute{\v!grid:\v!columns}
189 \hpack \layoutcomponentboxattribute to \makeupwidth
190 {\dorecurse\layoutcolumns
191 {\hskip\layoutcolumnwidth
192 \ifnum\recurselevel<\layoutcolumns
193 \vrule
194 \s!height\ht\scratchbox
195 \s!depth \dp\scratchbox
196 \s!width \layoutcolumndistance
197 \fi}}
198 \hskip\makeupwidth
199 \fi
200 \setlayoutcomponentattribute{\v!grid:\v!lines}
201 \hpack \layoutcomponentboxattribute{\box\scratchbox}
202 \endgroup
203 \ifcase\c_page_grids_location\or\hskip\makeupwidth\box#1\fi}
204 \stopcolor}
205
206\gdef\page_grids_add_to_one_indeed#1
207 {\begingroup
208 \resetvisualizers
209 \global\setbox#1\vpack{\noindent\backgroundline[layout:one]{\box#1}}
210 \endgroup}
211
212\gdef\page_grids_add_to_mix_indeed#1
213 {\begingroup
214 \resetvisualizers
215 \global\setbox#1\vpack{\noindent\backgroundline[layout:mix]{\box#1}}
216 \endgroup}
217
218\protect \endinput
219 |