summaryrefslogtreecommitdiff
path: root/tex/context/base/symb-ini.tex
blob: 3cbfe09cc496f3df8ff702fdbe647dece33506b7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
%D \module
%D   [       file=symb-ini,
%D        version=1998.07.20,
%D          title=\CONTEXT\ Symbol Libraries,
%D       subtitle=Basic Symbols Commands,
%D         author=Hans Hagen,
%D           date=\currentdate,
%D      copyright={PRAGMA / Hans Hagen \& Ton Otten}]
%C
%C This module is part of the \CONTEXT\ macro||package and is
%C therefore copyrighted by \PRAGMA. See mreadme.pdf for 
%C details. 

%D The macros described here used to be part of the \type
%D {core-con} module. I decided to move them here when 
%D symbolsets saw the light. Let their light shine.  

\writestatus{loading}{Context Symbol Libraries / Initialization}

\unprotect

% TOBIAS 

\startmessages  dutch  library: symbols
  title: symbolen
      1: symboolset -- wordt geladen
\stopmessages

\startmessages  english  library: symbols
  title: symbols
      1: loading symbolset --
\stopmessages

\startmessages  german  library: symbols
  title: Symbole
      1: Lade Symboldatei --    
\stopmessages

\startmessages  czech  library: symbols
  title: symboly
      1: nacita se soubor symbolu --    
\stopmessages

\startmessages  italian  library: symbols
  title: simboli
      1: caricamento gruppo di simboli --
\stopmessages

\startmessages  norwegian  library: symbols
  title: symboler
      1: leser inn symbolsett --
\stopmessages

\startmessages  romanian  library: symbols
  title: simboluri
      1: se incarca setul de simboluri --
\stopmessages

%D \macros
%D   {definesymbol, symbol}
%D 
%D Converting numbers or levels into a character, romannumeral,
%D symbol or something else, is supported by many \CONTEXT\
%D commands. Therefore we need a mechanism for linking such
%D numbers to their counterparts. 
%D 
%D First we take care of symbols. These are for instance used
%D in enumerations and itemizations. We have: 
%D 
%D \showsetup{\y!definesymbol} 
%D \showsetup{\y!symbol} 
%D 
%D Symbols are simply linked to a tag. Such tags can be numbers
%D or strings. 
%D 
%D \starttypen
%D \definesymbol [1]       [$\bullet$]
%D \definesymbol [level 5] [$\star$]
%D \stoptypen

% ss:tag     -> symbol 
% ss:set:tag -> symbol out of set 
% sstag      -> list of symbols in set  

