Is scrollbar at end?



I have a number of scrolling text widgets that are added to with code like:

..w.f.t insert end "$line\n"
..w.f.t see end

The "see end" is to get the text window to track the end of the text as
it's extended, of course. But this has a problem:  If I've scrolled it back
to look at something, and a new line comes along, the view pops back
to the end.  If the text widget is being used for something like a log file,
this can make it very difficult to use the scrollbar if there's much activity.

It seems to me that what is needed is something like:

..w.f.t insert end "$line\n"
if [.w.f.sb is at end of .w.f.t] {
     .w.f.t see end
}

where .w.f.sb is the scrollbar for .w.f.t, of course.  The problem is that
I haven't found how to translate that bracketed test into tcl/tk.  I've
googled for a lot of likely phrases, dug around in the usual printed
books, searched through this newsgroup, all to no avail.

Is there a way to get the behavior I'm looking for?  It's just the common
scrolling behavior of lots of other programs, where the window tracks
the end as long as the scrollbar is at the end, but doesn't scroll if the
user has scrolled the window back.
.