- Zero values no longer generate a 1-char bar in "task ghistory"

This commit is contained in:
Paul Beckingham 2008-06-27 18:05:02 -04:00
parent d199bada33
commit 00b7a5f1b4
3 changed files with 28 additions and 14 deletions

1
.gitignore vendored
View file

@ -9,4 +9,5 @@ src/Makefile
src/task
stamp-h1
Makefile
configure
config.log

View file

@ -242,8 +242,9 @@ std::string decode (color c)
////////////////////////////////////////////////////////////////////////////////
std::string colorize (color fg, color bg, const std::string& input)
{
if (fg != nocolor || bg != nocolor)
return decode (fg) + decode (bg) + input + decode (off);
if (input.length ())
if (fg != nocolor || bg != nocolor)
return decode (fg) + decode (bg) + input + decode (off);
return input;
}

View file

@ -1876,20 +1876,32 @@ void handleReportGHistory (const TDB& tdb, T& task, Config& conf)
if (conf.get ("color", true))
{
char number[24];
sprintf (number, "%d", addedGroup[i->first]);
std::string aBar = number;
while (aBar.length () < addedBar)
aBar = " " + aBar;
std::string aBar = "";
if (addedGroup[i->first])
{
sprintf (number, "%d", addedGroup[i->first]);
aBar = number;
while (aBar.length () < addedBar)
aBar = " " + aBar;
}
sprintf (number, "%d", completedGroup[i->first]);
std::string cBar = number;
while (cBar.length () < completedBar)
cBar = " " + cBar;
std::string cBar = "";
if (completedGroup[i->first])
{
sprintf (number, "%d", completedGroup[i->first]);
cBar = number;
while (cBar.length () < completedBar)
cBar = " " + cBar;
}
sprintf (number, "%d", deletedGroup[i->first]);
std::string dBar = number;
while (dBar.length () < deletedBar)
dBar = " " + dBar;
std::string dBar = "";
if (deletedGroup[i->first])
{
sprintf (number, "%d", deletedGroup[i->first]);
dBar = number;
while (dBar.length () < deletedBar)
dBar = " " + dBar;
}
bar = Text::colorize (Text::black, Text::on_green, aBar);
bar += Text::colorize (Text::black, Text::on_yellow, cBar);