Commit 58affb2e authored by Salvatore Bonaccorso's avatar Salvatore Bonaccorso

Merge branch 'upstream'

parents c6cfcd6c 2db7c685
2010-02-13 Jaromir Hradilek <jhradilek@gmail.com>
* Makefile, src/w2do.pl, src/w2html.pl, src/w2text.pl: Increased version for
a release.
2010-01-22 Jaromir Hradilek <jhradilek@gmail.com>
* src/w2html.pl: Updated the documentation.
* src/w2html.pl: Improved the progress bar look.
* src/w2html.pl: Implemented `--stats' command-line option.
* src/w2html.pl: Implemented support for overall statistics.
* src/w2html.pl: Minor code clean-up. I have changed the function names to
more self explaining ones.
* src/w2html.pl: Altered the look of generator meta information.
* src/w2do.pl: Redesigned the progress bar colour representation. Despite
the fact that most of the responders liked the previous design more, I just
did not feel comfortable with it. I prefer simplicity, so I guess this is the
advantage of being the lead (and only) developer.
2010-01-20 Jaromir Hradilek <jhradilek@gmail.com>
* src/w2do.pl: Added experimental colour support for stats listing.
* INSTALL, Makefile, src/w2do.pl, src/w2html.pl, src/w2text.pl: Increased
version for a release. I have also updated the copyright entries. We are
three years old now!
......
......@@ -28,7 +28,7 @@ mandir = $(prefix)/share/man
man1dir = $(mandir)/man1
# Additional information:
VERSION = 2.3.0
VERSION = 2.3.1
# Make rules; please do not edit these unless you really know what you are
# doing:
......
......@@ -27,7 +27,7 @@ use Text::Wrap;
# General script information:
use constant NAME => basename($0, '.pl'); # Script name.
use constant VERSION => '2.3.0'; # Script version.
use constant VERSION => '2.3.1'; # Script version.
# General script settings:
our $homedir = $ENV{HOME} || $ENV{USERPROFILE} || '.';
......@@ -380,18 +380,6 @@ sub choose_id {
return $chosen;
}
# Compose progress bar:
sub compose_progressbar {
my $percent = shift || 0;
# Decide which pointer to use:
my $pointer = ($percent > 0 && $percent < 100) ? '>' : '';
# Return the progress bar string:
return '[' . '=' x int($percent/10) . $pointer .
' ' x ($percent ? (9 - int($percent/10)) : 10) . ']';
}
# Draw table header:
sub draw_header {
# End here if the header is to be omitted:
......@@ -501,6 +489,103 @@ sub draw_row {
return 1;
}
# Draw short stats:
sub draw_short_statistics {
my ($groups, $tasks, $undone) = @_;
# Check whether to use colours:
unless ($coloured) {
# Display plain text overall statistics:
printf "%d group%s, %d task%s, %d unfinished\n",
$groups, (($groups != 1) ? 's' : ''),
$tasks, (($tasks != 1) ? 's' : ''),
$undone;
}
else {
# Display coloured overall statistics:
print colored ['bold'], $groups;
print (($groups != 1) ? ' groups, ' : ' group, ');
print colored ['bold'], $tasks;
print (($tasks != 1) ? ' tasks, ' : ' task, ');
print colored ['bold'], $undone;
print " unfinished\n";
}
# Return success:
return 1;
}
# Draw group statistics:
sub draw_group_statistics {
my ($group, $percentage, $done, $tasks) = @_;
# Print the group name:
printf "%-10s ", $group;
# Print the progress bar:
draw_progressbar($percentage);
# Print the finished/all ratio:
print " ($done/$tasks)\n";
# Return success:
return 1;
}
# Draw progress bar:
sub draw_progressbar {
my $percentage = shift || 0;
# Decide whether to use the pointer:
my $pointer = ($percentage > 0 && $percentage < 100) ? '>' : '';
# Check whether to use colours:
unless ($coloured) {
# Print the progress bar:
print '[' . '=' x int($percentage / 10) . $pointer .
' ' x ($percentage ? (9 - int($percentage / 10)) : 10) . ']';
# Print the percentage:
printf " %3d%%", $percentage;
}
else {
# Decide whether to use the pointer:
my $pointer = ($percentage > 0 && $percentage < 100) ? '>' : '';
# Print the opening bracket:
print colored ['bold'], '[';
# Pick the right colour:
if ($percentage <= 33) {
print color 'red';
}
elsif ($percentage > 66) {
print color 'green';
}
else {
print color 'yellow';
}
# Print the progress bar:
print '=' x int($percentage / 10) . $pointer .
' ' x ($percentage ? (9 - int($percentage / 10)) : 10);
# Reset the color:
print color 'reset';
# Print the closing bracket:
print colored ['bold'], ']';
# Print the percentage:
print color 'bold';
printf " %3d%%", $percentage;
print color 'reset';
}
# Return success:
return 1;
}
# Display usage information:
sub display_help {
my $NAME = NAME;
......@@ -633,10 +718,10 @@ sub display_statistics {
my $done = $tasks - $undone;
# Display overall statistics:
printf "%d group%s, %d task%s, %d unfinished\n",
$groups, (($groups != 1) ? 's' : ''),
$tasks, (($tasks != 1) ? 's' : ''),
$undone;
draw_short_statistics($groups, $tasks, $undone);
# Separate the lines:
print "\n" if $tasks;
# End here when the task list is empty:
return 1 unless $groups;
......@@ -646,27 +731,19 @@ sub display_statistics {
# Count group percentage:
$per = int($stats->{$group}->{done} * 100 / $stats->{$group}->{tasks});
# Prepare the progress bar:
$bar = compose_progressbar($per);
# Prepare the finished/all ratio:
$rat = "($stats->{$group}->{done}/$stats->{$group}->{tasks})";
# Display group progress:
printf "\n%-11s %s %3d%% %s", "$group:", $bar, $per, $rat;
draw_group_statistics($group, $per, $stats->{$group}->{done},
$stats->{$group}->{tasks});
}
# Count overall percentage:
$per = $tasks ? int($done * 100 / $tasks) : 0;
# Prepare the progress bar:
$bar = compose_progressbar($per);
# Separate the lines:
print "---\n" if $tasks;
# Prepare the finished/all ratio:
$rat = "($done/$tasks)";
# Count the overall percentage:
$per = $tasks ? int($done * 100 / $tasks) : 0;
# Display overall progress:
printf "\n---\n%-11s %s %3d%% %s\n", "total:", $bar, $per, $rat;
draw_group_statistics('total', $per, $done, $tasks);
# Return success:
return 1;
......
This diff is collapsed.
......@@ -25,7 +25,7 @@ use Getopt::Long;
# General script information:
use constant NAME => basename($0, '.pl'); # Script name.
use constant VERSION => '2.3.0'; # Script version.
use constant VERSION => '2.3.1'; # Script version.
# General script settings:
our $HOMEDIR = $ENV{HOME} || $ENV{USERPROFILE} || '.';
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment