mirror of
https://github.com/GothenburgBitFactory/taskwarrior.git
synced 2025-06-26 10:54:26 +02:00
Color
- Supports 'color.uda.<name>.<value>' (TW-1428)
This commit is contained in:
parent
aa89422b6f
commit
2c7013cc1c
4 changed files with 25 additions and 3 deletions
|
@ -158,6 +158,7 @@
|
||||||
- TW-1407 'task calendar 2014' leaks.
|
- TW-1407 'task calendar 2014' leaks.
|
||||||
- TW-1409 Allow "1 of N tasks remaining" to be correctly localized (thanks to
|
- TW-1409 Allow "1 of N tasks remaining" to be correctly localized (thanks to
|
||||||
Jeremy John Reeder).
|
Jeremy John Reeder).
|
||||||
|
- TW-1428 Add support for color.uda.<name>.<value> rules.
|
||||||
- Removed deprecated 'echo.command' setting, in favor of the 'header' and
|
- Removed deprecated 'echo.command' setting, in favor of the 'header' and
|
||||||
'affected' verbosity tokens.
|
'affected' verbosity tokens.
|
||||||
- Removed deprecated 'edit.verbose' setting, in favor of the 'edit' verbosity
|
- Removed deprecated 'edit.verbose' setting, in favor of the 'edit' verbosity
|
||||||
|
|
|
@ -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.
|
Colors any task that has the user defined attribute X.
|
||||||
.RE
|
.RE
|
||||||
|
|
||||||
|
.TP
|
||||||
|
.B color.uda.X.VALUE=on green
|
||||||
|
Colors any task that has the user defined attribute X set to VALUE.
|
||||||
|
.RE
|
||||||
|
|
||||||
.TP
|
.TP
|
||||||
.B color.error=green
|
.B color.error=green
|
||||||
Colors any of the error messages.
|
Colors any of the error messages.
|
||||||
|
|
|
@ -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)
|
static void colorizeUDA (Task& task, const std::string& rule, const Color& base, Color& c)
|
||||||
{
|
{
|
||||||
if (task.has (rule.substr (10)))
|
// Is the rule uda.name.value or uda.name?
|
||||||
c.blend (base);
|
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);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
|
@ -40,17 +40,22 @@ if (open my $fh, '>', 'color.rc')
|
||||||
"color.uda.x=red\n",
|
"color.uda.x=red\n",
|
||||||
"uda.x.type=numeric\n",
|
"uda.x.type=numeric\n",
|
||||||
"uda.x.label=X\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",
|
"color.alternate=\n",
|
||||||
"_forcecolor=1\n";
|
"_forcecolor=1\n";
|
||||||
close $fh;
|
close $fh;
|
||||||
}
|
}
|
||||||
|
|
||||||
qx{../src/task rc:color.rc add one 2>&1};
|
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};
|
my $output = qx{../src/task rc:color.rc list 2>/dev/null};
|
||||||
|
|
||||||
unlike ($output, qr/ \033\[32m .* one .* \033\[0m /x, 'No color.uda');
|
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\[31m .* two .* \033\[0m /x, 'Found color.uda');
|
||||||
|
like ($output, qr/ \033\[34m .* three .* \033\[0m /x, 'Found color.uda.x');
|
||||||
|
|
||||||
# Cleanup.
|
# Cleanup.
|
||||||
unlink qw(pending.data completed.data undo.data backlog.data color.rc);
|
unlink qw(pending.data completed.data undo.data backlog.data color.rc);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue