diff --git a/AUTHORS b/AUTHORS index 9f9f8182e..4e1422feb 100644 --- a/AUTHORS +++ b/AUTHORS @@ -158,3 +158,5 @@ suggestions: Stéphane Pezennec Jim B Jake Bell + Florian Hollerweger + diff --git a/ChangeLog b/ChangeLog index ba29205bf..9ded450f7 100644 --- a/ChangeLog +++ b/ChangeLog @@ -12,6 +12,8 @@ Features + Added Feature #1124, which provides a '_show' command that displays all configuration defaults and settings, for use by third-party software (thanks to Jake Bell). + + Added Feature #1099, which supports the 'color.uda.' color rule + (thanks to Florian Hollerweger). + The 'projects' command now outputs abstract parents and reduces repetition by not printing parent names in front of children names. + Added framework for testing bash autocompletion. diff --git a/NEWS b/NEWS index 62989f562..8c498c9ff 100644 --- a/NEWS +++ b/NEWS @@ -15,7 +15,7 @@ New commands in taskwarrior 2.2.0 New configuration options in taskwarrior 2.2.0 - - + - New color rule 'color.uda.'. Newly deprecated features in taskwarrior 2.2.0 diff --git a/doc/man/taskrc.5.in b/doc/man/taskrc.5.in index 3038a980e..ae7935e23 100644 --- a/doc/man/taskrc.5.in +++ b/doc/man/taskrc.5.in @@ -844,6 +844,11 @@ Colors any task assigned to project X. Colors any task where the description or any annotation contains X. .RE +.TP +.B color.uda.X=on green +Colors any taks that has the user defined attribute X. +.RE + .TP .B color.error=green Colors any of the error messages. diff --git a/src/Config.cpp b/src/Config.cpp index 2644477fd..9ed9701e1 100644 --- a/src/Config.cpp +++ b/src/Config.cpp @@ -211,6 +211,7 @@ std::string Config::_defaults = "color.blocking=white on color6 # Color of blocking tasks\n" "#color.completed=on blue # Color of completed tasks\n" "#color.deleted=on blue # Color of deleted tasks\n" + "#color.uda.estimate=on green # Color of UDA\n" #else "color.header=yellow # Color of header messages\n" "color.footnote=yellow # Color of footnote messages\n" @@ -265,12 +266,13 @@ std::string Config::_defaults = "color.blocking=black on bright white # Color of blocking tasks\n" "#color.completed=on blue # Color of completed tasks\n" "#color.deleted=on blue # Color of deleted tasks\n" + "#color.uda.estimate=on green # Color of UDA\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,blocking,blocked,overdue,due,scheduled,keyword.,project.,tag.,recurring,pri.,tagged,completed,deleted\n" + "rule.precedence.color=due.today,active,blocking,blocked,overdue,due,scheduled,keyword.,project.,tag.,uda.,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 92cc1d421..8e80b4695 100644 --- a/src/commands/CmdShow.cpp +++ b/src/commands/CmdShow.cpp @@ -229,6 +229,7 @@ int CmdShow::execute (std::string& output) if (i->substr (0, 14) != "color.keyword." && i->substr (0, 14) != "color.project." && i->substr (0, 10) != "color.tag." && + i->substr (0, 10) != "color.uda." && i->substr (0, 8) != "holiday." && i->substr (0, 7) != "report." && i->substr (0, 6) != "alias." && diff --git a/src/rules.cpp b/src/rules.cpp index 97109b68a..d18dd9b8a 100644 --- a/src/rules.cpp +++ b/src/rules.cpp @@ -211,6 +211,13 @@ static void colorizeKeyword (Task& task, const std::string& rule, const Color& b } } +//////////////////////////////////////////////////////////////////////////////// +static void colorizeUDA (Task& task, const std::string& rule, const Color& base, Color& c) +{ + if (task.has (rule.substr (10))) + c.blend (base); +} + //////////////////////////////////////////////////////////////////////////////// static void colorizeDue (Task& task, const Color& base, Color& c) { @@ -313,6 +320,7 @@ void autoColorize (Task& task, Color& c) else if (r->substr (0, 10) == "color.tag.") colorizeTag (task, *r, base, c); else if (r->substr (0, 14) == "color.project.") colorizeProject (task, *r, base, c); else if (r->substr (0, 14) == "color.keyword.") colorizeKeyword (task, *r, base, c); + else if (r->substr (0, 10) == "color.uda.") colorizeUDA (task, *r, base, c); } } } diff --git a/test/color.uda.t b/test/color.uda.t new file mode 100755 index 000000000..297635aba --- /dev/null +++ b/test/color.uda.t @@ -0,0 +1,62 @@ +#! /usr/bin/env perl +################################################################################ +## taskwarrior - a command line task list manager. +## +## Copyright 2006-2012, Paul Beckingham, Federico Hernandez. +## +## Permission is hereby granted, free of charge, to any person obtaining a copy +## of this software and associated documentation files (the "Software"), to deal +## in the Software without restriction, including without limitation the rights +## to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +## copies of the Software, and to permit persons to whom the Software is +## furnished to do so, subject to the following conditions: +## +## The above copyright notice and this permission notice shall be included +## in all copies or substantial portions of the Software. +## +## THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +## OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +## FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL +## THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +## LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +## OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +## SOFTWARE. +## +## http://www.opensource.org/licenses/mit-license.php +## +################################################################################ + +use strict; +use warnings; +use Test::More tests => 4; + +# Create the rc file. +if (open my $fh, '>', 'color.rc') +{ + print $fh "data.location=.\n", + "color.uda.x=red\n", + "uda.x.type=numeric\n", + "uda.x.label=X\n", + "_forcecolor=1\n"; + close $fh; + ok (-r 'color.rc', 'Created color.rc'); +} + +qx{../src/task rc:color.rc add one 2>&1}; +qx{../src/task rc:color.rc add two x:3 2>&1}; +my $output = qx{../src/task rc:color.rc list 2>&1}; + +unlike ($output, qr/ \033\[32m .* one .* \033\[0m /x, 'No color.uda'); +like ($output, qr/ \033\[31m .* two .* \033\[0m /x, 'Found color.uda'); + +# Cleanup. +unlink qw(pending.data completed.data undo.data backlog.data synch.key color.rc); +ok (! -r 'pending.data' && + ! -r 'completed.data' && + ! -r 'undo.data' && + ! -r 'backlog.data' && + ! -r 'synch.key' && + ! -r 'color.rc', 'Cleanup'); + +exit 0; +