summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/latex/asyfig/asyprocess.sty
blob: 718d4d4ac3ebd7ccf938ffbb236a4f4cbd97ecba (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
%% LaTeX2e file `asyprocess.sty'
%% generated by the `filecontents' environment
%% from source `asyfig' on 2010/03/20.
%%
\ProvidesPackage{asyprocess}
\nofiles

\RequirePackage{ifmtarg,ifpdf,catchfile,ifplatform,color,graphicx}
\RequirePackage[active,tightpage]{preview}

\def\@par@macro{\par}

\def\asy@status{asyprocess-statusfile.txt}

\edef\@tempa{\detokenize{-comp}}
\@temptokena{\def\asy@strip@comp#1}
\expandafter\the\expandafter\@temptokena\@tempa#2\@nil{%
  \@ifmtarg{#2}{%
    \errorstopmode
    \PackageError{asyprocess}{%
      The \string\jobname\space of this compilation must end with `-comp'%
    }{%
      You must set the \cmd\jobname\ with the equivalent of^^J\space\space
      pdflatex -jobname=XYZ-comp ...%
    }
  }{}%
  \edef\asy@compname{#1}}
\expandafter\expandafter\expandafter
  \asy@strip@comp\expandafter\jobname\@tempa\@nil

\newcommand\ProcessAsy{%
  \immediate\write18{%
    asy -wait -inlinetex -noprc -render 0 -tex \ifpdf pdf\fi latex
      \asy@compname\space 2> \asy@status}%
  \CatchFileDef{\@tempb}{\asy@status}{}%
  \immediate\write18{\ifwindows del \else rm \fi \asy@status}
  \ifx\@tempb\@par@macro
    \expandafter\@gobble
  \else
    \g@addto@macro\@tempb{^^J^^J%
      ------------ ASY ERROR ------------^^J%
      -----------------------------------}%
    \expandafter\@firstofone
  \fi{%
     \errorstopmode
     \typeout{%
       -----------------------------------^^J%
       ------------ ASY ERROR ------------^^J}
     \typeout{\expandafter\strip@prefix\meaning\@tempb}
     \batchmode
     \end{document}}}

\newcommand\ShowAsy{%
  \begin{preview}
    \input{\asy@compname_}
  \end{preview}}

\AtBeginDocument{\InputIfFileExists{\asy@compname_.pre}{}{}}