- Added three new colorization rules - color.tag.x, color.project.x, color.keyword.x.

- Updated default .taskrc file.
- Updated docs accordingly.
This commit is contained in:
Paul Beckingham
2008-06-03 09:00:51 -04:00
parent 039c3119ff
commit f73c64801c
4 changed files with 56 additions and 1 deletions

View File

@@ -107,6 +107,7 @@ void Config::createDefault (const std::string& file)
if (taskDir != "")
{
// Create a sample .taskrc file.
FILE* out;
if ((out = fopen (file.c_str (), "w")))
{
@@ -125,9 +126,13 @@ void Config::createDefault (const std::string& file)
fprintf (out, "#color.pri.L=on_green\n");
fprintf (out, "color.active=bold_cyan\n");
fprintf (out, "color.tagged=yellow\n");
fprintf (out, "#color.tag.bug=yellow\n");
fprintf (out, "#color.project.home=on_green\n");
fprintf (out, "#color.keyword.car=on_blue\n");
fclose (out);
// Now set the live values.
set ("data.location", taskDir);
set ("command.logging", "off");
set ("confirmation", "yes");

View File

@@ -83,6 +83,7 @@ void initializeColorRules (Config& conf)
void autoColorize (T& task, Text::color& fg, Text::color& bg)
{
// Note: fg, bg already contain colors specifically assigned via command.
// TODO These rules form a hierarchy - the last rule is king.
// Colorization of the tagged.
if (gsFg["color.tagged"] != Text::nocolor ||
@@ -174,6 +175,49 @@ void autoColorize (T& task, Text::color& fg, Text::color& bg)
bg = gsBg["color.due"];
}
}
// Colorization by tag value.
std::map <std::string, Text::color>::iterator it;
for (it = gsFg.begin (); it != gsFg.end (); ++it)
{
if (it->first.substr (0, 10) == "color.tag.")
{
std::string value = it->first.substr (10, std::string::npos);
if (task.hasTag (value))
{
fg = gsFg[it->first];
bg = gsBg[it->first];
}
}
}
// Colorization by project name.
for (it = gsFg.begin (); it != gsFg.end (); ++it)
{
if (it->first.substr (0, 14) == "color.project.")
{
std::string value = it->first.substr (14, std::string::npos);
if (task.getAttribute ("project") == value)
{
fg = gsFg[it->first];
bg = gsBg[it->first];
}
}
}
// Colorization by keyword.
for (it = gsFg.begin (); it != gsFg.end (); ++it)
{
if (it->first.substr (0, 14) == "color.keyword.")
{
std::string value = it->first.substr (14, std::string::npos);
if (task.getDescription ().find (value) != std::string::npos)
{
fg = gsFg[it->first];
bg = gsBg[it->first];
}
}
}
}
////////////////////////////////////////////////////////////////////////////////