%D \module
%D   [       file=supp-dir,
%D        version=2004.11.11,
%D          title=\CONTEXT\ Support Macros,
%D       subtitle=Directional Things,
%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.

\unprotect

% \immutable\chardef\directionlefttoright\zerocount
% \immutable\chardef\directionrighttoleft\plusone

\setnewconstant\directionlefttoright\zerocount
\setnewconstant\directionrighttoleft\plusone

\immutable\edef\??bdir{\ifdefined\bodydir bdir\else direction\fi}

\permanent\protected\edef\naturalhbox  {\hbox  \??bdir\directionlefttoright}
\permanent\protected\edef\naturalvbox  {\vbox  \??bdir\directionlefttoright}
\permanent\protected\edef\naturalvtop  {\vtop  \??bdir\directionlefttoright}
\permanent\protected\edef\naturalhpack {\hpack \??bdir\directionlefttoright}
\permanent\protected\edef\naturalvpack {\vpack \??bdir\directionlefttoright}
\permanent\protected\edef\naturaltpack {\tpack \??bdir\directionlefttoright}

\permanent\protected\edef\reversehbox  {\hbox  \??bdir\directionrighttoleft}
\permanent\protected\edef\reversevbox  {\vbox  \??bdir\directionrighttoleft}
\permanent\protected\edef\reversevtop  {\vtop  \??bdir\directionrighttoleft}
\permanent\protected\edef\reversehpack {\hpack \??bdir\directionrighttoleft}
\permanent\protected\edef\reversevpack {\vpack \??bdir\directionrighttoleft}
\permanent\protected\edef\reversetpack {\tpack \??bdir\directionrighttoleft}

% \expanded{\defineactivecharacter \number"2000E} {\textdirection\directionrighttoleft\relax}
% \expanded{\defineactivecharacter \number"2000F} {\textdirection\directionlefttoright\relax}

\def\syst_direction_string#1{\ifcase#1=\plusone r2l\else l2r\fi}

\permanent\protected\def\showdirsinmargin
  {\normalexpanded{\inleft{\naturalhbox
     {\ttxx[\syst_direction_string\pardirection,\syst_direction_string\textdirection]}}}}

\protect \endinput
