diff options
Diffstat (limited to 'Master/texmf-dist/tex/context/base/core-buf.mkii')
-rw-r--r-- | Master/texmf-dist/tex/context/base/core-buf.mkii | 143 |
1 files changed, 143 insertions, 0 deletions
diff --git a/Master/texmf-dist/tex/context/base/core-buf.mkii b/Master/texmf-dist/tex/context/base/core-buf.mkii new file mode 100644 index 00000000000..9a803764cfd --- /dev/null +++ b/Master/texmf-dist/tex/context/base/core-buf.mkii @@ -0,0 +1,143 @@ +%D \module +%D [ file=core-buf, % blocks are moved to core-blk +%D version=2000.01.05, +%D title=\CONTEXT\ Core Macros, +%D subtitle=Buffers, +%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. + +\unprotect + +\def\mkresetbuffer + {\unlinkfile{\TEXbufferfile\currentbuffer}} + +\long\def\mksetbuffer#1% + {\edef\bufferfilename{\TEXbufferfile{\currentbuffer}}% + \immediate\openout\tmpblocks\bufferfilename + \convertargument#1\to\ascii + \immediate\write\tmpblocks{\ascii}% + \immediate\closeout\tmpblocks} + +\def\mkstartbuffer#1#2#3#4#5% ook grabben a la mkiv / no, we need to add par anchors + {\doifelsenothing{#4} + {\letbeundefined{\e!stop\v!buffer}% % \let\stopbuffer=\relax % \undefined + \@EA\@EA\@EA\convertargument\@EA\e!start\v!buffer\to\beginofblock % else a space + \@EA\@EA\@EA\convertargument\@EA\e!stop \v!buffer\to\endofblock + \ifcase\buffernestmode + \let\processnextbufferline\processnextbufferlineB + \else + \let\processnextbufferline\processnextbufferlineA + \fi} + {\letbeundefined{#4}% \letvalue{#4}=\relax % \undefined + \@EA\convertargument\csname#3\endcsname\to\beginofblock + \@EA\convertargument\csname#4\endcsname\to\endofblock + \ifcase\buffernestmode + \let\processnextbufferline\processnextbufferlineB + \or + \let\processnextbufferline\processnextbufferlineB + \else + \let\processnextbufferline\processnextbufferlineA + \fi}% + \def\closebufferfile + {\ifsegmentatebuffer + \immediate\write\tmpblocks{\string\stopbufferparagraph}% + \fi + \immediate\closeout\tmpblocks + #5% \egroup + \getvalue{#4}}% + \doifelsenothing{#2} + {\edef\bufferfilename{\TEXbufferfile\jobname}}% + {\edef\bufferfilename{\TEXbufferfile{#2}}}% + \immediate\openout\tmpblocks\bufferfilename + \ifsegmentatebuffer + \immediate\write\tmpblocks{\string\startbufferparagraph}% + \fi + \newcounter\nestedbufferlevel + \recatcodeuppercharacterstrue + \setcatcodetable\vrbcatcodes + \obeylines + \copybufferline} + +\def\mkdobuffer#1% command + {\beginrestorecatcodes + #1% + \endrestorecatcodes} + +\def\mkgetbuffer {\readjobfile{\TEXbufferfile{\currentbuffer}}\donothing\donothing} +\def\mktypebuffer{\typefile{\TEXbufferfile{\currentbuffer}}} + +% support macros + +\expandafter \convertargument \gobbleoneargument @ \to \emptybufferline + +\ifx\tmpblocks\undefined \newwrite\tmpblocks \fi + +\newif\iftmpblockstarted + +\def\flushbufferline#1% + {\iftmpblockstarted + \ifsegmentatebuffer + \ifemptybufferline + \immediate\write\tmpblocks{\string\stopbufferparagraph }% + \immediate\write\tmpblocks{\string\startbufferparagraph}% + \else + \immediate\write\tmpblocks{#1}% + \fi + \else + \immediate\write\tmpblocks{#1}% + \fi + \else + \doifsomething{#1} + {\tmpblockstartedtrue + \immediate\write\tmpblocks{\string#1}}% + \fi} + +\long\def\processnextbufferlineA#1% + {\relax % checken waarom eerdere macro dit nodig heeft / supp-mps run + \convertargument#1 \to\next + \doifinstringelse{\delcharacter\letterpercent}{\delcharacter\next} + {\secondoftwoarguments} + {\doifincsnameelse\endofblock\next + {\ifnum\nestedbufferlevel=\zerocount + \expandafter\firstoftwoarguments + \else + \decrement\nestedbufferlevel\relax + \expandafter\secondoftwoarguments + \fi} + {\doifincsnameelse\beginofblock\next + {\increment\nestedbufferlevel\relax + \secondoftwoarguments} + {\secondoftwoarguments}}}} + +\long\def\processnextbufferlineB#1% #2#3% + {\convertargument#1 \to\next + \ifx\next\emptybufferline + \ifsegmentatebuffer \emptybufferlinetrue \fi + \expandafter\secondoftwoarguments% #3% + \else + \emptybufferlinefalse + \doifinstringelse\endofblock\next + {\expandafter\firstoftwoarguments }% #2} + {\expandafter\secondoftwoarguments}% #3}% + \fi} + +\bgroup +\obeylines +\long\gdef\copybufferline#1 + {\processnextbufferline{#1}\closebufferfile{\flushbufferline{#1}\copybufferline}} +\egroup + +% kind of obsolete with mkiv + +\def\mkstartmemorybuffer + {\dosingleempty\dostartmemorybuffer} + +\long\def\dostartmemorybuffer[#1]#2\stopbuffer + {\setbuffer[#1]#2\endbuffer} + +\protect \endinput |