From 14af3f447439750920f754792b89f113d019076a Mon Sep 17 00:00:00 2001
From: Karl Berry <karl@freefriends.org>
Date: Tue, 22 May 2007 17:41:52 +0000
Subject: texpower update

git-svn-id: svn://tug.org/texlive/trunk@4334 c570f23f-e606-0410-a88d-b1316a301751
---
 Master/texmf-dist/tex/latex/texpower/texpower.sty | 259 ++++++++++++++++------
 1 file changed, 187 insertions(+), 72 deletions(-)

(limited to 'Master/texmf-dist/tex/latex/texpower/texpower.sty')

diff --git a/Master/texmf-dist/tex/latex/texpower/texpower.sty b/Master/texmf-dist/tex/latex/texpower/texpower.sty
index a46f177abb7..fa31659c3a0 100644
--- a/Master/texmf-dist/tex/latex/texpower/texpower.sty
+++ b/Master/texmf-dist/tex/latex/texpower/texpower.sty
@@ -9,6 +9,7 @@
 %% --------------------------------------------------------------
 %% TeXPower bundle - dynamic online presentations with LaTeX
 %% Copyright (C) 1999-2004 Stephan Lehmke
+%% Copyright (C) 2003-2005 Hans Fredrik Nordhaug
 %% 
 %% This program is free software; you can redistribute it and/or
 %% modify it under the terms of the GNU General Public License
@@ -26,7 +27,7 @@
 %% 
 \NeedsTeXFormat{LaTeX2e}
 \ProvidesPackage{texpower}
-    [2004/07/27 v0.1b Create Dynamic Presentations with LaTeX.]
+    [2005/04/08 v0.2 Create Dynamic Presentations with LaTeX.]
 
 \RequirePackage{ifthen}
 \RequirePackage{calc}
@@ -38,6 +39,10 @@
 \DeclareOption{printout}{\setboolean{display}{false}}
 \newboolean{fixcolorstack@TP}
 \DeclareOption{fixcolorstack}{\setboolean{fixcolorstack@TP}{true}}
+\newboolean{oldfiltering@TP}
+\DeclareOption{oldfiltering}{\setboolean{oldfiltering@TP}{true}}
+\newcommand{\oldfilteringon}{\setboolean{oldfiltering@TP}{true}}
+\newcommand{\oldfilteringoff}{\setboolean{oldfiltering@TP}{false}}
 \newboolean{nineminutes@TP}
 \DeclareOption{nineminutes}{\setboolean{nineminutes@TP}{true}}
 \newboolean{TPcolor}
@@ -72,26 +77,22 @@
 \ifthenelse{\boolean{verbose@TP}}{\setcounter{errorcontextlines}{10000}}{}
 \newboolean{psspecialsallowed}
 \setboolean{psspecialsallowed}{true} % optimistic default
-\IfFileExists{ifpdf.sty}
-{%
-  \RequirePackage{ifpdf}%
-  }
-{%
-  \@ifundefined{pdftrue}
-  {%
-  \expandafter\newif\csname ifpdf\endcsname
-  \ifx\pdfoutput\undefined
-   \else
-    \ifx\pdfoutput\relax
-     \else
-      \ifcase\pdfoutput
-       \else
-        \pdftrue
-       \fi
-     \fi
-   \fi
-   }{}%
-   }
+\@ifundefined{pdftrue}{
+\IfFileExists{ifpdf.sty}{\RequirePackage{ifpdf}}{%
+ \expandafter\newif\csname ifpdf\endcsname
+ \ifx\pdfoutput\undefined
+  \else
+   \ifx\pdfoutput\relax
+    \else
+     \ifcase\pdfoutput
+      \else
+       \pdftrue
+      \fi
+    \fi
+  \fi
+ }
+}{% \ifpdf is defined - nothing to do
+}
 
 \ifpdf\setboolean{psspecialsallowed}{false}\fi
 \@ifclassloaded{slides}%
@@ -1461,7 +1462,9 @@
           }%
       \fi
       }% matches \ifthenelse{\equal{\bgndtoppanelheight@TP}{}}
-    {}% Yes. Nothing to do.
+    {% Yes.
+      \let\toppanelheight=\bgndtoppanelheight@TP%      Overwrite panel settings  - use user-supplied value.
+    }
     \ifthenelse{\equal{\bgndbottompanelheight@TP}{}}%         Has the bottom panel height been set?
     {% No. Guess default.
       \ifx\bottompanelcontents@TP\empty%                      Is the bottom panel defined?
@@ -1480,7 +1483,9 @@
           }%
       \fi
       }% matches \ifthenelse{\equal{\bgndbottompanelheight@TP}{}}
