diff --git a/ChangeLog b/ChangeLog index f8084d224..0bc2fece1 100644 --- a/ChangeLog +++ b/ChangeLog @@ -158,6 +158,7 @@ - TW-1407 'task calendar 2014' leaks. - TW-1409 Allow "1 of N tasks remaining" to be correctly localized (thanks to Jeremy John Reeder). +- TW-1428 Add support for color.uda.. rules. - Removed deprecated 'echo.command' setting, in favor of the 'header' and 'affected' verbosity tokens. - Removed deprecated 'edit.verbose' setting, in favor of the 'edit' verbosity diff --git a/doc/man/taskrc.5.in b/doc/man/taskrc.5.in index dc953361e..5decadd37 100644 --- a/doc/man/taskrc.5.in +++ b/doc/man/taskrc.5.in @@ -863,6 +863,11 @@ Colors any task where the description or any annotation contains X. Colors any task that has the user defined attribute X. .RE +.TP +.B color.uda.X.VALUE=on green +Colors any task that has the user defined attribute X set to VALUE. +.RE + .TP .B color.error=green Colors any of the error messages. diff --git a/src/rules.cpp b/src/rules.cpp index 613229421..0855369b5 100644 --- a/src/rules.cpp +++ b/src/rules.cpp @@ -225,8 +225,19 @@ 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); + // Is the rule uda.name.value or uda.name? + size_t pos = rule.find (".", 10); + if (pos == std::string::npos) + { + if (task.has (rule.substr (10))) + c.blend (base); + } + else { + const std::string uda = rule.substr (10, pos-10); + const std::string val = rule.substr (pos+1); + if (task.get (uda) == val) + c.blend (base); + } } //////////////////////////////////////////////////////////////////////////////// diff --git a/test/color.uda.t b/test/color.uda.t index 75faa6299..cd6309ca8 100755 --- a/test/color.uda.t +++ b/test/color.uda.t @@ -40,17 +40,22 @@ if (open my $fh, '>', 'color.rc') "color.uda.x=red\n", "uda.x.type=numeric\n", "uda.x.label=X\n", + "uda.y.type=numeric\n", + "uda.y.label=Y\n", + "color.uda.y.4=blue\n", "color.alternate=\n", "_forcecolor=1\n"; close $fh; } qx{../src/task rc:color.rc add one 2>&1}; -qx{../src/task rc:color.rc add two x:3 2>&1}; +qx{../src/task rc:color.rc add two x:3 y:2 2>&1}; +qx{../src/task rc:color.rc add three y:4 2>&1}; my $output = qx{../src/task rc:color.rc list 2>/dev/null}; unlike ($output, qr/ \033\[32m .* one .* \033\[0m /x, 'No color.uda'); like ($output, qr/ \033\[31m .* two .* \033\[0m /x, 'Found color.uda'); +like ($output, qr/ \033\[34m .* three .* \033\[0m /x, 'Found color.uda.x'); # Cleanup. unlink qw(pending.data completed.data undo.data backlog.data color.rc);