- Added Feature #1099, which supports the 'color.uda.<uda-name>' color rule
  (thanks to Florian Hollerweger).
This commit is contained in:
Paul Beckingham 2012-12-01 13:29:23 -05:00
parent 7710c7a623
commit d8579730f5
8 changed files with 84 additions and 2 deletions

View file

@ -158,3 +158,5 @@ suggestions:
Stéphane Pezennec Stéphane Pezennec
Jim B Jim B
Jake Bell Jake Bell
Florian Hollerweger

View file

@ -12,6 +12,8 @@ Features
+ Added Feature #1124, which provides a '_show' command that displays all + Added Feature #1124, which provides a '_show' command that displays all
configuration defaults and settings, for use by third-party software (thanks configuration defaults and settings, for use by third-party software (thanks
to Jake Bell). to Jake Bell).
+ Added Feature #1099, which supports the 'color.uda.<uda-name>' color rule
(thanks to Florian Hollerweger).
+ The 'projects' command now outputs abstract parents and reduces + The 'projects' command now outputs abstract parents and reduces
repetition by not printing parent names in front of children names. repetition by not printing parent names in front of children names.
+ Added framework for testing bash autocompletion. + Added framework for testing bash autocompletion.

2
NEWS
View file

@ -15,7 +15,7 @@ New commands in taskwarrior 2.2.0
New configuration options in taskwarrior 2.2.0 New configuration options in taskwarrior 2.2.0
- - New color rule 'color.uda.<uda-name>'.
Newly deprecated features in taskwarrior 2.2.0 Newly deprecated features in taskwarrior 2.2.0

View file

@ -844,6 +844,11 @@ Colors any task assigned to project X.
Colors any task where the description or any annotation contains X. Colors any task where the description or any annotation contains X.
.RE .RE
.TP
.B color.uda.X=on green
Colors any taks that has the user defined attribute X.
.RE
.TP .TP
.B color.error=green .B color.error=green
Colors any of the error messages. Colors any of the error messages.

View file

@ -211,6 +211,7 @@ std::string Config::_defaults =
"color.blocking=white on color6 # Color of blocking tasks\n" "color.blocking=white on color6 # Color of blocking tasks\n"
"#color.completed=on blue # Color of completed tasks\n" "#color.completed=on blue # Color of completed tasks\n"
"#color.deleted=on blue # Color of deleted tasks\n" "#color.deleted=on blue # Color of deleted tasks\n"
"#color.uda.estimate=on green # Color of UDA\n"
#else #else
"color.header=yellow # Color of header messages\n" "color.header=yellow # Color of header messages\n"
"color.footnote=yellow # Color of footnote 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.blocking=black on bright white # Color of blocking tasks\n"
"#color.completed=on blue # Color of completed tasks\n" "#color.completed=on blue # Color of completed tasks\n"
"#color.deleted=on blue # Color of deleted tasks\n" "#color.deleted=on blue # Color of deleted tasks\n"
"#color.uda.estimate=on green # Color of UDA\n"
#endif #endif
"\n" "\n"
"# Here is the rule precedence order, highest to lowest.\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" "# Note that these are just the color rule names, without the leading 'color.'\n"
"# and any trailing '.value'.\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" "\n"
"# Shadow file support\n" "# Shadow file support\n"
"#shadow.file=/tmp/shadow.txt # Location of shadow file\n" "#shadow.file=/tmp/shadow.txt # Location of shadow file\n"

View file

@ -229,6 +229,7 @@ int CmdShow::execute (std::string& output)
if (i->substr (0, 14) != "color.keyword." && if (i->substr (0, 14) != "color.keyword." &&
i->substr (0, 14) != "color.project." && i->substr (0, 14) != "color.project." &&
i->substr (0, 10) != "color.tag." && i->substr (0, 10) != "color.tag." &&
i->substr (0, 10) != "color.uda." &&
i->substr (0, 8) != "holiday." && i->substr (0, 8) != "holiday." &&
i->substr (0, 7) != "report." && i->substr (0, 7) != "report." &&
i->substr (0, 6) != "alias." && i->substr (0, 6) != "alias." &&

View file

@ -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) 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, 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.project.") colorizeProject (task, *r, base, c);
else if (r->substr (0, 14) == "color.keyword.") colorizeKeyword (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);
} }
} }
} }

62
test/color.uda.t Executable file
View file

@ -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;