Feature #391 - legendary enhancement

- Added feature #391, now the 'task color legend' command will show
  samples of all the defined colors and color rules from your .taskrc
  and theme.
This commit is contained in:
Paul Beckingham 2010-07-25 14:50:20 -04:00
parent 7dc55d831d
commit 43266a825f
6 changed files with 49 additions and 7 deletions

View file

@ -1863,10 +1863,36 @@ int handleColor (std::string &outs)
if (context.config.getBoolean ("color") || context.config.getBoolean ("_forcecolor"))
{
// If the description contains 'legend', show all the colors currently in
// use.
std::string description = context.task.get ("description");
if (description.find ("legend") != std::string::npos)
{
out << std::endl
<< "Here are the colors currently in use:"
<< std::endl;
std::vector <std::string> all;
context.config.all (all);
foreach (item, all)
{
if (*item != "_forcecolor" &&
*item != "color" &&
item->find ("color") != std::string::npos)
{
out << " "
<< Color::colorize (" " + *item + " ",
context.config.get (*item))
<< std::endl;
}
}
out << std::endl;
}
// If there is something in the description, then assume that is a color,
// and display it as a sample.
std::string description = context.task.get ("description");
if (description != "")
else if (description != "")
{
Color one ("black on bright yellow");
Color two ("underline cyan on bright blue");

View file

@ -24,6 +24,7 @@
// USA
//
////////////////////////////////////////////////////////////////////////////////
#include <iostream>
#include <iomanip>
#include <sstream>
@ -205,8 +206,9 @@ int shortUsage (std::string &outs)
table.addCell (row, 2, "Lists all tasks in iCalendar format.");
row = table.addRow ();
table.addCell (row, 1, "task color [sample]");
table.addCell (row, 2, "Displays all possible colors, or a sample.");
table.addCell (row, 1, "task color [sample | legend]");
table.addCell (row, 2, "Displays all possible colors, a named sample, or a "
"legend containing all currently defined colors.");
row = table.addRow ();
table.addCell (row, 1, "task version");