How do I create two lstlisting environments that each have its own counter?
If I use for example
\lstnewenvironment{algorithm}[2]{
\renewcommand\lstlistingname{Algorithm}
\lstset{ ... }
} {}
\lstnewenvironment{program}[2]{
\renewcommand\lstlistingname{Program}
\lstset{ ... }
} {}
And then
\begin{algorithm}{Algorithm caption}{alg-label}
...
\end{algorithm}
\begin{program}{Program caption}{prg-label}
...
\end{program}
Then they will share the counter, i.e. it will result for example in
Algorithm 1.1
...
Program 1.2
...
I would like the counting to be independent for different listing environments.
I also use the caption package to create a nice caption. I've already tried many things but none really successfuly. The only way that I found that indicates how to change the counter/file extension is via i.e. \DeclareCaptionType[fileext=alg]{algorithm} but the problem is that this command already defines a new environment so I don't know how to use it together with a new listings environment and the caption package. I'm using for example the following settings:
\DeclareCaptionFont{white}{\color{white}}
\DeclareCaptionFormat{listing}{\colorbox[cmyk]{0.43, 0.35, 0.35,0.01}{\parbox{\textwidth}{\hspace{15pt}#1#2#3}}}
\captionsetup[lstlisting]{format=listing,labelfont=white,textfont=white, singlelinecheck=false, margin=0pt, font={bf,footnotesize}}