%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 \defconvertedargument\ascii{#1}% \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 \edefconvertedargument\beginofblock{\e!start\v!buffer}% \edefconvertedargument\endofblock {\e!stop \v!buffer}% \ifcase\buffernestmode \let\processnextbufferline\processnextbufferlineB \else \let\processnextbufferline\processnextbufferlineA \fi} {\letbeundefined{#4}% \letvalue{#4}=\relax % \undefined \@EA\defconvertedargument\@EA\beginofblock\@EA{\csname#3\endcsname}% we could use defconvertedcommand here (no \@EA) \@EA\defconvertedargument\@EA\endofblock \@EA{\csname#4\endcsname}% we could use defconvertedcommand here (no \@EA) \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 \edefconvertedargument\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 \defconvertedargument\next{#1 }% \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% {\defconvertedargument\next{#1 }% \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