%D \module
%D   [       file=catc-def,
%D        version=2006.09.18,
%D          title=\CONTEXT\ Catcode Macros,
%D       subtitle=Default Tables,
%D         author=Hans Hagen,
%D           date=\currentdate,
%D      copyright={PRAGMA ADE \& \CONTEXT\ Development Team}]
%C
%C This module is part of the \CONTEXT\ macro||package and is
%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
%C details.

%D The following catcode tables are rather \CONTEXT\ independent.

\ifdefined\nilcatcodes \else \newcatcodetable \nilcatcodes  \fi
\ifdefined\texcatcodes \else \newcatcodetable \texcatcodes  \fi
\ifdefined\luacatcodes \else \newcatcodetable \luacatcodes  \fi
\ifdefined\notcatcodes \else \newcatcodetable \notcatcodes  \fi
\ifdefined\vrbcatcodes \else \newcatcodetable \vrbcatcodes  \fi
\ifdefined\prtcatcodes \else \newcatcodetable \prtcatcodes  \fi

\startcatcodetable \nilcatcodes
    \catcode\tabasciicode       \spacecatcode
    \catcode\endoflineasciicode \endoflinecatcode
    \catcode\formfeedasciicode  \endoflinecatcode
    \catcode\spaceasciicode     \spacecatcode
    \catcode\endoffileasciicode \ignorecatcode
\stopcatcodetable

\startcatcodetable \texcatcodes
    \catcode\tabasciicode       \spacecatcode
    \catcode\endoflineasciicode \endoflinecatcode
    \catcode\formfeedasciicode  \endoflinecatcode
    \catcode\spaceasciicode     \spacecatcode
    \catcode\endoffileasciicode \ignorecatcode
    \catcode\circumflexasciicode\superscriptcatcode
    \catcode\underscoreasciicode\subscriptcatcode
    \catcode\ampersandasciicode \alignmentcatcode
    \catcode\backslashasciicode \escapecatcode
    \catcode\leftbraceasciicode \begingroupcatcode
    \catcode\rightbraceasciicode\endgroupcatcode
    \catcode\dollarasciicode    \mathshiftcatcode
    \catcode\hashasciicode      \parametercatcode
    \catcode\commentasciicode   \commentcatcode
\stopcatcodetable

\startcatcodetable \luacatcodes
    \catcode\tabasciicode       \othercatcode
    \catcode\endoflineasciicode \othercatcode
    \catcode\formfeedasciicode  \othercatcode
    \catcode\spaceasciicode     \othercatcode
    \catcode\endoffileasciicode \ignorecatcode
    \catcode\circumflexasciicode\othercatcode
    \catcode\underscoreasciicode\othercatcode
    \catcode\ampersandasciicode \othercatcode
    \catcode\backslashasciicode \escapecatcode
    \catcode\commentasciicode   \othercatcode
    \catcode\hashasciicode      \othercatcode
    \catcode\barasciicode       \othercatcode
    \catcode\leftbraceasciicode \othercatcode
    \catcode\rightbraceasciicode\othercatcode
    \catcode\tildeasciicode     \othercatcode
    \catcode\dollarasciicode    \othercatcode
\stopcatcodetable

\startcatcodetable \notcatcodes % probably less needed
    \catcode\tabasciicode         \spacecatcode
    \catcode\endoflineasciicode   \endoflinecatcode
    \catcode\formfeedasciicode    \endoflinecatcode
    \catcode\spaceasciicode       \spacecatcode
    \catcode\endoffileasciicode   \ignorecatcode
    \catcode\circumflexasciicode  \othercatcode
    \catcode\underscoreasciicode  \othercatcode
    \catcode\ampersandasciicode   \othercatcode
    \catcode\tildeasciicode       \othercatcode
    \catcode\hashasciicode        \othercatcode
    \catcode\dollarasciicode      \othercatcode
    \catcode\commentasciicode     \othercatcode
    \catcode\lessthanasciicode    \othercatcode
    \catcode\morethanasciicode    \othercatcode
    \catcode\leftbraceasciicode   \othercatcode
    \catcode\rightbraceasciicode  \othercatcode
    \catcode\doublequoteasciicode \othercatcode
    \catcode\singlequoteasciicode \othercatcode
    \catcode\forwardslashasciicode\othercatcode
    \catcode\backslashasciicode   \othercatcode
    \catcode\barasciicode         \othercatcode
\stopcatcodetable

\startcatcodetable \vrbcatcodes % probably less needed
    \catcode\tabasciicode      \othercatcode
    \catcode\endoflineasciicode\othercatcode
    \catcode\formfeedasciicode \othercatcode
    \catcode\spaceasciicode    \othercatcode
    \catcode\endoffileasciicode\othercatcode
\stopcatcodetable

\startcatcodetable \prtcatcodes
    \catcode\tabasciicode            \spacecatcode
    \catcode\endoflineasciicode      \endoflinecatcode
    \catcode\formfeedasciicode       \endoflinecatcode
    \catcode\spaceasciicode          \spacecatcode
    \catcode\endoffileasciicode      \ignorecatcode
    \catcode\circumflexasciicode     \superscriptcatcode
    %catcode\underscoreasciicode     \subscriptcatcode
    \catcode\underscoreasciicode     \lettercatcode
    \catcode\ampersandasciicode      \alignmentcatcode
    \catcode\backslashasciicode      \escapecatcode
    \catcode\leftbraceasciicode      \begingroupcatcode
    \catcode\rightbraceasciicode     \endgroupcatcode
    \catcode\dollarasciicode         \mathshiftcatcode
    \catcode\hashasciicode           \parametercatcode
    \catcode\commentasciicode        \commentcatcode
    \catcode\atsignasciicode         \lettercatcode
    \catcode\exclamationmarkasciicode\lettercatcode
    \catcode\questionmarkasciicode   \lettercatcode
    \catcode\tildeasciicode          \activecatcode
    \catcode\barasciicode            \activecatcode
\stopcatcodetable

%D Because some characters have a special meaning, we provide
%D shortcuts to their character representation.

\chardef \^ = \circumflexasciicode
\chardef \_ = \underscoreasciicode
\chardef \& = \ampersandasciicode
\chardef \% = \commentasciicode
\chardef \# = \hashasciicode
\chardef \$ = \dollarasciicode
\chardef \{ = \leftbraceasciicode
\chardef \} = \rightbraceasciicode
\chardef \\ = \backslashasciicode
\chardef \| = \barasciicode

% way too wide in lm, so one can also use:
%
% \def\_{\dontleavehmode \kern.06em \vbox{\hrule width.3em}} % this will become a \chardef

%D From now on we can use the protection mechanisms.

\normalprotected\def\unprotect{\pushcatcodetable\setcatcodetable\prtcatcodes}
\normalprotected\def\protect  {\popcatcodetable}

% \prependtoks \catcodetable\ctxcatcodes \to \everyjob

\endinput
