%^^A* copyright
% \iffalse
%
%   This program is part of the Frankenstein bundle for LaTeX2e.
%
%   Copyright (C) 1995, 1996 Matt Swift <swift@bu.edu>
%
%   This program is free software; you can redistribute it and/or modify
%   it under the terms of the GNU General Public License as published by
%   the Free Software Foundation; either version 2 of the License, or
%   (at your option) any later version.
%
%   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
%   GNU General Public License for more details.
%
%   You should have received a copy of the GNU General Public License
%   along with this program; if not, write to the Free Software
%   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
%
%      NOTE:  I am willing to specially license this code.
%             Please simply contact me with your proposal.
%
%^^A   NOTE:  \DocInput will start reading after this \fi:
% \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 dialogue
%   from a script.
% \end{abstract}
%   
% \part{Discussion}
%
% An example should be sufficient for most of the  documentation:
% \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!   % page 41
%
%     Estragon has exited offstage to right and left and come ``panting'' back
%     and fallen into Vladimir's arms.
%
%     \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.
%   \end{dialogue} 
% \end{bothexample} 
%
% \DescribeEnv{dialogue}
% 
% \DescribeMacro\speak
%   \cs\speak\marg{speaker}
%
% \DescribeMacro\direct
%   \cs\direct\marg{directions}
%
% \DescribeMacro\refer
%   \cs\direct\marg{speaker} 
%
% \DescribeMacro\ReferStyle
% \DescribeMacro\DirectStyle
% \DescribeMacro\DialogueLabel
% \DescribeMacro\PreDialogue
%
% \StopEventually{}
%
% \part{Implementation}
%
% \section{Version control}
%
%  \begin{macro}{\fileinfo}
%  \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\DoXNeeDME{}
\def\fileversion{v1.0}
\def\filedate{1996/04/11}
\def\docdate{1996/04/11}
\edef\PPOptArg {%
  \filedate\space \fileversion\space \fileinfo
}
%    \end{macrocode}
%  \end{macro}
%  \end{macro}
%  \end{macro}
%  \end{macro}
%  \end{macro}
%
% Stop right here if we're just loading the file's information, and don't want
% to load this code for typesetting its documentation (only makes sense for
% certain packages).  The |JuStLaAdInFoRmAtIoN| flag will be set by the
% documentation driver; the |DoXNeeDME| flag will be set in the
% \ext{dtx} file, and will appear above if it's set.
%    \begin{macrocode}
\makeatletter
\@ifundefined{JuStLoAdInFoRmAtIoN} {%
  }{% ELSE
  \@ifundefined{DoXNeeDME} {%
    }{% ELSE
    \UndefineCS\JuStLoAdInFoRmAtIoN
    \usepackage{dialogue}%
  }
  \makeatother
  \endinput
}
%    \end{macrocode}
%
% Now we check for \LaTeX2e and declare the package.
%    \begin{macrocode}
\NeedsTeXFormat{LaTeX2e}
\ProvidesPackage{dialogue}[\PPOptArg]
%    \end{macrocode}
%
% ^^A NOTE: We have to compensate for the above backslashes, which are not
% ^^A actually in the doctex file I work on.
%%
% \AddToCheckSum{26}
% 
% \makeatletter
%   \@ifundefined{DoXNeeDME} {} {\AddToCheckSum{2}}
% \makeatother
%
%
% \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 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;
%   I hope that the units will be relative to the current size \emph{in} the
%   environment, not the current size when the setting is done. FIX: check.
%    \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