-    {}% Yes. Nothing to do.
+    {% Yes.
+      \let\bottompanelheight=\bgndbottompanelheight@TP%   Overwrite panel settings - use user-supplied value.
+    }
     \mklength@TP{\bgndleftpanelheight@TP}%                Calculate remaining space in the center.
     {\TPpageheight-\bgndtoppanelheight@TP-\bgndbottompanelheight@TP}%
     \let\bgndrightpanelheight@TP=\bgndleftpanelheight@TP% Height of left and right panels is equal.
@@ -1502,7 +1507,9 @@
           }%
       \fi
       }% matches \ifthenelse{\equal{\bgndleftpanelwidth@TP}{}}
-    {}% Yes. Nothing to do.
+    {% Yes.
+      \let\leftpanelwidth=\bgndleftpanelwidth@TP%         Overwrite panel settings - use user-supplied value.
+    }
     \ifthenelse{\equal{\bgndrightpanelwidth@TP}{}}%       Has the right panel width been set?
     {% No. Guess default.
       \ifx\rightpanelcontents@TP\empty%                   Is the panel defined?
@@ -1521,7 +1528,9 @@
           }%
       \fi
       }% matches \ifthenelse{\equal{\bgndrightpanelwidth@TP}{}}
-    {}% Yes. Nothing to do.
+    {% Yes.
+      \let\rightpanelwidth=\bgndrightpanelwidth@TP%       Overwrite panel settings - use user-supplied value.
+    }
     }% matches \ifthenelse{\boolean{hpanels@TP}}
   {% No. Vertical panels are `outer', horizontal panels are `inner'.
     \let\bgndleftpanelheight@TP=\TPpageheight%          Full height for vertical panels.
@@ -1544,7 +1553,9 @@
           }%
       \fi
       }% matches \ifthenelse{\equal{\bgndleftpanelwidth@TP}{}}
-    {}% Yes. Nothing to do.
+    {% Yes.
+      \let\leftpanelwidth=\bgndleftpanelwidth@TP%       Overwrite panel settings - use user-supplied value.
+    }
     \ifthenelse{\equal{\bgndrightpanelwidth@TP}{}}%       Has the right panel width been set?
     {% No. Guess default.
       \ifx\rightpanelcontents@TP\empty%                   Is the panel defined?
@@ -1563,7 +1574,9 @@
           }%
       \fi
       }% matches \ifthenelse{\equal{\bgndrightpanelwidth@TP}{}}
-    {}% Yes. Nothing to do.
+    {% Yes.
+      \let\rightpanelwidth=\bgndrightpanelwidth@TP%       Overwrite panel settings - use user-supplied value.
+    }
     \mklength@TP{\bgndtoppanelwidth@TP}%                Calculate remaining space in the center.
     {\TPpagewidth-\bgndleftpanelwidth@TP-\bgndrightpanelwidth@TP}%
     \let\bgndbottompanelwidth@TP=\bgndtoppanelwidth@TP% Width of top and bottom panels is equal.
@@ -1585,7 +1598,9 @@
           }%
       \fi
       }% matches \ifthenelse{\equal{\bgndtoppanelheight@TP}{}}
-    {}% Yes. Nothing to do.
+    {% Yes.
+      \let\toppanelheight=\bgndtoppanelheight@TP%       Overwrite panel settings - use user-supplied value.
+    }
     \ifthenelse{\equal{\bgndbottompanelheight@TP}{}}%       Has the bottom panel height been set?
     {% No. Guess default.
       \ifx\bottompanelcontents@TP\empty%                    Is the panel defined?
@@ -1604,7 +1619,9 @@
           }%
       \fi
       }% matches \ifthenelse{\equal{\bgndbottompanelheight@TP}{}}
