-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathdwmpcode.sty
More file actions
151 lines (151 loc) · 7.34 KB
/
dwmpcode.sty
File metadata and controls
151 lines (151 loc) · 7.34 KB
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
\NeedsTeXFormat{LaTeX2e}[1994/06/01]
\ProvidesPackage{dwmpcode}[2024/11/05 v0.02 Code setting in DwMP]
\RequirePackage{listings}
\makeatletter\lst@InputCatcodes
\def\lst@DefEC{%
\lst@CCECUse \lst@ProcessLetter
^^80^^81^^82^^83^^84^^85^^86^^87^^88^^89^^8a^^8b^^8c^^8d^^8e^^8f%
^^90^^91^^92^^93^^94^^95^^96^^97^^98^^99^^9a^^9b^^9c^^9d^^9e^^9f%
^^a0^^a1^^a2^^a3^^a4^^a5^^a6^^a7^^a8^^a9^^aa^^ab^^ac^^ad^^ae^^af%
^^b0^^b1^^b2^^b3^^b4^^b5^^b6^^b7^^b8^^b9^^ba^^bb^^bc^^bd^^be^^bf%
^^c0^^c1^^c2^^c3^^c4^^c5^^c6^^c7^^c8^^c9^^ca^^cb^^cc^^cd^^ce^^cf%
^^d0^^d1^^d2^^d3^^d4^^d5^^d6^^d7^^d8^^d9^^da^^db^^dc^^dd^^de^^df%
^^e0^^e1^^e2^^e3^^e4^^e5^^e6^^e7^^e8^^e9^^ea^^eb^^ec^^ed^^ee^^ef%
^^f0^^f1^^f2^^f3^^f4^^f5^^f6^^f7^^f8^^f9^^fa^^fb^^fc^^fd^^fe^^ff%
^^^^20ac^^^^0153^^^^0152% euro, OE, and oe
^^^^2013^^^^2014% typo-dashes
^^^^2018^^^^2019^^^^201c^^^^201d% typo quotes
^^00}
\lst@RestoreCatcodes\makeatother
\RequirePackage{xcolor}
\RequirePackage{luamplib}
\definecolor{textblue}{rgb}{.2,.2,.7}
\definecolor{textred}{rgb}{0.54,0,0}
\definecolor{textgreen}{rgb}{0,0.43,0}
\definecolor{squash}{rgb}{0.793, 0.359, 0.05}
\definecolor{carrot}{rgb}{0.934, 0.445, 0.082}
\definecolor{purple}{rgb}{0.398, 0.008, 0.234}
\def\red#1{\textcolor{textred}{#1}}
\def\blue#1{\textcolor{textblue}{#1}}
\def\green#1{\textcolor{textgreen}{#1}}
\newcommand\mpstyle{\lstset{language=Metapost,
basicstyle=\ttfamily,
keywordstyle=\color{textblue},
keywordstyle=[5]\color{squash},
keywordstyle=[6]\color{carrot},
keywordstyle=[7]\color{purple},
commentstyle=\color{textred},
stringstyle=\color{textgreen},
columns=fullflexible,
keepspaces=true,
extendedchars=true,
xleftmargin=\parindent,
% keywords[1] = Syntax primitive + plain sugar
keywords=[1]{beginfig, begingroup, bye, controls, curl, verbatimtex,%
cycle, def, delimiters, downto, else, elseif, end, enddef, endfig,%
endfor, endgroup, etex, exitif, exitunless, expr, fi, for, forever,%
forsuffixes, if, input, numtok, outer, primary, primarydef, range,%
relax, scantokens, secondary, secondarydef, step, suffix, tension,%
tertiary, tertiarydef, text, thru, until, upto, vardef, within},%
% keywords[2] = Operators - nullary, unary, binary, thing x of y
keywords=[2]{abs, and, angle, arclength, arctime, ASCII, bbox,%
blackpart, bluepart, bounded, byte, ceiling, center, char,%
clipped, colormodel, colorpart, cosd, counterclockwise, cutafter,%
cutbefore, cyanpart, dashpart, decimal, dir, direction,%
directionpoint, directiontime, div, dotprod, false, filled, floor,%
fontpart, fontsize, glyph, gobbled, greenpart, greypart, hex,%
infont, intersectionpoint, intersectiontimes, inverse, known,%
length, llcorner, lrcorner, magentapart, makepath, makepen,%
mexp, mlog, mod, normaldeviate, not, nullpen, nullpicture, oct,%
odd, of, or, pathpart, pencircle, penoffset, penpart, point,%
postcontrol, precontrol, readfrom, redpart, reflectedabout,%
reverse, rotated, rotatedabout, rotatedaround, round, scaled,%
shifted, sind, slanted, softjoin, sqrt, str, stroked, subpath,%
substring, textpart, textual, transformed, true,%
turningnumber, ulcorner, uniformdeviate, unitvector, unknown,%
urcorner, whatever, xpart, xscaled, xxpart, xypart, yellowpart,%
ypart, yscaled, yxpart, yypart, zscaled,%
top, bot, lft, rt, ulft, urt, llft, lrt,},
% keywords[3] = Commands
keywords=[3]{addto, also, batchmode, clearit, clearpen, clearxy,%
clear_pen_memory, clip, closefrom, contour, cutdraw, dotlabel,%
doublepath, draw, drawarrow, drawdblarrow, drawdot, drawoptions,%
errhelp, errmessage, errorstopmode, filenametemplate, fill,%
filldraw, fontmapfile, fontmapline, interim, label, let,%
loggingall, makelabel, message, newinternal, nonstopmode,%
penstroke, pickup, randomseed, readstring, save, savepen,%
scrollmode, setbounds, shipit, shipout, show, showdependencies,%
showtoken, showvariable, special, to, tracingall, tracingnone,%
undraw, undrawdot, unfill, unfilldraw, write},%
% keywords[4] = Specials, fancy macros, etc
keywords=[4]{boxit, boxjoin, bpath, buildcycle, circleit, dashed,%
dashpattern, decr, dotlabels, drawboxed, drawboxes, drawunboxed,%
erase, fixpos, fixsize, flex, gobble, hide, image, incr, interact,%
interpath, labels, magstep, max, min, off, on, penlabels, penpos,%
solve, stop, superellipse, takepower, tensepath, thelabel,%
withcmykcolor, withcolor, withgreyscale, withoutcolor, withpen,%
withpostscript, withprescript, withrgbcolor, withalpha, z},%
% keywords[5] = Predefined variables
keywords=[5]{ahangle, ahlength, arrowhead, background, bboxmargin,%
charcode, circmargin, currentpen, currentpicture, cuttings, day,%
defaultcolormodel, defaultdx, defaultdy, defaultfont, defaultpen,%
defaultscale, dotlabeldiam, eps, extra_beginfig, extra_endfig,%
hour, hppp, jobname, join_radius, labeloffset, laboff, labxf,%
labyf, linecap, linejoin, minute, miterlimit, month, mpprocset,%
numberprecision, numbersystem, outputfilename, outputformat,%
outputformatoptions, outputtemplate, pausing, pen_bot, pen_lft,%
pen_rt, pen_top, prologues, restoreclipcolor, showstopping, time,%
tolerance, tracingcapsules, tracingchoices, tracingcommands,%
tracingequations, tracinglostchars, tracingmacros, tracingonline,%
tracingoutput, tracingrestores, tracingspecs, tracingstats,%
tracingtitles, troffmode, truecorners, vppp, warningcheck, year},%
% keywords[6] = Constants
keywords=[6]{base_name, base_version, beveled, black,%
blankpicture, blue, bp, butt, cc, cm, dd, ditto, down, EOF,%
epsilon, evenly, fullcircle, green, halfcircle, identity, in, left,%
mitered, mm, mpversion, origin, pc, penrazor, penspeck,%
pensquare, pt, quartercircle, red, right, rounded, squared,%
unitsquare, up, white, withdots, infinity},%
% keywords[7] = Types
keywords=[7]{boolean, cmykcolor, color, numeric, pair, path, pen,%
picture, rgbcolor, string, transform},%
sensitive=true,%
alsoother={0123456789$@},%
morestring=[s]{verbatimtex}{etex},%
morestring=[s]{btex}{etex}%
}}
\lstnewenvironment{smallcode}[1][]{\mpstyle\lstset{basicstyle=\small\ttfamily,#1}}{}
\lstnewenvironment{code}[1][]{\mpstyle\lstset{#1}}{}
\newcommand\mpexternal[2][]{{\mpstyle\lstinputlisting[#1]{#2}}}
\newcommand\smallmpexternal[2][]{{\mpstyle\lstinputlisting[basicstyle=\small\ttfamily,#1]{#2}}}
\newcommand\mpl[1]{{\normalfont\mpstyle\lstinline!#1!}}
%
\newcommand\texstyle{\lstset{
language=[LaTeX]Tex,
basicstyle=\ttfamily,
keywordstyle=\color{textblue},
commentstyle=\color{textred},
stringstyle=\color{textgreen},
frame=none,
columns=fullflexible,
keepspaces=true,
xleftmargin=\parindent,
showstringspaces=false,
morekeywords={everymplib, everyendmplib, setmainfont, setsansfont, setmonofont,
mplibtextextlabel, mplibnumbersystem, mplibsetformat, mplibshowlog},
}}
\lstnewenvironment{texcode}[1][]{\texstyle\lstset{basicstyle=\small\ttfamily,#1}}{}
\newcommand\txl[1]{{\texstyle\lstinline!#1!}}
\newcommand\texternal[2][]{{\texstyle\lstinputlisting[#1]{#2}}}
\newcommand\smalltexternal[2][]{{\texstyle\lstinputlisting[basicstyle=\small\ttfamily,#1]{#2}}}
%
% Labels..
%
\newcommand\sep[1]{$\vcenter{\begin{mplibcode}
picture T; T = thelabel(TEX("\ttfamily " & #1), origin); interim bboxmargin := 3; path p; p = bbox T;
path S; S = superellipse(point 3/2 of p, point 5/2 of p, point 7/2 of p, point 1/2 of p, 0.78);
string x; x = substring (0, 1) of #1;
fill S withcolor if x = "m": 7/8[red, white] elseif x = "c": 7/8[blue, white] else: white fi;
draw S; draw T;\end{mplibcode}}$}
%
\endinput