summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/latex/tikz-timing/tikz-timing-counters.sty
blob: e81d3412b6860c20bbae8be3a24b7df22bc2f2ce (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
%%
%% This is file `tikz-timing-counters.sty',
%% generated with the docstrip utility.
%%
%% The original source files were:
%%
%% tikz-timing.dtx  (with options: `lib,lib-counters')
%% 
%% Copyright (C) 2009 by Martin Scharrer <martin@scharrer-online.de>
%% 
%% This work may be distributed and/or modified under the
%% conditions of the LaTeX Project Public License, either version 1.3c
%% of this license or (at your option) any later version.
%% The latest version of this license is in
%% 
%%    http://www.latex-project.org/lppl.txt
%% 
%% and version 1.3c or later is part of all distributions of LaTeX
%% version 2008/05/04 or later.
%% 
%% This work has the LPPL maintenance status `maintained'.
%% 
%% The Current Maintainer of this work is Martin Scharrer.
%% 
%% This work consists of the files tikz-timing.dtx, tikz-timing.ins
%% and the derived file tikz-timing.sty.
%% 
\RequirePackage{svn-prov}[2009/05/03]
\ProvidesPackageSVN[tikz-timing-counters]
  {$Id: tikz-timing.dtx 1580 2009-12-09 11:14:01Z martin $}
  [v0.7
   TikZ-Timing Library for
   counter values]
\GetFileInfoSVN*%
\RequirePackage{tikz-timing}[\filedate]%
\DefineFileInfoSVN

\tikzset{%
  timing/new counter/.style={timing/counter/new={#1}},
  timing/counter/.cd,
  new/.code={\tikztiming@counter@new{#1}},
  new/.value required,
  opt/.cd,
  char/.estore in=\tikztiming@counter@char,
  reset char/.estore in=\tikztiming@counter@resetchar,
  base/.estore in=\tikztiming@counter@base,
  half width char/.estore in=\tikztiming@counter@hwchar,
  char/.value required,
  reset char/.value required,
  base/.value required,
  half width char/.value required,
}
\def\tikztiming@counter@new#1{%
  \let\tikztiming@counter@char\empty
  \let\tikztiming@counter@resetchar\empty
  \def\tikztiming@counter@base{10}%
  \let\tikztiming@counter@hwchar\relax
  \pgfqkeys{/tikz/timing/counter/opt}{#1}%
  \ifx\tikztiming@counter@char\empty
    \PackageError{tikz-timing-counters}{Counter character must be given using
    the 'char' key!}%
  \else
    \edef\@tempa{%
      \noexpand\tikztiming@counter@new@{\tikztiming@counter@char}{\tikztiming@counter@base}%
        {\tikztiming@counter@hwchar}{\tikztiming@counter@resetchar}%
    }%
    \expandafter\@tempa
  \fi
}
\def\tikztiming@counter@new@#1#2#3#4{%
  \newcounter{tikztiming@counter@#1}%
  \tikzset{timing/counter/#1/.append style={}}%
  \tikztimingmetachar{#1}[1]{##1D{[timing/counter/#1]\tikztiming@counter@vs{#1}{#2}}}%
  \ifx\tikztiming@counter@hwchar\empty\else
    \ifx\tikztiming@counter@hwchar\relax
      \tikztiming@iflower{#1}{}%
        {\lowercase{\tikztimingmetachar{#1}}[1]%
          {##1d{[timing/counter/#1]\tikztiming@counter@vs{#1}{#2}}}}%
    \else
      \tikztimingmetachar{#3}[1]{##1d{[timing/counter/#1]\tikztiming@counter@vs{#1}{#2}}}%
    \fi
  \fi
  \ifx\tikztiming@counter@resetchar\empty\else
    \tikztimingmetachar{#4}[1]{[|/utils/exec=\tikztiming@counter@reset{#1}{##1}|]}%
  \fi
}
\def\tikztiming@counter@reset#1#2{%
  \pgfmathsetcounter{tikztiming@counter@#1}{round((#2)/\tikztiming@wscale)}%
  \setcounter{tikztiming@counter@#1}{\value{tikztiming@counter@#1}}%
}
\def\tikztiming@counter@vs#1#2{%
  \pgfmathdectoBase\pgfmathresult{\value{tikztiming@counter@#1}}{#2}%
  \pgfmathresult
  \stepcounter{tikztiming@counter@#1}%
}
\RequirePackage{pgfopts}
\ProcessPgfOptions{/tikz/timing/counter}
\endinput
%%
%% End of file `tikz-timing-counters.sty'.