% \iffalse meta-comment
% (The MIT License)
%
% Copyright (c) 2021-2024 Yegor Bugayenko
%
% Permission is hereby granted, free of charge, to any person obtaining a copy
% of this software and associated documentation files (the 'Software'), to deal
% in the Software without restriction, including without limitation the rights
% to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
% copies of the Software, and to permit persons to whom the Software is
% furnished to do so, subject to the following conditions:
%
% The above copyright notice and this permission notice shall be included in all
% copies or substantial portions of the Software.
%
% THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
% IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
% FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
% AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
% LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
% OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
% SOFTWARE.
% \fi

% \CheckSum{0}
%
% \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         \~}

% \GetFileInfo{clicks.dtx}
% \DoNotIndex{\endgroup,\begingroup,\let,\else,\fi,\newcommand,\newenvironment}

% \iffalse
%<*driver>
\ProvidesFile{clicks.dtx}
%</driver>
%<package>\NeedsTeXFormat{LaTeX2e}
%<package>\ProvidesPackage{clicks}
%<*package>
[2024/12/25 0.4.3 Slide Deck Animation]
%</package>
%<*driver>
\documentclass{ltxdoc}
\usepackage[tt=false, type1=true]{libertine}
\usepackage{clicks}
\usepackage{href-ul}
\PageIndex
\EnableCrossrefs
\CodelineIndex
\RecordChanges
\begin{document}
	\DocInput{clicks.dtx}
	\PrintChanges
	\PrintIndex
\end{document}
%</driver>
% \fi

% \title{|clicks|: \LaTeX{} Package \\ for Slide Deck Animation\thanks{The sources are in GitHub at \href{https://github.com/yegor256/clicks}{yegor256/clicks}}}
% \author{Yegor Bugayenko \\ \texttt{yegor256@gmail.com}}
% \date{\filedate, \fileversion}
%
% \maketitle
%
% \section{Introduction}
%
% This package helps simulate animation in PDF documents. You put
% some content on the page, then you ``click'' and the pages ends,
% while the content gets copied to the next page. There, you add new
% content. In the full-screen presentation mode this will look
% like animation, similar to what you can get with MS PowerPoint:
%\iffalse
%<*verb>
%\fi
\begin{verbatim}
\documentclass{article}
\usepackage{clicks}
\begin{document}
\print{Here is your wedding plan:}\click
\print{1. Buy a ring}\click
\print{2. Propose}\click
\print{3. Get married}\flush
\end{document}
\end{verbatim}
%\iffalse
%</verb>
%\fi

% You can make it shorter, with the help of
% |\plick| and |\plush| commands:
%\iffalse
%<*verb>
%\fi
\begin{verbatim}
\documentclass{article}
\usepackage{clicks}
\begin{document}
\plick[2]{Here is your wedding plan:}
\plick[3]{1. Buy a ring}
\plick[5]{2. Propose}
\plush[1]{3. Get married}
\end{document}
\end{verbatim}
%\iffalse
%</verb>
%\fi

% The optional parameters at |\plick| and |\plush|
% are the minutes: how long you are planning to stay at this animation.
% The minutes are accumulated in the |minutes| counter, which
% you can show, for example, at your header. This will help you track
% time during the presentation. The commands
% |\click| and |\flush| also have the
% same optional arguments.

% \section{Package Options}

% \begin{macro}{static}
% If you need to render the document without animation, just
% use the |static| package option.
% \end{macro}

% \StopEventually{}

% \section{Implementation}

% \changes{v0.1.0}{2021/09/13}{Initial version}

% First, we parse package options:
%    \begin{macrocode}
\RequirePackage{pgfopts}
\pgfkeys{
  /clicks/.cd,
  static/.store in=\clicks@static,
}
\ProcessPgfPackageOptions{/clicks}
%    \end{macrocode}

% Then, we define a few supplementary commands:
%    \begin{macrocode}
\makeatletter
\newcommand*\clicks@body{}
\newcommand\clicks@flush{%
  \clicks@body\vspace*{0pt}\newpage%
}
\makeatother
%    \end{macrocode}

% Then, we declare a counter of minutes:
%    \begin{macrocode}
\newcounter{minutes}
%    \end{macrocode}

% \begin{macro}{\print}
% Then, we define |\print| command:
%    \begin{macrocode}
\RequirePackage{etoolbox}
\makeatletter
\newcommand\print[1]{%
  \gappto\clicks@body{{#1}}%
  \def\param{#1}%
  \ifx\param\empty\else%
    \gappto\clicks@body{{\par}}%
  \fi%
}
\makeatother
%    \end{macrocode}
% \end{macro}

% \begin{macro}{\flush}
% Then, we define |\flush| command:
%    \begin{macrocode}
\makeatletter
\newcommand\flush[1][1]{%
  \ifx\clicks@body\empty\else%
    \clicks@flush%
    \renewcommand*\clicks@body{}%
  \fi%
  \ifdefined\clicks@static\else%
    \addtocounter{minutes}{#1}%
  \fi%
}
\makeatother
%    \end{macrocode}
% \end{macro}

% \begin{macro}{\click}
% Then, we define |\click| command:
%    \begin{macrocode}
\makeatletter
\newcommand\click[1][0]{%
  \ifdefined\clicks@static\else%
    \addtocounter{minutes}{#1}%
  \fi%
  \ifdefined\clicks@static\else%
    \clicks@flush%
  \fi%
}
\makeatother
%    \end{macrocode}
% \end{macro}

% \begin{macro}{\plush}
% Then, we define |\plush| command:
%    \begin{macrocode}
\newcommand\plush[2][1]{%
  \print{#2}%
  \flush[#1]%
}
%    \end{macrocode}
% \end{macro}

% \begin{macro}{\plick}
% Then, we define |\plick| command:
%    \begin{macrocode}
\newcommand\plick[2][1]{%
  \print{#2}%
  \click[#1]%
}
%    \end{macrocode}
% \end{macro}

% \Finale

%\clearpage
%
%\PrintChanges
%\clearpage
%\PrintIndex