-    {}% Yes. Nothing to do.
+    {% Yes.
+      \let\bottompanelheight=\bgndbottompanelheight@TP%     Overwrite panel settings - use user-supplied value.
+    }
     }% matches second argument of \ifthenelse{\boolean{hpanels@TP}}
   }% matches \newcommand{\initpanels@TP}[1]{
 \newcommand{\phantomrule@TP}[2]{\rule{0pt}{#2}\rule{#1}{0pt}}
@@ -2324,6 +2341,42 @@
 \newcommand{\pausesafecounter}[1]%
 {\expandafter\def\expandafter\cl@@ckptpause@TP\expandafter{\cl@@ckptpause@TP\@elt{#1}}}
 \@ifclassloaded{seminar}{\pausesafecounter{slide}}{}
+\ifthenelse{\boolean{display}}{%
+  \AtBeginDocument{\@ifpackageloaded{hyperref}{%
+  \let\hyper@anchor@TP=\hyper@anchor
+  \long\def\hyper@@anchor#1#2{%
+    %%% \ifthenelse{\boolean{instepwise@TP}}%
+    \ifthenelse{\boolean{instepwise@TP} \AND \NOT \boolean{oldfiltering@TP}}%
+      {\ifthenelse{\NOT \boolean{instep@TP}}%
+       {\ifthenelse{\value{step}=\value{firststep}}{\@hyper@@anchor#1\relax#2\relax}{}}%
+       {\ifthenelse{\boolean{active} \AND \boolean{firstactivation}}%
+            {\@hyper@@anchor#1\relax#2\relax}{}}% End \ifthenelse{\boolean{active} ...
+      }% End \ifthenelse{\NOT \boolean{instep@TP}}
+      {\@hyper@@anchor#1\relax#2\relax}% End \ifthenelse{\boolean{instepwise@TP}}
+  }
+  \let\hyper@anchorstart@TP=\hyper@anchorstart
+  \def\hyper@anchorstart#1{%
+    \ifthenelse{\boolean{instepwise@TP} \AND \NOT \boolean{oldfiltering@TP}}%
+      {\ifthenelse{\NOT \boolean{instep@TP}}%
+       {\ifthenelse{\value{step}=\value{firststep}}{\hyper@anchorstart@TP{#1}}{}}%
+       {\ifthenelse{\boolean{active} \AND \boolean{firstactivation}}%
+            {\hyper@anchorstart@TP{#1}}{}}% End \ifthenelse{\boolean{active} ...
+      }% End \ifthenelse{\NOT \boolean{instep@TP}}
+      {\hyper@anchorstart@TP{#1}}% End \ifthenelse{\boolean{instepwise@TP}}
+  }
+  }{}}% End \AtBeginDocument{\@ifpackageloaded{hyperref}{
+  % Changing \protected@write to avoid duplicates in aux-file
+  \let\protected@write@TP=\protected@write
+  \long\def\protected@write#1#2#3{%
+    \ifthenelse{\boolean{instepwise@TP} \AND \NOT \boolean{oldfiltering@TP}}%
+      {\ifthenelse{\NOT \boolean{instep@TP}}%
+       {\ifthenelse{\value{step}=\value{firststep}}{\protected@write@TP{#1}{#2}{#3}}{}}%
+       {\ifthenelse{\boolean{active} \AND \boolean{firstactivation}}%
+            {\protected@write@TP{#1}{#2}{#3}}{}}% End \ifthenelse{\boolean{active} ...
+      }% End \ifthenelse{\NOT \boolean{instep@TP}}
+      {\protected@write@TP{#1}{#2}{#3}}% End \ifthenelse{\boolean{instepwise@TP}}
+  }%
+}{}% End \ifthenelse{\boolean{display}}
 \def\save@TP
 {%
   \par%                                                Always end current paragraph.
@@ -2339,7 +2392,14 @@
   \output=\memoutput@TP%                               Restore output routine.
   }
 \let\filterpage@TP\relax
-\newcommand{\filterwhatsits@TP}{\global\setbox\@cclv=\hbox{\leaders\copy\@cclv\hskip\wd\@cclv}}
+\newcommand{\filterwhatsits@TP}{%
+  \ifthenelse{\boolean{oldfiltering@TP}}%
+    {\global\setbox\@cclv=\hbox{\leaders\copy\@cclv\hskip\wd\@cclv}}% Old aggressive/robust filtering
+    {}% No filtering - handled by \insertfilterwhatsits@TP and stepwise aware commands.
+}
+\newcommand{\insertfilterwhatsits@TP}{%
+  \global\setbox\tempbox@TP=\hbox{\leaders\copy\tempbox@TP\hskip\wd\tempbox@TP}%
+}
 \newcommand{\insertfirstduplicate@TP}
 {\unvcopy\mempageconts@TP}%             Just output the vbox's contents.
 \newcommand{\do@colorcorrections@TP}
@@ -2356,7 +2416,12 @@
   \global\skip\footins=\skip\memfootins@TP
   \global\count\footins=\count\memfootins@TP
   \global\dimen\footins=\dimen\memfootins@TP
-  \unvcopy\mempageconts@TP%                        Output the vbox's contents.
+  \ifthenelse{\boolean{oldfiltering@TP}}%
+    {\unvcopy\mempageconts@TP}%
+    {\setbox\tempbox@TP=\vbox{\unvcopy\mempageconts@TP}%
+     \insertfilterwhatsits@TP
+     \copy\tempbox@TP%
+    }
   }
 \newcommand{\outputduplicate@TP}
 {%
@@ -2422,64 +2487,55 @@
 \newcommand{\hidesmartignore}[1]{\setbox\tempbox@TP=\vbox{#1}}
 \AtBeginDocument%
 {%
-  \@ifpackageloaded{soul}%                      Can we use the soul package?
-  {%
-    \@ifpackagelater{soul}{2002/05/28}%         Correct version?
-    {% Yes. Let's define the necessary macros.
-      \DeclareRobustCommand*\hidetext
-      {%
-        \leavevmode%                              To prevent \phantom from inserting an hbox into the vertical list.
+  \@ifpackageloaded{soul}{%
+    \@ifpackagelater{soul}{2002/05/28}{
+      \DeclareRobustCommand*\hidetext{%
+        \leavevmode
         \SOUL@setup
-        \def\SOUL@everytoken{\phantom{\the\SOUL@token\SOUL@setkern\SOUL@charkern}}% Make current token `invisible'.
+        \def\SOUL@everytoken{\phantom{\the\SOUL@token\SOUL@setkern\SOUL@charkern}}
         \def\SOUL@everyhyphen
         {%
           \discretionary
           {%
             \unkern
-            \phantom{\SOUL@setkern\SOUL@hyphkern\char\hyphenchar\font}%  Output an `invisible' hyphen if needed.
+            \phantom{\SOUL@setkern\SOUL@hyphkern\char\hyphenchar\font}%
           }{}{}%
         }%
         \SOUL@%
       }%
-    }%
-    {% No. Encourage people to update.
+    }{
       \PackageInfo{texpower}
       {Package soul too old.\MessageBreak Command \string\hidetext\space disabled}%
-      \let\hidetext=\hidephantom%                 \hidephantom is a sorry excuse for \hidetext...
+      \let\hidetext=\hidephantom
     }%
-  }%
-  {% No. In this case, there is no useful definition for \hidetext.
+  }{
     \PackageInfo{texpower}
     {Package soul not loaded.\MessageBreak Command \string\hidetext\space disabled}%
-    \let\hidetext=\hidephantom%                 \hidephantom is a sorry excuse for \hidetext...
+    \let\hidetext=\hidephantom
   }%
 }
-\ifthenelse{\boolean{colormath@TP}}% Should we color math?
-{% Yes.
+\ifthenelse{\boolean{colormath@TP}}{%
   \newcommand{\commitcolor@TP}
   {\textcolor{\ifmmode mathcolor\else textcolor\fi}}
-  }
-{% No.
-  \newcommand{\commitcolor@TP}{\textcolor{textcolor}}% Switch to textcolor.
+}{
+  \newcommand{\commitcolor@TP}{\textcolor{textcolor}}
 }
-\ifthenelse{\boolean{TPcolor}}%            Can we use colors at all?
-{% Yes.
-  \newcommand{\hidedimmed}[1]%             Make argument appear in `dimmed' colors.
-  {%
-    {% A group makes the color changes local.
-      \ifthenelse{\boolean{instepwise@TP}}{\usecolorset{stwcolors}}{}% Just in case we currently are in dimmed mode...
-      \dimcolors%          Dim colors.
-      \commitcolor@TP{#1}% Switch on dimmed color.
-      }%
-    }%
-  }
-{\let\hidedimmed=\displayidentical}% No. Disable this command.
-\ifthenelse{\boolean{TPcolor}}% Can we use colors at all?
-{% Yes.
-  \newcommand{\hidevanish}[1]%            Make argument `vanish' by changing colors.
-  {\textcolor{\vanishcolor}{\vanishcolors#1}}
+\ifthenelse{\boolean{TPcolor}}{
+  \newcommand{\hidedimmed}[1]{%
+    {
+      \ifthenelse{\boolean{instepwise@TP}}{\usecolorset{stwcolors}}{}%
+      \dimcolors
+      \commitcolor@TP{#1}
+    }
   }
-{\let\hidevanish=\hidephantom}% No. Use \hidephantom instead.
+}{
+  \let\hidedimmed=\displayidentical
+}
+\ifthenelse{\boolean{TPcolor}}{
+  \newcommand{\hidevanish}[1]{\textcolor{\vanishcolor}{\vanishcolors#1}}
+}{
+  \let\hidevanish=\hidephantom
+}
 \newcommand{\boxedsteps}          % Use boxed versions.
 {\let\displaystepcontents=\displayboxed\let\hidestepcontents=\hidephantom}
 
@@ -2710,6 +2766,7 @@
 \newcommand{\@switch@TP}[2]
 {%
   \global\advance\c@stepcommand by 1\relax% This execution of \switch is counted.
+  \setboolean{instep@TP}{true}%             Set indicator.
   %
   % If the verbose option is set, type out some accounting information which can be used for debugging.
   \ifthenelse{\boolean{verbose@TP}}
@@ -2753,6 +2810,7 @@
     }% End of \s@step@TPcheck
   %
   \let\afterstep=\o@afterstep@TP%            Restore the definition of \afterstep.
+  \setboolean{instep@TP}{false}%             Set indicator.
   }% End of the definition of \@switch@TP.
 \@onlyinstepwise@TP\restep
 
@@ -2949,13 +3007,14 @@
 \def\paren@overlays@TP(#1){\def\optarg@ov@TP{(#1)}\@@overlays@TP}
 \newcommand{\@@overlays@TP}[2]
 {%
-  \setcounter{substep}{0}%       Initialize substep counter.
+  \setcounter{substep}{1}%       Initialize substep counter.
   \leavevmode%                   Make sure that \rlap doesn't insert anything in the vertical list.
-  \whiledo{\value{substep}<#1}%  Iterate <n> times.
+  \whiledo{\value{substep}<#1}%  Iterate <n-1> times (since we start at 1).
   {%
-    \stepcounter{substep}%
     \expandafter\switch\optarg@ov@TP{}{\ifthenelse{\boolean{firstactivation}}{\mbox{#2}}{\rlap{#2}}}%
+    \stepcounter{substep}%
   }%
+  \expandafter\switch\optarg@ov@TP{}{\mbox{#2}}% Always using \mbox for last overlay.
 }
 \newenvironment{stepcapsule}{}{}
 \newcommand{\afterstep}[1]
@@ -3048,6 +3107,7 @@
   \renewcommand{\@@@@dblhgradrule@TP}[3][0pt]{}%
 }
 \newboolean{instepwise@TP}
+\newboolean{instep@TP}
 \newcommand{\@stepwise@TP}[2][]
 {%
   \save@TP%                               Save the current contents of the page.
@@ -3143,7 +3203,62 @@
     \repeat
   \endgroup
   \global\c@firststep=\c@o@fs@TP\relax%     Restore default value of counter firststep.
-}% End of the definition of \@stepwise@TP
+}
+\newenvironment{fragilesteps}{%
+  \def\texpower@verbatimfilename{\jobname-texpower.vrb}%
+  \immediate\openout\texpower@verbatimfileout=\texpower@verbatimfilename%
+  \texpower@verbatimreadframe%
+}
+{%
+  \immediate\closeout\texpower@verbatimfileout%
+  \stepwise{\input{\texpower@verbatimfilename}}%
+}
+\newwrite\texpower@verbatimfileout
+
+\def\texpower@verbatimreadframe{%
+  \begingroup%
+  \let\do\@makeother\dospecials%
+  \count@=127%
+  \@whilenum\count@<255 \do{%
+    \advance\count@ by 1%
+    \catcode\count@=11%
+  }%
+  \@makeother\^^L% and whatever other special cases
+  \endlinechar`\^^M \catcode`\^^M=12 \texpower@processframefirstline}
+
+{\catcode`\^^M=12\endlinechar=-1%
+  \long\gdef\texpower@processframefirstline#1^^M{%
+    \def\texpower@test{#1}%
+    \ifx\texpower@test\texpower@stopframefirst%
+      \let\next=\texpower@endfragilesteps%
+    \else
+      \ifx\texpower@test\@empty%
+      \else%
+        \@temptokena={#1}%
+        \immediate\write\texpower@verbatimfileout{\the\@temptokena}%
+      \fi%
+      \let\next=\texpower@processframeline%
+    \fi%
+    \next%
+  }
+  \long\gdef\texpower@processframeline#1^^M{%
+    \def\texpower@test{#1}%
+    \ifx\texpower@test\texpower@stopframe%
+      \let\next=\texpower@endfragilesteps%
+    \else
+      \immediate\write\texpower@verbatimfileout{#1}%
+    \fi%
+    \next%
+  }
+}
+
+{
+  \escapechar=-1\relax%
+  \xdef\texpower@stopframe{\string\\end\string\{fragilesteps\string\}}
+  \xdef\texpower@stopframefirst{\noexpand\end\string\{fragilesteps\string\}}
+}
+
+\def\texpower@endfragilesteps{\endgroup\end{fragilesteps}}
 \InputIfFileExists{tpsettings.cfg}{}{}
 \endinput
 %%
-- 
cgit v1.2.3

