diff options
author | Karl Berry <karl@freefriends.org> | 2015-04-23 21:15:55 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2015-04-23 21:15:55 +0000 |
commit | 35d31d35c8c20e4783ade23cfd2b00fdf54bdb97 (patch) | |
tree | f01d83073c416e08023935fbe1db13c7869d7afa /Master/texmf-dist/tex/latex/cryptocode | |
parent | 33aacfecb5a1f423a522744ccd34c25af25021a2 (diff) |
cryptocode (23apr15)
git-svn-id: svn://tug.org/texlive/trunk@37019 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/tex/latex/cryptocode')
-rw-r--r-- | Master/texmf-dist/tex/latex/cryptocode/cryptocode.sty | 324 |
1 files changed, 236 insertions, 88 deletions
diff --git a/Master/texmf-dist/tex/latex/cryptocode/cryptocode.sty b/Master/texmf-dist/tex/latex/cryptocode/cryptocode.sty index 72fc9e90b12..5c1edac52b2 100644 --- a/Master/texmf-dist/tex/latex/cryptocode/cryptocode.sty +++ b/Master/texmf-dist/tex/latex/cryptocode/cryptocode.sty @@ -15,7 +15,7 @@ % This work consists of the files cryptocode.tex and cryptocode.sty \NeedsTeXFormat{LaTeX2e} \ProvidesPackage{cryptocode} - [2015/03/09 v0.01 Cryptocode LaTeX package for writing pseudocode in cryptographic settings] + [2015/04/22 v0.1 Cryptocode LaTeX package for writing pseudocode in cryptographic settings] \def\hi{Hello, this is Arno's crypto code package. } @@ -247,8 +247,8 @@ } \DeclareOption{lambda}{ - \providecommand{\secpar}{\ensuremath{\lambda}} - \providecommand{\secparam}{\ensuremath{1^\secpar}} + \renewcommand{\secpar}{\ensuremath{\lambda}} + \renewcommand{\secparam}{\ensuremath{1^\secpar}} } \DeclareOption*{% @@ -270,7 +270,7 @@ \RequirePackage{ifthen} \RequirePackage{xargs} \RequirePackage{pgf} -\RequirePackage{mathabx} +%\RequirePackage{mathabx} \RequirePackage{forloop} \RequirePackage{array} \RequirePackage{xparse} @@ -280,7 +280,7 @@ \RequirePackage{suffix} \RequirePackage{etoolbox} \RequirePackage{etex} -\RequirePackage{etextools} +%\RequirePackage{etextools} \RequirePackage{environ} %\RequirePackage{xspace} \RequirePackage{xkeyval} @@ -298,7 +298,7 @@ \providecommand{\nizk}{\pcalgostyle{NIZK}} % hash - \renewcommand{\hash}{\pcalgostyle{H}} + \providecommand{\hash}{\pcalgostyle{H}} \providecommand{\gash}{\pcalgostyle{G}} \providecommand{\fash}{\pcalgostyle{F}} @@ -333,6 +333,7 @@ \providecommand{\distinguisher}{\pcalgostyle{Dist}} \providecommand{\simulator}{\pcalgostyle{Sim}} \providecommand{\ext}{\pcalgostyle{Ext}} + \providecommand{\extractor}{\ext} \fi %% @@ -342,14 +343,11 @@ %%% % order of growth helper \ifpc@orderofgrowth - \providecommand{\olrk}[1]{% - \ifx\nursymbol#1\else\!\!\mskip4.5mu plus 0.5mu\left(#1\right)\fi} - \providecommand{\elrk}[1]{% - \ifx\nursymbol#1\else% - \!\!\mskip4.5mu plus0.5mu\left[\mskip2.5mu plus0.5mu #1\right]\fi} - \providecommand{\clrk}[1]{% - \ifx\nursymbol#1\else% - \!\!\mskip4.5mu plus0.5mu\left\{\mskip2.5mu plus0.5mu #1\right\}\fi} +\providecommand{\olrk}[1]{\ifx\nursymbol#1\else\!\!\mskip4.5mu plus 0.5mu\left(\mskip0.5mu plus0.5mu #1\mskip1.5mu plus0.5mu \right)\fi} + +\providecommand{\elrk}[1]{\ifx\nursymbol#1\else\!\!\mskip4.5mu plus0.5mu\left[\mskip0.5mu plus0.5mu #1\mskip1.5mu plus0.5mu \right]\fi} + +\providecommand{\clrk}[1]{\ifx\nursymbol#1\else\!\!\mskip4.5mu plus0.5mu\left\{\mskip0.5mu plus0.5mu #1\mskip1.5mu plus0.5mu \right\}\fi} \fi \ifpc@algorithmstyle @@ -360,7 +358,7 @@ % create command to measure width of align % \newcommand{\@settowidthofalign}[2]{% - \setbox\z@=\vbox{ + \setbox\z@=\vbox{\@pseudocodecodesize \begin{flalign*} #2 \ifmeasuring@\else\global\let\got@maxcolwd\maxcolumn@widths\fi @@ -370,8 +368,7 @@ \def\or{+}\edef\x{\endgroup#1=\dimexpr\got@maxcolwd\relax}\x} \newcommand{\@settowidthofaligned}[2]{% - \settowidth{#1}{$\begin{aligned}#2\end{aligned}$} -} +\settowidth{#1}{\@pseudocodesubcodesize$\begin{aligned}#2\end{aligned}$}} % check for draft mode \def\@pc@ifdraft{\ifdim\overfullrule>\z@ @@ -398,11 +395,6 @@ -% The size to be used by the pseudocode procedure -\providecommand{\pcsize}{\small} -% The size to be used by the pseudocode procedure when writing subprocedures -\providecommand{\pcsubsize}{\footnotesize} - %%%%% % spaces before and after pseudo codes (left and right) \providecommand{\beforepcskip}{2pt} @@ -478,6 +470,8 @@ % pseudocode command itself does need to do some counter magic \newcounter{pclinenumber} \newcounter{Hpclinenumber} % make hyperref happy +\newcounter{@pclinenumber} +\newcounter{H@pclinenumber} % make hyperref happy \newcounter{@pclinenumbertmp} \newcounter{pcgamecounter} \newcounter{Hpcgamecounter} @@ -493,6 +487,12 @@ \providecommand{\pclnspace}{0pt} \providecommand{\pclnrspace}{5pt} +\renewcommand{\the@pclinenumber}{\thepclinenumber} +\providecommand{\@pcln}{% +\refstepcounter{@pclinenumber}% +\stepcounter{H@pclinenumber}% +} + % left align line numbers \providecommand{\pcln}[1][]{% \refstepcounter{pclinenumber}% @@ -529,6 +529,7 @@ \newlength{\@pc@alt@minipage@length} % backward games +\newcommand{\@withingame}{false} \newcommand{\@withinbxgame}{false} \newcommand{\@bxgameheader}{} @@ -540,7 +541,7 @@ \newcommand{\@pc@beginnewline}{% -\@pc@and\@pseudocodelinenumber% +\@pseudocodelinenumber\@pc@and\@pcln% %checkspace \ifthenelse{\equal{\@pseudocodespace}{auto}}% {\expandafter\pcind\expandafter[\value{@pc@indentationlevel}]}% @@ -559,6 +560,7 @@ \newcommand*\@pseudocodehead{} \newcommand*\@pseudocodewidth{} \newcommand*\@pseudocodexshift{0pt} +\newcommand*\@pseudocodeyshift{0pt} \newcommand*\@pseudocodelinenumber{} \newcommand*\@pseudocodebeforeskip{0ex} \newcommand*\@pseudocodeafterskip{0ex} @@ -567,9 +569,15 @@ \newcommand*\@pseudocodesyntaxhighlighting{} \newcommand*\@pseudocodenodraft{false} +\newcommand*\@pseudocodeheadlinesep{0em} +\newcommand*\@pseudocodebodylinesep{-0.5\baselineskip} + \newcommand*\@pseudocodecolsep{0em} \newcommand*\@pseudocodeaddtolength{2pt} +\newcommand*\@pseudocodecodesize{\small} +\newcommand*\@pseudocodesubcodesize{\footnotesize} + %%%%%%%%%%%%%% % Define keywords for the automatic syntax highlighting % the accompanying add provides additional keywords. @@ -585,15 +593,20 @@ \end{@withspaces} +\define@key{pseudocode}{codesize}[\small]{\renewcommand*\@pseudocodecodesize{#1}} +\define@key{pseudocode}{subcodesize}[\small]{\renewcommand*\@pseudocodesubcodesize{#1}} \define@key{pseudocode}{head}[]{\renewcommand*\@pseudocodehead{#1}} \define@key{pseudocode}{width}[]{\renewcommand*\@pseudocodewidth{#1}} \define@key{pseudocode}{xshift}[]{\renewcommand*\@pseudocodexshift{#1}} +\define@key{pseudocode}{yshift}[]{\renewcommand*\@pseudocodeyshift{#1}} \define@key{pseudocode}{linenumbering}[on]{\ifthenelse{\equal{#1}{on}}{\renewcommand*\@pseudocodelinenumber{\pcln}}{\renewcommand*\@pseudocodelinenumber{}}} \define@key{pseudocode}{beforeskip}[]{\renewcommand*\@pseudocodebeforeskip{#1}} \define@key{pseudocode}{afterskip}[]{\renewcommand*\@pseudocodeafterskip{#1}} \define@key{pseudocode}{lnstart}[0]{\renewcommand*\@pseudocodelnstart{#1}} \define@key{pseudocode}{lnstartright}[0]{\renewcommand*\@pseudocodelnstartright{#1}} \define@key{pseudocode}{colsep}[0em]{\renewcommand*\@pseudocodecolsep{#1}} +\define@key{pseudocode}{headlinesep}[0em]{\renewcommand*\@pseudocodeheadlinesep{#1}} +\define@key{pseudocode}{bodylinesep}[0em]{\renewcommand*\@pseudocodebodylinesep{#1}} \define@key{pseudocode}{addtolength}[2pt]{\renewcommand*\@pseudocodeaddtolength{#1}} \define@key{pseudocode}{mode}[math]{% \ifthenelse{\equal{#1}{text}}{% @@ -789,6 +802,13 @@ \setcounter{@pclinenumbertmp}{\value{pclinenumber}}% \setcounter{@pcrlinenumbertmp}{\value{pcrlinenumber}}% % +% vertical space +\vspace{\@pseudocodeyshift}% +%\setlength{\abovedisplayskip}{0pt}% +%\setlength{\belowdisplayskip}{0pt}% +%\setlength{\abovedisplayshortskip}{0pt}% +%\setlength{\belowdisplayshortskip}{0pt}% +% % % line magic \ifthenelse{\value{@pc@global@pc@nestcnt}=1}{% @@ -846,25 +866,33 @@ \endgroup% } - -\let\pclb\relax -% -\newcommand{\pc@display@pseudocode}[2]{% -\ifthenelse{\equal{#1}{}}{\vspace{-0.8\baselineskip}\pcsize}{% +\newcommand{\@pc@gameheader}[2]{% \tikz{\gdef\i{\thepcgamecounter}% -\node[anchor=base] (gamenode\i) {\hspace{-2pt}#1\vphantom{$\sum^A_{A_b}$}}; +\node[anchor=base,#2,inner sep=0.05em,outer sep=0] (gamenode\i) {#1\vphantom{$\sum^A_{A_b}$}}; \ifthenelse{\equal{\@withinbxgame}{true}} {\node[draw,anchor=base, above=0.1cm of gamenode\i] (bgamenode\i) {\@bxgameheader\vphantom{$\sum^A_{A_b}$}};} {}% -}\vspace{-0.1\baselineskip}\hrule\small\vspace{-0.5\baselineskip}}% +}% +} + +\let\pclb\relax +% +\newcommand{\pc@display@pseudocode}[2]{% +\ifthenelse{\equal{#1}{}}{\vspace{-1\baselineskip}\@pseudocodecodesize}{% +\ifthenelse{\equal{\@withingame}{true}}{% +\@pc@gameheader{#1}{}\ifthenelse{\equal{\@pc@secondheader}{true}}{\addtocounter{pcgamecounter}{1}\@pc@gameheader{#1}{draw}}{}% +\vspace{0.2em}% +}{#1\vphantom{$\sum^A_{A_b}$}}% +\vspace{\@pseudocodeheadlinesep}\hrule\vspace{\@pseudocodebodylinesep}\@pseudocodecodesize}% \begin{flalign*}#2\end{flalign*}% } \newcommand{\pc@display@subcode}[2]{% \begingroup% -\ifthenelse{\equal{#1}{}}{}{#1\vphantom{$\sum^A_{A_b}$}\hrule \vspace{0.2\baselineskip}}% -\pcsubsize% +\ifthenelse{\equal{#1}{}}{}{#1\vphantom{$\sum^A_{A_b}$} % +\vspace{\@pseudocodeheadlinesep}\hrule \vspace{\baselineskip}\vspace{\@pseudocodebodylinesep}}% +\@pseudocodesubcodesize% $\begin{aligned}#2\end{aligned}$% \endgroup% } @@ -931,83 +959,122 @@ $\begin{aligned}#2\end{aligned}$% % Reductions \newcommand{\@bb@lastbox}{} \newcommand{\@bb@lastoracle}{} +\newcommand{\@bb@lastchallenger}{} + \newlength{\@bb@message@hoffset} \newlength{\@bb@query@hoffset} \newlength{\@bb@oraclequery@hoffset} +\newlength{\@bb@challengerquery@hoffset} \newcounter{@bb@oracle@cnt} \newcounter{@bb@oracle@nestcnt} +\newcounter{@bb@challenger@cnt} +\newcounter{@bb@challenger@nestcnt} + \newcounter{@bb@env@nestcnt} \newcommand{\bbroraclenodenameprefix}{ora-} +\newcommand{\bbrchallengernodenameprefix}{challenger-} \newcommand{\bbrenvnodenameprefix}{env-} %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % Black Box Reduction Enviconment -\newenvironmentx{bbrenv}[3][1=0pt,3=0pt]{ -\addtocounter{@bb@env@nestcnt}{1} -\renewcommand{\@bb@lastbox}{#2} - +\newenvironmentx{bbrenv}[3][1=0pt,3=0pt]{% +\addtocounter{@bb@env@nestcnt}{1}% +\renewcommand{\@bb@lastbox}{#2}% +% % reset lengths -\setlength{\@bb@message@hoffset}{0pt} -\setlength{\@bb@query@hoffset}{0pt} -\@pc@globalsetlength{\@bb@oraclequery@hoffset}{0pt} - +\setlength{\@bb@message@hoffset}{0pt}% +\setlength{\@bb@query@hoffset}{0pt}% +\@pc@globalsetlength{\@bb@oraclequery@hoffset}{0pt}% +\@pc@globalsetlength{\@bb@challengerquery@hoffset}{0pt}% +% %reset oracle counter and oracle query offset -\ifthenelse{\value{@bb@oracle@nestcnt}=0}{ - \setcounter{@bb@oracle@cnt}{0} -}{ -} - -\def\@bbendskip{#3} -\vspace{#1} -\ifthenelse{\value{@bb@env@nestcnt}=1}{ -\@pc@ensureremember +\ifthenelse{\value{@bb@oracle@nestcnt}=0} + {\setcounter{@bb@oracle@cnt}{0}}{}% +\ifthenelse{\value{@bb@challenger@nestcnt}=0} + {\setcounter{@bb@challenger@cnt}{0}}{}% +% +\def\@bbendskip{#3}% +\vspace{#1}% +\ifthenelse{\value{@bb@env@nestcnt}=1} + {\@pc@ensureremember% \begin{tikzpicture} }{\tikz\bgroup} -}{ -\ifthenelse{\value{@bb@env@nestcnt}=1}{ -\end{tikzpicture} -\@pc@releaseremember -}{\egroup} -\vspace{\@bbendskip} -\addtocounter{@bb@env@nestcnt}{-1} +}{% +\ifthenelse{\value{@bb@env@nestcnt}=1} +{\end{tikzpicture}% +\@pc@releaseremember% +}{\egroup}% +\vspace{\@bbendskip}% +\addtocounter{@bb@env@nestcnt}{-1}% } %%%%%%%%%%%%%%%%%%%%%%%%%%%% % black box reduction box % option keys \newcommand*\bbrboxname{} +\newcommand*\bbrboxnamepos{right} +\newcommand*\bbrboxnamestyle{} +\newcommand*\@bbrboxnamepos{below=0.5ex of \@bb@lastbox.north east,anchor=north east} +\newcommand*\@bbrboxnameposoffset{below left=0cm of phantomname.north west} \newcommand*\bbrboxstyle{draw} \newcommand*\bbrboxafterskip{} -\newcommand*\bbrboxxshift{-2cm} +\newcommand*\bbrboxminwidth{2cm} +\newcommand*\bbrboxxshift{0cm} +\newcommand*\bbrboxyshift{0cm} \define@key{bbrbox}{name}[]{\renewcommand*\bbrboxname{#1}} +\define@key{bbrbox}{namestyle}[]{\renewcommand*\bbrboxnamestyle{#1}} +\define@key{bbrbox}{namepos}[]{\renewcommand*\bbrboxnamepos{#1}} \define@key{bbrbox}{style}[draw]{\renewcommand*\bbrboxstyle{#1}} +\define@key{bbrbox}{minwidth}[]{\renewcommand*\bbrboxminwidth{#1}} \define@key{bbrbox}{minheight}[]{\renewcommand*\bbrboxafterskip{#1}} \define@key{bbrbox}{xshift}[]{\renewcommand*\bbrboxxshift{#1}} +\define@key{bbrbox}{yshift}[]{\renewcommand*\bbrboxyshift{#1}} \NewEnviron{bbrbox}[1][]{% \setkeys{bbrbox}{#1}% +\ifthenelse{\equal{\bbrboxnamepos}{center}} + {\renewcommand{\@bbrboxnamepos}{below=0.5ex of \@bb@lastbox.north,anchor=north}}{} +\ifthenelse{\equal{\bbrboxnamepos}{left}} + {\renewcommand{\@bbrboxnamepos}{below=0.5ex of \@bb@lastbox.north west,anchor=north west}\renewcommand{\@bbrboxnameposoffset}{below left=1\baselineskip of phantomname.south west}}{} +\ifthenelse{\equal{\bbrboxnamepos}{top right}} + {\renewcommand{\@bbrboxnamepos}{above=0cm of \@bb@lastbox.north east,anchor=south east}}{} +\ifthenelse{\equal{\bbrboxnamepos}{top center}} + {\renewcommand{\@bbrboxnamepos}{above=0cm of \@bb@lastbox.north,anchor=south}}{} +\ifthenelse{\equal{\bbrboxnamepos}{top left}} + {\renewcommand{\@bbrboxnamepos}{above=0cm of \@bb@lastbox.north west,anchor=south west}}{} + + \tikzset{BBRBOXSTYLE/.style/.expand once=\bbrboxstyle}% -\node[inner sep=0pt,outer sep=0pt] (bbrshift) {}; -\node[BBRBOXSTYLE,xshift=\bbrboxxshift] (\@bb@lastbox) at (bbrshift) \bgroup +\tikzset{BBRBOXNAMEPOS/.style/.expand once=\@bbrboxnamepos}% +\tikzset{BBRBOXNAMESTYLE/.style/.expand once=\bbrboxnamestyle}% +\tikzset{BBRBOXNAMEPOSOFFSET/.style/.expand once=\@bbrboxnameposoffset}% + +\node[inner sep=0pt,outer sep=0pt] (\@bb@lastbox-tmpouter) {}; +\node[inner sep=.3333em,anchor=north,BBRBOXSTYLE,below right=\bbrboxyshift and \bbrboxxshift of \@bb@lastbox-tmpouter] (\@bb@lastbox) \bgroup \tikz{ - \node (inner) {\begin{varwidth}{\linewidth}\BODY\end{varwidth}}; - \node[right=0.05cm of inner.north east] (tmpne) {}; - \node[above left=0.cm and 0pt of tmpne.north] (name) {\bbrboxname}; + \node[inner sep=0pt,outer sep=0pt] (phantomname) {}; %minimum width + \node[BBRBOXNAMEPOSOFFSET] (inner) {\begin{varwidth}{2\linewidth}\BODY\end{varwidth}}; \ifthenelse{\equal{\bbrboxafterskip}{}}{}{ \node[below=0cm of inner,minimum height=\bbrboxafterskip] {}; } + \node[inner sep=0pt,outer sep=0pt,at=(inner.south west)] () {\phantom{\hspace{\bbrboxminwidth}}}; %minimum width } \egroup; +\node[BBRBOXNAMEPOS,BBRBOXNAMESTYLE, inner sep=0.2ex, outer sep=0pt, overlay] () {\bbrboxname}; } -\newcommand*\bbroracledistance{1cm} -\define@key{bbroracle}{distance}[]{\renewcommand*\bbroracledistance{#1}} +\newcommand*\bbroraclevdistance{\baselineskip} +\newcommand*\bbroraclehdistance{1.5cm} +\define@key{bbroracle}{distance}[]{\renewcommand*\bbroraclehdistance{#1}} +\define@key{bbroracle}{hdistance}[]{\renewcommand*\bbroraclehdistance{#1}} +\define@key{bbroracle}{vdistance}[]{\renewcommand*\bbroraclevdistance{#1}} + % ORACLES \newenvironmentx{bbroracle}[2][2=]{% @@ -1018,9 +1085,9 @@ $\begin{aligned}#2\end{aligned}$% %if first oracle, then put it to the right, else stack them vertically \addtocounter{@bb@oracle@cnt}{1} \ifthenelse{\value{@bb@oracle@cnt}=1}{ - \node[below right=0cm and \bbroracledistance of \@bb@lastbox.north east] (\bbroraclenodenameprefix#1) \bgroup + \setlength{\@bb@tmplength@b}{\bbroraclevdistance-\baselineskip} + \node[inner sep=0pt,below right=\@bb@tmplength@b and \bbroraclehdistance of \@bb@lastbox.north east,anchor=north west] (\bbroraclenodenameprefix#1) \bgroup }{ -% \node[below0.05cm of \bbroraclenodenameprefix \@bb@lastoracle.south west, anchor=north west] (\bbroraclenodenameprefix#1) \bgroup % compute distance of top of last box to bottom of last oracle \coordinate (@bbtmpcoord) at (\@bb@lastbox.north east); \path (@bbtmpcoord); @@ -1028,8 +1095,8 @@ $\begin{aligned}#2\end{aligned}$% \coordinate (@bbtmpcoord) at (\bbroraclenodenameprefix \@bb@lastoracle.south west); \path (@bbtmpcoord); \pgfgetlastxy{\XCoord}{\YCoordB} - \setlength{\@bb@tmplength@b}{\YCoordA-\YCoordB} - \node[below right=\@bb@tmplength@b and \bbroracledistance of \@bb@lastbox.north east] (\bbroraclenodenameprefix#1) \bgroup + \setlength{\@bb@tmplength@b}{\YCoordA-\YCoordB+\bbroraclevdistance} + \node[inner sep=0pt,below right=\@bb@tmplength@b and \bbroraclehdistance of \@bb@lastbox.north east,anchor=north west] (\bbroraclenodenameprefix#1) \bgroup } \global\def\@bb@lastoracle{#1} \begin{bbrenv}{#1} @@ -1041,6 +1108,47 @@ $\begin{aligned}#2\end{aligned}$% \endgroup } + +\newcommand*\bbrchallengerhdistance{1.5cm} +\newcommand*\bbrchallengervdistance{\baselineskip} +\define@key{bbrchallenger}{distance}[]{\renewcommand*\bbrchallengerhdistance{#1}} +\define@key{bbrchallenger}{hdistance}[]{\renewcommand*\bbrchallengerhdistance{#1}} +\define@key{bbrchallenger}{vdistance}[]{\renewcommand*\bbrchallengervdistance{#1}} + + +% Challenger +\newenvironmentx{bbrchallenger}[2][2=]{% +\begingroup% +\setkeys{bbrchallenger}{#2}% +%add to nesting cout +\addtocounter{@bb@challenger@nestcnt}{1}% +%if first oracle, then put it to the right, else stack them vertically +\addtocounter{@bb@challenger@cnt}{1}% +\ifthenelse{\value{@bb@challenger@cnt}=1}{% +\setlength{\@bb@tmplength@b}{\bbrchallengervdistance-\baselineskip}% +\node[inner sep=0pt,below left=\@bb@tmplength@b and \bbrchallengerhdistance of \@bb@lastbox.north west,anchor=north east] (\bbrchallengernodenameprefix#1) \bgroup% +}{% +\coordinate (@bbtmpcoord) at (\@bb@lastbox.north west);% +\path (@bbtmpcoord);% +\pgfgetlastxy{\XCoord}{\YCoordA}% +\coordinate (@bbtmpcoord) at (\bbrchallengernodenameprefix \@bb@lastchallenger.south east);% +\path (@bbtmpcoord);% +\pgfgetlastxy{\XCoord}{\YCoordB}% +\setlength{\@bb@tmplength@b}{\YCoordA-\YCoordB+\bbrchallengervdistance}% +\node[inner sep=0pt,below left=\@bb@tmplength@b and \bbrchallengerhdistance of \@bb@lastbox.north west,anchor=north east] (\bbrchallengernodenameprefix#1) \bgroup% +}% +\global\def\@bb@lastchallenger{#1} +\begin{bbrenv}{#1}% +}{ +\end{bbrenv}% +\egroup;% +\addtocounter{@bb@challenger@nestcnt}{-1}% +\endgroup% +\let\msgfrom\bbrchallengerqueryto% +} + + + \newcommandx{\bbrinput}[2][1=0.75cm]{% \node[above right=#1 of \@bb@lastbox.north west] (input) {#2}; \draw[->] (input) --++ (0,-0.75cm); @@ -1056,7 +1164,7 @@ $\begin{aligned}#2\end{aligned}$% %temporary lengths \newlength{\@bb@com@tmpoffset} \newlength{\@bb@tmplength@b} -\newcommand{\@bb@firstmessageheight}{-0.15cm} +\newcommand{\@bb@firstmessageheight}{0.25\baselineskip} \newcommand{\@bb@msglength}{1.25cm} \newcommand{\@bb@qrylength}{1.5cm} @@ -1109,10 +1217,14 @@ $\begin{aligned}#2\end{aligned}$% \tikzset{BBRCOM-EDGESTYLE/.style/.expand once=\bbrcomedgestyle}% % increase space - #3\baselineskip - \ifthenelse{\equal{\bbrcomtop}{}}{}{#3\baselineskip} + \ifthenelse{\lengthtest{#2<\@bb@firstmessageheight}} + {#3{\@bb@firstmessageheight}} + { + #3{0.75\baselineskip} + \ifthenelse{\equal{\bbrcomtop}{}}{}{#3{0.75\baselineskip}} + } - \setlength{\@bb@com@tmpoffset}{#2+\@bb@firstmessageheight+\bbrcombeforeskip}% + \setlength{\@bb@com@tmpoffset}{#2+\bbrcombeforeskip}% } \newcommand{\@bb@comfinalize}[1]{ @@ -1152,14 +1264,32 @@ $\begin{aligned}#2\end{aligned}$% \@bb@comfinalize{#4} } -\newcommand{\bbroraclequeryfrom}[1]{ +\newcommand{\bbroracleqryfrom}[1]{ \@bbroracleqry{#1}{->}{\@bb@oraclequery@hoffset}{\bbroracleqryspace} } -\newcommand{\bbroraclequeryto}[1]{ +\newcommand{\bbroracleqryto}[1]{ \@bbroracleqry{#1}{<-}{\@bb@oraclequery@hoffset}{\bbroracleqryspace} } +\newcommand{\@bbrchallengerqry}[4]{ + \@bb@comsetup{#1}{#3}{#4} + % + + \path[#2] (\@bb@lastchallenger.north east) -- ++ (0,-\@bb@com@tmpoffset) node[inner sep=0pt,outer sep=0pt] (\bbrcomsidename){} edge[BBRCOM-EDGESTYLE] node[above,BBRCOM-TOPSTYLE] (\bbrcomtopname) {\bbrcomtop} node[below,BBRCOM-BOTTOMSTYLE] (\bbrcombottomname) {\bbrcombottom} (\@bb@lastbox.west|-\bbrcomsidename) node[inner sep=0pt,outer sep=0pt] (\bbrcomosidename) {}; + % + \@bb@comfinalize{#4} +} + +\newcommand{\bbrchallengerqryfrom}[1]{ + \@bbrchallengerqry{#1}{<-}{\@bb@challengerquery@hoffset}{\bbrchallengerqryspace} +} + +\newcommand{\bbrchallengerqryto}[1]{ + \@bbrchallengerqry{#1}{->}{\@bb@challengerquery@hoffset}{\bbrchallengerqryspace} +} + + \newcommand*\bbrcomloopleft{} \newcommand*\bbrcomloopright{} @@ -1172,9 +1302,9 @@ $\begin{aligned}#2\end{aligned}$% \begingroup % for local keys \setkeys{bbrcomloop}{#3}% - \path[->] (#1) edge[bend right=50] node[left] (bbrleft) {\bbrcomloopleft} (#2); - \path[->] (#2) edge[bend right=50] node[right] (bbrright) {\bbrcomloopright} (#1); - \node () at ($(bbrleft)!0.5!(bbrright)$) {\bbrcomloopcenter}; + \path[->] (#1) edge[bend right=50] node[midway,left] (bbrleft) {\bbrcomloopleft} (#2); + \path[->] (#2) edge[bend right=50] node[midway,right] (bbrright) {\bbrcomloopright} (#1); + \node[at=($(bbrleft.north west)!0.5!(bbrright.north east)$),anchor=north]() {\bbrcomloopcenter}; \endgroup } @@ -1231,6 +1361,22 @@ $\begin{aligned}#2\end{aligned}$% \@bbrintertext{#1}{below right}{north east}{\@bb@query@hoffset}{\bbrqryspace}{#2} } +\newcommand{\bbrchallengertxt}[2][]{ +\begingroup +\setlength{\@bb@tmplength@b}{\bbrchallengerhdistance/2}% +\renewcommand{\bbrintertexthoffset}{\the\@bb@tmplength@b}% + \@bbrintertext{#1}{below left}{north west}{\@bb@challengerquery@hoffset}{\bbrchallengerqryspace}{#2} +\endgroup +} + +\newcommand{\bbroracletxt}[2][]{ +\begingroup +\setlength{\@bb@tmplength@b}{\bbroraclehdistance/2}% +\renewcommand{\bbrintertexthoffset}{\the\@bb@tmplength@b}% + \@bbrintertext{#1}{below left}{north west}{\@bb@oraclequery@hoffset}{\bbroracleqryspace}{#2} +\endgroup +} + \newcommand{\bbrmsgspace}[1]{ \@pc@globaladdtolength{\@bb@message@hoffset}{#1} } @@ -1243,6 +1389,9 @@ $\begin{aligned}#2\end{aligned}$% \@pc@globaladdtolength{\@bb@oraclequery@hoffset}{#1} } +\newcommand{\bbrchallengerqryspace}[1]{ +\@pc@globaladdtolength{\@bb@challengerquery@hoffset}{#1} +} %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% @@ -1273,9 +1422,9 @@ $\begin{aligned}#2\end{aligned}$% %%%%%%%%%%%%%%%%%%%%%%% \NewEnviron{pcvstack}[1][]{% % display minipage -\ifthenelse{\equal{#1}{center}}{\begin{pccenter}}{} -\begin{varwidth}[t]{15cm}\BODY\end{varwidth} -\ifthenelse{\equal{#1}{center}}{\end{pccenter}}{} +\ifthenelse{\equal{#1}{center}}{\begin{pccenter}}{}% +\begin{varwidth}[t]{2\linewidth}\hspace{0pt}\BODY\end{varwidth}% hspace needed for proper vertical positioning .. strange as it is. +\ifthenelse{\equal{#1}{center}}{\end{pccenter}}{}% } @@ -1512,7 +1661,7 @@ $\begin{aligned}#2\end{aligned}$% }{\@pc@releaseremember\endgroup} \createpseudocodecommand{gameprocedure} - {\stepcounter{pcgamecounter}} + {\addtocounter{pcgamecounter}{1}\renewcommand{\@withingame}{true}} {\ensuremath{\pcgamename_{\thepcgamecounter}\gameprocedurearg}} {} @@ -1524,6 +1673,7 @@ $\begin{aligned}#2\end{aligned}$% \newcommand{\bxgameprocedure}{ \begingroup% \renewcommand{\@withinspaces}{false}% +\renewcommand{\@withingame}{true}% \renewcommand{\@withinbxgame}{true}% \stepcounter{pcgamecounter}% \@ifnextchar[%] @@ -1531,15 +1681,13 @@ $\begin{aligned}#2\end{aligned}$% {\@bxgame@pseudocodeB}% } +\newcommand{\@pc@secondheader}{} + %tbx top boxed \createpseudocodecommand{tbxgameprocedure} - {\addtocounter{pcgamecounter}{1}% -\xdef\@pcfirstgamename{\thepcgamecounter}% -\addtocounter{pcgamecounter}{1}% -\xdef\@pcsecgamename{\thepcgamecounter}% -} - {\ensuremath{\pcgamename_{\@pcfirstgamename}\gameprocedurearg}% -\ \setlength{\fboxsep}{3pt}\protect\fbox{\ensuremath{\pcgamename_{\@pcsecgamename}\gameprocedurearg}}} + {\addtocounter{pcgamecounter}{1}\renewcommand{\@withingame}{true}%% +\renewcommand{\@pc@secondheader}{true}} + {\ensuremath{\pcgamename_{\thepcgamecounter}\gameprocedurearg}} {} |