[Tex/LaTex] lstlisting: how to set code color and frame color

colorlistings

I am using lstlisting to show some code in my PDF. The problem is that when I use:

  basicstyle=\fontfamily{pcr}\selectfont\footnotesize\color{red},

to change the code color (not only the language keywords), the frame color changes too.
What I want to achive is to have the source code all red and the frame black.
Here my lstset:

\lstset{ 
    language=C++, % choose the language of the code
    basicstyle=\fontfamily{pcr}\selectfont\footnotesize\color{red},
    keywordstyle=\color{black}\bfseries, % style for keywords
    numbers=none, % where to put the line-numbers
    numberstyle=\tiny, % the size of the fonts that are used for the line-numbers     
    backgroundcolor=\color{darkgray},
    showspaces=false, % show spaces adding particular underscores
    showstringspaces=false, % underline spaces within strings
    showtabs=false, % show tabs within strings adding particular underscores
    frame=single, % adds a frame around the code
    tabsize=2, % sets default tabsize to 2 spaces
    rulesepcolor=\color{gray}
    captionpos=b, % sets the caption-position to bottom
    breaklines=true, % sets automatic line breaking
    breakatwhitespace=false, 
}

Best Answer

The package listings provide the option rulecolor.

rulecolor=\color{black},

To get a complete overview of all options have a look into the documentation.

An example with your settings is given below. I think with your settings you can see nothing.

\documentclass{article}
\usepackage{xcolor}
\usepackage{listings}
\lstset{ 
    language=C++, % choose the language of the code
    basicstyle=\fontfamily{pcr}\selectfont\footnotesize\color{red},
    keywordstyle=\color{black}\bfseries, % style for keywords
    numbers=none, % where to put the line-numbers
    numberstyle=\tiny, % the size of the fonts that are used for the line-numbers     
    backgroundcolor=\color{darkgray},
    showspaces=false, % show spaces adding particular underscores
    showstringspaces=false, % underline spaces within strings
    showtabs=false, % show tabs within strings adding particular underscores
    frame=single, % adds a frame around the code
    tabsize=2, % sets default tabsize to 2 spaces
    rulesepcolor=\color{gray},
    rulecolor=\color{black},
    captionpos=b, % sets the caption-position to bottom
    breaklines=true, % sets automatic line breaking
    breakatwhitespace=false, 
}
\begin{document}
\begin{lstlisting}

Some Code 

for loop

if

return
\end{lstlisting}
\end{document}