Okay, the "before={\testpage[] ...}  seems to solve my problems with the hanging empty text backgrounds.
Thanks Aditya




Message: 3
Date: Tue, 21 Apr 2009 09:10:16 -0400 (EDT)
From: Aditya Mahajan <adityam@umich.edu>
Subject: Re: [NTG-context] framed text question
To: mailing list for ConTeXt users <ntg-context@ntg.nl>
Message-ID: <alpine.LNX.2.00.0904210908150.8859@ybpnyubfg.ybpnyqbznva>
Content-Type: TEXT/PLAIN; charset=US-ASCII; format=flowed

On Tue, 21 Apr 2009, Jos van Gisbergen wrote:

> Hi,
>
> I have a question regarding framed text.
> To obtain framed verbatim text that breaks over pages, I use the macro
> \definetextbackground. I have encountered a slight problem, however:
> sometimes the upper part of the frame appears on the bottom of the
> page with no text in it (because there's not enough room). The strange
> thing is that if I comment out the setupcolors macro the problem
> disappears (in the example that is).

I sometimes use

\definetextbackground[....][before={\testpage[3], .. other options .. ]

The \testpage[3] checks if there is enough space to put three lines, if
not it issues a page break. In most cases this gets rid of the hanging
empty text backgrounds at the bottom of a page.

Aditya