From 10b97fc9670232e48bb08540e78b4834c8cea262 Mon Sep 17 00:00:00 2001 From: Paul Beckingham Date: Sat, 9 Jul 2011 19:00:58 -0400 Subject: [PATCH] Feature #340 - Added feature #340, which implements new color rules 'color.completed' and 'color.deleted'. --- ChangeLog | 2 ++ NEWS | 1 + doc/man/taskrc.5.in | 8 +++++++- src/Config.cpp | 6 +++++- src/commands/CmdShow.cpp | 2 ++ src/rules.cpp | 16 ++++++++++++++++ 6 files changed, 33 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index 9d101fae4..fb7199c8d 100644 --- a/ChangeLog +++ b/ChangeLog @@ -41,6 +41,8 @@ # Tracked Features, sorted by ID. + Added feature #278, which provides a more consistent command line grammar. + Added feature #330, which supports the 'inverse' color attribute. + + Added feature #340, which implements new color rules 'color.completed' and + 'color.deleted'. + Added feature #479, which enables filtering for the 'calendar' command. + Added feature #496, which allows rc.default.command to be supplemented with a filter, so that 'task project:Home' applies the project filter to the diff --git a/NEWS b/NEWS index dbb9eb480..4e52919b8 100644 --- a/NEWS +++ b/NEWS @@ -52,6 +52,7 @@ New configuration options in taskwarrior 2.0.0 or simple text patterns. - New 'exit.on.missing.db' control causes an exit if the ~/.task directory (or override) is missing. + - New 'color.completed' and 'color.deleted' color rules. Newly deprecated features in taskwarrior 2.0.0 diff --git a/doc/man/taskrc.5.in b/doc/man/taskrc.5.in index 430b7df7c..64a280bd6 100644 --- a/doc/man/taskrc.5.in +++ b/doc/man/taskrc.5.in @@ -699,6 +699,12 @@ Task has priority L. .br .B color.pri.none Task has no priority. +.br +.B color.completed +Task is completed. +.br +.B color.deleted +Task is deleted. .RE .RE @@ -850,7 +856,7 @@ Colors the output of the merge command. .RE .TP -.B rule.precedence.color=due.today,active,blocked,overdue,due,keyword,project,tag,recurring,pri,tagged +.B rule.precedence.color=due.today,active,blocked,overdue,due,keyword,project,tag,recurring,pri,tagged,completed,deleted .RS This setting specifies the precedence of the color rules, from highest to lowest. Note that the prefix 'color.' is omitted (for brevity), and that any diff --git a/src/Config.cpp b/src/Config.cpp index 50438e5ce..884107493 100644 --- a/src/Config.cpp +++ b/src/Config.cpp @@ -197,6 +197,8 @@ std::string Config::defaults = "color.pri.L=rgb245 # Color of priority:L tasks\n" "color.tagged=rgb031 # Color of tagged tasks\n" "color.blocked=white on color8 # Color of blocked tasks\n" + "#color.completed=on blue # Color of completed tasks\n" + "#color.deleted=on blue # Color of deleted tasks\n" #else "color.header=yellow # Color of header messages\n" "color.footnote=yellow # Color of footnote messages\n" @@ -246,12 +248,14 @@ std::string Config::defaults = "color.pri.L= # Color of priority:L tasks\n" "color.tagged=green # Color of tagged tasks\n" "color.blocked=black on white # Color of blocked tasks\n" + "#color.completed=on blue # Color of completed tasks\n" + "#color.deleted=on blue # Color of deleted tasks\n" #endif "\n" "# Here is the rule precedence order, highest to lowest.\n" "# Note that these are just the color rule names, without the leading 'color.'\n" "# and any trailing '.value'.\n" - "rule.precedence.color=due.today,active,blocked,overdue,due,keyword,project,tag,recurring,pri,tagged\n" + "rule.precedence.color=due.today,active,blocked,overdue,due,keyword,project,tag,recurring,pri,tagged,completed,deleted\n" "\n" "# Shadow file support\n" "#shadow.file=/tmp/shadow.txt # Location of shadow file\n" diff --git a/src/commands/CmdShow.cpp b/src/commands/CmdShow.cpp index 279f6e3a3..a028e14d7 100644 --- a/src/commands/CmdShow.cpp +++ b/src/commands/CmdShow.cpp @@ -92,7 +92,9 @@ int CmdShow::execute (std::string& output) " color.calendar.today" " color.calendar.weekend" " color.calendar.weeknumber" + " color.completed" " color.debug" + " color.deleted" " color.due" " color.due.today" " color.footnote" diff --git a/src/rules.cpp b/src/rules.cpp index e9ba71410..0fdc7e570 100644 --- a/src/rules.cpp +++ b/src/rules.cpp @@ -253,6 +253,20 @@ static void colorizeRecurring (Task& task, const std::string& rule, Color& c) c.blend (gsColor[rule]); } +//////////////////////////////////////////////////////////////////////////////// +static void colorizeCompleted (Task& task, const std::string& rule, Color& c) +{ + if (task.getStatus () == Task::completed) + c.blend (gsColor[rule]); +} + +//////////////////////////////////////////////////////////////////////////////// +static void colorizeDeleted (Task& task, const std::string& rule, Color& c) +{ + if (task.getStatus () == Task::completed) + c.blend (gsColor[rule]); +} + //////////////////////////////////////////////////////////////////////////////// void autoColorize (Task& task, Color& c) { @@ -283,6 +297,8 @@ void autoColorize (Task& task, Color& c) else if (*r == "color.due.today") colorizeDueToday (task, *r, c); else if (*r == "color.overdue") colorizeOverdue (task, *r, c); else if (*r == "color.recurring") colorizeRecurring (task, *r, c); + else if (*r == "color.completed") colorizeCompleted (task, *r, c); + else if (*r == "color.deleted") colorizeDeleted (task, *r, c); // Wildcards else if (r->substr (0, 9) == "color.tag") colorizeTag (task, *r, c);