diff --git a/src/rules.cpp b/src/rules.cpp index cac04156e..5744dd3ca 100644 --- a/src/rules.cpp +++ b/src/rules.cpp @@ -87,18 +87,7 @@ void autoColorize ( Config& conf) { // Note: fg, bg already contain colors specifically assigned via command. - // Note: These rules form a hierarchy - the last rule is king. - - // Colorization of the recurring. - if (gsFg["color.recurring"] != Text::nocolor || - gsBg["color.recurring"] != Text::nocolor) - { - if (task.getAttribute ("recur") != "") - { - fg = gsFg["color.recurring"]; - bg = gsBg["color.recurring"]; - } - } + // Note: These rules form a hierarchy - the last rule is King. // Colorization of the tagged. if (gsFg["color.tagged"] != Text::nocolor || @@ -234,6 +223,17 @@ void autoColorize ( bg = gsBg["color.due"]; } } + + // Colorization of the recurring. + if (gsFg["color.recurring"] != Text::nocolor || + gsBg["color.recurring"] != Text::nocolor) + { + if (task.getAttribute ("recur") != "") + { + fg = gsFg["color.recurring"]; + bg = gsBg["color.recurring"]; + } + } } //////////////////////////////////////////////////////////////////////////////// diff --git a/src/tests/abbreviation.t b/src/tests/abbreviation.t index 4d9b27515..18d330e65 100755 --- a/src/tests/abbreviation.t +++ b/src/tests/abbreviation.t @@ -28,7 +28,7 @@ use strict; use warnings; -use Test::More tests => 15; +use Test::More tests => 22; # Create the rc file. if (open my $fh, '>', 'abbrev.rc') @@ -38,7 +38,7 @@ if (open my $fh, '>', 'abbrev.rc') ok (-r 'abbrev.rc', 'Created abbrev.rc'); } -# Test the add command. +# Test the priority attribute abbrevations. qx{../task rc:abbrev.rc add priority:H with}; qx{../task rc:abbrev.rc add without}; @@ -66,6 +66,28 @@ $output = qx{../task rc:abbrev.rc list pri:H}; like ($output, qr/\bwith\b/, 'pri:H with'); unlike ($output, qr/\bwithout\b/, 'pri:H without'); +# Test the version command abbreviations. +$output = qx{../task version}; +like ($output, qr/ABSOLUTELY NO WARRANTY/, 'version'); + +$output = qx{../task versio}; +like ($output, qr/ABSOLUTELY NO WARRANTY/, 'versio'); + +$output = qx{../task versi}; +like ($output, qr/ABSOLUTELY NO WARRANTY/, 'versi'); + +$output = qx{../task vers}; +like ($output, qr/ABSOLUTELY NO WARRANTY/, 'vers'); + +$output = qx{../task ver}; +like ($output, qr/ABSOLUTELY NO WARRANTY/, 'ver'); + +$output = qx{../task ve}; +like ($output, qr/ABSOLUTELY NO WARRANTY/, 've'); + +$output = qx{../task v}; +like ($output, qr/ABSOLUTELY NO WARRANTY/, 'v'); + # Cleanup. unlink 'pending.data'; ok (!-r 'pending.data', 'Removed pending.data'); diff --git a/src/tests/color.active.t b/src/tests/color.active.t new file mode 100755 index 000000000..0ad678223 --- /dev/null +++ b/src/tests/color.active.t @@ -0,0 +1,60 @@ +#! /usr/bin/perl +################################################################################ +## task - a command line task list manager. +## +## Copyright 2006 - 2009, Paul Beckingham. +## All rights reserved. +## +## This program is free software; you can redistribute it and/or modify it under +## the terms of the GNU General Public License as published by the Free Software +## Foundation; either version 2 of the License, or (at your option) any later +## version. +## +## This program is distributed in the hope that it will be useful, but WITHOUT +## ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +## FOR A PARTICULAR PURPOSE. See the GNU General Public License for more +## details. +## +## You should have received a copy of the GNU General Public License along with +## this program; if not, write to the +## +## Free Software Foundation, Inc., +## 51 Franklin Street, Fifth Floor, +## Boston, MA +## 02110-1301 +## USA +## +################################################################################ + +use strict; +use warnings; +use Test::More tests => 5; + +# Create the rc file. +if (open my $fh, '>', 'color.rc') +{ + print $fh "data.location=.\n", + "color.active=red\n", + "_forcecolor=1\n"; + close $fh; + ok (-r 'color.rc', 'Created color.rc'); +} + +# Test the add command. +qx{../task rc:color.rc add nothing}; +qx{../task rc:color.rc add red}; +qx{../task rc:color.rc start 2}; +my $output = qx{../task rc:color.rc list}; + +like ($output, qr/ (?!<\033\[\d\dm) .* nothing .* (?!>\033\[0m) /x, 'none'); +like ($output, qr/ \033\[31m .* red .* \033\[0m /x, 'color.active'); + +# Cleanup. +unlink 'pending.data'; +ok (!-r 'pending.data', 'Removed pending.data'); + +unlink 'color.rc'; +ok (!-r 'color.rc', 'Removed color.rc'); + +exit 0; + diff --git a/src/tests/color.due.t b/src/tests/color.due.t new file mode 100755 index 000000000..af1f0077e --- /dev/null +++ b/src/tests/color.due.t @@ -0,0 +1,59 @@ +#! /usr/bin/perl +################################################################################ +## task - a command line task list manager. +## +## Copyright 2006 - 2009, Paul Beckingham. +## All rights reserved. +## +## This program is free software; you can redistribute it and/or modify it under +## the terms of the GNU General Public License as published by the Free Software +## Foundation; either version 2 of the License, or (at your option) any later +## version. +## +## This program is distributed in the hope that it will be useful, but WITHOUT +## ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +## FOR A PARTICULAR PURPOSE. See the GNU General Public License for more +## details. +## +## You should have received a copy of the GNU General Public License along with +## this program; if not, write to the +## +## Free Software Foundation, Inc., +## 51 Franklin Street, Fifth Floor, +## Boston, MA +## 02110-1301 +## USA +## +################################################################################ + +use strict; +use warnings; +use Test::More tests => 5; + +# Create the rc file. +if (open my $fh, '>', 'color.rc') +{ + print $fh "data.location=.\n", + "color.due=red\n", + "_forcecolor=1\n"; + close $fh; + ok (-r 'color.rc', 'Created color.rc'); +} + +# Test the add command. +qx{../task rc:color.rc add due:eoy nothing}; +qx{../task rc:color.rc add due:tomorrow red}; +my $output = qx{../task rc:color.rc list}; + +like ($output, qr/ (?!<\033\[\d\dm) \d{1,2}\/\d{1,2}\/\d{4} (?!>\033\[0m) .* nothing /x, 'none'); +like ($output, qr/ \033\[31m .* red .* \033\[0m/x, 'color.due'); + +# Cleanup. +unlink 'pending.data'; +ok (!-r 'pending.data', 'Removed pending.data'); + +unlink 'color.rc'; +ok (!-r 'color.rc', 'Removed color.rc'); + +exit 0; + diff --git a/src/tests/color.keyword.t b/src/tests/color.keyword.t new file mode 100755 index 000000000..4e99e7400 --- /dev/null +++ b/src/tests/color.keyword.t @@ -0,0 +1,62 @@ +#! /usr/bin/perl +################################################################################ +## task - a command line task list manager. +## +## Copyright 2006 - 2009, Paul Beckingham. +## All rights reserved. +## +## This program is free software; you can redistribute it and/or modify it under +## the terms of the GNU General Public License as published by the Free Software +## Foundation; either version 2 of the License, or (at your option) any later +## version. +## +## This program is distributed in the hope that it will be useful, but WITHOUT +## ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +## FOR A PARTICULAR PURPOSE. See the GNU General Public License for more +## details. +## +## You should have received a copy of the GNU General Public License along with +## this program; if not, write to the +## +## Free Software Foundation, Inc., +## 51 Franklin Street, Fifth Floor, +## Boston, MA +## 02110-1301 +## USA +## +################################################################################ + +use strict; +use warnings; +use Test::More tests => 6; + +# Create the rc file. +if (open my $fh, '>', 'color.rc') +{ + print $fh "data.location=.\n", + "color.keyword.red=red\n", + "color.keyword.green=green\n", + "_forcecolor=1\n"; + close $fh; + ok (-r 'color.rc', 'Created color.rc'); +} + +# Test the add command. +qx{../task rc:color.rc add nothing}; +qx{../task rc:color.rc add red}; +qx{../task rc:color.rc add green}; +my $output = qx{../task rc:color.rc list}; + +like ($output, qr/ (?!<\033\[\d\dm) .* nothing .* (?!>\033\[0m) /x, 'none'); +like ($output, qr/ \033\[31m .* red .* \033\[0m /x, 'color.keyword.red'); +like ($output, qr/ \033\[32m .* green .* \033\[0m /x, 'color.keyword.green'); + +# Cleanup. +unlink 'pending.data'; +ok (!-r 'pending.data', 'Removed pending.data'); + +unlink 'color.rc'; +ok (!-r 'color.rc', 'Removed color.rc'); + +exit 0; + diff --git a/src/tests/color.overdue.t b/src/tests/color.overdue.t new file mode 100755 index 000000000..9555a92cd --- /dev/null +++ b/src/tests/color.overdue.t @@ -0,0 +1,59 @@ +#! /usr/bin/perl +################################################################################ +## task - a command line task list manager. +## +## Copyright 2006 - 2009, Paul Beckingham. +## All rights reserved. +## +## This program is free software; you can redistribute it and/or modify it under +## the terms of the GNU General Public License as published by the Free Software +## Foundation; either version 2 of the License, or (at your option) any later +## version. +## +## This program is distributed in the hope that it will be useful, but WITHOUT +## ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +## FOR A PARTICULAR PURPOSE. See the GNU General Public License for more +## details. +## +## You should have received a copy of the GNU General Public License along with +## this program; if not, write to the +## +## Free Software Foundation, Inc., +## 51 Franklin Street, Fifth Floor, +## Boston, MA +## 02110-1301 +## USA +## +################################################################################ + +use strict; +use warnings; +use Test::More tests => 5; + +# Create the rc file. +if (open my $fh, '>', 'color.rc') +{ + print $fh "data.location=.\n", + "color.overdue=red\n", + "_forcecolor=1\n"; + close $fh; + ok (-r 'color.rc', 'Created color.rc'); +} + +# Test the add command. +qx{../task rc:color.rc add due:tomorrow nothing}; +qx{../task rc:color.rc add due:yesterday red}; +my $output = qx{../task rc:color.rc list}; + +like ($output, qr/ (?!<\033\[\d\dm) \d{1,2}\/\d{1,2}\/\d{4} (?!>\033\[0m) .* nothing /x, 'none'); +like ($output, qr/ \033\[31m .* red .* \033\[0m/x, 'color.overdue'); + +# Cleanup. +unlink 'pending.data'; +ok (!-r 'pending.data', 'Removed pending.data'); + +unlink 'color.rc'; +ok (!-r 'color.rc', 'Removed color.rc'); + +exit 0; + diff --git a/src/tests/color.project.t b/src/tests/color.project.t new file mode 100755 index 000000000..2b90ec59c --- /dev/null +++ b/src/tests/color.project.t @@ -0,0 +1,59 @@ +#! /usr/bin/perl +################################################################################ +## task - a command line task list manager. +## +## Copyright 2006 - 2009, Paul Beckingham. +## All rights reserved. +## +## This program is free software; you can redistribute it and/or modify it under +## the terms of the GNU General Public License as published by the Free Software +## Foundation; either version 2 of the License, or (at your option) any later +## version. +## +## This program is distributed in the hope that it will be useful, but WITHOUT +## ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +## FOR A PARTICULAR PURPOSE. See the GNU General Public License for more +## details. +## +## You should have received a copy of the GNU General Public License along with +## this program; if not, write to the +## +## Free Software Foundation, Inc., +## 51 Franklin Street, Fifth Floor, +## Boston, MA +## 02110-1301 +## USA +## +################################################################################ + +use strict; +use warnings; +use Test::More tests => 5; + +# Create the rc file. +if (open my $fh, '>', 'color.rc') +{ + print $fh "data.location=.\n", + "color.project.x=red\n", + "_forcecolor=1\n"; + close $fh; + ok (-r 'color.rc', 'Created color.rc'); +} + +# Test the add command. +qx{../task rc:color.rc add nothing}; +qx{../task rc:color.rc add project:x red}; +my $output = qx{../task rc:color.rc list}; + +like ($output, qr/ (?!<\033\[\d\dm) .* nothing .* (?!>\033\[0m) /x, 'none'); +like ($output, qr/ \033\[31m .* red .* \033\[0m /x, 'color.project.red'); + +# Cleanup. +unlink 'pending.data'; +ok (!-r 'pending.data', 'Removed pending.data'); + +unlink 'color.rc'; +ok (!-r 'color.rc', 'Removed color.rc'); + +exit 0; + diff --git a/src/tests/color.recurring.t b/src/tests/color.recurring.t new file mode 100755 index 000000000..27990b1aa --- /dev/null +++ b/src/tests/color.recurring.t @@ -0,0 +1,59 @@ +#! /usr/bin/perl +################################################################################ +## task - a command line task list manager. +## +## Copyright 2006 - 2009, Paul Beckingham. +## All rights reserved. +## +## This program is free software; you can redistribute it and/or modify it under +## the terms of the GNU General Public License as published by the Free Software +## Foundation; either version 2 of the License, or (at your option) any later +## version. +## +## This program is distributed in the hope that it will be useful, but WITHOUT +## ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +## FOR A PARTICULAR PURPOSE. See the GNU General Public License for more +## details. +## +## You should have received a copy of the GNU General Public License along with +## this program; if not, write to the +## +## Free Software Foundation, Inc., +## 51 Franklin Street, Fifth Floor, +## Boston, MA +## 02110-1301 +## USA +## +################################################################################ + +use strict; +use warnings; +use Test::More tests => 5; + +# Create the rc file. +if (open my $fh, '>', 'color.rc') +{ + print $fh "data.location=.\n", + "color.recurring=red\n", + "_forcecolor=1\n"; + close $fh; + ok (-r 'color.rc', 'Created color.rc'); +} + +# Test the add command. +qx{../task rc:color.rc add nothing}; +qx{../task rc:color.rc add due:tomorrow recur:1w red}; +my $output = qx{../task rc:color.rc list}; + +like ($output, qr/ (?!<\033\[\d\dm) .* nothing .* (?!>\033\[0m) /x, 'none'); +like ($output, qr/ \033\[31m .* red .* \033\[0m /x, 'color.recurring'); + +# Cleanup. +unlink 'pending.data'; +ok (!-r 'pending.data', 'Removed pending.data'); + +unlink 'color.rc'; +ok (!-r 'color.rc', 'Removed color.rc'); + +exit 0; + diff --git a/src/tests/color.tag.t b/src/tests/color.tag.t new file mode 100755 index 000000000..da870e39e --- /dev/null +++ b/src/tests/color.tag.t @@ -0,0 +1,62 @@ +#! /usr/bin/perl +################################################################################ +## task - a command line task list manager. +## +## Copyright 2006 - 2009, Paul Beckingham. +## All rights reserved. +## +## This program is free software; you can redistribute it and/or modify it under +## the terms of the GNU General Public License as published by the Free Software +## Foundation; either version 2 of the License, or (at your option) any later +## version. +## +## This program is distributed in the hope that it will be useful, but WITHOUT +## ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +## FOR A PARTICULAR PURPOSE. See the GNU General Public License for more +## details. +## +## You should have received a copy of the GNU General Public License along with +## this program; if not, write to the +## +## Free Software Foundation, Inc., +## 51 Franklin Street, Fifth Floor, +## Boston, MA +## 02110-1301 +## USA +## +################################################################################ + +use strict; +use warnings; +use Test::More tests => 6; + +# Create the rc file. +if (open my $fh, '>', 'color.rc') +{ + print $fh "data.location=.\n", + "color.tag.red=red\n", + "color.tag.green=green\n", + "_forcecolor=1\n"; + close $fh; + ok (-r 'color.rc', 'Created color.rc'); +} + +# Test the add command. +qx{../task rc:color.rc add nothing}; +qx{../task rc:color.rc add +red red}; +qx{../task rc:color.rc add +green green}; +my $output = qx{../task rc:color.rc list}; + +like ($output, qr/ (?!<\033\[\d\dm) .* nothing .* (?!>\033\[0m) /x, 'none'); +like ($output, qr/ \033\[31m .* red .* \033\[0m /x, 'color.tag.red'); +like ($output, qr/ \033\[32m .* green .* \033\[0m /x, 'color.tag.green'); + +# Cleanup. +unlink 'pending.data'; +ok (!-r 'pending.data', 'Removed pending.data'); + +unlink 'color.rc'; +ok (!-r 'color.rc', 'Removed color.rc'); + +exit 0; + diff --git a/src/tests/color.tagged.t b/src/tests/color.tagged.t new file mode 100755 index 000000000..947a467e9 --- /dev/null +++ b/src/tests/color.tagged.t @@ -0,0 +1,59 @@ +#! /usr/bin/perl +################################################################################ +## task - a command line task list manager. +## +## Copyright 2006 - 2009, Paul Beckingham. +## All rights reserved. +## +## This program is free software; you can redistribute it and/or modify it under +## the terms of the GNU General Public License as published by the Free Software +## Foundation; either version 2 of the License, or (at your option) any later +## version. +## +## This program is distributed in the hope that it will be useful, but WITHOUT +## ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +## FOR A PARTICULAR PURPOSE. See the GNU General Public License for more +## details. +## +## You should have received a copy of the GNU General Public License along with +## this program; if not, write to the +## +## Free Software Foundation, Inc., +## 51 Franklin Street, Fifth Floor, +## Boston, MA +## 02110-1301 +## USA +## +################################################################################ + +use strict; +use warnings; +use Test::More tests => 5; + +# Create the rc file. +if (open my $fh, '>', 'color.rc') +{ + print $fh "data.location=.\n", + "color.tagged=red\n", + "_forcecolor=1\n"; + close $fh; + ok (-r 'color.rc', 'Created color.rc'); +} + +# Test the add command. +qx{../task rc:color.rc add nothing}; +qx{../task rc:color.rc add +tag red}; +my $output = qx{../task rc:color.rc list}; + +like ($output, qr/ (?!<\033\[\d\dm) .* nothing .* (?!>\033\[0m) /x, 'none'); +like ($output, qr/ \033\[31m .* red .* \033\[0m /x, 'color.tagged'); + +# Cleanup. +unlink 'pending.data'; +ok (!-r 'pending.data', 'Removed pending.data'); + +unlink 'color.rc'; +ok (!-r 'color.rc', 'Removed color.rc'); + +exit 0; +