Bug Fix - calendar
- Task now displays as many calendars will fit across the window, unless a lower value is specified in the "monthsperline" configuration variable. - Task now obeys the "color" configuration variable when determining whether to add a legend to the calendar output.
This commit is contained in:
@@ -174,7 +174,9 @@
|
|||||||
<dt>monthsperline</dt>
|
<dt>monthsperline</dt>
|
||||||
<dd>
|
<dd>
|
||||||
Determines how many months the "task calendar" command
|
Determines how many months the "task calendar" command
|
||||||
renders across the screen. Defaults to 1.
|
renders across the screen. Defaults to however many will
|
||||||
|
fit. If more months that will fit are specified, task will
|
||||||
|
only show as many that will fit.
|
||||||
</dd>
|
</dd>
|
||||||
|
|
||||||
<dt>oldest</dt>
|
<dt>oldest</dt>
|
||||||
|
|||||||
@@ -127,7 +127,7 @@ void Config::createDefault (const std::string& home)
|
|||||||
fprintf (out, "confirmation=yes\n");
|
fprintf (out, "confirmation=yes\n");
|
||||||
fprintf (out, "next=2\n");
|
fprintf (out, "next=2\n");
|
||||||
fprintf (out, "dateformat=m/d/Y\n");
|
fprintf (out, "dateformat=m/d/Y\n");
|
||||||
fprintf (out, "monthsperline=2\n");
|
fprintf (out, "#monthsperline=2\n");
|
||||||
fprintf (out, "curses=on\n");
|
fprintf (out, "curses=on\n");
|
||||||
fprintf (out, "color=on\n");
|
fprintf (out, "color=on\n");
|
||||||
fprintf (out, "due=7\n");
|
fprintf (out, "due=7\n");
|
||||||
|
|||||||
@@ -1214,11 +1214,11 @@ std::string renderMonths (
|
|||||||
int firstYear,
|
int firstYear,
|
||||||
const Date& today,
|
const Date& today,
|
||||||
std::vector <T>& all,
|
std::vector <T>& all,
|
||||||
Config& conf)
|
Config& conf,
|
||||||
|
int monthsPerLine)
|
||||||
{
|
{
|
||||||
Table table;
|
Table table;
|
||||||
table.setDateFormat (conf.get ("dateformat", "m/d/Y"));
|
table.setDateFormat (conf.get ("dateformat", "m/d/Y"));
|
||||||
int monthsPerLine = (conf.get ("monthsperline", 1));
|
|
||||||
|
|
||||||
// Build table for the number of months to be displayed.
|
// Build table for the number of months to be displayed.
|
||||||
for (int i = 0 ; i < (monthsPerLine * 8); i += 8)
|
for (int i = 0 ; i < (monthsPerLine * 8); i += 8)
|
||||||
@@ -1337,6 +1337,26 @@ std::string handleReportCalendar (TDB& tdb, T& task, Config& conf)
|
|||||||
{
|
{
|
||||||
std::stringstream out;
|
std::stringstream out;
|
||||||
|
|
||||||
|
// Determine window size, and set table accordingly.
|
||||||
|
int width = conf.get ("defaultwidth", 80);
|
||||||
|
#ifdef HAVE_LIBNCURSES
|
||||||
|
if (conf.get ("curses", true))
|
||||||
|
{
|
||||||
|
WINDOW* w = initscr ();
|
||||||
|
width = w->_maxx + 1;
|
||||||
|
endwin ();
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// Each month requires 23 text columns width. See how many will actually
|
||||||
|
// fit. But if a preference is specified, and it fits, use it.
|
||||||
|
int preferredMonthsPerLine = (conf.get (std::string ("monthsperline"), 0));
|
||||||
|
int monthsThatFit = width / 23;
|
||||||
|
|
||||||
|
int monthsPerLine = monthsThatFit;
|
||||||
|
if (preferredMonthsPerLine != 0 && preferredMonthsPerLine < monthsThatFit)
|
||||||
|
monthsPerLine = preferredMonthsPerLine;
|
||||||
|
|
||||||
// Load all the pending tasks.
|
// Load all the pending tasks.
|
||||||
std::vector <T> pending;
|
std::vector <T> pending;
|
||||||
tdb.allPendingT (pending);
|
tdb.allPendingT (pending);
|
||||||
@@ -1369,8 +1389,6 @@ std::string handleReportCalendar (TDB& tdb, T& task, Config& conf)
|
|||||||
out << std::endl;
|
out << std::endl;
|
||||||
std::string output;
|
std::string output;
|
||||||
|
|
||||||
int monthsPerLine = (conf.get ("monthsperline", 1));
|
|
||||||
|
|
||||||
while (yFrom < yTo || (yFrom == yTo && mFrom <= mTo))
|
while (yFrom < yTo || (yFrom == yTo && mFrom <= mTo))
|
||||||
{
|
{
|
||||||
int nextM = mFrom;
|
int nextM = mFrom;
|
||||||
@@ -1398,7 +1416,7 @@ std::string handleReportCalendar (TDB& tdb, T& task, Config& conf)
|
|||||||
|
|
||||||
out << std::endl
|
out << std::endl
|
||||||
<< optionalBlankLine (conf)
|
<< optionalBlankLine (conf)
|
||||||
<< renderMonths (mFrom, yFrom, today, pending, conf)
|
<< renderMonths (mFrom, yFrom, today, pending, conf, monthsPerLine)
|
||||||
<< std::endl;
|
<< std::endl;
|
||||||
|
|
||||||
mFrom += monthsPerLine;
|
mFrom += monthsPerLine;
|
||||||
@@ -1409,6 +1427,7 @@ std::string handleReportCalendar (TDB& tdb, T& task, Config& conf)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (conf.get ("color", true) || conf.get (std::string ("_forcecolor"), false))
|
||||||
out << "Legend: "
|
out << "Legend: "
|
||||||
<< Text::colorize (Text::cyan, Text::nocolor, "today")
|
<< Text::colorize (Text::cyan, Text::nocolor, "today")
|
||||||
<< ", "
|
<< ", "
|
||||||
|
|||||||
Reference in New Issue
Block a user