%%
%% This file was generated by the docstrip utility from guitar.dtx.
%% You may distribute this file only together with the source guitar.dtx
%% (and if possible with guitar.ins) and only if these files are unmodified.
%%
%% Author:
%%
%% M. V\"ath      vaeth@mathematik.uni-wuerzburg.de
%%

\ifx\typeout\undefined
  \def\tbx@tmp{\immediate\write17}\expandafter\tbx@tmp
\else
  \expandafter\typeout
\fi{guitar.sty by M. Vaeth: Guitar chords over song texts 1.6}

\ifx\ProvidesPackage\undefined\else
  \ProvidesPackage{guitar}[2009/03/17 v1.6]
\fi
\ifx\RequirePackage\undefined
  \ifx\toolboxDef\undefined
    \input toolbox.sty
  \fi
\else
  \RequirePackage{toolbox}[2001/04/08]
\fi
\ifx\toolboxIfNextGobbling\undefined
  \errmessage{guitar.sty requires toolbox.sty version 2.0 or higher}
\fi

\ifx\newenvironment\undefined\else
  \newenvironment{guitar}{\guitarOn}{\guitarOff}
  \newenvironment{guitarMagic}{\guitarMagicOn}{\guitarMagicOff}
  \newenvironment{guitarCr}{\guitarCrOn}{\guitarCrOff}
\fi

\ifx\newcommand\undefined\else
  \newcommand{\guitarChord}{}

  \newcommand{\guitarOn}{}
  \newcommand{\guitarOff}{}
  \newcommand{\guitarMagicOn}{}
  \newcommand{\guitarMagicOff}{}
  \newcommand{\guitarCrOn}{}
  \newcommand{\guitarCrOff}{}

  \newcommand{\guitarSharp}{}
  \newcommand{\guitarFlat}{}
  \newcommand{\guitarMagicOnHook}{}
  \newcommand{\guitarMagicOffHook}{}
  \newcommand{\guitarCrOnHook}{}
  \newcommand{\guitarCrOffHook}{}
  \newcommand{\guitarEndLine}{}
  \newcommand{\guitarEndPar}{}
  \newcommand{\guitarEndDoublePar}{}
  \newcommand{\guitarCalcDim}{}
  \newcommand{\guitarPreAccord}{}

  \newcommand{\guitarPut}{}
  \newcommand{\guitarPutOnSpace}{}
  \newcommand{\guitarPutDist}{}
  \newcommand{\guitarPutMerge}{}

  \newcommand{\guitarNoChord}{}

  \newcommand{\guitarAccord}{}
  \newcommand{\guitarSplitDist}{}
  \newcommand{\guitarSplitMerge}{}
\fi

\ifx\newsavebox\undefined
  \newbox\guitarBox
\else
  \newsavebox{\guitarBox}
\fi
\ifx\newlength\undefined
  \newskip\guitarDim
\else
  \newlength{\guitarDim}
\fi

\def\guitarSharp{$\sharp$}
\def\guitarFlat{$\flat$}
\def\guitarCalcDim{\advance\guitarDim by 2pt}
\def\guitarPreAccord{\footnotesize\strut}
\let\guitarMagicOnHook\toolboxEmpty
\let\guitarMagicOffHook\toolboxEmpty
\def\guitarCrOnHook{\begingroup\leftskip 0pt plus 1fill\relax
  \parindent 0pt\leavevmode\gtr@CrOnHook\nobreak\hskip-\leftskip\relax
  \finalhyphendemerits=0\everypar{\nobreak\hskip-\leftskip\relax}\sloppy\relax
  \linepenalty=50\relax\parskip0pt\relax}
\def\guitarFirstLeft{\def\gtr@CrOnHook
  {\rightskip 0pt plus 1fil\relax\parfillskip 0pt\relax}}
\def\guitarFirstFlush{\let\gtr@CrOnHook\toolboxEmpty}
\guitarFirstFlush
\let\guitarCrOffHook\endgroup
\def\guitarEndLine{\par\leavevmode}
\def\guitarEndPar{\medskip\par\leavevmode}
\def\guitarEndDoublePar{\bigskip\par\leavevmode}

\def\guitarPut#1{\setbox0\hbox{\strut#1}\leavevmode
  \raise\ht0\hbox to 0pt{\hbox to\wd0{\guitarPreAccord
    \hfill\guitarAccord\hfill\hss}\hss}#1}
\def\guitarPutOnSpace{\leavevmode\raise\ht\strutbox
  \hbox{\guitarPreAccord\guitarAccord}}
