summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/context/base/meta-ini.tex
diff options
context:
space:
mode:
Diffstat (limited to 'Master/texmf-dist/tex/context/base/meta-ini.tex')
-rw-r--r--Master/texmf-dist/tex/context/base/meta-ini.tex261
1 files changed, 198 insertions, 63 deletions
diff --git a/Master/texmf-dist/tex/context/base/meta-ini.tex b/Master/texmf-dist/tex/context/base/meta-ini.tex
index d628e5e6c43..3353a9a0bd6 100644
--- a/Master/texmf-dist/tex/context/base/meta-ini.tex
+++ b/Master/texmf-dist/tex/context/base/meta-ini.tex
@@ -55,6 +55,11 @@
1: se incarca biblioteca metapost --
\stopmessages
+\startmessages french library: metapost
+ title: metapost
+ 1: chargement de la bibliothèque metapost --
+\stopmessages
+
%D This module extends the functionality of the support module
%D \type {supp-mps}, the module that is responsible for
%D \METAPOST\ inclusion in \CONTEXT. Some basic macros will be
@@ -64,42 +69,46 @@
\maxnofMPgraphics = 4000 % metafun disables the 4K boundary
-\appendtoks
+\startMPextensions
if unknown context_tool: input mp-tool; fi;
if unknown context_spec: input mp-spec; fi;
if unknown context_grph: input mp-grph; fi;
-\to \MPextensions
+\stopMPextensions
%D Since we want lables to follow the document settings, we
%D also set the font related variables.
-\appendtoks % scale is not yet ok
+\startMPinitializations % scale is not yet ok
defaultfont:="\truefontname{Regular}";
defaultscale:=\the\bodyfontsize/10pt;
-\to \MPinitializations
+\stopMPinitializations
%D In order to support fancy text features (like outline
%D fonts), we set:
-\appendtoks
+\startMPextensions
graphictextformat:="context";
graphictextdirective "\the\everyMPTEXgraphic";
-\to \MPextensions
+\stopMPextensions
-% \appendtoks
+% \startMPextensions
% textextdirective "\the\everyMPTEXgraphic";
-% \to \MPextensions
+% \stopMPextensions
%D A signal that we're in combines \CONTEXT||\METAFUN mode:
-\appendtoks
+\startMPextensions
string contextversion;
contextversion:="\contextversion";
-\to \MPextensions
+\stopMPextensions
%D Some safeguards:
-
-\appendtoks \cleanupfeatures \to \everyMPgraphic
+%D
+%D \starttyping
+%D \appendtoks \cleanupfeatures \to \everyMPgraphic
+%D \stoptyping
+%D
+%D No, we don't want that (else we loose UTF etc).
%D Another one:
@@ -244,11 +253,15 @@
\elabelgroup}
\long\def\startuniqueMPgraphic
- {\dodoublegroupempty\dostartuniqueMPgraphic}
-
-\long\def\dostartuniqueMPgraphic#1#2#3\stopuniqueMPgraphic%
{\blabelgroup
- \long\setgvalue{\@@MPG#1}{\handleuniqueMPgraphic{#1}{#2}{#3}}%
+ \dodoublegroupempty\dostartuniqueMPgraphic}
+
+\long\def\dostartuniqueMPgraphic
+ {\obeyMPlines
+ \dodostartuniqueMPgraphic}
+
+\long\def\dodostartuniqueMPgraphic#1#2#3\stopuniqueMPgraphic%
+ {\long\setgvalue{\@@MPG#1}{\handleuniqueMPgraphic{#1}{#2}{#3}}%
\elabelgroup}
\unexpanded\def\uniqueMPgraphic
@@ -259,6 +272,8 @@
\setupMPvariables[#1][#2]%
\getvalue{\@@MPG#1}{}%
\elabelgroup}
+
+\let\stopuniqueMPcode \relax % so that we can use it in \expanded
\long\def\handleuseMPgraphic#1#2#3%
{\blabelgroup
@@ -274,19 +289,27 @@
\elabelgroup}
\long\def\startuseMPgraphic
- {\dodoublegroupempty\dostartuseMPgraphic}
-
-\long\def\dostartuseMPgraphic#1#2#3\stopuseMPgraphic
{\blabelgroup
- \long\setgvalue{\@@MPG#1}{\handleuseMPgraphic{#1}{#2}{#3}}%
+ \dodoublegroupempty\dostartuseMPgraphic}
+
+\long\def\dostartuseMPgraphic
+ {\obeyMPlines
+ \dodostartuseMPgraphic}
+
+\long\def\dodostartuseMPgraphic#1#2#3\stopuseMPgraphic
+ {\long\setgvalue{\@@MPG#1}{\handleuseMPgraphic{#1}{#2}{#3}}%
\elabelgroup}
\long\def\startusableMPgraphic % redundant but handy
- {\dodoublegroupempty\dostartusableMPgraphic}
-
-\long\def\dostartusableMPgraphic#1#2#3\stopusableMPgraphic
{\blabelgroup
- \long\setgvalue{\@@MPG#1}{\handleuseMPgraphic{#1}{#2}{#3}}%
+ \dodoublegroupempty\dostartusableMPgraphic}
+
+\long\def\dostartusableMPgraphic % redundant but handy
+ {\obeyMPlines
+ \dodostartusableMPgraphic}
+
+\long\def\dodostartusableMPgraphic#1#2#3\stopusableMPgraphic
+ {\long\setgvalue{\@@MPG#1}{\handleuseMPgraphic{#1}{#2}{#3}}%
\elabelgroup}
\long\def\handlereusableMPgraphic#1#2#3%
@@ -305,16 +328,15 @@
\elabelgroup}
\long\def\startreusableMPgraphic
- {\dodoublegroupempty\dostartreusableMPgraphic}
+ {\blabelgroup
+ \dodoublegroupempty\dostartreusableMPgraphic}
-% \long\def\dostartreusableMPgraphic#1#2#3\stopreusableMPgraphic%
-% {\ifundefined{\@@MPG#1}%
-% \long\setgvalue{\@@MPG#1}{\handlereusableMPgraphic{#1}{#2}{#3}}%
-% \fi}
+\def\dostartreusableMPgraphic
+ {\obeyMPlines
+ \dodostartreusableMPgraphic}
-\long\def\dostartreusableMPgraphic#1#2#3\stopreusableMPgraphic
- {\blabelgroup
- \long\setgvalue{\@@MPG#1}{\handlereusableMPgraphic{#1}{#2}{#3}}%
+\long\def\dodostartreusableMPgraphic#1#2#3\stopreusableMPgraphic
+ {\long\setgvalue{\@@MPG#1}{\handlereusableMPgraphic{#1}{#2}{#3}}%
\elabelgroup}
\unexpanded\def\useMPgraphic
@@ -328,6 +350,11 @@
\let\reuseMPgraphic\useMPgraphic
+\let\stopuseMPcode \relax % so that we can use it in \expanded
+\let\stopusableMPcode \relax % so that we can use it in \expanded
+\let\stopreusableMPcode \relax % so that we can use it in \expanded
+\let\stopuniqueMPcode \relax % so that we can use it in \expanded
+
\def\enableincludeMPgraphics
{\let\handleuseMPgraphic \thirdofthreearguments
\let\handlereusableMPgraphic\thirdofthreearguments}
@@ -346,11 +373,15 @@
:\MPcolor\overlaycolor:\MPcolor\overlaylinecolor}
\long\def\startuniqueMPpagegraphic
- {\dodoublegroupempty\dostartuniqueMPpagegraphic}
-
-\long\def\dostartuniqueMPpagegraphic#1#2#3\stopuniqueMPpagegraphic
{\blabelgroup
- \long\setgvalue{\@@MPG o:#1}{\handleuniqueMPgraphic{o:#1}{#2}{#3}}%
+ \dodoublegroupempty\dostartuniqueMPpagegraphic}
+
+\long\def\dostartuniqueMPpagegraphic
+ {\obeyMPlines
+ \dodostartuniqueMPpagegraphic}
+
+\long\def\dodostartuniqueMPpagegraphic#1#2#3\stopuniqueMPpagegraphic
+ {\long\setgvalue{\@@MPG o:#1}{\handleuniqueMPgraphic{o:#1}{#2}{#3}}%
\long\setgvalue{\@@MPG e:#1}{\handleuniqueMPgraphic{e:#1}{#2}{#3}}%
\elabelgroup}
@@ -450,13 +481,13 @@
%D We also have to make sure that \METAPOST\ knows this:
-\appendtoks
+\startMPextensions
if not known _data_prefix_:
string _data_prefix_,_data_suffix_;
fi;
_data_prefix_:="\bufferprefix mpd-";
_data_suffix_:=".mpd";
-\to \MPextensions
+\stopMPextensions
%D \macros
%D {getMPdata}
@@ -482,10 +513,10 @@
%D We have to enable this mechanism with:
-\appendtoks
+\startMPextensions
boolean collapse_data; collapse_data:=true;
_data_suffix_:=".mpd"; % overloads previous one
-\to \MPextensions
+\stopMPextensions
%D For the moment, the next one is a private macro:
@@ -497,6 +528,7 @@
{\doprocessMPbuffer[\jobname]}
{\bgroup
\setnormalcatcodes
+ \obeyMPlines
%\let\par\empty % oeps, this makes dvi mode graphics hang when not found
\!!toksa\emptytoks
\def\copyMPbufferline{\expandafter\appendtoks\fileline\to\!!toksa}%
@@ -544,7 +576,7 @@
\long\def\dostartMPenvironment[#1][#2]#3\stopMPenvironment
{\egroup
\doif{#1}\s!reset\resetMPenvironment % reset mp toks
- \doif{#1}\v!global{#3}% % use in main doc too
+ \doif{#1}\v!global{#3}% % use in main doc too
\doif{#1}+{#3}% % use in main doc too
\convertargument#3\to\ascii
\expandafter\appendtoks\ascii\to\everyMPTEXgraphic}
@@ -635,10 +667,9 @@
\def\douseMPlibrary#1%
{\ifundefined{\c!file\f!javascriptprefix#1}%
\letvalueempty{\c!file\f!javascriptprefix#1}%
- \makeshortfilename[\f!metapostprefix#1]
- \showmessage\m!metapost1{#1}
+ \makeshortfilename[\truefilename{\f!metapostprefix#1}]%
\startreadingfile
- \readsysfile\shortfilename\donothing\donothing
+ \readsysfile\shortfilename{\showmessage\m!metapost1{#1}}\donothing
\stopreadingfile
\fi}
@@ -668,9 +699,13 @@
\convertargument#2\to\ascii
\dodoglobal\letvalue{\@@MPT#1}\ascii}
-\def\MPtext #1{\getvalue{\@@MPT#1}}
-\def\MPstring #1{"\getvalue{\@@MPT#1}"}
-\def\MPbetex #1{btex \getvalue{\@@MPT#1} etex}
+% \def\MPtext #1{\getvalue{\@@MPT#1}}
+% \def\MPstring #1{"\getvalue{\@@MPT#1}"}
+% \def\MPbetex #1{btex \getvalue{\@@MPT#1} etex}
+
+\def\MPtext #1{\executeifdefined{\@@MPT#1}\empty}
+\def\MPstring #1{"\executeifdefined{\@@MPT#1}\empty"}
+\def\MPbetex #1{btex \executeifdefined{\@@MPT#1}\empty\space etex}
%D Unfortunately \METAPOST\ does not have \CMYK\ support
%D built in, but by means of specials we can supply the
@@ -679,21 +714,21 @@
\newif\ifMPcmykcolors \MPcmykcolorstrue
\newif\ifMPspotcolors \MPspotcolorstrue
-\appendtoks
+\startMPinitializations
cmykcolors:=\ifMPcmykcolors true\else false\fi;
spotcolors:=\ifMPspotcolors true\else false\fi;
-\to \MPinitializations
+\stopMPinitializations
%D In order to communicate conveniently with the \TEX\
%D engine, we introduce some typesetting variables.
% todo : backgroundoffsets
-\appendtoks
+\startMPextensions
color OverlayColor,OverlayLineColor;
-\to \MPextensions
+\stopMPextensions
-\appendtoks
+\startMPinitializations
OverlayWidth:=\overlaywidth;
OverlayHeight:=\overlayheight;
OverlayDepth:=\overlayheight;
@@ -718,7 +753,11 @@
PageNumber:=\the\pageno;
RealPageNumber:=\the\realpageno;
LastPageNumber:= lastpage;
-\to \MPinitializations
+\stopMPinitializations
+
+\appendtoks
+ \expanded{\definecolor[currentcolor][\currentcolor]}%
+\to \everyMPgraphic
\appendtoks
\baselineskip1\baselineskip
@@ -758,9 +797,9 @@
\ifx\undefined\MPprologues \def\MPprologues{0} \fi
-\appendtoks
+\startMPinitializations
prologues:=\MPprologues;
-\to \MPinitializations
+\stopMPinitializations
\appendtoks
\def\MPprologues{0}%
@@ -811,7 +850,10 @@
%D However, on a 1 Gig Pentium, the next alternative saves
%D us 20 seconds run time for the 300 page \METAFUN\ manual:
-\def\insertMPfile#1#2{\doinsertMPfile{#1}}
+\let\insertMPfileARG\insertMPfile
+
+\def\insertMPfile#1#2% in context #2 is empty
+ {\doifelsenothing{#2}{\doinsertMPfile{#1}}{\insertMPfileARG{#1}{#2}}}
\def\includeMPasEPS#1%
{\bgroup
@@ -853,25 +895,25 @@
%D One more: (still needed?)
-\appendtoks
+\startMPextensions
def initialize_form_numbers =
do_initialize_numbers;
enddef;
-\to \MPextensions
+\stopMPextensions
-\appendtoks
+\startMPinitializations
HSize:=\the\hsize ;
VSize:=\the\vsize ;
-\to \MPinitializations
+\stopMPinitializations
-\appendtoks
+\startMPextensions
vardef ForegroundBox =
unitsquare xysized(HSize,VSize)
enddef ;
vardef PageFraction =
if \lastpage>1: (\realfolio-1)/(\lastpage-1) else: 1 fi
enddef ;
-\to \MPextensions
+\stopMPextensions
%D And some more. These are not really needed since we
%D don't use the normal figure inclusion macros any longer.
@@ -927,7 +969,7 @@
%D New:
-\definelayerpreset
+\definelayerpreset % no dx,dy - else nasty non-mp placement
[mp]
[\c!y=-\MPury bp,
\c!x=\MPllx bp,
@@ -956,13 +998,106 @@
%D
%D \ruledhbox{\flushlayer[mp]}
%D \stoptyping
+%D
+%D Reusing graphics is also possible (now):
+%D
+%D \starttyping
+%D \startreusableMPgraphic{axis}
+%D tickstep := 1cm ; ticklength := 2mm ;
+%D drawticks unitsquare xscaled 4cm yscaled 3cm shifted (-1cm,-1cm) ;
+%D tickstep := tickstep/2 ; ticklength := ticklength/2 ;
+%D drawticks unitsquare xscaled 4cm yscaled 3cm shifted (-1cm,-1cm) ;
+%D \stopreusableMPgraphic
+%D
+%D \startuseMPgraphic{demo}
+%D drawpoint "1cm,1.5cm" ;
+%D \stopuseMPgraphic
+%D
+%D \definelayer[mp][preset=mp]
+%D \setlayer[mp]{\reuseMPgraphic{axis}}
+%D \setlayer[mp]{\useMPgraphic{demo}}
+%D \ruledhbox{\flushlayer[mp]}
+%D \stoptyping
+
+%D \macros
+%D {startstaticMPfigure,useMPstaticfigure}
+%D
+%D Static figures are processed only when there has been
+%D something changed. Here is Aditya Mahajan's testcase:
+%D
+%D \startbuffer
+%D \startstaticMPfigure{circle}
+%D fill fullcircle scaled 1cm withcolor blue;
+%D \stopstaticMPfigure
+%D
+%D \startstaticMPfigure{axis}
+%D drawarrow (0,0)--(2cm,0) ;
+%D drawarrow (0,0)--(0,2cm) ;
+%D label.llft(textext("(0,0)") ,origin) ;
+%D \stopstaticMPfigure
+%D \stopbuffer
+%D
+%D \typebuffer \getbuffer
+
+\def\usestaticMPfigure[#1]%
+ {\dodoubleempty\externalfigure[\jobname-#1.pdf]}
+
+\def\startstaticMPfigure
+ {\begingroup
+ \obeyMPlines
+ \dostartstaticMPfigure}
+
+\def\dostartstaticMPfigure#1#2\stopstaticMPfigure
+ {\startstaticMPgraphic{\jobname-#1}#2\stopstaticMPgraphic
+ \endgroup}
+
+% faster, but more tricky
+%
+% \def\startstaticMPfigure
+% {\doifmodeelse{*\v!first}
+% {\begingroup
+% \obeyMPlines
+% \dostartstaticMPfigure}
+% {\gobbleuntil\stopstaticMPfigure}}
+%
+% \def\dostartstaticMPfigure#1#2\stopstaticMPfigure
+% {\startMPstaticgraphic{\jobname-#1}#2\stopMPstaticgraphic
+% % dirty trick, don't register, so no second main run of texexec:
+% \global\advance\nofMPgraphics \minusone
+% \endgroup}}
%D New:
% \appendtoks \closeMPgraphicfiles \to \everystoptext
+%D New:
+
+\newconditional\manyMPspecials % when set to true, > 1000 specials can be used
+
+\settrue \manyMPspecials % per 1/4/2006
+
+\prependtoks
+ _special_div_ := 1000\ifconditional\manyMPspecials0\fi ;
+\to \MPextensions
+
+%D Needed (will become default):
+
+\prependtoks
+ \resetlanguagespecifics
+\to \everyMPgraphic
+
+% Done.
+
\protect \endinput
+%D Experimental:
+
+\appendtoks
+ \ifrunMPgraphics \ifcase\systemcommandmode \or
+ \runMPgraphicsfalse
+ \fi \fi
+\to \everyjob
+
% also:
%
% linecap := rounded ;