s-layout-show.mkxl /size: 8884 b    last modification: 2021-10-28 13:51
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
=
4
em
,
\c!height
=
6
em
]
24
\definepapersize
[
Y
]
[
\c!width
=
1
2
em
,
\c!height
=
1
4
em
]
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
%D Page grids:
122 123
\newconstant
\c_page_grids_location
124
\newconstant
\c_page_grids_line_mode
125
\newconstant
\c_page_grids_lineno_mode
126
\newconstant
\c_page_grids_columns_mode
127 128
\permanent
\protected
\tolerant
\gdef
\showgrid
[
#
1
]
%
129
{
\c_page_grids_location
\plusone
% downward compatible default
130
\c_page_grids_line_mode
\plusone
131
\c_page_grids_lineno_mode
\plusone
132
\c_page_grids_columns_mode
\plusone
133
\processallactionsinset
134
[
#
1
]
%
135
[
\v!reset
=
>
\c_page_grids_location
\zerocount
136
\c_page_grids_columns_mode
\zerocount
,
137
\v!bottom
=
>
\c_page_grids_location
\plusone
,
138
\v!top
=
>
\c_page_grids_location
\plustwo
,
139
\v!none
=
>
\c_page_grids_line_mode
\zerocount
,
140
\v!all
=
>
\c_page_grids_line_mode
\plusone
,
141
\v!lines
=
>
\c_page_grids_line_mode
\plustwo
,
142
\v!frame
=
>
\c_page_grids_line_mode
\plusthree
,
143
\v!nonumber
=
>
\c_page_grids_lineno_mode
\zerocount
,
144
\v!right
=
>
\c_page_grids_lineno_mode
\plusone
,
145
\v!left
=
>
\c_page_grids_lineno_mode
\plustwo
,
146
\v!outer
=
>
\c_page_grids_lineno_mode
\plusthree
,
147
\v!inner
=
>
\c_page_grids_lineno_mode
\plusfour
,
148
\v!columns
=
>
\c_page_grids_columns_mode
\plusone
]
% new option
149
\ifcase
\c_page_grids_location
150
\let
\page_grids_add_to_box
\gobbleoneargument
151
\else
% 1=bottom 2=top
152
\let
\page_grids_add_to_box
\page_grids_add_to_box_indeed
153
\fi
154
\ifcase
\c_page_grids_columns_mode
155
\let
\page_grids_add_to_one
\gobbleoneargument
156
\let
\page_grids_add_to_mix
\gobbleoneargument
157
\else
158
\let
\page_grids_add_to_one
\page_grids_add_to_one_indeed
159
\let
\page_grids_add_to_mix
\page_grids_add_to_mix_indeed
160
\fi
}
161 162
% if really needed for speed we can cache the grid
163 164
\glet
\page_grids_add_to_box
\gobbleoneargument
165
\glet
\page_grids_add_to_one
\gobbleoneargument
166
\glet
\page_grids_add_to_mix
\gobbleoneargument
167 168
\gdef
\page_grids_add_to_box_indeed
#
1
% to be checked for color and layer ..... use mp
169
{
\startcolor
[
layout
:
grid
]
%
170
\resetvisualizers
171
\gridboxlinemode
\c_page_grids_line_mode
172
\gridboxlinenomode
\c_page_grids_lineno_mode
173
\setgridbox
\scratchbox
\makeupwidth
\textheight
% todo: check color
174
\global
\setbox
#
1
\hpack
% global ?
175
{
\ifcase
\c_page_grids_location
\or
\or
\box
#
1
\hskip
-
\makeupwidth
\fi
176
\begingroup
% color
177
\ifcase
\layoutcolumns
\else
178
\gray
179
\setlayoutcomponentattribute
{
\v!grid
:
\v!columns
}
%
180
\hpack
\layoutcomponentboxattribute
to
\makeupwidth
181
{
\dorecurse
\layoutcolumns
182
{
\hskip
\layoutcolumnwidth
183
\ifnum
\recurselevel
<
\layoutcolumns
184
\vrule
185
\s!height
\ht
\scratchbox
186
\s!depth
\dp
\scratchbox
187
\s!width
\layoutcolumndistance
188
\fi
}
}
%
189
\hskip
-
\makeupwidth
190
\fi
191
\setlayoutcomponentattribute
{
\v!grid
:
\v!lines
}
%
192
\hpack
\layoutcomponentboxattribute
{
\box
\scratchbox
}
%
193
\endgroup
194
\ifcase
\c_page_grids_location
\or
\hskip
-
\makeupwidth
\box
#
1
\fi
}
%
195
\stopcolor
}
196 197
\gdef
\page_grids_add_to_one_indeed
#
1
%
198
{
\begingroup
199
\resetvisualizers
200
\global
\setbox
#
1
\vpack
{
\noindent
\backgroundline
[
layout
:
one
]
{
\box
#
1
}
}
%
201
\endgroup
}
202 203
\gdef
\page_grids_add_to_mix_indeed
#
1
%
204
{
\begingroup
205
\resetvisualizers
206
\global
\setbox
#
1
\vpack
{
\noindent
\backgroundline
[
layout
:
mix
]
{
\box
#
1
}
}
%
207
\endgroup
}
208 209
\protect
210 211
\continueifinputfile
{
s
-
layout
-
show
.
mkxl
}
212 213
\setupwhitespace
[
big
]
214 215
\setuphead
[
section
]
[
page
=
yes
]
216 217
\starttext
218 219
\startsubject
[
title
=
\type
{
\showprint
}
]
220
\showprint
221
\stopsubject
222 223
\startsubject
[
title
=
\type
{
\showframe
}
]
224
\showframe
225
\stopsubject
226 227
\startsubject
[
title
=
\type
{
\showlayout
}
]
228
\showlayout
229
\stopsubject
230 231
\startsubject
[
title
=
\type
{
\showsetups
}
]
232
\showsetups
233
\stopsubject
234 235
\startsubject
[
title
=
\type
{
\showmargins
}
]
236
\showmargins
237
\stopsubject
238 239
\startsubject
[
title
=
\type
{
\showgrid
}
]
240
\showgrid
241
\stopsubject
242 243
\stoptext
244