From f73c64801c529c5e767561881df69b315b223fd6 Mon Sep 17 00:00:00 2001 From: Paul Beckingham Date: Tue, 3 Jun 2008 09:00:51 -0400 Subject: [PATCH] - Added three new colorization rules - color.tag.x, color.project.x, color.keyword.x. - Updated default .taskrc file. - Updated docs accordingly. --- ChangeLog | 1 + TUTORIAL | 7 ++++++- src/Config.cpp | 5 +++++ src/rules.cpp | 44 ++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 56 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index 19a37f372..ace45b8a6 100644 --- a/ChangeLog +++ b/ChangeLog @@ -13,6 +13,7 @@ + Bug: incorrect color specification in sample .taskrc file + Bug: when run without arguments, task dumps core on Solaris 10 + "task calendar" now reports all months with due pending tasks + + Added rules for colorization by tag, project and keyword 0.9.9 (5/27/2008) + Autoconf/automake behaving properly. diff --git a/TUTORIAL b/TUTORIAL index d82e3c4d0..372ecccac 100644 --- a/TUTORIAL +++ b/TUTORIAL @@ -29,7 +29,7 @@ transcript illustrates a typical installation: ... % make ... - % make install + % make install # (may require sudo, depending on --prefix) You need to make sure that the installed task program is in your PATH environment variable. @@ -617,6 +617,11 @@ Configuring Task bold_red on_bright_yellow + color.tag.X Colors any task that has the tag X. + + color.project.X Colors any task assigned to project X. + + color.keyword.X Colors any task where the description contains X. Colors diff --git a/src/Config.cpp b/src/Config.cpp index e15c3cdae..a8ecf9587 100644 --- a/src/Config.cpp +++ b/src/Config.cpp @@ -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"); diff --git a/src/rules.cpp b/src/rules.cpp index a79aa1757..8d727fced 100644 --- a/src/rules.cpp +++ b/src/rules.cpp @@ -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 ::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]; + } + } + } } ////////////////////////////////////////////////////////////////////////////////