X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=lib%2FTerm%2FProgressBar.pm;h=dcbc252860863d9b4ad8c1b0a6c1cab259ac9cf8;hb=3c81f09f8a35c65542ddd71e115d06ea44f3478f;hp=f1ed1dc1e3fe3b1414d32ec18a803a44000464b3;hpb=3797cda1b0da9caa24c7ff35e910e1f318c77918;p=term-progressbar.git diff --git a/lib/Term/ProgressBar.pm b/lib/Term/ProgressBar.pm index f1ed1dc..dcbc252 100644 --- a/lib/Term/ProgressBar.pm +++ b/lib/Term/ProgressBar.pm @@ -1,5 +1,3 @@ -# (X)Emacs mode: -*- cperl -*- - package Term::ProgressBar; #XXX TODO Redo original test with count=20 @@ -13,18 +11,18 @@ package Term::ProgressBar; # If name is wider than term, trim name # Don't update progress bar on new? -=head1 NAME +=head1 NAME Term::ProgressBar - provide a progress meter on a standard terminal -=head1 SYNOPSIS +=head1 SYNOPSIS use Term::ProgressBar; $progress = Term::ProgressBar->new ({count => $count}); $progress->update ($so_far); -=head1 DESCRIPTION +=head1 DESCRIPTION Term::ProgressBar provides a simple progress bar on the terminal, to let the user know that something is happening, roughly how much stuff has been done, @@ -34,7 +32,7 @@ A typical use sets up the progress bar with a number of items to do, and then calls L to update the bar whenever an item is processed. Often, this would involve updating the progress bar many times with no -user-visible change. To avoid uneccessary work, the update method returns a +user-visible change. To avoid unnecessary work, the update method returns a value, being the update value at which the user will next see a change. By only calling update when the current value exceeds the next update value, the call overhead is reduced. @@ -75,6 +73,8 @@ bar for the same width. } } +see eg/simle_use.pl + Here is a simple example. The process considers all the numbers between 0 and MAX, and updates the progress bar whenever it finds one. Note that the progress bar update will be very erratic. See below for a smoother example. @@ -97,6 +97,8 @@ distribution set (it is not installed as part of the module). $progress->update($_) } +See eg/smooth_bar.pl + This example calls update for each value considered. This will result in a much smoother progress update, but more program time is spent updating the bar than doing the "real" work. See below to remedy this. This example does @@ -145,7 +147,7 @@ distribution set (it is not installed as part of the module. my $progress = Term::ProgressBar->new({name => 'Powers', count => $max, - ETA => linear, }); + ETA => 'linear', }); $progress->max_update_rate(1); my $next_update = 0; @@ -250,7 +252,7 @@ use constant DEBUG => 0; use vars qw($PACKAGE $VERSION); $PACKAGE = 'Term-ProgressBar'; -$VERSION = '2.09'; +$VERSION = '2.13'; # ---------------------------------- # CLASS CONSTRUCTION @@ -492,7 +494,7 @@ sub init { } else { $config{bar_width} = $target; die "configured bar_width $config{bar_width} < 1" - if $config{bar_width} < 1; + if $config{bar_width} < 1; } } @@ -581,6 +583,24 @@ action, and not in action, respectively. =back +=head2 Configuration + +=over 4 + +=item lbrack + +Left bracket ( defaults to [ ) + + $progress->lbrack('<'); + +=item rbrack + +Right bracket ( defaults to ] ) + + $progress->rbrack('>'); + +=back + =cut # Private Scalar Components @@ -816,10 +836,10 @@ sub update { } } for ($self->{last_printed}) { - unless (defined and $_ eq $to_print) { - print $fh $to_print; - } - $_ = $to_print; + unless (defined and $_ eq $to_print) { + print $fh $to_print; + } + $_ = $to_print; } $next -= $self->offset; @@ -920,13 +940,9 @@ sub message { # ---------------------------------------------------------------------- -=head1 BUGS - -Z<> - =head1 REPORTING BUGS -Email the author. +via RT: L =head1 COMPATIBILITY @@ -936,22 +952,22 @@ Various other defaults are set to emulate version one (e.g., the major output character is '#', the bar width is set to 50 characters and the output filehandle is not treated as a terminal). This mode is deprecated. -=head1 AUTHOR +=head1 AUTHOR Martyn J. Pearce fluffy@cpan.org Significant contributions from Ed Avis, amongst others. +=head1 MAINTAINER + +Gabor Szabo L + =head1 COPYRIGHT Copyright (c) 2001, 2002, 2003, 2004, 2005 Martyn J. Pearce. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. -=head1 SEE ALSO - -Z<> - =cut 1; # keep require happy.