\def\guitarPutDist{\gtr@distMerge\hfil}
\def\guitarPutMerge{\gtr@distMerge\hrulefill}
\def\gtr@distMerge#1#2{\setbox\guitarBox\hbox{\strut#2}%
  \setbox0\hbox{\guitarPreAccord\guitarAccord}\leavevmode
  \guitarDim=\wd0\relax\guitarCalcDim
  \ifdim\wd\guitarBox<\guitarDim% Accord is too large:
    \hbox to 0pt{\raise\ht\guitarBox\hbox{\copy0}\hss}%
    \hbox to\guitarDim{\box\guitarBox#1}%
    \let\guitarAccord\toolboxEmpty%now used as a temporary variable.
  \else
    \hbox to 0pt{\raise\ht\guitarBox
      \hbox to\wd\guitarBox{\hfil\box0\hfil}\hss}%
    \def\guitarAccord{#2}%
  \fi\guitarAccord}

\def\guitarNoChord{\def\guitarPut##1{##1}%
   \let\guitarPutDist\guitarPut
   \let\guitarPutMerge\guitarPut
   \let\guitarPutOnSpace\toolboxSpace}

\toolboxMakeSplit{|}{guitarSplitDist}
\toolboxMakeSplit{_}{guitarSplitMerge}

\def\guitarOn{\guitarCrOn\guitarMagicOn}
\def\guitarOff{\guitarMagicOff\guitarCrOff}
\def\guitarMagicOn{\guitarMagicOnHook\gtr@magicOn\gtr@ignorespaces}
\def\guitarMagicOff{\gtr@magicOff\guitarMagicOffHook}
\def\gtr@crMagicCondOn{\gtr@magicCondOn\gtr@crCondOn}
\def\gtr@crMagicCondOff{\gtr@magicCondOff\gtr@crCondOff}
\def\gtr@magicOn{\gtr@magicOnCat
  \let\gtr@magicCondOff\gtr@magicOffCat
  \let\gtr@magicCondOn\gtr@magicOnCat}
\def\gtr@magicOff{\gtr@magicOffCat
  \let\gtr@magicCondOff\toolboxEmpty
  \let\gtr@magicCondOn\toolboxEmpty}
\let\gtr@magicOnDef\toolboxEmpty
\def\gtr@magicOnCat{\catcode`\[=13\gtr@magicOnDef}
\gtr@magicOnCat\def\gtr@magicOnDef{\let\gtr@magicSave[\let[\gtr@magicNew}%
\def\gtr@magicNew{\gtr@chordTest\gtr@scanBrace}
\def\gtr@magicOffCat{\let[\gtr@magicSave\catcode`\[=12\relax}
\gtr@magicOnDef\gtr@magicOff

\def\gtr@scanBrace#1]{\gtr@parse{#1}}

\def\guitarChord{\gtr@chordTest\gtr@parse}
\def\gtr@chordTest#1{\gtr@crMagicCondOff\gtr@change
  \toolboxIfNextGobbling*{\gtr@normal#1}{#1}}
\def\gtr@parse#1{\gtr@normal\gtr@changeDef
  \guitarSplitDist{#1}\guitarAccord\gtr@dist
  \expandafter
    \guitarSplitMerge\expandafter{\guitarAccord}\guitarAccord\gtr@merge
  \gtr@changeUndef
  \toolboxIfNextGobbling\toolboxSpaceToken
  {\gtr@crMagicCondOn\guitarPutOnSpace}\gtr@para}
\def\gtr@para#1{\gtr@crMagicCondOn
  \ifx\gtr@dist\undefined
    \ifx\gtr@merge\undefined
      \let\gtr@tmp\guitarPut
    \else
      \let\gtr@tmp\guitarPutMerge
    \fi
  \else
    \let\gtr@tmp\guitarPutDist
  \fi\gtr@tmp{#1}}

\def\gtr@change{\catcode`\#=13\catcode`b=13\relax}
\gtr@change\def\gtr@changeDef{\let\gtr@sharpSave#\let#\gtr@sharpNew
  \let\gtr@flatSave b\let b\gtr@flatNew}
\def\gtr@changeUndef{\let#\gtr@sharpSave\let b\gtr@flatSave}
\def\gtr@sharpNew{\guitarSharp}
\def\gtr@flatNew{\guitarFlat}
\def\gtr@normal{\catcode`\#=6\catcode`b=11\relax}
\gtr@changeDef\gtr@normal

\def\guitarCrOn{\guitarCrOnHook\gtr@crOn\gtr@ignorespaces}
\def\guitarCrOff{\gtr@crOff\guitarCrOffHook}
\def\gtr@crOn{\gtr@crOnCat
  \let\gtr@crCondOff\gtr@crOffCat
  \let\gtr@crCondOn\gtr@crOnCat}
\def\gtr@crOff{\gtr@crOffCat
  \let\gtr@crCondOff\toolboxEmpty
  \let\gtr@crCondOn\toolboxEmpty}
\let\gtr@crOnDef\toolboxEmpty
\def\gtr@crOnCat{\catcode`\^^M=13\gtr@crOnDef}
\gtr@crOnCat\def\gtr@crOnDef{\let\gtr@crSave^^M\let^^M\gtr@crNew}%
\def\gtr@crNew{\toolboxIfNextGobbling^^M\gtr@par\guitarEndLine}%
\def\gtr@par{\toolboxIfNextGobbling^^M\gtr@dblpar\guitarEndPar}%
\def\gtr@dblpar{\toolboxIfNextGobbling^^M\gtr@dblpar\guitarEndDoublePar}%
\def\gtr@ignorespaces{\toolboxIfNextGobbling^^M\gtr@ignorespaces\ignorespaces}%
\def\gtr@crOffCat{\let^^M\gtr@crSave\catcode`\^^M=5\relax}%
\gtr@crOnDef\gtr@crOff

\endinput
%%
%% End of file `guitar.sty'.
