% output=pdftex output=en
%
% copyright=pragma-ade readme=readme.pdf licence=cc-by-nc-sa

\environment back-0

\let\fakeparindent\empty

\startuseMPgraphic{mpos:par:columnset:shade}
  for i=1 upto nofmultipars :
    if     multilocs[i]=1 : fill multipars[i] withcolor .5[red,  white] ;
    elseif multilocs[i]=2 : fill multipars[i] withcolor .5[green,white] ;
    else                  : fill multipars[i] withcolor .5[blue, white] ;
    fi ;
  endfor ;
\stopuseMPgraphic

\setupindenting[medium,first]

\setrandomseed{1000}

\definecolumnset[two][n=4,distance=.5cm] 

\definetextbackground
  [test]
  [location=text,
   backgroundcolor=blue,
   mp=mpos:par:columnset:shade,
   methode=mpos:par:columnset,
   before=\blank,
   after=\blank]

\starttext

\startcolumnset[two]

\def\test #1 #2 #3 % preword break needed, else loop 
  {\bgroup
   \dontcomplain
   \hangindent#1\relax
   \hangafter #2\relax
   \parindent #3\relax
   \starttextbackground[test]\prewordbreak\fakewords{30}{200}\prewordbreak\stoptextbackground
   \blank
   \egroup}

\startbuffer
\test  2cm  -2  1cm
\test  2cm  -2  0cm
\test  2cm  -2 -1cm

\test  2cm -12  1cm
\test  2cm -12  0cm
\test  2cm -12 -1cm

\test  2cm -82  1cm
\test  2cm -82  0cm
\test  2cm -82 -1cm
\stopbuffer

%\dorecurse{2}{\getbuffer} \stopcolumnset 

\dorecurse{15}{\getbuffer}

\startbuffer
\test -2cm  -2  1cm
\test -2cm  -2  0cm
\test -2cm  -2 -1cm

\test -2cm -12  1cm
\test -2cm -12  0cm
\test -2cm -12 -1cm
\stopbuffer

\dorecurse{15}{\getbuffer}

\startbuffer
\test  2cm   2  1cm
\test  2cm   2  0cm
\test  2cm   2 -1cm

\test  2cm  12  1cm
\test  2cm  12  0cm
\test  2cm  12 -1cm
\stopbuffer

\dorecurse{15}{\getbuffer} %%% ok

\startbuffer
\test -2cm   2  1cm
\test -2cm   2  0cm
\test -2cm   2 -1cm

\test -2cm  12  1cm
\test -2cm  12  0cm
\test -2cm  12 -1cm
\stopbuffer

\dorecurse{15}{\getbuffer}

\stopcolumnset \stoptext
