diff --git a/src/TDB.cpp b/src/TDB.cpp index 9ea2db02c..76eaec080 100644 --- a/src/TDB.cpp +++ b/src/TDB.cpp @@ -52,9 +52,9 @@ #define DEBUG_OUTPUT 0 #if DEBUG_OUTPUT > 0 - #define DEBUG_STR(str) std::cout << "DEBUG: " << str << std::endl; std::cout.flush() + #define DEBUG_STR(str) std::cout << "DEBUG: " << str << "\n"; std::cout.flush() #define DEBUG_STR_PART(str) std::cout << "DEBUG: " << str; std::cout.flush() - #define DEBUG_STR_END(str) std::cout << str << std::endl; std::cout.flush() + #define DEBUG_STR_END(str) std::cout << str << "\n"; std::cout.flush() #else #define DEBUG_STR(str) #define DEBUG_STR_PART(str) @@ -613,6 +613,9 @@ int TDB::gc () std::vector ignore; loadPending (ignore, filter); + // TODO This whole idea of removing dangling dependencies is suspect. I'm not + // sure it should be included. + // Search for dangling dependencies. These are dependencies whose uuid cannot // be converted to an id by TDB. std::vector deps; @@ -758,10 +761,10 @@ void TDB::undo () if (context.config.get ("undo.style") == "side") { - std::cout << std::endl + std::cout << "\n" << "The last modification was made " << lastChange.toString () - << std::endl; + << "\n"; // Attributes are all there is, so figure the different attribute names // between before and after. @@ -844,9 +847,9 @@ void TDB::undo () } } - std::cout << std::endl + std::cout << "\n" << table.render () - << std::endl; + << "\n"; } // This style looks like this: @@ -977,15 +980,15 @@ void TDB::undo () } } - std::cout << std::endl + std::cout << "\n" << table.render () - << std::endl; + << "\n"; } // Output displayed, now confirm. if (!confirm ("The undo command is not reversible. Are you sure you want to revert to the previous state?")) { - std::cout << "No changes made." << std::endl; + std::cout << "No changes made.\n"; context.hooks.trigger ("post-undo"); return; } @@ -1013,12 +1016,12 @@ void TDB::undo () if (prior != "") { *task = prior; - std::cout << "Modified task reverted." << std::endl; + std::cout << "Modified task reverted.\n"; } else { p.erase (task); - std::cout << "Task removed." << std::endl; + std::cout << "Task removed.\n"; } // Rewrite files. @@ -1050,7 +1053,7 @@ void TDB::undo () File::write (completedFile, c); File::write (pendingFile, p); File::write (undoFile, u); - std::cout << "Modified task reverted." << std::endl; + std::cout << "Modified task reverted.\n"; context.debug ("TDB::undo - task belongs in pending.data"); } else @@ -1058,11 +1061,11 @@ void TDB::undo () *task = prior; File::write (completedFile, c); File::write (undoFile, u); - std::cout << "Modified task reverted." << std::endl; + std::cout << "Modified task reverted.\n"; context.debug ("TDB::undo - task belongs in completed.data"); } - std::cout << "Undo complete." << std::endl; + std::cout << "Undo complete.\n"; context.hooks.trigger ("post-undo"); return; } @@ -1072,10 +1075,8 @@ void TDB::undo () // Perhaps the task was in completed.data, which was still in file format 3? std::cout << "Task with UUID " << uuid.substr (6, 36) - << " not found in data." - << std::endl - << "No undo possible." - << std::endl; + << " not found in data.\n" + << "No undo possible.\n"; } //////////////////////////////////////////////////////////////////////////////// @@ -1199,7 +1200,7 @@ void TDB::merge (const std::string& mergeFile) { std::cout << "Skipping the new local task " << (*lmod_it).getUuid() - << std::endl; + << "\n"; uuid_left.insert ( (*lmod_it).getUuid ()); } @@ -1223,7 +1224,7 @@ void TDB::merge (const std::string& mergeFile) { std::cout << "Adding the new remote task " << tmod.getUuid() - << std::endl; + << "\n"; uuid_new.insert (tmod.getUuid ()); mods.push_back (tmod); rmods.erase (current); @@ -1292,7 +1293,7 @@ void TDB::merge (const std::string& mergeFile) // which one is newer? if (tmod_r > tmod_l) { - std::cout << "Applying remote changes for uuid " << uuid << std::endl; + std::cout << "Applying remote changes for uuid " << uuid << "\n"; mods.push_front(tmod_r); @@ -1305,7 +1306,7 @@ void TDB::merge (const std::string& mergeFile) } else { - std::cout << "Rejecting remote changes for uuid " << uuid << std::endl; + std::cout << "Rejecting remote changes for uuid " << uuid << "\n"; // inserting right mod into history of local database // so that it can be restored later @@ -1361,7 +1362,7 @@ void TDB::merge (const std::string& mergeFile) else // lit == undo.end () { // nothing happend on the local branch - std::cout << "No changes were made on the local database. Appending changes..." << std::endl; + std::cout << "No changes were made on the local database. Appending changes...\n"; // add remaining lines (remote branch) to the list of modifications readTaskmods (r, rit, mods); @@ -1372,7 +1373,7 @@ void TDB::merge (const std::string& mergeFile) if (!mods.empty ()) { - std::cout << "Running redo routine..." << std::endl; + std::cout << "Running redo routine...\n"; std::string pendingFile = location.data + "/pending.data"; std::vector pending; @@ -1411,7 +1412,7 @@ void TDB::merge (const std::string& mergeFile) if (it->find (uuid) != std::string::npos) { // Update the completed record. - std::cout << "Modifying " << uuid << std::endl; + std::cout << "Modifying " << uuid << "\n"; // remove the \n from composeF4() string std::string newline = tmod.getAfter ().composeF4 (); @@ -1449,7 +1450,7 @@ void TDB::merge (const std::string& mergeFile) if (it->find (uuid) != std::string::npos) { // Update the pending record. - std::cout << "Modifying " << uuid << std::endl; + std::cout << "Modifying " << uuid << "\n"; // remove the \n from composeF4() string // which will replace the current line @@ -1481,7 +1482,7 @@ void TDB::merge (const std::string& mergeFile) if (!found) { - std::cout << "Missing " << uuid << std::endl; + std::cout << "Missing " << uuid << "\n"; mods.erase (current); } @@ -1505,11 +1506,11 @@ void TDB::merge (const std::string& mergeFile) if (!found) { - std::cout << "Adding " << uuid << std::endl; + std::cout << "Adding " << uuid << "\n"; pending.push_back (tmod.getAfter ().composeF4 ()); } else - std::cout << "Not adding duplicate " << uuid << std::endl; + std::cout << "Not adding duplicate " << uuid << "\n"; mods.erase (current); } } @@ -1539,7 +1540,7 @@ void TDB::merge (const std::string& mergeFile) } else // nothing to be done { - std::cout << "Nothing to be done." << std::endl; + std::cout << "Nothing to be done.\n"; } // delete objects @@ -1590,7 +1591,7 @@ FILE* TDB::openAndLock (const std::string& file) if (mLock) while (flock (fileno (in), LOCK_NB | LOCK_EX) && ++retry <= 3) { - std::cout << "Waiting for file lock..." << std::endl; + std::cout << "Waiting for file lock...\n"; while (flock (fileno (in), LOCK_NB | LOCK_EX) && ++retry <= 3) delay (0.2); } diff --git a/src/command.cpp b/src/command.cpp index 837b3e9ee..b4f2cecc3 100644 --- a/src/command.cpp +++ b/src/command.cpp @@ -143,7 +143,7 @@ int handleAdd (std::string &outs) context.tdb.add (context.task); #ifdef FEATURE_NEW_ID - out << "Created task " << context.tdb.nextId () << "." << std::endl; + out << "Created task " << context.tdb.nextId () << ".\n"; #endif out << onProjectChange (context.task); @@ -212,7 +212,7 @@ int handleLog (std::string &outs) context.tdb.unlock (); if (context.config.getBoolean ("echo.command")) - out << "Logged task." << std::endl; + out << "Logged task.\n"; out << onProjectChange (context.task); @@ -309,14 +309,11 @@ int handleProjects (std::string &outs) << optionalBlankLine () << unique.size () << (unique.size () == 1 ? " project" : " projects") - << " (" << quantity << (quantity == 1 ? " task" : " tasks") << ")" - << std::endl; + << " (" << quantity << (quantity == 1 ? " task" : " tasks") << ")\n"; } else { - out << "No projects." - << std::endl; - + out << "No projects.\n"; rc = 1; } @@ -351,7 +348,7 @@ int handleCompletionProjects (std::string &outs) std::stringstream out; foreach (project, unique) if (project->first.length ()) - out << project->first << std::endl; + out << project->first << "\n"; outs = out.str (); return 0; @@ -430,13 +427,11 @@ int handleTags (std::string &outs) << optionalBlankLine () << unique.size () << (unique.size () == 1 ? " tag" : " tags") - << " (" << quantity << (quantity == 1 ? " task" : " tasks") << ")" - << std::endl; + << " (" << quantity << (quantity == 1 ? " task" : " tasks") << ")\n"; } else { - out << "No tags." - << std::endl; + out << "No tags.\n"; rc = 1; } @@ -476,7 +471,7 @@ int handleCompletionTags (std::string &outs) std::stringstream out; foreach (tag, unique) - out << tag->first << std::endl; + out << tag->first << "\n"; outs = out.str (); return 0; @@ -494,7 +489,7 @@ int handleCompletionCommands (std::string &outs) std::stringstream out; foreach (command, commands) - out << *command << std::endl; + out << *command << "\n"; outs = out.str (); return 0; @@ -509,7 +504,7 @@ int handleCompletionConfig (std::string &outs) std::stringstream out; foreach (config, configs) - out << *config << std::endl; + out << *config << "\n"; outs = out.str (); return 0; @@ -575,7 +570,7 @@ int handleCompletionIDs (std::string &outs) std::stringstream out; foreach (id, ids) - out << *id << std::endl; + out << *id << "\n"; outs = out.str (); return 0; @@ -715,7 +710,7 @@ int handleVersion (std::string &outs) Color bold ("bold"); - out << std::endl + out << "\n" << ((context.config.getBoolean ("color") || context.config.getBoolean ("_forcecolor")) ? bold.colorize (PACKAGE) : PACKAGE) @@ -755,16 +750,14 @@ int handleVersion (std::string &outs) << "-lua" #endif - << std::endl - << "Copyright (C) 2006 - 2010 P. Beckingham, F. Hernandez." - << std::endl + << "\n" + << "Copyright (C) 2006 - 2010 P. Beckingham, F. Hernandez.\n" #ifdef HAVE_LIBLUA - << "Portions of this software Copyright (C) 1994 – 2008 Lua.org, PUC-Rio." - << std::endl + << "Portions of this software Copyright (C) 1994 – 2008 Lua.org, PUC-Rio.\n" #endif << disclaimer.render () << link.render () - << std::endl; + << "\n"; outs = out.str (); context.hooks.trigger ("post-version-command"); @@ -912,25 +905,22 @@ int handleShow (std::string &outs) } } - out << std::endl + out << "\n" << table.render () - << (table.rowCount () == 0 ? "No matching configuration variables.\n" : "") - << std::endl; + << (table.rowCount () == 0 ? "No matching configuration variables.\n\n" : "\n"); // Display the unrecognized variables. if (unrecognized.size ()) { - out << "Your .taskrc file contains these unrecognized variables:" - << std::endl; + out << "Your .taskrc file contains these unrecognized variables:\n"; foreach (i, unrecognized) - out << " " << *i << std::endl; + out << " " << *i << "\n"; if (context.config.getBoolean ("color") || context.config.getBoolean ("_forcecolor")) - out << std::endl - << " These are highlighted in " << error.colorize ("color") << " above."; + out << "\n These are highlighted in " << error.colorize ("color") << " above."; - out << std::endl; + out << "\n"; } out << context.config.checkForDeprecatedColor (); @@ -970,13 +960,12 @@ int handleShow (std::string &outs) if (missing_scripts.size ()) { - out << "Your .taskrc file contains these missing or unreadable hook scripts:" - << std::endl; + out << "Your .taskrc file contains these missing or unreadable hook scripts:\n"; foreach (i, missing_scripts) - out << " " << *i << std::endl; + out << " " << *i << "\n"; - out << std::endl; + out << "\n"; } #endif @@ -987,8 +976,7 @@ int handleShow (std::string &outs) annotations != "none") out << "Configuration error: annotations contains an unrecognized value '" << annotations - << "'." - << std::endl; + << "'.\n"; // Check for bad values in rc.calendar.details. std::string calendardetails = context.config.get ("calendar.details"); @@ -997,8 +985,7 @@ int handleShow (std::string &outs) calendardetails != "none") out << "Configuration error: calendar.details contains an unrecognized value '" << calendardetails - << "'." - << std::endl; + << "'.\n"; // Check for bad values in rc.calendar.holidays. std::string calendarholidays = context.config.get ("calendar.holidays"); @@ -1007,8 +994,7 @@ int handleShow (std::string &outs) calendarholidays != "none") out << "Configuration error: calendar.holidays contains an unrecognized value '" << calendarholidays - << "'." - << std::endl; + << "'.\n"; // Check for bad values in rc.default.priority. std::string defaultPriority = context.config.get ("default.priority"); @@ -1018,16 +1004,14 @@ int handleShow (std::string &outs) defaultPriority != "") out << "Configuration error: default.priority contains an unrecognized value '" << defaultPriority - << "'." - << std::endl; + << "'.\n"; // Verify installation. This is mentioned in the documentation as the way // to ensure everything is properly installed. if (all.size () == 0) { - out << "Configuration error: .taskrc contains no entries." - << std::endl; + out << "Configuration error: .taskrc contains no entries.\n"; rc = 1; } else @@ -1036,13 +1020,11 @@ int handleShow (std::string &outs) if (location.data == "") out << "Configuration error: data.location not specified in .taskrc " - "file." - << std::endl; + "file.\n"; if (! location.exists ()) out << "Configuration error: data.location contains a directory name" - " that doesn't exist, or is unreadable." - << std::endl; + " that doesn't exist, or is unreadable.\n"; } outs = out.str (); @@ -1159,11 +1141,10 @@ int handleConfig (std::string &outs) File::write (context.config.original_file, contents); out << "Config file " << context.config.original_file.data - << " modified." - << std::endl; + << " modified.\n"; } else - out << "No changes made." << std::endl; + out << "No changes made.\n"; } else throw std::string ("Specify the name of a config variable to modify."); @@ -1241,8 +1222,7 @@ int handleDelete (std::string &outs) << sibling->id << " '" << sibling->get ("description") - << "'." - << std::endl; + << "'.\n"; } } } @@ -1263,8 +1243,7 @@ int handleDelete (std::string &outs) << task->id << " '" << task->get ("description") - << "'." - << std::endl; + << "'.\n"; dependencyChainOnComplete (*task); out << onProjectChange (*task); @@ -1286,15 +1265,14 @@ int handleDelete (std::string &outs) << task->id << " '" << task->get ("description") - << "'." - << std::endl; + << "'.\n"; dependencyChainOnComplete (*task); out << onProjectChange (*task); } } else { - out << "Task not deleted." << std::endl; + out << "Task not deleted.\n"; rc = 1; } @@ -1351,8 +1329,7 @@ int handleStart (std::string &outs) << task->id << " '" << task->get ("description") - << "'." - << std::endl; + << "'.\n"; if (!nagged) nagged = nag (*task); @@ -1364,8 +1341,7 @@ int handleStart (std::string &outs) << task->id << " '" << task->get ("description") - << "' already started." - << std::endl; + << "' already started.\n"; rc = 1; } } @@ -1415,8 +1391,7 @@ int handleStop (std::string &outs) << task->id << " '" << task->get ("description") - << "'." - << std::endl; + << "'.\n"; } else { @@ -1424,8 +1399,7 @@ int handleStop (std::string &outs) << task->id << " '" << task->get ("description") - << "' not started." - << std::endl; + << "' not started.\n"; rc = 1; } } @@ -1500,8 +1474,7 @@ int handleDone (std::string &outs) << task->id << " '" << task->get ("description") - << "'." - << std::endl; + << "'.\n"; dependencyChainOnComplete (*task); out << onProjectChange (*task, false); @@ -1523,8 +1496,7 @@ int handleDone (std::string &outs) << task->id << " '" << task->get ("description") - << "' is neither pending nor waiting." - << std::endl; + << "' is neither pending nor waiting.\n"; rc = 1; } @@ -1538,8 +1510,7 @@ int handleDone (std::string &outs) << count << " task" << (count == 1 ? "" : "s") - << " as done." - << std::endl; + << " as done.\n"; outs = out.str (); context.hooks.trigger ("post-done-command"); @@ -1610,8 +1581,7 @@ int handleModify (std::string &outs) std::cout << "Task " << task->id << " is a recurring task, and all other instances of this" - << " task will be modified." - << std::endl; + << " task will be modified.\n"; Task before (*other); @@ -1629,8 +1599,7 @@ int handleModify (std::string &outs) std::cout << "Task " << other->id - << " is now a recurring task." - << std::endl; + << " is now a recurring task.\n"; } // Apply other deltas. @@ -1671,7 +1640,7 @@ int handleModify (std::string &outs) context.tdb.unlock (); if (context.config.getBoolean ("echo.command")) - out << "Modified " << count << " task" << (count == 1 ? "." : "s.") << std::endl; + out << "Modified " << count << " task" << (count == 1 ? ".\n" : "s.\n"); outs = out.str (); context.hooks.trigger ("post-modify-command"); @@ -1732,8 +1701,7 @@ int handleAppend (std::string &outs) << context.task.get ("description") << "' to task " << other->id - << "." - << std::endl; + << ".\n"; if (before.get ("project") != other->get ("project")) out << onProjectChange (before, *other); @@ -1749,7 +1717,7 @@ int handleAppend (std::string &outs) context.tdb.unlock (); if (context.config.getBoolean ("echo.command")) - out << "Appended " << count << " task" << (count == 1 ? "." : "s.") << std::endl; + out << "Appended " << count << " task" << (count == 1 ? ".\n" : "s.\n"); outs = out.str (); context.hooks.trigger ("post-append-command"); @@ -1812,8 +1780,7 @@ int handlePrepend (std::string &outs) << context.task.get ("description") << "' to task " << other->id - << "." - << std::endl; + << ".\n"; if (before.get ("project") != other->get ("project")) out << onProjectChange (before, *other); @@ -1829,7 +1796,7 @@ int handlePrepend (std::string &outs) context.tdb.unlock (); if (context.config.getBoolean ("echo.command")) - out << "Prepended " << count << " task" << (count == 1 ? "." : "s.") << std::endl; + out << "Prepended " << count << " task" << (count == 1 ? ".\n" : "s.\n"); outs = out.str (); context.hooks.trigger ("post-prepend-command"); @@ -1875,8 +1842,7 @@ int handleDuplicate (std::string &outs) out << "Note: task " << task->id - << " was a recurring task. The new task is not." - << std::endl; + << " was a recurring task. The new task is not.\n"; } // Apply deltas. @@ -1897,8 +1863,7 @@ int handleDuplicate (std::string &outs) << task->id << " '" << task->get ("description") - << "'." - << std::endl; + << "'.\n"; out << onProjectChange (dup); @@ -1907,13 +1872,13 @@ int handleDuplicate (std::string &outs) if (context.config.getBoolean ("echo.command")) { - out << "Duplicated " << count << " task" << (count == 1 ? "." : "s.") << std::endl; + out << "Duplicated " << count << " task" << (count == 1 ? ".\n" : "s.\n"); #ifdef FEATURE_NEW_ID // All this, just for an id number. std::vector all; Filter none; context.tdb.loadPending (all, none); - out << "Created task " << context.tdb.nextId () << "." << std::endl; + out << "Created task " << context.tdb.nextId () << ".\n"; #endif } @@ -1938,16 +1903,10 @@ void handleShell () std::cout << ((context.config.getBoolean ("color") || context.config.getBoolean ("_forcecolor")) ? bold.colorize (PACKAGE_STRING) : PACKAGE_STRING) - << " shell" - << std::endl - << std::endl - << "Enter any task command (such as 'list'), or hit 'Enter'." - << std::endl - << "There is no need to include the 'task' command itself." - << std::endl - << "Enter 'quit' to end the session." - << std::endl - << std::endl; + << " shell\n\n" + << "Enter any task command (such as 'list'), or hit 'Enter'.\n" + << "There is no need to include the 'task' command itself.\n" + << "Enter 'quit' to end the session.\n\n"; // Make a copy because context.clear will delete them. std::string permanentOverrides = " " + context.file_override @@ -1995,12 +1954,12 @@ void handleShell () catch (std::string& error) { - std::cout << error << std::endl; + std::cout << error << "\n"; } catch (...) { - std::cerr << context.stringtable.get (100, "Unknown error.") << std::endl; + std::cerr << context.stringtable.get (100, "Unknown error.") << "\n"; } } } @@ -2029,9 +1988,7 @@ int handleColor (std::string &outs) std::string description = context.task.get ("description"); if (description.find ("legend") != std::string::npos) { - out << std::endl - << "Here are the colors currently in use:" - << std::endl; + out << "\nHere are the colors currently in use:\n"; std::vector all; context.config.all (all); @@ -2065,7 +2022,7 @@ int handleColor (std::string &outs) out << optionalBlankLine () << table.render () << optionalBlankLine () - << std::endl; + << "\n"; } // If there is something in the description, then assume that is a color, @@ -2080,30 +2037,29 @@ int handleColor (std::string &outs) Color six ("red on color173"); Color sample (description); - out << std::endl - << "Use this command to see how colors are displayed by your terminal." << std::endl - << std::endl - << "16-color usage (supports underline, bold text, bright background):" << std::endl - << " " << one.colorize ("task color black on bright yellow") << std::endl - << " " << two.colorize ("task color underline cyan on bright blue") << std::endl - << std::endl - << "256-color usage (supports underline):" << std::endl - << " " << three.colorize ("task color color214 on color202") << std::endl - << " " << four.colorize ("task color rgb150 on rgb020") << std::endl - << " " << five.colorize ("task color underline grey10 on grey3") << std::endl - << " " << six.colorize ("task color red on color173") << std::endl - << std::endl - << "Your sample:" << std::endl - << " " << sample.colorize ("task color " + description) << std::endl - << std::endl; + out << "\n" + << "Use this command to see how colors are displayed by your terminal.\n\n" + << "\n" + << "16-color usage (supports underline, bold text, bright background):\n" + << " " << one.colorize ("task color black on bright yellow") << "\n" + << " " << two.colorize ("task color underline cyan on bright blue") << "\n" + << "\n" + << "256-color usage (supports underline):\n" + << " " << three.colorize ("task color color214 on color202") << "\n" + << " " << four.colorize ("task color rgb150 on rgb020") << "\n" + << " " << five.colorize ("task color underline grey10 on grey3") << "\n" + << " " << six.colorize ("task color red on color173") << "\n" + << "\n" + << "Your sample:" << "\n" + << " " << sample.colorize ("task color " + description) << "\n\n"; } // Show all supported colors. Possibly show some unsupported ones too. else { - out << std::endl + out << "\n" << "Basic colors" - << std::endl + << "\n" << " " << Color::colorize (" black ", "black") << " " << Color::colorize (" red ", "red") << " " << Color::colorize (" blue ", "blue") @@ -2112,7 +2068,7 @@ int handleColor (std::string &outs) << " " << Color::colorize (" cyan ", "cyan") << " " << Color::colorize (" yellow ", "yellow") << " " << Color::colorize (" white ", "white") - << std::endl + << "\n" << " " << Color::colorize (" black ", "white on black") << " " << Color::colorize (" red ", "white on red") << " " << Color::colorize (" blue ", "white on blue") @@ -2121,24 +2077,21 @@ int handleColor (std::string &outs) << " " << Color::colorize (" cyan ", "black on cyan") << " " << Color::colorize (" yellow ", "black on yellow") << " " << Color::colorize (" white ", "black on white") - << std::endl - << std::endl; + << "\n\n"; out << "Effects" - << std::endl + << "\n" << " " << Color::colorize (" red ", "red") << " " << Color::colorize (" bold red ", "bold red") << " " << Color::colorize (" underline on blue ", "underline on blue") << " " << Color::colorize (" on green ", "black on green") << " " << Color::colorize (" on bright green ", "black on bright green") - << std::endl - << std::endl; + << "\n\n"; // 16 system colors. out << "color0 - color15" - << std::endl - << " 0 1 2 . . ." - << std::endl; + << "\n" + << " 0 1 2 . . .\n"; for (int r = 0; r < 2; ++r) { out << " "; @@ -2149,12 +2102,10 @@ int handleColor (std::string &outs) out << Color::colorize (" ", s.str ()); } - out << std::endl; + out << "\n"; } - out << " . . . 15" - << std::endl - << std::endl; + out << " . . . 15\n\n"; // Color cube. out << "Color cube rgb" @@ -2166,21 +2117,21 @@ int handleColor (std::string &outs) << Color::colorize ("5", "bold green") << Color::colorize ("5", "bold blue") << " (also color16 - color231)" - << std::endl + << "\n" << " " << Color::colorize ("0 " "1 " "2 " "3 " "4 " "5", "bold red") - << std::endl + << "\n" << " " << Color::colorize ("0 1 2 3 4 5 " "0 1 2 3 4 5 " "0 1 2 3 4 5 " "0 1 2 3 4 5 " "0 1 2 3 4 5 " "0 1 2 3 4 5", "bold blue") - << std::endl; + << "\n"; char label [12]; for (int g = 0; g < 6; ++g) @@ -2199,16 +2150,14 @@ int handleColor (std::string &outs) out << " "; } - out << std::endl; + out << "\n"; } - out << std::endl; + out << "\n"; // Grey ramp. - out << "Gray ramp gray0 - gray23 (also color232 - color255)" - << std::endl - << " 0 1 2 . . . . . . 23" - << std::endl + out << "Gray ramp gray0 - gray23 (also color232 - color255)\n" + << " 0 1 2 . . . . . . 23\n" << " "; for (int g = 0; g < 24; ++g) { @@ -2217,18 +2166,13 @@ int handleColor (std::string &outs) out << Color::colorize (" ", s.str ()); } - out << std::endl - << std::endl - << "Try running 'task color white on red'." - << std::endl - << std::endl; + out << "\n\nTry running 'task color white on red'.\n\n"; } } else { out << "Color is currently turned off in your .taskrc file. To enable " - "color, remove the line 'color=off', or change the 'off' to 'on'." - << std::endl; + "color, remove the line 'color=off', or change the 'off' to 'on'.\n"; rc = 1; } @@ -2282,8 +2226,7 @@ int handleAnnotate (std::string &outs) << task->id << " with '" << context.task.get ("description") - << "'." - << std::endl; + << "'.\n"; } } } @@ -2375,15 +2318,13 @@ int handleDenotate (std::string &outs) if (context.config.getBoolean ("echo.command")) out << "Found annotation '" << anno - << "' and deleted it." - << std::endl; + << "' and deleted it.\n"; } } else out << "Did not find any matching annotation to be deleted for '" << desc - << "'." - << std::endl; + << "'.\n"; } context.tdb.commit (); diff --git a/src/edit.cpp b/src/edit.cpp index cf6a8ee06..0110b843b 100644 --- a/src/edit.cpp +++ b/src/edit.cpp @@ -112,52 +112,52 @@ static std::string formatDate ( static std::string formatTask (Task task) { std::stringstream before; - before << "# The 'task edit ' command allows you to modify all aspects of a task" << std::endl - << "# using a text editor. What is shown below is a representation of the" << std::endl - << "# task in all it's detail. Modify what you wish, and if you save and" << std::endl - << "# quit your editor, taskwarrior will read this file and try to make sense" << std::endl - << "# of what changed, and apply those changes. If you quit your editor" << std::endl - << "# without saving or making any modifications, taskwarrior will do nothing."<< std::endl - << "#" << std::endl - << "# Lines that begin with # represent data you cannot change, like ID." << std::endl - << "# If you get too 'creative' with your editing, taskwarrior will dump you" << std::endl - << "# back into the editor to try again." << std::endl - << "#" << std::endl - << "# Should you find yourself in an endless Groundhog Day loop, editing and" << std::endl - << "# editing the same file, just quit the editor without making any changes." << std::endl - << "# Taskwarrior will notice this and stop the editing." << std::endl - << "#" << std::endl - << "# Name Editable details" << std::endl - << "# ----------------- ----------------------------------------------------" << std::endl - << "# ID: " << task.id << std::endl - << "# UUID: " << task.get ("uuid") << std::endl - << "# Status: " << ucFirst (Task::statusToText (task.getStatus ())) << std::endl - << "# Mask: " << task.get ("mask") << std::endl - << "# iMask: " << task.get ("imask") << std::endl - << " Project: " << task.get ("project") << std::endl - << " Priority: " << task.get ("priority") << std::endl; + before << "# The 'task edit ' command allows you to modify all aspects of a task\n" + << "# using a text editor. What is shown below is a representation of the\n" + << "# task in all it's detail. Modify what you wish, and if you save and\n" + << "# quit your editor, taskwarrior will read this file and try to make sense\n" + << "# of what changed, and apply those changes. If you quit your editor\n" + << "# without saving or making any modifications, taskwarrior will do nothing.\n" + << "#\n" + << "# Lines that begin with # represent data you cannot change, like ID.\n" + << "# If you get too 'creative' with your editing, taskwarrior will dump you\n" + << "# back into the editor to try again.\n" + << "#\n" + << "# Should you find yourself in an endless Groundhog Day loop, editing and\n" + << "# editing the same file, just quit the editor without making any changes.\n" + << "# Taskwarrior will notice this and stop the editing.\n" + << "#\n" + << "# Name Editable details\n" + << "# ----------------- ----------------------------------------------------\n" + << "# ID: " << task.id << "\n" + << "# UUID: " << task.get ("uuid") << "\n" + << "# Status: " << ucFirst (Task::statusToText (task.getStatus ())) << "\n" + << "# Mask: " << task.get ("mask") << "\n" + << "# iMask: " << task.get ("imask") << "\n" + << " Project: " << task.get ("project") << "\n" + << " Priority: " << task.get ("priority") << "\n"; std::vector tags; task.getTags (tags); std::string allTags; join (allTags, " ", tags); - before << "# Separate the tags with spaces, like this: tag1 tag2" << std::endl - << " Tags: " << allTags << std::endl - << "# The description field is allowed to wrap and use multiple lines. Task" << std::endl - << "# will combine them." << std::endl - << " Description: " << task.get ("description") << std::endl - << " Created: " << formatDate (task, "entry") << std::endl - << " Started: " << formatDate (task, "start") << std::endl - << " Ended: " << formatDate (task, "end") << std::endl - << " Due: " << formatDate (task, "due") << std::endl - << " Until: " << formatDate (task, "until") << std::endl - << " Recur: " << task.get ("recur") << std::endl - << " Wait until: " << formatDate (task, "wait") << std::endl - << " Parent: " << task.get ("parent") << std::endl - << " Foreground color: " << task.get ("fg") << std::endl - << " Background color: " << task.get ("bg") << std::endl - << "# Annotations look like this: -- and there can be any number of them" << std::endl - << "# ' -- ' is the separator between the date and text field. It should not be removed" << std::endl; + before << "# Separate the tags with spaces, like this: tag1 tag2\n" + << " Tags: " << allTags << "\n" + << "# The description field is allowed to wrap and use multiple lines. Task\n" + << "# will combine them.\n" + << " Description: " << task.get ("description") << "\n" + << " Created: " << formatDate (task, "entry") << "\n" + << " Started: " << formatDate (task, "start") << "\n" + << " Ended: " << formatDate (task, "end") << "\n" + << " Due: " << formatDate (task, "due") << "\n" + << " Until: " << formatDate (task, "until") << "\n" + << " Recur: " << task.get ("recur") << "\n" + << " Wait until: " << formatDate (task, "wait") << "\n" + << " Parent: " << task.get ("parent") << "\n" + << " Foreground color: " << task.get ("fg") << "\n" + << " Background color: " << task.get ("bg") << "\n" + << "# Annotations look like this: -- and there can be any number of them\n" + << "# ' -- ' is the separator between the date and text field. It should not be removed\n"; std::vector annotations; task.getAnnotations (annotations); @@ -165,12 +165,12 @@ static std::string formatTask (Task task) { Date dt (::atoi (anno->name ().substr (11).c_str ())); before << " Annotation: " << dt.toString (context.config.get ("dateformat.annotation")) - << " -- " << anno->value () << std::endl; + << " -- " << anno->value () << "\n"; } Date now; - before << " Annotation: " << now.toString (context.config.get ("dateformat.annotation")) << " -- " << std::endl - << "# End" << std::endl; + before << " Annotation: " << now.toString (context.config.get ("dateformat.annotation")) << " -- \n" + << "# End\n"; // TODO Add dependencies here. @@ -186,12 +186,12 @@ static void parseTask (Task& task, const std::string& after) { if (value != "") { - std::cout << "Project modified." << std::endl; + std::cout << "Project modified.\n"; task.set ("project", value); } else { - std::cout << "Project deleted." << std::endl; + std::cout << "Project deleted.\n"; task.remove ("project"); } } @@ -204,13 +204,13 @@ static void parseTask (Task& task, const std::string& after) { if (Att::validNameValue ("priority", "", value)) { - std::cout << "Priority modified." << std::endl; + std::cout << "Priority modified.\n"; task.set ("priority", value); } } else { - std::cout << "Priority deleted." << std::endl; + std::cout << "Priority deleted.\n"; task.remove ("priority"); } } @@ -228,7 +228,7 @@ static void parseTask (Task& task, const std::string& after) { if (value != "") { - std::cout << "Description modified." << std::endl; + std::cout << "Description modified.\n"; task.set ("description", value); } else @@ -244,7 +244,7 @@ static void parseTask (Task& task, const std::string& after) Date original (::atoi (task.get ("entry").c_str ())); if (!original.sameDay (edited)) { - std::cout << "Creation date modified." << std::endl; + std::cout << "Creation date modified.\n"; task.set ("entry", value); } } @@ -262,13 +262,13 @@ static void parseTask (Task& task, const std::string& after) Date original (::atoi (task.get ("start").c_str ())); if (!original.sameDay (edited)) { - std::cout << "Start date modified." << std::endl; + std::cout << "Start date modified.\n"; task.set ("start", value); } } else { - std::cout << "Start date modified." << std::endl; + std::cout << "Start date modified.\n"; task.set ("start", value); } } @@ -276,7 +276,7 @@ static void parseTask (Task& task, const std::string& after) { if (task.get ("start") != "") { - std::cout << "Start date removed." << std::endl; + std::cout << "Start date removed.\n"; task.remove ("start"); } } @@ -292,7 +292,7 @@ static void parseTask (Task& task, const std::string& after) Date original (::atoi (task.get ("end").c_str ())); if (!original.sameDay (edited)) { - std::cout << "Done date modified." << std::endl; + std::cout << "Done date modified.\n"; task.set ("end", value); } } @@ -303,7 +303,7 @@ static void parseTask (Task& task, const std::string& after) { if (task.get ("end") != "") { - std::cout << "Done date removed." << std::endl; + std::cout << "Done date removed.\n"; task.setStatus (Task::pending); task.remove ("end"); } @@ -320,13 +320,13 @@ static void parseTask (Task& task, const std::string& after) Date original (::atoi (task.get ("due").c_str ())); if (!original.sameDay (edited)) { - std::cout << "Due date modified." << std::endl; + std::cout << "Due date modified.\n"; task.set ("due", value); } } else { - std::cout << "Due date modified." << std::endl; + std::cout << "Due date modified.\n"; task.set ("due", value); } } @@ -337,11 +337,11 @@ static void parseTask (Task& task, const std::string& after) if (task.getStatus () == Task::recurring || task.get ("parent") != "") { - std::cout << "Cannot remove a due date from a recurring task." << std::endl; + std::cout << "Cannot remove a due date from a recurring task.\n"; } else { - std::cout << "Due date removed." << std::endl; + std::cout << "Due date removed.\n"; task.remove ("due"); } } @@ -358,13 +358,13 @@ static void parseTask (Task& task, const std::string& after) Date original (::atoi (task.get ("until").c_str ())); if (!original.sameDay (edited)) { - std::cout << "Until date modified." << std::endl; + std::cout << "Until date modified.\n"; task.set ("until", value); } } else { - std::cout << "Until date modified." << std::endl; + std::cout << "Until date modified.\n"; task.set ("until", value); } } @@ -372,7 +372,7 @@ static void parseTask (Task& task, const std::string& after) { if (task.get ("until") != "") { - std::cout << "Until date removed." << std::endl; + std::cout << "Until date removed.\n"; task.remove ("until"); } } @@ -386,7 +386,7 @@ static void parseTask (Task& task, const std::string& after) Duration d; if (d.valid (value)) { - std::cout << "Recurrence modified." << std::endl; + std::cout << "Recurrence modified.\n"; if (task.get ("due") != "") { task.set ("recur", value); @@ -400,7 +400,7 @@ static void parseTask (Task& task, const std::string& after) } else { - std::cout << "Recurrence removed." << std::endl; + std::cout << "Recurrence removed.\n"; task.setStatus (Task::pending); task.remove ("recur"); task.remove ("until"); @@ -420,13 +420,13 @@ static void parseTask (Task& task, const std::string& after) Date original (::atoi (task.get ("wait").c_str ())); if (!original.sameDay (edited)) { - std::cout << "Wait date modified." << std::endl; + std::cout << "Wait date modified.\n"; task.set ("wait", value); } } else { - std::cout << "Wait date modified." << std::endl; + std::cout << "Wait date modified.\n"; task.set ("wait", value); } } @@ -434,7 +434,7 @@ static void parseTask (Task& task, const std::string& after) { if (task.get ("wait") != "") { - std::cout << "Wait date removed." << std::endl; + std::cout << "Wait date removed.\n"; task.remove ("wait"); } } @@ -445,12 +445,12 @@ static void parseTask (Task& task, const std::string& after) { if (value != "") { - std::cout << "Parent UUID modified." << std::endl; + std::cout << "Parent UUID modified.\n"; task.set ("parent", value); } else { - std::cout << "Parent UUID removed." << std::endl; + std::cout << "Parent UUID removed.\n"; task.remove ("parent"); } } @@ -461,12 +461,12 @@ static void parseTask (Task& task, const std::string& after) { if (value != "") { - std::cout << "Foreground color modified." << std::endl; + std::cout << "Foreground color modified.\n"; task.set ("fg", value); } else { - std::cout << "Foreground color removed." << std::endl; + std::cout << "Foreground color removed.\n"; task.remove ("fg"); } } @@ -477,12 +477,12 @@ static void parseTask (Task& task, const std::string& after) { if (value != "") { - std::cout << "Background color modified." << std::endl; + std::cout << "Background color modified.\n"; task.set ("bg", value); } else { - std::cout << "Background color removed." << std::endl; + std::cout << "Background color removed.\n"; task.remove ("bg"); } } @@ -557,11 +557,11 @@ void editFile (Task& task) ARE_THESE_REALLY_HARMFUL: // Launch the editor. - std::cout << "Launching '" << editor << "' now..." << std::endl; + std::cout << "Launching '" << editor << "' now...\n"; if (-1 == system (editor.c_str ())) - std::cout << "No editing performed." << std::endl; + std::cout << "No editing performed.\n"; else - std::cout << "Editing complete." << std::endl; + std::cout << "Editing complete.\n"; // Slurp file. std::string after; @@ -571,7 +571,7 @@ ARE_THESE_REALLY_HARMFUL: // if changes were made. if (before != after) { - std::cout << "Edits were detected." << std::endl; + std::cout << "Edits were detected.\n"; std::string problem = ""; bool oops = false; @@ -588,7 +588,7 @@ ARE_THESE_REALLY_HARMFUL: if (oops) { - std::cout << "Error: " << problem << std::endl; + std::cout << "Error: " << problem << "\n"; // Preserve the edits. before = after; @@ -599,7 +599,7 @@ ARE_THESE_REALLY_HARMFUL: } } else - std::cout << "No edits were detected." << std::endl; + std::cout << "No edits were detected.\n"; // Cleanup. File::remove (file.str ()); diff --git a/src/report.cpp b/src/report.cpp index 1b08a09f9..2f2a00f7e 100644 --- a/src/report.cpp +++ b/src/report.cpp @@ -253,12 +253,12 @@ int shortUsage (std::string &outs) std::stringstream out; out << table.render () - << std::endl + << "\n" << "Documentation for taskwarrior can be found using 'man task', " << "'man taskrc', 'man task-tutorial', 'man task-color', 'man task-faq' " << "or at http://taskwarrior.org" - << std::endl - << std::endl; + << "\n" + << "\n"; outs = out.str (); return 0; @@ -336,7 +336,7 @@ int longUsage (std::string &outs) << "\n" << "Many characters have special meaning to the shell, including:" << "\n" << " $ ! ' \" ( ) ; \\ ` * ? { } [ ] < > | & % # ~" << "\n" - << std::endl; + << "\n"; outs = out.str(); context.hooks.trigger ("post-usage-command"); @@ -438,19 +438,20 @@ int handleInfo (std::string &outs) } // dependencies: blocked - if (task->has ("depends")) { std::vector blocked; dependencyGetBlocked (*task, blocked); + if (blocked.size ()) + { + std::stringstream message; + std::vector ::const_iterator it; + for (it = blocked.begin (); it != blocked.end (); ++it) + message << it->id << " " << it->get ("description") << "\n"; - std::stringstream message; - std::vector ::const_iterator it; - for (it = blocked.begin (); it != blocked.end (); ++it) - message << it->id << " " << it->get ("description") << "\n"; - - row = table.addRow (); - table.addCell (row, 0, "This task blocked by"); - table.addCell (row, 1, message.str ()); + row = table.addRow (); + table.addCell (row, 0, "This task blocked by"); + table.addCell (row, 1, message.str ()); + } } // dependencies: blocking @@ -635,11 +636,11 @@ int handleInfo (std::string &outs) out << optionalBlankLine () << table.render () - << std::endl; + << "\n"; } if (! tasks.size ()) { - out << "No matches." << std::endl; + out << "No matches.\n"; rc = 1; } @@ -788,9 +789,9 @@ int handleReportSummary (std::string &outs) << optionalBlankLine () << table.rowCount () << (table.rowCount () == 1 ? " project" : " projects") - << std::endl; + << "\n"; else { - out << "No projects." << std::endl; + out << "No projects.\n"; rc = 1; } @@ -994,10 +995,10 @@ int handleReportHistoryMonthly (std::string &outs) if (table.rowCount ()) out << optionalBlankLine () << table.render () - << std::endl; + << "\n"; else { - out << "No tasks." << std::endl; + out << "No tasks.\n"; rc = 1; } @@ -1158,10 +1159,10 @@ int handleReportHistoryAnnual (std::string &outs) if (table.rowCount ()) out << optionalBlankLine () << table.render () - << std::endl; + << "\n"; else { - out << "No tasks." << std::endl; + out << "No tasks.\n"; rc = 1; } @@ -1352,7 +1353,7 @@ int handleReportGHistoryMonthly (std::string &outs) { out << optionalBlankLine () << table.render () - << std::endl; + << "\n"; if (context.config.getBoolean ("color") || context.config.getBoolean ("_forcecolor")) out << "Legend: " @@ -1362,13 +1363,13 @@ int handleReportGHistoryMonthly (std::string &outs) << ", " << color_delete.colorize ("deleted") << optionalBlankLine () - << std::endl; + << "\n"; else - out << "Legend: + added, X completed, - deleted" << std::endl; + out << "Legend: + added, X completed, - deleted\n"; } else { - out << "No tasks." << std::endl; + out << "No tasks.\n"; rc = 1; } @@ -1555,7 +1556,7 @@ int handleReportGHistoryAnnual (std::string &outs) { out << optionalBlankLine () << table.render () - << std::endl; + << "\n"; if (context.config.getBoolean ("color") || context.config.getBoolean ("_forcecolor")) out << "Legend: " @@ -1565,13 +1566,13 @@ int handleReportGHistoryAnnual (std::string &outs) << ", " << color_delete.colorize ("deleted") << optionalBlankLine () - << std::endl; + << "\n"; else - out << "Legend: + added, X completed, - deleted" << std::endl; + out << "Legend: + added, X completed, - deleted\n"; } else { - out << "No tasks." << std::endl; + out << "No tasks.\n"; rc = 1; } @@ -1633,9 +1634,9 @@ int handleReportTimesheet (std::string &outs) + endString.toString (context.config.get ("dateformat")); Color bold (Color::nocolor, Color::nocolor, false, true, false); - out << std::endl + out << "\n" << (color ? bold.colorize (title) : title) - << std::endl; + << "\n"; // Render the completed table. Table completed; @@ -1692,11 +1693,11 @@ int handleReportTimesheet (std::string &outs) } } - out << " Completed (" << completed.rowCount () << " tasks)" << std::endl; + out << " Completed (" << completed.rowCount () << " tasks)\n"; if (completed.rowCount ()) out << completed.render () - << std::endl; + << "\n"; // Now render the started table. Table started; @@ -1753,12 +1754,11 @@ int handleReportTimesheet (std::string &outs) } } - out << " Started (" << started.rowCount () << " tasks)" << std::endl; + out << " Started (" << started.rowCount () << " tasks)\n"; if (started.rowCount ()) out << started.render () - << std::endl - << std::endl; + << "\n\n"; // Prior week. start -= 7 * 86400; @@ -2161,7 +2161,7 @@ int handleReportCalendar (std::string &outs) int details_mFrom = mFrom; std::stringstream out; - out << std::endl; + out << "\n"; while (yFrom < yTo || (yFrom == yTo && mFrom <= mTo)) { @@ -2205,10 +2205,10 @@ int handleReportCalendar (std::string &outs) } } - out << std::endl + out << "\n" << optionalBlankLine () << renderMonths (mFrom, yFrom, today, tasks, monthsPerLine) - << std::endl; + << "\n"; mFrom += monthsPerLine; if (mFrom > 12) @@ -2244,7 +2244,7 @@ int handleReportCalendar (std::string &outs) << color_weeknumber.colorize ("weeknumber") << "." << optionalBlankLine () - << std::endl; + << "\n"; if (context.config.get ("calendar.details") == "full" || context.config.get ("calendar.holidays") == "full") { @@ -2343,7 +2343,7 @@ int handleReportCalendar (std::string &outs) out << optionalBlankLine () << holTable.render () - << std::endl; + << "\n"; } }