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