% \def\dodefinesymbol[#1][#2]%
%   {\ifx\currentsymboldef\empty
%      \setvalue{\??ss:#1}{#2}%
%    \else
%      \doifundefinedelse{\??ss\currentsymboldef}
%        {\let\currentsymbollist\empty}
%        {\edef\currentsymbollist{\csname\??ss\currentsymboldef\endcsname}}%
%      \addtocommalist{#1}\currentsymbollist
%      \setvalue{\??ss:\currentsymboldef:#1}{#2}%
%      \letvalue{\??ss\currentsymboldef}\currentsymbollist
%    \fi}

\def\dodefinesymbol[#1][#2]%
  {\ifx\currentsymboldef\empty
     \setvalue{\??ss:#1}{#2}%
   \else
     \setvalue{\??ss:\currentsymboldef:#1}{#2}%
     \addvalue{\??ss\currentsymboldef}{#1}%
   \fi}

\def\definesymbol
  {\dodoubleargument\dodefinesymbol}

\unexpanded\def\symbol%      % This one always gobbles spaces, 
  {\dodoubleempty\dosymbol}  % so never change it again!

%D Since symbols are used frequently in interactive 
%D documents, we speed up this one.  

\newif\ifnosymbol \newtoks\everysymbol

\def\dodosymbol#1% \relax's prevent lookahead problems 
  {\nosymbolfalse{\the\everysymbol\csname\??ss:#1\endcsname\relax}\relax}

\beginTEX 

\def\dosymbol[#1][#2]%
  {\nosymboltrue 
   \ifsecondargument \@EA\ifx\csname\??ss:#1:#2\endcsname\relax\else
     \dodosymbol{#1:#2}%
   \fi \fi 
   \ifnosymbol
     \edef\currentsymbol{#1}%
     \the\symbolsetups
     \ifnosymbol 
       \redosymbol\currentsymbol
     \fi
   \fi}

\def\fetchsymbol#1%
  {\ifnosymbol % will be a \cs anyway, so no test needed 
     %\@EA\ifx\csname\??ss:#1:\currentsymbol\endcsname\relax\else
       \dodosymbol{#1:\currentsymbol}%
     %\fi 
   \fi}

\def\redosymbol#1%
  {\@EA\ifx\csname\??ss:#1\endcsname\relax\else\@EA\dodosymbol\fi{#1}}

\endTEX

\beginETEX \ifcsname

\def\dosymbol[#1][#2]%
  {\nosymboltrue 
   \ifsecondargument \ifcsname\??ss:#1:#2\endcsname
     \dodosymbol{#1:#2}%
   \fi \fi 
   \ifnosymbol
     \edef\currentsymbol{#1}%
     \the\symbolsetups
     \ifnosymbol 
       \redosymbol\currentsymbol
     \fi
   \fi}

\def\fetchsymbol#1%
  {\ifnosymbol 
     \ifcsname\??ss:#1:\currentsymbol\endcsname
       \dodosymbol{#1:\currentsymbol}%
     \fi 
   \fi}

\def\redosymbol#1%
  {\ifcsname\??ss:#1\endcsname\@EA\dodosymbol\else\fi{#1}}

\endETEX

% % % % %
% this should go in symb-fig, to be loaded after core-fig

%D \macros
%D   {definefiguresymbol}
%D
%D To simplify defining figure symbols, we offer:
%D
%D \showsetup{\y!definefiguresymbol} 
%D
%D By default, such symbols scale along the current bodyfont
%D size or running font size (which is better). 

\def\defaultsymbolfactor{10}
\def\defaultsymbolheight{1.25ex}

\def\dohandlefiguresymbol#1#2% 
  {\externalfigure
     [#1]
     [\c!reset=\v!ja,
      \c!symbool=\v!ja,
      \c!hoogte=\defaultsymbolheight,
      %\c!hfactor=\defaultsymbolfactor,
      #2]}

\appendtoks \resetexternalfigures \to \everysymbol

\def\definefiguresymbol%
  {\dotripleempty\dodefinefiguresymbol}

\def\dodefinefiguresymbol[#1][#2][#3]%
  {\ifsecondargument
     \definesymbol[#1][\dohandlefiguresymbol{#2}{#3}]%
   \fi}

% but for the moment we keep it here
% % % % % % 

%\def\objectsymbol[#1]%
%  {\dopresetfieldsymbol{#1}\dogetfieldsymbol{#1}}

%D \macros
%D   {doifsymboldefinedelse}
%D
%D A handy private one: 

\beginTEX

\def\xfetchsymbol#1%
  {\ifnosymbol % will be a \cs anyway, so no test needed 
     %\@EA\ifx\csname\??ss:#1:\currentsymbol\endcsname\relax\else
       \nosymbolfalse
     %\fi 
   \fi}

\def\xredosymbol#1%
  {\@EA\ifx\csname\??ss:#1\endcsname\relax\else\nosymbolfalse\fi}

\endTEX

\beginETEX

\def\xfetchsymbol#1%
  {\ifnosymbol 
     \ifcsname\??ss:#1:\currentsymbol\endcsname\nosymbolfalse\fi 
   \fi}

\def\xredosymbol#1%
  {\ifcsname\??ss:#1\endcsname\nosymbolfalse\fi}

\endETEX

\def\doifsymboldefinedelse#1%
  {\bgroup
   \edef\currentsymbol{#1}%
   \let\fetchsymbol\xfetchsymbol
  %\let\redosymbol \xredosymbol
   \nosymboltrue 
   \the\symbolsetups
   \ifnosymbol 
    %\redosymbol\currentsymbol 
     \xredosymbol\currentsymbol 
     \ifnosymbol
       \egroup\@EAEAEA\secondoftwoarguments
     \else
       \egroup\@EAEAEA\firstoftwoarguments
     \fi
   \else
     \egroup\@EA\firstoftwoarguments
   \fi}

%D \macros
%D   {setupsymbolset,startsymbolset}
%D 
%D From these macro definitions one can deduce that symbols can
%D be grouped in symbol sets: 
%D 
%D \starttypen
%D \startsymbolset [navigation 1]
%D   \definefiguresymbol [Next] [mp-symb.1] 
%D   \definefiguresymbol [Prev] [mp-symb.2]
%D \stopsymbolset
%D \stoptypen
%D 
%D Such a symbol can be typeset with:
%D 
%D \starttypen
%D \setupsymbolset[navigation 1]\symbol[Next]
%D \stoptypen
%D 
%D or simply:
%D 
%D \starttypen
%D \symbol[navigation 1][Next]
%D \stoptypen
%D 
%D Formally:
%D 
%D \showsetup{\y!setupsymbolset} 
%D \showsetup{\y!startsymbolset} 

\let\currentsymboldef\empty

\def\startsymbolset[#1]
  {\def\currentsymboldef{#1}}

\def\stopsymbolset
  {\let\currentsymboldef\empty}

\newtoks\symbolsetups

\def\setupsymbolset[#1]%
  {\prependtoksonce\fetchsymbol{#1}\to\symbolsetups}

\def\resetsymbolset
  {\symbolsetups\emptytoks}

\def\forcesymbolset[#1]%
  {\symbolsetups{\fetchsymbol{#1}}}

%D \macros
%D   {showsymbolset}
%D
%D \showsetup{\y!showsymbolset} 

\fetchruntimecommand \showsymbolset {\f!symbolprefix\s!run}

%D \macros 
%D   {usesymbols}
%D
%D \showsetup{\y!usesymbols}

\def\dousesymbols#1%
  {\makeshortfilename[\f!symbolprefix#1]%
   \showmessage{\m!symbols}{1}{#1}%
   \startreadingfile
   \readsysfile{\shortfilename}{}{}%
   \stopreadingfile}

\def\usesymbols[#1]%
  {\processcommalist[#1]\dousesymbols}

%D As longs as symbols are linked to levels or numbers, we can 
%D also use the conversion mechanism, but in for instance the 
%D itemization macros, we prefer symbols because they can more 
%D easier be (partially) redefined. 

%D We predefine some common symbols and conversions that will
%D be understood by many commands. 

\definesymbol [\v!geen]   []
\definesymbol [bullet]    [\mathematics{\bullet}]
\definesymbol [dash]      [\mathematics{-}]
\definesymbol [star]      [\mathematics{\star}]
\definesymbol [triangle]  [\mathematics{\triangleright}]
\definesymbol [circle]    [\mathematics{\circ}]
\definesymbol [medcircle] [\hbox{\setsmallbodyfont\raise\!!onepoint\hbox{$\bigcirc$}}]
\definesymbol [bigcircle] [\mathematics{\bigcirc}]
\definesymbol [square]    [\mathematics{\square}]
\definesymbol [diamond]   [\mathematics{\diamond}]

\definesymbol [1] [{\symbol[bullet]}]
\definesymbol [2] [{\symbol[dash]}]
\definesymbol [3] [{\symbol[star]}]
\definesymbol [4] [{\symbol[triangle]}]
\definesymbol [5] [{\symbol[circle]}]
\definesymbol [6] [{\symbol[medcircle]}]
\definesymbol [7] [{\symbol[bigcircle]}]
\definesymbol [8] [{\symbol[square]}]

%D Special hyperlinks, namely those to pages or navigational 
%D properties, are associated with symbols. 

\definesymbol [\v!eerstepagina]      [\gotobegincharacter]
\definesymbol [\v!vorigepagina]      [\gobackwardcharacter]
\definesymbol [\v!volgendepagina]    [\goforwardcharacter]
\definesymbol [\v!laatstepagina]     [\gotoendcharacter]
\definesymbol [\v!eerstesubpagina]   [\gotobegincharacter]
\definesymbol [\v!vorigesubpagina]   [\gobackwardcharacter]
\definesymbol [\v!volgendesubpagina] [\goforwardcharacter]
\definesymbol [\v!laatstesubpagina]  [\gotoendcharacter]
\definesymbol [\v!PreviousJump]      [\gobackjumpcharacter]
\definesymbol [\v!NextJump]          [\goforjumpcharacter]
\definesymbol [\v!CloseDocument]     [\closecharacter]

\definesymbol [\v!eerste]   [{\symbol[\v!eerstepagina]}]
\definesymbol [\v!vorige]   [{\symbol[\v!vorigepagina]}]
\definesymbol [\v!volgende] [{\symbol[\v!volgendepagina]}]
\definesymbol [\v!laatste]  [{\symbol[\v!laatstepagina]}]
\definesymbol [\v!ergens]   [\gotosomewherecharacter]
\definesymbol [\v!nergens]  [\gonowherecharacter]

\definesymbol [\v!achteruit] [{\symbol[\v!vorigepagina]}]
\definesymbol [\v!vooruit]   [{\symbol[\v!volgendepagina]}]

%D The next two symbols (\symbol[P] and \symbol[S]) are 
%D variations in their math counterparts. The following ones 
%D {\em do} scale. 

\definesymbol[S][\getglyph{MathSymbol}{\char"78}]
\definesymbol[P][\getglyph{MathSymbol}{\char"7B}]

%D These symbols are taken from the Computer Moders Roman
%D symbol set or, when present, from the additional symbols of
%D the American Mathematical Society. Of course one can use 
%D his or her own symbols by redefining them. 

\def\dogotocharacter#1#2#3%
  {\ifx#1\undefined#2\else#3\fi}

\def\gotobegincharacter%
  {\hbox
     {\dogotocharacter\blacktriangleleft
        {\setbox0=\hbox{\mathematics{\triangleleft}}%
         \vrule\!!width.085ex\!!height1.075\ht0\!!depth\dp0
         \kern-.11ex\box0} 
        {\setbox0=\hbox{\mathematics{\blacktriangleleft}}%
         \setbox2=\hbox{\vrule\!!height\ht0\!!depth\dp0\!!width.25ex}%
         \hbox{\lower.03ex\box2\kern-.35ex\box0}}}}

\def\gotoendcharacter%
  {\hbox
     {\dogotocharacter\blacktriangleright
        {\setbox0=\hbox{\mathematics{\triangleright}}%
         \copy0\kern-.11ex 
         \vrule\!!width.085ex\!!height1.075\ht0\!!depth\dp0}  
        {\setbox0=\hbox{\mathematics{\blacktriangleright}}%
         \setbox2=\hbox{\vrule\!!height\ht0\!!depth\dp0\!!width.25ex}%
         \hbox{\box0\kern-.35ex\lower.03ex\box2}}}}

\def\gobackwardcharacter%
  {\mathematics{\dogotocharacter\blacktriangleright\triangleleft\blacktriangleleft}}

\def\goforwardcharacter%
  {\mathematics{\dogotocharacter\blacktriangleright\triangleright\blacktriangleright}}

\def\gonowherecharacter%
  {\mathematics{\bullet}}

%\def\gotosomewherecharacter% {} permits ^\...
%  {{\hbox{\hsmash{\gobackwardcharacter}\goforwardcharacter}}}

\def\gotosomewherecharacter%
  {{\hbox{\hsmash{\symbol[\v!vorige]}\symbol[\v!volgende]}}}

\unexpanded\def\closecharacter%
  {\dogotocharacter\boxtimes
     {\ruledhbox{\mathematics{\times}}}
     {\mathematics{\boxtimes}}}

\def\goforjumpcharacter%
  {\hbox{\goforwardcharacter \kern-.5em\goforwardcharacter}}

\def\gobackjumpcharacter%
  {\hbox{\gobackwardcharacter\kern-.5em\gobackwardcharacter}}

% temporarily here

% gejat van Knuth (zie \copyright, p356)

\def\omcirkeld#1%
  {{\ooalign{\hfil\raise0.07ex\hbox{{\tfx#1}}\hfil\crcr\mathhexbox20D}}}

\def\copyright
  {\omcirkeld{c}}

\protect \endinput