From 72ff15ea7a51fad34efaf65e3ddc35a1e5145525 Mon Sep 17 00:00:00 2001 From: Paul Beckingham Date: Thu, 7 May 2009 00:30:20 -0400 Subject: [PATCH] Enhancements - Fixed word wrapping problem on "help" page. - Writes errors to std::cout because std::cerr confuses tests. Presumably no users will care. I don't. - Added listDiff template function. --- src/task.cpp | 8 ++++---- src/task.h | 47 +++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 51 insertions(+), 4 deletions(-) diff --git a/src/task.cpp b/src/task.cpp index 190d86daa..bf725f8a5 100644 --- a/src/task.cpp +++ b/src/task.cpp @@ -226,9 +226,9 @@ static std::string longUsage (Config& conf) { std::stringstream out; out << shortUsage (conf) - << "ID is the numeric identifier displayed by the 'task list' command." << "\n" - << "You can specify multiple IDs for task commands, and multiple tasks" << "\n" - << "will be affected. To specify multiple IDs make sure you use one" << "\n" + << "ID is the numeric identifier displayed by the 'task list' command. " + << "You can specify multiple IDs for task commands, and multiple tasks " + << "will be affected. To specify multiple IDs make sure you use one " << "of these forms:" << "\n" << " task delete 1,2,3" << "\n" << " task info 1-3" << "\n" @@ -341,7 +341,7 @@ int main (int argc, char** argv) catch (std::string& error) { - std::cerr << error << std::endl; + std::cout << error << std::endl; return -1; } diff --git a/src/task.h b/src/task.h index ab4faa514..2ecc4f755 100644 --- a/src/task.h +++ b/src/task.h @@ -90,8 +90,14 @@ std::string handleUndo (TDB&, T&, Config&); std::string handleColor (Config&); std::string handleAnnotate (TDB&, T&, Config&); T findT (int, const std::vector &); +int deltaAppend (T&, T&); +int deltaDescription (T&, T&); +int deltaTags (T&, T&); +int deltaAttributes (T&, T&); +int deltaSubstitutions (T&, T&); // report.cpp +void filterSequence (std::vector&, T&); void filter (std::vector&, T&); std::string handleInfo (TDB&, T&, Config&); std::string handleCompleted (TDB&, T&, Config&); @@ -151,4 +157,45 @@ void autoColorize (T&, Text::color&, Text::color&, Config&); // import.cpp std::string handleImport (TDB&, T&, Config&); +// list template +/////////////////////////////////////////////////////////////////////////////// +template void listDiff ( + const T& left, const T& right, T& leftOnly, T& rightOnly) +{ + leftOnly.clear (); + rightOnly.clear (); + + for (unsigned int l = 0; l < left.size (); ++l) + { + bool found = false; + for (unsigned int r = 0; r < right.size (); ++r) + { + if (left[l] == right[r]) + { + found = true; + break; + } + } + + if (!found) + leftOnly.push_back (left[l]); + } + + for (unsigned int r = 0; r < right.size (); ++r) + { + bool found = false; + for (unsigned int l = 0; l < left.size (); ++l) + { + if (left[l] == right[r]) + { + found = true; + break; + } + } + + if (!found) + rightOnly.push_back (right[r]); + } +} + ////////////////////////////////////////////////////////////////////////////////