core-var.mkii / last modification: 2020-01-30 14:15
%D \module
%D   [       file=core-var,
%D        version=1998.02.21,
%D          title=\CONTEXT\ Core Macros,
%D       subtitle=Variables,
%D         author=Hans Hagen,
%D           date=\currentdate,
%D      copyright={PRAGMA ADE \& \CONTEXT\ Development Team}]
%C This module is part of the \CONTEXT\ macro||package and is
%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
%C details.

\writestatus{loading}{ConTeXt Core Macros / Variables}


%D We introduce a couple of variables that are used all over
%D \CONTEXT. Alternatively we could define them in each module
%D but as they are part of the bigger picture we prefer to do
%D it here.

%D \macros
%D   {every...}
%D A few every's. Some are only used in \MKII\ or \MKIV.

%D Output routine:

\newtoks \everybeforeoutput
\newtoks \everyafteroutput

%D Shipout:

\newtoks \everyshipout
\newtoks \everybeforeshipout
\newtoks \everyaftershipout
\newtoks \everyfirstshipout
\newtoks \everylastshipout

%D End of run:

\newtoks \everybye
\newtoks \everygoodbye
\newtoks \everynotabene

%D Document

\newtoks \everysetupdocument
\newtoks \everyendoftextbody

\newtoks \everystarttext
\newtoks \everystoptext

%D Purity:

\newtoks \everyforgetall
\newtoks \everycleanupfeatures

\def\forgetall      {\the\everyforgetall}

%D Page building:

\newtoks \everybeforepagebody
\newtoks \everyafterpagebody

\let \everypagebody \everybeforepagebody % backward compatible

%D Multipass:

\newtoks \everybeforeutilityread
\newtoks \everyafterutilityread

%D Floats:

\newtoks \everyinsidefloat

%D Sectioning:

\newtoks \everyheadstart

%D Par building (experimental, used in xml <p> .. </p>)

\newtoks \everybeginofpar
\newtoks \everyendofpar
%newtoks \everyparflush

\def\bpar{\the\everybeginofpar\ignorespaces} % may interfere with \everypar
\def\epar{\ifhmode\removeunwantedspaces\the\everyendofpar\fi} % test prevents problems with \bpar\epar

%D Lists:

\newtoks \everylistentry
\newtoks \everysavesortkeys

%D Marks:

\newtoks \everymarking

%D Fonts:

\newtoks \everyfont
\newtoks \everyglobalbodyfont
\newtoks \everydefinedfont

\newevery \everybodyfont   \EveryBodyFont
\newevery \everyfontswitch \EveryFontSwitch

%D Math:

\newtoks \everybeforedisplayformula
\newtoks \everymathematics

\prependtoks \the\everymathematics \to \everymath
\prependtoks \the\everymathematics \to \everydisplay

%D Tables

\newtoks \everytable

%D State mess:

\newtoks \everypushsomestate
\newtoks \everypopsomestate

\def\popsomestates {\the\everypopsomestate }

%D More generic (used to be pushcolor etc)



\def\pushproperties     {\the\everypushproperties}
\def\popproperties      {\the\everypopproperties}
\def\popsplitproperties {\the\everypopsplitproperties}

\def\stoptextproperties {\the\everystoptextproperties}

%D This is pretty important (esp since we now ignore shipouts).
%D Actually we should nil all writes, marks, specials.

\appendtoks \globallet\popproperties     \relax \to \everylastshipout
\appendtoks \globallet\popsplitproperties\relax \to \everylastshipout

%D \macros
%D   {defineinputmode,setinputmode}
%D New. Some work needs to be done.

% not in mkiv

\def\defineinputmode[#1]{\@EA\newtoks\csname every#1inputmode\endcsname}
\def\setinputmode   [#1]{\the\executeifdefined{every#1inputmode}\emptytoks}

\defineinputmode [TEX]
\defineinputmode [XML]

\setinputmode    [TEX]

%D \macros
%D   {trialtypesetting}
%D We disable trial typesetting in the output routine,
%D just to be sure.


\prependtoks \trialtypesettingfalse \to \everybeforepagebody

%D \macros
%D   {ifinpagebody,ifinsidecolumns,ifdoublesided,ifsinglesided}

\newif \ifinpagebody
\newif \ifinsidecolumns
\newif \ifdoublesided   \doublesidedfalse
\newif \ifsinglesided   \singlesidedtrue
\newif \ifinsidefloat
\newif \ifdoingblocks
\newif \ifgridsnapping

%D \macros
%D   {ifprocessingXML}
%D We need this one even if no \XML\ is supported.

\newif\ifprocessingXML % old way

%D \macros
%D   {ifproductionrun}
%D This boolean can be used to bypass certain
%D initializations.

\ifx\protectionlevel\undefined \newcount\protectionlevel \fi


\appendtoks \productionruntrue \to \everydump

\appendtoks \ifcase\protectionlevel\else\reportunprotection\fi \to \everydump

%D \macros
%D   {everyboxedcontent, ifboxedcontent,
%D    startboxedcontent, stopboxedcontent}
%D This one is relatively new and will be used as a more
%D robust test for inner situations.

\newif  \ifboxedcontent

\appendtoks \boxedcontenttrue \to \everyboxedcontent

\let\stopboxedcontent  \egroup

%D \macros
%D   {fastmode,silentmode}
%D These commands are obsolete.

\let\fastmode  \relax

%D \macros
%D   {defineselector,setupselector}
%D \starttyping
%D \defineselector[caption][max=2,n=2]
%D \start
%D     \setupselector[caption][n=1]
%D     \placelist[figure][criterium=all]
%D \stop
%D \starttext
%D     \placefigure
%D       {\select{caption}{zapf}{\input zapf \relax}}
%D       {}
%D \stoptext
%D \stoptyping

\def\setupselector {\dodoubleargument\dosetupselector}

\def\dosetupselector [#1][#2]{\getparameters[\??sx#1][#2]}

     {\executeifdefined{\??sx#1\c!n  }1}}

%D We store some original meanings, maybe in \type
%D {math-ini}.

\let\normalat   \at
\let\normalin   \in
\let\normalfrom \from
%let\normalover \over

%D Add-ons:

\let\stoplayoutcomponent \relax
%D Concepts:



\protect \endinput