Calendar coloring

- Added 3 new color configuration variables to colorize today, days with due tasks
  and days with overdue tasks in the calendar:
  'calendar.color.today', 'color.calendar.due' and 'calendar.calendar.overdue'
This commit is contained in:
Federico Hernandez 2010-01-08 12:23:26 +01:00
parent 6dd00f41e9
commit d552b208dd
6 changed files with 29 additions and 9 deletions

View file

@ -36,6 +36,9 @@
+ Added 2 new configuration variables to display the details of tasks with due + Added 2 new configuration variables to display the details of tasks with due
dates when doing a 'task cal' for the corresponding months: dates when doing a 'task cal' for the corresponding months:
'calendar.details' and 'calendar.details.report' 'calendar.details' and 'calendar.details.report'
+ Added 3 new color configuration variables to colorize today, days with due tasks
and days with overdue tasks in the calendar:
'calendar.color.today', 'color.calendar.due' and 'calendar.calendar.overdue'
+ Fixed bug #316 which caused the timesheet report to display an oddly sorted + Fixed bug #316 which caused the timesheet report to display an oddly sorted
list. list.
+ Fixed bug #317 which colored tasks in the 'completed' report according to + Fixed bug #317 which colored tasks in the 'completed' report according to

View file

@ -300,6 +300,18 @@ Colors any of the messages printed after the report output.
.TP .TP
.B color.footnote=green .B color.footnote=green
Colors any of the messages printed last. Colors any of the messages printed last.
.TP
.B color.calendar.today=cyan
Color of today in calendar.
.TP
.B color.calendar.due=black on yellow
Color of days with due tasks in calendar.
.TP
.B color.calendar.overdue=black on red
Color of days with overdue tasks in calendar
.RE .RE
.SS SHADOW FILE .SS SHADOW FILE

View file

@ -172,6 +172,9 @@ void Config::createDefaultRC (const std::string& rc, const std::string& data)
<< "#color.recurring=on_red # Color of recur.any: tasks\n" << "#color.recurring=on_red # Color of recur.any: tasks\n"
<< "#color.header=bold_green # Color of header messages\n" << "#color.header=bold_green # Color of header messages\n"
<< "#color.footnote=bold_green # Color of footnote messages\n" << "#color.footnote=bold_green # Color of footnote messages\n"
<< "color.calendar.today=cyan # Color of today in calendar\n"
<< "color.calendar.due=black on yellow # Color of days with due tasks in calendar\n"
<< "color.calendar.overdue=black on red # Color of days with overdue tasks in calendar\n"
<< "\n" << "\n"
<< "#shadow.file=/tmp/shadow.txt # Location of shadow file\n" << "#shadow.file=/tmp/shadow.txt # Location of shadow file\n"
<< "#shadow.command=list # Task command for shadow file\n" << "#shadow.command=list # Task command for shadow file\n"

View file

@ -554,6 +554,7 @@ int handleConfig (std::string &outs)
" blanklines bulk calendar.details calendar.details.report color color.active " " blanklines bulk calendar.details calendar.details.report color color.active "
"color.due color.overdue color.pri.H color.pri.L color.pri.M color.pri.none " "color.due 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.recurring color.tagged color.footnote color.header color.debug color.alternate "
"color.calendar.today color.calendar.due color.calendar.overdue "
"confirmation curses data.location dateformat debug default.command default.priority " "confirmation curses data.location dateformat debug default.command default.priority "
"default.project defaultwidth due locale displayweeknumber echo.command " "default.project defaultwidth due locale displayweeknumber echo.command "
"locking monthsperline nag next project shadow.command shadow.file " "locking monthsperline nag next project shadow.command shadow.file "

View file

@ -1430,11 +1430,15 @@ std::string renderMonths (
table.addCell (row, thisCol, d); table.addCell (row, thisCol, d);
Color color_today (context.config.get ("color.calendar.today", "cyan"));
Color color_due (context.config.get ("color.calendar.due", "black on yellow"));
Color color_overdue (context.config.get ("color.calendar.overdue", "black on red"));
if ((context.config.get ("color", true) || context.config.get (std::string ("_forcecolor"), false)) && if ((context.config.get ("color", true) || context.config.get (std::string ("_forcecolor"), false)) &&
today.day () == d && today.day () == d &&
today.month () == months.at (mpl) && today.month () == months.at (mpl) &&
today.year () == years.at (mpl)) today.year () == years.at (mpl))
table.setCellColor (row, thisCol, Color (Color::cyan)); table.setCellColor (row, thisCol, color_today);
foreach (task, all) foreach (task, all)
{ {
@ -1447,10 +1451,7 @@ std::string renderMonths (
due.day () == d && due.day () == d &&
due.month () == months[mpl] && due.month () == months[mpl] &&
due.year () == years[mpl]) due.year () == years[mpl])
{ table.setCellColor (row, thisCol, (due < today ? color_overdue : color_due));
Color c (Color::black, (due < today ? Color::red : Color::yellow));
table.setCellColor (row, thisCol, c);
}
} }
} }
@ -1632,9 +1633,9 @@ int handleReportCalendar (std::string &outs)
} }
} }
Color color_today (Color::cyan); Color color_today (context.config.get ("color.calendar.today", "cyan"));
Color color_due (Color::black, Color::yellow); Color color_due (context.config.get ("color.calendar.due", "black on yellow"));
Color color_overdue (Color::black, Color::red); Color color_overdue (context.config.get ("color.calendar.overdue", "black on red"));
if (context.config.get ("color", true) || context.config.get (std::string ("_forcecolor"), false)) if (context.config.get ("color", true) || context.config.get (std::string ("_forcecolor"), false))
out << "Legend: " out << "Legend: "

View file

@ -30,7 +30,7 @@
use strict; use strict;
use warnings; use warnings;
use Test::More tests => 36; use Test::More tests => 58;
# Create the rc file. # Create the rc file.
if (open my $fh, '>', 'cal.rc') if (open my $fh, '>', 'cal.rc')