mirror of
https://github.com/GothenburgBitFactory/taskwarrior.git
synced 2025-08-23 14:36:44 +02:00
Added coloring of dates with scheduled tasks
Color can be changed using color.calendar.scheduled
This commit is contained in:
parent
90bc7f4b23
commit
3d61966831
4 changed files with 44 additions and 21 deletions
|
@ -77,6 +77,8 @@
|
||||||
Thanks to Scott Mcdermott
|
Thanks to Scott Mcdermott
|
||||||
- TW #1824 Fixed countdown formatting
|
- TW #1824 Fixed countdown formatting
|
||||||
Thanks to Sebastian Uharek
|
Thanks to Sebastian Uharek
|
||||||
|
- #2208 Feature: added coloring of dates with scheduled tasks to calendar
|
||||||
|
Thanks to Sebastian Uharek
|
||||||
|
|
||||||
------ current release ---------------------------
|
------ current release ---------------------------
|
||||||
|
|
||||||
|
|
|
@ -227,6 +227,7 @@ std::string configurationDefaults =
|
||||||
"color.calendar.due.today=color15 on color1\n"
|
"color.calendar.due.today=color15 on color1\n"
|
||||||
"color.calendar.due=color0 on color1\n"
|
"color.calendar.due=color0 on color1\n"
|
||||||
"color.calendar.holiday=color0 on color11\n"
|
"color.calendar.holiday=color0 on color11\n"
|
||||||
|
"color.calendar.scheduled=rgb013 on color15\n"
|
||||||
"color.calendar.overdue=color0 on color9\n"
|
"color.calendar.overdue=color0 on color9\n"
|
||||||
"color.calendar.today=color15 on rgb013\n"
|
"color.calendar.today=color15 on rgb013\n"
|
||||||
"color.calendar.weekend=on color235\n"
|
"color.calendar.weekend=on color235\n"
|
||||||
|
|
|
@ -290,6 +290,7 @@ int CmdCalendar::execute (std::string& output)
|
||||||
Color color_overdue (config.get ("color.calendar.overdue"));
|
Color color_overdue (config.get ("color.calendar.overdue"));
|
||||||
Color color_weekend (config.get ("color.calendar.weekend"));
|
Color color_weekend (config.get ("color.calendar.weekend"));
|
||||||
Color color_holiday (config.get ("color.calendar.holiday"));
|
Color color_holiday (config.get ("color.calendar.holiday"));
|
||||||
|
Color color_scheduled (config.get ("color.calendar.scheduled"));
|
||||||
Color color_weeknumber (config.get ("color.calendar.weeknumber"));
|
Color color_weeknumber (config.get ("color.calendar.weeknumber"));
|
||||||
|
|
||||||
if (Context::getContext ().color () && config.getBoolean ("calendar.legend"))
|
if (Context::getContext ().color () && config.getBoolean ("calendar.legend"))
|
||||||
|
@ -307,6 +308,8 @@ int CmdCalendar::execute (std::string& output)
|
||||||
<< color_duetoday.colorize ("due-today")
|
<< color_duetoday.colorize ("due-today")
|
||||||
<< ", "
|
<< ", "
|
||||||
<< color_overdue.colorize ("overdue")
|
<< color_overdue.colorize ("overdue")
|
||||||
|
<< ", "
|
||||||
|
<< color_scheduled.colorize ("scheduled")
|
||||||
<< ", ";
|
<< ", ";
|
||||||
|
|
||||||
// If colorizing holidays, print legend
|
// If colorizing holidays, print legend
|
||||||
|
@ -528,6 +531,7 @@ std::string CmdCalendar::renderMonths (
|
||||||
Color color_overdue (config.get ("color.calendar.overdue"));
|
Color color_overdue (config.get ("color.calendar.overdue"));
|
||||||
Color color_weekend (config.get ("color.calendar.weekend"));
|
Color color_weekend (config.get ("color.calendar.weekend"));
|
||||||
Color color_holiday (config.get ("color.calendar.holiday"));
|
Color color_holiday (config.get ("color.calendar.holiday"));
|
||||||
|
Color color_scheduled (config.get ("color.calendar.scheduled"));
|
||||||
Color color_weeknumber (config.get ("color.calendar.weeknumber"));
|
Color color_weeknumber (config.get ("color.calendar.weeknumber"));
|
||||||
|
|
||||||
// Loop through months to be added on this line.
|
// Loop through months to be added on this line.
|
||||||
|
@ -603,23 +607,37 @@ std::string CmdCalendar::renderMonths (
|
||||||
if (today.sameDay (date))
|
if (today.sameDay (date))
|
||||||
cellColor.blend (color_today);
|
cellColor.blend (color_today);
|
||||||
|
|
||||||
// colorize due tasks
|
// colorize due and scheduled tasks
|
||||||
if (config.get ("calendar.details") != "none")
|
if (config.get ("calendar.details") != "none")
|
||||||
{
|
{
|
||||||
config.set ("due", 0);
|
config.set ("due", 0);
|
||||||
|
config.set ("scheduled", 0);
|
||||||
|
// if a date has a task that is due on that day, the due color
|
||||||
|
// takes precedence over the scheduled color
|
||||||
|
bool coloredWithDue = false;
|
||||||
for (auto& task : all)
|
for (auto& task : all)
|
||||||
{
|
{
|
||||||
auto status = task.getStatus ();
|
auto status = task.getStatus ();
|
||||||
if ((status == Task::pending ||
|
if ((status == Task::pending ||
|
||||||
status == Task::waiting ) &&
|
status == Task::waiting ) &&
|
||||||
!task.hasTag ("nocal") &&
|
!task.hasTag ("nocal"))
|
||||||
task.has ("due"))
|
|
||||||
{
|
{
|
||||||
|
if(task.has("scheduled") && !coloredWithDue) {
|
||||||
|
std::string scheduled = task.get ("scheduled");
|
||||||
|
Datetime scheduleddmy (strtol (scheduled.c_str(), nullptr, 10));
|
||||||
|
|
||||||
|
if (scheduleddmy.sameDay (date))
|
||||||
|
{
|
||||||
|
cellColor.blend(color_scheduled);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(task.has("due")) {
|
||||||
std::string due = task.get ("due");
|
std::string due = task.get ("due");
|
||||||
Datetime duedmy (strtol (due.c_str(), nullptr, 10));
|
Datetime duedmy (strtol (due.c_str(), nullptr, 10));
|
||||||
|
|
||||||
if (duedmy.sameDay (date))
|
if (duedmy.sameDay (date))
|
||||||
{
|
{
|
||||||
|
coloredWithDue = true;
|
||||||
switch (task.getDateState ("due"))
|
switch (task.getDateState ("due"))
|
||||||
{
|
{
|
||||||
case Task::dateNotDue:
|
case Task::dateNotDue:
|
||||||
|
@ -642,6 +660,7 @@ std::string CmdCalendar::renderMonths (
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
view.set (row, thisCol, cellColor);
|
view.set (row, thisCol, cellColor);
|
||||||
}
|
}
|
||||||
|
|
|
@ -98,6 +98,7 @@ int CmdShow::execute (std::string& output)
|
||||||
" color.calendar.due"
|
" color.calendar.due"
|
||||||
" color.calendar.due.today"
|
" color.calendar.due.today"
|
||||||
" color.calendar.holiday"
|
" color.calendar.holiday"
|
||||||
|
" color.calendar.scheduled"
|
||||||
" color.calendar.overdue"
|
" color.calendar.overdue"
|
||||||
" color.calendar.today"
|
" color.calendar.today"
|
||||||
" color.calendar.weekend"
|
" color.calendar.weekend"
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue