%^^A* legal notices
% \iffalse
%
%   This program is part of the Frankenstein bundle for LaTeX.  
%
%   Copyright 1995-2001 Matt Swift <swift@alum.mit.edu>.
%
%   This file contains both the code and documentation for the
%   dialogue LaTeX package.  It will work ONLY if it is placed in a
%   proper directory.  Files called README, INSTALL, dialogue.tex
%   and dialogue.ins should have also been distributed to you
%   with this file.  See them for more information on how to typeset
%   the documentation with LaTeX and how to generate a version of this
%   file that will work faster than this one.
%
%   This program is free software; you may redistribute it and/or
%   modify it under the conditions of the LaTeX Project Public
%   License, either version 1.2 or (at your option) any later version.
%   The latest version of this license is in
%   http://www.latex-project.org/lppl.txt, and version 1.2 or later is
%   part of all distributions of LaTeX version 1999/12/01 or later.
%
%   This program is distributed in the hope that it will be useful,
%   but without any warranty; without even the implied warranty of
%   merchantability or fitness for a particular purpose.  See the
%   LaTeX Project Public License for more details.
%
% \fi  
%
%^^A* checks
%
%^^A NOTE:  The character table, with two %'s, will get written to all files.
%% \CharacterTable
%%  {Upper-case    \A\B\C\D\E\F\G\H\I\J\K\L\M\N\O\P\Q\R\S\T\U\V\W\X\Y\Z
%%   Lower-case    \a\b\c\d\e\f\g\h\i\j\k\l\m\n\o\p\q\r\s\t\u\v\w\x\y\z
%%   Digits        \0\1\2\3\4\5\6\7\8\9
%%   Exclamation   \!     Double quote  \"     Hash (number) \#
%%   Dollar        \$     Percent       \%     Ampersand     \&
%%   Acute accent  \'     Left paren    \(     Right paren   \)
%%   Asterisk      \*     Plus          \+     Comma         \,
%%   Minus         \-     Point         \.     Solidus       \/
%%   Colon         \:     Semicolon     \;     Less than     \<
%%   Equals        \=     Greater than  \>     Question mark \?
%%   Commercial at \@     Left bracket  \[     Backslash     \\
%%   Right bracket \]     Circumflex    \^     Underscore    \_
%%   Grave accent  \`     Left brace    \{     Vertical bar  \|
%%   Right brace   \}     Tilde         \~}
%
% \CheckSum{43}
%
%^^A** abstract
% \begin{abstract}
%   The \env{dialogue} environment is for citing short passages of scripted
%   dialogue.  It is not for typsetting a long script.
% \end{abstract}
% \tableofcontents
%   
% \part{Discussion}
%
% \section{Dialogue}
%
% An example will have to suffice for most documentation at the moment.
% \cs\attrib is defined in the \package{attrib} package, also in the
% \Frankenstein bundle.
% \begin{bothexample}
%   \begin{dialogue}
%     \speak{Vladimir} Whare are all these corpses from?
%     \speak{Estragon} These skeletons.
%     \par\lips\par
%     \speak{Vladimir} A charnel-house!  A charnel-house!
%     
%     \attrib{\play{Waiting for Godot}, 41 \normalcitations\cite{beckett:godot}}
%
%     \medskip
%     \direct{
%     Estragon has exited offstage to right and left and come ``panting'' back
%     and fallen into Vladimir's arms.  \emph{---Ed.}
%     }
%     \speak{Estragon} I'm in hell!
%     \speak{Vladimir} Where were you?
%     \speak{Estragon} They're coming there too!
%     \speak{Vladimir} We're surrounded! \direct{\refer{Estragon} makes a rush
%                      towards back.}  Imbecile!  There's no way out there.
%                      \direct{\refer{He} takes \refer{Estragon} by the arms
%                      and drags him towards front.  Gesture towards front.}
%                      There!  Not a soul in sight!  Off you go!  Quick!
%                      \direct{\refer{He} pushes \refer{Estragon} towards
%                      auditorium.  \refer{Estragon} recoils in horror.}  You
%                      won't?  \direct{\refer{He} contemplates auditorium.}
%                      Well I can understand that.  Wait till I see.
%                      \direct{\refer{He} reflects.}  Your only hope left is to
%                      disappear.
%   
%     \attrib{47}
%   \end{dialogue} 
% \end{bothexample} 
%
% \DescribeMacro\direct
%   \cs\direct\marg{directions}  Inline stage directions.  Can be used anywhere.
%
% \DescribeMacro\refer
%   \cs\refer\marg{speaker} Refer to a character in a play.  Can be used anywhere.
% 
% \DescribeEnv{dialogue}
%   Inside the \env{dialogue} environment, commands \cs\direct, and \cs\refer
%   behave differently, but have the same function.
% 
% \DescribeMacro\speak
%   \cs\speak\marg{speaker}  Introduce the speech of speaker \meta{speaker}
%   within a \env{dialogue} environment.
%
% \section{Programmer's interface}
%
% \DescribeMacro\ReferStyle
% \DescribeMacro\DirectStyle
% \DescribeMacro\DialogueLabel
% \DescribeMacro\PreDialogue
%
%   These macros are available for adjusting the behavior of the user
%   commands.  I'm afraid you'll have to read the (easy) code until I write
%   better documentation.
%
% \StopEventually{}
%
% \part{Implementation}
%
% \section{Version control}
%
%  \begin{macro}{\fileinfo}
%  \begin{macro}{\DoXUsepackagE}
%  \begin{macro}{\HaveECitationS}
%  \begin{macro}{\fileversion}
%  \begin{macro}{\filedate}
%  \begin{macro}{\docdate}
%  \begin{macro}{\PPOptArg}
% These definitions must be the first ones in the file.
%    \begin{macrocode}
\def\fileinfo{dialogue environment (Frankenstein's mouth)}
\def\DoXPackageS {dialogue,attrib}
\def\initelyHavECitationS {}
\def\fileversion{v1.1}
\def\filedate{1999/03/01}
\def\docdate{1996/04/11}
\edef\PPOptArg {%
  \filedate\space \fileversion\space \fileinfo
}
%    \end{macrocode}
%  \end{macro}
%  \end{macro}
%  \end{macro}
%  \end{macro}
%  \end{macro}
%  \end{macro}
%  \end{macro}
%
% If we're loading this file from a \cs\ProcessDTXFile command (see the
% \package{compsci} package), then \cs\JusTLoaDInformatioN will be defined;
% othewise we assume it is not (that's why the FunkY NamE).
% 
% If we're loading from \cs\ProcessDTXFile, we want to load the packages listed
% in \cs\DoXPackageS (needed to typeset the documentation for this file) and
% then bail out.  Otherwise, we're using this file in a normal way as a
% package, so do nothing.  \cs\DoXPackageS, if there are any, are declared in
% the \ext{dtx} file, and, if you're reading the typeset documentation of this
% package, would appear just above.  (It's OK to call \cs\usepackage with an
% empty argument or \cs\relax, by the way.)
%    \begin{macrocode}
\makeatletter% A special comment to help create bst files.  Don't change!
\@ifundefined{JusTLoaDInformatioN} {%
  }{% ELSE (we know the compsci package is already loaded, too)
  \UndefineCS\JusTLoaDInformatioN
  \SaveDoXVarS
  \eExpand\csname DoXPackageS\endcsname\In {%use \csname in case it's undefined
    \usepackage{#1}%
  }%
  \RestoreDoXVarS
  \makeatother
  \endinput
}% A special comment to help create bst files.  Don't change!
%    \end{macrocode}
%
% Now we check for \LaTeX2e and declare the LaTeX package.
%    \begin{macrocode}
\NeedsTeXFormat{LaTeX2e}
\ProvidesPackage{dialogue}[\PPOptArg]
%    \end{macrocode}^^A special comment to help create bst files.  Don't change!
%
% ^^A NOTE: We have to compensate for the above backslashes, which are not
% ^^A       actually in the .dtx file the author works on, by adding to the
% ^^A       CheckSum.
%%
% \AddToCheckSum{17}^^A `dtx-update-checksum' automatically handles this.
% \AddToCheckSum{7}^^A The half a macrocode env. at the top is missed, however...
% \AddToCheckSum{10}^^A ... and so are the 5 \defs from the .dtx file 
%                   ^^A     that precede it.
% \IfCitations {%
%   \AddToCheckSum{2}^^A When \initelyHavECitationS is defined in
% }                  ^^A the .dtx file, we need 2 more in the CheckSum.
%
%
% \section{Requirements}
% 
%    \begin{macrocode}
\RequirePackage{blkcntrl,moredefs,relsize}
%    \end{macrocode}
%
% \section{The macros}
%
% The standard classes set \cs\partopsep, \cs\parsep, \cs\topsep, and
% \cs\itemsep to positive values.  \cs\leftmargin goes to |2.5em| in
% onecolumn.  \cs\labelsep is |.5em|; \cs\labelwidth = \cs\leftmargin -
% \cs\labelsep.
%
% \begin{macro}{\refer}
% \begin{macro}{\ReferStyle}
% \begin{macro}{\direct}
% \begin{macro}{\DirectStyle}
%   \mbox{}
%    \begin{macrocode}
\NewTextFontCommand\refer\ReferStyle

\newcommand\ReferStyle {%
  \scshape
}
\newcommand\direct [1] {%
  [{\DirectStyle #1}]%
}
\newcommand\DirectStyle {%
  \relsize{-1}%
  \slshape
}
%    \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\DialogueLabel}
% \begin{macro}{\PreDialogue}
% \begin{environment}{dialogue}
%   The first line of a new speaker has the speaker's name flush with the left
%   margin of the surrounding text, then the default \cs\labelsep, then the
%   first line of dialogue.  Subsequent lines all begin |2.5em| in, and end
%   |2.5em| before the surrounding text.  Interparagraph space is the same as
%   the surrounding text's.  Extra positive stretchability of |.5ex| is added
%   between speakers.  \todo{Ensure that the units will be relative to the current
%   size \emph{in} the environment, not the current size when the setting is
%   done.}
%    \begin{macrocode}
\newcommand*\DialogueLabel [1] {%
  \scshape\lowercase{#1}:\hfil
}
\newcommand\PreDialogue {%
  \PreChunk
}
\newenvironment{dialogue} {%
    \begin{list}{} {%
        \setlength\itemsep{\z@ \@plus .5ex}%
        \setlength\parsep{\parskip}%
        \setlength\rightmargin{\leftmargin}%
        \defcommand\speak [1] {\item[{##1}]}%
        \let\makelabel\DialogueLabel
      }%
      \PreDialogue\relax
    }{%
  \end{list}%
  }
%    \end{macrocode}
%  \end{environment}
%  \end{macro}
%  \end{macro}
%
% \Finale