s-module-basic.mkiv /size: 8809 b    last modification: 2020-07-01 14:35
1
%D \module
2
%D [ file=s-mod-01,
3
%D version=very-old,
4
%D title=\CONTEXT\ Style File,
5
%D subtitle=Module Documentation,
6
%D author={Hans Hagen \& Luigi Scarso},
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
\unprotect
15 16
%D Usage:
17
%D
18
%D \starttyping
19
%D context --ctx=s-mod somefile.mkiv
20
%D \stoptyping
21
%D
22
%D In due time there will be a \type {mtx-context-module} as well.
23
%D
24
%D Luigi Scarso coordinates the processing of modules so best contact
25
%D him when you run into problems. Bugs in this style can be sent to
26
%D Hans.
27 28
\showframe
29 30
\usemodule
[
abbreviations
-
words
]
31 32
\startmodule
[
modules
-
basics
]
33 34
\setupdocument
35
[
file
=
\jobname
,
36
type
=
unknown
,
37
version
=
{
\currentdate
[
\v!year
,
{
.
}
,
\v!month
,
{
.
}
,
\v!day
]
}
,
38
system
=
\CONTEXT
,
39
title
=
Unknown
Title
,
40
subtitle
=
,
41
author
=
Unknown
Author
,
42
date
=
\currentdate
,
43
copyright
=
Unknown
Copyright
,
44
suggestions
=]
45 46
\let
\module
\setupdocument
47 48
\definepalet
[
module
:
unknown
]
[
localone
=
black
,
localtwo
=
white
]
49 50
\definepalet
[
module
:
tex
]
[
localone
=
blue
,
localtwo
=
green
]
51
\definepalet
[
module
:
mkii
]
[
localone
=
blue
,
localtwo
=
green
]
52
\definepalet
[
module
:
mkiv
]
[
localone
=
blue
,
localtwo
=
green
]
53
\definepalet
[
module
:
mkvi
]
[
localone
=
blue
,
localtwo
=
green
]
54 55
\definepalet
[
module
:
lua
]
[
localone
=
red
,
localtwo
=
green
]
56
\definepalet
[
module
:
cld
]
[
localone
=
red
,
localtwo
=
green
]
57 58
\definepalet
[
module
:
mp
]
[
localone
=
red
,
localtwo
=
blue
]
59
\definepalet
[
module
:
mpii
]
[
localone
=
red
,
localtwo
=
blue
]
60
\definepalet
[
module
:
mpiv
]
[
localone
=
red
,
localtwo
=
blue
]
61
\definepalet
[
module
:
metapost
][
localone
=
red
,
localtwo
=
blue
]
62 63
\setuppalet
64
[
module
:
unknown
]
65 66
\startuseMPgraphic
{
page
}
67 68
StartPage
;
69 70
color
local_white
;
local_white
:
=
.8
white
;
71
color
local_one
;
local_one
:
=
\MPcolor
{
localone
}
randomized
(
.6
,
.8
)
;
72
color
local_two
;
local_two
:
=
\MPcolor
{
localtwo
}
randomized
(
.3
,
.4
)
;
73 74
color
local_one
;
local_one
:
=
.75
[
\MPcolor
{
localone
}
,
white
]
;
75
color
local_two
;
local_two
:
=
.75
[
\MPcolor
{
localtwo
}
,
white
]
;
76 77
numeric
width
;
width
:
=
bbwidth
Page
;
78
numeric
height
;
height
:
=
bbheight
Page
;
79 80
u
:
=
width
/
400
;
81 82
def
a_module
(
expr
dx
,
dy
)
=
83
picture
p
;
p
:
=
image
(
84
ddy
:
=
0
;
sx
:
=
60
u
;
85
for
i
=
1
upto
(
4
randomized
2
)
:
86
sy
:
=
7
u
randomized
3
u
;
87
fill
unitsquare
xyscaled
(
sx
,
sy
)
shifted
(
0
,
ddy
)
withcolor
local_two
;
88
ddy
:
=
ddy
+
sy
+
4
u
;
89
endfor
;
90
)
;
91
p
:
=
p
shifted
(
dx
,
dy
)
shifted
-
center
p
;
92
fill
boundingbox
p
enlarged
8
u
withcolor
local_white
;
93
fill
boundingbox
p
enlarged
4
u
withcolor
local_one
;
94
draw
p
;
95
enddef
;
96 97
set_grid
(
width
,
height
,
width
/
15
,
height
/
15
)
;
98 99
forever
:
100
if
new_on_grid
(
uniformdeviate
width
,
uniformdeviate
height
)
:
101
a_module
(
dx
,
dy
)
;
102
fi
;
103
exitif
grid_full
;
104
endfor
;
105 106
picture
p
;
107 108
draw
image
(
109
draw
anchored
.
urt
(
textext
(
"
\bf\strut\documentvariable{system}
"
)
ysized
5.0
cm
,
urcorner
Page
shifted
(
-1
cm
,
-
1
cm
)
)
;
110
draw
anchored
.
urt
(
textext
(
"
\bf\strut\documentvariable{title}
"
)
ysized
1.5
cm
,
urcorner
Page
shifted
(
-1
cm
,
-
8
cm
)
)
;
111
draw
anchored
.
urt
(
textext
(
"
\bf\strut\documentvariable{subtitle}
"
)
ysized
1.5
cm
,
urcorner
Page
shifted
(
-1
cm
,
-10
cm
)
)
;
112
draw
anchored
.
urt
(
textext
(
"
\bf\strut\documentvariable{author}
"
)
ysized
1.5
cm
,
lrcorner
Page
shifted
(
-1
cm
,
5
cm
)
)
;
113
draw
anchored
.
urt
(
textext
(
"
\bf\strut\currentdate
"
)
ysized
1.5
cm
,
lrcorner
Page
shifted
(
-1
cm
,
3
cm
)
)
;
114
)
withcolor
.25
white
;
115 116
StopPage
;
117 118
\stopuseMPgraphic
119 120
\startsetups
[
document
:
start
]
121 122
\setuppalet
123
[
module
:
\documentvariable
{
type
}
]
124 125
\setuptyping
126
[
definition
]
127
[
lines
=
yes
,
128
option
=
\documentvariable
{
type
}
]
129 130
\startTEXpage
131
\useMPgraphic
{
page
}
132
\stopTEXpage
133 134
\page
[
right
]
135 136
\stopsetups
137 138
\startsetups
[
document
:
stop
]
139 140
\page
141 142
\placeregister
143
[
\v!index
]
144
[
\c!balance
=
\v!yes
,
145
\c!indicator
=
\v!no
,
146
\c!criterium
=
\v!text
]
147 148
\stopsetups
149 150
% In order to be able to typeset this one too, we need to avoid
151
% direct backslashed names.
152 153
\starttexdefinition
startmoduledocumentation
154
\starttext
155
\page
156
\begingroup
157
\startdocument
158
\stoptexdefinition
159 160
\starttexdefinition
stopmoduledocumentation
161
\stopdocument
162
\page
163
\endgroup
164
\stoptext
165
\stoptexdefinition
166 167
\starttexdefinition
startdocumentation
168
\par
169
\bgroup
170
\stoptexdefinition
171 172
\starttexdefinition
stopdocumentation
173
\par
174
\egroup
175
\stoptexdefinition
176 177
\definetyping
178
[
definition
]
179 180
\starttexdefinition
startcompressdefinitions
181
\blank
182
\begingroup
183
\setuptyping
[
definition
][
bodyfont
=
small
]
184
\stoptexdefinition
185 186
\starttexdefinition
stopcompressdefinitions
187
\blank
188
\endgroup
189
\stoptexdefinition
190 191
% \definetyping [PL] [\c!option=PL]
192
% \definetyping [JV] [\c!option=JV]
193
% \definetyping [MP] [\c!option=MP]
194
% \definetyping [TEX] [\c!option=TEX]
195
% \definetyping [LUA] [\c!option=LUA]
196 197
\setuptyping
198
[
\v!typing
]
199
[
\c!margin
=
\v!standard
,
200
\c!lines
=
\v!yes
]
201 202
\setuptyping
203
[
\v!file
]
204
[
\c!margin
=
\v!standard
,
205
\c!lines
=
\v!yes
]
206 207
\setuptyping
208
[
definition
]
209
[
\c!margin
=
0
pt
,
210
\c!numbering
=
\v!line
,
211
\c!continue
=
\v!yes
,
212
\c!lines
=
\v!yes
]
213 214
\setuplinenumbering
215
[
definition
]
216
[
\c!style
=
\ttx
,
217
\c!align
=
\v!flushright
]
218 219
% This will be cleaned up.
220 221
\unexpanded
\def
\domodulemarginstuff
#
1
#
2
%
222
{
\marginstuff
223
{
\ifx
#
1
\relax
224
\index
{
#
2
}
%
225
\else
226
\index
{
#
1
{
#
2
}}
%
227
\fi
228
\dontleavehmode
#
1
{
\doboundtext
{
#
2
}{
\leftmarginwidth
}{
.
.
}}}}
229 230
\unexpanded
\def
\modulemarginstuff
#
1
#
2
% to be renamed
231
{
\processcommalist
[#
2
]
{
\domodulemarginstuff
#
1
}}
232 233
\definemargindata
234
[
marginstuff
]
235
[
left
]
236
[
stack
=
yes
,
237
hoffset
=
2
em
,
238
style
=
\ttxx
\setstrut
]
239 240
\unexpanded
\def
\macros
{
\modulemarginstuff
\tex
}
241
\unexpanded
\def
\extras
{
\modulemarginstuff
\relax
}
242
\unexpanded
\def
\elements
{
\modulemarginstuff
\someelement
}
243 244
\unexpanded
\def
\someelement
#
1
{
\type
{
<#
1
>
}}
245 246
% [index]{command}
247 248
% \macros{a,b}
249
% \macros{a,b}{b}
250
% \macros[a]{a,b}{b}
251 252
% weg ermee (indeed):
253
%
254
% \defineparagraphs [interface] [\c!n=2]
255
% \setupparagraphs [interface] [1] [\c!width=4cm]
256 257
\starttexdefinition
startexample
258
\par
259
\startnarrower
260
\stoptexdefinition
261 262
\starttexdefinition
stopexample
263
\stopnarrower
264
\stoptexdefinition
265 266
%D Command references:
267 268
\usemodule
[
int
-
load
]
\loadsetups
269 270
\let
\showsetup
\setup
271 272
\setupframedtexts
273
[
setuptext
]
274
[
\c!background
=
\v!screen
,
275
\c!frame
=
\v!off
]
276 277
% style (we use dejavu as it supports more characters)
278 279
\usebodyfont
280
[
dejavu
-
condensed
,
9
pt
]
% preload
281 282
\setupbodyfont
283
[
dejavu
,
9
pt
]
% main font
284 285
\mainlanguage
286
[
en
]
287 288
\setuptyping
289
[
\v!typing
]
290
[
\c!bodyfont
=
dejavu
-
condensed
]
291 292
\setupwhitespace
293
[
\v!big
]
294 295
\setuptolerance
296
[
\v!verytolerant
,
\v!stretch
]
297 298
\setuplayout
299
[
\c!backspace
=
3
.
5
cm
,
300
\c!cutspace
=
2
cm
,
301
\c!leftmargin
=
1
.
7
5
cm
,
302
\c!rightmargin
=
0
cm
,
303
\c!margindistance
=
.
5
cm
,
304
\c!leftedgedistance
=
.
2
5
cm
,
305
\c!rightedgedistance
=
.
5
cm
,
306
\c!edge
=
1
.
5
cm
,
307
\c!width
=
middle
,
308
\c!topspace
=
2
cm
,
309
\c!header
=
1
.
2
5
cm
,
310
\c!footer
=
1
.
2
5
cm
,
311
\c!height
=
middle
,
312
\c!style
=
\ss
]
313 314
\setuppagenumbering
315
[
\c!location
=]
316 317
\setuppagenumbering
318
[
\c!alternative
=
{
\v!doublesided
,
\v!singlesided
}
]
319 320
\setupfootertexts
321
[
\v!edge
]
322
[][
\pagenumber
]
323 324
\setupfootertexts
325
[
\v!margin
]
326
[
\filename
{
\documentvariable
{
file
}}
][]
327
[
\filename
{
\documentvariable
{
file
}}
][]
328 329
\setupfootertexts
330
[
\v!text
]
331
[
\CONTEXT
]
332
[
\documentvariable
{
title
}
]
333 334
\setupheadertexts
335
[
\v!text
]
336
[]
337
[
\documentvariable
{
subtitle
}
]
338 339
\setupinmargin
340
[
\c!location
=
\v!left
]
341 342
\setupheads
343
[
\c!alternative
=
\v!inmargin
]
344 345
\setuphead
346
[
\v!chapter
]
347
[
\c!style
=
\bfc
,
348
\c!page
=
\v!right
,
349
\c!header
=
\v!empty
]
350 351
\setuphead
352
[
\v!section
]
353
[
\c!style
=
\bfb
,
354
\c!page
=
\v!right
]
355 356
\setuphead
357
[
\v!subsection
]
358
[
\c!style
=
\bfa
]
359 360
\setuplist
361
[
\v!chapter
]
362
[
\c!style
=
\v!bold
,
363
\c!after
=
\blank
]
364 365
\setupcombinedlist
366
[
\v!content
]
367
[
\c!width
=
3
em
,
368
\c!aligntitle
=
\v!yes
]
369 370
\setupregister
371
[
\v!index
]
372
[
\c!balance
=
\v!yes
,
373
\c!indicator
=
\v!no
]
374 375
\setupinteraction
376
[
\c!state
=
\v!start
,
377
\c!color
=
,
378
\c!contrastcolor
=
,
379
\c!style
=]
380 381
% modes
382 383
\doifmode
{
nocolor
}
{
384 385
\setupcolors
386
[
\c!conversion
=
\v!always
]
387 388
}
389 390
\doifmode
{
singlesided
}
{
391 392
\setuppagenumbering
393
[
\c!alternative
=
\v!singlesided
]
394 395
\setupfootertexts
396
[
\v!margin
]
397
[
\filename
{
\documentvariable
{
file
}}
][]
398 399
}
400 401
\protect
402 403
\stopmodule
404