MAJOR=13
MINOR=66
DEVNAME=input/event2
  7   #ˆl–Ãa¾””†»â‚Àµq—ÔÅ£�þBÙ@%›d!�e	üÿÖ„y÷ /ÕÅÒ ?÷     #%D \module
%D   [       file=supp-box,
%D        version=1995.10.10,
%D          title=\CONTEXT\ Support Macros,
%D       subtitle=Boxes,
%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 This module implements some box manipulation macros. Some
%D are quite simple, some are more advanced and when understood
%D well, all can be of use.

%D No longer generic, why bother.

\writestatus{loading}{ConTeXt Support Macros / Boxes}

\unprotect

%D \macros
%D   {strutdp,strutht,strutwd}
%D
%D The next shortcuts save memory and keying. The width is
%D normally zero points (if not, you're in trouble). These
%D shortcuts can be used like a dimension, opposite to the
%D core macros \type {\strutdepth} and alike, which are
%D values.

\def\strutdp{\dp\strutbox}
\def\strutht{\ht\strutbox}
\def\strutwd{\wd\strutbox}

%D \macros
%D   {resetbox, emptybox}
%D
%D Let's start with an easy one. The next macro hides the
%D ugly \type {@} in \type {\voidb@x}.

\ifx\voidbox\undefined      \newbox\voidbox \fi
\ifx\voidb@x\undefined \let\voidb@x\voidbox \fi

\def\emptybox  {\box   \voidbox}
\def\unvoidbox {\unhbox\voidbox}
\def\resetbox#1{\setbox#1\box\voidbox}

%D \macros
%D   {nextdepth}
%D
%D Let's start with a rather simple declaration. Sometimes we
%D need to save the \TEX\ \DIMENSION\ \type{\prevdepth} and
%D append it later on. The name \type{\nextdepth} suits
%D this purpose well.

\newdimen\nextdepth

%D \macros
%D   {smashbox, smashedbox}
%D
%D Smashing is introduced in \PLAIN\ \TEX, and stands for
%D reducing the dimensions of a box to zero. The most resolute
%D one is presented first.

\def\smashbox#1%
  {\wd#1\zeropoint
   \ht#1\zeropoint
   \dp#1\zeropoint}

\def\smashboxed#1%
  {\smashbox{#1}%
   \box#1\relax}

%D \macros
%D   {hsmashbox,vsmashbox}
%D
%D Smashing can be used for overlaying boxes. Depending on
%D the mode, horizontal or vertical, one can use:

\def\hsmashbox#1%
  {\wd#1\zeropoint}

\def\vsmashbox#1%
  {\ht#1\zeropoint
   \dp#1\zeropoint}

%D The next implementation is less sensitive for spurious
%D spaces.

\newcount\registercount

\def\smashbox
  {\afterassignment\dosmashbox\registercount}

\def\dosmashbox
  {\wd\registercount\zeropoint
   \ht\registercount\zeropoint
   \dp\registercount\zeropoint}

\def\smashedbox
  {\afterassignment\thesmashedbox\registercount}

\def\thesmashedbox
  {\dosmashbox
   \box\registercount}

\def\hsmashbox
  {\afterassignment\dohsmashbox\registercount}

\def\dohsmashbox
  {\wd\registercount\zeropoint}

\def\vsmashbox
  {\afterassignment\dovsmashbox\registercount}

\def\dovsmashbox
  {\ht\registercount\zeropoint
   \dp\registercount\zeropoint}

%D \macros
%D   {hsmash,vsmash,
%D    hsmashed,vsmashed}
%D
%D While the previous macros expected a \BOX, the next act on a
%D content. They are some subtle differences betreen the smash
%D and smashed alternatives. The later ones reduce all
%D dimensions to zero.

% Ok, but inefficient and/or catcode unsafe:
%
% \def\hsmash  #1{\bgroup\setbox0=\normalhbox{#1}\hsmashbox0\box0\egroup}
% \def\vsmash  #1{\bgroup\setbox0=\normalvbox{#1}\vsmashbox0\box0\egroup}
% \def\hsmashed#1{\bgroup\setbox0=\normalhbox{#1}\smashbox 0\box0\egroup}
% \def\vsmashed#1{\bgroup\setbox0=\normalvbox{#1}\smashbox 0\box0\egroup}
%
% Better, but a waste of tokens:
%
% \def\hsmash  {\bgroup\dowithnextbox{\hsmashbox\nextbox\flushnextbox\egroup}\normalhbox}
% \def\vsmash  {\bgroup\dowithnextbox{\vsmashbox\nextbox\flushnextbox\nextbox\egroup}\normalvbox}
% \def\hsmashed{\bgroup\dowithnextbox{\smashbox \nextbox\flushnextbox\nextbox\egroup}\normalhbox}
% \def\vsmashed{\bgroup\dowithnextbox{\smashbox \nextbox\flushnextbox\nextbox\egroup}\normalvbox}
%
% The best:

\def\dosomesmash#1% (begin|end)group ipv (b|e)group ?
  {\bgroup\dowithnextbox{#1\nextbox\flushnextbo