Enhancement - colors report

- Implemented colors report.
- Commented out all other commands and reports.
- Eliminated obsolete findT function.
This commit is contained in:
Paul Beckingham 2009-06-09 22:21:56 -04:00
parent 940f4a85a4
commit a694ac05b1
5 changed files with 82 additions and 76 deletions

View file

@ -164,6 +164,7 @@ void Context::dispatch ()
*/
if (cmd.command == "projects") { out = handleProjects (); }
else if (cmd.command == "tags") { out = handleTags (); }
else if (cmd.command == "colors") { out = handleColor (); }
/*
else if (command == "info") { out = handleInfo (tdb, task); }
else if (command == "stats") { out = handleReportStats (tdb, task); }
@ -172,7 +173,6 @@ void Context::dispatch ()
else if (command == "calendar") { out = handleReportCalendar (tdb, task); }
else if (command == "summary") { out = handleReportSummary (tdb, task); }
else if (command == "timesheet") { out = handleReportTimesheet (tdb, task); }
else if (command == "colors") { out = handleColor ( ); }
else if (command == "version") { out = handleVersion ( ); }
else if (command == "help") { out = longUsage ( ); }

View file

@ -50,7 +50,7 @@ extern Context context;
std::string handleAdd (TDB& tdb, T& task)
{
std::stringstream out;
/*
char entryTime[16];
sprintf (entryTime, "%u", (unsigned int) time (NULL));
task.setAttribute ("entry", entryTime);
@ -87,7 +87,7 @@ std::string handleAdd (TDB& tdb, T& task)
if (!tdb.addT (task))
throw std::string ("Could not create new task.");
*/
return out.str ();
}
@ -196,7 +196,7 @@ std::string handleTags ()
std::string handleUndelete (TDB& tdb, T& task)
{
std::stringstream out;
/*
std::vector <T> all;
tdb.allPendingT (all);
filterSequence (all, task);
@ -224,7 +224,7 @@ std::string handleUndelete (TDB& tdb, T& task)
<< "Please note that tasks can only be reliably undeleted if the undelete "
<< "command is run immediately after the errant delete command."
<< std::endl;
*/
return out.str ();
}
@ -234,7 +234,7 @@ std::string handleUndelete (TDB& tdb, T& task)
std::string handleUndo (TDB& tdb, T& task)
{
std::stringstream out;
/*
std::vector <T> all;
tdb.allPendingT (all);
filterSequence (all, task);
@ -262,7 +262,7 @@ std::string handleUndo (TDB& tdb, T& task)
<< "Please note that tasks can only be reliably undone if the undo "
<< "command is run immediately after the errant done command."
<< std::endl;
*/
return out.str ();
}
@ -270,7 +270,7 @@ std::string handleUndo (TDB& tdb, T& task)
std::string handleVersion ()
{
std::stringstream out;
/*
// Determine window size, and set table accordingly.
int width = context.config.get ("defaultwidth", (int) 80);
#ifdef HAVE_LIBNCURSES
@ -423,7 +423,7 @@ std::string handleVersion ()
" that doesn't exist, or is unreadable."
<< std::endl;
}
*/
return out.str ();
}
@ -431,7 +431,7 @@ std::string handleVersion ()
std::string handleDelete (TDB& tdb, T& task)
{
std::stringstream out;
/*
std::vector <T> all;
tdb.allPendingT (all);
filterSequence (all, task);
@ -514,7 +514,7 @@ std::string handleDelete (TDB& tdb, T& task)
else
out << "Task not deleted." << std::endl;
}
*/
return out.str ();
}
@ -522,7 +522,7 @@ std::string handleDelete (TDB& tdb, T& task)
std::string handleStart (TDB& tdb, T& task)
{
std::stringstream out;
/*
std::vector <T> all;
tdb.pendingT (all);
filterSequence (all, task);
@ -551,7 +551,7 @@ std::string handleStart (TDB& tdb, T& task)
out << "Task " << t->getId () << " '" << t->getDescription () << "' already started." << std::endl;
}
}
*/
return out.str ();
}
@ -559,7 +559,7 @@ std::string handleStart (TDB& tdb, T& task)
std::string handleStop (TDB& tdb, T& task)
{
std::stringstream out;
/*
std::vector <T> all;
tdb.pendingT (all);
filterSequence (all, task);
@ -579,15 +579,18 @@ std::string handleStop (TDB& tdb, T& task)
out << "Task " << t->getId () << " '" << t->getDescription () << "' not started." << std::endl;
}
}
*/
return out.str ();
}
////////////////////////////////////////////////////////////////////////////////
std::string handleDone (TDB& tdb, T& task)
{
/*
int count = 0;
*/
std::stringstream out;
/*
std::vector <T> all;
tdb.allPendingT (all);
@ -643,7 +646,7 @@ std::string handleDone (TDB& tdb, T& task)
<< (count == 1 ? "" : "s")
<< " as done"
<< std::endl;
*/
return out.str ();
}
@ -651,7 +654,7 @@ std::string handleDone (TDB& tdb, T& task)
std::string handleExport (TDB& tdb, T& task)
{
std::stringstream output;
/*
// Use the description as a file name, then clobber the description so the
// file name isn't used for filtering.
std::string file = trim (task.getDescription ());
@ -700,15 +703,18 @@ std::string handleExport (TDB& tdb, T& task)
}
else
throw std::string ("You must specify a file to write to.");
*/
return output.str ();
}
////////////////////////////////////////////////////////////////////////////////
std::string handleModify (TDB& tdb, T& task)
{
/*
int count = 0;
*/
std::stringstream out;
/*
std::vector <T> all;
tdb.allPendingT (all);
@ -754,15 +760,18 @@ std::string handleModify (TDB& tdb, T& task)
if (context.config.get ("echo.command", true))
out << "Modified " << count << " task" << (count == 1 ? "" : "s") << std::endl;
*/
return out.str ();
}
////////////////////////////////////////////////////////////////////////////////
std::string handleAppend (TDB& tdb, T& task)
{
/*
int count = 0;
*/
std::stringstream out;
/*
std::vector <T> all;
tdb.allPendingT (all);
@ -804,15 +813,18 @@ std::string handleAppend (TDB& tdb, T& task)
if (context.config.get ("echo.command", true))
out << "Appended " << count << " task" << (count == 1 ? "" : "s") << std::endl;
*/
return out.str ();
}
////////////////////////////////////////////////////////////////////////////////
std::string handleDuplicate (TDB& tdb, T& task)
{
/*
int count = 0;
*/
std::stringstream out;
/*
std::vector <T> all;
tdb.allPendingT (all);
@ -859,7 +871,7 @@ std::string handleDuplicate (TDB& tdb, T& task)
if (context.config.get ("echo.command", true))
out << "Duplicated " << count << " task" << (count == 1 ? "" : "s") << std::endl;
*/
return out.str ();
}
@ -867,7 +879,6 @@ std::string handleDuplicate (TDB& tdb, T& task)
std::string handleColor ()
{
std::stringstream out;
if (context.config.get ("color", true) || context.config.get (std::string ("_forcecolor"), false))
{
out << optionalBlankLine () << "Foreground" << std::endl
@ -917,35 +928,37 @@ std::string handleColor ()
<< Text::colorize (Text::bold_underline_white, Text::nocolor, "bold_underline_white") << std::endl
<< std::endl << "Background" << std::endl
<< " " << Text::colorize (Text::nocolor, Text::on_black, "on_black") << " "
<< Text::colorize (Text::nocolor, Text::on_bright_black, "on_bright_black") << std::endl
<< " " << Text::colorize (Text::nocolor, Text::on_black, "on_black") << " "
<< Text::colorize (Text::nocolor, Text::on_bright_black, "on_bright_black") << std::endl
<< " " << Text::colorize (Text::nocolor, Text::on_red, "on_red") << " "
<< Text::colorize (Text::nocolor, Text::on_bright_red, "on_bright_red") << std::endl
<< " " << Text::colorize (Text::nocolor, Text::on_red, "on_red") << " "
<< Text::colorize (Text::nocolor, Text::on_bright_red, "on_bright_red") << std::endl
<< " " << Text::colorize (Text::nocolor, Text::on_green, "on_green") << " "
<< Text::colorize (Text::nocolor, Text::on_bright_green, "on_bright_green") << std::endl
<< " " << Text::colorize (Text::nocolor, Text::on_green, "on_green") << " "
<< Text::colorize (Text::nocolor, Text::on_bright_green, "on_bright_green") << std::endl
<< " " << Text::colorize (Text::nocolor, Text::on_yellow, "on_yellow") << " "
<< Text::colorize (Text::nocolor, Text::on_bright_yellow, "on_bright_yellow") << std::endl
<< " " << Text::colorize (Text::nocolor, Text::on_yellow, "on_yellow") << " "
<< Text::colorize (Text::nocolor, Text::on_bright_yellow, "on_bright_yellow") << std::endl
<< " " << Text::colorize (Text::nocolor, Text::on_blue, "on_blue") << " "
<< Text::colorize (Text::nocolor, Text::on_bright_blue, "on_bright_blue") << std::endl
<< " " << Text::colorize (Text::nocolor, Text::on_blue, "on_blue") << " "
<< Text::colorize (Text::nocolor, Text::on_bright_blue, "on_bright_blue") << std::endl
<< " " << Text::colorize (Text::nocolor, Text::on_magenta, "on_magenta") << " "
<< Text::colorize (Text::nocolor, Text::on_bright_magenta, "on_bright_magenta") << std::endl
<< " " << Text::colorize (Text::nocolor, Text::on_magenta, "on_magenta") << " "
<< Text::colorize (Text::nocolor, Text::on_bright_magenta, "on_bright_magenta") << std::endl
<< " " << Text::colorize (Text::nocolor, Text::on_cyan, "on_cyan") << " "
<< Text::colorize (Text::nocolor, Text::on_bright_cyan, "on_bright_cyan") << std::endl
<< " " << Text::colorize (Text::nocolor, Text::on_cyan, "on_cyan") << " "
<< Text::colorize (Text::nocolor, Text::on_bright_cyan, "on_bright_cyan") << std::endl
<< " " << Text::colorize (Text::nocolor, Text::on_white, "on_white") << " "
<< Text::colorize (Text::nocolor, Text::on_bright_white, "on_bright_white") << std::endl
<< " " << Text::colorize (Text::nocolor, Text::on_white, "on_white") << " "
<< Text::colorize (Text::nocolor, Text::on_bright_white, "on_bright_white") << std::endl
<< optionalBlankLine ();
}
else
{
out << "Color is currently turned off in your .taskrc file." << std::endl;
out << "Color is currently turned off in your .taskrc file. "
"To enable color, create the entry 'color=on'."
<< std::endl;
}
return out.str ();
@ -954,10 +967,13 @@ std::string handleColor ()
////////////////////////////////////////////////////////////////////////////////
std::string handleAnnotate (TDB& tdb, T& task)
{
/*
if (task.getDescription () == "")
throw std::string ("Cannot apply a blank annotation.");
*/
std::stringstream out;
/*
std::vector <T> all;
tdb.pendingT (all);
filterSequence (all, task);
@ -975,21 +991,10 @@ std::string handleAnnotate (TDB& tdb, T& task)
<< "'"
<< std::endl;
}
*/
return out.str ();
}
////////////////////////////////////////////////////////////////////////////////
T findT (int id, const std::vector <T>& all)
{
std::vector <T>::const_iterator it;
for (it = all.begin (); it != all.end (); ++it)
if (id == it->getId ())
return *it;
return T ();
}
////////////////////////////////////////////////////////////////////////////////
int deltaAppend (T& task, T& delta)
{

View file

@ -207,7 +207,7 @@ void filter (std::vector<T>& all, T& task)
std::string handleCompleted (TDB& tdb, T& task)
{
std::stringstream out;
/*
// Determine window size, and set table accordingly.
int width = context.config.get ("defaultwidth", (int) 80);
#ifdef HAVE_LIBNCURSES
@ -303,6 +303,7 @@ std::string handleCompleted (TDB& tdb, T& task)
else
out << "No matches."
<< std::endl;
*/
return out.str ();
}
@ -312,7 +313,7 @@ std::string handleCompleted (TDB& tdb, T& task)
std::string handleInfo (TDB& tdb, T& task)
{
std::stringstream out;
/*
// Determine window size, and set table accordingly.
int width = context.config.get ("defaultwidth", (int) 80);
#ifdef HAVE_LIBNCURSES
@ -544,7 +545,7 @@ std::string handleInfo (TDB& tdb, T& task)
if (! tasks.size ())
out << "No matches." << std::endl;
*/
return out.str ();
}
@ -555,7 +556,7 @@ std::string handleInfo (TDB& tdb, T& task)
std::string handleReportSummary (TDB& tdb, T& task)
{
std::stringstream out;
/*
std::vector <T> tasks;
tdb.allT (tasks);
handleRecurrence (tdb, tasks);
@ -692,7 +693,7 @@ std::string handleReportSummary (TDB& tdb, T& task)
<< std::endl;
else
out << "No projects." << std::endl;
*/
return out.str ();
}
@ -718,7 +719,7 @@ std::string handleReportSummary (TDB& tdb, T& task)
std::string handleReportNext (TDB& tdb, T& task)
{
std::stringstream out;
/*
// Load all pending.
std::vector <T> pending;
tdb.allPendingT (pending);
@ -875,7 +876,7 @@ std::string handleReportNext (TDB& tdb, T& task)
else
out << "No matches."
<< std::endl;
*/
return out.str ();
}
@ -904,7 +905,7 @@ time_t monthlyEpoch (const std::string& date)
std::string handleReportHistory (TDB& tdb, T& task)
{
std::stringstream out;
/*
std::map <time_t, int> groups;
std::map <time_t, int> addedGroup;
std::map <time_t, int> completedGroup;
@ -1089,7 +1090,7 @@ std::string handleReportHistory (TDB& tdb, T& task)
<< std::endl;
else
out << "No tasks." << std::endl;
*/
return out.str ();
}
@ -1097,7 +1098,7 @@ std::string handleReportHistory (TDB& tdb, T& task)
std::string handleReportGHistory (TDB& tdb, T& task)
{
std::stringstream out;
/*
// Determine window size, and set table accordingly.
int width = context.config.get ("defaultwidth", (int) 80);
#ifdef HAVE_LIBNCURSES
@ -1334,7 +1335,7 @@ std::string handleReportGHistory (TDB& tdb, T& task)
}
else
out << "No tasks." << std::endl;
*/
return out.str ();
}
@ -1342,7 +1343,7 @@ std::string handleReportGHistory (TDB& tdb, T& task)
std::string handleReportTimesheet (TDB& tdb, T& task)
{
std::stringstream out;
/*
// Determine window size, and set table accordingly.
int width = context.config.get ("defaultwidth", (int) 80);
#ifdef HAVE_LIBNCURSES
@ -1537,7 +1538,7 @@ std::string handleReportTimesheet (TDB& tdb, T& task)
start -= 7 * 86400;
end -= 7 * 86400;
}
*/
return out.str ();
}
@ -1706,7 +1707,7 @@ std::string renderMonths (
std::string handleReportCalendar (TDB& tdb, T& task)
{
std::stringstream out;
/*
// Determine window size, and set table accordingly.
int width = context.config.get ("defaultwidth", (int) 80);
#ifdef HAVE_LIBNCURSES
@ -1824,7 +1825,7 @@ std::string handleReportCalendar (TDB& tdb, T& task)
<< "."
<< optionalBlankLine ()
<< std::endl;
*/
return out.str ();
}
@ -1832,7 +1833,7 @@ std::string handleReportCalendar (TDB& tdb, T& task)
std::string handleReportActive (TDB& tdb, T& task)
{
std::stringstream out;
/*
// Determine window size, and set table accordingly.
int width = context.config.get ("defaultwidth", (int) 80);
#ifdef HAVE_LIBNCURSES
@ -1958,7 +1959,7 @@ std::string handleReportActive (TDB& tdb, T& task)
<< std::endl;
else
out << "No active tasks." << std::endl;
*/
return out.str ();
}
@ -1966,7 +1967,7 @@ std::string handleReportActive (TDB& tdb, T& task)
std::string handleReportOverdue (TDB& tdb, T& task)
{
std::stringstream out;
/*
// Determine window size, and set table accordingly.
int width = context.config.get ("defaultwidth", (int) 80);
#ifdef HAVE_LIBNCURSES
@ -2082,7 +2083,7 @@ std::string handleReportOverdue (TDB& tdb, T& task)
<< std::endl;
else
out << "No overdue tasks." << std::endl;
*/
return out.str ();
}
@ -2090,7 +2091,7 @@ std::string handleReportOverdue (TDB& tdb, T& task)
std::string handleReportStats (TDB& tdb, T& task)
{
std::stringstream out;
/*
// Determine window size, and set table accordingly.
int width = context.config.get ("defaultwidth", (int) 80);
#ifdef HAVE_LIBNCURSES
@ -2284,7 +2285,7 @@ std::string handleReportStats (TDB& tdb, T& task)
out << optionalBlankLine ()
<< table.render ()
<< optionalBlankLine ();
*/
return out.str ();
}
@ -2481,6 +2482,7 @@ std::string handleCustomReport (
T& task,
const std::string& report)
{
/*
// Determine window size, and set table accordingly.
int width = context.config.get ("defaultwidth", (int) 80);
#ifdef HAVE_LIBNCURSES
@ -2890,8 +2892,9 @@ std::string handleCustomReport (
if (sequence.size () == 1)
maximum = sequence[0];
}
*/
std::stringstream out;
/*
if (table.rowCount ())
out << optionalBlankLine ()
<< table.render (maximum)
@ -2902,7 +2905,7 @@ std::string handleCustomReport (
else
out << "No matches."
<< std::endl;
*/
return out.str ();
}

View file

@ -460,7 +460,6 @@ std::string runTaskCommand (
else if (command == "calendar") { out = handleReportCalendar (tdb, task); }
else if (command == "summary") { out = handleReportSummary (tdb, task); }
else if (command == "timesheet") { out = handleReportTimesheet (tdb, task); }
else if (command == "colors") { out = handleColor ( ); }
else if (command == "version") { out = handleVersion ( ); }
else if (command == "help") { out = longUsage ( ); }

View file

@ -79,7 +79,6 @@ std::string handleUndo (TDB&, T&);
std::string handleColor ();
std::string handleAnnotate (TDB&, T&);
std::string handleDuplicate (TDB&, T&);
T findT (int, const std::vector <T>&);
int deltaAppend (T&, T&);
int deltaDescription (T&, T&);
int deltaTags (T&, T&);