From 44220287c4053d409cc3e4c989d9f03a86d41678 Mon Sep 17 00:00:00 2001 From: Tomas Babej Date: Wed, 21 Apr 2021 23:26:05 -0400 Subject: [PATCH] CmdCalendar: Only display relevant parts of the legend --- src/commands/CmdCalendar.cpp | 28 ++++++++++++++++++---------- 1 file changed, 18 insertions(+), 10 deletions(-) diff --git a/src/commands/CmdCalendar.cpp b/src/commands/CmdCalendar.cpp index b3f027cc8..3f8cd7527 100644 --- a/src/commands/CmdCalendar.cpp +++ b/src/commands/CmdCalendar.cpp @@ -293,23 +293,31 @@ int CmdCalendar::execute (std::string& output) Color color_weeknumber (config.get ("color.calendar.weeknumber")); if (Context::getContext ().color () && config.getBoolean ("calendar.legend")) + { out << "Legend: " << color_today.colorize ("today") << ", " - << color_due.colorize ("due") - << ", " - << color_duetoday.colorize ("due-today") - << ", " - << color_overdue.colorize ("overdue") - << ", " << color_weekend.colorize ("weekend") - << ", " - << color_holiday.colorize ("holiday") - << ", " - << color_weeknumber.colorize ("weeknumber") + << ", "; + + // If colorizing due dates, print legend + if (config.get ("calendar.details") != "none") + out << color_due.colorize ("due") + << ", " + << color_duetoday.colorize ("due-today") + << ", " + << color_overdue.colorize ("overdue") + << ", "; + + // If colorizing holidays, print legend + if (config.get ("calendar.holidays") != "none") + out << color_holiday.colorize ("holiday") << ", "; + + out << color_weeknumber.colorize ("weeknumber") << '.' << optionalBlankLine () << '\n'; + } if (config.get ("calendar.details") == "full" || config.get ("calendar.holidays") == "full") {