Code Comments
Programming Forum and web based access to our favorite programming groups.I have a need to view a log file that is constantly growing in length.
Data is being viewed in a Scrolled Text widget (Scrolled("Text")).
When I first start, I populate the Text widget with everything in the
file, and then effectively 'tail' it, adjusting srollbar using yview so
that user sees end of log file (i.e. bottom of text widget). This works.
But what is a way to preserve the view when the user manually scrolls up
to view an earlier part of the text? It is rather annoying to have yview
send him back to the bottom when new data is appended.
Mucho TIA,
TP
Post Follow-up to this messageTony P wrote:
> I have a need to view a log file that is constantly growing in length.
> Data is being viewed in a Scrolled Text widget (Scrolled("Text")).
>
> When I first start, I populate the Text widget with everything in the
> file, and then effectively 'tail' it, adjusting srollbar using yview so
> that user sees end of log file (i.e. bottom of text widget). This works.
>
> But what is a way to preserve the view when the user manually scrolls up
> to view an earlier part of the text? It is rather annoying to have yview
> send him back to the bottom when new data is appended.
>
> Mucho TIA,
> TP
>
Sounds like you are trying to do two mutually exclusive things.
If I was doing somthing similar, I would track the location of
the cursor versus the end of the file. If the cursor ('insert'
mark) is within 80 lines of the end, scroll the display on append,
if not, don't. Depending on how much and how fast data is added
to the file you may want to make it 20 or 200 or whatever.
If you want to examine the file, scroll up a page or two and
set the cursor. To go back to following the tail, scroll to the
end and set the cursor.
Insert some code in the tail routine similar to:
my $scrollthreshold = 80;
my ($endline, $endcol) = split/\./, $text->index('end');
my ($cursorline,$cursorcol) = split/\./, $text->index('insert');
$text->see('end') if (($endline - $cursorline) < $scrollthreshold);
Post Follow-up to this messagePowered by vBulletin
Copyright 2000-2006 Jelsoft Enterprises Limited.