I would like to be able to wrap source code around a figure. Here's a MWE that should make it clear what I have in mind:
\documentclass{article}
\usepackage{wrapfig}
\usepackage{listings}
\lstset{language={},
breaklines=true,
basicstyle=\ttfamily,
breakatwhitespace=true}
\begin{document}
\noindent
\def \myasywidth {5cm}
\begin{wrapfigure}{l}{\myasywidth}
\vspace{0pt}
\rule{\myasywidth}{\myasywidth}
\end{wrapfigure}
%
%
\begin{lstlisting}
settings.outformat="pdf";
size(5cm,0);
real xmin = -0.1;
real xmax = 2;
real ymin = -0.1;
real ymax = 2;
path s = (0,0){up} .. (1/2,sqrt(1/2)) .. (1,1) .. (xmax,sqrt(xmax));
fill(s -- (xmax,0) -- cycle, mediumgray);
draw(s);
arrowbar axisarrow = Arrow(TeXHead);
draw((xmin,0) -- (xmax,0), arrow=axisarrow);
draw((0,ymin) -- (0,ymax), arrow = axisarrow);
real x = 1.4;
real dx = .05;
real t0 = times(s,x)[0];
real t1 = times(s,x+dx)[0];
path striptop = subpath(s,t0,t1);
draw((x,0) -- striptop -- (x+dx,0) -- cycle, blue);
\end{lstlisting}
%
\end{document}
Here's the result (produced with some warnings about conflicting environments):

How do I make this work? (In addition to wrapping, the solution should also restore the behavior of the listings package that continuations of automatically broken lines should be indented.)

path s = (0,0){up} .. (1/2,sqrt(1/2)) .. (1,1) .. (xmax,sqrt(xmax));) is split into several shorter lines, I want all but the first of these indented, so that it is easy to see that this is conceptually a single line of code. This is the normal behavior of thelstlistingenvironment, but usingwrapfigureseems to break it. – Charles Staats Sep 17 '13 at 16:41wrapfigure) to the next line. – Charles Staats Sep 17 '13 at 16:49