summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/context/base/mkii/verb-mp.mkii
blob: aef52217d8c37404e331085f4f917173a78459ff (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
%D \module
%D   [       file=verb-mp,
%D        version=1997.12.22,
%D          title=\CONTEXT\ Verbatim Macros,
%D       subtitle=Pretty \METAPOST\ Verbatim,
%D         author=Hans Hagen,
%D           date=\currentdate,
%D      copyright={PRAGMA ADE \& \CONTEXT\ Development Team}]
%C
%C This module is part of the \CONTEXT\ macro||package and is
%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
%C details.

\writestatus{loading}{ConTeXt Verbatim Macros / Pretty METAPOST Verbatim}

% bug: in mp-char.mp the char should not be highlighted

% can be simplified

%D This module was first used when I documented our new
%D company logo. This interpreter is modeled after the \PERL\
%D one.
%D
%D \startMP
%D beginfig(1);
%D   z1 = (0,0);
%D   z2 = (100,0);
%D   z3 = (0,100);
%D   draw z1--z2--z3--cycle;
%D endfig;
%D \stopMP
%D
%D Of course we cannot (yet) provide a nice layout, so some
%D formatting is still needed.

\unprotect

%D \macros
%D   {prettyMPvariables}
%D
%D Identifiers and system variables are typeset in a different
%D style. One can turn of this mechanism for the variables by
%D setting th enext boolean.
%D

\doglobal\newif\ifprettyMPvariables

\global\prettyMPvariablestrue

%D We support \METAFONT\ as well as \METAPOST.

\gdef\MPsetcontrols
  {\saveprettycontrols
   \everyprettyend
     {\endMPtypesix}%
   \def\obeyedspace%
     {\endMPtypesix
      \oldobeyedspace}%
   \def\flushrestofverbatimline%
     {\endMPtypesix}%
   \let\obeytabs=\ignoretabs}

\gdef\setupprettyMPtype
  {\def\prettyidentifier{MP}%
   \global\inMPtexmodefalse
   \MPsetvariables
   \MPsetcontrols
   \MPsethandlers
   \MPsetspecials}

\doglobal\newif\ifinMPtexmode

\gdef\MPsetvariables
  {\global\inMPtexmodefalse
   \global\let\MPsequence=\empty}

\gdef\MPsetspecials
  {\setpretty`\;=11 \setpretty`\$=12 \setpretty`\@=12 \setpretty`\#=12
   \setpretty`\%=20
   \setpretty`\[=31 \setpretty`\]=31 \setpretty`\(=32 \setpretty`\)=32
   \setpretty`\:=33 \setpretty`\==34 \setpretty`\<=34 \setpretty`\>=34
   \setpretty`\-=41 \setpretty`\+=41 \setpretty`\/=41 \setpretty`\*=41
   \setpretty`\|=41 \setpretty`\`=41 \setpretty`\!=41 \setpretty`\?=41
   \setpretty`\^=41 \setpretty`\&=42
   \setpretty`\\=50
   \setpretty`\1=61 \setpretty`\2=61 \setpretty`\3=61 \setpretty`\4=61
   \setpretty`\5=61 \setpretty`\6=61 \setpretty`\7=61 \setpretty`\8=61
   \setpretty`\9=61 \setpretty`\0=61
   \setpretty`\A=62 \setpretty`\B=62 \setpretty`\C=62 \setpretty`\D=62 \setpretty`\E=62
   \setpretty`\F=62 \setpretty`\G=62 \setpretty`\H=62 \setpretty`\I=62 \setpretty`\J=62
   \setpretty`\K=62 \setpretty`\L=62 \setpretty`\M=62 \setpretty`\N=62 \setpretty`\O=62
   \setpretty`\P=62 \setpretty`\Q=62 \setpretty`\R=62 \setpretty`\S=62 \setpretty`\T=62
   \setpretty`\U=62 \setpretty`\V=62 \setpretty`\W=62 \setpretty`\X=62 \setpretty`\Y=62
   \setpretty`\Z=62
   \setpretty`\a=62 \setpretty`\b=62 \setpretty`\c=62 \setpretty`\d=62 \setpretty`\e=62
   \setpretty`\f=62 \setpretty`\g=62 \setpretty`\h=62 \setpretty`\i=62 \setpretty`\j=62
   \setpretty`\k=62 \setpretty`\l=62 \setpretty`\m=62 \setpretty`\n=62 \setpretty`\o=62
   \setpretty`\p=62 \setpretty`\q=62 \setpretty`\r=62 \setpretty`\s=62 \setpretty`\t=62
   \setpretty`\u=62 \setpretty`\v=62 \setpretty`\w=62 \setpretty`\x=62 \setpretty`\y=62
   \setpretty`\z=62
   \setpretty`\_=62
   \setpretty`\,=70 \setpretty`\.=70
   \setpretty`\'=81 \setpretty`\"=82
   \setpretty`\{=90 \setpretty`\}=90 }

\gdef\MPsethandlers
  {\installprettyhandler 11 \MPtypeone
   \installprettyhandler 12 \MPtypeone
   \installprettyhandler 20 \MPtypetwo
   \installprettyhandler 31 \MPtypethreeA
   \installprettyhandler 32 \MPtypethreeA
   \installprettyhandler 33 \MPtypethreeB
   \installprettyhandler 34 \MPtypethreeB
   \installprettyhandler 41 \MPtypefour
   \installprettyhandler 42 \MPtypefour
   \installprettyhandler 50 \MPtypefive
   \installprettyhandler 61 \MPtypesixone
   \installprettyhandler 62 \MPtypesixtwo
   \installprettyhandler 70 \MPtypeseven
   \installprettyhandler 81 \MPtypeeightone
   \installprettyhandler 82 \MPtypeeighttwo
   \installprettyhandler 90 \MPtypenine }

\gdef\MPtypeone#1%
  {\endMPtypesix
   \ifinMPtexmode
     \getpretty{#1}%
   \else
     \beginofpretty[\!!prettyone]\getpretty{#1}\endofpretty%
   \fi}

\gdef\doMPtypetwo#1%
  {\ifnaturaltextext
     \let\next\naturaltextext
   \else
     \disableprettytrue\disableprettyafterwards
     \def\next{\beginofpretty[\!!prettyfour]\getpretty{#1}\endofpretty}%
   \fi
   \next}

\gdef\MPtypetwo
  {\endMPtypesix
   \ifnewpretty\expandafter\handlenewpretty\fi\doMPtypetwo}

\gdef\MPtypethreeA#1%
  {\endMPtypesix
   \ifinMPtexmode
     \getpretty{#1}%
   \else
     \beginofpretty[\!!prettythree]\getpretty{#1}\endofpretty
   \fi}

\gdef\MPtypethreeB#1%
  {\endMPtypesix
   \ifinMPtexmode
     \getpretty{#1}%
   \else
     \beginofpretty[\!!prettyone]\getpretty{#1}\endofpretty
   \fi}

\gdef\MPtypefour#1%
  {\endMPtypesix
   \ifinMPtexmode
     \getpretty{#1}%
   \else
     \beginofpretty[\!!prettyfour]\getpretty{#1}\endofpretty
   \fi}

\gdef\MPtypefive#1%
  {\endMPtypesix
   \ifinMPtexmode
     \getpretty{#1}%
   \else
     \beginofpretty[\!!prettytwo]\getpretty{#1}\endofpretty
   \fi}

\gdef\endMPtypesix
  {\ifx\MPsequence\empty\else
     \doifprettyidentifierelse{\MPsequence}{\MPidentifiers}
       {\doifprettyidentifierelse{\MPsequence}{\MPbtex}
          {\beginofpretty[\!!prettytwo]%
             {\prettyidentifierfont\MPsequence}%
           \endofpretty
           \global\inMPtexmodetrue}
          {\ifinMPtexmode
             \doifprettyidentifierelse{\MPsequence}{\MPetex}
               {\global\inMPtexmodefalse}{}%
           \fi
           \beginofpretty[\!!prettytwo]%
             {\prettyidentifierfont\MPsequence}%
           \endofpretty}}
       {\ifprettyMPvariables
          \doifprettyidentifierelse{\MPsequence}{\MPvariables}
            {\beginofpretty[\!!prettytwo]%
             {\prettyvariablefont\MPsequence}%
             \endofpretty}
            {\MPsequence}%
        \else
          \MPsequence
        \fi}%
     \global\let\MPsequence=\empty
   \fi}

\gdef\MPtypesixone
  {\endMPtypesix
   \getpretty}

\gdef\MPtypesixtwo#1%
  {\xdef\MPsequence{\MPsequence\getpretty{#1}}}

\gdef\MPtypeseven#1%
  {\endMPtypesix
   \ifinMPtexmode
     \getpretty{#1}%
   \else
     \beginofpretty[\!!prettyfour]\getpretty{#1}\endofpretty
   \fi}

\gdef\MPtypeeightone#1%
  {\endMPtypesix
   \ifinMPtexmode
     \getpretty{#1}%
   \else
     \beginofpretty[\!!prettythree]\getpretty{#1}\endofpretty
   \fi}

\gdef\MPtypeeighttwo#1%
  {\endMPtypesix
   \ifinMPtexmode
     \getpretty{#1}%
   \else
     \beginofpretty[\!!prettythree]\getpretty{#1}\endofpretty
   \fi}

\gdef\MPtypenine#1%
  {\endMPtypesix
   \ifinMPtexmode
     \getpretty{#1}%
   \else
     \getpretty{#1}%
   \fi}

%D \METAPOST\ \TEX||ies:

\useprettyidentifiers \MPbtex \MPsetspecials
  btex verbatimtex

\useprettyidentifiers \MPetex \MPsetspecials
  etex

\useprettyidentifiers \MPidentifiers \MPsetspecials
  btex etex verbatimtex

%D \METAPOST\ internal variables \& predefined variables:

\useprettyidentifiers \MPidentifiers \MPsetspecials
  charcode day linecap linejoin miterlimit month pausing
  prologues showstopping time tracingcapsules tracingchoices mpprocset
  tracingcommands tracingequations tracinglostchars
  tracingmacros tracingonline tracingoutput tracingrestores
  tracingspecs tracingstats tracingtitles truecorners
  warningcheck year

\useprettyidentifiers \MPvariables \MPsetspecials
  ahangle ahlength bboxmargin defaultpen defaultscale
  labeloffset background currentpen currentpicture cuttings
  defaultfont extra_beginfig extra_endfig

%D \METAPOST\ predefined constants:

\useprettyidentifiers \MPidentifiers \MPsetspecials
  false nullpicture pencircle true

\useprettyidentifiers \MPvariables \MPsetspecials
  beveled black blue bp butt cc cm dd ditto down epsilon
  evenly fullcircle green halfcircle identity in infinity left
  mitered mm origin pensquare pt quartercircle red right
  rounded squared unitsquare up white withdots

%D \METAPOST\ operators:

\useprettyidentifiers \MPidentifiers \MPsetspecials
  and angle arclength arctime ASCII bluepart boolean bot
  char color cosd cycle decimal directiontime floor fontsize
  greenpart hex infont intersectiontimes known length llcorner
  lrcorner makepath makepen mexp mlog normaldeviate not
  numeric oct odd or path pair pen penoffset picture point
  postcontrol precontrol redpart reverse rotated scaled
  shifted sind slanted sqrt str string subpath substring
  transform transformed ulcorner uniformdeviate unknown
  urcorner xpart xscaled xxpart xypart ypart yscaled yxpart
  yypart zscaled

\useprettyidentifiers \MPvariables \MPsetspecials
  abs bbox ceiling center cutafter cutbefore dir
  directionpoint div dotprod intersectionpoint inverse mod lft
  round rt unitvector whatever

%D \METAPOST\ commands:

\useprettyidentifiers \MPidentifiers \MPsetspecials
  addto clip input interim let newinternal save setbounds
  shipout show showdependencies showtoken showvariable
  special

\useprettyidentifiers \MPvariables \MPsetspecials
  cutdraw draw drawarrow drawdblarrow fill filldraw
  loggingall pickup tracingall tracingnone undraw unfill
  unfilldraw drawdot

%D \METAPOST\ macro||like functions:

\useprettyidentifiers \MPvariables \MPsetspecials
  buildcycle dashpattern decr dotlabel dotlabels drawoptions
  incr label labels max min thelabel z

%D More \METAPOST:

\useprettyidentifiers \MPidentifiers \MPsetspecials
  begingroup endgroup of curl tension and controls
  reflectedabout rotatedaround interpath on off beginfig
  endfig def vardef enddef epxr suffix text primary secondary
  tertiary primarydef secondarydef tertiarydef top bottom
  ulft urt llft lrt randomseed also contour doublepath
  withcolor withpen dashed if else elseif fi for endfor
  forsuffixes forever downto upto step until end

%D \METAFONT\ stuff:

\useprettyidentifiers \MPidentifiers \MPsetspecials
  charlist extensible fontdimen headerbyte kern ligtable
  boundarychar chardp charext charht charic charwd designsize
  fontmaking charexists

\useprettyidentifiers \MPvariables \MPsetspecials
  beginchar blacker capsule_end change_width
  define_blacker_pixels define_corrected_pixels
  define_good_x_pixels define_good_y_pixels
  define_horizontal_corrected_pixels define_pixels
  define_whole_blacker_pixels define_whole_pixels
  define_whole_vertical_blacker_pixels
  define_whole_vertical_pixels endchar extra_beginchar
  extra_endchar extra_setup font_coding_scheme
  font_extra_space

%D \METAFONT\ no||op stuff:

\useprettyidentifiers \MPidentifiers \MPsetspecials
  cullit currenttransform gfcorners grayfont hround
  imagerules lowres_fix nodisplays notransforms openit
  displaying currentwindow screen_rows screen_cols
  pixels_per_inch cull display openwindow numspecial
  totalweight autorounding fillin proofing tracingpens
  xoffset chardx granularity smoothing turningcheck yoffset
  chardy hppp tracingedges vppp

%D \METAPOST\ goodies:

\useprettyidentifiers \MPidentifiers \MPsetspecials
  extra_beginfig extra_endfig mpxbreak

\protect

\endinput