mirror of
https://github.com/GothenburgBitFactory/taskwarrior.git
synced 2025-06-26 10:54:26 +02:00
color.due.today and color.calendar.due.today
- tasks due on the current day ("today") can now be colorized with their own color. - this is for reports and the calendar
This commit is contained in:
parent
adb72ef023
commit
4adfec4482
8 changed files with 131 additions and 29 deletions
|
@ -53,6 +53,8 @@
|
|||
The default dateformat being YMD (20101224) set by dateformat.holiday.
|
||||
+ The coloring of due tasks in reports can now be enabled for all tasks, and not
|
||||
only the imminent ones, by setting the configuration variable due=0.
|
||||
+ Tasks due on the current day ("today") can now have their own color setting
|
||||
color.due.today and color.calendar.due.today.
|
||||
+ Added a new 'task-faq' man page for common questions and answers.
|
||||
+ Added a new 'task-color' man page detailing how to set up and use color in
|
||||
task.
|
||||
|
|
|
@ -82,16 +82,17 @@ std::string Config::defaults =
|
|||
"#monthsperline=3 # Number of calendar months on a line\n"
|
||||
"\n"
|
||||
"# Color controls.\n"
|
||||
"color=on # Enable color\n"
|
||||
"#color.header=bold green # Color of header messages\n"
|
||||
"#color.footnote=bold green # Color of footnote messages\n"
|
||||
"color.calendar.today=black on cyan # Color of today in calendar\n"
|
||||
"color.calendar.due=black on green # Color of days with due tasks in calendar\n"
|
||||
"color.calendar.overdue=black on red # Color of days with overdue tasks in calendar\n"
|
||||
"color=on # Enable color\n"
|
||||
"#color.header=bold green # Color of header messages\n"
|
||||
"#color.footnote=bold green # Color of footnote messages\n"
|
||||
"color.calendar.today=black on cyan # Color of today in calendar\n"
|
||||
"color.calendar.due=black on green # Color of days with due tasks in calendar\n"
|
||||
"color.calendar.due.today=black on magenta # Color of days with due tasks in calendar\n"
|
||||
"color.calendar.overdue=black on red # Color of days with overdue tasks in calendar\n"
|
||||
"color.calendar.weekend=bright white on black # Color of weekend days in calendar\n"
|
||||
"color.calendar.holiday=black on bright yellow # Color of public holidays in calendar\n"
|
||||
"color.calendar.weeknumber=black on white # Color of the weeknumbers in calendar\n"
|
||||
"#color.debug=magenta # Color of diagnostic output\n"
|
||||
"#color.debug=magenta # Color of diagnostic output\n"
|
||||
"\n"
|
||||
"# The following rules are presented in their order of precedence.\n"
|
||||
"# The higher the color rule is up this list, the higher precedence\n"
|
||||
|
@ -99,17 +100,18 @@ std::string Config::defaults =
|
|||
"# in brackets [1]\n"
|
||||
"#color.recurring=on red # [1] Color of recur.any: tasks\n"
|
||||
"color.overdue=bold red # [2] Color of overdue tasks\n"
|
||||
"color.due=bold yellow # [3] Color of due tasks\n"
|
||||
"#color.keyword.car=on blue # [4] Color of description.contains:car tasks\n"
|
||||
"#color.project.garden=on green # [5] Color of project:garden tasks\n"
|
||||
"#color.tag.bug=yellow # [6] Color of +bug tasks\n"
|
||||
"color.active=bold cyan # [7] Color of active tasks\n"
|
||||
"#color.pri.none=white on blue # [8] Color of priority: tasks\n"
|
||||
"color.pri.H=bold # [8] Color of priority:H tasks\n"
|
||||
"#color.pri.M=on yellow # [8] Color of priority:M tasks\n"
|
||||
"#color.pri.L=on green # [8] Color of priority:L tasks\n"
|
||||
"color.tagged=yellow # [9] Color of tagged tasks\n"
|
||||
"#color.alternate=on rgb253 # [10] Alternate color for line coloring\n"
|
||||
"color.due.today=bold magenta # [3] Color of tasks due today\n"
|
||||
"color.due=bold yellow # [4] Color of due tasks\n"
|
||||
"#color.keyword.car=on blue # [5] Color of description.contains:car tasks\n"
|
||||
"#color.project.garden=on green # [6] Color of project:garden tasks\n"
|
||||
"#color.tag.bug=yellow # [7] Color of +bug tasks\n"
|
||||
"color.active=bold cyan # [8] Color of active tasks\n"
|
||||
"#color.pri.none=white on blue # [9] Color of priority: tasks\n"
|
||||
"color.pri.H=bold # [9] Color of priority:H tasks\n"
|
||||
"#color.pri.M=on yellow # [9] Color of priority:M tasks\n"
|
||||
"#color.pri.L=on green # [9] Color of priority:L tasks\n"
|
||||
"color.tagged=yellow # [10] Color of tagged tasks\n"
|
||||
"#color.alternate=on rgb253 # [11] Alternate color for line coloring\n"
|
||||
"\n"
|
||||
"# Shadow file support\n"
|
||||
"#shadow.file=/tmp/shadow.txt # Location of shadow file\n"
|
||||
|
|
|
@ -704,10 +704,10 @@ int handleConfig (std::string &outs)
|
|||
// Note that there is a leading and trailing space, to make searching easier.
|
||||
std::string recognized =
|
||||
" annotations blanklines bulk calendar.details calendar.details.report "
|
||||
"calendar.holidays calendar.legend color color.active color.due "
|
||||
"calendar.holidays calendar.legend color color.active color.due color.due.today "
|
||||
"color.overdue color.pri.H color.pri.L color.pri.M color.pri.none "
|
||||
"color.recurring color.tagged color.footnote color.header color.debug "
|
||||
"color.alternate color.calendar.today color.calendar.due "
|
||||
"color.alternate color.calendar.today color.calendar.due color.calendar.due.today "
|
||||
"color.calendar.overdue color.calendar.weekend color.calendar.holiday "
|
||||
"color.calendar.weeknumber confirmation curses data.location dateformat "
|
||||
"dateformat.holiday dateformat.report debug default.command "
|
||||
|
|
|
@ -388,6 +388,9 @@ int getDueState (const std::string& due)
|
|||
Date thisDay (rightNow.month (), rightNow.day (), rightNow.year ());
|
||||
|
||||
if (dt < thisDay)
|
||||
return 3;
|
||||
|
||||
if (dt == thisDay)
|
||||
return 2;
|
||||
|
||||
int imminentperiod = context.config.getInteger ("due");
|
||||
|
@ -436,7 +439,7 @@ bool nag (Task& task)
|
|||
{
|
||||
if (t->id == task.id)
|
||||
{
|
||||
if (getDueState (t->get ("due")) == 2)
|
||||
if (getDueState (t->get ("due")) == 3)
|
||||
isOverdue = true;
|
||||
|
||||
std::string priority = t->get ("priority");
|
||||
|
@ -445,7 +448,7 @@ bool nag (Task& task)
|
|||
}
|
||||
else if (t->getStatus () == Task::pending)
|
||||
{
|
||||
if (getDueState (t->get ("due")) == 2)
|
||||
if (getDueState (t->get ("due")) == 3)
|
||||
overdue++;
|
||||
|
||||
std::string priority = t->get ("priority");
|
||||
|
|
|
@ -1473,6 +1473,7 @@ std::string renderMonths (
|
|||
|
||||
Color color_today (context.config.get ("color.calendar.today"));
|
||||
Color color_due (context.config.get ("color.calendar.due"));
|
||||
Color color_duetoday (context.config.get ("color.calendar.due.today"));
|
||||
Color color_overdue (context.config.get ("color.calendar.overdue"));
|
||||
Color color_weekend (context.config.get ("color.calendar.weekend"));
|
||||
Color color_holiday (context.config.get ("color.calendar.holiday"));
|
||||
|
@ -1542,19 +1543,44 @@ std::string renderMonths (
|
|||
|
||||
// colorize due tasks
|
||||
if (context.config.get ("calendar.details") != "none")
|
||||
{
|
||||
context.config.set ("due", 0);
|
||||
foreach (task, all)
|
||||
{
|
||||
|
||||
|
||||
if (task->getStatus () == Task::pending &&
|
||||
task->has ("due"))
|
||||
{
|
||||
Date due (atoi (task->get ("due").c_str ()));
|
||||
std::string due = task->get ("due");
|
||||
Date duedmy (atoi(due.c_str()));
|
||||
|
||||
if (due.day () == d &&
|
||||
due.month () == months[mpl] &&
|
||||
due.year () == years[mpl])
|
||||
table.setCellColor (row, thisCol, (due < today ? color_overdue : color_due));
|
||||
if (duedmy.day () == d &&
|
||||
duedmy.month () == months[mpl] &&
|
||||
duedmy.year () == years[mpl])
|
||||
{
|
||||
switch (getDueState (due))
|
||||
{
|
||||
case 1: // imminent
|
||||
table.setCellColor (row, thisCol, color_due);
|
||||
break;
|
||||
|
||||
case 2: // today
|
||||
table.setCellColor (row, thisCol, color_duetoday);
|
||||
break;
|
||||
|
||||
case 3: // overdue
|
||||
table.setCellColor (row, thisCol, color_overdue);
|
||||
break;
|
||||
|
||||
case 0: // not due at all
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Check for end of week, and...
|
||||
|
@ -1741,6 +1767,7 @@ int handleReportCalendar (std::string &outs)
|
|||
|
||||
Color color_today (context.config.get ("color.calendar.today"));
|
||||
Color color_due (context.config.get ("color.calendar.due"));
|
||||
Color color_duetoday (context.config.get ("color.calendar.due.today"));
|
||||
Color color_overdue (context.config.get ("color.calendar.overdue"));
|
||||
Color color_weekend (context.config.get ("color.calendar.weekend"));
|
||||
Color color_holiday (context.config.get ("color.calendar.holiday"));
|
||||
|
@ -1753,6 +1780,8 @@ int handleReportCalendar (std::string &outs)
|
|||
<< ", "
|
||||
<< color_due.colorize ("due")
|
||||
<< ", "
|
||||
<< color_duetoday.colorize ("due-today")
|
||||
<< ", "
|
||||
<< color_overdue.colorize ("overdue")
|
||||
<< ", "
|
||||
<< color_weekend.colorize ("weekend")
|
||||
|
|
|
@ -144,7 +144,11 @@ void autoColorize (Task& task, Color& c)
|
|||
c.blend (gsColor["color.due"]);
|
||||
break;
|
||||
|
||||
case 2: // overdue
|
||||
case 2: // today
|
||||
c.blend (gsColor["color.due.today"]);
|
||||
break;
|
||||
|
||||
case 3: // overdue
|
||||
c.blend (gsColor["color.overdue"]);
|
||||
break;
|
||||
|
||||
|
|
|
@ -41,7 +41,7 @@ if (open my $fh, '>', 'color.rc')
|
|||
}
|
||||
|
||||
# Test the add command.
|
||||
qx{../task rc:color.rc add due:eoy nothing};
|
||||
qx{../task rc:color.rc add due:12/31/2037 nothing};
|
||||
qx{../task rc:color.rc add due:tomorrow red};
|
||||
my $output = qx{../task rc:color.rc list};
|
||||
|
||||
|
|
62
src/tests/color.duetoday.t
Executable file
62
src/tests/color.duetoday.t
Executable file
|
@ -0,0 +1,62 @@
|
|||
#! /usr/bin/perl
|
||||
################################################################################
|
||||
## task - a command line task list manager.
|
||||
##
|
||||
## Copyright 2006 - 2010, 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.due.today=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:12/31/2037 nothing};
|
||||
qx{../task rc:color.rc add due:today 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.today');
|
||||
|
||||
# Cleanup.
|
||||
unlink 'pending.data';
|
||||
ok (!-r 'pending.data', 'Removed pending.data');
|
||||
|
||||
unlink 'undo.data';
|
||||
ok (!-r 'undo.data', 'Removed undo.data');
|
||||
|
||||
unlink 'color.rc';
|
||||
ok (!-r 'color.rc', 'Removed color.rc');
|
||||
|
||||
exit 0;
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue