Debian Codegraph @

texmf-dist/tex/latex/tikz-timing/tikz-timing-counters.sty

raw
1 %%
2 %% This is file `tikz-timing-counters.sty',
3 %% generated with the docstrip utility.
4 %%
5 %% The original source files were:
6 %%
7 %% tikz-timing.dtx (with options: `tikz-timing-counters.sty')
8 %%
9 %% IMPORTANT NOTICE:
10 %%
11 %% For the copyright see the source file.
12 %%
13 %% Any modified versions of this file must be renamed
14 %% with new filenames distinct from tikz-timing-counters.sty.
15 %%
16 %% For distribution of the original source see the terms
17 %% for copying and modification in the file tikz-timing.dtx.
18 %%
19 %% This generated file may be distributed as long as the
20 %% original source files, as listed above, are part of the
21 %% same distribution. (The sources need not necessarily be
22 %% in the same archive or directory.)
23 %% Copyright (C) 2009-2012 by Martin Scharrer <[email protected]>
24 %% ----------------------------------------------------------------------
25 %% This work may be distributed and/or modified under the
26 %% conditions of the LaTeX Project Public License, either version 1.3
27 %% of this license or (at your option) any later version.
28 %% The latest version of this license is in
29 %% http://www.latex-project.org/lppl.txt
30 %% and version 1.3 or later is part of all distributions of LaTeX
31 %% version 2005/12/01 or later.
32 %%
33 %% This work has the LPPL maintenance status `maintained'.
34 %%
35 %% The Current Maintainer of this work is Martin Scharrer.
36 %%
37 %% This work consists of the files tikz-timing.dtx and tikz-timing.ins
38 %% and the derived filebase tikz-timing*.sty.
39 %%
40 \NeedsTeXFormat{LaTeX2e}[1999/12/01]
41 \ProvidesPackage{tikz-timing-counters}[%
42 2017/12/20
43 v0.7f
44 tikz-timing library for counter values]
45 \newif\if@tikztiming@counter@wraps
46
47 \tikzset{%
48 timing/new counter/.style={timing/counter/new={#1}},
49 timing/counter/.cd,
50 new/.code={\tikztiming@counter@new{#1}},
51 new/.value required,
52 opt/.cd,
53 char/.initial=,
54 char/.value required,
55 reset char/.initial=,
56 reset char/.value required,
57 reset type/.is choice,
58 reset type/width/.code={\def\tikztiming@resettype{0}},
59 reset type/arg/.code={\def\tikztiming@resettype{1}},
60 reset type/both/.code={\def\tikztiming@resettype{2}},
61 reset type/Both/.code={\def\tikztiming@resettype{3}},
62 half width char/.initial=,
63 half width char/.value required,
64 base/.initial=10,
65 base/.value required,
66 increment/.initial=1,
67 increment/.value required,
68 max value/.initial=,
69 max value/.value required,
70 min value/.initial=,
71 min value/.value required,
72 wraps/.is if=@tikztiming@counter@wraps,
73 digits/.initial=,
74 digits/.value required,
75 fg style/.initial=,
76 bg style/.initial=,
77 text style/.initial=,
78 text format/.initial=,
79 fg style/.value required,
80 bg style/.value required,
81 text style/.value required,
82 text format/.value required,
83 }
84 \def\tikztiming@counter@textformat{}%
85 \def\tikztimingcounter#1{%
86 \csname tikztiming@counter@#1\endcsname
87 }
88 \def\tikztimingsetcounter#1#2{%
89 \begingroup
90 \pgfmathtruncatemacro\@tempa{#2}%
91 \expandafter\global\expandafter\let\csname tikztiming@counter@#1\endcsname\@tempa
92 \endgroup
93 }
94 \def\tikztiming@counter@new#1{%
95 \begingroup
96 \def\tikztiming@resettype{0}%
97 \pgfqkeys{/tikz/timing/counter/opt}{#1}%
98 \tikzset{timing/counter/opt/char/.get=\counterchar}%
99 \ifx\counterchar\empty
100 \PackageError{tikz-timing-counters}{Counter character must be given using
101 the 'char' key!}{}%
102 \endgroup
103 \else
104 \pgfkeys{/tikz/timing/counter/opt/min value/.get=\min}%
105 \pgfkeys{/tikz/timing/counter/opt/max value/.get=\max}%
106 \if@tikztiming@counter@wraps
107 \ifx\min\empty
108 \def\min{0}%
109 \fi
110 \ifx\max\empty
111 \PackageError{tikz-timing-counters}{The option 'wraps' needs the option 'max value' to be set!}{}%
112 \fi
113 \def\@tempb{%
114 \noexpand\tikztiming@counter@wrap%
115 {\expandafter\unexpanded\expandafter{\min}}%
116 {\expandafter\unexpanded\expandafter{\max}}%
117 }%
118 \else
119 \ifx\min\empty
120 \ifx\max\empty
121 \let\@tempb\empty
122 \else
123 \def\@tempb{%
124 \noexpand\tikztiming@counter@maxsat%
125 {\expandafter\unexpanded\expandafter{\max}}%
126 }%
127 \fi
128 \else
129 \ifx\max\empty
130 \def\@tempb{%
131 \noexpand\tikztiming@counter@minsat%
132 {\expandafter\unexpanded\expandafter{\min}}%
133 }%
134 \else
135 \def\@tempb{%
136 \noexpand\tikztiming@counter@minmaxsat%
137 {\expandafter\unexpanded\expandafter{\min}}%
138 {\expandafter\unexpanded\expandafter{\max}}%
139 }%
140 \fi
141 \fi
142 \fi
143 \pgfkeys{/tikz/timing/counter/opt/fg style/.get=\fgstyle}%
144 \pgfkeys{/tikz/timing/counter/opt/bg style/.get=\bgstyle}%
145 \pgfkeys{/tikz/timing/counter/opt/text style/.get=\textstyle}%
146 \pgfkeys{/tikz/timing/counter/opt/text format/.get=\textformat}%
147 \pgfkeys{/tikz/timing/counter/opt/increment/.get=\increment}%
148 \edef\@tempa{%
149 \noexpand\tikztiming@counter@new@
150 {\pgfkeysvalueof{/tikz/timing/counter/opt/char}}%
151 {\pgfkeysvalueof{/tikz/timing/counter/opt/base}}%
152 {\pgfkeysvalueof{/tikz/timing/counter/opt/half width char}}%
153 {\pgfkeysvalueof{/tikz/timing/counter/opt/reset char}}%
154 {\pgfkeysvalueof{/tikz/timing/counter/opt/digits}}%
155 {\expandafter\unexpanded\expandafter{\increment}}%
156 {\@tempb}%
157 {\min}%
158 {\tikztiming@resettype}%
159 {\expandafter\unexpanded\expandafter{\fgstyle}}%
160 {\expandafter\unexpanded\expandafter{\bgstyle}}%
161 {\expandafter\unexpanded\expandafter{\textstyle}}%
162 {\expandafter\unexpanded\expandafter{\textformat}}%
163 }%
164 \expandafter\expandafter\expandafter\endgroup
165 \expandafter\@tempa
166 \fi
167 }
168 \def\tikztiming@counter@new@#1#2#3#4#5#6#7#8#9{%
169 \ifx\empty#8\empty
170 \@namedef{tikztiming@counter@#1}{0}%
171 \else
172 \expandafter
173 \pgfmathtruncatemacro\csname tikztiming@counter@#1\endcsname{#8}%
174 \fi
175 \tikztimingmetachar{#1}[1]{ { [timing/counter/#1] ##1D{[timing/counter/#1/text]\tikztiming@counter@vs{#1}{#2}{#5}{#6}{#7}} } }%
176 \ifx\empty#3\empty
177 \tikztiming@iflower{#1}{}%
178 {\lowercase{\tikztimingmetachar{#1}}[1]%
179 { { [timing/counter/#1] ##1d{[timing/counter/#1/text]\tikztiming@counter@vs{#1}{#2}{#5}{#6}{#7}}} }%
180 }%
181 \else
182 \tikztimingmetachar{#3}[1]{%
183 { [timing/counter/#1] ##1d{[timing/counter/#1/text]\tikztiming@counter@vs{#1}{#2}{#5}{#6}{#7}} }%
184 }%
185 \fi
186 \ifx\empty#4\empty\else
187 \ifcase0#9\relax
188 \tikztimingmetachar{#4}[1]{[|/utils/exec=\tikztiming@counter@reset{#1}{##1}|]}%
189 \or
190 \tikztimingmetachar{#4}[2]{[|/utils/exec=\tikztimingsetcounter{#1}{##2}|]}%
191 \or
192 \uppercase{\tikztimingmetachar{#4}}[1]{[|/utils/exec=\tikztiming@counter@reset{#1}{##1}|]}%
193 \lowercase{\tikztimingmetachar{#4}}[2]{[|/utils/exec=\tikztimingsetcounter{#1}{##2}|]}%
194 \or
195 \lowercase{\tikztimingmetachar{#4}}[1]{[|/utils/exec=\tikztiming@counter@reset{#1}{##1}|]}%
196 \uppercase{\tikztimingmetachar{#4}}[2]{[|/utils/exec=\tikztimingsetcounter{#1}{##2}|]}%
197 \fi
198 \fi
199 \tikztiming@counter@new@@{#1}%
200 }
201 \def\tikztiming@counter@new@@#1#2#3#4#5{%
202 \tikzset{timing/counter/#1/.style={}}%
203 \ifx\empty#2\empty\else
204 \tikzset{timing/counter/#1/.append style={%
205 /tikz/timing/d/.style={#2}%
206 }}%
207 \fi
208 \ifx\empty#3\empty\else
209 \tikzset{timing/counter/#1/.append style={%
210 /tikz/timing/d/background/.style={#3}%
211 }}%
212 \fi
213 \tikzset{timing/counter/#1/text/.style={#4}}%
214 \ifx\empty#5\empty\else
215 \tikzset{timing/counter/#1/.append style={%
216 /utils/exec={\def\tikztiming@counter@textformat{#5}}%
217 }}%
218 \fi
219 }
220 \def\tikztiming@counter@reset#1#2{%
221 \begingroup
222 \pgfmathtruncatemacro\@tempa{round((#2)/\tikztiming@wscale)}%
223 \expandafter\global\expandafter\let\csname tikztiming@counter@#1\endcsname\@tempa
224 \endgroup
225 }
226 \def\tikztiming@counter@vs#1#2#3#4#5{%
227 \begingroup
228 \ifx\empty#3\empty\else
229 \pgfmathsetbasenumberlength{#3}%
230 \fi
231 \ifnum#2=10
232 \expandafter\expandafter\expandafter\tikztiming@counter@textformat
233 \expandafter\expandafter\expandafter{\csname tikztiming@counter@#1\endcsname}%
234 \else
235 \pgfmathdectoBase\pgfmathresult{\@nameuse{tikztiming@counter@#1}}{#2}%
236 \expandafter\tikztiming@counter@textformat\expandafter{\pgfmathresult}%
237 \fi
238 \edef\N{\@nameuse{tikztiming@counter@#1}}%
239 \pgfmathtruncatemacro\N{\N + #4}%
240 #5%
241 \expandafter\global\expandafter\let\csname tikztiming@counter@#1\endcsname\N
242 \endgroup
243 }
244 \def\tikztiming@counter@minsat#1{%
245 \pgfmathtruncatemacro\MIN{#1}%
246 \ifnum\N<\MIN \let\N\MIN \fi
247 }
248 \def\tikztiming@counter@maxsat#1{%
249 \pgfmathtruncatemacro\MAX{#1}%
250 \ifnum\N>\MAX \let\N\MAX \fi
251 }
252 \def\tikztiming@counter@minmaxsat#1#2{%
253 \tikztiming@counter@minsat{#1}%
254 \tikztiming@counter@maxsat{#2}%
255 }
256 \def\tikztiming@counter@wrap#1#2{%
257 \pgfmathtruncatemacro\MIN{#1}%
258 \pgfmathtruncatemacro\MAX{#2}%
259 \ifnum\N>\MAX
260 \pgfmathtruncatemacro\N{\MIN + (\N-\MAX-1)}%
261 \fi
262 \ifnum\N<\MIN
263 \pgfmathtruncatemacro\N{\MAX - (\MIN-\N+1)}%
264 \fi
265 }
266 \RequirePackage{pgfopts}
267 \ProcessPgfOptions{/tikz/timing/counter}
268 \endinput
269 %%
270 %% End of file `tikz-timing-counters.sty'.