| 1 |
% Copyright 2018 by Mark Wibrow |
| 2 |
% |
| 3 |
% This file may be distributed and/or modified |
| 4 |
% |
| 5 |
% 1. under the LaTeX Project Public License and/or |
| 6 |
% 2. under the GNU Public License. |
| 7 |
% |
| 8 |
% See the file doc/generic/pgf/licenses/LICENSE for more details. |
| 9 |
|
| 10 |
|
| 11 |
% Common keys for all logic gates. |
| 12 |
% |
| 13 |
\pgfkeys{/pgf/.cd,% |
| 14 |
logic gate input sep/.initial=0.125cm, |
| 15 |
logic gate inputs/.initial={normal,normal},% |
| 16 |
logic gate inverted radius/.initial=2pt, |
| 17 |
}% |
| 18 |
|
| 19 |
|
| 20 |
% Internal macro for parsing inputs. |
| 21 |
% |
| 22 |
\expandafter\ifx\csname pgf@lib@sh@logicgate@parseinputs\endcsname\relax% |
| 23 |
\def\pgf@lib@sh@logicgate@parseinputs#1{% |
| 24 |
\edef\pgf@lib@sh@temp{\pgfkeysvalueof{/pgf/logic gate inputs}}% |
| 25 |
\c@pgf@counta#1\relax% |
| 26 |
\c@pgf@countb0\relax% |
| 27 |
\expandafter\pgfutil@in@\expandafter,\expandafter{\pgf@lib@sh@temp}% |
| 28 |
\ifpgfutil@in@% |
| 29 |
\let\pgf@lib@sh@next\pgf@lib@sh@logicgate@parseinputs@long% |
| 30 |
\else% |
| 31 |
\let\pgf@lib@sh@next\pgf@lib@sh@logicgate@parseinputs@short% |
| 32 |
\fi% |
| 33 |
\pgf@lib@sh@next% |
| 34 |
}% |
| 35 |
\def\pgf@lib@sh@itext{i}% |
| 36 |
\def\pgf@lib@sh@invertedtext{inverted}% |
| 37 |
\def\pgf@lib@sh@atchar{@}% |
| 38 |
\def\pgf@lib@sh@gobbletilat#1@{}% |
| 39 |
\def\pgf@lib@sh@gobbletilatcomma#1@,{}% |
| 40 |
% |
| 41 |
% The `short' version for input specification is an extension of |
| 42 |
% ideas due to Juergen Werber and Christoph Bartoschek. |
| 43 |
% |
| 44 |
\def\pgf@lib@sh@logicgate@parseinputs@short{% |
| 45 |
\expandafter\pgf@lib@sh@logicgate@parseinputs@@short\pgf@lib@sh@temp @% |
| 46 |
}% |
| 47 |
\def\pgf@lib@sh@logicgate@parseinputs@@short#1{% |
| 48 |
\def\pgf@lib@sh@tmp{#1}% |
| 49 |
\ifx\pgf@lib@sh@tmp\pgf@lib@sh@atchar% |
| 50 |
\edef\pgf@lib@sh@logicgate@numinputs{\the\c@pgf@countb}% |
| 51 |
\let\pgf@lib@sh@next=\relax% |
| 52 |
\else% |
| 53 |
\ifnum\c@pgf@countb=\c@pgf@counta% |
| 54 |
\edef\pgf@lib@sh@logicgate@numinputs{\the\c@pgf@countb}% |
| 55 |
\let\pgf@lib@sh@next=\pgf@lib@sh@gobbletilat% |
| 56 |
\else% |
| 57 |
\advance\c@pgf@countb by1\relax% |
| 58 |
\expandafter\ifx\pgf@lib@sh@itext#1% |
| 59 |
\expandafter\pgf@sh@resavedmacro\expandafter{\csname input-\the\c@pgf@countb\endcsname}{% |
| 60 |
\expandafter\def\csname input-\the\c@pgf@countb\endcsname{i}}% |
| 61 |
\else% |
| 62 |
\expandafter\pgf@sh@resavedmacro\expandafter{\csname input-\the\c@pgf@countb\endcsname}{% |
| 63 |
\expandafter\def\csname input-\the\c@pgf@countb\endcsname{n}}% |
| 64 |
\fi% |
| 65 |
\let\pgf@lib@sh@next=\pgf@lib@sh@logicgate@parseinputs@@short% |
| 66 |
\fi% |
| 67 |
\fi% |
| 68 |
\pgf@lib@sh@next% |
| 69 |
}% |
| 70 |
|
| 71 |
|
| 72 |
\def\pgf@lib@sh@logicgate@parseinputs@long{% |
| 73 |
\expandafter\pgf@lib@sh@logicgate@parseinputs@@long\pgf@lib@sh@temp,@,% |
| 74 |
}% |
| 75 |
\def\pgf@lib@sh@logicgate@parseinputs@@long#1,{% |
| 76 |
\def\pgf@lib@sh@tmp{#1}% |
| 77 |
\ifx\pgf@lib@sh@tmp\pgf@lib@sh@atchar% |
| 78 |
\edef\pgf@lib@sh@logicgate@numinputs{\the\c@pgf@countb}% |
| 79 |
\let\pgf@lib@sh@next=\relax% |
| 80 |
\else% |
| 81 |
\ifnum\c@pgf@countb=\c@pgf@counta% |
| 82 |
\edef\pgf@lib@sh@logicgate@numinputs{\the\c@pgf@countb}% |
| 83 |
\let\pgf@lib@sh@next=\pgf@lib@sh@gobbletilatcomma% |
| 84 |
\else% |
| 85 |
\advance\c@pgf@countb by1\relax% |
| 86 |
\def\pgf@lib@sh@temp{#1}% |
| 87 |
\ifx\pgf@lib@sh@invertedtext\pgf@lib@sh@temp% |
| 88 |
\expandafter\pgf@sh@resavedmacro\expandafter{\csname input-\the\c@pgf@countb\endcsname}{% |
| 89 |
\expandafter\def\csname input-\the\c@pgf@countb\endcsname{i}}% |
| 90 |
\else% |
| 91 |
\expandafter\pgf@sh@resavedmacro\expandafter{\csname input-\the\c@pgf@countb\endcsname}{% |
| 92 |
\expandafter\def\csname input-\the\c@pgf@countb\endcsname{n}}% |
| 93 |
\fi% |
| 94 |
\let\pgf@lib@sh@next=\pgf@lib@sh@logicgate@parseinputs@@@long% |
| 95 |
\fi% |
| 96 |
\fi% |
| 97 |
\pgf@lib@sh@next% |
| 98 |
}% |
| 99 |
\def\pgf@lib@sh@logicgate@parseinputs@@@long{% |
| 100 |
\pgfutil@ifnextchar x{\pgf@lib@sh@logicgate@parseinputs@@long}% |
| 101 |
{\pgf@lib@sh@logicgate@parseinputs@@long}% |
| 102 |
}% |
| 103 |
\fi% |